Rev 3975 | Rev 4093 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3975 | Rev 3994 | ||
|---|---|---|---|
| Line 58... | Line 58... | ||
| 58 | static uint32_t ega_cursor; |
58 | static uint32_t ega_cursor; |
| 59 | static uint8_t *videoram; |
59 | static uint8_t *videoram; |
| 60 | static uint8_t *backbuf; |
60 | static uint8_t *backbuf; |
| 61 | static ioport8_t *ega_base; |
61 | static ioport8_t *ega_base; |
| 62 | 62 | ||
| - | 63 | #define EMPTY_CHAR 0x0720 |
|
| - | 64 | ||
| 63 | chardev_t ega_console; |
65 | chardev_t ega_console; |
| 64 | 66 | ||
| 65 | /* |
67 | /* |
| 66 | * This function takes care of scrolling. |
68 | * This function takes care of scrolling. |
| 67 | */ |
69 | */ |
| 68 | static void ega_check_cursor(void) |
70 | static void ega_check_cursor(void) |
| 69 | { |
71 | { |
| 70 | if (ega_cursor < EGA_SCREEN) |
72 | if (ega_cursor < EGA_SCREEN) |
| 71 | return; |
73 | return; |
| 72 | 74 | ||
| 73 | memmove((void *) videoram, (void *) (videoram + EGA_COLS * 2), |
75 | memmove((void *) videoram, (void *) (videoram + EGA_COLS * 2), |
| 74 | (EGA_SCREEN - EGA_COLS) * 2); |
76 | (EGA_SCREEN - EGA_COLS) * 2); |
| 75 | memmove((void *) backbuf, (void *) (backbuf + EGA_COLS * 2), |
77 | memmove((void *) backbuf, (void *) (backbuf + EGA_COLS * 2), |
| 76 | (EGA_SCREEN - EGA_COLS) * 2); |
78 | (EGA_SCREEN - EGA_COLS) * 2); |
| 77 | memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, 0x0720); |
79 | memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR); |
| 78 | memsetw(backbuf + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, 0x0720); |
80 | memsetw(backbuf + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR); |
| 79 | ega_cursor = ega_cursor - EGA_COLS; |
81 | ega_cursor = ega_cursor - EGA_COLS; |
| 80 | } |
82 | } |
| 81 | 83 | ||
| 82 | static void ega_show_cursor(void) |
84 | static void ega_show_cursor(void) |
| 83 | { |
85 | { |
| Line 101... | Line 103... | ||
| 101 | uint8_t hi = pio_read_8(ega_base + EGA_DATA_REG); |
103 | uint8_t hi = pio_read_8(ega_base + EGA_DATA_REG); |
| 102 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
104 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
| 103 | uint8_t lo = pio_read_8(ega_base + EGA_DATA_REG); |
105 | uint8_t lo = pio_read_8(ega_base + EGA_DATA_REG); |
| 104 | 106 | ||
| 105 | ega_cursor = (hi << 8) | lo; |
107 | ega_cursor = (hi << 8) | lo; |
| - | 108 | ||
| - | 109 | if (ega_cursor >= EGA_SCREEN) |
|
| - | 110 | ega_cursor = 0; |
|
| - | 111 | ||
| 106 | if ((ega_cursor % EGA_COLS) != 0) |
112 | if ((ega_cursor % EGA_COLS) != 0) |
| 107 | ega_cursor = (ega_cursor + EGA_COLS) - ega_cursor % EGA_COLS; |
113 | ega_cursor = (ega_cursor + EGA_COLS) - ega_cursor % EGA_COLS; |
| 108 | 114 | ||
| - | 115 | memsetw(videoram + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR); |
|
| - | 116 | memsetw(backbuf + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR); |
|
| - | 117 | ||
| 109 | ega_check_cursor(); |
118 | ega_check_cursor(); |
| 110 | ega_move_cursor(); |
119 | ega_move_cursor(); |
| 111 | ega_show_cursor(); |
120 | ega_show_cursor(); |
| 112 | } |
121 | } |
| 113 | 122 | ||
| Line 117... | Line 126... | ||
| 117 | 126 | ||
| 118 | if (!silent) |
127 | if (!silent) |
| 119 | videoram[ega_cursor * 2] = ch; |
128 | videoram[ega_cursor * 2] = ch; |
| 120 | } |
129 | } |
| 121 | 130 | ||
| 122 | static void ega_putchar(chardev_t *d __attribute__((unused)), const char ch, bool silent) |
131 | static void ega_putchar(chardev_t *dev __attribute__((unused)), const char ch, bool silent) |
| 123 | { |
132 | { |
| 124 | ipl_t ipl; |
133 | ipl_t ipl; |
| 125 | 134 | ||
| 126 | ipl = interrupts_disable(); |
135 | ipl = interrupts_disable(); |
| 127 | spinlock_lock(&egalock); |
136 | spinlock_lock(&egalock); |