Page 1 of 1

How to use VESA VBE in qemu

Posted: Thu Dec 09, 2021 5:17 pm
by michael
My os runs well on bochs but not in qemu, and here is my code:

Code: Select all

void Start_Kernel(void){
	int *addr=(int*)0xffff800000a00000;
	for(int i=0;i<1440*20;i++){
		*addr=0x0032FA00;
		addr+=1;		
	}
	while(1);
}
This code will simply print a green stripe on the screen

According to my debug, I found that both qemu and Bochs are able to reach the while(1) successfully, but there're nothing printed on the qemu, while it runs correctly on Bochs. I now doubt it is the problem of SVGA mode(since I set SVGA into VESA VBE), and I wonder how can I let qemu support VESA VBE mode.

Here is the code I use to setup VESA VBE mode:

Code: Select all

   mov ax,4F02h
	mov bx,4180h
	int 10h
I already setup a pagetable and link the physical address of video memory(0xe0000000) with the linear address(0xffff800000a00000).

And here is the command I use to load os in to qemu:

Code: Select all

qemu-system-x86_64 -s -S -fda a.img
Here is my bochsrc file

Code: Select all

###############################################################
# Configuration file for Bochs
###############################################################

# how much memory the emulated machine will have
megs: 32

# filename of ROM images
romimage: file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/share/vgabios/vgabios.bin

# what disk images will be used
floppya: 1_44=a.img, status=inserted

# hard disk
#ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
# !! Remember to change these if the hd img is changed:
#    1. include/sys/config.h::MINOR_BOOT
#    2. boot/include/load.inc::ROOT_BASE
#    3. Makefile::HD
#    4. commands/Makefile::HD
#ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63

# choose the boot disk.
boot: floppy

# where do we send log messages?
log: bochsout.txt

# disable the mouse
mouse: enabled=0

# enable key mapping, using US layout as default.
keyboard:  keymap=/usr/share/bochs/keymaps/x11-pc-us.map
I've put the results in Bochs(cap2.png) and qemu(cap1.png) on the attachment.

Re: How to use VESA VBE in qemu

Posted: Thu Dec 09, 2021 6:02 pm
by Octocontrabass
michael wrote:I already setup a pagetable and link the physical address of video memory(0xe0000000)
Are you sure this is the physical address of video memory in QEMU?

Re: How to use VESA VBE in qemu

Posted: Fri Dec 10, 2021 10:21 am
by nexos
I already setup a pagetable and link the physical address of video memory(0xe0000000)
That doesn't look right. In QEMU, video memory is at 0xFD000000 (IIRC).