1 /* 2 * Copyright 2015, Bruno Bierbaumer. All rights reserved. 3 * Copyright 2019-2020, Haiku, Inc. All rights reserved. 4 * Released under the terms of the MIT License 5 */ 6 7 8 #include <efi/protocol/apple-setos.h> 9 #include <KernelExport.h> 10 11 #include "efi_platform.h" 12 13 14 #define APPLE_FAKE_OS_VENDOR "Apple Inc." 15 #define APPLE_FAKE_OS_VERSION "Mac OS X 10.9" 16 17 18 // Apple Hardware configures hardware differently depending on 19 // the operating system being booted. Examples include disabling 20 // and powering down the internal GPU on some device models. 21 static void 22 quirks_fake_apple(void) 23 { 24 efi_guid appleSetOSProtocolGUID = EFI_APPLE_SET_OS_GUID; 25 efi_apple_set_os_protocol* set_os = NULL; 26 27 efi_status status = kSystemTable->BootServices->LocateProtocol( 28 &appleSetOSProtocolGUID, NULL, (void**)&set_os); 29 30 // If not relevant, we will exit here (the protocol doesn't exist) 31 if (status != EFI_SUCCESS || set_os == NULL) { 32 return; 33 } 34 35 dprintf("Located Apple set_os protocol, applying EFI Apple Quirks...\n"); 36 37 if (set_os->Revision != 0) { 38 status = set_os->SetOSVersion((char*)APPLE_FAKE_OS_VERSION); 39 if (status != EFI_SUCCESS) { 40 dprintf("%s: unable to set os version!\n", __func__); 41 return; 42 } 43 } 44 45 status = set_os->SetOSVendor((char*)APPLE_FAKE_OS_VENDOR); 46 if (status != EFI_SUCCESS) { 47 dprintf("%s: unable to set os version!\n", __func__); 48 return; 49 } 50 51 return; 52 } 53 54 55 void 56 quirks_init(void) 57 { 58 quirks_fake_apple(); 59 } 60