RevoBoot is ready for OS X 10.9 aka Mavericks

Some of you may know that I lost work due to an accidental rm by Jeroen, and thus we had to redo the work for OS X 10.9 Mavericks and Haswell processor support

Not that I had a clue about the name Apple was going to use, but I guessed that it wouldn’t take long before Apple pushed DP1 out of the door. And since we here like to be prepared… RevoBoot is ready for Mavericks and Haswell processors. Yah.

https://github.com/Piker-Alpha/RevoBoot/commits/clang

Edit: Added Haswell compatibility info.

XNU 10.8.3 Haswell Compatibility

The mach_kernel for OS X 10.9 Mavericks has built-in support for Haswell and Haswell ULT processors, but since that is not released yet. Not for a long time, you may as well want to patch the XNU (10.8.3) source code. And here is what you need to add:

xnu/osfmk/i386/cpuid.h

+ #define CPUID_MODEL_HASWELL	0x3C
+ #define CPUID_MODEL_HASWELL_ULT	0x45

xnu/osfmk/i386/cpuid.c

+		case CPUID_MODEL_HASWELL:
+			cpufamily = CPUFAMILY_INTEL_HASWELL;
+			break;
+		case CPUID_MODEL_HASWELL_ULT:
+			cpufamily = CPUFAMILY_INTEL_HASWELL_ULT;
+			break;

xnu/osfmk/i386/tsc.c

	switch (cpuid_cpufamily()) {
	case CPUFAMILY_INTEL_IVYBRIDGE:
	case CPUFAMILY_INTEL_SANDYBRIDGE:
	case CPUFAMILY_INTEL_WESTMERE:
	case CPUFAMILY_INTEL_NEHALEM:
+	case CPUFAMILY_INTEL_HASWELL:
+	case CPUFAMILY_INTEL_HASWELL_ULT: {

xnu/osfmk/mach/machine.h

+ #define CPUFAMILY_INTEL_HASWELL 0x78EA4FBC
+ #define CPUFAMILY_INTEL_HASWELL_ULT 0x10B282DC

Note: If you don’t know what to do with it, forget it. No support here.

Edit: Filename error corrected. Thanks to necrophagous for the tip.

New MacBook Air

Good news!

Apple introduced a new 13-inch MacBook Air today. One with a Intel® Haswell i5-4250U (ULT) processor and a faster one with the Intel® Haswell i7-4650U processor. Both with a max TDP of just 15 W. This surely helps to improve battery life – should run all day long now, but I have yet to see if this is true or not.

The max Turbo frequency of the i5-4250U is 200 MHz lower as the previous generation, but it is just as fast. Want to see the GeekBench results? Here they are:
GeekBench 32-bit (MacBookAir6,2)
GeekBench 64-bit (MacBookAir6,1)

More interesting data:

model identifier: MacBookAir6,2
board-id: Mac-7DF21CB3ED6977E5
OS X version: 10.8.4 (Build 12E3067)
iGPU version: Intel® HD graphics 5000

All compiled into RevoBoot and ssdtPRGen. This along with all other Haswell processor data (soon to be pushed into the Githib repository).

p.s. You can pull this version of OS X of off the Apple servers, but I cannot tell you how. Just use the data and… well you know. Recovery mode anyone?

Enjoy!

Edit 1: Links to processor specs added.
Edit 2: MacBookAir6,1 data added.

model identifier: MacBookAir6,1
board-id: Mac-35C1E88140C3E6CF

Update: The SMC version info is 2.13f5 (smc-huronriver) and I also noticed a new SMC key BFCL(6) but I have yet to figure out where and what it is used for. Mavericks also reads F0AC and F0Mx.

Haswell mach_kernel patch

Here is a quick and dirty patch for the mach_kernel to let it run IvyBridge code on Haswell CPUs. This is the original assembler code:

ffffff80002a85e1 83f83a cmpl $58, %ex
ffffff80002a85e4 7505 jne 0xffffff80002a85eb
ffffff80002a85e6 bb35e8651f movl $526772277, %ebx // CPUFAMILY_INTEL_IVYBRIDGE

Which you want to patch by searching for eb0a83f83a and replace it with eb0a83f83c

Haswell C1 Errata/Markings

Errata
Here are the known issues of the C1 stepping.
Haswell_Errata_C1

Markings
In case you want to verify what chipset stepping your Haswell motherboard is using, then use this data.
Haswell_Markings_C1

LPC device-id’s
And for the few who are still wondering if OS X 10.8.4 is Haswell ready or not… it is not. You can check this yourself by looking for any of the following device-ids.
Haswell_LPC_DeviceIDs
Yup. We still need a self compiled kernel. We also still have to patch some other files, notably AppleLPC.kext (of course) but… I will not share anything else. Not until people in our community stop BEGGING for donations! To me this hobby project is nothing more than a hobby and I kindly ask you to ignore me when I start asking for donations.

Yeah. This is simply who I am. A real man. A proud guy who is willing to share his ideas and hard work. All this without ever asking for anything in return. Not that I couldn’t use the money, because I could, but I was raised as a proud member of the Alpha family where hard work and pay-checks rule. Not to mention the word “honour” because my mom and dad would go mad when I went cheap goat. NEVER EVER. I rather die working hard than ever going to ask you for money.

End of story!

Haswell Power Management Fix

Almost all UEFI BIOS versions lock MSR 0xE2. Not that it matters, because we know exactly what/where to look for. Something that has helped us to patch the BIOS before and we are about to do it again. This blog article however will show you the exact UEFI source code that locks BIT 15 of MSR 0xE2 (MSR_PMG_CST_CONFIG_CONTROL). Let’s start with the PowerManagement.inf

#/*++
#  This file contains an 'Intel Peripheral Driver' and uniquely
#  identified as "Intel Reference Module" and is
#  licensed for Intel CPUs and chipsets under the terms of your
#  license agreement with Intel or your vendor.  This file may
#  be modified by the user, subject to additional terms of the
#  license agreement
#--*/
#
#/*++
#
#Copyright (c)  1999 - 2010 Intel Corporation. All rights reserved
#This software and associated documentation (if any) is furnished
#under a license and may only be used or copied in accordance
#with the terms of the license. Except as permitted by such
#license, no part of this software or documentation may be
#reproduced, stored in a retrieval system, or transmitted in any
#form or by any means without the express written consent of
#Intel Corporation.
#
#Module Name:
#
#  PowerManagement.inf
#
#Abstract:
#
#  Component description file for Power Management module
#
#--*/

[defines]
BASE_NAME            = PowerManagement2
FILE_GUID            = f7731b4c-58a2-4df4-8980-5645d39ece58
COMPONENT_TYPE       = RT_DRIVER

[sources.common]
  PowerManagement.h
  PowerManagement.c

  Ppm.h
  PpmInitialization.c
  PpmRuntime.c

#
# Edk II Glue Driver Entry Point
#
 EdkIIGlueSmmDriverEntryPoint.c

[sources.x64]
  x64\ProcessorSaveStateSupport.h
  x64\ProcessorSaveStateSupport.c

[includes.common]
  .

  $(EDK_SOURCE)\Foundation
  $(EDK_SOURCE)\Foundation\Include
  $(EDK_SOURCE)\Foundation\Efi
  $(EDK_SOURCE)\Foundation\Efi\Include
  $(EDK_SOURCE)\Foundation\Framework
  $(EDK_SOURCE)\Foundation\Framework\Include
  $(EDK_SOURCE)\Foundation\Include\IndustryStandard
  $(EDK_SOURCE)\Foundation\Library\Dxe\Include
  $(EFI_SOURCE)
  $(EFI_SOURCE)\Include
  $(EFI_SOURCE)\Include\IndustryStandard
  $(EFI_SOURCE)\Platform\$(PROJECT_FAMILY)\Common
  $(EFI_SOURCE)\Platform\$(PROJECT_FAMILY)\Common\Include
  $(EFI_SOURCE)\$(PROJECT_PPM_ROOT)
  $(EFI_SOURCE)\$(PROJECT_PPM_ROOT)\Include
  $(EFI_SOURCE)\$(PROJECT_PPM_ROOT)\Library\SandyBridgePpm\Smm
  $(EFI_SOURCE)\$(PROJECT_PCH_ROOT)\Include
  $(EFI_SOURCE)\$(PROJECT_PCH_ROOT)\Include\Library
  $(EFI_SOURCE)\$(PROJECT_PCH_ROOT)

#
# Typically the sample code referenced will be available in the code base already
# So keep this include at the end to defer to the source base definition
# and only use the sample code definition if source base does not include these files.
#
  $(EFI_SOURCE)\$(PROJECT_PPM_ROOT)\SampleCode\Include
  $(EFI_SOURCE)\$(PROJECT_PPM_ROOT)\SampleCode

#
# Edk II Glue Library, some hearder are included by R9 header so have to include
#

 $(EFI_SOURCE)
 $(EFI_SOURCE)\Framework
 $(EDK_SOURCE)\Foundation
 $(EDK_SOURCE)\Foundation\Framework
 $(EDK_SOURCE)\Foundation\Include\IndustryStandard
 $(EDK_SOURCE)\Foundation\Core\Dxe
 $(EDK_SOURCE)\Foundation\Include\Pei
 $(EDK_SOURCE)\Foundation\Library\Dxe\Include
 $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\Include

[libraries.common]

  PowerManagementGuidLib
  PowerManagementProtocolLib
  SandyBridgePpmLib
  DxeAslUpdateLib
  EfiProtocolLib
  EdkFrameworkProtocolLib
  EdkIIGlueBaseLib
  EdkIIGlueBaseIoLibIntrinsic
  EdkIIGlueBaseMemoryLib
  EdkIIGlueDxeMemoryAllocationLib
  EdkIIGlueDxeDebugLibReportStatusCode
  EdkIIGlueSmmRuntimeDxeReportStatusCodeLib
  EdkIIGlueUefiBootServicesTableLib
  EdkIIGlueUefiDevicePathLib
  EfiScriptLib
  EdkProtocolLib

[libraries.ia32,libraries.x64]
  CpuIa32Lib

[nmake.common]
  IMAGE_ENTRY_POINT = _ModuleEntryPoint
  DPX_SOURCE        = $(PROCESSOR)\PowerManagement.dxs
#
# Module Entry Point
#
 C_FLAGS = $(C_FLAGS) /D__EDKII_GLUE_MODULE_ENTRY_POINT__=InitializePowerManagement
 C_FLAGS = $(C_FLAGS) /D __EDKII_GLUE_BASE_LIB__ \
                      /D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \
                      /D __EDKII_GLUE_BASE_MEMORY_LIB__ \
                      /D __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ \
                      /D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \
                      /D __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__ \
                      /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ \
                      /D __EDKII_GLUE_UEFI_DEVICE_PATH_LIB__

This gives us the target GUID of the Power Management module aka F7731B4C-58A2-4DF4-8980-5645D39ECE58 which is also used for the filename in the iMac13,N EFI.
For example:

F7731B4C-58A2-4DF4-8980-5645D39ECE58_0_164.ROM
F7731B4C-58A2-4DF4-8980-5645D39ECE58_0_170.ROM

This should help you to locate the PM module. Next up. The actual locking code:

//
//---------------------------------------------------------------------------
//
// Procedure:   DoCstateProgramming
//
// Description: Program C-state registers.
//
// Input:
//  IN VOID *SetupHandle
//
// Output:  VOID
//
//---------------------------------------------------------------------------
//

VOID DoCstateProgramming(IN VOID *SetupHandle)
{
    UINT32 CpuSignature = GetCpuSignature();
    UINT32 CpuSigNoVer = CpuSignature & 0xfffffff0;
    UINT8  CpuSigVer = CpuSignature & 0xf;
    BOOLEAN IsSandyBridge = CpuSigNoVer == SANDY_BRIDGE || CpuSigNoVer == JAKETOWN || CpuSigNoVer == IVY_BRIDGE || CpuSigNoVer == HASWELL;
	UINT8	CstRange;
    UINT8   PkgCstLimitProg;
    UINT32  PmgCstConfCntr;
	UINT32	RegEax, RegEbx, RegEcx, RegEdx;

    CPULib_CpuID(5, &RegEax, &RegEbx, &RegEcx, &RegEdx);

    //Check if C1E is available.
    if ((RegEdx & C1_SUB_STATES_MASK) > 0x10) {  //bits [7:4] are for C1
        //Enable C1E [1]
        ReadWriteMsr(MSR_POWER_CTL, BIT1, (UINT64)-1);   //0x1fc
    }

    if (IsSandyBridge) {
        ReadWriteMsr(MSR_PKGC3_IRTL, 0x50 + (2 << 10) + BIT15, (UINT64)0xffffffffffffe00);
        ReadWriteMsr(MSR_PKGC6_IRTL, 0x68 + (2 << 10) + BIT15, (UINT64)0xffffffffffffe00);
        ReadWriteMsr(MSR_PKGC7_IRTL, 0x6d + (2 < 4 || CpuSigNoVer == JAKETOWN) {
            //Enable C1 and C3 Un-demotion and lock.
            PmgCstConfCntr |= BIT28 + BIT27 + BIT15;
        }
    } else {
        PmgCstConfCntr |= BIT15;   //Lock CFG
    }

    // Program IO-redirect as well as Package C State Limit
    ReadWriteMsr(MSR_PMG_CST_CONFIG_CONTROL, PmgCstConfCntr, (UINT64)-8);

    if(RegEdx & C7_SUB_STATES_MASK)         CstRange = 2;
    else if (RegEdx & C6_SUB_STATES_MASK)   CstRange = 1;
	else CstRange = 0;

	WriteMsr(MSR_PMG_IO_CAPTURE_ADDR, (CstRange << 16) + PM_BASE_ADDRESS + 0x14);	//0xe4 - C State IO Capture Base Address.
}

That is it. Nothing more to see. Problem located and ready to get patched!

Note: Intel® Corporation (legal) representatives are kindly asked to contact me per e-mail for the express written consent to publish this – to prevent DMCA take down notices.

A few Haswell related tips

1.) Make sure to get a Z87 motherboard without the USB 3.0 bug (you want a chipset with stepping C2 and revision 5). Get that in writing before you order your motherboard!

2.) Make sure you get a motherboard with at least a display port on it. A Thunderbolt connector is also highly recommended.

3.) Get a massive CPU cooler, if you haven’t one already. A water cooling kit is a must have for people who plan to overclock their K model CPU.

4.) Check for UEFI BIOS upgrades regularly and install them when available.

5.) Prepare yourself for 4K display technology. It won’t be cheap, but you won’t want to miss out on it either. Here is a new one from Asus.
PQ321Q_Side_650
Soon available in 31,5-inch and 39-inch models.

6.) Get a motherboard with Intel LAN.

7.) Get a motherboard with a supported codec (892/898) so that you’ll have audio from day one.

8.) Don’t expect power management to work without a UEFI BIOS mod. Yes. MSR 0xE2 is still locked and thus your UEFI BIOS need a patch, but since it is essentially the same kind of mod that we have been using ever since Sam figured it out… this is not a problem.

9.) All power related tests out on the Internet are VOID in the world of Apple/OS X – I have no idea where these people are getting their data from, but what I can tell you is that my 2500 Euro hardware shows me anything but the wattage they publish in their tests.

10.) But most importantly… wait for new Apple hardware with OS X 10.9 pre-installed on it 😉

OC’ed Haswell requires Water-cooling

Ok. The cat is out of the bag. It is 1 June 2013 and thus the Intel Non Disclosure Agreement (NDA) is lifted. News articles from different sources, magazines, bloggers and the likes, will all start to publish facts about the fourth generation of Intel processors. Most of them who will try to push the barrier of their i7-4770K ES will soon figure out what they need… at least a water cooler kit.

One of the kits that I would like to recommend here is the NZXT Kraken X60.
Picture courtesy of NZXT
Another good brand is, of course, Corsair. Which by the way will soon release new Vengeance Pro memory kits and two new cases – thanks to Corsair George for the tip!

Note: A mild OC doesn’t necessarily require a water cooling kit, but it will definitely keep your processor cooler than any air cooler out on the market. And when I say mild I mean a couple of 100 MHz.

No yesteryear technology here

Remember this:

QUO’s AOS motherboard is the only one in the industry with Firewire 400 and 800 (1394A and 1394B)

To which I blatantly say; rubbish!

No thanks. I don’t want yesteryears technology. Not when you can get a real Intel DZ87KLT-75K reference motherboard with dual Intel Gigabit Ethernet and Thunderbolt plus HDMI on it. Not to mention that this board is designed for the Intel K series processors. And sure. It has FireWire 400 and 800 as well, for the few that still need it. That and a socket 1150 for Haswell processors. It also comes with a debug port on the board plus a Bluetooth module as well. Which I use often lately (the former).

This Intel motherboard should be available in a matter of days, for $246, and then the fun begins. Using less power. Having 4K display support. A great new faster processor that will help us to get things done in less time. In my view it is just plain stupid not to step into the world of Haswell, but I like to note that some features won’t work out of the box with OS X. Not until the new Mac Book Pro is released with OS X 10.9. Notably for display/power management support.

By the way. I was told that the QUO computer “developers” aren’t really professional developers, and are still struggling to make everything work. To deliver something that does what they said it would do. Really? Oops I guess! Well. Have fun playing guys, while I plug-in my new monitor and have some fun with todays technology. Nope. No yesteryear technology here…

p.s. It boots Windows, Linux and OS X. Like your current motherboard does. Nothing new to see here – running Any Operating System is a decade old already 🙂