problem with bootin

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
asdfgh
Member
Member
Posts: 42
Joined: Fri Apr 18, 2008 9:14 pm

problem with bootin

Post 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 ?
CodeCat
Member
Member
Posts: 158
Joined: Tue Sep 23, 2008 1:45 pm
Location: Eindhoven, Netherlands

Re: problem with bootin

Post by CodeCat »

Does it use any 64 bit stuff at all?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: problem with bootin

Post 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).
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Re: problem with bootin

Post 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)?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: problem with bootin

Post by pcmattman »

Ah, my mistake. Thanks for that, I'll keep that in mind ;).
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: problem with bootin

Post 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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: problem with bootin

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: problem with bootin

Post 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? :^o
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: problem with bootin

Post 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).
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: problem with bootin

Post 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? :^o
I read the Intel manuals and got confused about the 64/32 bit compatibility stuff :P. So it's not really uninformed as much as misinformed.
Post Reply