Help - Search - Members - Calendar
Full Version: My Bootloader
Project OS X Forums > OS X 10.6 (Snow Leopard) > Bootloaders
Pages: 1, 2, 3
maceshka
Hello Slice. Could you upload latest revision of your Bootloader, please.
Slice
QUOTE (maceshka @ Mar 17 2011, 02:56 PM) *
Hello Slice. Could you upload latest revision of your Bootloader, please.

I stopped the project working on EFI bootloader. The version RC5m-721 is the last and best Chameleon. @topic.

OK. There is rev749 in topic
SMF
Slice,

Question on install - I use extra/extensions and boot from EFI. I don't build an .mkext as I only have FakeSMC and LegacyHDA kexts with an otherwise vanilla install. With Asere's bootloader and now Chameleon RC5 it boots fine. Your bootloader doesn't work for me - do you check for and use extensions in /Volumes/EFI/Extra/Extensions?

bdmesg from Chameleon RC5 r750 boot.

Click to view attachment

Regards,
SMF
Slice
QUOTE (SMF @ Mar 27 2011, 02:36 AM) *
Slice,

Question on install - I use extra/extensions and boot from EFI. I don't build an .mkext as I only have FakeSMC and LegacyHDA kexts with an otherwise vanilla install. With Asere's bootloader and now Chameleon RC5 it boots fine. Your bootloader doesn't work for me - do you check for and use extensions in /Volumes/EFI/Extra/Extensions?

bdmesg from Chameleon RC5 r750 boot.

Click to view attachment

Regards,
SMF

I didn't change this part of base Chameleon. Extensions should be loaded from bt(0,0)/Extra/Extensions.
Try to play with modules - remove unnecessary.
SMF
Slice,

I tried booting with GUI, HPET, klibc, Memory, Networking, and Resolution. I can only get it to boot if I use -f (ignore caches) and it appears that my DSDT is not being processed - my screen resolution is locked at 1024 x 768.

Here's my bdmesg.

Click to view attachment

I understand you've moved on to the EFI booter but wanted to send on my results for you in case it i helpful. If you would like me to test something let me know.

Regards,
SMF
Slice
QUOTE (SMF @ Mar 27 2011, 11:02 PM) *
Slice,

I tried booting with GUI, HPET, klibc, Memory, Networking, and Resolution. I can only get it to boot if I use -f (ignore caches) and it appears that my DSDT is not being processed - my screen resolution is locked at 1024 x 768.

Here's my bdmesg.

Click to view attachment

I understand you've moved on to the EFI booter but wanted to send on my results for you in case it i helpful. If you would like me to test something let me know.

Regards,
SMF

No, resolution doesn't depend on DSDT. BIOS reads EDID if possible. In your case it is not happen.
About cache - something wrong in your kext's set. Try to delete all caches.
SMF
Slice,

I tried deleting all caches - I can boot without -f but still have problems with resolution. With Chameleon I get full resolution at the graphic bootscreen and in OSX after booting. With your booter I'm stuck at 1024x768. Looking at the bdmesg I see the booter is trying PCI Root x0 and my system uses x1 (Gigabyte P35-DQ6). I also notice that it's not reading my FSB speed consistently - I have overclocked to 400 but in some places it's reading 333 - you'll see that in my bdmesg. For some reason it still seems that it's not reading my DSDT.aml.

Sorry that my programming skills are so rusty I can't dig through your code and try to figure it out on my own.

Regards,
SMF
Slice
Not sure if it works
CODE
PciRoot=<value>         Use an alternate value for PciRoot (default value 0).
SMF
QUOTE (Slice @ Mar 28 2011, 02:23 AM) *
Not sure if it works
CODE
PciRoot=<value>         Use an alternate value for PciRoot (default value 0).



Slice,

I thought of that but won't have an ability to test for a few days. However that is not necessary with Chameleon - it keeps me going back to a belief that my DSDT is not being processed with your bootloader. With Chameleon and Asere's bootloader I don't need that in my boot.plist. It's taken care of in my DSDT.

Regards,
SMF
Slice
QUOTE (SMF @ Mar 28 2011, 02:34 PM) *
Slice,

I thought of that but won't have an ability to test for a few days. However that is not necessary with Chameleon - it keeps me going back to a belief that my DSDT is not being processed with your bootloader. With Chameleon and Asere's bootloader I don't need that in my boot.plist. It's taken care of in my DSDT.

Regards,
SMF

Nonsense.
How did you imagine a bootloader for hackintosh that can not process DSDT.aml?
SMF
QUOTE (Slice @ Mar 29 2011, 12:28 PM) *
Nonsense.
How did you imagine a bootloader for hackintosh that can not process DSDT.aml?


Slice,

I know it's crazy but if I look at the bdmesg when I boot Chameleon (posted above) I can see that it's processing my DSDT.aml and my /Extra/Extensions. If you look at the bdmesg from when I boot with your bootloader I see none of that reported. I've checked permissions on my DSDT.aml and the file structure of my /Extra folder matches yours and it's the same I have been using with Asere's bootloader and now with Chameleon RC5. The only difference is the addition of the modules directory. I have GUI, klibc, Memory, and Resolution installed. When I boot with your bootloader I'm stuck with 1024x768 resolution in the bootloader gui and at the OSX desktop. It all seems to point to my DSDT.aml not being processed.

Regards,
SMF
Slice
No, I just disabled messages from ReadFile to speedup booting. DSDT is loading that you can check by making some patch for cosmetics.
For example
CODE
                Device (GIGE)
                {
                    Name (_ADR, Zero)
                    Name (_SUN, 0x02)
                    Method (_DSM, 4, NotSerialized)
                    {
                        Store (Package ()
                            {
                                "model",
                                Buffer (0x21)
                                {
                                    "Marvell Yukon 8040 Fast Ethernet"
                                },

                                "device_type",
                                Buffer (0x09)
                                {
                                    "Ethernet"
                                },
                                
                                "built-in",
                                Buffer (One)
                                {
                                    0x00
                                }
                            }, Local0)
                        DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
                        Return (Local0)
                    }
                }

You problem seems to be unsupported Video card by my GraphicsEnabler.
Hmm, you didn't install it?
SMF
Slice,

I'll try again. I have an NVIDIA GeForce 9800 GT. I think I've tried it with and without the graphics enabler module. I'm so stumped with why it's not working that I'll have to go back to square one with more modules installed and try it. I thought that even if I didn't use the graphics enabler for boot my DSDT would take care of that in OSX. It certainly works with Chameleon. I'll try it and see what I get in System Profiler. Attached is a picture of what I get with Chameleon RC5 and my DSDT.

Regards,
SMF

Click to view attachment

SMF
Slice,

Yes. I wasn't clear in my last message. None of the customizations in my DSDT - the graphics card name, etc. is shown after I boot with your bootloader. My DSDT is not being loaded.

Regards,
SMF


QUOTE (Slice @ Mar 31 2011, 03:43 AM) *
Did you try my advice to check if DSDT is loaded?
Slice
QUOTE (SMF @ Apr 1 2011, 07:39 PM) *
Slice,

Yes. I wasn't clear in my last message. None of the customizations in my DSDT - the graphics card name, etc. is shown after I boot with your bootloader. My DSDT is not being loaded.

Regards,
SMF

Place your dsdt into root of booted partition and name it exactly "DSDT.aml".

You also can customize from prompt
"dsdt=/test/test_dsdt.aml"
akbar102
hi slice
i am get your last version on your trankm branche after installing i am geting instand reboot after this:
loading driver :....../extra/extension.mkext
please.can you provide a doc about change that you make in your branch?
thanks for your work.
Slice
First of all, I want to say that I based on latest trunk and keep my codes in sync with it.
I didn't change anything concerning /Extra b/c I didn't like it. Let it be the same as trunk.
About your issue try the follow:
- boot with -f option;
- erase the mkext;
- take latest revision of the bootloader.

Now I want to report what is the difference.
1. i386/Cconfig
CODE
    string "Optimization Level"
-    default "-Oz"
+    default "-Os"

AFAIK there is no -Oz for Apple's gcc-4.2.1. Level -Os gives me fastest and smallest codes.
2. i386/boot2/boot.c
CODE
char gMacOSVersion[8];
+void *gRootPCIDev;
+void *gPlatform;
+void *gBootOrder;
+void *gSMBIOS;
+int gDualLink;

I need these global variables to exchange data between modules.
3. i386/boot2/boot.h
CODE
+extern char gMacOSVersion[];
+extern int     bvCount;
+extern void *gRootPCIDev;
+extern void* gPlatform;
+extern void* gBootOrder;
+extern uint16_t vgaVendor;;

External definitions for them.
4. i386/boot2/graphics.h
CODE
+extern int gDualLink;

This variable is needed for GraphicsEnabler after modules Resolution do its work.
5. i386/boot2/gui.c
CODE
+    gDualLink =((screen_params[0] * screen_params[1]) > (1<<20))?1:0; //Slice - needed for GMAX3100

Thus for screen 1024x768 gDualLink=0 while for 1440x900 gDualLink=1.
6. i386/boot2/modules.c
CODE
-        verbose("Invalid mach magic 0x%X\n", ((struct mach_header*)binary)->magic);
+//        verbose("Invalid mach magic 0x%X\n", ((struct mach_header*)binary)->magic);

sad.gif Just disable the message as I don't know a reason for it.
7. i386/libsaio/Makefile
CODE
-    convert.o aml_generator.o console.o
+    convert.o aml_generator.o console.o exfat.o

Added support for exFAT file system by dmazar
8. i386/libsaio/acpi_patcher.c
CODE
+#include "smbios_getters.h"

I need some relations between SMBIOS and ACPI.
CODE
+bool fix_restart;
+uint64_t acpi10_p;
+uint64_t acpi20_p;
+
+int rsdplength;
+void *new_dsdt=NULL;
+
+extern char* gSMBIOSBoardModel;
+

These variables defined as local in different procedures. I made them common for all module.
CODE
-        verbose("ACPI table not found: %s\n", filename);
+        //verbose("ACPI table not found: %s\n", filename);

-                printf("Couldn't read table %s\n",dirspec);
+                //verbose("Couldn't read table %s\n",dirspec);

These spam about missing SSDT is not interesting. The user knows that these files are absent.
CODE
-    if (Platform.CPU.Vendor != 0x756E6547) {
+    if (Platform->CPU.Vendor != 0x756E6547) {

I changed Platform structure definition to pointer and allocate the structure dynamically because I had an issue with losing address of static variable in modules system.
CODE
-                    case 0x0D:                // ???
+                    case CPU_MODEL_PENTIUM_M:                // ???

CPU_MODEL_PENTIUM_M=0x0d. Why not write it explicitly?
CODE
-    struct acpi_2_fadt *fadt_mod;
+    struct acpi_2_fadt *fadt_mod = NULL;
    bool fadt_rev2_needed = false;
-    bool fix_restart;
+    bool fix_restart_acpi = false;

These variables may be used uninitialized.
CODE
    // Restart Fix
-    if (Platform.CPU.Vendor == 0x756E6547) {    /* Intel */
+//    if (Platform->CPU.Vendor == 0x756E6547) {    /* Intel */
        fix_restart = true;
-        getBoolForKey(kRestartFix, &fix_restart, &bootInfo->chameleonConfig);
+        value = getStringForKey(kRestartFix, &bootInfo->chameleonConfig);
+        if (value[0] == 'A') {
+            fix_restart_acpi = true;
+        } else if (value[0] == 'P') {
+            fix_restart_acpi = false;
+        } else {
+            fix_restart = false;
+        }
+/*

Now RestartFix has three states = ACPI | PS2 | NO. http://forum.voodooprojects.org/index.php/topic,1056.0.html
CODE
+        if (fix_restart_acpi) {
+            fadt_mod->Flags|= 0x400;
+            fadt_mod->Reset_SpaceID        = 0x01;   // System I/O
+            fadt_mod->Reset_BitWidth    = 0x08;   // 1 byte
+            fadt_mod->Reset_BitOffset    = 0x00;   // Offset 0
+            fadt_mod->Reset_AccessWidth    = 0x01;   // Byte access
+            fadt_mod->Reset_Address        = 0x0cf9; // Address of the register
+            fadt_mod->Reset_Value        = 0x06;   // Value to write to reset the system
+            msglog("FADT: ACPI Restart Fix applied!\n");            
+        } else {
+            fadt_mod->Flags|= 0x400;
+            fadt_mod->Reset_SpaceID        = 0x01;   // System I/O
+            fadt_mod->Reset_BitWidth    = 0x08;   // 1 byte
+            fadt_mod->Reset_BitOffset    = 0x00;   // Offset 0
+            fadt_mod->Reset_AccessWidth    = 0x01;   // Byte access
+            fadt_mod->Reset_Address        = 0x64; // Address of the register
+            fadt_mod->Reset_Value        = 0xfe;   // Value to write to reset the system
+            msglog("FADT: PS2 Restart Fix applied!\n");            
+        }

So the user can choose the best method for him.
CODE
    // Determine system type / PM_Model
+    if (fadt_mod && Platform->Type) {
+        fadt_mod->PM_Profile = Platform->Type;
+    } //else do not change anything
+

Sometimes FACP contains wrong value for PM_Profile. I want to force the setting based on calculation in SMBIOS (will be explained later).
CODE
    /* XXX aserebln why uint32 cast if pointer is uint64 ? */
-    acpi10_p = (uint32_t)getAddressOfAcpiTable();
-    acpi20_p = (uint32_t)getAddressOfAcpi20Table();
+            //Slice because rsdp_mod is a pointer (32bit in i386) to a structure uint64_t*
+    acpi10_p = (uint64_t)(uint32_t)getAddressOfAcpiTable();
+    acpi20_p = (uint64_t)(uint32_t)getAddressOfAcpi20Table();

Warning eliminatings.
CODE
+static struct acpi_2_xsdt* createNewXSDTfromRSDT(struct acpi_2_rsdt * rsdt)
+{

And many new codes correspond to conversion from ancient ACPI1.0 to ACPI2.0 that obligatory for MacOSX.
CODE
    // Load replacement DSDT
    new_dsdt = loadACPITable(dirSpec);
+    struct acpi_2_dsdt* dsdt = (struct acpi_2_dsdt*)new_dsdt;
+    if (new_dsdt) {
+        msglog("DSDT.aml loaded from %s\n", dirSpec);
+        strncpy(dsdt->OEMID, "Apple ", 6);
+        strncpy(dsdt->OEMTableId, MacModel, 8);
+        dsdt->OEMRevision = ModelRev;
+        dsdt->Checksum=0;
+        dsdt->Checksum=256-checksum8(new_dsdt,dsdt->Length);
+        
+    }

Cosmetics(?) for System Profiler. http://www.insanelymac.com/forum/index.php...&start=560#
CODE
            {                
                ssdt_count++;
            }
-            else
+/*            else
            {
                break;
-            }
+            }*/

Before if SSDT.aml, SSDT-1.aml and SSDT-3.aml are present the loading breaks before SSDT-3 was loading. Now continue search all 30 tables.
CODE
+                    //Now I want to replace DSDT in place
+                    // it is only way to patch DSDT on some platform
+                    old_dsdt = (char *)fadt->DSDT;

And some new codes to copy new_dsdt in place of old_dsdt. It works!
CODE
                /*FIXME: Now we just hope that if MacOS doesn't find XSDT it reverts to RSDT.
                 * A Better strategy would be to generate
                 */
+                //Slice - it is possible only for ACPI20
+                if (version) {
+                    if(rsdp->RsdtAddress){
+                        rsdp_mod->XsdtAddress =
+                        (uint64_t)(uint32_t)createNewXSDTfromRSDT((struct acpi_2_rsdt*)rsdp->RsdtAddress);
+                        continue;
+                    }
+                    else
+                        DBG(" no sample to create XSDT, dropping\n");
+                }

This FIXME comment origins from mackerintel AFAIK and still remain in newest trunk.
Slice
Continue.
9. i386/libsaio/acpi_patcher.h
CODE
+//Slice - it's bullshit to define variables in header file
+//uint64_t acpi10_p;
+//uint64_t acpi20_p;
+//uint64_t smbios_p;

If a header file are included in two different c files then variables will be different.
10. i386/libsaio/cpu.c
CODE
-                DBG("msr(%d): platform_info %08x\n", __LINE__, bitfield(msr, 31, 0));
+                DBG("msr(0x%04x): platform_info %08x-%08x\n", MSR_PLATFORM_INFO,
+                (msr >> 32) & 0xffffffff, msr & 0xffffffff);

What do you want to see in bdmesg.log, source line number or number of used MSR?
CODE
-        /* Mobile CPU */
-        if (rdmsr64(MSR_IA32_PLATFORM_ID) & (1<<28)) {
+        /* Mobile CPU ? */
+//Slice
+        msr = rdmsr64(MSR_IA32_PLATFORM_ID);
+        DBG("msr(0x%04x): MSR_IA32_PLATFORM_ID 0x%08x\n", MSR_IA32_PLATFORM_ID, msr & 0xffffffff); //__LINE__ - source line number :)
+        if (msr) {
+            p->CPU.Mobile = FALSE;
+            switch (p->CPU.Model) {
+                case 0x0D:
+                    p->CPU.Mobile = TRUE; // CPU_FEATURE_MOBILE;
+                    break;
+                case 0x0F:
+                    p->CPU.Mobile = FALSE; // CPU_FEATURE_MOBILE;
+                    break;
+                case 0x02:
+                case 0x03:
+                case 0x04:
+                case 0x06:    
+                    p->CPU.Mobile = (rdmsr64(MSR_P4_EBC_FREQUENCY_ID) && (1 << 21));
+                    break;
+                default:
+                    p->CPU.Mobile = (rdmsr64(MSR_IA32_PLATFORM_ID) && (1<<28));
+                    break;
+            }
+            if (p->CPU.Mobile) {
            p->CPU.Features |= CPU_FEATURE_MOBILE;
        }

The mobility calculation is not common for any CPU.
11. i386/libsaio/device_inject.c
CODE
-    verbose("efi_inject_get_devprop_string NULL trying stringdata\n");
+//    verbose("efi_inject_get_devprop_string NULL trying stringdata\n");

The spam.
CODE
-  uint32_t strlength;
-  char *string = efi_inject_get_devprop_string(&strlength);
+//  uint32_t strlength;
+  char *string = efi_inject_get_devprop_string(&stringlength);

-    cnt = strlength * 2;
+    cnt = stringlength * 2;

Reusing variable instead of creating new one. Is it a bug?
12. i386/libsaio/disk.c
CODE
+                    case FDISK_LINUX:
+                        bvr = newGPTBVRef(biosdev, gptID, gptMap->ent_lba_start, gptMap,
+                                          0, 0, 0, 0, 0, 0, EX2GetDescription,
+                                          (BVFree)free, 0, kBIOSDevTypeHardDrive, 0);
+                        break;

An attempt to detect Linux. http://forum.voodooprojects.org/index.php/topic,1832.0.html
CODE
BVRef diskScanBootVolumes( int biosdev, int * countPtr )
{
-    struct DiskBVMap *        map;
+    struct DiskBVMap *        map = NULL;

The variable may be used uninitialized.
13. i386/libsaio/fake_efi.c
CODE
-#include "smbios.h"
+#include "smbios_getters.h"

I need more relations between SMBIOS and EFI.
CODE
+    smbios_p = (EFI_PTR32)getSmbios(SMBIOS_PATCHED);    // process smbios asap
+    bool useDMIinfoCPU = true;
+    getBoolForKey("GetCPUfromBIOS", &useDMIinfoCPU, &bootInfo->bootConfig);
+    if (useDMIinfoCPU) {
+        scan_cpu_DMI(); //Platform);
+    }

Here I want to explain more.
For example. Intel Core 2 Duo E6300. Native BusSpeed=266MHz, default CPU speed=266*6=1600MHz. It is very low and I can easy to overclock it.
366*7=2562MHz. But coeff=7 is turbo, MSR inform us about max=6 turbo=7. So what Chameleon will calculate?
TSC speed=2560Mhz ratio=6 and follow FSB=467MHz with following system bugs.
On the other hand, if we took FSB from MSR it will be 266 but not 366 as we set.
Other user report http://forum.voodooprojects.org/index.php/topic,1912.0.html
So I suppose to not calculate CPU and FSB speed and just take them from DMI. So some additional codes in SMBIOS_patcher needed.
CODE
    // Generate efi device strings
+        //Slice - remember globals
+    Platform = (PlatformInfo_t *)gPlatform;
+    root_pci_dev = (pci_dt_t*)gRootPCIDev;
    setup_pci_devs(root_pci_dev);
+    smbios_p = (EFI_PTR32)getSmbios(SMBIOS_ORIGINAL);
+#if DEBUG    
+    verbose("SMBIOS_ORIGINAL=%x \n", smbios_p);
+#endif    
    
-    readSMBIOSInfo(getSmbios(SMBIOS_ORIGINAL));
+    getSmbiosTableStructure((void*)(EFI_PTR32)smbios_p);
+    readSMBIOSInfo((void*)(EFI_PTR32)smbios_p);

+    getSmbiosProductName();
+    getSmbiosMacModel();
+    setupAcpi();

These codes appears to do the work.
14. i386/libsaio/gma.c
CODE
+#include "graphics.h"

Remember globals.
CODE
-uint8_t GMAX3100_vals[22][4] = {
-    { 0x01,0x00,0x00,0x00 },
....
+//Slice - correct all values, still not sure
+uint8_t GMAX3100_vals[23][4] = {
+    { 0x01,0x00,0x00,0x00 },    //0 "AAPL,HasPanel"

I correct these values according to my working X3100.
CODE
+        devprop_add_value(device, "AAPL01,DualLink", &gDualLink, 1);        //GMAX3100_vals[10]

As calculated by Resolution module.
CODE
+//        devprop_add_value(device, "AAPL01,InverterCurrency",GMAX3100_vals[15], 4);

What is the Currency?
15. i386/libsaio/hfs.c
CODE
-    verbose("Read HFS%s file: [%s/%s] %d bytes.\n",
-            (gIsHFSPlus ? "+" : ""), devStr, filePath, (uint32_t)length);
+//    verbose("Read HFS%s file: [%s/%s] %d bytes.\n",
+//            (gIsHFSPlus ? "+" : ""), devStr, filePath, (uint32_t)length);

I consider this as a main patch to Chameleon smile.gif
I do not want to see 200 lines about loading kexts in IgnoreCache mode. 5 minutes to see them !!!
16. i386/libsaio/msdos.c
CODE
-    verbose("Read FAT%d file: [%s/%s] %d bytes.\n",
-            msdosfatbits, devStr, filePath, (uint32_t)( toread<0 ) ? wastoread : wastoread-toread);
+//    verbose("Read FAT%d file: [%s/%s] %d bytes.\n",
+//            msdosfatbits, devStr, filePath, (uint32_t)( toread<0 ) ? wastoread : wastoread-toread);

Same here.
17. i386/libsaio/nvidia.c
CODE
-static uint8_t default_dcfg_0[]        =    {0xff, 0xff, 0xff, 0xff};
-static uint8_t default_dcfg_1[]        =    {0xff, 0xff, 0xff, 0xff};
+static uint8_t default_dcfg_0[]= {0x03, 0x01, 0x03, 0x00};
+static uint8_t default_dcfg_1[]= {0xff, 0xff, 0x00, 0x01};

Default values should be reliable for users who can't set own values.
CODE
+static uint8_t default_NVPM[]= {
+    0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00
+};

This is useful setting.
CODE
+    delay(50);

Wait for PCI bus.
18. i386/libsaio/pci.c
CODE
+            new->subclass                = pci_config_read8(pci_addr, PCI_CLASS_PROG);

I want to see more info about PCI devices.
CODE
+    
+    if (!root_pci_dev)
+        return;
+    gRootPCIDev = (void*)root_pci_dev;

Safety. The reason is losing pci pointer in some cases.
CODE
-        printf("%02x:%02x.%x [%04x] [%04x:%04x] (subsys [%04x:%04x]):: %s\n",
+        msglog("%02x:%02x.%x [%04x%02x] [%04x:%04x] (subsys [%04x:%04x]):: %s\n",
            current->dev.bits.bus, current->dev.bits.dev, current->dev.bits.func,
-            current->class_id, current->vendor_id, current->device_id,
+               current->class_id, current->subclass, current->vendor_id, current->device_id,

Dump more PCI infos.
19. i386/libsaio/pci.h
CODE
-    }                        subsys_id;
-
+    }subsys_id;
+    uint8_t        revision;
+    uint8_t        subclass;

Required change in definition.
20. i386/libsaio/pci_setup.c
CODE
+uint16_t vgaVendor;
......
-                    switch (current->vendor_id)
+                {
+                    vgaVendor = current->vendor_id;
+                    switch (vgaVendor)
                    {

The variable needed for SMBIOS patch.
Slice
Continue.
21. i386/libsaio/platform.c
CODE
void scan_platform(void)
{
-    memset(&Platform, 0, sizeof(Platform));
+    Platform = malloc(sizeof(PlatformInfo_t));
+    memset(Platform, 0, sizeof(PlatformInfo_t));
+    gPlatform = (void*)Platform;

As I already mentioned I want to make Platform structure is dynamically allocated.
22. i386/libsaio/platform.h
CODE
+extern void scan_cpu();
+
+#define bit(n)            (1ULL << (n))
+#define bitmask(h,l)        ((bit(h)|(bit(h)-1)) & ~(bit(l)-1))
+#define bitfield(x,h,l)        (((x) & bitmask(h,l)) >> l)
+#define MEGA 1000000LL

defined here instead of two places.
CODE
+        float            MaxRatio;        // non-integer ratio    
+        float            MinRatio;
+        float            CurrRatio;                
        uint64_t        TSCFrequency;            // TSC Frequency Hz
        uint64_t        FSBFrequency;            // FSB Frequency Hz
        uint64_t        CPUFrequency;            // CPU Frequency Hz
-        uint32_t        MaxRatio;                // Max Bus Ratio
-        uint32_t        MinRatio;                // Min Bus Ratio
+        bool            Mobile;                    // Mobile CPU

Ratio may be non-integer.
CODE
-extern PlatformInfo_t Platform;
+extern PlatformInfo_t* Platform;

Now it is a pointer.
23. i386/libsaio/smbios.c
CODE
#define kDefaultMacBook                                "MacBook4,1"
-#define kDefaultMacBookBIOSVersion                    "    MB41.88Z.0073.B00.0903051113"
+#define kDefaultMacBookBIOSVersion                    "    MB41.88Z.0073.B00.0809221748"

Some default values corrected
CODE
+#define MAX_DMI_TABLES 255
+typedef struct DmiNumAssocTag {
+    SMBStructHeader* dmi;
+    uint8_t type;
+} DmiNumAssoc;
+
+static DmiNumAssoc DmiTablePair[MAX_DMI_TABLES];
+static int DmiTablePairCount = 0;
+static int current_pos=0;
+static bool ftTablePairInit = true; //use twice first run and after

New structures and variables to do smbios patching.
CODE
+void getSmbiosTableStructure(struct SMBEntryPoint *smbios)
+{
...

and so on...
CODE
-    if (platformCPUFeature(CPU_FEATURE_MOBILE))
+    if (Platform->Type == 2)        //platformCPUFeature(CPU_FEATURE_MOBILE))
    {

Platform mobility must not be related to CPU mobility but Enclosure type because there are Books with desktop CPU and iMacs with mobile CPU.
CODE
-        if (Platform.CPU.NoCores > 1)
+        if (vgaVendor != PCI_VENDOR_ID_INTEL) //Slice

Choice between MacBook and MacBookPro. It is not Nr of Cores b/c MacBook4,1 (which is default) has Core 2 Duo T8200 with 2 cores.
CODE
void addSMBOemProcessorBusSpeed(SMBStructPtrs *structPtr)
{
...
                default:
-                    return;
+                    tmp = (Platform->CPU.FSBFrequency * 4) / MEGA;
+                    break;
+                    //return;
            }

This is defined in AppleSMBIOS http://opensource.apple.com
CODE
+            case kSMBTypeSystemEnclosure:
+                tmp = ((SMBSystemEnclosure *)structHeader)->type;
+                Platform->Type = (tmp >=8)?2:1;
+                break;
+            case kSMBTypeProcessorInformation:
+                tmpW = ((SMBProcessorInformation *)structHeader)->externalClock;
+                Platform->CPU.FSBFrequency = tmpW * MEGA + (tmpW & 7) * 110000; //According to Intel 133->133.33MHz
+                tmpW = ((SMBProcessorInformation *)structHeader)->currentClock;
+                Platform->CPU.CPUFrequency = tmpW * MEGA + (tmpW & 7) * 110000;
+                msglog("From SMBIOS: FSB=%d CPU=%d\n", Platform->CPU.FSBFrequency, Platform->CPU.CPUFrequency);
+                break;
+

Took values from original SMBIOS.
24. i386/libsaio/smbios_decode.c
CODE
-    DBG("\tversion: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->version));
+//    DBG("\tversion: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->version));

These values are not printable and mess debug and bdmesg.
25. i386/libsaio/smbios_getters.c
CODE
+//Slice - for ACPI patcher templates
+int        ModelLength = 0;
+char    MacModel[8] = "MacBook";
+unsigned int ModelRev = 0x00010001;
+uint64_t smbios_p;
+char*    gSMBIOSBoardModel;

Data exchange with ACPIpatcher.
CODE
bool getSMBOemProcessorBusSpeed(returnType *value)
{
.......
                    case CPU_MODEL_YONAH:        // Intel Mobile Core Solo, Duo
                    case CPU_MODEL_MEROM:        // Intel Mobile Core 2 Solo, Duo, Xeon 30xx, Xeon 51xx, Xeon X53xx, Xeon E53xx, Xeon X32xx
                    case CPU_MODEL_PENRYN:        // Intel Core 2 Solo, Duo, Quad, Extreme, Xeon X54xx, Xeon X33xx
                    case CPU_MODEL_ATOM:        // Intel Atom (45nm)
-                        return false;
+                        value->word = ((Platform->CPU.FSBFrequency * 4)/1000000); //Slice
+                        return true;

Double.
CODE
                    case CPU_MODEL_WESTMERE_EX:    // Intel Xeon E7
+                    case CPU_MODEL_SANDY:
+                    case CPU_MODEL_SANDY_XEON:    
                    {
                        // thanks to dgobe for i3/i5/i7 bus speed detection

Why not?
CODE
+void getSmbiosMacModel(void)
+{
+#define MAX_MODEL_LEN    32
+    
+    //Slice - I want to use MacModel for ACPITables so I need char* representation

Calculated here.
CODE
+void getSmbiosProductName()
+{
........
+        strncpy(gSMBIOSBoardModel, tempString, tmpLen);
+        Node* node = DT__FindNode("/", false);
+        DT__AddProperty(node, "orig-model", tmpLen, gSMBIOSBoardModel);
+    }
+    verbose("Actual model name is '%s'\n", tempString);
+}

Nice cosmetic from other chameleon codes.
CODE
+void scan_cpu_DMI(void) //PlatformInfo_t *p)
+{
........
+            Platform->CPU.FSBFrequency = (cpuInfo->externalClock) * MEGA;
...
+            Platform->CPU.CPUFrequency = cpuInfo->currentClock * MEGA;
....
+            Platform->CPU.NoCores = cpuInfo->coreCount;
...
+            Platform->CPU.NoThreads = cpuInfo->Threads;

Instead of scan_cpu calculations.
26. i386/libsaio/sys.c
CODE
+// zef - ramdisk variables
+extern BVRef  gRAMDiskVolume;
+extern bool   gRAMDiskBTAliased;
+
...
+            // turbo - bt(0,0) hook
+            if ((dp->biosdev + unit) == 0x101) {
+                // zef - use the ramdisk if available and the alias is active.
+                if (gRAMDiskVolume != NULL && gRAMDiskBTAliased) {
+                    bvr = gRAMDiskVolume;
+                } else {
+                    bvr = gBIOSBootVolume;
+                }
+            } else {
            bvr = newBootVolumeRef(dp->biosdev + unit, partition);
+            }
...
-        bvr = newBootVolumeRef(biosdev, part);
+
+        // turbo - bt(0,0) hook
+        if (biosdev == 0x101)
+        {
+          // zef - use the ramdisk if available and the alias is active.
+          if (gRAMDiskVolume != NULL && gRAMDiskBTAliased)
+            bvr = gRAMDiskVolume;
+          else
+            bvr = gBIOSBootVolume;
+        }
+        else
+        {
+            bvr = newBootVolumeRef(biosdev, part);
+        }

Don't know about this codes. I found it in some other branch.
27. i386/libsaio/xml.c
CODE
+    TagPtr tmpTag;
...
-    TagPtr tmpTag = NewTag();
+    tmpTag = NewTag();
...
-        tmpTag = NewTag();

In this algo I reorder assignment to aviod losing pointers and uninitialized variables.


Also I am experimenting with modules from meklort, cparm, azimutz but still no news. Only Resolution is working.
nobb1x
hello, i'm trying rev1208 with lion. i get a immediate reset after the initial loading,i tried erasing cache,with -x,with -f, with no changes. currently i'm using a usb stick for boot and the bootloader is installed on it.
Using -v i can see (until it reboot)

(...smbios infos...)
Actual modelname is 'N/A
/ (i see some activity on the hdd)
Starting darwin kernel (immediate reboot)
the smbios infos appear as parsed correctly,cpu recognized too with correct clock.

my system (a laptop) boot ok with chameleon v1187.

this is the Extra folder i use with the loader.

Click to view attachment

fakesmc and ps2 support are on S/L/E.
Slice
QUOTE (nobb1x @ Jul 26 2011, 02:20 PM) *
hello, i'm trying rev1208 with lion. i get a immediate reset after the initial loading,i tried erasing cache,with -x,with -f, with no changes. currently i'm using a usb stick for boot and the bootloader is installed on it.
Using -v i can see (until it reboot)

(...smbios infos...)
Actual modelname is 'N/A
/ (i see some activity on the hdd)
Starting darwin kernel (immediate reboot)
the smbios infos appear as parsed correctly,cpu recognized too with correct clock.

my system (a laptop) boot ok with chameleon v1187.

this is the Extra folder i use with the loader.

Click to view attachment

fakesmc and ps2 support are on S/L/E.

Exclude KernelPatcher.dylib. It is not work yet.
kyndder
Hy Slice!!!

I did a test with your Bootloader and a strange thing happened ...

System performance in general improved, however, I was slow video...

Actually I was very confused, QE/CI were fully active, the system started much more faster, as the applications, but the video slow ...

Here are my details if you need > http://www.mediafire.com/file/u6478vq09f01bh5/Slice.zip

Thank you.
Slice
Compared to?
1. Other OS version
2. Other Chameleon version
3. XPC bootloader
kyndder
QUOTE (Slice @ Aug 1 2011, 09:04 AM) *
Compared to?
1. Other OS version
2. Other Chameleon version
3. XPC bootloader


Compared with the same OS version (Lion) and the currently Build that i'm using 1187.
Slice
So it seems to be an GPUPM that is switched on on my version of Chameleon vs off in trunk version.
my propositions:
Try to tune
/System/Library/Extensions/AppleGraphicsControl.kext
/System/Library/Extensions/AppleGraphicsPowerManagement.kext
/System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/ACPI_SMC_PlatformPlugin.kext/Contents/Resources

Or I can remake my Chameleon if you are interesting.
kyndder
QUOTE (Slice @ Aug 2 2011, 02:54 AM) *
So it seems to be an GPUPM that is switched on on my version of Chameleon vs off in trunk version.
my propositions:
Try to tune
/System/Library/Extensions/AppleGraphicsControl.kext
/System/Library/Extensions/AppleGraphicsPowerManagement.kext
/System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/ACPI_SMC_PlatformPlugin.kext/Contents/Resources

Or I can remake my Chameleon if you are interesting.


Wow!
Do not need all this work ... rolleyes.gif

You've helped me a lot to show me the way ...

If I can make the adjustments I tell you the result ...

Thanks...

wink.gif
Slice
After testing with www.applelife.ru I made working version 1291.
Downloads in topic.

Modules NVRAM and KernelPatcher has special assignment.
NVRAM creates an ability to store variables during reboot. With the module you may see UUID as Mac-address.
KernelPatcher is intended for Atom CPU and for lapic patch. It is not my sources, I just made it starting. May be after some testing we can make it fully working.
kingoffright
Hi, Slice. I need your help. I adpot your RestartFix code, but I am sure it can't be load correctly, I add some verbose line and the output show fail:
CODE
/**********************************/
    // Restart Fix
    if (Platform.CPU.Vendor == 0x756E6547) {    /* Intel */
        fix_restart = true;
        value = getStringForKey(kRestartFix, &bootInfo->chameleonConfig);
        verbose("value[0] is \n", value[0], "Key is \n", kRestartFix);
        if (value[0] == 'A') {
            fix_restart_acpi = true;
            verbose("FADT: ACPI\n");
        } else if (value[0] == 'P') {
            fix_restart_acpi = false;
            verbose("FADT: PS2\n");
        } else {
            fix_restart = false;
            verbose("FADT: Fail\n");
        }
    } else {
        verbose ("Not an Intel platform: Restart Fix not applied !!!\n");
        fix_restart = false;
    }
/**********************************/

Output as below:
/**********************************/
value[0] is
FADT: Fail
FADT: Using custom DSDT!
value[0] is
FADT: Fail
FADT: Using custom DSDT!
/**********************************/


I add your changes base on the latest trunk source
Click to view attachment
Slice
Your mistake is here
CODE
        verbose("value[0] is \n", value[0], "Key is \n", kRestartFix);

Should be
CODE
        verbose("value[0] is %c  \n Key is %s\n",  value[0], kRestartFix);
kingoffright
Hi, Slice, thanks for the debug code. Now the output as below, I don't know why it get the 'S' value?!
CODE
value[0] is S
Key is RestartFix
FADT: Fail
FADT: Using custom DSDT!
value[0] is S
Key is RestartFix
FADT: Fail
FADT: Using custom DSDT!


And my RestartFix value is PS2
CODE
    <key>RestartFix</key>
    <string>PS2</string>
Slice
Hmm. It looks like value[1]... I can propose that
CODE
value = getStringForKey(kRestartFix, &bootInfo->chameleonConfig);

makes a shifted value.

Try to print the whole string
CODE
verbose("value is %s  \n Key is %s\n",  value, kRestartFix);


May be the problem that your config file saved as Unicode?
kingoffright
seems the value array get from wrong place? Cause I change the key value to ABCDEFG, it still get 'S'

CODE
    <key>RestartFix</key>
    <string>ABCDEFG</string>


I show the whole value of value, but seems it only get one element?
Click to view attachment

and my plist is same format as yours, it's unicode(UTF-8)

Also I see all the source which will use getStringForKey return as a bool value
CODE
    const char *boardid = getStringForKey("SMboardproduct", &bootInfo->smbiosConfig);
    if (boardid)
        DT__AddProperty(node, BOARDID_PROP, strlen(boardid)+1, (EFI_CHAR16*)boardid);
Slice
CODE
if (boardid)

means if boardid is not zero. But it doesn't mean that the type is Boolean.

It looks like trunk sources is not good enough to do such patch.
kingoffright
QUOTE (Slice @ Aug 14 2011, 07:06 PM) *
CODE
if (boardid)

means if boardid is not zero. But it doesn't mean that the type is Boolean.

It looks like trunk sources is not good enough to do such patch.


Hi, Slice, it solved. The reason is my boot plist has some comments like <!-- ... -->, this cause the XML praser fail to get the correct keey, now it raised as issue 137 pending be solved. Thanks
tmacyunn1
Hi slice, I am very interest in your revision of bootloader, but when i install it on my laptop, stopped by auto reboot. By using the -f option, it shows actual mod:xxx

Here is my information:Click to view attachment
Slice
QUOTE (tmacyunn1 @ Aug 15 2011, 02:40 PM) *
Hi slice, I am very interest in your revision of bootloader, but when i install it on my laptop, stopped by auto reboot. By using the -f option, it shows actual mod:xxx

Here is my information:Click to view attachment

I see no mistakes.
Try to exclude my modules from Extra to check if you can boot without.
tmacyunn1
QUOTE (Slice @ Aug 15 2011, 01:51 PM) *
I see no mistakes.
Try to exclude my modules from Extra to check if you can boot without.


I try to exclude the modules but no luck, still auto reboot.
Slice
QUOTE (tmacyunn1 @ Aug 15 2011, 08:37 PM) *
I try to exclude the modules but no luck, still auto reboot.

Clear kernelcache and start with -v -f. What is the stop point?
tmacyunn1
QUOTE (Slice @ Aug 16 2011, 06:22 AM) *
Clear kernelcache and start with -v -f. What is the stop point?


I do it as you said, when using -v -f , it prints the cpu info and memory slot info, after the "Actual mode is XXXX" appears it stopped and auto reboot . It seems like the bootloader can't read information from hardware drive, here is my HDD partition table is MBR structure, the output result is :
CODE
yuns-MacBook:~ zpRood$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *320.1 GB   disk0
   1:               Windows_NTFS System                  116.0 GB   disk0s1
   2:                  Apple_HFS Macintosh               150.3 GB   disk0s2
   3:                      Linux                         26.8 GB    disk0s3
   4:                      Linux                         26.9 GB    disk0s5
yuns-MacBook:~ zpRood$
Slice
Next message may be wake from hibernate... Try "Use ForceWake=y to override" or something with SleepImage.
My bootloader vs trunk will try to wake from hibernate.
tmacyunn1
QUOTE (Slice @ Aug 16 2011, 11:33 AM) *
Next message may be wake from hibernate... Try "Use ForceWake=y to override" or something with SleepImage.
My bootloader vs trunk will try to wake from hibernate.

Sorry for that, I try to remove the /var/vm/sleepimage and use "ForceWake=yes", but it still exist , can't boot up.
Slice
QUOTE (tmacyunn1 @ Aug 16 2011, 05:51 PM) *
Sorry for that, I try to remove the /var/vm/sleepimage and use "ForceWake=yes", but it still exist , can't boot up.

One thing that meklort points me. If "RestartFix" is missing then bootloader may crash.
Write RestartFix=PS2 into boot.plist.
tmacyunn1
QUOTE (Slice @ Aug 17 2011, 07:32 AM) *
One thing that meklort points me. If "RestartFix" is missing then bootloader may crash.
Write RestartFix=PS2 into boot.plist.

It's weird, I have done it already, remove the openhaltrestart.kext and set RestartFix=PS2, even delete the sleep image from /var/vm/sleepimage. But it auto restarts again.
Slice
QUOTE (tmacyunn1 @ Aug 18 2011, 07:08 AM) *
It's weird, I have done it already, remove the openhaltrestart.kext and set RestartFix=PS2, even delete the sleep image from /var/vm/sleepimage. But it auto restarts again.

I'm sorry but I don't know what is the problem. I can't reproduce the bug.
bautzen
QUOTE (Slice @ Sep 1 2011, 07:33 PM) *
I'm sorry but I don't know what is the problem. I can't reproduce the bug.


Hi Slice, thank you for your 'miracle' that resolved my dual core boot on NC6400 and NC4400 T7200 cpu on dual core mode: not more random KP about CPU01 Failed to start, CPU halted and then "no HPTEs ....". With this your chameleon, every boot it's OK. Thank you!

Anyway, I noticed something related to screensaver and sleep after applied your bootloader: not more autosleep and automatic screensaver. In other words, if I put the notebook manually in stop it works fine (after your PNLF fix) and if I test screensaver works great, but they don't start automatically. Only the monitor in stop works automatically.

I have graphicsenabler=YES and FixRestart=PS2. I have GMA950 code in my DSDT so maybe I don't need "graphicsenabler", what do you think about? I'm using a smbios.plist of MacBook2,1 because it seems more similar to my HW (GMA950, Intel T7200 etc) or do you think that I have to let your default MacBookPro4,1?
Do you think that my issues with autosleep and autoscreensaver could be related to bootloader or not?
I have just tried to remove all com.apple.screensaver.*.plist and Systempreferences.plist, but without success.

Regards

Pat
Slice
With Dell Latitude D420 (aka MacBook1,1) with GMA950 I have full working graphics without GraphicsEnabler, just DSDT fixes. Screensaver and panel brightness works like a charm.
Click to view attachment
Slice
Chameleon is dead. It is no more exists for me.
I see Chameleon team is not proposing to apply my patches, let it be.
Now I am using Clover.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.