Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1920 → Rev 1921

/trunk/kernel/generic/include/ddi/irq.h
37,6 → 37,10
 
#include <arch/types.h>
#include <adt/list.h>
#include <ipc/ipc.h>
#include <ipc/irq.h>
#include <atomic.h>
#include <synch/spinlock.h>
 
typedef enum {
IRQ_DECLINE, /**< Decline to service. */
62,13 → 66,18
/** Hash table link. */
link_t link;
 
/** Lock protecting everything in this structure
* except the link member. When both the IRQ
* hash table lock and this lock are to be acquired,
* this lock must not be taken first.
*/
SPINLOCK_DECLARE(lock);
 
/** Unique device number. -1 if not yet assigned. */
devno_t devno;
 
/** Actual IRQ number. -1 if not yet assigned. */
inr_t inr;
/** Task ID of the task to be notified about the IRQ or 0. */
task_id_t notif;
/** Trigger level of the IRQ.*/
irq_trigger_t trigger;
/** Claim ownership of the IRQ. */
77,6 → 86,14
irq_handler_t handler;
/** Argument for the handler. */
void *arg;
 
/** Answerbox of the task that wanted to be notified. */
answerbox_t *notif_answerbox;
/** Pseudo-code to be performed by the top-half
* before a notification is sent. */
irq_code_t *code;
/** Counter of IRQ notifications. */
atomic_t counter;
};
 
extern void irq_init(count_t inrs, count_t chains);
/trunk/kernel/generic/src/ddi/irq.c
63,6 → 63,7
#include <arch/types.h>
#include <typedefs.h>
#include <synch/spinlock.h>
#include <atomic.h>
#include <arch.h>
 
/**
127,13 → 128,16
void irq_initialize(irq_t *irq)
{
link_initialize(&irq->link);
spinlock_initialize(&irq->lock, "irq.lock");
irq->inr = -1;
irq->devno = -1;
irq->notif = 0;
irq->trigger = 0;
irq->claim = NULL;
irq->handler = NULL;
irq->arg = NULL;
irq->notif_answerbox = NULL;
irq->code = NULL;
atomic_set(&irq->counter, 0);
}
 
/** Register IRQ for device.
220,8 → 224,13
{
irq_t *irq = hash_table_get_instance(item, irq_t, link);
inr_t *inr = (inr_t *) key;
bool rv;
return ((irq->inr == *inr) && (irq->claim() == IRQ_ACCEPT));
spinlock_lock(&irq->lock);
rv = ((irq->inr == *inr) && (irq->claim() == IRQ_ACCEPT));
spinlock_unlock(&irq->lock);
 
return rv;
}
 
/** Compute hash index for the key.
259,8 → 268,13
bool irq_lin_compare(unative_t *key, count_t keys, link_t *item)
{
irq_t *irq = list_get_instance(item, irq_t, link);
bool rv;
return (irq->claim() == IRQ_ACCEPT);
spinlock_lock(&irq->lock);
rv = (irq->claim() == IRQ_ACCEPT);
spinlock_unlock(&irq->lock);
return rv;
}
 
/** @}