OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 10:44 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: QEMU does't support VBE?
PostPosted: Thu Apr 10, 2014 4:37 am 
Offline

Joined: Wed Mar 12, 2014 9:52 pm
Posts: 16
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:
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:
qemu-system-i386 -kernel kernel.elf -vga std

Qemu says
Code:
qemu: multiboot knows VBE. we don't

What's the problem?


Top
 Profile  
 
 Post subject: Re: QEMU does't support VBE?
PostPosted: Thu Apr 10, 2014 4:51 am 
Offline
Member
Member
User avatar

Joined: Fri Jul 16, 2010 2:16 pm
Posts: 117
Location: California
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

_________________
Cedille - Toy kernel


Top
 Profile  
 
 Post subject: Re: QEMU does't support VBE?
PostPosted: Thu Apr 10, 2014 5:27 am 
Offline

Joined: Wed Mar 12, 2014 9:52 pm
Posts: 16
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:
multiboot kernel.elf
but GRUB says premature end of file.


Top
 Profile  
 
 Post subject: Re: QEMU does't support VBE?
PostPosted: Thu Apr 10, 2014 5:36 am 
Offline
Member
Member
User avatar

Joined: Fri Jul 16, 2010 2:16 pm
Posts: 117
Location: California
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?

_________________
Cedille - Toy kernel


Top
 Profile  
 
 Post subject: Re: QEMU does't support VBE?
PostPosted: Thu Apr 10, 2014 5:55 am 
Offline

Joined: Wed Mar 12, 2014 9:52 pm
Posts: 16
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:
.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:
ENTRY(start)
SECTIONS
{
   . = 1M;
   .text :
   {
      *(.text)
   }
   .rodata :
   {
      *(.rodata)
   }
   .data :
   {
      *(.data)
   }
   .bss :
   {
      *(.bss)
   }
}



Makefile
Code:
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:
#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;
}


Top
 Profile  
 
 Post subject: Re: QEMU does't support VBE?
PostPosted: Thu Apr 10, 2014 5:58 am 
Offline
Member
Member
User avatar

Joined: Thu Dec 19, 2013 1:40 am
Posts: 100
Location: Asia, Singapore
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.


Top
 Profile  
 
 Post subject: Re: QEMU does't support VBE?
PostPosted: Thu Apr 10, 2014 6:30 am 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 930
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.


Top
 Profile  
 
 Post subject: Re: QEMU does't support VBE?
PostPosted: Thu Apr 10, 2014 6:36 am 
Offline

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


Top
 Profile  
 
 Post subject: Re: QEMU does't support VBE?
PostPosted: Thu Apr 10, 2014 6:51 am 
Offline

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


Top
 Profile  
 
 Post subject: Re: QEMU does't support VBE?
PostPosted: Fri Apr 11, 2014 3:11 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], SemrushBot [Bot] and 113 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group