Changeset c47e1a8 in mainline for kernel/generic/src/ipc


Ignore:
Timestamp:
2010-05-21T07:50:04Z (16 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d51ee2b
Parents:
cf8cc36 (diff), 15b592b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge mainline changes (rev. 451)

Location:
kernel/generic/src/ipc
Files:
4 edited

Legend:

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

    rcf8cc36 rc47e1a8  
    3838#include <ipc/event_types.h>
    3939#include <mm/slab.h>
    40 #include <arch/types.h>
     40#include <typedefs.h>
    4141#include <synch/spinlock.h>
    4242#include <console/console.h>
  • kernel/generic/src/ipc/ipc.c

    rcf8cc36 rc47e1a8  
    218218        answerbox_t *callerbox = call->callerbox;
    219219        bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox));
     220        ipl_t ipl;
     221
     222        /* Count sent answer */
     223        ipl = interrupts_disable();
     224        spinlock_lock(&TASK->lock);
     225        TASK->ipc_info.answer_sent++;
     226        spinlock_unlock(&TASK->lock);
     227        interrupts_restore(ipl);
    220228
    221229        call->flags |= IPC_CALL_ANSWERED;
     
    276284static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call)
    277285{
     286        ipl_t ipl;
     287
     288        /* Count sent ipc call */
     289        ipl = interrupts_disable();
     290        spinlock_lock(&TASK->lock);
     291        TASK->ipc_info.call_sent++;
     292        spinlock_unlock(&TASK->lock);
     293        interrupts_restore(ipl);
     294
    278295        if (!(call->flags & IPC_CALL_FORWARDED)) {
    279296                atomic_inc(&phone->active_calls);
     
    376393int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox, int mode)
    377394{
     395        ipl_t ipl;
     396
     397        /* Count forwarded calls */
     398        ipl = interrupts_disable();
     399        spinlock_lock(&TASK->lock);
     400        TASK->ipc_info.forwarded++;
     401        spinlock_unlock(&TASK->lock);
     402        interrupts_restore(ipl);
     403
    378404        spinlock_lock(&oldbox->lock);
    379405        list_remove(&call->link);
     
    407433        call_t *request;
    408434        ipl_t ipl;
     435        uint64_t irq_cnt = 0;
     436        uint64_t answer_cnt = 0;
     437        uint64_t call_cnt = 0;
    409438        int rc;
    410439
     
    416445        spinlock_lock(&box->lock);
    417446        if (!list_empty(&box->irq_notifs)) {
     447                /* Count recieved IRQ notification */
     448                irq_cnt++;     
     449
    418450                ipl = interrupts_disable();
    419451                spinlock_lock(&box->irq_lock);
     
    425457                interrupts_restore(ipl);
    426458        } else if (!list_empty(&box->answers)) {
     459                /* Count recieved answer */
     460                answer_cnt++;
     461
    427462                /* Handle asynchronous answers */
    428463                request = list_get_instance(box->answers.next, call_t, link);
     
    430465                atomic_dec(&request->data.phone->active_calls);
    431466        } else if (!list_empty(&box->calls)) {
     467                /* Count recieved call */
     468                call_cnt++;
     469
    432470                /* Handle requests */
    433471                request = list_get_instance(box->calls.next, call_t, link);
     
    441479        }
    442480        spinlock_unlock(&box->lock);
     481       
     482        ipl = interrupts_disable();
     483        spinlock_lock(&TASK->lock);
     484        TASK->ipc_info.irq_notif_recieved += irq_cnt;
     485        TASK->ipc_info.answer_recieved += answer_cnt;
     486        TASK->ipc_info.call_recieved += call_cnt;
     487        spinlock_unlock(&TASK->lock);
     488        interrupts_restore(ipl);
     489
    443490        return request;
    444491}
     
    644691        call_t *call;
    645692        link_t *tmp;
     693        ipl_t ipl;
    646694       
     695        ipl = interrupts_disable();
    647696        spinlock_lock(&tasks_lock);
    648697        task = task_find_by_id(taskid);
     
    650699                spinlock_lock(&task->lock);
    651700        spinlock_unlock(&tasks_lock);
    652         if (!task)
     701        if (!task) {
     702                interrupts_restore(ipl);
    653703                return;
     704        }
    654705
    655706        /* Print opened phones & details */
     
    734785        spinlock_unlock(&task->answerbox.lock);
    735786        spinlock_unlock(&task->lock);
     787        interrupts_restore(ipl);
    736788}
    737789
  • kernel/generic/src/ipc/kbox.c

    rcf8cc36 rc47e1a8  
    4747void ipc_kbox_cleanup(void)
    4848{
    49         ipl_t ipl;
    5049        bool have_kb_thread;
    5150
     
    7877         * kbox thread to clean it up since sender != debugger.
    7978         */
    80         ipl = interrupts_disable();
    81         spinlock_lock(&TASK->lock);
     79        mutex_lock(&TASK->udebug.lock);
    8280        udebug_task_cleanup(TASK);
    83         spinlock_unlock(&TASK->lock);
    84         interrupts_restore(ipl);
    85        
     81        mutex_unlock(&TASK->udebug.lock);
     82
    8683        if (have_kb_thread) {
    8784                LOG("Join kb.thread.");
     
    126123        ipc_answer(&TASK->kb.box, call);
    127124
     125        mutex_lock(&TASK->kb.cleanup_lock);
     126
    128127        ipl = interrupts_disable();
    129128        spinlock_lock(&TASK->lock);
     
    136135
    137136                /* Only detach kbox thread unless already terminating. */
    138                 mutex_lock(&TASK->kb.cleanup_lock);
    139137                if (TASK->kb.finished == false) {
    140138                        /* Detach kbox thread so it gets freed from memory. */
     
    142140                        TASK->kb.thread = NULL;
    143141                }
    144                 mutex_unlock(&TASK->kb.cleanup_lock);
    145142
    146143                LOG("Phone list is empty.");
     
    153150        spinlock_unlock(&TASK->lock);
    154151        interrupts_restore(ipl);
     152
     153        mutex_unlock(&TASK->kb.cleanup_lock);
    155154}
    156155
  • kernel/generic/src/ipc/sysipc.c

    rcf8cc36 rc47e1a8  
    5858#define DATA_XFER_LIMIT         (64 * 1024)
    5959
    60 #define GET_CHECK_PHONE(phone, phoneid, err) \
    61 { \
    62         if (phoneid > IPC_MAX_PHONES) { \
    63                 err \
    64         } \
    65         phone = &TASK->phones[phoneid]; \
     60/** Get phone from the current task by ID.
     61 *
     62 * @param phoneid       Phone ID.
     63 * @param phone         Place to store pointer to phone.
     64 * @return              EOK on success, EINVAL if ID is invalid.
     65 */
     66static int phone_get(unative_t phoneid, phone_t **phone)
     67{
     68        if (phoneid >= IPC_MAX_PHONES)
     69                return EINVAL;
     70
     71        *phone = &TASK->phones[phoneid];
     72        return EOK;
    6673}
    6774
     
    374381        case IPC_M_CONNECTION_CLONE: {
    375382                phone_t *cloned_phone;
    376                 GET_CHECK_PHONE(cloned_phone, IPC_GET_ARG1(call->data),
    377                     return ENOENT;);
     383
     384                if (phone_get(IPC_GET_ARG1(call->data), &cloned_phone) != EOK)
     385                        return ENOENT;
    378386                phones_lock(cloned_phone, phone);
     387
    379388                if ((cloned_phone->state != IPC_PHONE_CONNECTED) ||
    380389                    phone->state != IPC_PHONE_CONNECTED) {
     
    534543        int res;
    535544        int rc;
    536        
    537         GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
     545
     546        if (phone_get(phoneid, &phone) != EOK)
     547                return ENOENT;
    538548
    539549        call = ipc_call_alloc(0);
     
    591601        int rc;
    592602
    593         GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
     603        if (phone_get(phoneid, &phone) != EOK)
     604                return ENOENT;
    594605
    595606        call = ipc_call_alloc(0);
     
    666677                return IPC_CALLRET_TEMPORARY;
    667678
    668         GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;);
     679        if (phone_get(phoneid, &phone) != EOK)
     680                return IPC_CALLRET_FATAL;
    669681
    670682        call = ipc_call_alloc(0);
     
    705717                return IPC_CALLRET_TEMPORARY;
    706718
    707         GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;);
     719        if (phone_get(phoneid, &phone) != EOK)
     720                return IPC_CALLRET_FATAL;
    708721
    709722        call = ipc_call_alloc(0);
     
    755768        call->flags |= IPC_CALL_FORWARDED;
    756769
    757         GET_CHECK_PHONE(phone, phoneid, {
     770        if (phone_get(phoneid, &phone) != EOK) {
    758771                IPC_SET_RETVAL(call->data, EFORWARD);
    759772                ipc_answer(&TASK->answerbox, call);
    760773                return ENOENT;
    761         });
     774        }
    762775
    763776        if (!method_is_forwardable(IPC_GET_METHOD(call->data))) {
     
    956969 * @return              Return 0 on success or an error code.
    957970 */
    958 unative_t sys_ipc_hangup(int phoneid)
     971unative_t sys_ipc_hangup(unative_t phoneid)
    959972{
    960973        phone_t *phone;
    961974
    962         GET_CHECK_PHONE(phone, phoneid, return ENOENT;);
     975        if (phone_get(phoneid, &phone) != EOK)
     976                return ENOENT;
    963977
    964978        if (ipc_phone_hangup(phone))
Note: See TracChangeset for help on using the changeset viewer.