X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=vgasrc%2Fvgabios.c;h=7b6c50af95051fbf513cffd4af2a2d34c5d31997;hb=refs%2Fheads%2Fcoreboot;hp=d00016685f884f9fb49e254b00c4fd4e046ef274;hpb=3876b531222c53124b0eb154fb331c0c662f5e09;p=seabios.git diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index d000166..7b6c50a 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -138,11 +138,9 @@ set_cursor_pos(struct cursorpos cp) return; // Calculate the memory address - u16 nbcols = GET_BDA(video_cols); - u16 address = (GET_BDA(video_pagesize) * cp.page - + (cp.x + cp.y * nbcols) * 2); - - stdvga_set_cursor_pos(address / 2); + int address = (GET_BDA(video_pagesize) * cp.page + + (cp.x + cp.y * GET_BDA(video_cols)) * 2); + stdvga_set_cursor_pos(address); } static struct cursorpos @@ -176,9 +174,8 @@ set_active_page(u8 page) struct cursorpos cp = get_cursor_pos(page); // Calculate memory address of start of page - u8 memmodel = GET_GLOBAL(vmode_g->memmodel); - u16 address = GET_BDA(video_pagesize) * page; - stdvga_set_active_page(memmodel == MM_TEXT ? address / 2 : address); + int address = GET_BDA(video_pagesize) * page; + vgahw_set_displaystart(vmode_g, address); // And change the BIOS page SET_BDA(video_pagestart, address); @@ -307,10 +304,10 @@ write_string(struct cursorpos *pcp, u8 attr, u16 count, u16 seg, u8 *offset_far) * Save and restore bda state ****************************************************************/ -static void +void save_bda_state(u16 seg, struct saveBDAstate *info) { - SET_FARVAR(seg, info->video_mode, GET_BDA(video_mode)); + SET_FARVAR(seg, info->video_mode, GET_BDA(vbe_mode)); SET_FARVAR(seg, info->video_cols, GET_BDA(video_cols)); SET_FARVAR(seg, info->video_pagesize, GET_BDA(video_pagesize)); SET_FARVAR(seg, info->crtc_address, GET_BDA(crtc_address)); @@ -320,7 +317,7 @@ save_bda_state(u16 seg, struct saveBDAstate *info) SET_FARVAR(seg, info->video_switches, GET_BDA(video_switches)); SET_FARVAR(seg, info->modeset_ctl, GET_BDA(modeset_ctl)); SET_FARVAR(seg, info->cursor_type, GET_BDA(cursor_type)); - u16 i; + int i; for (i=0; i<8; i++) SET_FARVAR(seg, info->cursor_pos[i], GET_BDA(cursor_pos[i])); SET_FARVAR(seg, info->video_pagestart, GET_BDA(video_pagestart)); @@ -330,12 +327,15 @@ save_bda_state(u16 seg, struct saveBDAstate *info) SET_FARVAR(seg, info->font1, GET_IVT(0x43)); } -static void +void restore_bda_state(u16 seg, struct saveBDAstate *info) { u16 mode = GET_FARVAR(seg, info->video_mode); - SET_BDA(video_mode, mode); SET_BDA(vbe_mode, mode); + if (mode < 0x100) + SET_BDA(video_mode, mode); + else + SET_BDA(video_mode, 0xff); SET_BDA(video_cols, GET_FARVAR(seg, info->video_cols)); SET_BDA(video_pagesize, GET_FARVAR(seg, info->video_pagesize)); SET_BDA(crtc_address, GET_FARVAR(seg, info->crtc_address)); @@ -345,7 +345,7 @@ restore_bda_state(u16 seg, struct saveBDAstate *info) SET_BDA(video_switches, GET_FARVAR(seg, info->video_switches)); SET_BDA(modeset_ctl, GET_FARVAR(seg, info->modeset_ctl)); SET_BDA(cursor_type, GET_FARVAR(seg, info->cursor_type)); - u16 i; + int i; for (i = 0; i < 8; i++) SET_BDA(cursor_pos[i], GET_FARVAR(seg, info->cursor_pos[i])); SET_BDA(video_pagestart, GET_FARVAR(seg, info->video_pagestart)); @@ -1133,73 +1133,37 @@ handle_101b(struct bregs *regs) static void -handle_101c00(struct bregs *regs) -{ - u16 flags = regs->cx; - u16 size = 0; - if (flags & 1) - size += sizeof(struct saveVideoHardware); - if (flags & 2) - size += sizeof(struct saveBDAstate); - if (flags & 4) - size += sizeof(struct saveDACcolors); - regs->bx = size; - regs->al = 0x1c; -} - -static void -handle_101c01(struct bregs *regs) -{ - u16 flags = regs->cx; - u16 seg = regs->es; - void *data = (void*)(regs->bx+0); - if (flags & 1) { - stdvga_save_state(seg, data); - data += sizeof(struct saveVideoHardware); - } - if (flags & 2) { - save_bda_state(seg, data); - data += sizeof(struct saveBDAstate); - } - if (flags & 4) - stdvga_save_dac_state(seg, data); - regs->al = 0x1c; -} - -static void -handle_101c02(struct bregs *regs) +handle_101c(struct bregs *regs) { - u16 flags = regs->cx; u16 seg = regs->es; void *data = (void*)(regs->bx+0); - if (flags & 1) { - stdvga_restore_state(seg, data); - data += sizeof(struct saveVideoHardware); - } - if (flags & 2) { - restore_bda_state(seg, data); - data += sizeof(struct saveBDAstate); - } - if (flags & 4) - stdvga_restore_dac_state(seg, data); - regs->al = 0x1c; -} - -static void -handle_101cXX(struct bregs *regs) -{ - debug_stub(regs); -} - -static void -handle_101c(struct bregs *regs) -{ + u16 states = regs->cx; + if (states & ~0x07) + goto fail; + int ret; switch (regs->al) { - case 0x00: handle_101c00(regs); break; - case 0x01: handle_101c01(regs); break; - case 0x02: handle_101c02(regs); break; - default: handle_101cXX(regs); break; + case 0x00: + ret = vgahw_size_state(states); + if (ret < 0) + goto fail; + regs->bx = ret / 64; + break; + case 0x01: + ret = vgahw_save_state(seg, data, states); + if (ret) + goto fail; + break; + case 0x02: + ret = vgahw_restore_state(seg, data, states); + if (ret) + goto fail; + break; + default: + goto fail; } + regs->al = 0x1c; +fail: + return; } static void @@ -1274,16 +1238,19 @@ init_bios_area(void) } int VgaBDF VAR16 = -1; +int HaveRunInit VAR16; void VISIBLE16 vga_post(struct bregs *regs) { debug_enter(regs, DEBUG_VGA_POST); - if (CONFIG_VGA_PCI) { + if (CONFIG_VGA_PCI && !GET_GLOBAL(HaveRunInit)) { u16 bdf = regs->ax; - if (pci_config_readw(bdf, PCI_VENDOR_ID) == CONFIG_VGA_VID - && pci_config_readw(bdf, PCI_DEVICE_ID) == CONFIG_VGA_DID) + if ((pci_config_readw(bdf, PCI_VENDOR_ID) + == GET_GLOBAL(rom_pci_data.vendor)) + && (pci_config_readw(bdf, PCI_DEVICE_ID) + == GET_GLOBAL(rom_pci_data.device))) SET_VGA(VgaBDF, bdf); } @@ -1293,6 +1260,9 @@ vga_post(struct bregs *regs) return; } + if (GET_GLOBAL(HaveRunInit)) + return; + init_bios_area(); SET_VGA(video_save_pointer_table.videoparam @@ -1304,6 +1274,8 @@ vga_post(struct bregs *regs) // XXX - clear screen and display info + SET_VGA(HaveRunInit, 1); + // Fixup checksum extern u8 _rom_header_size, _rom_header_checksum; SET_VGA(_rom_header_checksum, 0);