Changeset 018f95a in mainline for arch/ia32/src/drivers/ega.c


Ignore:
Timestamp:
2006-05-31T19:50:17Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
41d33ac
Parents:
39031cc
Message:

kernel support for text-only framebuffer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/drivers/ega.c

    r39031cc r018f95a  
    2727 */
    2828
    29 #include <arch/ega.h>
     29#include <arch/drivers/ega.h>
    3030#include <putchar.h>
    3131#include <mm/page.h>
     
    3838#include <console/chardev.h>
    3939#include <console/console.h>
     40#include <sysinfo/sysinfo.h>
    4041
    4142/*
     
    4647SPINLOCK_INITIALIZE(egalock);
    4748static __u32 ega_cursor;
     49static __u8 *videoram;
    4850
    4951static void ega_putchar(chardev_t *d, const char ch);
     
    5961{
    6062        __u8 hi, lo;
    61 
    62         page_mapping_insert(AS_KERNEL, PA2KA(VIDEORAM), VIDEORAM, PAGE_NOT_CACHEABLE);
    63         outb(0x3d4,0xe);
     63       
     64        videoram = (__u8 *) hw_map(VIDEORAM, SCREEN * 2);
     65        outb(0x3d4, 0xe);
    6466        hi = inb(0x3d5);
    65         outb(0x3d4,0xf);
     67        outb(0x3d4, 0xf);
    6668        lo = inb(0x3d5);
    67         ega_cursor = (hi<<8)|lo;
     69        ega_cursor = (hi << 8) | lo;
    6870
    6971        chardev_initialize("ega_out", &ega_console, &ega_ops);
    7072        stdout = &ega_console;
    71 
     73       
     74        sysinfo_set_item_val("fb", NULL, true);
     75        sysinfo_set_item_val("fb.kind", NULL, 2);
     76        sysinfo_set_item_val("fb.width", NULL, ROW);
     77        sysinfo_set_item_val("fb.height", NULL, ROWS);
     78        sysinfo_set_item_val("fb.address.physical", NULL, VIDEORAM);
     79       
    7280#ifndef CONFIG_FB
    7381        putchar('\n');
     
    7785static void ega_display_char(char ch)
    7886{
    79         __u8 *vram = (__u8 *) PA2KA(VIDEORAM);
    80        
    81         vram[ega_cursor*2] = ch;
     87        videoram[ega_cursor * 2] = ch;
    8288}
    8389
     
    9096                return;
    9197
    92         memcpy((void *)PA2KA(VIDEORAM), (void *)(PA2KA(VIDEORAM) + ROW*2), (SCREEN - ROW)*2);
    93         memsetw(PA2KA(VIDEORAM) + (SCREEN - ROW)*2, ROW, 0x0720);
     98        memcpy((void *) videoram, (void *) (videoram + ROW * 2), (SCREEN - ROW) * 2);
     99        memsetw((__address) (videoram + (SCREEN - ROW) * 2), ROW, 0x0720);
    94100        ega_cursor = ega_cursor - ROW;
    95101}
     
    103109
    104110        switch (ch) {
    105         case '\n':
    106                 ega_cursor = (ega_cursor + ROW) - ega_cursor % ROW;
    107                 break;
    108         case '\t':
    109                 ega_cursor = (ega_cursor + 8) - ega_cursor % 8;
    110                 break;
    111         case '\b':
    112                 if (ega_cursor % ROW)
    113                         ega_cursor--;
    114                 break;
    115         default:
    116                 ega_display_char(ch);
    117                 ega_cursor++;
    118                 break;
    119         }
     111                case '\n':
     112                        ega_cursor = (ega_cursor + ROW) - ega_cursor % ROW;
     113                        break;
     114                case '\t':
     115                        ega_cursor = (ega_cursor + 8) - ega_cursor % 8;
     116                        break;
     117                case '\b':
     118                        if (ega_cursor % ROW)
     119                                ega_cursor--;
     120                        break;
     121                default:
     122                        ega_display_char(ch);
     123                        ega_cursor++;
     124                        break;
     125        }
    120126        ega_check_cursor();
    121127        ega_move_cursor();
     
    127133void ega_move_cursor(void)
    128134{
    129         outb(0x3d4,0xe);
    130         outb(0x3d5,(ega_cursor>>8)&0xff);
    131         outb(0x3d4,0xf);
    132         outb(0x3d5,ega_cursor&0xff);   
     135        outb(0x3d4, 0xe);
     136        outb(0x3d5, (ega_cursor >> 8) & 0xff);
     137        outb(0x3d4, 0xf);
     138        outb(0x3d5, ega_cursor & 0xff);
    133139}
Note: See TracChangeset for help on using the changeset viewer.