QEMU does't support VBE?

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
xtricman
Posts: 16
Joined: Wed Mar 12, 2014 9:52 pm

QEMU does't support VBE?

Post by xtricman »

The qemu emulator usr documentation said if I use "-vga std" qemu can provide a Standard VGA card with Bochs VBE extensions.
But I use this multiboot header,

Code: Select all

multiboot_header:
required:
	.long 0x1BADB002
	.long 0x00000007
	.long -(0x1BADB002 + 0x00000007)
addrinfo_ignored:
	.long 0
	.long 0
	.long 0
	.long 0
	.long 0
videomode:
	.long 0
	.long 1024
	.long 768
	.long 24
and the use

Code: Select all

qemu-system-i386 -kernel kernel.elf -vga std
Qemu says

Code: Select all

qemu: multiboot knows VBE. we don't
What's the problem?
User avatar
Lionel
Member
Member
Posts: 117
Joined: Fri Jul 16, 2010 2:16 pm
Libera.chat IRC: ryanel
Location: California

Re: QEMU does't support VBE?

Post by Lionel »

There is no problem. Qemu does not support VBE with loading a kernel with --kernel. You need to use GRUB to load the kernel for the results you want, as that initializes VBE. Qemu with -vga std DOES support VBE, it just wont initialize it for you (like grub).

"Mulitboot knows VBE. we don't" eludes to this, as using sentence breaking would dictate two things
=> That the multiboot standard knows about VBE
=> Qemu, which is implementing the multiboot standard, does not.

Hope this helps,
Lionel
xtricman
Posts: 16
Joined: Wed Mar 12, 2014 9:52 pm

Re: QEMU does't support VBE?

Post by xtricman »

Lionel wrote:There is no problem. Qemu does not support VBE with loading a kernel with --kernel. You need to use GRUB to load the kernel for the results you want, as that initializes VBE. Qemu with -vga std DOES support VBE, it just wont initialize it for you (like grub).
OK,but GRUB can't boot my kernel.I use

Code: Select all

 multiboot kernel.elf 
but GRUB says premature end of file.
User avatar
Lionel
Member
Member
Posts: 117
Joined: Fri Jul 16, 2010 2:16 pm
Libera.chat IRC: ryanel
Location: California

Re: QEMU does't support VBE?

Post by Lionel »

What version of grub are you using? I see your using a cross compiler (for i386... thats quite old, you know). How are you linking it? Whats your assembler? Could you post your Makefile (or build script) & linker script?
xtricman
Posts: 16
Joined: Wed Mar 12, 2014 9:52 pm

Re: QEMU does't support VBE?

Post by xtricman »

Lionel wrote:What version of grub are you using? I see your using a cross compiler (for i386... thats quite old, you know). How are you linking it? Whats your assembler? Could you post your Makefile (or build script) & linker script?
Er....First thank you for helping.But actually I just use my native gcc and grub2.00(I really don't want a cross-compiler because native gcc works well at least when I just using VGA text mode).
Here are my codes

bootstrap.s

Code: Select all

.section .text
.global start
.align 64
multiboot_header:
required:
	.long 0x1BADB002
	.long 0x00000007
	.long -(0x1BADB002 + 0x00000007)
addrinfo_ignored:
	.long 0
	.long 0
	.long 0
	.long 0
	.long 0
videomode:
	.long 0
	.long 1024
	.long 768
	.long 32
start:
	.skip 16384
stack:
	movl $stack, %esp
	cli
	push %ebx
	call kernel_main
linker.ld

Code: Select all

ENTRY(start)
SECTIONS
{
	. = 1M;
	.text :
	{
		*(.text)
	} 
	.rodata :
	{
		*(.rodata)
	}
	.data :
	{
		*(.data)
	}
	.bss :
	{
		*(.bss)
	}
}

Makefile

Code: Select all

GCC=gcc
LD=ld
LDSCRIPT=linker.ld
GAS=as

all: kernel.elf

kernel.elf: bootstrap.o
	$(LD) bootstrap.o kernel.o -g -o kernel.elf -T $(LDSCRIPT)

install: kernel.elf
	cp kernel.elf /mnt -f

bootstrap.o: bootstrap.s kernel.c
	$(GAS) bootstrap.s -g -o bootstrap.o 
	$(GCC) kernel.c -std=c99 -c -g -o kernel.o

clean: 
	rm -f *.o *.elf

test:
	qemu-system-x86_64 -vga std -hda /dev/sdb

kernel.c

Code: Select all

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

typedef struct {
	uint32_t flags;
	uint32_t mem_lower;
	uint32_t mem_upper;
	uint32_t boot_device;
	uint32_t cmdline;
	uint32_t mods_count;
	uint32_t mods_addr;
	uint32_t num;
	uint32_t size;
	uint32_t addr;
	uint32_t shndx;
	uint32_t mmap_length;
	uint32_t mmap_addr;
	uint32_t drives_length;
	uint32_t drives_addr;
	uint32_t config_table;
	uint32_t boot_loader_name;
	uint32_t apm_table;
	uint32_t vbe_control_info;
	uint32_t vbe_mode_info;
	uint16_t vbe_mode;
	uint16_t vbe_interface_seg;
	uint16_t vbe_interface_off;
	uint16_t vbe_interface_len;
} multiboot_info;

void kernel_main(multiboot_info *p)
{
	uint32_t *vbe_entry = (uint32_t *)((p->vbe_interface_seg<<4) + (p->vbe_interface_off));
	*vbe_entry = 0xFF34122A;
	ROLL:
	goto ROLL;
}
User avatar
hometue
Member
Member
Posts: 100
Joined: Thu Dec 19, 2013 1:40 am
Location: Asia, Singapore

Re: QEMU does't support VBE?

Post by hometue »

I would suggest you to recompile with a cross-compiler. Its not that hard to make one. The problem might be caused by the fact you aren't using one. (if its not someone suggest the correct method to solve this) Take a look at the wiki for the steps to make a cross-compiler.
CookieOS. Want a cookie? Its only black and white for now though, probably as bad as my baking skills.
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: QEMU does't support VBE?

Post by sortie »

Read the Bare Bones tutorial. You are not building the kernel correctly with gcc, in particular you are not passing -ffreestanding and you don't appear to be linking the kernel correctly. Additionally, if this is a x86_64 kernel, you may wish to use -mno-red-zone and also disable sse and such if you don't support it.
xtricman
Posts: 16
Joined: Wed Mar 12, 2014 9:52 pm

Re: QEMU does't support VBE?

Post by xtricman »

hometue wrote:I would suggest you to recompile with a cross-compiler. Its not that hard to make one. The problem might be caused by the fact you aren't using one. (if its not someone suggest the correct method to solve this) Take a look at the wiki for the steps to make a cross-compiler.
I already build a i586-elf-gcc and x86_64-elf-gcc ,but i just don't want to use them.I ever used it and I know it works well.But I found when I'm just using VGA textmode,my native gcc works well too!So I just want to see if my gcc can do something I want.I 'll use my i586-elf-gcc and try again.Thank you.
xtricman
Posts: 16
Joined: Wed Mar 12, 2014 9:52 pm

Re: QEMU does't support VBE?

Post by xtricman »

sortie wrote:Read the Bare Bones tutorial. You are not building the kernel correctly with gcc, in particular you are not passing -ffreestanding and you don't appear to be linking the kernel correctly. Additionally, if this is a x86_64 kernel, you may wish to use -mno-red-zone and also disable sse and such if you don't support it.
Problem Still Exist

Code: Select all

GCC=i586-elf-gcc
LD=i586-elf-gcc
LDSCRIPT=linker.ld
GAS=i586-elf-as

all: kernel.elf

kernel.elf: bootstrap.o
	$(LD) bootstrap.o kernel.o -g -ffreestanding -nostdlib -lgcc -o kernel.elf -T $(LDSCRIPT)

install: kernel.elf
	cp kernel.elf /mnt -f

bootstrap.o: bootstrap.s kernel.c
	$(GAS) bootstrap.s -g -o bootstrap.o 
	$(GCC) kernel.c -std=c99 -c -g -ffreestanding -o kernel.o

clean: 
	rm -f *.o *.elf

test:
	qemu-system-i386 -vga std -hda /dev/sdb
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: QEMU does't support VBE?

Post by Kevin »

When GRUB refuses to start an image, mbchk can sometimes give a hint. Did you try it?

Also, the Makefile looks like you're trying to keep the file system mounted all the time while you're running qemu? That's probably not a good idea. At the very least you need to do a 'sync', even if your VM doesn't write to the file system yet, but unmounting would be better.

ENTRY(start) isn't quite correct either, your kernel starts with executing the 16384 bytes of stack as code.
Developer of tyndur - community OS of Lowlevel (German)
Post Reply