64 Bit Booting

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
User avatar
jakelstr
Member
Member
Posts: 52
Joined: Wed Jul 05, 2006 9:30 am

64 Bit Booting

Post by jakelstr »

Hi all.
I think I am going to make my OS 64 bit only. When booting, do you have to call [64 BITS] just as you do [32 BITS] to get into 64 bit mode? Also if you have to do this can you go from 16 to 64 bits or do you still have to go 16-32-64 BITS???????? :?:
User avatar
jakelstr
Member
Member
Posts: 52
Joined: Wed Jul 05, 2006 9:30 am

Ooops

Post by jakelstr »

Sorry people,
I got my bits backward.
Should read

Code: Select all

[BITS 16] [BITS 32] [BITS 64]
User avatar
JAAman
Member
Member
Posts: 880
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

without knowing what tools you are using, its hard to tell what you have to do, as each tool does things a little differently
User avatar
jakelstr
Member
Member
Posts: 52
Joined: Wed Jul 05, 2006 9:30 am

Tools

Post by jakelstr »

For the bootloader I am using NASM, os code gcc, and ld :lol:
User avatar
JAAman
Member
Member
Posts: 880
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

nasm cannot do 64bit mode

if you want 64bit asm, try fasm, yasm, intels tool (not sure what its called), or masm

(intel is free on linux, masm is free on windows)


the manuals recomend using PMode as an intermediate state (going from 16bit to PMode then to LMode), but it may not be necessary -- never really got a clear answer, afaik, from brendens question at AMD, but because it is listed as such in the manuals, some 3rd party (not AMD or Intel) CPUs might have trouble going directly

personally, i plan to support both, so going to PMode first is obvious (also if you ever plan to use VMode (for BIOS calls, for example) you cannot use VMode from LMode)

make sure you have the latest manuals (from either intel or AMD -- both are essentially the same, just a different orginization) Intels version can be downloaded or ordered from the link in my sig
User avatar
jakelstr
Member
Member
Posts: 52
Joined: Wed Jul 05, 2006 9:30 am

Thanks

Post by jakelstr »

Hey, Thanks a lot. This will really help me. i was reading the AMD x86-64 white paper, and aparently i have to load 64bit, then can activate legacy 16 and 32 bit modes to allow these programs.
thank you :wink:
User avatar
JAAman
Member
Member
Posts: 880
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

no, actually, 16bit mode cannot be done from LMode -- there is no VMode within LMode

really, get the intel manuals -- they will really help you understand loading, and using, LMode -- much more than the white-paper will
User avatar
JAAman
Member
Member
Posts: 880
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

sorry, i guess my sig got dissabled:
anyway, the intel manuals can be downloaded here

also from that page there is a link to the information about ordering hard-copies -- i really recomend it, its completely free (including shipping)

get all 5 books, and read through volume 3a a couple times before proceeding -- especially chapters 3 - 6
User avatar
jakelstr
Member
Member
Posts: 52
Joined: Wed Jul 05, 2006 9:30 am

Thanks

Post by jakelstr »

Thanks alot guys, the intel (or AMD) manuals will really help, i'm going to get them as soon as i get off here. One last thing, are there any example kernels that use 64 BITS? I could really use them.
Thanks :wink:
User avatar
JAAman
Member
Member
Posts: 880
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

i dont know of any... not to say that there arnt any

basically doing it in LMode is just like doing it in PMode, except some of the structures are different, and you cannot use hard-task-switching (which most people avoid anyway)
User avatar
jakelstr
Member
Member
Posts: 52
Joined: Wed Jul 05, 2006 9:30 am

Post by jakelstr »

thanks jaaman, you've been a huge help today!!!
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

You can get a example here : http://board.flatassembler.net/topic.php?t=5421
its for yasm and fasm, but it triple faults if int are enabled in the fasm one.
Post Reply