Loading Kernel with GRUB.

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
CETian

Loading Kernel with GRUB.

Post by CETian »

     I'm currently in the making of an OS. I've loaded my Kernel with GRUB. Currnetly i've setup paging,can perform multitasking,etc.. My problem is that form the start i linked my kernel to be loaded at 1MB mark. Now i'm thinking about making a kernel level memory allocator. I want to load my kernel at a virtual address say 3GB mark and located at 1MB physical memory. How can we accomplish it usnig grub. GRUB is refused to load kernel linked to address 0xC0000000. I'ii be really thankful if someone helps me...
ka3r

RE:Loading Kernel with GRUB.

Post by ka3r »

You have to create a linker script for the kernel like this one (which should work with your code):

OUTPUT_FORMAT("elf32-i386")
ENTRY(_start)
_phys_base = 0x100000;
_virt_base = 0xC0000000;
SECTIONS
{
. = _phys_base;
. = _virt_base;

.text _virt_base : AT (_phys_base)
    {   code = .;
        *(.text);
    }
    .rodata : AT (_phys_base + (rodata - code))
    {   rodata = .;
         *(.rodata*);
    }
    .data : AT (_phys_base + (data - code))
    {   data = .;
         *(.data);
    }
    .bss : AT (_phys_base + (bss - code))
    {   bss = .;
. = ALIGN(4096);
        *(.bss)
        *(COMMON);
    }
    _end = .;
}

I use this for my kernel and it does work great!
CETian

RE:Loading Kernel with GRUB.

Post by CETian »

     I'm greatly thankful to the reply to the question. It was the first time i visited this site, and it looks great.
Post Reply