PearOs wrote:Wow Dirk, thanks for all the info. So I looked through VBE3.pdf and I found some really useful information. But here's where things get tricky. I want to support higher resolutions. I don't really mind if its done with VBE or something else. But what is the fastest way to support fast higher resoultion graphics in long mode without writing drivers for every graphics card and without using VGA? Or is this impossible? Thanks, Matt
Well I have been doing lot's of reading. And I find most homebrewed operating systems are using VESA mode by setting the mode before they enter protected mode. So I guess my question would be, how do I setup VESA in real mode, set the mode ect.. and then in Protected Mode Get/Set Pixels and other things? Thanks guys, this is a huge learning curve for me. I know VGA pretty well but I have never ventured past it.
I try to explain the most importend thinks about the VBE.
We are starting in the RM or V86-Mode, or maybe in the 16 bit big-realmode/unrealmode with vbe function 4F00h (in the AX-register) of the int 10h for to get the VBE-info in a buffer of 512 bytes (ES:DI must be points to the buffer).
Then we check if this function is suported and if we become the value of 4Fh back in AX, or non if it fails.
The next step is to check the major number of our VBE version(VBE_Info_Buffer+5) if it is number 2 or 3, or a lesser number.
With the VBE version number 2 and number 3 we can get the pointer(offset, segment) of the list of VBE-modenumbers in the VBE_Info_Buffer+0Eh = contains the pointer to the modelist, not the modelist itself. (Maybe the modelist is nearby also inside of the VBE_Info_Buffer). The modelist ends with a word of "0FFFFh".
The next step is to get each modenumber from the modelist for to use this number by number to get the mode information of each number/mode with the funcion 4F01h in an additional "mode_info:buffer" of 256 bytes. (+checking if we become back 4Fh in AX.) (ES:DI must be points to the buffer.)
Now we have to check some parameter inside of this mode_info:buffer, for to find the resolution we are looking for.
Mode_info:buffer+12h contains a word of the max horizontal resolution, Mode_info:buffer+14h contains a word of the vertical resolution, Mode_info:buffer+19h contains the amoung of bits for each pixel, the highest bit of the byte in Mode_info:buffer+0 is set if the linear access is supported, Mode_info:buffer+28h contains the 32bit address of the LFB, or contains zeros if non LFB is possible in this mode. (Hint: The scanlines of the screen are maybe longer as the horizontal resolution, so we have to use the word of the Mode_info:buffer+10h for to calculate the address of a pixel. and not the word in the Mode_info:buffer+12h.)
...
If we found the VBE modenumber 3, then it is possible to set a VBE-mode with our own CRT-parameter for to become a higher refreshrate, otherwise we become only the default 60hz refreshrate. For to use a higher refreshrate it would be wise for to check the capacity of our monitor before. Therefore we can get the EDID(monitor information) from the DDC(a special line for to transmit those infos) by using function 4F15h of the int 10h. Calling with BL=0 we can check if the function is aviable and if we become 4Fh back in AX. (Hint: older BNC-monitor-cable with only five lines do not have a DDC.)
Then we can get the EDID with BL=1 with function 4F15h in a new buffer of 128 bytes.
Inside of the EDID-buffer we can search for a "Text-identifier" of the value dword "0FD000000h" in EDID_buffer+36h, or in EDID_buffer+48h, or in EDID_buffer+5Ah, or in EDID_buffer+6Ch. If we found a "Text-identifier", then we can adding to this adress 6 bytes for to get the max HZ in a byte and if we are adding 8 bytes to this address of the "Text-identifier", then we can get the max KHZ of the monitor.
The next step for to become a higher refreschrate is to get the pixelclock for our CRT-parameter (using funktion 4F0Bh) for to recalculate the refreschrate with this pixelclock that we become back and with the other paramter of our CRT-parameter-block (RefreshRate=Pixelclock/(HTotal*Vtotal)).
Example of a CRTC-parameter-block for the resolution of 1024x768 with 100 hz refreshrate using a CRT-monitor with a capacity of max. 96 khz and max. 160 hz like a lot of 19" CRT-monitors provide.
Code: Select all
CRTC DW 1456 ; Horizontal Total in Pixel
HORIANF DW 1122 ; Horizontal Sync-Start in Pixel
HORIEND DW 216 ; Horizontal Sync-End in Pixel
VERTOTA DW 814 ; Vertical Total in Lines
VERTANF DW 768 ; Vertical Sync-Start in Lines
VERTEND DW 42 ; Vertical Sync-End in Lines
DOIFLAG DB 04h ; Flag (interlaced,doubleScan,polarity)
PIXCLOC DD 118309000 ; Pixel clock in hz (Hint: We have to get the "normalized" pixelclock from our bios and this value can be different.)
REFRATE DW 10000 ; Refresh-Rate in 0.01 hz (Hint: We have to recalculatad the HZ-value together with the "normalized" pixelclock.)
;---------------------
DB 40 dup (0)
;--------------------------------------
More puplic documents from vesa.org:
EEDIDguideV1.pdf
EEDIDverifGuideRa.pdf
For to become those CRT-parameters we can use a small DOS application with the name VBEHz.com inside of a zip-archiv.
http://www.pcworld.com/product/1048351/vbehz.html
Additional there is also a "MODELIST.COM" inside, for to see which modes your BIOS or VESA driver supports.
...
At last we set the VBE-mode with function 4F02h with a modenumber+4000h for to use the LFB and optional with modenumber+800h for to use own CRT-parameter and with ES:DI points to our CRT-block.
After we have set our VBE-mode, then we can switch to the 32 PM, or to the 64 bit mode and we can start to fill the LFB with our content.
...
I have written a small 16 bit DOS-application in assembler(MASM/Intel-syntax)
only using the 16 bit bigrealmode for to show how to use a VBE 3 bios with a resolution of 1024x768x32 @100 hz refresrate together with the VBE hardware triple buffering (function 4F07h of the int 10h) for to move some larger objects across the screen without to become a flickering screen or a tearing. I programm it with a geforce 4(agp with 64 MB) und with a 19" CRT from Samsung and a 19" CRT from SAMTRON (both CRTs provide 96khz/160hz capacity) together with a AMD 32 bit "Palomino"- CPU "1800+" @1533 mhz for a sockel "A" mainboard. (My newer 28" LCD monitor with 60hz refreshrate ignore the CRT-parameter and switch only to 1024x768 @60 hz.)
http://www.alice-dsl.net/freecracmaps/Tool/Neutrip.zip
Dirk