Rev 606 | Rev 958 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 606 | Rev 607 | ||
|---|---|---|---|
| Line 35... | Line 35... | ||
| 35 | static chardev_t console; |
35 | static chardev_t console; |
| 36 | 36 | ||
| 37 | static void msim_write(chardev_t *dev, const char ch); |
37 | static void msim_write(chardev_t *dev, const char ch); |
| 38 | static void msim_enable(chardev_t *dev); |
38 | static void msim_enable(chardev_t *dev); |
| 39 | static void msim_disable(chardev_t *dev); |
39 | static void msim_disable(chardev_t *dev); |
| - | 40 | static char msim_do_read(chardev_t *dev); |
|
| 40 | 41 | ||
| 41 | static chardev_operations_t msim_ops = { |
42 | static chardev_operations_t msim_ops = { |
| 42 | .resume = msim_enable, |
43 | .resume = msim_enable, |
| 43 | .suspend = msim_disable, |
44 | .suspend = msim_disable, |
| 44 | .write = msim_write |
45 | .write = msim_write, |
| - | 46 | .read = msim_do_read, |
|
| 45 | }; |
47 | }; |
| 46 | 48 | ||
| 47 | /** Putchar that works with MSIM & gxemul */ |
49 | /** Putchar that works with MSIM & gxemul */ |
| 48 | void msim_write(chardev_t *dev, const char ch) |
50 | void msim_write(chardev_t *dev, const char ch) |
| 49 | { |
51 | { |
| Line 61... | Line 63... | ||
| 61 | { |
63 | { |
| 62 | cp0_mask_int(MSIM_KBD_IRQ); |
64 | cp0_mask_int(MSIM_KBD_IRQ); |
| 63 | } |
65 | } |
| 64 | 66 | ||
| 65 | #include <print.h> |
67 | #include <print.h> |
| - | 68 | /** Read character using polling, assume interrupts disabled */ |
|
| - | 69 | static char msim_do_read(chardev_t *dev) |
|
| - | 70 | { |
|
| - | 71 | char ch; |
|
| - | 72 | ||
| - | 73 | while (1) { |
|
| - | 74 | ch = *((volatile char *) MSIM_KBD_ADDRESS); |
|
| - | 75 | if (ch) { |
|
| - | 76 | if (ch == '\r') |
|
| - | 77 | return '\n'; |
|
| - | 78 | if (ch == 0x7f) |
|
| - | 79 | return '\b'; |
|
| - | 80 | return ch; |
|
| - | 81 | } |
|
| - | 82 | } |
|
| - | 83 | } |
|
| - | 84 | ||
| 66 | /** Process keyboard interrupt. */ |
85 | /** Process keyboard interrupt. */ |
| 67 | static void msim_interrupt(int n, void *stack) |
86 | static void msim_interrupt(int n, void *stack) |
| 68 | { |
87 | { |
| 69 | char ch; |
88 | char ch = 0; |
| 70 | 89 | ||
| 71 | ch = *((char *) MSIM_KBD_ADDRESS); |
90 | ch = *((char *) MSIM_KBD_ADDRESS); |
| 72 | if (ch =='\r') |
91 | if (ch =='\r') |
| 73 | ch = '\n'; |
92 | ch = '\n'; |
| 74 | if (ch == 0x7f) |
93 | if (ch == 0x7f) |