Rev 1920 | Rev 1922 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1920 | Rev 1921 | ||
|---|---|---|---|
| Line 61... | Line 61... | ||
| 61 | #include <ddi/irq.h> |
61 | #include <ddi/irq.h> |
| 62 | #include <adt/hash_table.h> |
62 | #include <adt/hash_table.h> |
| 63 | #include <arch/types.h> |
63 | #include <arch/types.h> |
| 64 | #include <typedefs.h> |
64 | #include <typedefs.h> |
| 65 | #include <synch/spinlock.h> |
65 | #include <synch/spinlock.h> |
| - | 66 | #include <atomic.h> |
|
| 66 | #include <arch.h> |
67 | #include <arch.h> |
| 67 | 68 | ||
| 68 | /** |
69 | /** |
| 69 | * Spinlock protecting the hash table. |
70 | * Spinlock protecting the hash table. |
| 70 | * This lock must be taken only when interrupts are disabled. |
71 | * This lock must be taken only when interrupts are disabled. |
| Line 125... | Line 126... | ||
| 125 | * |
126 | * |
| 126 | */ |
127 | */ |
| 127 | void irq_initialize(irq_t *irq) |
128 | void irq_initialize(irq_t *irq) |
| 128 | { |
129 | { |
| 129 | link_initialize(&irq->link); |
130 | link_initialize(&irq->link); |
| - | 131 | spinlock_initialize(&irq->lock, "irq.lock"); |
|
| 130 | irq->inr = -1; |
132 | irq->inr = -1; |
| 131 | irq->devno = -1; |
133 | irq->devno = -1; |
| 132 | irq->notif = 0; |
- | |
| 133 | irq->trigger = 0; |
134 | irq->trigger = 0; |
| 134 | irq->claim = NULL; |
135 | irq->claim = NULL; |
| 135 | irq->handler = NULL; |
136 | irq->handler = NULL; |
| 136 | irq->arg = NULL; |
137 | irq->arg = NULL; |
| - | 138 | irq->notif_answerbox = NULL; |
|
| - | 139 | irq->code = NULL; |
|
| - | 140 | atomic_set(&irq->counter, 0); |
|
| 137 | } |
141 | } |
| 138 | 142 | ||
| 139 | /** Register IRQ for device. |
143 | /** Register IRQ for device. |
| 140 | * |
144 | * |
| 141 | * The irq structure must be filled with information |
145 | * The irq structure must be filled with information |
| Line 218... | Line 222... | ||
| 218 | */ |
222 | */ |
| 219 | bool irq_ht_compare(unative_t *key, count_t keys, link_t *item) |
223 | bool irq_ht_compare(unative_t *key, count_t keys, link_t *item) |
| 220 | { |
224 | { |
| 221 | irq_t *irq = hash_table_get_instance(item, irq_t, link); |
225 | irq_t *irq = hash_table_get_instance(item, irq_t, link); |
| 222 | inr_t *inr = (inr_t *) key; |
226 | inr_t *inr = (inr_t *) key; |
| - | 227 | bool rv; |
|
| 223 | 228 | ||
| - | 229 | spinlock_lock(&irq->lock); |
|
| 224 | return ((irq->inr == *inr) && (irq->claim() == IRQ_ACCEPT)); |
230 | rv = ((irq->inr == *inr) && (irq->claim() == IRQ_ACCEPT)); |
| - | 231 | spinlock_unlock(&irq->lock); |
|
| - | 232 | ||
| - | 233 | return rv; |
|
| 225 | } |
234 | } |
| 226 | 235 | ||
| 227 | /** Compute hash index for the key. |
236 | /** Compute hash index for the key. |
| 228 | * |
237 | * |
| 229 | * This function computes hash index into |
238 | * This function computes hash index into |
| Line 257... | Line 266... | ||
| 257 | * @return True on match or false otherwise. |
266 | * @return True on match or false otherwise. |
| 258 | */ |
267 | */ |
| 259 | bool irq_lin_compare(unative_t *key, count_t keys, link_t *item) |
268 | bool irq_lin_compare(unative_t *key, count_t keys, link_t *item) |
| 260 | { |
269 | { |
| 261 | irq_t *irq = list_get_instance(item, irq_t, link); |
270 | irq_t *irq = list_get_instance(item, irq_t, link); |
| - | 271 | bool rv; |
|
| - | 272 | ||
| - | 273 | spinlock_lock(&irq->lock); |
|
| - | 274 | rv = (irq->claim() == IRQ_ACCEPT); |
|
| - | 275 | spinlock_unlock(&irq->lock); |
|
| 262 | 276 | ||
| 263 | return (irq->claim() == IRQ_ACCEPT); |
277 | return rv; |
| 264 | } |
278 | } |
| 265 | 279 | ||
| 266 | /** @} |
280 | /** @} |
| 267 | */ |
281 | */ |