64-bit OS howto

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
amitron94
Posts: 2
Joined: Fri Apr 23, 2010 12:33 pm

64-bit OS howto

Post by amitron94 »

"Just make a 32-bit kernel! It's easier!"
No. 32-bit is the past. ;) We're in the future, despite obvious lack of flying cars.

So, anyway, how do I actually go about doing this? I need actual code samples and stuff because I'm a relative noob.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: 64-bit OS howto

Post by NickJohnson »

User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: 64-bit OS howto

Post by Creature »

amitron94 wrote:"Just make a 32-bit kernel! It's easier!"
No. 32-bit is the past. ;) We're in the future, despite obvious lack of flying cars.

So, anyway, how do I actually go about doing this? I need actual code samples and stuff because I'm a relative noob.
If you're relatively new to the subject, I certainly wouldn't recommend jumping into 64-bit. It makes sense to say 64-bit is the way to go, but it certainly complicates things a lot, for example:
  • You will need extra setup to get a 64-bit kernel up and running.
  • Long mode requires PAE (it MUST be on before switching), if you never really understood paging or didn't get the hang of it, this will be a bottleneck.
  • The easiest ways of getting BIOS interrupts working (VM8086 and switching back to real mode) are impossible (or perhaps possible in some very complicated way if you manage to turn off long mode again, with huge amounts of overhead perhaps). Instead you will need specific drivers or an emulator of some sorts.
If that didn't convince you, Stephan Van Schaik is working on a tutorial relating 64-bit and long mode. Other information may be found on the wiki.

EDIT: Nick beat me to it.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
amitron94
Posts: 2
Joined: Fri Apr 23, 2010 12:33 pm

Re: 64-bit OS howto

Post by amitron94 »

So I guess I'll stick to 32-bit, and once I can I'll rewrite it as 64-bit... (I hope by then GRUB 2 will get awesomeness that allows you to launch directly into long mode and stuff, but it's another one of my pipe dreams.)
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: 64-bit OS howto

Post by gravaera »

You know, all of these newbies who run around saying things like "32-bit is archaic" really get tiresome after a while, since they seem not to know what they're talking about as there are millions of embedded devices which are running today on 32-bit low-end CPUs and whose companies are not going to switch to 64-bit processors for an embedded device for at least probably another ~5 years, if so few.

Of course, if you're writing a single-platform kernel for x86-IBM_PC then by all means, go ahead and stick yourself to 64-bit x86. 32-bit CPUs *still* make up the largest CPU-type both in current distribution, and in the number of them that have already been released. and for quite a while after this, they'll remain so.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: 64-bit OS howto

Post by Owen »

The most common CPU type in distribution today is 8-bit. By sales volume, it is most probably clones of the Intel 8051 architecture (8-bitters vastly outsell bigger processors, and the 8051 has a large dominance there - largely because it is a defacto standard architecture used by multiple manufacturers).

The single biggest seller of 8-bit microcontrollers is Microchip (And its PIC lines), however.
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: 64-bit OS howto

Post by gravaera »

Mm. I see, thanks for the correction :) .

Either way, the whole "32-bit is gone" argument remains shaky.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
TylerH
Member
Member
Posts: 285
Joined: Tue Apr 13, 2010 8:00 pm
Contact:

Re: 64-bit OS howto

Post by TylerH »

The whole point is not to spend time on something that will become obsolete within the foreseeable future. Albeit 64bit will eventually go the way of the Z80, it's not going to happen within the next 10 years and probably not in the next 20.

Although I see the OP's point, I still agree 32bit, if not 16bit, is the way to go for your first OS. One shouldn't fool oneself into thinking one's first attempt will be worth anything but the knowledge one gains from making it, as soon as one starts to get anything of any importance one will realize the mistakes one made while learning. Those mistakes will be numerous.
Post Reply