Page 1 of 1

64 Bit Booting

Posted: Thu Jul 06, 2006 6:36 am
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???????? :?:

Ooops

Posted: Thu Jul 06, 2006 6:48 am
by jakelstr
Sorry people,
I got my bits backward.
Should read

Code: Select all

[BITS 16] [BITS 32] [BITS 64]

Posted: Thu Jul 06, 2006 7:19 am
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

Tools

Posted: Thu Jul 06, 2006 7:22 am
by jakelstr
For the bootloader I am using NASM, os code gcc, and ld :lol:

Posted: Thu Jul 06, 2006 7:35 am
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

Thanks

Posted: Thu Jul 06, 2006 7:43 am
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:

Posted: Thu Jul 06, 2006 8:05 am
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

Posted: Thu Jul 06, 2006 8:10 am
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

Thanks

Posted: Thu Jul 06, 2006 9:13 am
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:

Posted: Thu Jul 06, 2006 9:32 am
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)

Posted: Thu Jul 06, 2006 9:46 am
by jakelstr
thanks jaaman, you've been a huge help today!!!

Posted: Thu Jul 06, 2006 10:06 am
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.