Ignore:
File:
1 edited

Legend:

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

    rda1bafb rb366a6f4  
    4141#include <mm/slab.h>
    4242#include <arch/mm/page.h>
    43 #include <synch/spinlock.h>
    4443#include <typedefs.h>
    4544#include <arch/asm.h>
     
    6564        IRQ_SPINLOCK_DECLARE(lock);
    6665       
     66        parea_t parea;
     67       
    6768        uint32_t cursor;
    6869        uint8_t *addr;
     
    7172} ega_instance_t;
    7273
    73 static void ega_putchar(outdev_t *, wchar_t, bool);
     74static void ega_putchar(outdev_t *, wchar_t);
    7475static void ega_redraw(outdev_t *);
    7576
     
    438439 * This function takes care of scrolling.
    439440 */
    440 static void ega_check_cursor(ega_instance_t *instance, bool silent)
     441static void ega_check_cursor(ega_instance_t *instance)
    441442{
    442443        if (instance->cursor < EGA_SCREEN)
     
    449450            EGA_COLS, EMPTY_CHAR);
    450451       
    451         if (!silent) {
     452        if ((!instance->parea.mapped) || (console_override)) {
    452453                memmove((void *) instance->addr,
    453454                    (void *) (instance->addr + EGA_COLS * 2),
     
    460461}
    461462
    462 static void ega_show_cursor(ega_instance_t *instance, bool silent)
    463 {
    464         if (!silent) {
     463static void ega_show_cursor(ega_instance_t *instance)
     464{
     465        if ((!instance->parea.mapped) || (console_override)) {
    465466                pio_write_8(instance->base + EGA_INDEX_REG, 0x0a);
    466467                uint8_t stat = pio_read_8(instance->base + EGA_DATA_REG);
     
    470471}
    471472
    472 static void ega_move_cursor(ega_instance_t *instance, bool silent)
    473 {
    474         if (!silent) {
     473static void ega_move_cursor(ega_instance_t *instance)
     474{
     475        if ((!instance->parea.mapped) || (console_override)) {
    475476                pio_write_8(instance->base + EGA_INDEX_REG, 0x0e);
    476477                pio_write_8(instance->base + EGA_DATA_REG,
     
    482483}
    483484
    484 static void ega_sync_cursor(ega_instance_t *instance, bool silent)
    485 {
    486         if (!silent) {
     485static void ega_sync_cursor(ega_instance_t *instance)
     486{
     487        if ((!instance->parea.mapped) || (console_override)) {
    487488                pio_write_8(instance->base + EGA_INDEX_REG, 0x0e);
    488489                uint8_t hi = pio_read_8(instance->base + EGA_DATA_REG);
     
    504505            EGA_SCREEN - instance->cursor, EMPTY_CHAR);
    505506       
    506         if (!silent)
     507        if ((!instance->parea.mapped) || (console_override))
    507508                memsetw(instance->addr + instance->cursor * 2,
    508509                    EGA_SCREEN - instance->cursor, EMPTY_CHAR);
    509510       
    510         ega_check_cursor(instance, silent);
    511         ega_move_cursor(instance, silent);
    512         ega_show_cursor(instance, silent);
    513 }
    514 
    515 static void ega_display_char(ega_instance_t *instance, wchar_t ch, bool silent)
     511        ega_check_cursor(instance);
     512        ega_move_cursor(instance);
     513        ega_show_cursor(instance);
     514}
     515
     516static void ega_display_char(ega_instance_t *instance, wchar_t ch)
    516517{
    517518        uint16_t index = ega_oem_glyph(ch);
     
    530531        instance->backbuf[instance->cursor * 2 + 1] = style;
    531532       
    532         if (!silent) {
     533        if ((!instance->parea.mapped) || (console_override)) {
    533534                instance->addr[instance->cursor * 2] = glyph;
    534535                instance->addr[instance->cursor * 2 + 1] = style;
     
    536537}
    537538
    538 static void ega_putchar(outdev_t *dev, wchar_t ch, bool silent)
     539static void ega_putchar(outdev_t *dev, wchar_t ch)
    539540{
    540541        ega_instance_t *instance = (ega_instance_t *) dev->data;
     
    556557                break;
    557558        default:
    558                 ega_display_char(instance, ch, silent);
     559                ega_display_char(instance, ch);
    559560                instance->cursor++;
    560561                break;
    561562        }
    562         ega_check_cursor(instance, silent);
    563         ega_move_cursor(instance, silent);
     563        ega_check_cursor(instance);
     564        ega_move_cursor(instance);
    564565       
    565566        irq_spinlock_unlock(&instance->lock, true);
     
    573574       
    574575        memcpy(instance->addr, instance->backbuf, EGA_VRAM_SIZE);
    575         ega_move_cursor(instance, silent);
    576         ega_show_cursor(instance, silent);
     576        ega_move_cursor(instance);
     577        ega_show_cursor(instance);
    577578       
    578579        irq_spinlock_unlock(&instance->lock, true);
     
    613614        }
    614615       
     616        link_initialize(&instance->parea.link);
     617        instance->parea.pbase = addr;
     618        instance->parea.frames = SIZE2FRAMES(EGA_VRAM_SIZE);
     619        instance->parea.unpriv = false;
     620        instance->parea.mapped = false;
     621        ddi_parea_register(&instance->parea);
     622       
    615623        /* Synchronize the back buffer and cursor position. */
    616624        memcpy(instance->backbuf, instance->addr, EGA_VRAM_SIZE);
    617         ega_sync_cursor(instance, silent);
     625        ega_sync_cursor(instance);
    618626       
    619627        if (!fb_exported) {
    620628                /*
    621                  * This is the necessary evil until the userspace driver is entirely
    622                  * self-sufficient.
     629                 * We export the kernel framebuffer for uspace usage.
     630                 * This is used in the case the uspace framebuffer
     631                 * driver is not self-sufficient.
    623632                 */
    624633                sysinfo_set_item_val("fb", NULL, true);
Note: See TracChangeset for help on using the changeset viewer.