Changeset 13a638d in mainline


Ignore:
Timestamp:
2009-04-06T19:32:22Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3636964
Parents:
149d14e5
Message:

move event notification to the ipc directory (where it probably belogs to, side-by-side to IRQ notifications)
cleanup the notification code a little bit (there is probably no need to allocate two structured dynamically)

Location:
kernel
Files:
6 edited
3 moved

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r149d14e5 r13a638d  
    162162        generic/src/ddi/device.c \
    163163        generic/src/debug/symtab.c \
    164         generic/src/event/event.c \
    165164        generic/src/interrupt/interrupt.c \
    166165        generic/src/main/main.c \
     
    215214        generic/src/ipc/ipcrsc.c \
    216215        generic/src/ipc/irq.c \
     216        generic/src/ipc/event.c \
    217217        generic/src/security/cap.c \
    218218        generic/src/sysinfo/sysinfo.c
  • kernel/generic/include/ipc/event.h

    r149d14e5 r13a638d  
    3636#define KERN_EVENT_H_
    3737
    38 #include <event/event_types.h>
     38#include <ipc/event_types.h>
    3939#include <arch/types.h>
    4040#include <synch/spinlock.h>
  • kernel/generic/src/console/cmd.c

    r149d14e5 r13a638d  
    6565#include <ipc/ipc.h>
    6666#include <ipc/irq.h>
    67 #include <event/event.h>
     67#include <ipc/event.h>
    6868#include <symtab.h>
    6969#include <errno.h>
  • kernel/generic/src/console/console.c

    r149d14e5 r13a638d  
    4242#include <ddi/irq.h>
    4343#include <ddi/ddi.h>
    44 #include <event/event.h>
     44#include <ipc/event.h>
    4545#include <ipc/irq.h>
    4646#include <arch.h>
     
    5353#include <string.h>
    5454
    55 #define KLOG_SIZE     PAGE_SIZE
    56 #define KLOG_LENGTH   (KLOG_SIZE / sizeof(wchar_t))
     55#define KLOG_PAGES    4
     56#define KLOG_LENGTH   (KLOG_PAGES * PAGE_SIZE / sizeof(wchar_t))
    5757#define KLOG_LATENCY  8
    5858
     
    9696       
    9797        ASSERT((uintptr_t) faddr % FRAME_SIZE == 0);
    98         ASSERT(KLOG_SIZE % FRAME_SIZE == 0);
    9998       
    10099        klog_parea.pbase = (uintptr_t) faddr;
     
    103102       
    104103        sysinfo_set_item_val("klog.faddr", NULL, (unative_t) faddr);
    105         sysinfo_set_item_val("klog.pages", NULL, SIZE2FRAMES(sizeof(klog)));
     104        sysinfo_set_item_val("klog.pages", NULL, KLOG_PAGES);
    106105       
    107106        spinlock_lock(&klog_lock);
  • kernel/generic/src/ipc/event.c

    r149d14e5 r13a638d  
    3232/**
    3333 * @file
    34  * @brief       Kernel event notifications.
     34 * @brief Kernel event notifications.
    3535 */
    3636
    37 #include <event/event.h>
    38 #include <event/event_types.h>
     37#include <ipc/event.h>
     38#include <ipc/event_types.h>
    3939#include <mm/slab.h>
    4040#include <arch/types.h>
     
    5050 * likelyhood of cacheline ping-pong.
    5151 */
    52 static event_t *events[EVENT_END];
     52static event_t events[EVENT_END];
    5353
    5454/** Initialize kernel events. */
    5555void event_init(void)
    5656{
    57         int i;
    58 
     57        unsigned int i;
     58       
    5959        for (i = 0; i < EVENT_END; i++) {
    60                 events[i] = (event_t *) malloc(sizeof(event_t), 0);
    61                 spinlock_initialize(&events[i]->lock, "event.lock");
    62                 events[i]->answerbox = NULL;
    63                 events[i]->counter = 0;
    64                 events[i]->method = 0;
     60                spinlock_initialize(&events[i].lock, "event.lock");
     61                events[i].answerbox = NULL;
     62                events[i].counter = 0;
     63                events[i].method = 0;
    6564        }
    6665}
    6766
    6867static int
    69 event_subscribe(event_type_t e, unative_t method, answerbox_t *answerbox)
     68event_subscribe(event_type_t evno, unative_t method, answerbox_t *answerbox)
    7069{
    71         if (e >= EVENT_END)
     70        if (evno >= EVENT_END)
    7271                return ELIMIT;
    73 
    74         int res = EEXISTS;
    75         event_t *event = events[e];
    76 
    77         spinlock_lock(&event->lock);
    78         if (!event->answerbox) {
    79                 event->answerbox = answerbox;
    80                 event->method = method;
    81                 event->counter = 0;
     72       
     73        spinlock_lock(&events[evno].lock);
     74       
     75        int res;
     76       
     77        if (events[evno].answerbox == NULL) {
     78                events[evno].answerbox = answerbox;
     79                events[evno].method = method;
     80                events[evno].counter = 0;
    8281                res = EOK;
    83         }
    84         spinlock_unlock(&event->lock);
    85 
     82        } else
     83                res = EEXISTS;
     84       
     85        spinlock_unlock(&events[evno].lock);
     86       
    8687        return res;
    8788}
     
    9394}
    9495
    95 bool event_is_subscribed(event_type_t e)
     96bool event_is_subscribed(event_type_t evno)
    9697{
    9798        bool res;
    98 
    99         ASSERT(e < EVENT_END);
    100         spinlock_lock(&events[e]->lock);
    101         res = events[e]->answerbox != NULL;
    102         spinlock_unlock(&events[e]->lock);
    103 
     99       
     100        ASSERT(evno < EVENT_END);
     101       
     102        spinlock_lock(&events[evno].lock);
     103        res = events[evno].answerbox != NULL;
     104        spinlock_unlock(&events[evno].lock);
     105       
    104106        return res;
    105107}
     
    108110void event_cleanup_answerbox(answerbox_t *answerbox)
    109111{
    110         int i;
    111 
     112        unsigned int i;
     113       
    112114        for (i = 0; i < EVENT_END; i++) {
    113                 spinlock_lock(&events[i]->lock);
    114                 if (events[i]->answerbox == answerbox) {
    115                         events[i]->answerbox = NULL;
    116                         events[i]->counter = 0;
    117                         events[i]->method = 0;
     115                spinlock_lock(&events[i].lock);
     116                if (events[i].answerbox == answerbox) {
     117                        events[i].answerbox = NULL;
     118                        events[i].counter = 0;
     119                        events[i].method = 0;
    118120                }
    119                 spinlock_unlock(&events[i]->lock);
     121                spinlock_unlock(&events[i].lock);
    120122        }
    121123}
    122124
    123125void
    124 event_notify(event_type_t e, unative_t a1, unative_t a2, unative_t a3,
     126event_notify(event_type_t evno, unative_t a1, unative_t a2, unative_t a3,
    125127    unative_t a4, unative_t a5)
    126128{
    127         ASSERT(e < EVENT_END);
    128         event_t *event = events[e];
    129         spinlock_lock(&event->lock);
    130         if (event->answerbox) {
     129        ASSERT(evno < EVENT_END);
     130       
     131        spinlock_lock(&events[evno].lock);
     132        if (events[evno].answerbox != NULL) {
    131133                call_t *call = ipc_call_alloc(FRAME_ATOMIC);
    132134                if (call) {
    133135                        call->flags |= IPC_CALL_NOTIF;
    134                         call->priv = ++event->counter;
    135                         IPC_SET_METHOD(call->data, event->method);
     136                        call->priv = ++events[evno].counter;
     137                        IPC_SET_METHOD(call->data, events[evno].method);
    136138                        IPC_SET_ARG1(call->data, a1);
    137139                        IPC_SET_ARG2(call->data, a2);
     
    139141                        IPC_SET_ARG4(call->data, a4);
    140142                        IPC_SET_ARG5(call->data, a5);
    141 
    142                         spinlock_lock(&event->answerbox->irq_lock);
    143                         list_append(&call->link, &event->answerbox->irq_notifs);
    144                         spinlock_unlock(&event->answerbox->irq_lock);
    145 
    146                         waitq_wakeup(&event->answerbox->wq, WAKEUP_FIRST);
     143                       
     144                        spinlock_lock(&events[evno].answerbox->irq_lock);
     145                        list_append(&call->link, &events[evno].answerbox->irq_notifs);
     146                        spinlock_unlock(&events[evno].answerbox->irq_lock);
     147                       
     148                        waitq_wakeup(&events[evno].answerbox->wq, WAKEUP_FIRST);
    147149                }
    148150        }
    149         spinlock_unlock(&event->lock);
     151        spinlock_unlock(&events[evno].lock);
    150152}
    151153
  • kernel/generic/src/ipc/ipc.c

    r149d14e5 r13a638d  
    4545#include <ipc/ipc.h>
    4646#include <ipc/kbox.h>
    47 #include <event/event.h>
     47#include <ipc/event.h>
    4848#include <errno.h>
    4949#include <mm/slab.h>
     
    5252#include <memstr.h>
    5353#include <debug.h>
    54 
    55 
    5654#include <print.h>
    5755#include <console/console.h>
  • kernel/generic/src/main/main.c

    r149d14e5 r13a638d  
    3333/**
    3434 * @file
    35  * @brief       Main initialization kernel function for all processors.
     35 * @brief Main initialization kernel function for all processors.
    3636 *
    3737 * During kernel boot, all processors, after architecture dependent
     
    8383#include <ddi/ddi.h>
    8484#include <main/main.h>
    85 #include <event/event.h>
     85#include <ipc/event.h>
    8686
    8787/** Global configuration structure. */
  • kernel/generic/src/syscall/syscall.c

    r149d14e5 r13a638d  
    4949#include <synch/smc.h>
    5050#include <ddi/ddi.h>
    51 #include <event/event.h>
     51#include <ipc/event.h>
    5252#include <security/cap.h>
    5353#include <sysinfo/sysinfo.h>
Note: See TracChangeset for help on using the changeset viewer.