Page 1 of 1
problem with bootin
Posted: Wed Oct 22, 2008 11:29 am
by asdfgh
Hai i have made a 32 bit os following james molloy tuturial and tested it.
it shows no problem with bochs.
i tested it in intel celeron processor and it worked fine..
but if i test it in any of 64bit processors or newer intel processors it jus reboots after grub is loaded..
what is the reason ?
Re: problem with bootin
Posted: Wed Oct 22, 2008 12:40 pm
by CodeCat
Does it use any 64 bit stuff at all?
Re: problem with bootin
Posted: Thu Oct 23, 2008 12:24 am
by pcmattman
Because a 64-bit processor won't run a 32-bit OS? I know it has compatibility modes to run 32 bit code, but I doubt it'll run a 32-bit OS (at least, AFAIK).
Re: problem with bootin
Posted: Thu Oct 23, 2008 12:33 am
by xyzzy
pcmattman wrote:Because a 64-bit processor won't run a 32-bit OS? I know it has compatibility modes to run 32 bit code, but I doubt it'll run a 32-bit OS (at least, AFAIK).
No. If that was the case, GRUB wouldn't even run
x86_64 processors can run both 32-bit and 64-bit OSes, depending on what CPU mode you are in.
@asdfgh: What processors exactly does this happen on? Also, does it happen if you run it on 64-bit QEMU (qemu-system-x86_64)?
Re: problem with bootin
Posted: Thu Oct 23, 2008 12:50 am
by pcmattman
Ah, my mistake. Thanks for that, I'll keep that in mind
.
Re: problem with bootin
Posted: Thu Oct 23, 2008 1:36 am
by ~
asdfgh wrote:Hai i have made a 32 bit os following james molloy tuturial and tested it.
it shows no problem with bochs.
i tested it in intel celeron processor and it worked fine..
but if i test it in any of 64bit processors or newer intel processors it jus reboots after grub is loaded..
what is the reason ?
Try to make a test kernel that just basically sets protected mode register values.
Try to load the DS, ES, FS and GS registers with valid segment numbers, maybe to the default data segment for testing purposes.
Also, and probably most importantly, reload the SS register to a proper data segment for the stack (it can be the default 4GB data segment I guess) and then reload the ESP register to point just the end of the stack. For example if the end of your kernel stack is at 0x500000, give ESP the value of
0x500000-1 (please somebody correct in case substracting 1 is incorrect).
Try it out. My first kernels, which loaded from floppy using a custom Master Boot Record always failed for this kind of things, in a HP Vectra VL 5/200 Series 4.
Re: problem with bootin
Posted: Thu Oct 23, 2008 2:10 am
by Brendan
Hi,
asdfgh wrote:it shows no problem with bochs.
i tested it in intel celeron processor and it worked fine..
but if i test it in any of 64bit processors or newer intel processors it jus reboots after grub is loaded..
what is the reason ?
I'd assume it has more to do with "newer processors" than it has to do with "64-bit processors"...
For example, it could be that the newer computers have more RAM and there's a bug in the memory manager initialization, or that a reserved bit is set somewhere that's ignored on older CPUs but used for something on newer CPUs, or that TLB's aren't being invalidated properly and the bug only shows itself if the CPU has large enough TLBs, or some sort of race condition that only causes problems if the CPU is fast enough, or the code detects some new feature is present and tries to use or initialize it and fails (but doesn't try to use the feature or fail on older CPUs that don't have the feature), or uses uninitialized RAM which happens to be set to zero on some computers, or...
Basically it could be any sort of problem with any piece of code; and without much useful information you won't get many useful answers.
You could try inserting something like "
for(;;);" near the start of the code and see if it locks up instead of rebooting, and then keep shifting this line of code and retrying until you know exactly where it reboots. Implementing some temporary/basic screen output and/or exception handling might help too. Alternatively, you could comment out parts until it works, then slowly remove the comments.
Cheers,
Brendan
Re: problem with bootin
Posted: Thu Oct 23, 2008 6:59 am
by Brynet-Inc
pcmattman wrote:Because a 64-bit processor won't run a 32-bit OS? I know it has compatibility modes to run 32 bit code, but I doubt it'll run a 32-bit OS (at least, AFAIK).
How can anyone be so uninformed?
Re: problem with bootin
Posted: Thu Oct 23, 2008 11:39 am
by 01000101
I think the OP should be reading the Intel/AMD manuals and maybe just some general computer theory books before diving into 32-bit programming (in general, not just OS development).
Re: problem with bootin
Posted: Fri Oct 24, 2008 4:49 pm
by pcmattman
Brynet-Inc wrote:pcmattman wrote:Because a 64-bit processor won't run a 32-bit OS? I know it has compatibility modes to run 32 bit code, but I doubt it'll run a 32-bit OS (at least, AFAIK).
How can anyone be so uninformed?
I read the Intel manuals and got confused about the 64/32 bit compatibility stuff
. So it's not really uninformed as much as misinformed.