I've just spent the better part of 6 hours writing my own bootloader and kernel, although heavily referenced from tutorials, it's 99% my handwritten code, and I've come accross a slight problem. Heap memory doesn't work. In my kernel.c file, if I have this:
Code: Select all
void _entry()
{
???unsigned char???*vidmem = (unsigned char *)0x0b8000;???
???vidmem[40] = '!';
???vidmem[41] = 0x07;
???for(;;);
}The fact that I know nothing about asm and the GNU tools doesn't help either. I think the problem has to do with my linking methods and the bootloader. The bootloader loads the next 10 sectors of the image I'm using into 0x7e00, and then executes it in protected mode. But my linking script has the initial address at the 1mb mark or something.
I'd be really appreciative if someone could give me an answer to this problem that was in ultra-simple asm-illiterate language. That or you could make me go off and use the Linux boot script like I'm going to have to if I don't solve this problem. I have my bootloader attached and the linker script below. Tools are nasm, ld, gcc and my own file appending tool, kappend, as well as the .NET 2003 IDE.
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}