Changeset 874621f in mainline for generic/src/ipc/irq.c


Ignore:
Timestamp:
2006-06-06T07:40:51Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0dbc4e7
Parents:
6f9a9bc
Message:

Added kernel circular buffer klog.
Added automatic killing of tasks raising inappropriate exceptions.
TODO Fix vsnprintf return value(and behaviour according to specs) and remove workaround in klog.

File:
1 edited

Legend:

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

    r6f9a9bc r874621f  
    157157{
    158158        ipl_t ipl;
     159        int mq = irq + IPC_IRQ_RESERVED_VIRTUAL;
    159160
    160161        ipl = interrupts_disable();
    161         spinlock_lock(&irq_conns[irq].lock);
    162         if (irq_conns[irq].box == box) {
    163                 irq_conns[irq].box = NULL;
    164                 code_free(irq_conns[irq].code);
    165                 irq_conns[irq].code = NULL;
    166         }
    167 
    168         spinlock_unlock(&irq_conns[irq].lock);
     162        spinlock_lock(&irq_conns[mq].lock);
     163        if (irq_conns[mq].box == box) {
     164                irq_conns[mq].box = NULL;
     165                code_free(irq_conns[mq].code);
     166                irq_conns[mq].code = NULL;
     167        }
     168
     169        spinlock_unlock(&irq_conns[mq].lock);
    169170        interrupts_restore(ipl);
    170171}
     
    175176        ipl_t ipl;
    176177        irq_code_t *code;
     178        int mq = irq + IPC_IRQ_RESERVED_VIRTUAL;
    177179
    178180        ASSERT(irq_conns);
     
    186188
    187189        ipl = interrupts_disable();
    188         spinlock_lock(&irq_conns[irq].lock);
    189 
    190         if (irq_conns[irq].box) {
    191                 spinlock_unlock(&irq_conns[irq].lock);
     190        spinlock_lock(&irq_conns[mq].lock);
     191
     192        if (irq_conns[mq].box) {
     193                spinlock_unlock(&irq_conns[mq].lock);
    192194                interrupts_restore(ipl);
    193195                code_free(code);
    194196                return EEXISTS;
    195197        }
    196         irq_conns[irq].box = box;
    197         irq_conns[irq].code = code;
    198         atomic_set(&irq_conns[irq].counter, 0);
    199         spinlock_unlock(&irq_conns[irq].lock);
     198        irq_conns[mq].box = box;
     199        irq_conns[mq].code = code;
     200        atomic_set(&irq_conns[mq].counter, 0);
     201        spinlock_unlock(&irq_conns[mq].lock);
    200202        interrupts_restore(ipl);
    201203
     
    203205}
    204206
    205 /** Notify process that an irq had happend
    206  *
    207  * We expect interrupts to be disabled
    208  */
    209 void ipc_irq_send_notif(int irq)
     207/** Add call to proper answerbox queue
     208 *
     209 * Assume irq_conns[mq].lock is locked */
     210static void send_call(int mq, call_t *call)
     211{
     212        spinlock_lock(&irq_conns[mq].box->irq_lock);
     213        list_append(&call->link, &irq_conns[mq].box->irq_notifs);
     214        spinlock_unlock(&irq_conns[mq].box->irq_lock);
     215               
     216        waitq_wakeup(&irq_conns[mq].box->wq, 0);
     217}
     218
     219/** Send notification message
     220 *
     221 */
     222void ipc_irq_send_msg(int irq, __native a2, __native a3)
    210223{
    211224        call_t *call;
    212 
    213         ASSERT(irq_conns);
    214         spinlock_lock(&irq_conns[irq].lock);
    215 
    216         if (irq_conns[irq].box) {
     225        int mq = irq + IPC_IRQ_RESERVED_VIRTUAL;
     226
     227        spinlock_lock(&irq_conns[mq].lock);
     228
     229        if (irq_conns[mq].box) {
    217230                call = ipc_call_alloc(FRAME_ATOMIC);
    218231                if (!call) {
    219                         spinlock_unlock(&irq_conns[irq].lock);
     232                        spinlock_unlock(&irq_conns[mq].lock);
    220233                        return;
    221234                }
     
    223236                IPC_SET_METHOD(call->data, IPC_M_INTERRUPT);
    224237                IPC_SET_ARG1(call->data, irq);
    225                 IPC_SET_ARG3(call->data, atomic_preinc(&irq_conns[irq].counter));
     238                IPC_SET_ARG2(call->data, a2);
     239                IPC_SET_ARG3(call->data, a3);
     240               
     241                send_call(mq, call);
     242        }
     243        spinlock_unlock(&irq_conns[mq].lock);
     244}
     245
     246/** Notify process that an irq had happend
     247 *
     248 * We expect interrupts to be disabled
     249 */
     250void ipc_irq_send_notif(int irq)
     251{
     252        call_t *call;
     253        int mq = irq + IPC_IRQ_RESERVED_VIRTUAL;
     254
     255        ASSERT(irq_conns);
     256        spinlock_lock(&irq_conns[mq].lock);
     257
     258        if (irq_conns[mq].box) {
     259                call = ipc_call_alloc(FRAME_ATOMIC);
     260                if (!call) {
     261                        spinlock_unlock(&irq_conns[mq].lock);
     262                        return;
     263                }
     264                call->flags |= IPC_CALL_NOTIF;
     265                IPC_SET_METHOD(call->data, IPC_M_INTERRUPT);
     266                IPC_SET_ARG1(call->data, irq);
     267                IPC_SET_ARG3(call->data, atomic_preinc(&irq_conns[mq].counter));
    226268
    227269                /* Execute code to handle irq */
    228                 code_execute(call, irq_conns[irq].code);
    229 
    230                 spinlock_lock(&irq_conns[irq].box->irq_lock);
    231                 list_append(&call->link, &irq_conns[irq].box->irq_notifs);
    232                 spinlock_unlock(&irq_conns[irq].box->irq_lock);
    233 
    234                 waitq_wakeup(&irq_conns[irq].box->wq, 0);
    235         }
     270                code_execute(call, irq_conns[mq].code);
    236271               
    237         spinlock_unlock(&irq_conns[irq].lock);
    238 }
    239 
    240 
    241 /** Initialize table of interrupt handlers */
     272                send_call(mq, call);
     273        }
     274               
     275        spinlock_unlock(&irq_conns[mq].lock);
     276}
     277
     278
     279/** Initialize table of interrupt handlers
     280 *
     281 * @param irqcount Count of required hardware IRQs to be supported
     282 */
    242283void ipc_irq_make_table(int irqcount)
    243284{
    244285        int i;
     286
     287        irqcount +=  IPC_IRQ_RESERVED_VIRTUAL;
    245288
    246289        irq_conns_size = irqcount;
Note: See TracChangeset for help on using the changeset viewer.