Jump to content

AMD Lion Kernel


deadreaper
 Share

98 posts in this topic

Recommended Posts

Sorry if it shows my utter ignorance on the subject, but the ssse3 instructions emulator must necessarily be written in assembly?

 

A high level language, (aka as an HLL, e. g., C, Java, etc.) can be thought of as the Sargent who orders a private to dig the trenches. Assembly language can be thought of as the private who actually does the digging. In other words, assembly language is closer to the actual machine language that the processor uses than the HLL.

 

In the early days of compiler design, not much effort was put into creating the most efficient implementation of an algorithm, and higher compiled languages typically ran slower then they should. In those cases where you needed responsive code (say communications on a PC), assembly language was used instead. It's also very tedious to write and rather boring, because one HLL statement can involve from as few as one (shift) to a as many as several hundred (so I was told, other's can correct me). (I recall that OS2 v2.0 was written in assembly! Which was the only way they could ensure a GUI worked responsively on a 80286 at the time; check out MS Windows for 286 and you will understand why.)

 

 

Since then, compilers have come a long way in implementing clever short-cuts in code. Nowadays, there's very little to be gained to the point that you'd be challenged to write an assembly level version. But when new instruction come out, there's a learning curve involved with implementing them in an efficient manner in a compiler. Hence, we're better off writing at the assembly language level.

 

From what little I see on wikipedia, I note that there are 16 discrete instructions for SSSE3. Presuming the various different kinds of execution for each instruction, we're looking at a lot of assembly instructions.

 

The other problem is that fact that the hardware that can't be use the SSSE3 instruction is now obsolete. As time goes on, more folks will upgrade to hardware and the demand incentive to emulate SSSE3 will fade away. Unless there's a concerted effort by folks on this and other boards to make the patch for a working 64-bit 10.7 and beyond using AMD's sans SSSE3 will be gone by the end of the year.

 

At least that's my take on it, YMMV.

  • Like 2
Link to comment
Share on other sites

Sorry if it shows my utter ignorance on the subject, but the ssse3 instructions emulator must necessarily be written in assembly?

To add to user_hostile's point, an SSSE3 emulator is unnecessary. With the old SSE3 emulator in years past, that was necessary because the kernel and many applications (and Rosetta) used SSE3. Here with SSSE3, the instructions (AFAIK) are only in the kernel and not in applications; therefore an on-the-fly dynamic emulator is not needed, but rather some brilliant mind needs to translate the SSSE3 instructions to SSE3 so it is a static (doesn't change) translation. :)

  • Like 1
Link to comment
Share on other sites

Is there somewhere a starter guide for devs in AMD assembly (or x86 assembly, if it's not any difference)? No, just kidding: i have barely basic knowledge of c-type languages and unfortunately don't have the time and skills necessary to do the task. Let's hope for something from Nawcom, if he's really better from his health issues, or for some undiscovered pro-AMD talented person to show up.

Link to comment
Share on other sites

To add to user_hostile's point, an SSSE3 emulator is unnecessary. With the old SSE3 emulator in years past, that was necessary because the kernel and many applications (and Rosetta) used SSE3. Here with SSSE3, the instructions (AFAIK) are only in the kernel and not in applications; therefore an on-the-fly dynamic emulator is not needed, but rather some brilliant mind needs to translate the SSSE3 instructions to SSE3 so it is a static (doesn't change) translation. :)

 

And you fought my ignorance. So if I understand this problem, it's matter of taking the source code of the kernal, compiling it into assembly, doing a search for the instruction, swapping it out with a macro, and living happily ever after, right?

 

I'm only trying to understand the scale of the work involved here (the SSSE3 to SSE3 conversion is a separate issue)

  • Like 1
Link to comment
Share on other sites

Is there somewhere a starter guide for devs in AMD assembly (or x86 assembly, if it's not any difference)? No, just kidding: i have barely basic knowledge of c-type languages and unfortunately don't have the time and skills necessary to do the task. Let's hope for something from Nawcom, if he's really better from his health issues, or for some undiscovered pro-AMD talented person to show up.

Haha actually there are good Assembly guides out there; it's not the most complex language! :D

 

Yeah, nawcom healthwise is doing great, haven't seen any activity on his blog in a while though. He's still on irc.osx86.hu, which is a good sign. :)

 

And you fought my ignorance. So if I understand this problem, it's matter of taking the source code of the kernal, compiling it into assembly, doing a search for the instruction, swapping it out with a macro, and living happily ever after, right?

 

I'm only trying to understand the scale of the work involved here (the SSSE3 to SSE3 conversion is a separate issue)

Very close. Basically in the kernel source there are a bunch of C headers and C files, along with Assembly files for certain kernel instructions. So basically one goes into the source, modifies the Assembly files as needed, and compiles. :)

  • Like 1
Link to comment
Share on other sites

It just has come to my mind: we have patches for AMD, made by bronzovka and rawx86. Using some text tool, can't we just separate the specific AMD instructions by comparing with the vanilla source and then apply them to the Mountain Lion source? Or even better, following and useful advice from Meklort, apply them as a binary patch to the Mountain Lion binary? It would be possible to test it?

 

If yes, i'm willing to do it and make the experiment. Can someone point me to some text tool that make possible to compare and extract the differences between two texts (these would be the patched kernel and the vanilla kernel) saving me the time to do it by eye, so i can re-patch it and compile it for mountain lion instead?

 

Can someone explain me what tools and procedures do i use to apply a binary patch to the binary kernel?

Link to comment
Share on other sites

I thought the same thing theconnactic, however I soon realized that Mountain Lion is 100% 64-bit ONLY, so if this did work, only those with AMD Bulldozer cpus with SSSE3 would be able to actually start the OS. :P We need those SSSE3 > SSE3 Translations! (But no rush, i'm fine on ubuntu until i can get a modern version of OS X on this computer)

  • Like 1
Link to comment
Share on other sites

I'm running Lion 10.7.4 and, as i said, it runs just fine on my PC. But 32-bit only, so no Finder and other 64-bit apps (even my CPU being a 64-bit capable CPU; ssse3 is crucial for Lion to support 64-bit apps on 32-bit mode).

 

With Mountain-Lion, as you said, we'll definitely need a ssse3 emulator for non-FX CPUs, but even that won't be enough: until now, we couldn't get a Lion 64-bit kernel to work on AMD CPUs, even Buldozer ones; the maximum we got was 64-bit app support, only on Buldozer CPUs. To run Mountain Lion, we've got to do better than that: we'll need a 64-bit kernel and the ssse3 emulator (a static one, easier than the previous on the fly sse3 emulator, but still no easy a task) for the non-FX CPUs. So the road ahead has a lot of pitfalls.

Link to comment
Share on other sites

Haha actually there are good Assembly guides out there; it's not the most complex language! :D

 

Could you give me the directions to one that's available on the internet for free download?

 

 

Yeah, nawcom healthwise is doing great, haven't seen any activity on his blog in a while though. He's still on irc.osx86.hu, which is a good sign. :)

 

Glad to hear that! So he abandoned AMD hackintoshing altogether?

 

 

Very close. Basically in the kernel source there are a bunch of C headers and C files, along with Assembly files for certain kernel instructions. So basically one goes into the source, modifies the Assembly files as needed, and compiles. :)

 

Do you have an idea of what have i to look for in order to adapt the XNU kernel to run on AMD machines? As for the ssse3 emulator, has it to be written in assembly? Do you have, or do you know where do i find a copy of the source of the old sse3 emulator (which would serve as a good example of how to start an emulator for ssse3)?

Link to comment
Share on other sites

Could you give me the directions to one that's available on the internet for free download?

Try a few of the following:

 

1. http://www.drpaulcarter.com/pcasm/

2. http://www.friedspace.com/assembly/intro.php

3. http://savannah.nongnu.org/projects/pgubook/ (hit the Downloads link to download it)

Glad to hear that! So he abandoned AMD hackintoshing altogether?

No, it's just that his AMD machine broke and he didn't have the money for a new one; last I heard he was trying to scrape enough together for a cheap AMD build...

Do you have an idea of what have i to look for in order to adapt the XNU kernel to run on AMD machines? As for the ssse3 emulator, has it to be written in assembly? Do you have, or do you know where do i find a copy of the source of the old sse3 emulator (which would serve as a good example of how to start an emulator for ssse3)?

Yes; all you have to do is edit the assembly files in the source, which are labeled with a .s extension. One example is bcopy.s. Just look for .s files in the XNU source.

 

And, I believe I said this before, but you do not need to write an SSSE3 emulator! All you need to do is edit all the .s files, change SSSE3 calls to SSE3, and that should do the trick. :) An emulator is not necessary at all; it would be extra and unneeded work. Just translate the SSSE3 calls to SSE3 and see how it rolls. ;)

  • Like 1
Link to comment
Share on other sites

Thank you, Pooky! This is quite valuable information!

 

So this ssse3 calls are found always inside the assembly code, right? Or could some of them have been written in c? If it's the case, do you know the appearance that a ssse3 call statement would have in c?

 

I'm planning to make some experiences with the latest Mountain Lion and the Lion XNU kernel, keeping in mind your suggestions about simply changing ssse3 calls to sse3 calls, as soon as i gain some fluence in assembly coding. Or, if it's possible to be done in c, i can do it tonight. :)

Link to comment
Share on other sites

Is your SATA controller an ATI one? If not, it won't work.

 

You said you used CCC, huh? I have my doubts about the capability of CCC to make a bootable hackintosh HD clone. Maybe you solve this issue by reinstalling chameleon (use the one from Mountain Lion installation topics).

Link to comment
Share on other sites

My best advice is that you wipe your installation out and start all over again, using devout's method ([AMD] 10.7.3 Guide - Experimental Only - InsanelyMac Forum), that worked like a charm for me. Since you already have an OSX installation, you won't lose anything: when everything is up and running, you connect your other HD, the one from which you made your cloning in the first place, then you use OSX's Migration Tools to import your settings, programs etc. (but after use it, don't forget to check if it don't messed with your kernel before you restart your machine.)

 

If you don't want to resort to such drastic measures, i think some of this solutions are a bit outdated, but maybe you want to try (one of) them:

 

http://www.ihackinto...or-root-device/

 

http://apple2pc.blog...oot-device.html

 

http://osx86.co/f85/...1467/page3.html

 

Please report back, for us to know what worked in the end.

Link to comment
Share on other sites

Here's what I tried in the meantime:

 

Downloaded Niresh v2 10.7.3 and burned iso to disc: Doesn't even load Chameleon bootloader, stuck at blinking underscore

 

Install ATI and AHCI packages from Niresh iso to laptop HDD using existing hackintosh and USB 3.0 to SATA adapter: Didn't do anything

 

Install SuperVIAATA package from Niresh iso (also contains my SATA-controllers ID (0x43911002)) to laptop HDD:

 

 

 

localhost kernel[0]: kxld[com.c0rk007hck.SuperVIAATA]: The Mach-O file is malformed: Invalid magic number: 0xfeedfacf.

localhost kernel[0]: Can't load kext com.c0rk007hck.SuperVIAATA - link failed.

localhost kernel[0]: Failed to load executable for kext com.c0rk007hck.SuperVIAATA.

localhost kernel[0]: Kext com.c0rk007hck.SuperVIAATA failed to load (0xdc008016).

localhost kernel[0]: Failed to load kext com.c0rk007hck.Super

Link to comment
Share on other sites

 Share

×
×
  • Create New...