Rev 1888 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1888 | Rev 1936 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | #include <interrupt.h> |
35 | #include <interrupt.h> |
36 | #include <console/chardev.h> |
36 | #include <console/chardev.h> |
37 | #include <arch/drivers/msim.h> |
37 | #include <arch/drivers/msim.h> |
38 | #include <arch/cp0.h> |
38 | #include <arch/cp0.h> |
39 | #include <console/console.h> |
39 | #include <console/console.h> |
- | 40 | #include <ddi/irq.h> |
|
- | 41 | #include <sysinfo/sysinfo.h> |
|
- | 42 | ||
- | 43 | /** Address of devices. */ |
|
- | 44 | #define MSIM_VIDEORAM 0xB0000000 |
|
- | 45 | #define MSIM_KBD_ADDRESS 0xB0000000 |
|
- | 46 | #define MSIM_KBD_IRQ 2 |
|
40 | 47 | ||
41 | static chardev_t console; |
48 | static chardev_t console; |
- | 49 | static irq_t msim_irq; |
|
42 | 50 | ||
43 | static void msim_write(chardev_t *dev, const char ch); |
51 | static void msim_write(chardev_t *dev, const char ch); |
44 | static void msim_enable(chardev_t *dev); |
52 | static void msim_enable(chardev_t *dev); |
45 | static void msim_disable(chardev_t *dev); |
53 | static void msim_disable(chardev_t *dev); |
46 | static char msim_do_read(chardev_t *dev); |
54 | static char msim_do_read(chardev_t *dev); |
Line 87... | Line 95... | ||
87 | } |
95 | } |
88 | } |
96 | } |
89 | } |
97 | } |
90 | 98 | ||
91 | /** Process keyboard interrupt. */ |
99 | /** Process keyboard interrupt. */ |
92 | static void msim_interrupt(int n, istate_t *istate) |
100 | static void msim_irq_handler(irq_t *irq, void *arg, ...) |
93 | { |
101 | { |
- | 102 | if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox)) |
|
- | 103 | ipc_irq_send_notif(irq); |
|
- | 104 | else { |
|
94 | char ch = 0; |
105 | char ch = 0; |
95 | 106 | ||
96 | ch = *((char *) MSIM_KBD_ADDRESS); |
107 | ch = *((char *) MSIM_KBD_ADDRESS); |
97 | if (ch =='\r') |
108 | if (ch =='\r') |
98 | ch = '\n'; |
109 | ch = '\n'; |
99 | if (ch == 0x7f) |
110 | if (ch == 0x7f) |
100 | ch = '\b'; |
111 | ch = '\b'; |
101 | chardev_push_character(&console, ch); |
112 | chardev_push_character(&console, ch); |
102 | } |
113 | } |
- | 114 | } |
|
103 | 115 | ||
104 | - | ||
105 | /* Return console object representing msim console */ |
- | |
106 | void msim_console(void) |
116 | static irq_ownership_t msim_claim(void) |
107 | { |
117 | { |
108 | chardev_initialize("msim_console", &console, &msim_ops); |
- | |
109 | - | ||
110 | int_register(MSIM_KBD_IRQ, "msim_kbd", msim_interrupt); |
- | |
111 | - | ||
112 | cp0_unmask_int(MSIM_KBD_IRQ); |
- | |
113 | - | ||
114 | stdin = &console; |
118 | return IRQ_ACCEPT; |
115 | stdout = &console; |
- | |
116 | } |
119 | } |
117 | 120 | ||
118 | static iroutine oldvector; |
- | |
119 | void msim_kbd_grab(void) |
121 | void msim_kbd_grab(void) |
120 | { |
122 | { |
121 | oldvector = int_register(MSIM_KBD_IRQ, "msim_kbd", msim_interrupt); |
123 | msim_irq.notif_cfg.notify = false; |
122 | } |
124 | } |
- | 125 | ||
123 | void msim_kbd_release(void) |
126 | void msim_kbd_release(void) |
124 | { |
127 | { |
- | 128 | if (msim_irq.notif_cfg.answerbox) |
|
- | 129 | msim_irq.notif_cfg.notify = true; |
|
- | 130 | } |
|
- | 131 | ||
- | 132 | ||
- | 133 | /* Return console object representing msim console */ |
|
- | 134 | void msim_console(devno_t devno) |
|
- | 135 | { |
|
- | 136 | chardev_initialize("msim_console", &console, &msim_ops); |
|
125 | if (oldvector) |
137 | stdin = &console; |
- | 138 | stdout = &console; |
|
- | 139 | ||
- | 140 | irq_initialize(&msim_irq); |
|
- | 141 | msim_irq.devno = devno; |
|
- | 142 | msim_irq.inr = MSIM_KBD_IRQ; |
|
- | 143 | msim_irq.claim = msim_claim; |
|
- | 144 | msim_irq.handler = msim_irq_handler; |
|
- | 145 | irq_register(&msim_irq); |
|
- | 146 | ||
- | 147 | cp0_unmask_int(MSIM_KBD_IRQ); |
|
- | 148 | ||
- | 149 | sysinfo_set_item_val("kbd", NULL, true); |
|
126 | int_register(MSIM_KBD_IRQ, "user_interrupt", oldvector); |
150 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
- | 151 | sysinfo_set_item_val("kbd.inr", NULL, MSIM_KBD_IRQ); |
|
- | 152 | sysinfo_set_item_val("kbd.address.virtual", NULL, MSIM_KBD_ADDRESS); |
|
127 | } |
153 | } |
128 | 154 | ||
129 | /** @} |
155 | /** @} |
130 | */ |
156 | */ |