powerpc and intel

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
feare56
Member
Member
Posts: 97
Joined: Sun Dec 23, 2012 5:48 pm

powerpc and intel

Post by feare56 »

I recently got a PowerMac g5 dp 2.3 GHz and was wondering if I could use a universal boot loader and kernel. I am redoing my work so I figured I would get it bootable from both my laptop and PowerMac
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: powerpc and intel

Post by iansjack »

I'm not quite sure what you are asking here. The boot process on a PPC Mac is very different from a normal PC and the instruction set and architecture are completely different. Code that runs on one won't run on the other. I suppose that you could produce binaries that contained kernels for both architectures (as in OS X universal binaries), but what's the point?
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: powerpc and intel

Post by Casm »

iansjack wrote:I'm not quite sure what you are asking here. The boot process on a PPC Mac is very different from a normal PC and the instruction set and architecture are completely different. Code that runs on one won't run on the other. I suppose that you could produce binaries that contained kernels for both architectures (as in OS X universal binaries), but what's the point?
I don't know about the architecture or load address for the boot code, but Apple switched to the x86 processors some years ago; so the instruction set is the same. I do know that it uses EFI during the boot process, so the loader can have the nice property of being written in C.

Having an x86 processor inside it doesn't necessarily mean that a Mac is now a PC in disguise. The only way to find that out is to consult some technical reference manuals.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: powerpc and intel

Post by iansjack »

Casm wrote:
iansjack wrote:I'm not quite sure what you are asking here. The boot process on a PPC Mac is very different from a normal PC and the instruction set and architecture are completely different. Code that runs on one won't run on the other. I suppose that you could produce binaries that contained kernels for both architectures (as in OS X universal binaries), but what's the point?
I don't know about the architecture or load address for the boot code, but Apple switched to the x86 processors some years ago; so the instruction set is the same.
The description "G5" might be taken as a clue.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: powerpc and intel

Post by dozniak »

Casm wrote:I don't know about the architecture or load address for the boot code, but Apple switched to the x86 processors some years ago; so the instruction set is the same.
G5 is a PowerPC machine. The instruction set is very different from x86.
Learn to read.
feare56
Member
Member
Posts: 97
Joined: Sun Dec 23, 2012 5:48 pm

Re: powerpc and intel

Post by feare56 »

But in theory I could make the universal binary because apple did do that for a couple of mac releases during the Intel switch
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: powerpc and intel

Post by NickJohnson »

feare56 wrote:But in theory I could make the universal binary because apple did do that for a couple of mac releases during the Intel switch
"Universal" binaries either contained two copies of the program code, one for PowerPC and one for x86, or used software emulation of PowerPC instructions on x86 (I believe Apple called this feature "Rosetta"). Either way, you need some sort of program loader (and maybe an emulation layer) to be running as native code before you can run a binary like that.

In addition, even though things work pretty cleanly using emulation in userspace, the kernel needs to deal with a lot of idiosyncracies of each processor type, so you are going to have at least some of your HAL written using native assembly and architecture-specific logic, which is inherently not portable.

If you want the sort of functionality where you can take a single image (e.g. a CD image) and boot it on multiple architectures, that basically would involve the equivalent of writing two kernels (or one portable kernel compiled twice, containing a lot of arch-specific code) and two bootloaders and packaging them on the same media. You don't get portability for free.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: powerpc and intel

Post by iansjack »

feare56 wrote:But in theory I could make the universal binary because apple did do that for a couple of mac releases during the Intel switch
The kernel wasn't a universal binary. Can you see why?
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: powerpc and intel

Post by dozniak »

"Universal binaries" did contain two copies of the executable code in the so-called "fat" MachO files. There was i686 code and powerpc code. This is similar to "fat binaries" used during m68k to PPC transition starting 1994. ELF has a preliminary proposal called FatELF to make elfs support the same configuration.

Older PPC binaries were supported by the translation layer called Rosetta, up until Lion. Starting with Lion the PPC architecture is no longer supported.
Learn to read.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: powerpc and intel

Post by Owen »

iansjack wrote:The kernel wasn't a universal binary. Can you see why?
/mach_kernel on my Intel MacBook was a Universal binary (back when that was relevant, because there were still i386 and em64t kernels)

Having the kernel in a fat binary is a useful thing (think bootable CDs, netboot images) but is completely irrelevant to the need for a bootloader per boot architecture...

Still, it seems feare56 needs to go and learn OpenFirmware...
feare56
Member
Member
Posts: 97
Joined: Sun Dec 23, 2012 5:48 pm

Re: powerpc and intel

Post by feare56 »

Ok I would have to make the two of each, so would I have to write a pre-bootloader so to speak and detect which processor it is and jump to the intel or ppc bootloader? Is it better to just keep them separate on different disks
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: powerpc and intel

Post by iansjack »

Owen wrote:
iansjack wrote:The kernel wasn't a universal binary. Can you see why?
/mach_kernel on my Intel MacBook was a Universal binary (back when that was relevant, because there were still i386 and em64t kernels)
I think we are talking about different varieties of "universal" binaries. The discussion here is about PPC & x86 code, not 32/64 bit code. Even the bootloaders are different for PPC and x86 kernels. What point would there be in trying to combine both varieties of code in one binary? If you want to boot both varieties of the kernel from one CD you just have two binaries on the CD.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: powerpc and intel

Post by Combuster »

Bottom line is that these "universal binaries" are just an irrelevant buzzword to the whole problem. There is still one compiled binary per platform to cover each of the platforms, and each of the platforms need a dedicated bootloader.

I could pack the bootstrap for several possible platforms together with each of the kernels and userland tools for each of the platforms, create an iso file with all these files and bootstraps, then call the resulting CD image an "universal binary" - it is a binary file and it works over all the intended platforms. :wink:


At any rate, get yourself an OFW bootstrap, El-torito bootstrap and an EFI one, see if you can stick them on a CD or DVD together without getting conflicts between them, then drop in the architecture-specific code in whatever casting shape you might want them, and go testing the result.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: powerpc and intel

Post by Owen »

iansjack wrote:I think we are talking about different varieties of "universal" binaries. The discussion here is about PPC & x86 code, not 32/64 bit code. Even the bootloaders are different for PPC and x86 kernels. What point would there be in trying to combine both varieties of code in one binary? If you want to boot both varieties of the kernel from one CD you just have two binaries on the CD.
The same point there was for doing it for i386/x86_64: permitting one image to boot multiple machines.

For example: It saves space if one NetBoot image can handle all four architectures (ppc, ppc64, i386, x86_64). And, in Apple's case, only one binary on a HFS partition can be "blessed".
feare56
Member
Member
Posts: 97
Joined: Sun Dec 23, 2012 5:48 pm

Re: powerpc and intel

Post by feare56 »

The question now is should I support ppc64 or just stick with Intel since that is the machine I do all my coding and testing in a vm? Plus would the possibilities that I could add be more on Intel or my ppc64 which is clocked at a higher speed than the Intel.
Post Reply