Rev 4223 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4223 | Rev 4320 | ||
---|---|---|---|
Line 424... | Line 424... | ||
424 | } |
424 | } |
425 | 425 | ||
426 | /* |
426 | /* |
427 | * This function takes care of scrolling. |
427 | * This function takes care of scrolling. |
428 | */ |
428 | */ |
429 | static void ega_check_cursor(void) |
429 | static void ega_check_cursor(bool silent) |
430 | { |
430 | { |
431 | if (ega_cursor < EGA_SCREEN) |
431 | if (ega_cursor < EGA_SCREEN) |
432 | return; |
432 | return; |
433 | 433 | ||
434 | memmove((void *) videoram, (void *) (videoram + EGA_COLS * 2), |
- | |
435 | (EGA_SCREEN - EGA_COLS) * 2); |
- | |
436 | memmove((void *) backbuf, (void *) (backbuf + EGA_COLS * 2), |
434 | memmove((void *) backbuf, (void *) (backbuf + EGA_COLS * 2), |
437 | (EGA_SCREEN - EGA_COLS) * 2); |
435 | (EGA_SCREEN - EGA_COLS) * 2); |
438 | memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR); |
- | |
439 | memsetw(backbuf + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR); |
436 | 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 | ||
440 | ega_cursor = ega_cursor - EGA_COLS; |
444 | ega_cursor = ega_cursor - EGA_COLS; |
441 | } |
445 | } |
442 | 446 | ||
443 | static void ega_show_cursor(void) |
447 | static void ega_show_cursor(bool silent) |
444 | { |
448 | { |
- | 449 | if (!silent) { |
|
445 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
450 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
446 | uint8_t stat = pio_read_8(ega_base + EGA_DATA_REG); |
451 | uint8_t stat = pio_read_8(ega_base + EGA_DATA_REG); |
447 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
452 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
448 | pio_write_8(ega_base + EGA_DATA_REG, stat & (~(1 << 5))); |
453 | pio_write_8(ega_base + EGA_DATA_REG, stat & (~(1 << 5))); |
449 | } |
454 | } |
- | 455 | } |
|
450 | 456 | ||
451 | static void ega_move_cursor(void) |
457 | static void ega_move_cursor(bool silent) |
452 | { |
458 | { |
- | 459 | if (!silent) { |
|
453 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
460 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
454 | pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff)); |
461 | pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff)); |
455 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
462 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
456 | pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff)); |
463 | pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff)); |
457 | } |
464 | } |
- | 465 | } |
|
458 | 466 | ||
459 | static void ega_sync_cursor(void) |
467 | static void ega_sync_cursor(bool silent) |
460 | { |
468 | { |
- | 469 | if (!silent) { |
|
461 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
470 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
462 | uint8_t hi = pio_read_8(ega_base + EGA_DATA_REG); |
471 | uint8_t hi = pio_read_8(ega_base + EGA_DATA_REG); |
463 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
472 | pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
464 | uint8_t lo = pio_read_8(ega_base + EGA_DATA_REG); |
473 | uint8_t lo = pio_read_8(ega_base + EGA_DATA_REG); |
465 | 474 | ||
466 | ega_cursor = (hi << 8) | lo; |
475 | ega_cursor = (hi << 8) | lo; |
- | 476 | } else |
|
- | 477 | ega_cursor = 0; |
|
467 | 478 | ||
468 | if (ega_cursor >= EGA_SCREEN) |
479 | if (ega_cursor >= EGA_SCREEN) |
469 | ega_cursor = 0; |
480 | ega_cursor = 0; |
470 | 481 | ||
471 | if ((ega_cursor % EGA_COLS) != 0) |
482 | if ((ega_cursor % EGA_COLS) != 0) |
472 | ega_cursor = (ega_cursor + EGA_COLS) - ega_cursor % EGA_COLS; |
483 | ega_cursor = (ega_cursor + EGA_COLS) - ega_cursor % EGA_COLS; |
473 | 484 | ||
474 | memsetw(videoram + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR); |
- | |
475 | memsetw(backbuf + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR); |
485 | memsetw(backbuf + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR); |
476 | 486 | ||
- | 487 | if (!silent) |
|
- | 488 | memsetw(videoram + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR); |
|
- | 489 | ||
477 | ega_check_cursor(); |
490 | ega_check_cursor(silent); |
478 | ega_move_cursor(); |
491 | ega_move_cursor(silent); |
479 | ega_show_cursor(); |
492 | ega_show_cursor(silent); |
480 | } |
493 | } |
481 | 494 | ||
482 | static void ega_display_char(wchar_t ch, bool silent) |
495 | static void ega_display_char(wchar_t ch, bool silent) |
483 | { |
496 | { |
484 | uint16_t index = ega_oem_glyph(ch); |
497 | uint16_t index = ega_oem_glyph(ch); |
Line 523... | Line 536... | ||
523 | default: |
536 | default: |
524 | ega_display_char(ch, silent); |
537 | ega_display_char(ch, silent); |
525 | ega_cursor++; |
538 | ega_cursor++; |
526 | break; |
539 | break; |
527 | } |
540 | } |
528 | ega_check_cursor(); |
541 | ega_check_cursor(silent); |
529 | - | ||
530 | if (!silent) |
- | |
531 | ega_move_cursor(); |
542 | ega_move_cursor(silent); |
532 | 543 | ||
533 | spinlock_unlock(&egalock); |
544 | spinlock_unlock(&egalock); |
534 | interrupts_restore(ipl); |
545 | interrupts_restore(ipl); |
535 | } |
546 | } |
536 | 547 | ||
Line 550... | Line 561... | ||
550 | 561 | ||
551 | videoram = (uint8_t *) hw_map(videoram_phys, EGA_VRAM_SIZE); |
562 | videoram = (uint8_t *) hw_map(videoram_phys, EGA_VRAM_SIZE); |
552 | 563 | ||
553 | /* Synchronize the back buffer and cursor position. */ |
564 | /* Synchronize the back buffer and cursor position. */ |
554 | memcpy(backbuf, videoram, EGA_VRAM_SIZE); |
565 | memcpy(backbuf, videoram, EGA_VRAM_SIZE); |
555 | ega_sync_cursor(); |
566 | ega_sync_cursor(silent); |
556 | 567 | ||
557 | outdev_initialize("ega", &ega_console, &ega_ops); |
568 | outdev_initialize("ega", &ega_console, &ega_ops); |
558 | stdout = &ega_console; |
569 | stdout = &ega_console; |
559 | 570 | ||
560 | sysinfo_set_item_val("fb", NULL, true); |
571 | sysinfo_set_item_val("fb", NULL, true); |
Line 566... | Line 577... | ||
566 | } |
577 | } |
567 | 578 | ||
568 | void ega_redraw(void) |
579 | void ega_redraw(void) |
569 | { |
580 | { |
570 | memcpy(videoram, backbuf, EGA_VRAM_SIZE); |
581 | memcpy(videoram, backbuf, EGA_VRAM_SIZE); |
571 | ega_move_cursor(); |
582 | ega_move_cursor(silent); |
572 | ega_show_cursor(); |
583 | ega_show_cursor(silent); |
573 | } |
584 | } |
574 | 585 | ||
575 | /** @} |
586 | /** @} |
576 | */ |
587 | */ |