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.sCode:
.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.ldCode:
ENTRY(start)
SECTIONS
{
. = 1M;
.text :
{
*(.text)
}
.rodata :
{
*(.rodata)
}
.data :
{
*(.data)
}
.bss :
{
*(.bss)
}
}
MakefileCode:
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.cCode:
#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;
}