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