VESA list on real hardware

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jmkerdal
Posts: 12
Joined: Sun Apr 14, 2019 12:19 am
Libera.chat IRC: jmkerdal

VESA list on real hardware

Post by jmkerdal »

Hello, I have a question about VESA and real hardware.

whit this code:

Code: Select all

	cli                         # BIOS enabled interrupts; disable
	cld
	
	# Zero data segment registers DS, ES, and SS.
	xorw    %ax, %ax             # Set %ax to zero
	movw    %ax, %ds             # -> Data Segment
	movw    %ax, %es             # -> Extra Segment
	movw    %ax, %ss             # -> Stack Segment

	/* Don't lose dl */
	mov %dl, boot_disk

	/* Initialize stack to just below us */
	mov $0x7c00, %ax
	mov %ax, %sp

	/* Ask for drive params */
	mov $0x48, %ah
#	mov boot_disk, %dl
	mov $drive_params, %si
	int $0x13

	/* Get video mode info */
	mov $0, %ax
	mov %ax, %es
	mov $vbe_cont_info, %di
	mov $0x4F00, %ax
	int $0x10
On my PC with QEMU emulation when I run my boot, VESA table is stored at 0x7E04:
PC: 7E04
56 45 53 41 00 03 D9 58 00 C0 01 00 00 00 26 7E
00 00 00 01 00 00 ED 58 00 C0 00 59 00 C0 14 59
00 C0 00 01 01 01 02 01 03 01 04 01 05 01 06 01
07 01 0D 01 0E 01 0F 01 10 01 11 01 12 01 13 01
This is correct, I got 7E26 for starting list of available mode.
But with two real machine I got this:
Lenovo:
56 45 53 41 00 03 BC 94 00 C0 01 00 00 00 93 95
00 C0 FF 01 00 00 00 00 00 00 00 00 00 00 00 00
Server:
56 45 53 41 00 03 3A 59 00 C0 01 00 00 00 A7 55
00 C0 00 01 09 03 4F 59 00 C0 56 59 00 C0 5F 59
00 C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00
What's wrong?
sebihepp
Member
Member
Posts: 223
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: VESA list on real hardware

Post by sebihepp »

What should be wrong? You will find the list of video modes on 0x0:0x9593 and 0x0:0x55A7
Octocontrabass
Member
Member
Posts: 5805
Joined: Mon Mar 25, 2013 7:01 pm

Re: VESA list on real hardware

Post by Octocontrabass »

jmkerdal wrote: Tue May 20, 2025 9:23 amWhat's wrong?
It's a far pointer, not a near pointer. You got 0x0000:0x7E26 on QEMU, 0xC000:0x9593 on the first machine, and 0xC000:0x55A7 on the second machine. Those sound like reasonable addresses to me.
sebihepp wrote: Tue May 20, 2025 9:58 amYou will find the list of video modes on 0x0:0x9593 and 0x0:0x55A7
...I don't think so...
jmkerdal
Posts: 12
Joined: Sun Apr 14, 2019 12:19 am
Libera.chat IRC: jmkerdal

Re: VESA list on real hardware

Post by jmkerdal »

What I understand is that function fill the 512 bytes table vbe_cont_info.
With emulation like QEMU, VirtualBox I get 26 7E that is the first mode available (here 00 01 is the 0x100 mode 640×400 256 colors).

With two real PC I got a different adresse and it's out of the table. And when I read I got plenty of 0 and strange values and never got the 0xFFFF end of table.

Possibly it's not the good way to retreive and set video mode on real hardware?

PS: I try to force video mode to 0x 0115 and that crash on real PC.
sebihepp
Member
Member
Posts: 223
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: VESA list on real hardware

Post by sebihepp »

Octocontrabass wrote: Tue May 20, 2025 11:41 am sebihepp wrote: ↑20 May 2025, 17:58
You will find the list of video modes on 0x0:0x9593 and 0x0:0x55A7
...I don't think so...
Oh, you are right. I used the wrong offset and switched segment and address. My fault :oops:
jmkerdal wrote: Wed May 21, 2025 2:25 am What I understand is that function fill the 512 bytes table vbe_cont_info.
With emulation like QEMU, VirtualBox I get 26 7E that is the first mode available (here 00 01 is the 0x100 mode 640×400 256 colors).
It fills the table VbeInfoBlock. My documentation says it gives you a far pointer to a list of video modes at offset 0xE. The list of video modes supported doesn't have to be inside that table. It can be everywhere. Do you also use the correct segment?
jmkerdal wrote: Wed May 21, 2025 2:25 am PS: I try to force video mode to 0x 0115 and that crash on real PC.
Maybe the real PCs don't support mode 0x115?
jmkerdal wrote: Wed May 21, 2025 2:25 am Possibly it's not the good way to retreive and set video mode on real hardware?
Video mode switching on modern PCs is quite difficult. I have been told that most modern graphics cards don't implement VBE3.0 PMode interface anymore. And switching to RMode and back is no option, as it is error prone and very difficult and expensive to do. I rely on limine (bootloader) to set the graphics mode for me and then just use it. Later I need to implement drivers for each video card... sadly...
Maybe then I try again VBE3.0 PMode, just to see where it is supported.
Octocontrabass
Member
Member
Posts: 5805
Joined: Mon Mar 25, 2013 7:01 pm

Re: VESA list on real hardware

Post by Octocontrabass »

jmkerdal wrote: Wed May 21, 2025 2:25 amWith emulation like QEMU, VirtualBox I get 26 7E that is the first mode available
The pointer is four bytes, not two: 26 7E 00 00. You need to use all four bytes. If you're only using two bytes, it won't work on real hardware.
jmkerdal
Posts: 12
Joined: Sun Apr 14, 2019 12:19 am
Libera.chat IRC: jmkerdal

Re: VESA list on real hardware

Post by jmkerdal »

Ho yes you are right! It is not a ushort but a uint, as written in the documentation.

Example I took on GitHub is not correct, as usual I must say...
Real hardware is another level.

I will test tomorrow because today I am working at the client's site. I tell you if it's working or not.
nullplan
Member
Member
Posts: 1889
Joined: Wed Aug 30, 2017 8:24 am

Re: VESA list on real hardware

Post by nullplan »

jmkerdal wrote: Thu May 22, 2025 1:45 am Example I took on GitHub is not correct, as usual I must say...
And that's the stuff they train Copilot on. Another reason to pass on that.
Carpe diem!
jmkerdal
Posts: 12
Joined: Sun Apr 14, 2019 12:19 am
Libera.chat IRC: jmkerdal

Re: VESA list on real hardware

Post by jmkerdal »

Thank's values are correct now.
Post Reply