OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Sep 20, 2020 5:27 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Help With Booting Kernel.bin
PostPosted: Wed Jan 26, 2011 7:04 pm 
Offline

Joined: Wed Jan 26, 2011 7:01 pm
Posts: 1
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!


Last edited by techsandwhich on Wed Jan 26, 2011 11:05 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Help With Booting Kernel.bin
PostPosted: Wed Jan 26, 2011 7:26 pm 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
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 ?

_________________
If a trainstation is where trains stop, what is a workstation ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group