Changeset 9979acb in mainline for kernel/genarch/src


Ignore:
Timestamp:
2009-02-20T17:19:03Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c9b550b
Parents:
5c06c1c
Message:

make hw_area API more generic
this allows mapping of EGA VRAM on ia32/amd64

File:
1 edited

Legend:

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

    r5c06c1c r9979acb  
    2727 */
    2828
    29 /** @addtogroup genarch_drivers 
     29/** @addtogroup genarch_drivers
    3030 * @{
    3131 */
     
    6868static void ega_check_cursor(void)
    6969{
    70         if (ega_cursor < SCREEN)
     70        if (ega_cursor < EGA_SCREEN)
    7171                return;
    7272
    73         memmove((void *) videoram, (void *) (videoram + ROW * 2),
    74             (SCREEN - ROW) * 2);
    75         memmove((void *) backbuf, (void *) (backbuf + ROW * 2),
    76             (SCREEN - ROW) * 2);
    77         memsetw(videoram + (SCREEN - ROW) * 2, ROW, 0x0720);
    78         memsetw(backbuf + (SCREEN - ROW) * 2, ROW, 0x0720);
    79         ega_cursor = ega_cursor - ROW;
     73        memmove((void *) videoram, (void *) (videoram + EGA_COLS * 2),
     74            (EGA_SCREEN - EGA_COLS) * 2);
     75        memmove((void *) backbuf, (void *) (backbuf + EGA_COLS * 2),
     76            (EGA_SCREEN - EGA_COLS) * 2);
     77        memsetw(videoram + (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;
    8080}
    8181
     
    8585        pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff));
    8686        pio_write_8(ega_base + EGA_INDEX_REG, 0xf);
    87         pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff));   
     87        pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff));
    8888}
    8989
     
    105105        switch (ch) {
    106106        case '\n':
    107                 ega_cursor = (ega_cursor + ROW) - ega_cursor % ROW;
     107                ega_cursor = (ega_cursor + EGA_COLS) - ega_cursor % EGA_COLS;
    108108                break;
    109109        case '\t':
     
    111111                break;
    112112        case '\b':
    113                 if (ega_cursor % ROW)
     113                if (ega_cursor % EGA_COLS)
    114114                        ega_cursor--;
    115115                break;
     
    134134void ega_init(ioport8_t *base, uintptr_t videoram_phys)
    135135{
    136         /* Initialize the software structure. */       
     136        /* Initialize the software structure. */
    137137        ega_base = base;
    138138       
    139         backbuf = (uint8_t *) malloc(SCREEN * 2, 0);
     139        backbuf = (uint8_t *) malloc(EGA_VRAM_SIZE, 0);
    140140        if (!backbuf)
    141141                panic("Unable to allocate backbuffer.");
    142142       
    143         videoram = (uint8_t *) hw_map(videoram_phys, SCREEN * 2);
     143        videoram = (uint8_t *) hw_map(videoram_phys, EGA_VRAM_SIZE);
    144144       
    145145        /* Clear the screen and set the cursor position. */
    146         memsetw(videoram, SCREEN, 0x0720);
    147         memsetw(backbuf, SCREEN, 0x0720);
     146        memsetw(videoram, EGA_SCREEN, 0x0720);
     147        memsetw(backbuf, EGA_SCREEN, 0x0720);
    148148        ega_move_cursor();
    149149       
     
    153153        sysinfo_set_item_val("fb", NULL, true);
    154154        sysinfo_set_item_val("fb.kind", NULL, 2);
    155         sysinfo_set_item_val("fb.width", NULL, ROW);
    156         sysinfo_set_item_val("fb.height", NULL, ROWS);
     155        sysinfo_set_item_val("fb.width", NULL, EGA_COLS);
     156        sysinfo_set_item_val("fb.height", NULL, EGA_ROWS);
    157157        sysinfo_set_item_val("fb.blinking", NULL, true);
    158158        sysinfo_set_item_val("fb.address.physical", NULL, videoram_phys);
     
    161161void ega_redraw(void)
    162162{
    163         memcpy(videoram, backbuf, SCREEN * 2);
     163        memcpy(videoram, backbuf, EGA_VRAM_SIZE);
    164164        ega_move_cursor();
    165165}
Note: See TracChangeset for help on using the changeset viewer.