Page 1 of 1

GRUB doesn't set a right multiboot info?

Posted: Thu Apr 10, 2014 9:38 pm
by xtricman
bootstrap.s

Code: Select all

.section .text
.global start
multiboot_header:
required:
	.long 0x1BADB002
	.long 0x00000007
	.long -(0x1BADB002 + 0x00000007)
addr_ignored:
	.long 0
	.long 0
	.long 0
	.long 0
	.long 0
videomode:
	.long 0
	.long 800
	.long 600
	.long 32
start:
	.skip 16384
stack:
	movl $stack, %esp
	cli
	push %ebx
	call kernel_main

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
	mount /dev/sdb1 /mnt
	cp kernel.elf /mnt -f
	umount /mnt

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
I use this multiboot header and I think grub2 DO initialize the VBE for me because I really get a 800*600 (or 1024*768 when I change the videomode field in multiboot_header)qemu window after I boot my kernel.But When I begin to debug, I found that flags in multiboot_info is 0x1267, the bit[11] is not set,so I can't get the VBE information.what's wrong?

Re: GRUB doesn't set a right multiboot info?

Posted: Thu Apr 10, 2014 11:35 pm
by jnc100
Firstly, I do not see your entry point being defined anywhere. I presume it is 'start' and therefore you initially start executing 16384 bytes of garbage. Secondly, what ABI is your compiler using? You are pushing ebx to the stack and therefore assuming the cdecl calling convention, but your compiler may not expect this (especially if you are using the system compiler on a 64-bit machine). Also, you do not anywhere stop the compiler using e.g. mmx or sse functionality, which you haven't set up for.

You may want to investigate the GCC Cross-Compiler article.

Regards,
John.