Rev 3940 | Rev 3994 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3940 | Rev 3975 | ||
---|---|---|---|
Line 77... | Line 77... | ||
77 | memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, 0x0720); |
77 | memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, 0x0720); |
78 | memsetw(backbuf + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, 0x0720); |
78 | memsetw(backbuf + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, 0x0720); |
79 | ega_cursor = ega_cursor - EGA_COLS; |
79 | ega_cursor = ega_cursor - EGA_COLS; |
80 | } |
80 | } |
81 | 81 | ||
- | 82 | static void ega_show_cursor(void) |
|
- | 83 | { |
|
- | 84 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
|
- | 85 | uint8_t stat = pio_read_8(ega_base + EGA_DATA_REG); |
|
- | 86 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
|
- | 87 | pio_write_8(ega_base + EGA_DATA_REG, stat & (~(1 << 5))); |
|
- | 88 | } |
|
- | 89 | ||
82 | static void ega_move_cursor(void) |
90 | static void ega_move_cursor(void) |
83 | { |
91 | { |
84 | pio_write_8(ega_base + EGA_INDEX_REG, 0xe); |
92 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
85 | pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff)); |
93 | pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff)); |
86 | pio_write_8(ega_base + EGA_INDEX_REG, 0xf); |
94 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
87 | pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff)); |
95 | pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff)); |
88 | } |
96 | } |
89 | 97 | ||
- | 98 | static void ega_sync_cursor(void) |
|
- | 99 | { |
|
- | 100 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
|
- | 101 | uint8_t hi = pio_read_8(ega_base + EGA_DATA_REG); |
|
- | 102 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
|
- | 103 | uint8_t lo = pio_read_8(ega_base + EGA_DATA_REG); |
|
- | 104 | ||
- | 105 | ega_cursor = (hi << 8) | lo; |
|
- | 106 | if ((ega_cursor % EGA_COLS) != 0) |
|
- | 107 | ega_cursor = (ega_cursor + EGA_COLS) - ega_cursor % EGA_COLS; |
|
- | 108 | ||
- | 109 | ega_check_cursor(); |
|
- | 110 | ega_move_cursor(); |
|
- | 111 | ega_show_cursor(); |
|
- | 112 | } |
|
- | 113 | ||
90 | static void ega_display_char(char ch, bool silent) |
114 | static void ega_display_char(char ch, bool silent) |
91 | { |
115 | { |
92 | backbuf[ega_cursor * 2] = ch; |
116 | backbuf[ega_cursor * 2] = ch; |
93 | 117 | ||
94 | if (!silent) |
118 | if (!silent) |
Line 140... | Line 164... | ||
140 | if (!backbuf) |
164 | if (!backbuf) |
141 | panic("Unable to allocate backbuffer."); |
165 | panic("Unable to allocate backbuffer."); |
142 | 166 | ||
143 | videoram = (uint8_t *) hw_map(videoram_phys, EGA_VRAM_SIZE); |
167 | videoram = (uint8_t *) hw_map(videoram_phys, EGA_VRAM_SIZE); |
144 | 168 | ||
145 | /* Clear the screen and set the cursor position. */ |
169 | /* Synchronize the back buffer and cursor position. */ |
146 | memsetw(videoram, EGA_SCREEN, 0x0720); |
170 | memcpy(backbuf, videoram, EGA_VRAM_SIZE); |
147 | memsetw(backbuf, EGA_SCREEN, 0x0720); |
- | |
148 | ega_move_cursor(); |
171 | ega_sync_cursor(); |
149 | 172 | ||
150 | chardev_initialize("ega_out", &ega_console, &ega_ops); |
173 | chardev_initialize("ega_out", &ega_console, &ega_ops); |
151 | stdout = &ega_console; |
174 | stdout = &ega_console; |
152 | 175 | ||
153 | sysinfo_set_item_val("fb", NULL, true); |
176 | sysinfo_set_item_val("fb", NULL, true); |
Line 160... | Line 183... | ||
160 | 183 | ||
161 | void ega_redraw(void) |
184 | void ega_redraw(void) |
162 | { |
185 | { |
163 | memcpy(videoram, backbuf, EGA_VRAM_SIZE); |
186 | memcpy(videoram, backbuf, EGA_VRAM_SIZE); |
164 | ega_move_cursor(); |
187 | ega_move_cursor(); |
- | 188 | ega_show_cursor(); |
|
165 | } |
189 | } |
166 | 190 | ||
167 | /** @} |
191 | /** @} |
168 | */ |
192 | */ |