I try to use grub to load my own kernel wich is in pe format.
I have read the few tutorials on subject, mainly this one http://www.srenevasan.org/~kaushik/articles/pe.html
Grub load my kernel and Invariably give an error 13
Here is my code
Code: Select all
// init.cpp : définit le point d'entrée pour l'application console.
//
#include "init.h"
__declspec(naked) void __multiboot_entry__(void)
{
__asm{
multiboot_header:
dd(0x1BADB002) ; magic
dd(1 << 16)|(1<<0)|(1<<1) ; flags
dd(-(0x1BADB002 + ((1 << 16)|(1<<0)|(1<<1)))) ; checksum
dd(0x00101000) ; header_addr
dd(0x00101000) ; load_addr
dd(0x00102000) ; load_end_addr
dd(0x00102000) ; bss_end_addr
dd(0x00101030) ; entry_addr
dd(0x00000000) ; mode_type
dd(0x00000000) ; width
dd(0x00000000) ; height
dd(0x00000000) ; depth
kernel_entry:
mov esp, KERNEL_STACK
xor ecx, ecx
push ecx
popf
push ebx
push eax
call main
jmp $
}
}
void main(unsigned long magic, unsigned long addr)
{
char *string = "Hello World!", *ch;
unsigned short *vidmem = (unsigned short *) 0xB8000;
int i;
for(ch = string, i = 0; *ch; ch++, i++)
vidmem[i] = (unsigned char) *ch | 0x0700;
}
Code: Select all
init
Timestamp is 4b041946 (Wed Nov 18 16:56:54 2009)
Preferred load address is 00100000
Start Length Name Class
0001:00000000 000000acH .text CODE
0002:00000000 0000000dH .rdata DATA
Address Publics by Value Rva+Base Lib:Object
0001:00000000 ?__multiboot_entry__@@YGXXZ 00101000 f init.obj
0001:00000050 _main 00101050 f init.obj
0002:00000000 ??_C@_0N@GCDOMLDM@Hello?5World?$CB?$AA@ 00102000 init.obj
entry point at 0000:00000000
Static symbols
My opinion is that the header has bad values but i can be wrong.
Does anyone has an idea ?