Page 1 of 1

VBE enabling

Posted: Sat Jul 31, 2010 1:57 pm
by brodeur235
I am following the official VBE 3.0 specs to enable the protected mode entry point that I need to get VBE going. I made sure to download an lgpl'd VGABIOS and fix my bochsrc, but when I scan my 32Kb copied BIOS image, I cannot find the PMID signature... So when I make sure that everything I'm doing looks correct, I get to thinking maybe the VBE specs are outdated or incorrect. Maybe. I'm just wondering is the BIOS image always at 0xC0000 like the specs say? And is it safe to assume the BIOS image is 32Kb, like the specs say?

What I did was copy the 32Kb at 0xC0000 to 0x10E000, which is a 9 page area in my kernel dedicated to holding the copied BIOS and enabling VBE. The copy worked. I used my simple _mem_cpy function and checked and double checked that it was working properly. It is. The problem is not the copy. I can see the problem being one of three things:

- The location of the original BIOS in RAM is incorrect (0xC0000)
- The size of the original BIOS in RAM is incorrect (0x8000)
- The scan isn't working properly.

However, I really don't think it's the latter because it's a very simple function that I've recoded a number of ways to test for different bugs and it's had the same outcome of "PMID NOT FOUND" every time. Here is the code:

Code: Select all

global _setup_vbe
_setup_vbe:
	
	; setup stack frame
	push ebp
	mov ebp,esp
	pushad
	
	; Following Exact VBE 3.0 Specs
	; =============================
	
	; Step 1.) Allocate a protected mode buffer large enough to hold
	;          the entire BIOS image (32Kb normally).
	
	; Done in the paging module.
	
	; Step 2.) Copy the BIOS image from the 0xC000 physical memory 
	;          region to the protected mode buffer.
	
	push DWORD 0x00008000 ; 32 kb = 0x8000 bytes
	push DWORD 0x000C0000
	push DWORD 0x0010E000
	call _mem_copy
	add esp,DWORD 0x0C
	
	; Step 3.) Scan the BIOS image for the PMInfoBlock structure 
	;          and check that the checksum for the block is 0.
	
	mov ecx,DWORD 0x10E000
	add ecx,DWORD 0x8000
	sub ecx,DWORD 0x04
	mov eax,DWORD 0x10E000
	.next_check:
		
		; check if counter reached limit
		cmp eax,ecx
		jz .not_found
		
		; check for signature
		cmp DWORD [ds:eax],0x504D4944 ; "PMID"
		jz .found
		
		; increment counter and loop back around
		inc eax
		jmp .next_check
	
	.not_found:
		
		call _dbg_no
		
	.found:
		
		call _dbg_yes
		
	; jump to end (over code)
	jmp .done
		
	; data
	.data:
		
		.PMInfoBlock dd 0x00000000
	
	; end
	.done:
	
	; clean up stack frame
	popad
	mov esp,ebp
	pop ebp
	ret
Anyway, here's an image verifying that the memory copy is working and that the signature is not being found:
Image
The "No" on one line followed by "Yes" on the next are the results of calling the _dbg_yes and _dbg_no routines and since "No" is there, the signature wasn't found.


Help appreciated,

Brodeur235

Re: VBE enabling

Posted: Sat Jul 31, 2010 2:01 pm
by JohnnyTheDon
Most BIOSes don't support the protected mode entry point. Its generally best to switch video modes before entering protected mode.

Re: VBE enabling

Posted: Sat Jul 31, 2010 2:47 pm
by brodeur235
This one does: http://forum.osdev.org/viewtopic.php?t=9655. Still looking for help.

Brodeur235

Re: VBE enabling

Posted: Sat Jul 31, 2010 2:52 pm
by Owen
brodeur235 wrote:This one does: http://forum.osdev.org/viewtopic.php?t=9655. Still looking for help.

Brodeur235
  1. That thread is extremely old and likely out of date
  2. It explicitly says that VBE protected mode is unsupported on Bochs
  3. It also says that VBE protected mode is present but unusable broken on many cards

Re: VBE enabling

Posted: Sat Jul 31, 2010 7:22 pm
by brodeur235
Then which kind of GUI implementation can I do that has at least a 1280x768 resolution and is widely supported?

Brodeur235

Re: VBE enabling

Posted: Sat Jul 31, 2010 8:29 pm
by JohnnyTheDon
brodeur235 wrote:Then which kind of GUI implementation can I do that has at least a 1280x768 resolution and is widely supported?

Brodeur235
Either change video modes before entering protected mode, or switch back to real mode to change video modes, or create a virtual 8086 task to run bios code in protected mode. All of this is on the wiki.

Re: VBE enabling

Posted: Sat Jul 31, 2010 10:11 pm
by brodeur235
The Bochs VGA BIOS supports, to an extent, the VBE specification.
See Vesa Information in Bochs thread for more info.
Well, apparently it's linking me to outdated and incorrect information..

Anyways. I decided to go with the largest VGA resolution (640x480x16). I have never programmed the VGA in a graphics and not text mode and when I tried to write a _fill_rect method, I got this sad looking result:
Image

Anybody have any idea what I might be doing wrong off the top of their head?

Here's the code if you actually want to glance through it:

Code: Select all

; @param1 (DWORD) X-TL Coordinate
; @param2 (DWORD) Y-TL Coordinate
; @param3 (DWORD) X-BR Coordinate
; @param4 (DWORD) Y-BR Coordinate
; @param5 (DWORD) Color.

global _fill_rect
_fill_rect:
	
	; setup stack frame
	push ebp
	mov ebp,esp
	pushad
	
	; get base address
	mov eax,DWORD [ebp + 12]
	imul eax,DWORD 640d
	add eax,DWORD [ebp + 8]
	add eax,DWORD 0xA0000
	mov DWORD [ds:KLOC(.base)],eax
	
	; get width
	mov eax,DWORD [ebp + 16]
	sub eax,DWORD [ebp + 8]
	mov DWORD [ds:KLOC(.width)],eax
	
	; get height
	mov eax,DWORD [ebp + 20]
	sub eax,DWORD [ebp + 12]
	mov DWORD [ds:KLOC(.height)],eax
	
	; loop thru height
	.next_y:
		
		; check if counter reached limit
		mov ecx,DWORD [ds:KLOC(.y_cntr)]
		cmp ecx,DWORD [ds:KLOC(.height)]
		jz .done
		
		;==================================================
		;==================================================
		
		; loop thru width
		.next_x:
			
			; check if counter reached limit
			mov ecx,DWORD [ds:KLOC(.x_cntr)]
			cmp ecx,DWORD [ds:KLOC(.width)]
			jz .done_x
			
			mov eax,DWORD [ds:KLOC(.y_cntr)]
			imul eax,DWORD 640d
			add eax,DWORD [ds:KLOC(.x_cntr)]
			add eax,DWORD [ds:KLOC(.base)]
			mov ebx,DWORD [ebp + 24]
			mov BYTE [ds:eax],bl
			
			; increment counter and loop back around
			inc DWORD [ds:KLOC(.x_cntr)]
			jmp .next_x
			
		.done_x:
		mov DWORD [ds:KLOC(.x_cntr)],0x00
			
		;==================================================
		;==================================================
		
		; increment counter and loop back around
		inc DWORD [ds:KLOC(.y_cntr)]
		jmp .next_y
	
	; data
	.data:
		
		.base   dd 0x00000000
		.width  dd 0x00000000
		.height dd 0x00000000
		.x_cntr dd 0x00000000
		.y_cntr dd 0x00000000
	
	; completed
	.done:
	
	; clean up stack frame
	popad
	mov esp,ebp
	pop ebp
	ret
Help appreciated,

Brodeur235

Re: VBE enabling

Posted: Sun Aug 01, 2010 1:31 am
by Candy
You're pretending it's a linear framebuffer and it's not. It's banked.

That means that you should treat it as being 1bpp for now, until you have that working. Then, switch to the next bank and write the next bit for each pixel. I'm pretty sure this is documented on the wiki.

Re: VBE enabling

Posted: Tue Aug 03, 2010 10:37 am
by JohnWilson
brodeur235 wrote: ...

Code: Select all

		; check for signature
		cmp DWORD [ds:eax],0x504D4944 ; "PMID"
		jz .found
...
Whatever else is going on, you need to reverse the byte order. You want 44494D50h if you're trying to match "db 'PMID'" in memory. FWIW I just checked the two of my PCs that are powered on right now -- one has the PMID signature, one doesn't.

John Wilson
D Bit