Large fixed arrays in basic 'kernel'
Posted: Thu Feb 21, 2008 6:33 am
Hello,
In an attempt to get a starter 'kernel' going, I have hit a bit of a snag (to me at least)...
My problem is with large fixed arrays declared at compile-time in C. Specifically when passing their pointer to a function.
for example:
My boot loader merely reads two tracks off of a floppy disk (where the kernel is saved) loads it to 0x1000, sets cr0, creates a basic GDT with a DS of base 0 to limit FFFFF and a CS of base 0 to limit FFFFF.
Paging is not enabled.
The bootsector then jumps into the 'kernel' and continues execution there.
At this point the system reboots (does NOT occur in VirtualBox, Bochs, etc...)
If I make the array global, the reboot does not occur, presumably because it's not being put into the stack like the inline array.
I realize malloc would be a better way to acquire space, but malloc doesn't exist yet.
Can anyone explain to me why this is happening? I'd be nice to know how to fix it too
If you need to see my bootsector, it'll have to wait until I get home tonight
Thanks for any help!
In an attempt to get a starter 'kernel' going, I have hit a bit of a snag (to me at least)...
My problem is with large fixed arrays declared at compile-time in C. Specifically when passing their pointer to a function.
for example:
Code: Select all
void foo(void *p);
void KernelMain() {
char a[0x1000]; /* not that this is very big */
/* if I boot with this call, then the system will reboot */
foo(a);
}
void foo(void *p) {
/* doesn't matter */
}
Paging is not enabled.
The bootsector then jumps into the 'kernel' and continues execution there.
At this point the system reboots (does NOT occur in VirtualBox, Bochs, etc...)
If I make the array global, the reboot does not occur, presumably because it's not being put into the stack like the inline array.
I realize malloc would be a better way to acquire space, but malloc doesn't exist yet.
Can anyone explain to me why this is happening? I'd be nice to know how to fix it too
If you need to see my bootsector, it'll have to wait until I get home tonight
Thanks for any help!