Changeset 691eb52 in mainline for kernel/generic/src/ddi/irq.c


Ignore:
Timestamp:
2009-02-24T13:30:47Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c0855a0
Parents:
5b0ae4be
Message:

switch between the preference of kernel/uspace IRQ hash table

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ddi/irq.c

    r5b0ae4be r691eb52  
    7373#include <arch/types.h>
    7474#include <synch/spinlock.h>
     75#include <console/console.h>
    7576#include <memstr.h>
    7677#include <arch.h>
     
    194195}
    195196
    196 /** Dispatch the IRQ.
    197  *
    198  * We assume this function is only called from interrupt
    199  * context (i.e. that interrupts are disabled prior to
    200  * this call).
    201  *
    202  * This function attempts to lookup a fitting IRQ
    203  * structure. In case of success, return with interrupts
    204  * disabled and holding the respective structure.
    205  *
    206  * @param inr Interrupt number (aka inr or irq).
    207  *
    208  * @return IRQ structure of the respective device or NULL.
    209  */
    210 irq_t *irq_dispatch_and_lock(inr_t inr)
     197/** Search and lock the uspace IRQ hash table.
     198 *
     199 */
     200static irq_t *irq_dispatch_and_lock_uspace(inr_t inr)
    211201{
    212202        link_t *lnk;
    213203        unative_t key[] = {
    214204                (unative_t) inr,
    215                 (unative_t) -1          /* search will use claim() instead of devno */
     205                (unative_t) -1    /* search will use claim() instead of devno */
    216206        };
    217207       
    218         /*
    219          * Try uspace handlers first.
    220          */
    221208        spinlock_lock(&irq_uspace_hash_table_lock);
    222209        lnk = hash_table_find(&irq_uspace_hash_table, key);
     
    229216        }
    230217        spinlock_unlock(&irq_uspace_hash_table_lock);
    231 
    232         /*
    233          * Fallback to kernel handlers.
    234          */
     218       
     219        return NULL;
     220}
     221
     222/** Search and lock the kernel IRQ hash table.
     223 *
     224 */
     225static irq_t *irq_dispatch_and_lock_kernel(inr_t inr)
     226{
     227        link_t *lnk;
     228        unative_t key[] = {
     229                (unative_t) inr,
     230                (unative_t) -1    /* search will use claim() instead of devno */
     231        };
     232       
    235233        spinlock_lock(&irq_kernel_hash_table_lock);
    236234        lnk = hash_table_find(&irq_kernel_hash_table, key);
     
    243241        }
    244242        spinlock_unlock(&irq_kernel_hash_table_lock);
    245 
    246         return NULL;   
     243       
     244        return NULL;
     245}
     246
     247/** Dispatch the IRQ.
     248 *
     249 * We assume this function is only called from interrupt
     250 * context (i.e. that interrupts are disabled prior to
     251 * this call).
     252 *
     253 * This function attempts to lookup a fitting IRQ
     254 * structure. In case of success, return with interrupts
     255 * disabled and holding the respective structure.
     256 *
     257 * @param inr Interrupt number (aka inr or irq).
     258 *
     259 * @return IRQ structure of the respective device or NULL.
     260 */
     261irq_t *irq_dispatch_and_lock(inr_t inr)
     262{
     263        irq_t *irq;
     264       
     265        /*
     266         * If the kernel console is silenced,
     267         * then try first the uspace handlers,
     268         * eventually fall back to kernel handlers.
     269         *
     270         * If the kernel console is active,
     271         * then do it the other way around.
     272         */
     273        if (silent) {
     274                irq = irq_dispatch_and_lock_uspace(inr);
     275                if (irq)
     276                        return irq;
     277                return irq_dispatch_and_lock_kernel(inr);
     278        }
     279       
     280        irq = irq_dispatch_and_lock_kernel(inr);
     281        if (irq)
     282                return irq;
     283        return irq_dispatch_and_lock_uspace(inr);
    247284}
    248285
Note: See TracChangeset for help on using the changeset viewer.