Help With Booting Kernel.bin
Posted: Wed Jan 26, 2011 7:04 pm
I Followed The Simple C Kernel http://www.osdever.net/tutorials/pdf/basickernel.pdf. I Just Finished Compiling it, and i got a .bin File. i used the Grub Version,So i just want to know how to boot with grub.
CODE:
Kernel.c
kernel_start.asm
Thanks!
CODE:
Kernel.c
Code: Select all
#define WHITE_TXT 0x07 // white on black text
void k_clear_screen();
unsigned int k_printf(char *message, unsigned int line);
k_main() // like main in a normal C program
{
k_clear_screen();
k_printf("Hi!\nHow's this for a starter OS?", 0);
};
void k_clear_screen() // clear the entire text screen
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
while(i < (80*25*2))
{
vidmem[i]=' ';
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
unsigned int k_printf(char *message, unsigned int line) // the message and then the line #
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
i=(line*80*2);
while(*message!=0)
{
if(*message=='\n') // check for a new line
{
line++;
i=(line*80*2);
*message++;
} else {
vidmem[i]=*message;
*message++;
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
return(1);
};
Code: Select all
%include "grub.inc" ; needed for the multiboot header
[BITS 32]
[global start]
[extern k_main] ; this is in the c file
start:
call k_main
cli ; stop interrupts
hlt ; halt the CPU
; these are in the linker script file
EXTERN code, bss, end
ALIGN 4
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; aout kludge. These must be PHYSICAL addresses
dd mboot
dd code
dd bss
dd end
dd start
Thanks!