]> code.delx.au - refind/commitdiff
Further tweaks to spoof_osx_version code, including writing
authorsrs5694 <srs5694@users.sourceforge.net>
Fri, 30 Oct 2015 01:17:35 +0000 (21:17 -0400)
committersrs5694 <srs5694@users.sourceforge.net>
Fri, 30 Oct 2015 01:17:35 +0000 (21:17 -0400)
refind.conf sample entry.

NEWS.txt
refind.conf-sample
refind/main.c

index 2510be0c3dfd1b91cd8bda5cb254863f1acb4b62..186ec3a701f60234959cc0818007588f0de8326b 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,6 +1,14 @@
 0.9.3 (??/??/2015):
 -------------------
 
 0.9.3 (??/??/2015):
 -------------------
 
+- Added new "spoof_osx_version" token, which takes an OS X version number
+  (such as "10.9") as an option. This feature, when enabled, causes rEFInd
+  to tell a Mac's firmware that the specified version of OS X is being
+  launched. This option is usually unnecessary, but it can help properly
+  initialize some hardware -- particularly secondary video devices. OTOH,
+  on some Macs it can cause hardware (notably keyboards and mice) to become
+  unresponsive, so you should not use this option unnecessarily.
+
 - Worked around an EFI bug that affected my 32-bit Mac Mini: That system
   seems to have a broken EFI, or possibly a buggy CPU, that causes some
   (but not all) conversions from floating-point to integer numbers to hang
 - Worked around an EFI bug that affected my 32-bit Mac Mini: That system
   seems to have a broken EFI, or possibly a buggy CPU, that causes some
   (but not all) conversions from floating-point to integer numbers to hang
index abab655eeb8edb20e558a47d092abbc769fa6d56..d4e242bcd6ba386835f394c3ce4e9faf64847397 100644 (file)
@@ -369,6 +369,21 @@ timeout 20
 #
 #enable_and_lock_vmx false
 
 #
 #enable_and_lock_vmx false
 
+# Tell a Mac's EFI that OS X is about to be launched, even when it's not.
+# This option causes some Macs to initialize their hardware differently than
+# when a third-party OS is launched normally. In some cases (particularly on
+# Macs with multiple video cards), using this option can cause hardware to
+# work that would not otherwise work. On the other hand, using this option
+# when it is not necessary can cause hardware (such as keyboards and mice) to
+# become inaccessible. Therefore, you should not enable this option if your
+# non-Apple OSes work correctly; enable it only if you have problems with
+# some hardware devices. When needed, a value of "10.9" usually works, but
+# you can experiment with other values. This feature has no effect on
+# non-Apple computers.
+# The default is inactive (no OS X spoofing is done).
+#
+#spoof_osx_version "10.9"
+
 # Include a secondary configuration file within this one. This secondary
 # file is loaded as if its options appeared at the point of the "include"
 # token itself, so if you want to override a setting in the main file,
 # Include a secondary configuration file within this one. This secondary
 # file is loaded as if its options appeared at the point of the "include"
 # token itself, so if you want to override a setting in the main file,
index 2c39bae099836919e781eb5aa5f62d5475c684dd..4a09e86db414eaed6e11c7452f40c838c55f7a42 100644 (file)
@@ -2150,66 +2150,51 @@ static VOID SetConfigFilename(EFI_HANDLE ImageHandle) {
     { 0xb2, 0xf1, 0x3f, 0xd5, 0x2b, 0xb1, 0x00, 0x77 } \
   }
 
     { 0xb2, 0xf1, 0x3f, 0xd5, 0x2b, 0xb1, 0x00, 0x77 } \
   }
 
-typedef struct efi_apple_set_os_interface {
-    UINT64 version;
-    EFI_STATUS EFIAPI (*set_os_version) (IN CHAR8 *version);
-    EFI_STATUS EFIAPI (*set_os_vendor) (IN CHAR8 *vendor);
-} efi_apple_set_os_interface;
+typedef struct EfiAppleSetOsInterface {
+    UINT64 Version;
+    EFI_STATUS EFIAPI (*SetOsVersion) (IN CHAR8 *Version);
+    EFI_STATUS EFIAPI (*SetOsVendor) (IN CHAR8 *Vendor);
+} EfiAppleSetOsInterface;
 
 // Function to tell the firmware that OS X is being launched. This is
 // required to work around problems on some Macs that don't fully
 // initialize some hardware (especially video displays) when third-party
 // OSes are launched in EFI mode.
 static EFI_STATUS SetAppleOSInfo() {
 
 // Function to tell the firmware that OS X is being launched. This is
 // required to work around problems on some Macs that don't fully
 // initialize some hardware (especially video displays) when third-party
 // OSes are launched in EFI mode.
 static EFI_STATUS SetAppleOSInfo() {
-//    CHAR8 apple_os_version[] = "Mac OS X 10.9";
     CHAR16 *AppleOSVersion = NULL;
     CHAR8 *AppleOSVersion8 = NULL;
     CHAR16 *AppleOSVersion = NULL;
     CHAR8 *AppleOSVersion8 = NULL;
-//    CHAR8 apple_os_vendor[]  = "Apple Inc.";
     EFI_STATUS Status;
     EFI_GUID apple_set_os_guid = EFI_APPLE_SET_OS_PROTOCOL_GUID;
     EFI_STATUS Status;
     EFI_GUID apple_set_os_guid = EFI_APPLE_SET_OS_PROTOCOL_GUID;
-    efi_apple_set_os_interface *set_os = NULL;
+    EfiAppleSetOsInterface *SetOs = NULL;
 
 
-    Status = refit_call3_wrapper(BS->LocateProtocol, &apple_set_os_guid, NULL, (VOID**) &set_os);
+    Status = refit_call3_wrapper(BS->LocateProtocol, &apple_set_os_guid, NULL, (VOID**) &SetOs);
 
     // Not a Mac, so ignore the call....
 
     // Not a Mac, so ignore the call....
-    if ((Status != EFI_SUCCESS) || (!set_os)) {
-        Print(L"Not a Mac!\n");
-        PauseForKey();
+    if ((Status != EFI_SUCCESS) || (!SetOs))
         return EFI_SUCCESS;
         return EFI_SUCCESS;
-    }
 
 
-    if ((set_os->version != 0) && GlobalConfig.SpoofOSXVersion) {
+    if ((SetOs->Version != 0) && GlobalConfig.SpoofOSXVersion) {
         AppleOSVersion = StrDuplicate(L"Mac OS X");
         MergeStrings(&AppleOSVersion, GlobalConfig.SpoofOSXVersion, ' ');
         AppleOSVersion = StrDuplicate(L"Mac OS X");
         MergeStrings(&AppleOSVersion, GlobalConfig.SpoofOSXVersion, ' ');
-        Print(L"Setting OS version to '%s'\n", AppleOSVersion);
         AppleOSVersion8 = AllocateZeroPool((StrLen(AppleOSVersion) + 1) * sizeof(CHAR8));
         UnicodeStrToAsciiStr(AppleOSVersion, AppleOSVersion8);
         if (AppleOSVersion8) {
         AppleOSVersion8 = AllocateZeroPool((StrLen(AppleOSVersion) + 1) * sizeof(CHAR8));
         UnicodeStrToAsciiStr(AppleOSVersion, AppleOSVersion8);
         if (AppleOSVersion8) {
-            Print(L"Calling set_os_version()\n");
-            Status = refit_call1_wrapper (set_os->set_os_version, AppleOSVersion8);
-            Print(L"Returned %lx\n", Status);
-            if (EFI_ERROR(Status))
-                Print(L"ERROR! Returned %x\n", Status);
+            Status = refit_call1_wrapper (SetOs->SetOsVersion, AppleOSVersion8);
+            if (!EFI_ERROR(Status))
+                Status = EFI_SUCCESS;
         } else {
             Status = EFI_OUT_OF_RESOURCES;
             Print(L"Out of resources!\n");
         }
         } else {
             Status = EFI_OUT_OF_RESOURCES;
             Print(L"Out of resources!\n");
         }
-    }
-
-    if (/* (Status == EFI_SUCCESS) && */ (set_os->version == 2)) {
-        Print(L"Setting OS vendor....");
-        Status = refit_call1_wrapper (set_os->set_os_vendor, "Apple Inc.");
-        Print(L"Returned %x\n", Status);
-    }
+        if ((Status == EFI_SUCCESS) && (SetOs->Version == 2))
+            Status = refit_call1_wrapper (SetOs->SetOsVendor, "Apple Inc.");
+    } // if
 
 
-    if (Status != EFI_SUCCESS) {
+    if (Status != EFI_SUCCESS)
         Print(L"Unable to set firmware boot type!\n");
         Print(L"Unable to set firmware boot type!\n");
-    }
 
     MyFreePool(AppleOSVersion);
     MyFreePool(AppleOSVersion8);
 
     MyFreePool(AppleOSVersion);
     MyFreePool(AppleOSVersion8);
-    Print(L"Returning %x\n", Status);
-    PauseForKey();
     return (Status);
 } // EFI_STATUS SetAppleOSInfo()
 
     return (Status);
 } // EFI_STATUS SetAppleOSInfo()