Couple of patches to fix an overflow, optimize a bit and support bigger resolutions using Windows 8.
Frediano Ziglio
2012-May-01 13:52 UTC
[PATCH 1/7] vgabios: Output to Xen debug port instead of using Bochs one
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- tools/firmware/vgabios/vgabios.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/firmware/vgabios/vgabios.c b/tools/firmware/vgabios/vgabios.c index a9dbe00..e0b1ed9 100644 --- a/tools/firmware/vgabios/vgabios.c +++ b/tools/firmware/vgabios/vgabios.c @@ -3811,9 +3811,9 @@ void printf(s) for (i=0; i<format_width; i++) { nibble = (arg >> (4 * digit)) & 0x000f; if (nibble <= 9) - outb(0xe9, nibble + ''0''); + outb(0x12, nibble + ''0''); else - outb(0xe9, (nibble - 10) + ''A''); + outb(0x12, (nibble - 10) + ''A''); digit--; } in_format = 0; @@ -3823,7 +3823,7 @@ void printf(s) // } } else { - outb(0xe9, c); + outb(0x12, c); } s ++; } -- 1.7.5.4
Frediano Ziglio
2012-May-01 13:52 UTC
[PATCH 2/7] vgabios: Does not define cur_mode if not required
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- tools/firmware/vgabios/vbe.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/tools/firmware/vgabios/vbe.c b/tools/firmware/vgabios/vbe.c index 3fc786d..3d42216 100644 --- a/tools/firmware/vgabios/vbe.c +++ b/tools/firmware/vgabios/vbe.c @@ -761,7 +761,9 @@ Bit16u *AX;Bit16u ES;Bit16u DI; Bit16u status; Bit16u result; Bit16u vbe2_info; +#ifdef DEBUG Bit16u cur_mode=0; +#endif Bit16u cur_ptr=34; ModeInfoListItem *cur_info=&mode_info_list; @@ -849,9 +851,9 @@ Bit16u *AX;Bit16u ES;Bit16u DI; (cur_info->info.XResolution * cur_info->info.XResolution * cur_info->info.BitsPerPixel <= vbe_info_block.TotalMemory << 19 )) { #ifdef DEBUG printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode); + cur_mode++; #endif write_word(ES, DI + cur_ptr, cur_info->mode); - cur_mode++; cur_ptr+=2; } else { #ifdef DEBUG -- 1.7.5.4
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- tools/firmware/vgabios/vbe.c | 30 ++++++++++++++++++++++++++++-- 1 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tools/firmware/vgabios/vbe.c b/tools/firmware/vgabios/vbe.c index 3d42216..35d9866 100644 --- a/tools/firmware/vgabios/vbe.c +++ b/tools/firmware/vgabios/vbe.c @@ -742,6 +742,29 @@ no_vbe_flag: jmp _display_string ASM_END +ASM_START +_size64: + push bp + mov bp, sp + push dx + +; multiply bbp by yres first as results fit in 16bits +; then multiply by xres + mov ax, 8[bp] + mul word 6[bp] + mul word 4[bp] +; divide by 2^19 ceiling result + add ax, #0xffff + adc dx, #7 + mov ax, dx + shr ax, #3 + + pop dx + pop bp + ret +ASM_END + + /** Function 00h - Return VBE Controller Information * * Input: @@ -846,9 +869,12 @@ Bit16u *AX;Bit16u ES;Bit16u DI; do { + Bit16u size_64k = size64(cur_info->info.XResolution, cur_info->info.YResolution, cur_info->info.BitsPerPixel); + Bit16u max_bpp = dispi_get_max_bpp(); + if ((cur_info->info.XResolution <= dispi_get_max_xres()) && - (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) && - (cur_info->info.XResolution * cur_info->info.XResolution * cur_info->info.BitsPerPixel <= vbe_info_block.TotalMemory << 19 )) { + (cur_info->info.BitsPerPixel <= max_bpp) && + (size_64k <= vbe_info_block.TotalMemory)) { #ifdef DEBUG printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode); cur_mode++; -- 1.7.5.4
Frediano Ziglio
2012-May-01 13:52 UTC
[PATCH 4/7] vgabios: Report mode not supported getting mode informations
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- tools/firmware/vgabios/vbe.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/firmware/vgabios/vbe.c b/tools/firmware/vgabios/vbe.c index 35d9866..fff314e 100644 --- a/tools/firmware/vgabios/vbe.c +++ b/tools/firmware/vgabios/vbe.c @@ -911,7 +911,8 @@ Bit16u *AX;Bit16u ES;Bit16u DI; void vbe_biosfn_return_mode_information(AX, CX, ES, DI) Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI; { - Bit16u result=0x0100; + // error by default is 0x014f which means supported but error + Bit16u result=0x014f; Bit16u ss=get_SS(); ModeInfoBlock info; ModeInfoListItem *cur_info; @@ -955,7 +956,6 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI; #ifdef DEBUG printf("VBE *NOT* found mode %x\n",CX); #endif - result = 0x100; } if (result == 0x4f) -- 1.7.5.4
Frediano Ziglio
2012-May-01 13:52 UTC
[PATCH 5/7] vgabios: Reduce stack usage getting mode informations
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- tools/firmware/vgabios/vbe.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/firmware/vgabios/vbe.c b/tools/firmware/vgabios/vbe.c index fff314e..0b8b736 100644 --- a/tools/firmware/vgabios/vbe.c +++ b/tools/firmware/vgabios/vbe.c @@ -914,9 +914,9 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI; // error by default is 0x014f which means supported but error Bit16u result=0x014f; Bit16u ss=get_SS(); - ModeInfoBlock info; ModeInfoListItem *cur_info; Boolean using_lfb; + ModeInfoBlockCompact info; #ifdef DEBUG printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES,DI,CX); @@ -933,7 +933,6 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI; #ifdef DEBUG printf("VBE found mode %x\n",CX); #endif - memsetb(ss, &info, 0, sizeof(ModeInfoBlock)); memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact)); if (using_lfb) { info.NumberOfBanks = 1; @@ -950,6 +949,10 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI; info.PhysBasePtr |= inw(VBE_DISPI_IOPORT_DATA); #endif result = 0x4f; + + // copy updates in mode_info_block back + memsetb(ES, DI, 0, sizeof(ModeInfoBlock)); + memcpyb(ES, DI, ss, &info, sizeof(info)); } else { @@ -957,12 +960,6 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI; printf("VBE *NOT* found mode %x\n",CX); #endif } - - if (result == 0x4f) - { - // copy updates in mode_info_block back - memcpyb(ES, DI, ss, &info, sizeof(info)); - } write_word(ss, AX, result); } -- 1.7.5.4
Frediano Ziglio
2012-May-01 13:52 UTC
[PATCH 6/7] vgabios: Check if mode is currently supported as vesa specifications
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- tools/firmware/vgabios/vbe.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/tools/firmware/vgabios/vbe.c b/tools/firmware/vgabios/vbe.c index 0b8b736..a7b06b9 100644 --- a/tools/firmware/vgabios/vbe.c +++ b/tools/firmware/vgabios/vbe.c @@ -930,10 +930,22 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI; if (cur_info != 0) { + Bit16u max_bpp = dispi_get_max_bpp(); + Bit16u size_64k; + Bit16u totalMemory; + + outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIDEO_MEMORY_64K); + totalMemory = inw(VBE_DISPI_IOPORT_DATA); #ifdef DEBUG printf("VBE found mode %x\n",CX); #endif memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact)); + size_64k = size64(info.XResolution, info.YResolution, info.BitsPerPixel); + if ((info.XResolution > dispi_get_max_xres()) || + (info.BitsPerPixel > max_bpp) || + (size_64k > totalMemory)) + info.ModeAttributes &= ~VBE_MODE_ATTRIBUTE_SUPPORTED; + if (using_lfb) { info.NumberOfBanks = 1; } -- 1.7.5.4
Frediano Ziglio
2012-May-01 13:52 UTC
[PATCH 7/7] vgabios: Make Windows 8 support greater resolutions
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- tools/firmware/vgabios/vbe.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/firmware/vgabios/vbe.c b/tools/firmware/vgabios/vbe.c index a7b06b9..9131721 100644 --- a/tools/firmware/vgabios/vbe.c +++ b/tools/firmware/vgabios/vbe.c @@ -946,9 +946,9 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI; (size_64k > totalMemory)) info.ModeAttributes &= ~VBE_MODE_ATTRIBUTE_SUPPORTED; - if (using_lfb) { - info.NumberOfBanks = 1; - } + /* Windows 8 require this to be 1! */ + info.NumberOfBanks = 1; + if (info.WinAAttributes & VBE_WINDOW_ATTRIBUTE_RELOCATABLE) { info.WinFuncPtr = 0xC0000000UL; *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall); -- 1.7.5.4
Paul Durrant
2012-May-01 14:03 UTC
Re: [PATCH 1/7] vgabios: Output to Xen debug port instead of using Bochs one
I''m confused. Last time I looked 0xE9 was the xen debug port. Paul> -----Original Message----- > From: xen-devel-bounces@lists.xen.org [mailto:xen-devel- > bounces@lists.xen.org] On Behalf Of Frediano Ziglio > Sent: 01 May 2012 14:53 > To: Frediano Ziglio; xen-devel@lists.xen.org > Subject: [Xen-devel] [PATCH 1/7] vgabios: Output to Xen debug port instead > of using Bochs one > > > Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> > --- > tools/firmware/vgabios/vgabios.c | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/tools/firmware/vgabios/vgabios.c > b/tools/firmware/vgabios/vgabios.c > index a9dbe00..e0b1ed9 100644 > --- a/tools/firmware/vgabios/vgabios.c > +++ b/tools/firmware/vgabios/vgabios.c > @@ -3811,9 +3811,9 @@ void printf(s) > for (i=0; i<format_width; i++) { > nibble = (arg >> (4 * digit)) & 0x000f; > if (nibble <= 9) > - outb(0xe9, nibble + ''0''); > + outb(0x12, nibble + ''0''); > else > - outb(0xe9, (nibble - 10) + ''A''); > + outb(0x12, (nibble - 10) + ''A''); > digit--; > } > in_format = 0; > @@ -3823,7 +3823,7 @@ void printf(s) > // } > } > else { > - outb(0xe9, c); > + outb(0x12, c); > } > s ++; > } > -- > 1.7.5.4 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Reasonably Related Threads
- [PATCH] Fix EDD pointer in int 13h, fn 48h BIOS call return buffer
- Bug#659642: xen-hypervisor-4.0-amd64: outl segfaults when restoring monitor from sleep with DPMS
- Image corruption with default X-server for Geforce 6600
- [PATCH] 4k_sector: Support dynamic sectors in GPT MBR
- [PATCH 1/2] gcov: Add script to split coverage informations.