提交 1eaab9ad 编写于 作者: G Goldfish64

OpenCoreKernel: Fix 64-bit detection behavior

上级 f723a503
......@@ -129,9 +129,13 @@ typedef enum OC_PICKER_MODE_ {
10.6 - K32_U32 | K32_U64 | K64_U64.
10.7+ - K32_U64 | K64_U64.
**/
#define OC_KERN_CAPABILITY_K32_U32 BIT0 ///< Supports K32 and U32 (10.4~10.6)
#define OC_KERN_CAPABILITY_K32_U64 BIT1 ///< Supports K32 and U64 (10.4~10.7)
#define OC_KERN_CAPABILITY_K64_U64 BIT2 ///< Supports K64 and U64 (10.6+)
#define OC_KERN_CAPABILITY_K32_U32 BIT0 ///< Supports K32 and U32 (10.4~10.6)
#define OC_KERN_CAPABILITY_K32_U64 BIT1 ///< Supports K32 and U64 (10.4~10.7)
#define OC_KERN_CAPABILITY_K64_U64 BIT2 ///< Supports K64 and U64 (10.6+)
#define OC_KERN_CAPABILITY_K32_K64_U64 (OC_KERN_CAPABILITY_K32_U64 | OC_KERN_CAPABILITY_K64_U64)
#define OC_KERN_CAPABILITY_K32_U32_U64 (OC_KERN_CAPABILITY_K32_U32 | OC_KERN_CAPABILITY_K32_U64)
#define OC_KERN_CAPABILITY_ALL (OC_KERN_CAPABILITY_K32_U32 | OC_KERN_CAPABILITY_K32_K64_U64)
/**
Action to perform as part of executing a system boot entry.
......@@ -1081,7 +1085,7 @@ OcParseBootArgs (
@param[in] GetVariable Preferred UEFI NVRAM reader, optional.
@param[in] Argument Argument, e.g. -v, slide=, debug=, etc.
@param[in] ArgumentLength Argument length, e.g. L_STR_LEN ("-v").
@param[in,out] Value Argument value length allocated from pool.
@param[in,out] Value Argument value allocated from pool.
@retval TRUE if argument is present.
**/
......
......@@ -192,5 +192,8 @@ IsMacModel64BitCompatible (
}
}
return FALSE;
//
// Default behavior allows 64-bit on both 10.6 and 10.7 if the model is not found.
//
return TRUE;
}
......@@ -52,8 +52,11 @@ OcKernelConfigureCapabilities (
UINT32 ArgumentCount;
UINT32 RequestedArch;
BOOLEAN HasAppleArch;
BOOLEAN SnowLeo64;
BOOLEAN Lion64;
UINT32 KernelVersion;
BOOLEAN IsSnowLeo;
BOOLEAN IsLion;
DEBUG ((DEBUG_VERBOSE, "OC: Supported boot capabilities %u\n", Capabilities));
//
// Reset to the default value.
......@@ -104,27 +107,39 @@ OcKernelConfigureCapabilities (
//
// Determine the current operating system.
//
SnowLeo64 = (Capabilities & (OC_KERN_CAPABILITY_K32_U32 | OC_KERN_CAPABILITY_K32_U64 | OC_KERN_CAPABILITY_K64_U64))
== (OC_KERN_CAPABILITY_K32_U32 | OC_KERN_CAPABILITY_K32_U64 | OC_KERN_CAPABILITY_K64_U64);
Lion64 = (Capabilities & (OC_KERN_CAPABILITY_K32_U32 | OC_KERN_CAPABILITY_K32_U64 | OC_KERN_CAPABILITY_K64_U64))
== (OC_KERN_CAPABILITY_K32_U64 | OC_KERN_CAPABILITY_K64_U64);
IsSnowLeo = FALSE;
IsLion = FALSE;
if ((Capabilities & OC_KERN_CAPABILITY_ALL) == OC_KERN_CAPABILITY_ALL) {
KernelVersion = KERNEL_VERSION_SNOW_LEOPARD_MIN;
IsSnowLeo = TRUE;
} else if ((Capabilities & OC_KERN_CAPABILITY_ALL) == OC_KERN_CAPABILITY_K32_K64_U64) {
KernelVersion = KERNEL_VERSION_LION_MIN;
IsLion = TRUE;
} else if ((Capabilities & OC_KERN_CAPABILITY_ALL) == OC_KERN_CAPABILITY_K32_U32_U64) {
KernelVersion = KERNEL_VERSION_LEOPARD_MIN;
} else {
KernelVersion = KERNEL_VERSION_MOUNTAIN_LION_MIN;
}
//
// In automatic mode, if we do not support SSSE3 and can downgrade to U32, do it.
//
if (RequestedArch == 0
&& (mOcCpuInfo->ExtFeatures & CPUID_EXTFEATURE_EM64T) == 0
&& (mOcCpuInfo->Features & CPUID_FEATURE_SSSE3) == 0
&& (Capabilities & OC_KERN_CAPABILITY_K32_U32) != 0
&& (Capabilities & (OC_KERN_CAPABILITY_K32_U64 | OC_KERN_CAPABILITY_K64_U64)) != 0) {
&& (Capabilities & OC_KERN_CAPABILITY_K32_K64_U64) != 0) {
DEBUG ((DEBUG_INFO, "OC: Missing SSSE3 disables U64 capabilities %u\n", Capabilities));
Capabilities &= ~(OC_KERN_CAPABILITY_K32_U64 | OC_KERN_CAPABILITY_K64_U64);
Capabilities &= ~(OC_KERN_CAPABILITY_K32_K64_U64);
}
//
// If we support K64 mode, check whether the board supports it.
//
if ((Capabilities & OC_KERN_CAPABILITY_K64_U64) != 0
&& !OcPlatformIs64BitSupported (SnowLeo64 ? KERNEL_VERSION_SNOW_LEOPARD_MIN : KERNEL_VERSION_LION_MIN)) {
&& !OcPlatformIs64BitSupported (KernelVersion)) {
DEBUG ((DEBUG_INFO, "OC: K64 forbidden due to current platform on version %u\n", KernelVersion));
Capabilities &= ~(OC_KERN_CAPABILITY_K64_U64);
}
......@@ -150,9 +165,9 @@ OcKernelConfigureCapabilities (
// - SnowLeo64 or Lion64 and try to boot i386.
//
ArgumentCount = 0;
if (Capabilities == OC_KERN_CAPABILITY_K64_U64 && SnowLeo64) {
if (Capabilities == OC_KERN_CAPABILITY_K64_U64 && IsSnowLeo) {
NewArguments[ArgumentCount++] = "arch=x86_64";
} else if (Capabilities != OC_KERN_CAPABILITY_K64_U64 && (SnowLeo64 || Lion64)) {
} else if (Capabilities != OC_KERN_CAPABILITY_K64_U64 && (IsSnowLeo || IsLion)) {
NewArguments[ArgumentCount++] = "arch=i386";
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册