Changeset c214a65 in mainline


Ignore:
Timestamp:
2009-02-27T13:30:20Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dbaaf0a
Parents:
c1f7f6ea
Message:

keep original contents of the EGA framebuffer,
make sure the cursor is on

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/drivers/ega/ega.c

    rc1f7f6ea rc214a65  
    8080}
    8181
     82static 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
    8290static void ega_move_cursor(void)
    8391{
    84         pio_write_8(ega_base + EGA_INDEX_REG, 0xe);
     92        pio_write_8(ega_base + EGA_INDEX_REG, 0x0e);
    8593        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);
    8795        pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff));
     96}
     97
     98static 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();
    88112}
    89113
     
    143167        videoram = (uint8_t *) hw_map(videoram_phys, EGA_VRAM_SIZE);
    144168       
    145         /* Clear the screen and set the cursor position. */
    146         memsetw(videoram, EGA_SCREEN, 0x0720);
    147         memsetw(backbuf, EGA_SCREEN, 0x0720);
    148         ega_move_cursor();
     169        /* Synchronize the back buffer and cursor position. */
     170        memcpy(backbuf, videoram, EGA_VRAM_SIZE);
     171        ega_sync_cursor();
    149172       
    150173        chardev_initialize("ega_out", &ega_console, &ega_ops);
     
    163186        memcpy(videoram, backbuf, EGA_VRAM_SIZE);
    164187        ega_move_cursor();
     188        ega_show_cursor();
    165189}
    166190
Note: See TracChangeset for help on using the changeset viewer.