VGABIOS patches
Couple of patches to fix an overflow, optimize a bit and support bigger resolutions using Windows 8.
PATCH 1/7 vgabios: Output to Xen debug port instead of using Bochs one
--- tools/firmware/vgabios/vgabios.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
tools/firmware/vgabios/vgabios.c +3 -3
@@ -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 ++; }
Signature · 1 line
1.7.5.4
PATCH 2/7 vgabios: Does not define cur_mode if not required
In reply to Frediano Ziglio--- tools/firmware/vgabios/vbe.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
tools/firmware/vgabios/vbe.c +3 -1
@@ -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
Signature · 1 line
1.7.5.4
PATCH 3/7 vgabios: Fix size computation overflow
In reply to Frediano Ziglio--- tools/firmware/vgabios/vbe.c | 30 ++++++++++++++++++++++++++++-- 1 files changed, 28 insertions(+), 2 deletions(-)
tools/firmware/vgabios/vbe.c +28 -2
@@ -742,6 +742,29 @@ no_vbe_flag: jmp _display_stringASM_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++;
Signature · 1 line
1.7.5.4
PATCH 4/7 vgabios: Report mode not supported getting mode informations
In reply to Frediano Ziglio--- tools/firmware/vgabios/vbe.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
tools/firmware/vgabios/vbe.c +2 -2
@@ -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 )
Signature · 1 line
1.7.5.4
PATCH 5/7 vgabios: Reduce stack usage getting mode informations
In reply to Frediano Ziglio--- tools/firmware/vgabios/vbe.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
tools/firmware/vgabios/vbe.c +5 -8
@@ -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); }
Signature · 1 line
1.7.5.4
PATCH 6/7 vgabios: Check if mode is currently supported as vesa specifications
In reply to Frediano Ziglio--- tools/firmware/vgabios/vbe.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
tools/firmware/vgabios/vbe.c +12 -0
@@ -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 ; }
Signature · 1 line
1.7.5.4
PATCH 7/7 vgabios: Make Windows 8 support greater resolutions
In reply to Frediano Ziglio--- tools/firmware/vgabios/vbe.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
tools/firmware/vgabios/vbe.c +3 -3
@@ -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);
Signature · 1 line
1.7.5.4
Re: [PATCH 1/7] vgabios: Output to Xen debug port instead of using Bochs one
In reply to Frediano ZiglioI'm confused. Last time I looked 0xE9 was the xen debug port.
Paul
Quoted 48 lines
-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Frediano Ziglio
Sent: 01 May 2012 14:53
To: Frediano Ziglio; [email protected]
Subject: [Xen-devel] [PATCH 1/7] vgabios: Output to Xen debug port instead of using Bochs oneSigned-off-by Frediano Ziglio <[email protected]>--- tools/firmware/vgabios/vgabios.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)tools/firmware/vgabios/vgabios.c +3
-4@@ -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
[email protected]
http://lists.xen.org/xen-devel