Help With Booting Kernel.bin

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
techsandwhich
Posts: 1
Joined: Wed Jan 26, 2011 7:01 pm

Help With Booting Kernel.bin

Post by techsandwhich »

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: 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);
};
kernel_start.asm

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!
Last edited by techsandwhich on Wed Jan 26, 2011 11:05 pm, edited 2 times in total.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Help With Booting Kernel.bin

Post by gerryg400 »

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 ?
Post Reply