OSDev.org
https://forum.osdev.org/

Help With Booting Kernel.bin
https://forum.osdev.org/viewtopic.php?f=1&t=23046
Page 1 of 1

Author:  techsandwhich [ Wed Jan 26, 2011 7:04 pm ]
Post subject:  Help With Booting Kernel.bin

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
Code:
#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);
};


kernel_start.asm
Code:
%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!

Author:  gerryg400 [ Wed Jan 26, 2011 7:26 pm ]
Post subject:  Re: Help With Booting Kernel.bin

techsandwhich wrote:
Well i followed the osdever tutorial for the grub simple c kernel, made a bin file.but i can't boot it. HElP? :!:
Techsandwhich, do you think you have provided enough information for someone to help you ?

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/