From a9af4abd09187eebb3668f1dedfbcbe65e80cb53 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sat, 24 Oct 2020 19:50:17 +0300 Subject: [PATCH] OcBootManagementLib: Fixed `ScanPolicy` NVMe handling on MacPro5,1 closes acidanthera/bugtracker#1234 --- Changelog.md | 1 + Include/Acidanthera/Library/OcDevicePathLib.h | 8 ++++++++ Library/OcBootManagementLib/PolicyManagement.c | 1 + Library/OcDevicePathLib/OcDevicePathLib.c | 7 ++----- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index fdacb886..0b77fdd5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -17,6 +17,7 @@ OpenCore Changelog - Fixed intermittent 32-bit prelinking failures caused by improper Mach-O expansion - Fixed failures in cacheless injection dependency resolution - Fixed detection issues with older Atom CPUs +- Fixed `ScanPolicy` NVMe handling on MacPro5,1 #### v0.6.2 - Updated builtin firmware versions for SMBIOS and the rest diff --git a/Include/Acidanthera/Library/OcDevicePathLib.h b/Include/Acidanthera/Library/OcDevicePathLib.h index fd8215b0..cb69dee1 100755 --- a/Include/Acidanthera/Library/OcDevicePathLib.h +++ b/Include/Acidanthera/Library/OcDevicePathLib.h @@ -15,6 +15,14 @@ #ifndef OC_DEVICE_PATH_LIB_H #define OC_DEVICE_PATH_LIB_H +/** + Apple MacPro5,1 includes NVMe driver, however, it contains a typo in MSG_SASEX_DP. + Instead of 0x16 aka 22 (SasEx) it uses 0x22 aka 34 (Unspecified). + Here we replace it with the "right" value. + Reference: https://forums.macrumors.com/posts/28169441. +**/ +#define MSG_APPLE_NVME_NAMESPACE_DP 0x22 + /** Append file name to device path. diff --git a/Library/OcBootManagementLib/PolicyManagement.c b/Library/OcBootManagementLib/PolicyManagement.c index e0582146..a37d629a 100644 --- a/Library/OcBootManagementLib/PolicyManagement.c +++ b/Library/OcBootManagementLib/PolicyManagement.c @@ -80,6 +80,7 @@ OcGetDevicePolicyType ( return OC_SCAN_ALLOW_DEVICE_SASEX; case MSG_SCSI_DP: return OC_SCAN_ALLOW_DEVICE_SCSI; + case MSG_APPLE_NVME_NAMESPACE_DP: case MSG_NVME_NAMESPACE_DP: return OC_SCAN_ALLOW_DEVICE_NVME; case MSG_ATAPI_DP: diff --git a/Library/OcDevicePathLib/OcDevicePathLib.c b/Library/OcDevicePathLib/OcDevicePathLib.c index a9b471c3..d0c6c11d 100755 --- a/Library/OcDevicePathLib/OcDevicePathLib.c +++ b/Library/OcDevicePathLib/OcDevicePathLib.c @@ -484,16 +484,13 @@ OcFixAppleBootDevicePathNode ( case MSG_NVME_NAMESPACE_DP: // - // Apple MacPro5,1 includes NVMe driver, however, it contains a typo in MSG_SASEX_DP. - // Instead of 0x16 aka 22 (SasEx) it uses 0x22 aka 34 (Unspecified). - // Here we replace it with the "right" value. - // Reference: https://forums.macrumors.com/posts/28169441. + // Workaround for MacPro5,1 using custom NVMe type. // if (RestoreContext != NULL) { RestoreContext->Types.SasExNvme.SubType = Node.DevPath->SubType; } - Node.NvmeNamespace->Header.SubType = 0x22; + Node.NvmeNamespace->Header.SubType = MSG_APPLE_NVME_NAMESPACE_DP; return 1; default: -- GitLab