Changeset 05ffb41 in mainline for kernel/generic/src/ipc/ipc.c


Ignore:
Timestamp:
2017-08-17T19:11:14Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1c85bae
Parents:
7e3826d9
Message:

Turn IPC phones into kobjects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ipc.c

    r7e3826d9 r05ffb41  
    4343#include <synch/waitq.h>
    4444#include <ipc/ipc.h>
     45#include <ipc/ipcrsc.h>
    4546#include <abi/ipc/methods.h>
    4647#include <ipc/kbox.h>
     
    740741         * Locking is needed as there may be connection handshakes in progress.
    741742         */
    742         for (i = 0; i < IPC_MAX_PHONES; i++) {
    743                 phone_t *phone = &TASK->phones[i];
    744 
    745                 mutex_lock(&phone->lock);       
     743        for (i = 0; i < MAX_KERNEL_OBJECTS; i++) {
     744                phone_t *phone = phone_get_current(i);
     745                if (!phone)
     746                        continue;
     747
     748                mutex_lock(&phone->lock);
    746749                if ((phone->state == IPC_PHONE_HUNGUP) &&
    747750                    (atomic_get(&phone->active_calls) == 0)) {
     
    784787               
    785788        /* Got into cleanup */
    786         if (i == IPC_MAX_PHONES)
     789        if (i == MAX_KERNEL_OBJECTS)
    787790                return;
    788791               
     
    816819
    817820        /* Disconnect all our phones ('ipc_phone_hangup') */
    818         for (size_t i = 0; i < IPC_MAX_PHONES; i++)
    819                 ipc_phone_hangup(&TASK->phones[i]);
     821        for (int i = 0; i < MAX_KERNEL_OBJECTS; i++) {
     822                phone_t *phone = phone_get_current(i);
     823                if (!phone)
     824                        continue;
     825                ipc_phone_hangup(phone);
     826        }
    820827       
    821828        /* Unsubscribe from any event notifications. */
     
    903910        irq_spinlock_exchange(&tasks_lock, &task->lock);
    904911       
    905         printf("[phone id] [calls] [state\n");
     912        printf("[phone cap] [calls] [state\n");
    906913       
    907914        size_t i;
    908         for (i = 0; i < IPC_MAX_PHONES; i++) {
    909                 if (SYNCH_FAILED(mutex_trylock(&task->phones[i].lock))) {
     915        for (i = 0; i < MAX_KERNEL_OBJECTS; i++) {
     916                phone_t *phone = phone_get(task, i);
     917                if (!phone)
     918                        continue;
     919
     920                if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {
    910921                        printf("%-10zu (mutex busy)\n", i);
    911922                        continue;
    912923                }
    913924               
    914                 if (task->phones[i].state != IPC_PHONE_FREE) {
    915                         printf("%-10zu %7" PRIun " ", i,
    916                             atomic_get(&task->phones[i].active_calls));
     925                if (phone->state != IPC_PHONE_FREE) {
     926                        printf("%-11zu %7" PRIun " ", i,
     927                            atomic_get(&phone->active_calls));
    917928                       
    918                         switch (task->phones[i].state) {
     929                        switch (phone->state) {
    919930                        case IPC_PHONE_CONNECTING:
    920931                                printf("connecting");
     
    922933                        case IPC_PHONE_CONNECTED:
    923934                                printf("connected to %" PRIu64 " (%s)",
    924                                     task->phones[i].callee->task->taskid,
    925                                     task->phones[i].callee->task->name);
     935                                    phone->callee->task->taskid,
     936                                    phone->callee->task->name);
    926937                                break;
    927938                        case IPC_PHONE_SLAMMED:
    928                                 printf("slammed by %p",
    929                                     task->phones[i].callee);
     939                                printf("slammed by %p", phone->callee);
    930940                                break;
    931941                        case IPC_PHONE_HUNGUP:
    932                                 printf("hung up by %p",
    933                                     task->phones[i].callee);
     942                                printf("hung up by %p", phone->callee);
    934943                                break;
    935944                        default:
     
    940949                }
    941950               
    942                 mutex_unlock(&task->phones[i].lock);
     951                mutex_unlock(&phone->lock);
    943952        }
    944953       
Note: See TracChangeset for help on using the changeset viewer.