Im trying to boot custom kernel with help of grub and qemu.
If i start it with "qemu -kernel -m 64 ./kernel.bin" it works fine.
Bud if i create iso with "grub-mkrescue -o os.iso ./os/"
It start to load grub and screen stay black
directories tree:
------
./os/boot/
kernel.bin
grub/
grub.cfg
------
content of grub.cfg
set default="0"
set timeout="3"
### BEGIN 10 ###
menuentry "tmx.os" {
multiboot /boot/kernel.bin
echo " LOADING KERNEL: done"
}
### END 10 ###
the line "LOADING KERNEL: done" is displayed on the screen.
Have somebody idea what can be wrong ? Any advise is welcome
======================================================= UPD: i have kernel_main() in "C" file, and as i can see in GDB kernel_main gets never called. Strange ?
assembly code
bits 32
section .text
align 4 ; align at 4 byte
dd 0x1BADB002 ; MAGIC
dd 0x00
dd - (0x1BADB002 + 0x00)
global start
extern kernel_main
start:
cli ; Clear interrupt flag [IF = 0]; 0xFA
mov esp, kernel_stack ; set stack pointer
;push eax ; multiboot structure
;push ebx ; MAGIC
call kernel_main ; controll to kernel_main(); in kernelc.c
hlt ; HLT Enter halt state 0xF4
end:
cli
hlt
jmp end
section .bss
resb 1024*256 ; *Kb for stack
kernel_stack: ; <= stack_space
I cant understand, what happens to "call kernel_main" instruction ?
this is "kernel.c", there is like nothing, just clear vid.mem. buffer
#include "kernel.h" // <<< extern void kernel_main();
void kernel_main() {
char * BUFF = (char*) 0xb8000;
int i=0;
int ii=0;
while ( i < 80*25) {
BUFF[ ii++ ] = '#';
BUFF[ ii++ ] = 0x7;
i++;
}
}
also "grub-file --is-x86-multiboot kernel.bin" is "multiboot confirmed"
[SOLVED] I do not know how it cat be, bud it works now. Its MAGIC | 0x1BADB002
I wrote kernel is AT&T syntax, sub could not implement all things i need. GDT, and IDT keeps crashing, so i test one more time with kernel.s [NASM]
And MAGIC, it works now. Yeeeeeeeeeeyyy :p