Ignore:
Timestamp:
2009-04-24T09:32:44Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
700dcb5
Parents:
821cc93
Message:

avoid touching EGA video memory or cursor in silent mode

File:
1 edited

Legend:

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

    r821cc93 rd797054c  
    427427 * This function takes care of scrolling.
    428428 */
    429 static void ega_check_cursor(void)
     429static void ega_check_cursor(bool silent)
    430430{
    431431        if (ega_cursor < EGA_SCREEN)
    432432                return;
    433433       
    434         memmove((void *) videoram, (void *) (videoram + EGA_COLS * 2),
    435             (EGA_SCREEN - EGA_COLS) * 2);
    436434        memmove((void *) backbuf, (void *) (backbuf + EGA_COLS * 2),
    437435            (EGA_SCREEN - EGA_COLS) * 2);
    438         memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR);
    439436        memsetw(backbuf + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR);
     437       
     438        if (!silent) {
     439                memmove((void *) videoram, (void *) (videoram + EGA_COLS * 2),
     440                    (EGA_SCREEN - EGA_COLS) * 2);
     441                memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR);
     442        }
     443       
    440444        ega_cursor = ega_cursor - EGA_COLS;
    441445}
    442446
    443 static void ega_show_cursor(void)
    444 {
    445         pio_write_8(ega_base + EGA_INDEX_REG, 0x0a);
    446         uint8_t stat = pio_read_8(ega_base + EGA_DATA_REG);
    447         pio_write_8(ega_base + EGA_INDEX_REG, 0x0a);
    448         pio_write_8(ega_base + EGA_DATA_REG, stat & (~(1 << 5)));
    449 }
    450 
    451 static void ega_move_cursor(void)
    452 {
    453         pio_write_8(ega_base + EGA_INDEX_REG, 0x0e);
    454         pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff));
    455         pio_write_8(ega_base + EGA_INDEX_REG, 0x0f);
    456         pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff));
    457 }
    458 
    459 static void ega_sync_cursor(void)
    460 {
    461         pio_write_8(ega_base + EGA_INDEX_REG, 0x0e);
    462         uint8_t hi = pio_read_8(ega_base + EGA_DATA_REG);
    463         pio_write_8(ega_base + EGA_INDEX_REG, 0x0f);
    464         uint8_t lo = pio_read_8(ega_base + EGA_DATA_REG);
    465        
    466         ega_cursor = (hi << 8) | lo;
     447static void ega_show_cursor(bool silent)
     448{
     449        if (!silent) {
     450                pio_write_8(ega_base + EGA_INDEX_REG, 0x0a);
     451                uint8_t stat = pio_read_8(ega_base + EGA_DATA_REG);
     452                pio_write_8(ega_base + EGA_INDEX_REG, 0x0a);
     453                pio_write_8(ega_base + EGA_DATA_REG, stat & (~(1 << 5)));
     454        }
     455}
     456
     457static void ega_move_cursor(bool silent)
     458{
     459        if (!silent) {
     460                pio_write_8(ega_base + EGA_INDEX_REG, 0x0e);
     461                pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff));
     462                pio_write_8(ega_base + EGA_INDEX_REG, 0x0f);
     463                pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff));
     464        }
     465}
     466
     467static void ega_sync_cursor(bool silent)
     468{
     469        if (!silent) {
     470                pio_write_8(ega_base + EGA_INDEX_REG, 0x0e);
     471                uint8_t hi = pio_read_8(ega_base + EGA_DATA_REG);
     472                pio_write_8(ega_base + EGA_INDEX_REG, 0x0f);
     473                uint8_t lo = pio_read_8(ega_base + EGA_DATA_REG);
     474               
     475                ega_cursor = (hi << 8) | lo;
     476        } else
     477                ega_cursor = 0;
    467478       
    468479        if (ega_cursor >= EGA_SCREEN)
     
    472483                ega_cursor = (ega_cursor + EGA_COLS) - ega_cursor % EGA_COLS;
    473484       
    474         memsetw(videoram + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR);
    475485        memsetw(backbuf + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR);
    476486       
    477         ega_check_cursor();
    478         ega_move_cursor();
    479         ega_show_cursor();
     487        if (!silent)
     488                memsetw(videoram + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR);
     489       
     490        ega_check_cursor(silent);
     491        ega_move_cursor(silent);
     492        ega_show_cursor(silent);
    480493}
    481494
     
    526539                break;
    527540        }
    528         ega_check_cursor();
    529        
    530         if (!silent)
    531                 ega_move_cursor();
     541        ega_check_cursor(silent);
     542        ega_move_cursor(silent);
    532543       
    533544        spinlock_unlock(&egalock);
     
    553564        /* Synchronize the back buffer and cursor position. */
    554565        memcpy(backbuf, videoram, EGA_VRAM_SIZE);
    555         ega_sync_cursor();
     566        ega_sync_cursor(silent);
    556567       
    557568        outdev_initialize("ega", &ega_console, &ega_ops);
     
    569580{
    570581        memcpy(videoram, backbuf, EGA_VRAM_SIZE);
    571         ega_move_cursor();
    572         ega_show_cursor();
     582        ega_move_cursor(silent);
     583        ega_show_cursor(silent);
    573584}
    574585
Note: See TracChangeset for help on using the changeset viewer.