Rev 4343 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4343 | Rev 4344 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | /** @file |
32 | /** @file |
33 | * @brief GXemul drivers. |
33 | * @brief GXemul drivers. |
34 | */ |
34 | */ |
35 | 35 | ||
36 | #include <interrupt.h> |
36 | #include <interrupt.h> |
37 | #include <ipc/irq.h> |
- | |
38 | #include <console/chardev.h> |
37 | #include <console/chardev.h> |
39 | #include <arch/drivers/gxemul.h> |
38 | #include <arch/drivers/gxemul.h> |
40 | #include <console/console.h> |
39 | #include <console/console.h> |
41 | #include <sysinfo/sysinfo.h> |
40 | #include <sysinfo/sysinfo.h> |
42 | #include <print.h> |
41 | #include <print.h> |
Line 185... | Line 184... | ||
185 | * |
184 | * |
186 | * @param irq IRQ information. |
185 | * @param irq IRQ information. |
187 | */ |
186 | */ |
188 | static void gxemul_irq_handler(irq_t *irq) |
187 | static void gxemul_irq_handler(irq_t *irq) |
189 | { |
188 | { |
190 | if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox)) { |
- | |
191 | ipc_irq_send_notif(irq); |
- | |
192 | } else { |
- | |
193 | char ch = 0; |
189 | char ch = 0; |
194 | 190 | ||
195 | ch = *((char *) gxemul_hw_map.kbd); |
191 | ch = *((char *) gxemul_hw_map.kbd); |
196 | if (ch == '\r') { |
192 | if (ch == '\r') { |
197 | ch = '\n'; |
193 | ch = '\n'; |
198 | } |
- | |
199 | if (ch == 0x7f) { |
- | |
200 | ch = '\b'; |
- | |
201 | } |
- | |
202 | chardev_push_character(&console, ch); |
- | |
203 | } |
194 | } |
- | 195 | if (ch == 0x7f) { |
|
- | 196 | ch = '\b'; |
|
- | 197 | } |
|
- | 198 | chardev_push_character(&console, ch); |
|
204 | } |
199 | } |
205 | 200 | ||
206 | static irq_ownership_t gxemul_claim(void *instance) |
201 | static irq_ownership_t gxemul_claim(irq_t *irq) |
207 | { |
202 | { |
208 | return IRQ_ACCEPT; |
203 | return IRQ_ACCEPT; |
209 | } |
204 | } |
210 | 205 | ||
211 | - | ||
212 | /** Acquire console back for kernel. */ |
- | |
213 | void gxemul_grab_console(void) |
- | |
214 | { |
- | |
215 | ipl_t ipl = interrupts_disable(); |
- | |
216 | spinlock_lock(&gxemul_console_irq.lock); |
- | |
217 | gxemul_console_irq.notif_cfg.notify = false; |
- | |
218 | spinlock_unlock(&gxemul_console_irq.lock); |
- | |
219 | interrupts_restore(ipl); |
- | |
220 | } |
- | |
221 | - | ||
222 | /** Return console to userspace. */ |
- | |
223 | void gxemul_release_console(void) |
- | |
224 | { |
- | |
225 | ipl_t ipl = interrupts_disable(); |
- | |
226 | spinlock_lock(&gxemul_console_irq.lock); |
- | |
227 | if (gxemul_console_irq.notif_cfg.answerbox) { |
- | |
228 | gxemul_console_irq.notif_cfg.notify = true; |
- | |
229 | } |
- | |
230 | spinlock_unlock(&gxemul_console_irq.lock); |
- | |
231 | interrupts_restore(ipl); |
- | |
232 | } |
- | |
233 | - | ||
234 | /** Initializes console object representing gxemul console. |
206 | /** Initializes console object representing gxemul console. |
235 | * |
207 | * |
236 | * @param devno device number. |
208 | * @param devno device number. |
237 | */ |
209 | */ |
238 | void gxemul_console_init(devno_t devno) |
210 | void gxemul_console_init(devno_t devno) |
Line 263... | Line 235... | ||
263 | static void gxemul_timer_start(uint32_t frequency) |
235 | static void gxemul_timer_start(uint32_t frequency) |
264 | { |
236 | { |
265 | *((uint32_t*) gxemul_hw_map.rtc_freq) = frequency; |
237 | *((uint32_t*) gxemul_hw_map.rtc_freq) = frequency; |
266 | } |
238 | } |
267 | 239 | ||
268 | static irq_ownership_t gxemul_timer_claim(void *instance) |
240 | static irq_ownership_t gxemul_timer_claim(irq_t *irq) |
269 | { |
241 | { |
270 | return IRQ_ACCEPT; |
242 | return IRQ_ACCEPT; |
271 | } |
243 | } |
272 | 244 | ||
273 | /** Timer interrupt handler. |
245 | /** Timer interrupt handler. |