Page 1 of 1

kernel size causes error.

Posted: Thu Jun 26, 2008 11:04 am
by suthers
I don't get this error, When my kernel get's to much code, It starts making weird error.
I've just recently added some code for fetching the time in my kernel.
I don't even call it..., but I get absolutely no output from my kernel after the clear screen... except that the text cursor turns red...
I know it gets to the end of my kernel, the EIP that bochs gives me corresponds to where the loop is.
I also looked at a few of the printfs and the address for the text passed to them are correct, I really don't get it...
If I comment out the #include for the time header, it works again, so it's definitely something to do with the size, I also checked quite a few calls and they all point to the right address, so I don't see what it could be....
Any suggestions as to what it could be?
Thanks in advance,

Jules

Re: kernel size causes error.

Posted: Thu Jun 26, 2008 11:13 am
by inflater
Hmm, aren't you overwriting something in memory? Try setting the stack if you don't have one, or set it bigger. Or set it somewhere else.

What bootloader are you using? If your kernel is loaded from real mode, be sure the file size is under 64 kB, if you are using second stage bootloader or GRUB, it doesn't matter.

Re: kernel size causes error.

Posted: Thu Jun 26, 2008 11:36 am
by suthers
My stack is fine, it's nearly 1Kb long (1000 bytes).
I don't think its a problem with that.
My bootloader is custom, but it passes to the kernel loaded at 0x100000 in protected mode, but anyway, my kernel is still well under 64K, (just over 20K).
But I looked through the memory with bochs, and the strings aren't where they should be...
So it's either a bootloader problem or something is writing where it shouldn't be....
Thanks,

Jules

Re: kernel size causes error.

Posted: Thu Jun 26, 2008 11:46 am
by piranha
Try booting with GRUB. Then you'll know better where the problem lies.

-JL

Re: kernel size causes error.

Posted: Thu Jun 26, 2008 2:00 pm
by suthers
I checked where certain strings where meant to be in memory as soon as my kernel loaded and they weren't present, seems like my loader is buggy...
Oh God, save my soul... :lol:
Jules

Re: kernel size causes error.

Posted: Thu Jun 26, 2008 3:47 pm
by suthers
Its not a problem, I just wrote originally to only load 35 sectors...
35 * 512 = 17.5K...
My kernel is just over 20K and the string are at then end of the kernel, so their not loaded by the bootloader...
obvious error, but I couldn't figure it out because I hadn't looked at it in ages and had sort of forgotten about it existence... :oops:
I'll work on it tomorrow...
Thanks for the help (without it, I would have looked through every single instruction generated by my kernel to figure out hat was going wrong, then probably blamed grub, then maybe in a week thought of looking at the bootloader :lol: )
Thanks,

Jules

Re: kernel size causes error.

Posted: Fri Jun 27, 2008 10:02 am
by suthers
Thanks, fixed it this morning, no problems now...
Thanks,
Jules

Re: kernel size causes error.

Posted: Sat Jun 28, 2008 2:16 am
by pcmattman
You might want to write your bootloader to load the kernel some other way, or load sectors until it reads a sector that has some magic value or something, or else you're going to have a lot of fun updating your kernel in the future ;).

Re: kernel size causes error.

Posted: Sat Jun 28, 2008 3:24 am
by suthers
That's exactly what I'm working on doing right now :D
Thanks,

Jules