diff options
author | Volker Ruppert <info@vruppert.de> | 2004-05-08 16:05:41 +0000 |
---|---|---|
committer | Volker Ruppert <info@vruppert.de> | 2004-05-08 16:05:41 +0000 |
commit | 852a0fc4cc087d010121a617df689348b2c56ddc (patch) | |
tree | 4e59a589c30bc207d46333d0a0db9bf34ae25b0b | |
parent | 508c43c4e1ff195fcfa876a8316e36505c0c5da7 (diff) | |
download | vgabios-852a0fc4cc087d010121a617df689348b2c56ddc.tar.gz |
- VBE internal functions dispi_set_enable and dispi_set_bank now called both from C and asm code
- VBE function 0x03 rewritten in assembler
- VBE function 0x08 cleaned up
- text output and scroll functions for graphics modes rewritten using case structures
- documentation and comments updated
-rw-r--r-- | BUGS | 6 | ||||
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | TODO | 28 | ||||
-rw-r--r-- | vbe.c | 124 | ||||
-rw-r--r-- | vbe.h | 2 | ||||
-rw-r--r-- | vbe_display_api.txt | 7 | ||||
-rw-r--r-- | vgabios.c | 158 |
7 files changed, 147 insertions, 187 deletions
@@ -1,9 +1,3 @@ -The code is quite new, and testing has been very minimal. Not all the functions have been implemented yet. -From an implemented point of view, these should be working but do not : -- 43/50 lines switching -- cursor shape seems broken (volker) - - Please report any bugs to <cbothamy@free.fr> @@ -15,12 +15,12 @@ To compile the VGA Bios you will need : - as86 - ld86 -Untar the archive, and type make. You should get a "vgabios.bin" file. -Alternatively, you can use the binary file "vgabios-XXX.bin", i have -compiled for you. +Untar the archive, and type make. You should get a "VGABIOS-lgpl-latest.bin" +file. Alternatively, you can use the binary file "VGABIOS-lgpl-latest.bin", +i have compiled for you. Edit your plex86/bochs conf file, and modify the load-rom command in the -VGA BIOS section, to point to the new vgabios.bin file. +VGA BIOS section, to point to the new vgabios image file. Debugging @@ -38,7 +38,6 @@ Testing Look at the "testvga.c" file in the archive. This is a minimal Turbo C 2.0 source file that calls a few int10 functions. Feel free to modify it to suit your needs. -The VGA Bios in its current version has been very little tested. Copyright and License @@ -6,49 +6,25 @@ General - Add new functionalities and modify static functionality table - Performance : 16 bits IO -v0.4 - - Implement the remaining functions : - - chargen ax=1100, ax=1101, ax=1102, ax=1103, ax=1104, ax=1110, - ax=1111, ax=1112, ax=1120, ax=1121, ax=1122, ax=1123, ax=1124 - v0.5 - Reimplement the tables so it is compatible with the video save pointer table - Implement the remaining functions (don't know if all are needed): - - set border ah=0b bh=00, set cga palette ah=0b bh=01, + - chargen ax=1120, ax=1121, ax=1122, ax=1123, ax=1124 - display switch interface ah=12 bl=35 - video refresh control ah=12 bl=36 - save/restore state ah=1c v0.6 - Graphic modes - - Implement the remaining functions : - - read/write graphic pixel ah=0c, ah=0d, - + v1.0 - Bugfixes -Long term : ------------ - -v2.0 - - upload the fonts to the "card" memory - - display fonts from the "card" memory (plex86/bochs vga card needs update) - ================================================================================================= VBE: ---- -Short term: -- bugfixes for bochs 1.4(+) support -- implement remaining functions that can be done with DISPI 0xb0c0 interface - (get functions for mode?, window) - Long term: -- extend DISPI interface (see also bochs bug [ 529554 ] unsupported VBE features DISPI update) - . clear / preserve display memory upon set vbe - . set/get logical scanline length (4f06) - . set/get display start (4f07) - have plex86 host side display interface -- support more modi (16bit/32bit modi support) - have text io functions in vbe mode @@ -30,7 +30,7 @@ // defines available -// enable LFB support (depends upon bochs-vbe-lfb patch) +// enable LFB support #define VBE_HAVE_LFB // disable VESA/VBE2 check in vbe info @@ -200,28 +200,32 @@ static Bit16u dispi_get_max_bpp() return max_bpp; } -static Bit16u dispi_get_enable() -{ - outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); - return inw(VBE_DISPI_IOPORT_DATA); -} - -void dispi_set_enable(enable) - Bit16u enable; -{ - outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); - outw(VBE_DISPI_IOPORT_DATA,enable); -} +ASM_START +_dispi_set_enable: + push dx + push ax + mov dx, # VBE_DISPI_IOPORT_INDEX + mov ax, # VBE_DISPI_INDEX_ENABLE + out dx, ax + pop ax + mov dx, # VBE_DISPI_IOPORT_DATA + out dx, ax + pop dx + ret -static void dispi_set_bank(bank) - Bit16u bank; -{ - outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BANK); - outw(VBE_DISPI_IOPORT_DATA,bank); -} +dispi_get_enable: + push dx + mov dx, # VBE_DISPI_IOPORT_INDEX + mov ax, # VBE_DISPI_INDEX_ENABLE + out dx, ax + mov dx, # VBE_DISPI_IOPORT_DATA + in ax, dx + pop dx + ret +ASM_END ASM_START -dispi_set_bank: +_dispi_set_bank: push dx push ax mov dx, # VBE_DISPI_IOPORT_INDEX @@ -726,27 +730,28 @@ Bit16u *AX;Bit16u BX; Bit16u ES;Bit16u DI; * BX = Current VBE Mode * */ -void vbe_biosfn_return_current_mode(AX, BX) -Bit16u *AX;Bit16u *BX; -{ - Bit16u ss=get_SS(); - Bit16u mode; - -#ifdef DEBUG - printf("VBE vbe_biosfn_return_current_mode\n"); -#endif - - if(dispi_get_enable()) - { - mode=read_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE); - } - else - { - mode=read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE); - } - write_word(ss, AX, 0x4f); - write_word(ss, BX, mode); -} +ASM_START +vbe_biosfn_return_current_mode: + push ds + mov ax, # BIOSMEM_SEG + mov ds, ax + call dispi_get_enable + and ax, # VBE_DISPI_ENABLED + jz no_vbe_mode + mov bx, # BIOSMEM_VBE_MODE + mov ax, [bx] + mov bx, ax + jnz vbe_03_ok +no_vbe_mode: + mov bx, # BIOSMEM_CURRENT_MODE + mov al, [bx] + mov bl, al + xor bh, bh +vbe_03_ok: + mov ax, #0x004f + pop ds + ret +ASM_END /** Function 04h - Save/Restore State @@ -799,7 +804,7 @@ vbe_biosfn_display_window_control: ret set_display_window: mov ax, dx - call dispi_set_bank + call _dispi_set_bank call dispi_get_bank cmp ax, dx jne vbe_05_failed @@ -946,43 +951,34 @@ ASM_END */ ASM_START vbe_biosfn_set_get_dac_palette_format: - push dx - mov dx, # VBE_DISPI_IOPORT_INDEX - mov ax, # VBE_DISPI_INDEX_ENABLE - out dx, ax cmp bl, #0x01 je get_dac_palette_format - ja vbe_08_unknown - mov dx, # VBE_DISPI_IOPORT_DATA - in ax, dx - cmp bh, #0x08 - je set_8bit_dac + jb set_dac_palette_format + mov ax, #0x0100 + ret +set_dac_palette_format: + call dispi_get_enable cmp bh, #0x06 + je set_normal_dac + cmp bh, #0x08 jne vbe_08_unsupported - and ax, #~ VBE_DISPI_8BIT_DAC - out dx, ax - jmp get_dac_palette_format -set_8bit_dac: or ax, # VBE_DISPI_8BIT_DAC - out dx, ax + jnz set_dac_mode +set_normal_dac: + and ax, #~ VBE_DISPI_8BIT_DAC +set_dac_mode: + call _dispi_set_enable get_dac_palette_format: mov bh, #0x06 - mov dx, # VBE_DISPI_IOPORT_DATA - in ax, dx + call dispi_get_enable and ax, # VBE_DISPI_8BIT_DAC jz vbe_08_ok mov bh, #0x08 vbe_08_ok: mov ax, #0x004f - pop dx - ret -vbe_08_unknown: - mov ax, #0x0100 - pop dx ret vbe_08_unsupported: mov ax, #0x014f - pop dx ret ASM_END @@ -16,7 +16,6 @@ void vbe_display_info(); void vbe_biosfn_return_controller_information(AX, ES, DI); void vbe_biosfn_return_mode_information(AX, CX, ES, DI); void vbe_biosfn_set_mode(AX, BX, ES, DI); -void vbe_biosfn_return_current_mode(AX, BX); void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX); void vbe_biosfn_set_get_palette_data(AX); void vbe_biosfn_return_protected_mode_interface(AX); @@ -198,7 +197,6 @@ typedef struct ModeInfoBlock #define VBE_VESA_MODE_1280X1024X888 0x11B // BOCHS/PLEX86 'own' mode numbers -// FIXME: Add more modi #define VBE_OWN_MODE_320X200X8888 0x140 #define VBE_OWN_MODE_640X400X8888 0x141 #define VBE_OWN_MODE_640X480X8888 0x142 diff --git a/vbe_display_api.txt b/vbe_display_api.txt index 9ca9afc..788e17a 100644 --- a/vbe_display_api.txt +++ b/vbe_display_api.txt @@ -7,7 +7,7 @@ VBE Display API very heavily on each other. As such, this documents needs be synchronised between bochs CVS and the vgabios CVS. - This document does not describe hwo the VBEBios implements the VBE2/3 spec. + This document does not describe how the VBEBios implements the VBE2/3 spec. This document does not describe how the Bochs display code will display gfx based upon this spec. @@ -55,9 +55,6 @@ History Todo ---- - Version 0.6 - add virtual width, height, x offset, y offset in bios & bochs - (for set/get logical scan line length and set/get display start) - Version 0.6+ [random order] - Add lots of different (A)RGB formats @@ -194,7 +191,7 @@ API * VBE_DISPI_INDEX_BPP : WORD {R,W} The value written is now the number of bits per pixel. A value of 0 is treated the same as 8 for backward compatibilty. These values are supported: 8, 15, - 16, 24 and 32. The value of 4 is not handled in the VBE code. + 16, 24 and 32. The value of 4 is not yet handled in the VBE code. * VBE_DISPI_INDEX_ENABLE : WORD {R,W} The new flag VBE_DISPI_NOCLEARMEM allows to preserve the VBE video memory. The new flag VBE_DISPI_LFB_ENABLED indicates the usage of the LFB. @@ -312,6 +312,11 @@ int10_test_101B: int10_test_4F: cmp ah, #0x4f jne int10_normal + cmp al, #0x03 + jne int10_test_vbe_05 + call vbe_biosfn_return_current_mode + jmp int10_end +int10_test_vbe_05: cmp al, #0x05 jne int10_test_vbe_06 call vbe_biosfn_display_window_control @@ -697,10 +702,7 @@ static void int10_func(DI, SI, BP, SP, BX, DX, CX, AX, DS, ES, FLAGS) case 0x02: vbe_biosfn_set_mode(&AX,BX,ES,DI); break; - case 0x03: - vbe_biosfn_return_current_mode(&AX,&BX); - break; - case 0x04: + case 0x04: //FIXME #ifdef DEBUG unimplemented(); @@ -1147,7 +1149,7 @@ Bit8u nblines;Bit8u attr;Bit8u rul;Bit8u cul;Bit8u rlr;Bit8u clr;Bit8u page;Bit8 { // page == 0xFF if current - Bit8u mode,line,cheight; + Bit8u mode,line,cheight,cols; Bit16u nbcols,nbrows,i; Bit16u address; @@ -1170,6 +1172,7 @@ Bit8u nblines;Bit8u attr;Bit8u rul;Bit8u cul;Bit8u rlr;Bit8u clr;Bit8u page;Bit8 if(rlr>=nbrows)rlr=nbrows-1; if(clr>=nbcols)clr=nbcols-1; if(nblines>nbrows)nblines=0; + cols=clr-cul+1; if(vga_modes[line].class==TEXT) { @@ -1189,18 +1192,18 @@ Bit8u nblines;Bit8u attr;Bit8u rul;Bit8u cul;Bit8u rlr;Bit8u clr;Bit8u page;Bit8 {for(i=rul;i<=rlr;i++) { if((i+nblines>rlr)||(nblines==0)) - memsetw(vga_modes[line].sstart,address+(i*nbcols+cul)*2,(Bit16u)attr*0x100+' ',clr-cul+1); + memsetw(vga_modes[line].sstart,address+(i*nbcols+cul)*2,(Bit16u)attr*0x100+' ',cols); else - memcpyw(vga_modes[line].sstart,address+(i*nbcols+cul)*2,vga_modes[line].sstart,((i+nblines)*nbcols+cul)*2,clr-cul+1); + memcpyw(vga_modes[line].sstart,address+(i*nbcols+cul)*2,vga_modes[line].sstart,((i+nblines)*nbcols+cul)*2,cols); } } else {for(i=rlr;i>=rul;i--) { if((i<rul+nblines)||(nblines==0)) - memsetw(vga_modes[line].sstart,address+(i*nbcols+cul)*2,(Bit16u)attr*0x100+' ',clr-cul+1); + memsetw(vga_modes[line].sstart,address+(i*nbcols+cul)*2,(Bit16u)attr*0x100+' ',cols); else - memcpyw(vga_modes[line].sstart,address+(i*nbcols+cul)*2,vga_modes[line].sstart,((i-nblines)*nbcols+cul)*2,clr-cul+1); + memcpyw(vga_modes[line].sstart,address+(i*nbcols+cul)*2,vga_modes[line].sstart,((i-nblines)*nbcols+cul)*2,cols); } } } @@ -1209,39 +1212,40 @@ Bit8u nblines;Bit8u attr;Bit8u rul;Bit8u cul;Bit8u rlr;Bit8u clr;Bit8u page;Bit8 { // FIXME gfx mode not complete cheight=vga_modes[line].cheight; - if((vga_modes[line].memmodel==PLANAR4)||(vga_modes[line].memmodel==PLANAR1)) + switch(vga_modes[line].memmodel) { - if(nblines==0&&rul==0&&cul==0&&rlr==nbrows-1&&clr==nbcols-1) - { - memsetb(vga_modes[line].sstart,0,0x00,nbrows*nbcols*cheight); - } - else - {// if Scroll up - if(dir==SCROLL_UP) - {for(i=rul;i<=rlr;i++) - { - if((i+nblines>rlr)||(nblines==0)) - vgamem_fill_pl4(cul,i,clr-cul+1,nbcols,cheight); - else - vgamem_copy_pl4(cul,i+nblines,i,clr-cul+1,nbcols,cheight); - } + case PLANAR4: + case PLANAR1: + if(nblines==0&&rul==0&&cul==0&&rlr==nbrows-1&&clr==nbcols-1) + { + memsetb(vga_modes[line].sstart,0,0x00,nbrows*nbcols*cheight); } else - {for(i=rlr;i>=rul;i--) - { - if((i<rul+nblines)||(nblines==0)) - vgamem_fill_pl4(cul,i,clr-cul+1,nbcols,cheight); - else - vgamem_copy_pl4(cul,i,i-nblines,clr-cul+1,nbcols,cheight); + {// if Scroll up + if(dir==SCROLL_UP) + {for(i=rul;i<=rlr;i++) + { + if((i+nblines>rlr)||(nblines==0)) + vgamem_fill_pl4(cul,i,cols,nbcols,cheight); + else + vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight); + } + } + else + {for(i=rlr;i>=rul;i--) + { + if((i<rul+nblines)||(nblines==0)) + vgamem_fill_pl4(cul,i,cols,nbcols,cheight); + else + vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight); + } } } - } - } - else - { + break; #ifdef DEBUG - printf("Scroll in graphics mode "); - unimplemented(); + default: + printf("Scroll in graphics mode "); + unimplemented(); #endif } } @@ -1479,22 +1483,21 @@ Bit8u car;Bit8u page;Bit8u attr;Bit16u count; bpp=vga_modes[line].pixbits; while((count-->0) && (xcurs<nbcols)) { - if((vga_modes[line].memmodel==PLANAR4)||(vga_modes[line].memmodel==PLANAR1)) - { - write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight); - } - else if(vga_modes[line].memmodel==CGA) - { - write_gfx_char_cga(car,attr,xcurs,ycurs,nbcols,bpp); - } - else if(vga_modes[line].memmodel==LINEAR8) - { - write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols); - } - else + switch(vga_modes[line].memmodel) { + case PLANAR4: + case PLANAR1: + write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight); + break; + case CGA: + write_gfx_char_cga(car,attr,xcurs,ycurs,nbcols,bpp); + break; + case LINEAR8: + write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols); + break; #ifdef DEBUG - unimplemented(); + default: + unimplemented(); #endif } xcurs++; @@ -1540,22 +1543,21 @@ Bit8u car;Bit8u page;Bit8u attr;Bit16u count; bpp=vga_modes[line].pixbits; while((count-->0) && (xcurs<nbcols)) { - if((vga_modes[line].memmodel==PLANAR4)||(vga_modes[line].memmodel==PLANAR1)) - { - write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight); - } - else if(vga_modes[line].memmodel==CGA) - { - write_gfx_char_cga(car,attr,xcurs,ycurs,nbcols,bpp); - } - else if(vga_modes[line].memmodel==LINEAR8) - { - write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols); - } - else + switch(vga_modes[line].memmodel) { + case PLANAR4: + case PLANAR1: + write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight); + break; + case CGA: + write_gfx_char_cga(car,attr,xcurs,ycurs,nbcols,bpp); + break; + case LINEAR8: + write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols); + break; #ifdef DEBUG - unimplemented(); + default: + unimplemented(); #endif } xcurs++; @@ -1842,26 +1844,24 @@ Bit8u car;Bit8u page;Bit8u attr;Bit8u flag; // FIXME gfx mode not complete cheight=vga_modes[line].cheight; bpp=vga_modes[line].pixbits; - if((vga_modes[line].memmodel==PLANAR4)||(vga_modes[line].memmodel==PLANAR1)) - { - write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight); - } - else if(vga_modes[line].memmodel==CGA) - { - write_gfx_char_cga(car,attr,xcurs,ycurs,nbcols,bpp); - } - else if(vga_modes[line].memmodel==LINEAR8) - { - write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols); - } - else + switch(vga_modes[line].memmodel) { + case PLANAR4: + case PLANAR1: + write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight); + break; + case CGA: + write_gfx_char_cga(car,attr,xcurs,ycurs,nbcols,bpp); + break; + case LINEAR8: + write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols); + break; #ifdef DEBUG - unimplemented(); + default: + unimplemented(); #endif } } - xcurs++; } |