X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=vgasrc%2Fvbe.c;h=505cb61cbea902c352b195ec2e9258e041c93ecc;hb=refs%2Fheads%2Fcoreboot;hp=d7dd8b4086e2d1adee29b83d305e2b5f49958308;hpb=b3df857fe6d3fffb108379637ea4a456ce6e09ba;p=seabios.git diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c index d7dd8b4..505cb61 100644 --- a/vgasrc/vbe.c +++ b/vgasrc/vbe.c @@ -1,6 +1,7 @@ // Video Bios Extensions handlers // -// Copyright (C) 2009 Kevin O'Connor +// Copyright (C) 2012 Kevin O'Connor +// Copyright (C) 2011 Julian Pidancet // Copyright (C) 2001-2008 the LGPL VGABios developers Team // // This file may be distributed under the terms of the GNU LGPLv3 license. @@ -100,30 +101,27 @@ vbe_104f01(struct bregs *regs) SET_FARVAR(seg, info->winB_attributes, 0); SET_FARVAR(seg, info->win_granularity, GET_GLOBAL(VBE_win_granularity)); SET_FARVAR(seg, info->win_size, 64); /* Bank size 64K */ - SET_FARVAR(seg, info->winA_seg, SEG_GRAPH); + SET_FARVAR(seg, info->winA_seg, GET_GLOBAL(vmode_g->sstart)); SET_FARVAR(seg, info->winB_seg, 0x0); - SET_FARVAR(seg, info->win_func_ptr.segoff, 0x0); + extern void entry_104f05(void); + SET_FARVAR(seg, info->win_func_ptr + , SEGOFF(get_global_seg(), (u32)entry_104f05)); int width = GET_GLOBAL(vmode_g->width); int height = GET_GLOBAL(vmode_g->height); - int linesize = width * DIV_ROUND_UP(depth, 8); + int linesize = DIV_ROUND_UP(width * vga_bpp(vmode_g), 8); SET_FARVAR(seg, info->bytes_per_scanline, linesize); SET_FARVAR(seg, info->xres, width); SET_FARVAR(seg, info->yres, height); - SET_FARVAR(seg, info->xcharsize, 8); - SET_FARVAR(seg, info->ycharsize, 16); - if (depth == 4) - SET_FARVAR(seg, info->planes, 4); - else - SET_FARVAR(seg, info->planes, 1); + SET_FARVAR(seg, info->xcharsize, GET_GLOBAL(vmode_g->cwidth)); + SET_FARVAR(seg, info->ycharsize, GET_GLOBAL(vmode_g->cheight)); + int planes = (depth == 4) ? 4 : 1; + SET_FARVAR(seg, info->planes, planes); SET_FARVAR(seg, info->bits_per_pixel, depth); SET_FARVAR(seg, info->banks, 1); SET_FARVAR(seg, info->mem_model, GET_GLOBAL(vmode_g->memmodel)); SET_FARVAR(seg, info->bank_size, 0); u32 pages = GET_GLOBAL(VBE_total_memory) / (height * linesize); - if (depth == 4) - SET_FARVAR(seg, info->pages, (pages / 4) - 1); - else - SET_FARVAR(seg, info->pages, pages - 1); + SET_FARVAR(seg, info->pages, (pages / planes) - 1); SET_FARVAR(seg, info->reserved0, 1); u8 r_size, r_pos, g_size, g_pos, b_size, b_pos, a_size, a_pos; @@ -184,9 +182,9 @@ vbe_104f02(struct bregs *regs) { dprintf(1, "VBE mode set: %x\n", regs->bx); - int mode = regs->bx & 0x1ff; - int flags = regs->bx & (MF_CUSTOMCRTC|MF_LINEARFB|MF_NOCLEARMEM); - int ret = vgahw_set_mode(mode, flags); + int mode = regs->bx & ~MF_VBEFLAGS; + int flags = regs->bx & MF_VBEFLAGS; + int ret = vga_set_mode(mode, flags); regs->ah = ret; regs->al = 0x4f; @@ -195,48 +193,169 @@ vbe_104f02(struct bregs *regs) static void vbe_104f03(struct bregs *regs) { - u16 mode = GET_BDA(vbe_mode); - if (!mode) - regs->bx = GET_BDA(video_mode); - + regs->bx = GET_BDA(vbe_mode); dprintf(1, "VBE current mode=%x\n", regs->bx); - regs->ax = 0x004f; } static void vbe_104f04(struct bregs *regs) { - debug_stub(regs); - regs->ax = 0x0100; + u16 seg = regs->es; + void *data = (void*)(regs->bx+0); + u16 states = regs->cx; + if (states & ~0x0f) + goto fail; + int ret; + switch (regs->dl) { + 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->ax = 0x004f; + return; +fail: + regs->ax = 0x014f; } -static void +void VISIBLE16 vbe_104f05(struct bregs *regs) { - debug_stub(regs); + if (regs->bh > 1 || regs->bl > 1) + goto fail; + if (GET_BDA(vbe_mode) & MF_LINEARFB) { + regs->ah = VBE_RETURN_STATUS_INVALID; + return; + } + struct vgamode_s *vmode_g = get_current_mode(); + if (! vmode_g) + goto fail; + if (regs->bh) { + int ret = vgahw_get_window(vmode_g, regs->bl); + if (ret < 0) + goto fail; + regs->dx = ret; + regs->ax = 0x004f; + return; + } + int ret = vgahw_set_window(vmode_g, regs->bl, regs->dx); + if (ret) + goto fail; + regs->ax = 0x004f; + return; +fail: regs->ax = 0x0100; } static void vbe_104f06(struct bregs *regs) { - debug_stub(regs); - regs->ax = 0x0100; + if (regs->bl > 0x02) + goto fail; + struct vgamode_s *vmode_g = get_current_mode(); + if (! vmode_g) + goto fail; + int bpp = vga_bpp(vmode_g); + + if (regs->bl == 0x00) { + int ret = vgahw_set_linelength(vmode_g, DIV_ROUND_UP(regs->cx * bpp, 8)); + if (ret) + goto fail; + } else if (regs->bl == 0x02) { + int ret = vgahw_set_linelength(vmode_g, regs->cx); + if (ret) + goto fail; + } + int linelength = vgahw_get_linelength(vmode_g); + if (linelength < 0) + goto fail; + + regs->bx = linelength; + regs->cx = (linelength * 8) / bpp; + regs->dx = GET_GLOBAL(VBE_total_memory) / linelength; + regs->ax = 0x004f; + return; +fail: + regs->ax = 0x014f; } static void vbe_104f07(struct bregs *regs) { - debug_stub(regs); - regs->ax = 0x0100; + struct vgamode_s *vmode_g = get_current_mode(); + if (! vmode_g) + goto fail; + int bpp = vga_bpp(vmode_g); + int linelength = vgahw_get_linelength(vmode_g); + if (linelength < 0) + goto fail; + + int ret; + switch (regs->bl) { + case 0x80: + case 0x00: + ret = vgahw_set_displaystart( + vmode_g, DIV_ROUND_UP(regs->cx * bpp, 8) + linelength * regs->dx); + if (ret) + goto fail; + break; + case 0x01: + ret = vgahw_get_displaystart(vmode_g); + if (ret < 0) + goto fail; + regs->dx = ret / linelength; + regs->cx = (ret % linelength) * 8 / bpp; + break; + default: + goto fail; + } + regs->ax = 0x004f; + return; +fail: + regs->ax = 0x014f; } static void vbe_104f08(struct bregs *regs) { - debug_stub(regs); - regs->ax = 0x0100; + struct vgamode_s *vmode_g = get_current_mode(); + if (! vmode_g) + goto fail; + u8 memmodel = GET_GLOBAL(vmode_g->memmodel); + if (memmodel == MM_DIRECT || memmodel == MM_YUV) { + regs->ax = 0x034f; + return; + } + if (regs->bl > 1) + goto fail; + if (regs->bl == 0) { + int ret = vgahw_set_dacformat(vmode_g, regs->bh); + if (ret < 0) + goto fail; + } + int ret = vgahw_get_dacformat(vmode_g); + if (ret < 0) + goto fail; + regs->bh = ret; + regs->ax = 0x004f; + return; +fail: + regs->ax = 0x014f; } static void @@ -246,6 +365,26 @@ vbe_104f0a(struct bregs *regs) regs->ax = 0x0100; } +static void +vbe_104f10(struct bregs *regs) +{ + switch (regs->bl) { + case 0x00: + regs->bx = 0x0f30; + break; + case 0x01: + SET_BDA(vbe_flag, regs->bh); + break; + case 0x02: + regs->bh = GET_BDA(vbe_flag); + break; + default: + regs->ax = 0x014f; + return; + } + regs->ax = 0x004f; +} + static void vbe_104fXX(struct bregs *regs) { @@ -272,6 +411,7 @@ handle_104f(struct bregs *regs) case 0x07: vbe_104f07(regs); break; case 0x08: vbe_104f08(regs); break; case 0x0a: vbe_104f0a(regs); break; + case 0x10: vbe_104f10(regs); break; default: vbe_104fXX(regs); break; } }