Rev 2131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2131 | Rev 2456 | ||
---|---|---|---|
Line 42... | Line 42... | ||
42 | #include <ddi/irq.h> |
42 | #include <ddi/irq.h> |
43 | #include <ipc/irq.h> |
43 | #include <ipc/irq.h> |
44 | #include <proc/thread.h> |
44 | #include <proc/thread.h> |
45 | #include <synch/spinlock.h> |
45 | #include <synch/spinlock.h> |
46 | #include <arch/asm.h> |
46 | #include <arch/asm.h> |
- | 47 | #include <synch/rcu.h> |
|
47 | 48 | ||
48 | #define SKI_KBD_INR 0 |
49 | #define SKI_KBD_INR 0 |
49 | 50 | ||
50 | static irq_t ski_kbd_irq; |
51 | static irq_t ski_kbd_irq; |
51 | static devno_t ski_kbd_devno; |
52 | static devno_t ski_kbd_devno; |
Line 140... | Line 141... | ||
140 | 141 | ||
141 | ch = ski_getchar(); |
142 | ch = ski_getchar(); |
142 | if(ch == '\r') |
143 | if(ch == '\r') |
143 | ch = '\n'; |
144 | ch = '\n'; |
144 | if (ch) { |
145 | if (ch) { |
145 | if (ski_kbd_irq.notif_cfg.notify && ski_kbd_irq.notif_cfg.answerbox) { |
146 | if (rcu_dereference_pointer(ski_kbd_irq.notif_cfg).notify && rcu_dereference_pointer(ski_kbd_irq.notif_cfg).answerbox) { |
146 | chardev_push_character(&ski_uconsole, ch); |
147 | chardev_push_character(&ski_uconsole, ch); |
147 | ipc_irq_send_notif(&ski_kbd_irq); |
148 | ipc_irq_send_notif(&ski_kbd_irq); |
148 | } else { |
149 | } else { |
149 | chardev_push_character(&ski_console, ch); |
150 | chardev_push_character(&ski_console, ch); |
150 | } |
151 | } |
Line 153... | Line 154... | ||
153 | interrupts_restore(ipl); |
154 | interrupts_restore(ipl); |
154 | return; |
155 | return; |
155 | } |
156 | } |
156 | 157 | ||
157 | if (last) { |
158 | if (last) { |
158 | if (ski_kbd_irq.notif_cfg.notify && ski_kbd_irq.notif_cfg.answerbox) { |
159 | if (rcu_dereference_pointer(ski_kbd_irq.notif_cfg).notify && rcu_dereference_pointer(ski_kbd_irq.notif_cfg).answerbox) { |
159 | chardev_push_character(&ski_uconsole, 0); |
160 | chardev_push_character(&ski_uconsole, 0); |
160 | ipc_irq_send_notif(&ski_kbd_irq); |
161 | ipc_irq_send_notif(&ski_kbd_irq); |
161 | } |
162 | } |
162 | last = 0; |
163 | last = 0; |
163 | } |
164 | } |
Line 230... | Line 231... | ||
230 | } |
231 | } |
231 | 232 | ||
232 | void ski_kbd_grab(void) |
233 | void ski_kbd_grab(void) |
233 | { |
234 | { |
234 | ipl_t ipl = interrupts_disable(); |
235 | ipl_t ipl = interrupts_disable(); |
235 | spinlock_lock(&ski_kbd_irq.lock); |
236 | //rcu_read_lock() is not needed, ints are disabled |
236 | ski_kbd_irq.notif_cfg.notify = false; |
237 | //rcu: atomic update doesn't need reallocation |
237 | spinlock_unlock(&ski_kbd_irq.lock); |
238 | rcu_dereference_pointer(ski_kbd_irq.notif_cfg).notify = false; |
238 | interrupts_restore(ipl); |
239 | interrupts_restore(ipl); |
239 | } |
240 | } |
240 | 241 | ||
241 | void ski_kbd_release(void) |
242 | void ski_kbd_release(void) |
242 | { |
243 | { |
243 | ipl_t ipl = interrupts_disable(); |
244 | ipl_t ipl = interrupts_disable(); |
- | 245 | //rcu: atomic update doesn't need reallocation |
|
244 | spinlock_lock(&ski_kbd_irq.lock); |
246 | spinlock_lock(&ski_kbd_irq.lock); |
245 | if (ski_kbd_irq.notif_cfg.answerbox) |
247 | if (rcu_dereference_pointer(ski_kbd_irq.notif_cfg).answerbox) |
246 | ski_kbd_irq.notif_cfg.notify = true; |
248 | rcu_dereference_pointer(ski_kbd_irq.notif_cfg).notify = true; |
247 | spinlock_unlock(&ski_kbd_irq.lock); |
249 | spinlock_unlock(&ski_kbd_irq.lock); |
248 | interrupts_restore(ipl); |
250 | interrupts_restore(ipl); |
249 | } |
251 | } |
250 | 252 | ||
251 | 253 |