diff --git a/.gitignore b/.gitignore index f491c27..966d393 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,37 @@ .DS_Store -data-hp.h -data-asus.h -settings-hp.h -setting-asus.h +.git + +out.log +obj/* +sym/* + +i386/boot0/boot0 +i386/boot1/boot1h + +i386/config/SETTINGS/*.h + +i386/config/ACPI/*.h +i386/config/EFI/*.h +i386/config/SMBIOS/*.h + +i386/util/libcc_kext.a + +MODEL + +xcuserdata +project.xcworkspace + +i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/secretCode.h +i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo.xcodeproj/xcuserdata +i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo.xcodeproj/project.xcworkspace + +i386/libsaio/cpu/tools/PMinfoBackup + +i386/libsaio/smbios/tools/smbios2struct3 +i386/libsaio/smbios/tools/smbios2struct4 + +*OLD* +*BAK* +*test* +BACKUP + diff --git a/CHANGES b/CHANGES index e8624a6..c08c6d5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,15 +1,177 @@ +RevoBoot v2.0.00 +================ +- Support for OS X 10.10 aka Yosemite added (Pike R. Alpha, June 2013). +- VERSION updated to v2.0.00 +- LZVN decompression added for Yosemite. +- IODeviceTree:/chosen/random-seed added for Yosemite. +- kernel and kernelcache path updated for Yosemite. +- boot2/picopng.c and boot2/picopng.c added (removed in v2.0.10). +- bootstruct.c and bootstruct.h updated for Yosemite. + + +RevoBoot v1.5.40 +================ +- Support for OS X 10.9 aka Mavericks added (Pike R. Alpha, June 2013). +- VERSION updated to v1.5.40 + + +RevoBoot v1.5.39 +================ +- Fixed boot failure for InstallESD/BaseSystem.dmg/patched kernelcache (Pike R. Alpha, April 2013). +- LION_INSTALL_SUPPORT renamed to INSTALL_ESD_SUPPORT (Pike R. Alpha, April 2013). +- Stripped (unnecessary) argument from loadSystemConfig (Pike R. Alpha, April 2013). +- Renamed function loadSystemConfig to loadCABootPlist (Pike R. Alpha, April 2013). +- Simplified search for and read of com.apple.Boot.plist (Pike R. Alpha, April 2013). +- Board ID's for iMac12,n fixed (Jeroen, April 2013). +- Settings template updated (Pike R. Alpha, April 2013). +- VERSION updated to v1.5.39 + + +RevoBoot v1.5.38 +================ +- RevoBoot/i386/libsaio/efi.c modified to workaround iMessage login/registration problems (Pike R. Alpha, January 2013). +- getBoardType in RevoBoot/i386/libsaio/SMBIOS/getters.h now always returns a board type (Pike R. Alpha, January 2013). +- STATIC_NVRAM_ROM/STATIC_NVRAM_MLB added (used in efi.c) to settings-template.h (Pike R. Alpha, January 2013). +- VERSION updated to v1.5.38 + + +RevoBoot v1.5.37 +================ +- DISK_TARGET_SUPPORT in settings-template.h renamed to STARTUP_DISK_SUPPORT (Pike R. Alpha, November 2012). +- Restored copyright of efi_tables.c to original developer (Pike R. Alpha, November 2012). +- Renamed RevoBoot/i386/libsa/efi_tables.c to crc32.c (Pike R. Alpha, November 2012). +- Moved GUID function from efi_tables.c to RevoBoot/i386/libsaio/guid.c (Pike R. Alpha, November 2012). +- Fixed some minor C99 issues / restoring gcc compatibility (Pike R. Alpha, November 2012). +- Cleanups and other minor improvements. +- VERSION updated to v1.5.37 + + +RevoBoot v1.5.36 +================ +- Now reading efi-boot-device-data from /Extra/NVRAM/nvramStorage.plist to select the Startup Disk (Pike R. Alpha, November 2012). +- New DISK_TARGET_SUPPORT setting in settings-template.h (Pike R. Alpha, November 2012). +- New file RevoBoot/i386/libsaio/base64.c (written by Sam) added (Pike R. Alpha, November 2012). +- Support for data fields added (Pike R. Alpha, November 2012). +- Copied macro's from EDK2's EfiDevicePath.h to RevoBoot/i386/libsaio/efi/essentials.h (Pike R. Alpha, November 2012). +- Port of EDK2's function (getGUIDFromDevicePath written by Sam) added (Pike R. Alpha, November 2012). +- Function loadSystemConfig now calls new function loadConfigFile (Pike R. Alpha, November 2012). +- Cleanups and other minor improvements. +- VERSION updated to v1.5.36 + + +RevoBoot v1.5.35 +================ +- SMBIOS related enhancements for RevoBoot v1.5.35 (Pike R. Alpha, November 2012). +- VERSION updated to v1.5.35 + + +RevoBoot v1.5.34 +================ +- LOAD_STATIC_EFI_DATA_FROM_EXTRA in settings-template.h renamed to LOAD_MODEL_SPECIFIC_EFI_DATA (Pike R. Alpha, October 2012). +- LOAD_STATIC_SMBIOS_DATA_FROM_EXTRA in settings-template.h renamed to LOAD_MODEL_SPECIFIC_SMBIOS_DATA (Pike R. Alpha, October 2012). +- New LOAD_MODEL_SPECIFIC_ACPI_DATA setting in settings-template.h (Pike R. Alpha, October 2012). +- New LOAD_MODEL_SPECIFIC_STATIC_DATA setting in settings-template.h (Pike R. Alpha, October 2012). +- VERSION updated to v1.5.34 + +Notes: + +Static EFI/SMBIOS data will be used when RevoBoot can't find model specific data: /Extra/[EFI/SMBIOS]/MacModelNN.bin +DSDT.aml will be loaded when RevoBoot can't find: /Extra/ACPI/DSDT-MacModelNN.aml (example). +You must use the latest version of RevoBoot/i386/config/settings-template.h or things won't work. + + +RevoBoot v1.5.33 +================ +- Restored lost lines in RevoBoot/i386/libsaio/SMBIOS/static_data.h (Pike R. Alpha, November 2012). +- VERSION updated to v1.5.33 + + +RevoBoot v1.5.32 +================ +- Optionally include Recovery HD support code in boot.c (Pike R. Alpha, October 2012). +- Renamed LION_RECOVERY_SUPPORT to CORE_STARAGE_SUPPORT in disk.c (Pike R. Alpha, October 2012). +- Renamed LION_FILEVAULT_SUPPORT to CORE_STARAGE_SUPPORT in disk.c (Pike R. Alpha, November 2012). +- Renamed encryptedBootPartition to coreStoragePartition in disk.c (Pike R. Alpha, October 2012). +- Cleaned up settings-template.h (Pike R. Alpha, October 2012). +- VERSION updated to v1.5.32 + + +RevoBoot v1.5.31 +================ +- STATIC_SYSTEM_SERIAL_NUMBER renamed to EFI_SYSTEM_SERIAL_NUMBER (Pike R. Alpha, October 2012). +- Restored lost STATIC_SMSERIALNUMBER in setings-template.h (Pike R. Alpha, October 2012). +- STATIC_SMSERIALNUMBER renamed to SMB_SYSTEM_SERIAL_NUMBER (Pike R. Alpha, October 2012). +- VERSION updated to v1.5.31 + + +RevoBoot v1.5.30 +================ +- Move/update /Extra/ data reading to RevoBoot/i386/libsaio/load.c (Pike R. Alpha, October 2012). +- Option to read /Extra/EFI/[MacModelNN.bin] when static EFI data is used (Pike R. Alpha, October 2012). +- Option to read /Extra/SMBIOS/[MacModelNN.bin] when static SMBIOS data is used (Pike R. Alpha, October 2012). +- Makefile changes for above features(Pike R. Alpha, October 2012). +- VERSION updated to v1.5.30 + + +RevoBoot v1.5.25 +================ +- RevoBoot/i386/config/data.h is no longer included with (Pike R. Alpha, October 2012). +- New static data paths in RevoBoot/i386/libsaio/Makefile (Pike R. Alpha, October 2012). +- Use model identifier as filename for static data (Pike R. Alpha, October 2012). +- VERSION updated to v1.5.25 + + +RevoBoot v1.5.23 +================ +- Bug fix and cleanups in RevoBoot/i386/libsaio/SMBIOS/dynamic_data.h (Pike R. Alpha, October 2012). +- VERSION updated to v1.5.23 + + +RevoBoot v1.5.22 +================ +- Bug fix in RevoBoot/Makefile (Pike R. Alpha, October 2012). +- VERSION updated to v1.5.22 + + +RevoBoot v1.5.21 +================ +- Model data for new Macmini6,N added (Pike R. Alpha, October 2012). +- VERSION updated to v1.5.21 + + +RevoBoot v1.5.20 +================ +- Automatic data selection for ACPI/EFI and SMBIOS data (Pike R. Alpha, October 2012) +- Copies ACPI/EFI/SMBIOS/data-template.h to [your model.h] for new configurations (Pike R. Alpha, October 2012) + + +RevoBoot v1.5.10 +================ +- Makefiles cleaned up/optimized (Pike R. Alpha, October 2012). +- make now defaults to Mountain Lion (Pike R. Alpha, October 2012). +- MODEL=[your model] argument added to makefiles (Pike R. Alpha, October 2012). +- MODEL=$1 added to RevoBoot/r for optional model identifier (Pike R. Alpha, October 2012). +- make now creates RevoBoot/i386/config/SETTINGS when missing (Pike R. Alpha, October 2012). +- Makefile now copies settings-template.h to SETTINGS/[your model.h] when missing (Pike R. Alpha, October 2012). + + +RevoBoot v1.5.01 +================ +- MacPro SMBIOS board serial/type added (dgsga, October 2012). + + RevoBoot v1.5.00 ================ -- RevoBoot project forked (PikerAlpha, October 2012). +- RevoBoot project forked (Pike R. Alpha, October 2012). - - Time to say goodbye to some of the legacy code. Something I will do with the help of Sam's notes, - but not everything is written in stone. Unfortenately. Meaning that I will have to experiment and - improvise. Hopefully achieving the same goals that she had in mind for you. - -- Support for self compiled libcc_kext.a (Xcode 4.5.1 compatibility) added (PikerAlpha, October 2012). -- SMBIOS legacy code removed (PikerAlpha, October 2012). -- EFI/SMBIOS data logic moved to preprocessor code (PikerAlpha, October 2012). -- RevoBoot/i386/config/settings.h stripped for simplicity (PikerAlpha, October 2012). +- Support for self compiled libcc_kext.a (Xcode 4.5.1 compatibility) added (Pike R. Alpha, October 2012). +- SMBIOS legacy code removed (Pike R. Alpha, October 2012). +- EFI/SMBIOS data logic moved to preprocessor code (Pike R. Alpha, October 2012). +- RevoBoot/i386/config/settings.h stripped for simplicity (Pike R. Alpha, October 2012). - - Note: If there is anything that doesn't work for you... let me know and I will look at it. - diff --git a/Makefile b/Makefile index 8216a1e..b8905d2 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,41 @@ # -# Makefile for RevoBoot +# File: RevoBoot/Makefile +# +# Updates: +# +# - Major cleanup (Pike R. Alpha, October 2012). +# - Output improvements (Pike R. Alpha, October 2012). +# - Default build target is now Mountain Lion (Pike R. Alpha, October 2012). +# - PRODUCT_MODEL_TARGET for target build model added (Pike R. Alpha, October 2012). +# - Creates RevoBoot/config/SETTINGS when missing (Pike R. Alpha, October 2012). +# - Copies settings-template.h to SETTINGS/ModelnameNN.h when missing (Pike R. Alpha, October 2012). +# - Automatic ACPI/EFI/SMBIOS data selection (Pike R. Alpha, October 2012). +# - Copies ACPI/EFI/SMBIOS/data-template.h for new conigurations (Pike R. Alpha, October 2012). +# - Output added for cp/mkdir/rm actions (Pike R. Alpha, November 2012). +# - New build target 'help' added (Pike R. Alpha, November 2012). +# - Cleanups and output changed (Pike R. Alpha, November 2012). +# - Yosemite support added (Pike R. Alpha, June 2014). +# - Changed default from Mavericks to Yosemite (Pike R. Alpha, June 2014). +# - El Capitan support added (Pike R. Alpha, June 2015). +# - Sierra support added (Pike R. Alpha, June 2016). +# - macOS 10.13 support added (Pike R. Alpha, March 2017). +# + +# +# Include Apple makefile definitions. # export USE_APPLE_PB_SUPPORT = all -# CFLAGS = -O $(MORECPP) -arch i386 -g -DEFINES= -CONFIG = hd LIBDIR = libsa INC = -I. -I$(LIBDIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = ld + PAX = /bin/pax OBJROOT = `pwd`/obj SYMROOT = `pwd`/sym -DSTROOT = `pwd`/dst -SRCROOT = /tmp + +DEFAULT_MODEL=$(shell cat MODEL) # # Export version number (picked up by i386/libsaio/Makefile) @@ -31,69 +45,227 @@ export PRODUCT_VERSION_NUMBER = `cat ../../VERSION` EXCLUDE = --exclude=.DS_Store --exclude=sym --exclude=obj --exclude=*.sh -ARCHLESS_RC_CFLAGS=`echo $(RC_CFLAGS) | sed 's/-arch [a-z0-9]*//g'` +# +# Search paths. +# VPATH = $(OBJROOT):$(SYMROOT) -GENERIC_SUBDIRS = +OS_TYPE = "OS\ X" # -# Export target OS type (picked up by i386/libsaio/Makefile) +# Check if OS build target is specified (example: make mountain-lion). # -ifeq ($(MAKECMDGOALS), mountain-lion) - MAKE_TARGET_OS = 6; +ifeq ($(MAKECMDGOALS),) + # + # No OS build target given. Build for High Sierra (default). + # + MAKEGOAL = high-sierra + MAKE_TARGET_OS = 254; + MAKE_TARGET_OS_VER = 10.13 + OS_TYPE = "macOS" else - ifeq ($(MAKECMDGOALS), lion) + # + # Setting MAKE_TARGET_OS and MAKEGOAL based on OS build target. + # + ifeq ($(MAKECMDGOALS), high-sierra) + MAKEGOAL = high-sierra + MAKE_TARGET_OS = 254; + MAKE_TARGET_OS_VER = 10.13 + OS_TYPE = "macOS" + else ifeq ($(MAKECMDGOALS), sierra) + MAKEGOAL = sierra + MAKE_TARGET_OS = 126; + MAKE_TARGET_OS_VER = 10.12 + OS_TYPE = "macOS" + else ifeq ($(MAKECMDGOALS), el-capitan) + MAKEGOAL = el-capitan + MAKE_TARGET_OS = 62; + MAKE_TARGET_OS_VER = 10.11 + else ifeq ($(MAKECMDGOALS), yosemite) + MAKEGOAL = yosemite + MAKE_TARGET_OS = 26; + MAKE_TARGET_OS_VER = 10.10 + else ifeq ($(MAKECMDGOALS), mavericks) + MAKEGOAL = mavericks + MAKE_TARGET_OS = 10; + MAKE_TARGET_OS_VER = 10.9 + else ifeq ($(MAKECMDGOALS), mountain-lion) + MAKEGOAL = mountain-lion + MAKE_TARGET_OS = 6; + MAKE_TARGET_OS_VER = 10.8 + else ifeq ($(MAKECMDGOALS), lion) + MAKEGOAL = lion MAKE_TARGET_OS = 2; - else + MAKE_TARGET_OS_VER = 10.7 + else ifeq ($(MAKECMDGOALS), legacy) + MAKEGOAL = legacy MAKE_TARGET_OS = 1; + MAKE_TARGET_OS_VER = 10.6 endif endif +# +# Export our make goal i.e. Sierra, El Capitan, Yosemite, Mavericks, Mountain Lion, Lion or legacy (Snow Leopard or Leopard). +# + +export MAKEGOAL + +# +# Export OS build target (picked up by: i386/libsaio/Makefile). +# + export PRODUCT_OS_TARGET = `echo $(MAKE_TARGET_OS)` -lion: all -mountain-lion: all - -all: $(SYMROOT) $(OBJROOT) - @if [ -z "$(RC_ARCHS)" ]; then \ - RC_ARCHS="i386"; \ - fi; \ - SUBDIRS="$(GENERIC_SUBDIRS) $$RC_ARCHS"; \ - for i in $$SUBDIRS; \ - do \ - if [ -d $$i ]; then \ - echo ================= make $@ for $$i =================; \ - ( OBJROOT=$(OBJROOT)/$${i}; \ - SYMROOT=$(SYMROOT)/$${i}; \ - DSTROOT=$(DSTROOT); \ - XCFLAGS=$(ARCHLESS_RC_CFLAGS); \ - GENSUBDIRS="$(GENERIC_SUBDIRS)"; \ - for x in $$GENSUBDIRS; \ - do \ - if [ "$$x" == "$$i" ]; then \ - XCFLAGS="$(RC_CFLAGS)"; \ - break; \ - fi \ - done; \ - echo "$$OBJROOT $$SYMROOT $$DSTROOT"; \ - cd $$i; ${MAKE} \ - "OBJROOT=$$OBJROOT" \ - "SYMROOT=$$SYMROOT" \ - "DSTROOT=$$DSTROOT" \ - "SRCROOT=$$SRCROOT" \ - "RC_ARCHS=$$RC_ARCHS" \ - "TARGET=$$i" \ - "RC_CFLAGS=$$XCFLAGS" $@ \ - ) || exit $$?; \ - else \ - echo "========= Nothing to build for $$i ========="; \ - fi; \ - done +# +# Export target OS version (picked up by: i386/libsaio/Makefile) for platform.c +# + +export PRODUCT_OS_TARGET_VERSION = `echo \"$(MAKE_TARGET_OS_VER)\"` + +# +# Check if a target model was specified (example: make MODEL=MacPro61). +# + +ifdef MODEL + # + # MODEL=[MacModelNN] specified, export target model. + # + ifneq ($(MODEL),) + export MAKE_TARGET_MODEL = $(MODEL) + # + # Include static ACPI/EFI/SMBIOS data file per model identifier. + # + DATA_FILE = $(MODEL) + else + # + # No. Use Macmini62 as a fallback default. + # + MODEL = Macmini62 + export MAKE_TARGET_MODEL = Macmini62 + # + # Include default/empty static data files (no model identifier specified). + # + DATA_FILE = data-template + endif +else + # + # MODEL=[MacModelNN], check if DEFAULT_MODEL was set (first run only). + # + ifdef DEFAULT_MODEL + # + # Yes it is. Use Macmodel[nn] from RevoBoot/MODEL + # + MODEL = $(DEFAULT_MODEL) + export MAKE_TARGET_MODEL = $(MODEL) + # + # Include static ACPI/EFI/SMBIOS data files per model identifier. + # + DATA_FILE = $(MODEL) + else + # + # No. Use Macmini62 as a fallback default. + # + MODEL = Macmini62 + export MAKE_TARGET_MODEL = $(MODEL) + # + # Include default/empty static data file (no model identifier specified). + # + DATA_FILE = data-template + endif +endif + +# +# Export target filenames for static ACPI, EFI and SMBIOS data. +# + +export MAKE_ACPI_DATA_FILE = ACPI/$(DATA_FILE).h +export MAKE_EFI_DATA_FILE = EFI/$(DATA_FILE).h +export MAKE_SMBIOS_DATA_FILE = SMBIOS/$(DATA_FILE).h + +# +# Our one and only build target directory. +# + +ARCH_DIR=i386 + +CONFIG_DIR=$(ARCH_DIR)/config + +SETTINGS_DIR=$(CONFIG_DIR)/SETTINGS +SETTINGS_FILE=$(SETTINGS_DIR)/$(MAKE_TARGET_MODEL).h + +$(MAKEGOAL): +# +# autoclean +# + @if [ -d "$(OBJROOT)" ]; then \ + echo "\t[RMDIR] $(OBJROOT)" > /dev/null; \ + fi; + + @if [ -d "$(SYMROOT)" ]; then \ + echo "\t[RMDIR] $(SYMROOT)" > /dev/null; \ + fi; + + @rm -rf sym obj dst out.log +# +# normal make goal +# + @printf "\nCompiling RevoBoot, setup for a $(MODEL) running $(OS_TYPE) $(MAKE_TARGET_OS_VER) ($@)\n" >&2; + + @if [ ! -f $(CONFIG_DIR)/$(MAKE_ACPI_DATA_FILE) ]; then \ + echo "\t[CP] $(CONFIG_DIR)/ACPI/data-template.h $(CONFIG_DIR)/$(MAKE_ACPI_DATA_FILE)"; \ + cp -n $(CONFIG_DIR)/ACPI/data-template.h $(CONFIG_DIR)/$(MAKE_ACPI_DATA_FILE); \ + fi; + + @if [ ! -f $(CONFIG_DIR)/$(MAKE_EFI_DATA_FILE) ]; then \ + echo "\t[CP] $(CONFIG_DIR)/EFI/data-template.h $(CONFIG_DIR)/$(MAKE_EFI_DATA_FILE)"; \ + cp -n $(CONFIG_DIR)/EFI/data-template.h $(CONFIG_DIR)/$(MAKE_EFI_DATA_FILE); \ + fi; + + @if [ ! -f $(CONFIG_DIR)/$(MAKE_SMBIOS_DATA_FILE) ]; then \ + echo "\t[CP] $(CONFIG_DIR)/SMBIOS/data-template.h $(CONFIG_DIR)/$(MAKE_SMBIOS_DATA_FILE)"; \ + cp -n $(CONFIG_DIR)/SMBIOS/data-template.h $(CONFIG_DIR)/$(MAKE_SMBIOS_DATA_FILE); \ + fi; + + @if [ ! -d $(SETTINGS_DIR) ]; then \ + echo "\t[MKDIR] $(SETTINGS_DIR)"; \ + /bin/mkdir -p $(SETTINGS_DIR); \ + fi; + + @if [ ! -f $(SETTINGS_FILE) ]; then \ + echo "\t[CP] $(CONFIG_DIR)/settings-template.h $(SETTINGS_FILE)"; \ + cp -n $(CONFIG_DIR)/settings-template.h $(SETTINGS_FILE); \ + fi; + + @echo "======================================================"; + @echo "Running: make MODEL=$(MODEL) $@"; + + @(OBJROOT=$(OBJROOT)/$(ARCH_DIR); \ + SYMROOT=$(SYMROOT)/$(ARCH_DIR); \ + XCFLAGS="$(RC_CFLAGS)"; \ + cd $(ARCH_DIR); \ + ${MAKE} "OBJROOT=$$OBJROOT" "SYMROOT=$$SYMROOT" "RC_ARCHS=$(ARCH_DIR)" \ + "TARGET=$(ARCH_DIR)" "RC_CFLAGS=$$XCFLAGS" $@ ) clean: - rm -rf sym obj dst out.log + @if [ -d "$(OBJROOT)" ]; then \ + echo "\t[RMDIR] $(OBJROOT)" > /dev/null; \ + fi; + + @if [ -d "$(SYMROOT)" ]; then \ + echo "\t[RMDIR] $(SYMROOT)" > /dev/null; \ + fi; + + @rm -rf sym obj dst out.log + +help: + @echo + @echo 'Build targets:' + @echo ' - Builds all targets [DEFAULT]' + @echo + @echo 'Cleaning targets:' + @echo ' clean - Removes generated files' -$(SYMROOT) $(OBJROOT) $(DSTROOT): - @$(MKDIRS) $@ +$(SYMROOT) $(OBJROOT): + @/bin/mkdir -p $@ diff --git a/README b/README index 00f967b..8aadc67 100644 --- a/README +++ b/README @@ -1,13 +1,32 @@ -RevoBoot can now be build with Xcode 4.5.1 on Mountain Lion. See change log for instructions. +- About this project -Please note that RevoBoot must be configured for your hardware so start reading our WiKi. See also: +This Open Source hobby project was first started by Master Chief, then taken over by DHP/RevoGirl (Samantha †) and is now maintained by Pike R. Alpha (http://pikeralpha.wordpress.com). A long time supporter of the RevoBoot project. -https://github.com/blackosx/RevoBuilder/wiki/Using-RevoBuilder -We also have a configuration README available at: +- Server.app -https://github.com/RevoGirl/RevoBoot/blob/master/i386/config/README +RevoBoot works with the Server app for Mountain Lion (12C60) and Mavericks. -There's also RevoBuilder (a great tool for first starters) over at: -https://github.com/blackosx/RevoBuilder/wiki/Using-RevoBuilder +- Fusion Drive Support + + +Apple's Fusion Drive* is a software implementation to speedup the boot and load process for frequently used applications, without limiting the storage capacity in a bad way. See also: http://support.apple.com/kb/HT5446 + +The new Mac's that come with a Fusion Drive, boot from the third (Recovery HD like) partition on the SSD. This partition is 134.2 MB in size and is called "Boot OS X". The Recovery HD partition can be found as third partition on the HDD. RevoBoot detects CoreStorage partitions and will boot from the boot helper partition on the SDD. + + +- NetBoot/NetInstall + +People who have Mountain Lion Server setup and like to install their hack from it... sorry that won't work. The source +code snippets for it have been stripped out (by Master Chief in 2009). + + +- Xcode Support for Mountain Lion, Mavericks and Yosemite + +RevoBoot can be built on Snow Leopard, Lion and Mountain Lion. The latter requires Xcode 4.5.1 (and greater) and the latest 'command line tools' need to be installed. See change log for instructions. + + +- Configuration + +Please note that RevoBoot must be configured for your hardware specifically. This makes it on of, if not the most difficult boot loader to setup, but that's just what you have to do. And sorry, but don't expect any help from me, because I don't have the time for it. diff --git a/VERSION b/VERSION index 4ada1d8..f08cf98 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.00 +2.0.00 diff --git a/c b/c index 892a658..de746e2 100755 --- a/c +++ b/c @@ -1,3 +1,85 @@ -sudo cp sym/i386/boot /Volumes/USBBOOT/ -sudo diskutil unmount /Volumes/USBBOOT +#!/bin/sh +# +# Bash script executed from: RevoBoot/i386/boot2/Makefile +# +# +# Version 1.3 - Copyright (c) 2013-2017 by Pike R. Alpha +# +# Updates: +# - v1.1 Improved output (Pike R. Alpha, June 2017). +# - v1.2 Fix typo (Pike R. Alpha, June 2017). +# - Now also asks if you want to reboot. +# - v1.3 Improved volume name support. Thanks to 'M': +# - https://pikeralpha.wordpress.com/2017/06/22/script-to-upgrade-macos-high-sierra-dp1-to-dp2/#comment-10216 + +let index=0 + +# +# Get currect working directory. +# +workingDirectory=$(pwd) + +# +# Change additional shell optional behavior (expand unmatched names to a null string). +# +shopt -s nullglob + +# +# Change to Volumes folder. +# +cd /Volumes + +# +# Collect available volume names. +# +targetVolumes=(*) + +echo "\nAvailable target volumes:\n" + +for volume in "${targetVolumes[@]}" +do + echo "[$index] $volume" + let index++ +done + +echo "" + +# +# Ask to select a target volume. +# +read -p "Select a target volume for the boot file: " volumeNumber + +# +# Verify selection. +# +if [ $volumeNumber -gt $index ]; + then + printf "\nError: Invalid Option ($volumeNumber)!\nAborting ...\n" + exit 0 + else + cd "${workingDirectory}" + echo "Copying RevoBoot/sym/i386/boot to: /Volumes/${targetVolumes[$volumeNumber]}/" + sudo cp ../../sym/i386/boot "/Volumes/${targetVolumes[$volumeNumber]}/" + # + # Compare files. + # + cmp -s ../../sym/i386/boot /Volumes/${targetVolumes[$volumeNumber]}/boot + # + # Check status (zero is ok). + # + if [[ $? -ne 0 ]]; + then + echo "Error: Copying boot file failed!" + else + echo "" + read -p "Do you want to reboot now (y/n) ?" shouldReboot + + if [ $shouldReboot == "y" ]; + then + sudo reboot now + else + echo "Done!" + fi + fi +fi diff --git a/fdisk440 b/fdisk440 new file mode 100755 index 0000000..f2d042f Binary files /dev/null and b/fdisk440 differ diff --git a/i b/i new file mode 100755 index 0000000..608be42 --- /dev/null +++ b/i @@ -0,0 +1,71 @@ +#!/bin/sh + +# +# Bash script to install boot files. +# +# +# Version 1.2 - Copyright (c) 2013-2017 by Pike R. Alpha +# +# Updates: +# - 1.1 Verbose output added. +# - 1.2 Check files/run nasm for missing boot files. +# + +pwd=$(pwd) + +if [ ! -e i386/boot0/boot0 ]; + then + cd i386/boot0 + echo "Running nasm for boot0 ..." + nasm boot0.s -o boot0 + cd "${pwd}" +fi + +if [ ! -e i386/boot0/boot1h ]; + then + cd "i386/boot1" + echo "Running nasm for boot1h ..." + nasm boot1h.s -o boot1h + cd "${pwd}" +fi + +let index=0 + +if [[ -e "i386/boot0/boot0" && -e "i386/boot1/boot1h" ]]; + then + # + # Collect available volume names. + # + cd /Volumes/ + targetVolumes=(*) + cd "${pwd}" + + echo "\nAvailable target volumes:\n" + + for volume in "${targetVolumes[@]}" + do + echo "[$index] $volume" + let index++ + done + + echo "" + + # + # Ask to select a target volume. + # + read -p "Select a target volume for the boot files: " volumeNumber + + # + # Path to target volume. + # + targetVolume="/Volumes/${targetVolumes[$volumeNumber]}" + + # + # Get device identifier. + # + disk=$(diskutil info "${targetVolume}" | awk '$1$2$3 == "PartofWhole:" { print $4 }') + + sudo ./fdisk440 -f i386/boot0/boot0 -u -y "/dev/r${disk}" + + sudo dd if=i386/boot1/boot1h of="/dev/r${disk}s2" +fi diff --git a/i386/MakeInc.dir b/i386/MakeInc.dir old mode 100755 new mode 100644 index 77611ac..759c94b --- a/i386/MakeInc.dir +++ b/i386/MakeInc.dir @@ -1,22 +1,14 @@ # -# Common makefile targets. +# File: RevoBoot/i386/MakeInc.dir # -# Define these variables (if desired) in directory makefiles: -# DIRS_NEEDED -# INSTALLDIR -# SRCROOT +# Updates: # -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif - -# -# Use /usr/bin/gcc instead of /usr/bin/cc (symbolic link to clang in Xcode 4.3.2 and greater). +# - Major cleanup (Pike R. Alpha, October 2012). +# - Fixed clang compilation (dgsga, November 2012). +# - Single pass compilation (Pike R. Alpha, November 2012). +# - Removed unused CPPFLAGS (Pike R. Alpha, November 2012). # -CC = gcc # Toggle this as to whether you want a frame pointer (%ebp) to be used. It is # invaluable for debugging the booter. For example using GDB attached to VMware. @@ -26,48 +18,32 @@ CC = gcc #OMIT_FRAME_POINTER_CFLAG=-fomit-frame-pointer OMIT_FRAME_POINTER_CFLAG= -installsrc:: $(SRCROOT) - cp $(ALLSRC) $(SRCROOT) - cd $(SRCROOT); chmod a-w $(ALLSRC) - -install:: installhdrs - @if [ -z "$(RC_ARCHS)" -o -n "$(RC_i386)" ]; then \ - $(MAKE) install_i386 OBJROOT=${OBJROOT} \ - SYMROOT=${SYMROOT} DSTROOT=${DSTROOT} \ - SRCROOT=${SRCROOT}; \ - else \ - echo i386 not selected - null build.; \ - fi - -install_i386:: all - -installhdrs:: .SUFFIXES: .s .i .c .o .c.o .m.o: - $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \ - -MD -dependency-file $(OBJROOT)/$*.d - $(SYMROOT)/md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d + @echo "\t[CC] $<" + @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$@ $(OBJROOT)/%.o: %.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \ - -MD -dependency-file $(OBJROOT)/$*.d - $(SYMROOT)/md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d + @echo "\t[CC] $<" + @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$@ $(OBJROOT)/%.o: %.m - $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \ - -MD -dependency-file $(OBJROOT)/$*.d - $(SYMROOT)/md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d + @echo "\t[M] $<" + @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$@ .s.o: - $(CC) $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $< + @echo "\t[AS] $<" + @$(CC) -c $(INC) -arch i386 $< -o $(OBJROOT)/$@ -boot2.o: - $(CC) $(CPPFLAGS) -Wa,-n -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) boot2.s +$(OBJROOT)/boot2.o: + @echo "\t[AS] boot2.s" + @$(CC) -Wa,-n -c $(INC) -arch i386 boot2.s -o $(OBJROOT)/$@ $(OBJROOT)/%.o: %.s - $(CC) $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $< + @echo "\t[AS] $<" + @$(CC) -c $(INC) -arch i386 $< -o $(OBJROOT)/$@ -$(DIRS_NEEDED) $(INSTALLDIR) $(SRCROOT): - $(MKDIRS) $@ +$(DIRS_NEEDED): + @/bin/mkdir -p $@ diff --git a/i386/MakePaths.dir b/i386/MakePaths.dir old mode 100755 new mode 100644 index 978ddf4..5fe8cbd --- a/i386/MakePaths.dir +++ b/i386/MakePaths.dir @@ -1,9 +1,15 @@ +# +# File: RevoBoot/i386/MakePaths.dir +# +# Updates: +# +# - Major cleanup (Pike R. Alpha, October 2012). +# + + # # Default paths for subdirectories. # OBJROOT=../../obj/i386/$(DIR) SYMROOT=../../sym/i386 -DSTROOT=../../dst/i386 -SRCROOT=/tmp - diff --git a/i386/Makefile b/i386/Makefile index 7d96cf6..9b930a8 100644 --- a/i386/Makefile +++ b/i386/Makefile @@ -1,49 +1,38 @@ # -# Makefile for RevoBoot +# File: RevoBoot/i386/Makefile +# +# Updates: +# +# - Major cleanup (PikerAlpha, October 2012). +# - Output improvements (PikerAlpha, October 2012). +# - PRODUCT_MODEL_TARGET renamed to MAKE_TARGET_MODEL (PikerAlpha, November 2012). +# - Cleanup and output changed (PikerAlpha, October 2012). # - -CFLAGS = -O $(MORECPP) -arch i386 -g -static -CONFIG = hd -LIBDIR = libsa -INC = -I. -I$(LIBDIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = ld # # These paths are only valid in subdirectories of this directory. # -OBJROOT=`pwd`/../../obj/i386 -SYMROOT=`pwd`/../../sym/i386 -DSTROOT=`pwd`/../../dst/i386 -SRCROOT=/tmp +OBJROOT=../i386/obj/i386 +SYMROOT=../i386/sym/i386 -VPATH = $(OBJROOT):$(SYMROOT) +# VPATH = $(OBJROOT):$(SYMROOT) # -# The build over here is important. +# The build order here is important. # SUBDIRS = util libsa libsaio boot2 -lion: all -mountain-lion: all -all: - @for i in ${SUBDIRS}; \ +$(MAKEGOAL): + @for i in $(SUBDIRS); \ do \ - echo ================= make $@ for $$i =================; \ - ( cd $$i; ${MAKE} \ - "OBJROOT=$(OBJROOT)/$$i" \ - "SYMROOT=$(SYMROOT)" \ - "DSTROOT=$(DSTROOT)" \ - "SRCROOT=$(SRCROOT)" \ - "RC_ARCHS=$(RC_ARCHS)" \ - "RC_CFLAGS=$(RC_CFLAGS)" $@ \ - ) || exit $$?; \ + echo ================= RevoBoot/i386/$$i =================; \ + ( cd $$i; ${MAKE} \ + "OBJROOT=$(OBJROOT)/$$i" \ + "SYMROOT=$(SYMROOT)" \ + "RC_ARCHS=$(RC_ARCHS)" \ + "RC_CFLAGS=$(RC_CFLAGS)" $@ \ + ) || exit $$?; \ done diff --git a/i386/boot0/boot0.s b/i386/boot0/boot0.s new file mode 100644 index 0000000..7469671 --- /dev/null +++ b/i386/boot0/boot0.s @@ -0,0 +1,808 @@ +; Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. +; +; @APPLE_LICENSE_HEADER_START@ +; +; Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights +; Reserved. This file contains Original Code and/or Modifications of +; Original Code as defined in and that are subject to the Apple Public +; Source License Version 2.0 (the "License"). You may not use this file +; except in compliance with the License. Please obtain a copy of the +; License at http://www.apple.com/publicsource and read it before using +; this file. +; +; The Original Code and all software distributed under the License are +; distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +; EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +; INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the +; License for the specific language governing rights and limitations +; under the License. +; +; @APPLE_LICENSE_HEADER_END@ +; +; Boot Loader: boot0 +; +; A small boot sector program written in x86 assembly whose only +; responsibility is to locate the active partition, load the +; partition booter into memory, and jump to the booter's entry point. +; It leaves the boot drive in DL and a pointer to the partition entry in SI. +; +; This boot loader must be placed in the Master Boot Record. +; +; In order to coexist with a fdisk partition table (64 bytes), and +; leave room for a two byte signature (0xAA55) in the end, boot0 is +; restricted to 446 bytes (512 - 64 - 2). If boot0 did not have to +; live in the MBR, then we would have 510 bytes to work with. +; +; boot0 is always loaded by the BIOS or another booter to 0:7C00h. +; +; This code is written for the NASM assembler. +; nasm boot0.s -o boot0 + +; +; This version of boot0 implements hybrid GUID/MBR partition scheme support +; +; Written by Tam‡s Kos‡rszky on 2008-03-10 +; +; Turbo added EFI System Partition boot support +; +; Added KillerJK's switchPass2 modifications +; + +; +; Set to 1 to enable obscure debug messages. +; +DEBUG EQU 0 + +; +; Set to 1 to enable verbose mode +; +VERBOSE EQU 0 + +; +; Various constants. +; +kBoot0Segment EQU 0x0000 +kBoot0Stack EQU 0xFFF0 ; boot0 stack pointer +kBoot0LoadAddr EQU 0x7C00 ; boot0 load address +kBoot0RelocAddr EQU 0xE000 ; boot0 relocated address + +kMBRBuffer EQU 0x1000 ; MBR buffer address +kLBA1Buffer EQU 0x1200 ; LBA1 - GPT Partition Table Header buffer address +kGPTABuffer EQU 0x1400 ; GUID Partition Entry Array buffer address + +kPartTableOffset EQU 0x1be +kMBRPartTable EQU kMBRBuffer + kPartTableOffset + +kSectorBytes EQU 512 ; sector size in bytes +kBootSignature EQU 0xAA55 ; boot sector signature +kHFSPSignature EQU 'H+' ; HFS+ volume signature +kHFSPCaseSignature EQU 'HX' ; HFS+ volume case-sensitive signature +kFAT32BootCodeOffset EQU 0x5a ; offset of boot code in FAT32 boot sector +kBoot1FAT32Magic EQU 'BO' ; Magic string to detect our boot1f32 code + + +kGPTSignatureLow EQU 'EFI ' ; GUID Partition Table Header Signature +kGPTSignatureHigh EQU 'PART' +kGUIDLastDwordOffs EQU 12 ; last 4 byte offset of a GUID + +kPartCount EQU 4 ; number of paritions per table +kPartTypeHFS EQU 0xaf ; HFS+ Filesystem type +kPartTypeABHFS EQU 0xab ; Apple_Boot partition +kPartTypePMBR EQU 0xee ; On all GUID Partition Table disks a Protective MBR (PMBR) + ; in LBA 0 (that is, the first block) precedes the + ; GUID Partition Table Header to maintain compatibility + ; with existing tools that do not understand GPT partition structures. + ; The Protective MBR has the same format as a legacy MBR + ; and contains one partition entry with an OSType set to 0xEE + ; reserving the entire space used on the disk by the GPT partitions, + ; including all headers. + +kPartActive EQU 0x80 ; active flag enabled +kPartInactive EQU 0x00 ; active flag disabled +kHFSGUID EQU 0x48465300 ; first 4 bytes of Apple HFS Partition Type GUID. +kAppleGUID EQU 0xACEC4365 ; last 4 bytes of Apple type GUIDs. +kEFISystemGUID EQU 0x3BC93EC9 ; last 4 bytes of EFI System Partition Type GUID: + ; C12A7328-F81F-11D2-BA4B-00A0C93EC93B + +%ifdef FLOPPY +kDriveNumber EQU 0x00 +%else +kDriveNumber EQU 0x80 +%endif + +; +; Format of fdisk partition entry. +; +; The symbol 'part_size' is automatically defined as an `EQU' +; giving the size of the structure. +; + struc part +.bootid resb 1 ; bootable or not +.head resb 1 ; starting head, sector, cylinder +.sect resb 1 ; +.cyl resb 1 ; +.type resb 1 ; partition type +.endhead resb 1 ; ending head, sector, cylinder +.endsect resb 1 ; +.endcyl resb 1 ; +.lba resd 1 ; starting lba +.sectors resd 1 ; size in sectors + endstruc + +; +; Format of GPT Partition Table Header +; + struc gpth +.Signature resb 8 +.Revision resb 4 +.HeaderSize resb 4 +.HeaderCRC32 resb 4 +.Reserved resb 4 +.MyLBA resb 8 +.AlternateLBA resb 8 +.FirstUsableLBA resb 8 +.LastUsableLBA resb 8 +.DiskGUID resb 16 +.PartitionEntryLBA resb 8 +.NumberOfPartitionEntries resb 4 +.SizeOfPartitionEntry resb 4 +.PartitionEntryArrayCRC32 resb 4 + endstruc + +; +; Format of GUID Partition Entry Array +; + struc gpta +.PartitionTypeGUID resb 16 +.UniquePartitionGUID resb 16 +.StartingLBA resb 8 +.EndingLBA resb 8 +.Attributes resb 8 +.PartitionName resb 72 + endstruc + +; +; Macros. +; +%macro DebugCharMacro 1 + mov al, %1 + call print_char +%endmacro + +%macro LogString 1 + mov di, %1 + call log_string +%endmacro + +%if DEBUG +%define DebugChar(x) DebugCharMacro x +%else +%define DebugChar(x) +%endif + +;-------------------------------------------------------------------------- +; Start of text segment. + + SEGMENT .text + + ORG kBoot0RelocAddr + +;-------------------------------------------------------------------------- +; Boot code is loaded at 0:7C00h. +; +start: + ; + ; Set up the stack to grow down from kBoot0Segment:kBoot0Stack. + ; Interrupts should be off while the stack is being manipulated. + ; + cli ; interrupts off + xor ax, ax ; zero ax + mov ss, ax ; ss <- 0 + mov sp, kBoot0Stack ; sp <- top of stack + sti ; reenable interrupts + + mov es, ax ; es <- 0 + mov ds, ax ; ds <- 0 + + ; + ; Relocate boot0 code. + ; + mov si, kBoot0LoadAddr ; si <- source + mov di, kBoot0RelocAddr ; di <- destination + cld ; auto-increment SI and/or DI registers + mov cx, kSectorBytes/2 ; copy 256 words + repnz movsw ; repeat string move (word) operation + + ; + ; Code relocated, jump to start_reloc in relocated location. + ; + jmp kBoot0Segment:start_reloc + +;-------------------------------------------------------------------------- +; Start execution from the relocated location. +; +start_reloc: + + DebugChar('>') + +%if DEBUG + mov al, dl + call print_hex +%endif + + ; + ; Since this code may not always reside in the MBR, always start by + ; loading the MBR to kMBRBuffer and LBA1 to kGPTBuffer. + ; + + xor eax, eax + mov [my_lba], eax ; store LBA sector 0 for read_lba function + mov al, 2 ; load two sectors: MBR and LBA1 + mov bx, kMBRBuffer ; MBR load address + call load + jc error ; MBR load error + + ; + ; Look for the booter partition in the MBR partition table, + ; which is at offset kMBRPartTable. + ; + mov si, kMBRPartTable ; pointer to partition table + call find_boot ; will not return on success + +error: + LogString(boot_error_str) + +hang: + hlt + jmp hang + + +;-------------------------------------------------------------------------- +; Find the active (boot) partition and load the booter from the partition. +; +; Arguments: +; DL = drive number (0x80 + unit number) +; SI = pointer to fdisk partition table. +; +; Clobber list: +; EAX, BX, EBP +; +find_boot: + + ; + ; Check for boot block signature 0xAA55 following the 4 partition + ; entries. + ; + cmp WORD [si + part_size * kPartCount], kBootSignature + jne .exit ; boot signature not found. + + xor bx, bx ; BL will be set to 1 later in case of + ; Protective MBR has been found + + inc bh ; BH = 1. Giving a chance for a second pass + ; to boot an inactive but boot1h aware HFS+ partition + ; by scanning the MBR partition entries again. + +.start_scan: + mov cx, kPartCount ; number of partition entries per table + +.loop: + + ; + ; First scan through the partition table looking for the active + ; partition. + ; +%if DEBUG + mov al, [si + part.type] ; print partition type + call print_hex +%endif + + mov eax, [si + part.lba] ; save starting LBA of current + mov [my_lba], eax ; MBR partition entry for read_lba function + cmp BYTE [si + part.type], 0 ; unused partition? + je .continue ; skip to next entry + cmp BYTE [si + part.type], kPartTypePMBR ; check for Protective MBR + jne .testPass + + mov BYTE [si + part.bootid], kPartInactive ; found Protective MBR + ; clear active flag to make sure this protective + ; partition won't be used as a bootable partition. + mov bl, 1 ; Assume we can deal with GPT but try to scan + ; later if not found any other bootable partitions. + +.testPass: + cmp bh, 1 + jne .Pass2 + +.Pass1: + cmp BYTE [si + part.bootid], kPartActive ; In pass 1 we are walking on the standard path + ; by trying to hop on the active partition. + jne .continue + xor dh, dh ; Argument for loadBootSector to skip HFS+ partition + ; signature check. + jmp .tryToBoot + +.Pass2: + cmp BYTE [si + part.type], kPartTypeHFS ; In pass 2 we're going to find a HFS+ partition + ; equipped with boot1h in its boot record + ; regardless if it's active or not. + jne .continue + mov dh, 1 ; Argument for loadBootSector to check HFS+ partition signature. + + DebugChar('*') + + ; + ; Found boot partition, read boot sector to memory. + ; + +.tryToBoot: + + call loadBootSector + jne .continue + jmp SHORT initBootLoader + +.continue: + add si, BYTE part_size ; advance SI to next partition entry + loop .loop ; loop through all partition entries + + ; + ; Scanned all partitions but not found any with active flag enabled + ; Anyway if we found a protective MBR before we still have a chance + ; for a possible GPT Header at LBA 1 + ; + dec bl + jnz .switchPass2 ; didn't find Protective MBR before + call checkGPT + +.switchPass2: + ; + ; Switching to Pass 2 + ; try to find a boot1h aware HFS+ MBR partition + ; + dec bh + mov si, kMBRPartTable ; set SI to first entry of MBR Partition table + jz .start_scan ; scan again + +.exit: + ret ; Giving up. + + + ; + ; Jump to partition booter. The drive number is already in register DL. + ; SI is pointing to the modified partition entry. + ; +initBootLoader: + +DebugChar('J') + +%if VERBOSE + LogString(done_str) +%endif + + jmp kBoot0LoadAddr + + + ; + ; Found Protective MBR Partition Type: 0xEE + ; Check for 'EFI PART' string at the beginning + ; of LBA1 for possible GPT Table Header + ; +checkGPT: + push bx + + mov di, kLBA1Buffer ; address of GUID Partition Table Header + cmp DWORD [di], kGPTSignatureLow ; looking for 'EFI ' + jne .exit ; not found. Giving up. + cmp DWORD [di + 4], kGPTSignatureHigh ; looking for 'PART' + jne .exit ; not found. Giving up indeed. + mov si, di + + ; + ; Loading GUID Partition Table Array + ; + mov eax, [si + gpth.PartitionEntryLBA] ; starting LBA of GPT Array + mov [my_lba], eax ; save starting LBA for read_lba function + mov cx, [si + gpth.NumberOfPartitionEntries] ; number of GUID Partition Array entries + mov bx, [si + gpth.SizeOfPartitionEntry] ; size of GUID Partition Array entry + + push bx ; push size of GUID Partition entry + + ; + ; Calculating number of sectors we need to read for loading a GPT Array + ; +; push dx ; preserve DX (DL = BIOS drive unit number) +; mov ax, cx ; AX * BX = number of entries * size of one entry +; mul bx ; AX = total byte size of GPT Array +; pop dx ; restore DX +; shr ax, 9 ; convert to sectors + + ; + ; ... or: + ; Current GPT Arrays uses 128 partition entries each 128 bytes long + ; 128 entries * 128 bytes long GPT Array entries / 512 bytes per sector = 32 sectors + ; + mov al, 32 ; maximum sector size of GPT Array (hardcoded method) + + mov bx, kGPTABuffer + push bx ; push address of GPT Array + call load ; read GPT Array + pop si ; SI = address of GPT Array + pop bx ; BX = size of GUID Partition Array entry + jc error + + ; + ; Walk through GUID Partition Table Array + ; and load boot record from first available HFS+ partition. + ; + ; If it has boot signature (0xAA55) then jump to it + ; otherwise skip to next partition. + ; + +%if VERBOSE + LogString(gpt_str) +%endif + +.gpt_loop: + + mov eax, [si + gpta.PartitionTypeGUID + kGUIDLastDwordOffs] + + cmp eax, kAppleGUID ; check current GUID Partition for Apple's GUID type + je .gpt_ok + + ; + ; Turbo - also try EFI System Partition + ; + + cmp eax, kEFISystemGUID ; check current GUID Partition for EFI System Partition GUID type + jne .gpt_continue + +.gpt_ok: + ; + ; Found HFS Partition + ; + + mov eax, [si + gpta.StartingLBA] ; load boot sector from StartingLBA + mov [my_lba], eax + mov dh, 1 ; Argument for loadBootSector to check HFS+ partition signature. + call loadBootSector + jne .gpt_continue ; no boot loader signature + + mov si, kMBRPartTable ; fake the current GUID Partition + mov [si + part.lba], eax ; as MBR style partition for boot1h + mov BYTE [si + part.type], kPartTypeHFS ; with HFS+ filesystem type (0xAF) + jmp SHORT initBootLoader + +.gpt_continue: + + add si, bx ; advance SI to next partition entry + loop .gpt_loop ; loop through all partition entries + +.exit: + pop bx + ret ; no more GUID partitions. Giving up. + + +;-------------------------------------------------------------------------- +; loadBootSector - Load boot sector +; +; Arguments: +; DL = drive number (0x80 + unit number) +; DH = 0 skip HFS+ partition signature checking +; 1 enable HFS+ partition signature checking +; [my_lba] = starting LBA. +; +; Returns: +; ZF = 0 if boot sector hasn't kBootSignature +; 1 if boot sector has kBootSignature +; +loadBootSector: + pusha + + mov al, 3 + mov bx, kBoot0LoadAddr + call load + jc error + + or dh, dh + jz .checkBootSignature + +.checkHFSSignature: + +%if VERBOSE + LogString(test_str) +%endif + + ; + ; Looking for HFSPlus ('H+') or HFSPlus case-sensitive ('HX') signature. + ; + mov ax, [kBoot0LoadAddr + 2 * kSectorBytes] + cmp ax, kHFSPSignature ; 'H+' + je .checkBootSignature + cmp ax, kHFSPCaseSignature ; 'HX' + je .checkBootSignature + + ; + ; Looking for boot1f32 magic string. + ; + mov ax, [kBoot0LoadAddr + kFAT32BootCodeOffset] + cmp ax, kBoot1FAT32Magic + jne .exit + +.checkBootSignature: + ; + ; Check for boot block signature 0xAA55 + ; + mov di, bx + cmp WORD [di + kSectorBytes - 2], kBootSignature + +.exit: + + popa + + ret + + +;-------------------------------------------------------------------------- +; load - Load one or more sectors from a partition. +; +; Arguments: +; AL = number of 512-byte sectors to read. +; ES:BX = pointer to where the sectors should be stored. +; DL = drive number (0x80 + unit number) +; [my_lba] = starting LBA. +; +; Returns: +; CF = 0 success +; 1 error +; +load: + push cx + +.ebios: + mov cx, 5 ; load retry count +.ebios_loop: + call read_lba ; use INT13/F42 + jnc .exit + loop .ebios_loop + +.exit: + pop cx + ret + + +;-------------------------------------------------------------------------- +; read_lba - Read sectors from a partition using LBA addressing. +; +; Arguments: +; AL = number of 512-byte sectors to read (valid from 1-127). +; ES:BX = pointer to where the sectors should be stored. +; DL = drive number (0x80 + unit number) +; [my_lba] = starting LBA. +; +; Returns: +; CF = 0 success +; 1 error +; +read_lba: + pushad ; save all registers + mov bp, sp ; save current SP + + ; + ; Create the Disk Address Packet structure for the + ; INT13/F42 (Extended Read Sectors) on the stack. + ; + +; push DWORD 0 ; offset 12, upper 32-bit LBA + push ds ; For sake of saving memory, + push ds ; push DS register, which is 0. + mov ecx, [my_lba] ; offset 8, lower 32-bit LBA + push ecx + push es ; offset 6, memory segment + push bx ; offset 4, memory offset + xor ah, ah ; offset 3, must be 0 + push ax ; offset 2, number of sectors + + ; It pushes 2 bytes with a smaller opcode than if WORD was used + push BYTE 16 ; offset 0-1, packet size + + DebugChar('<') +%if DEBUG + mov eax, ecx + call print_hex +%endif + + ; + ; INT13 Func 42 - Extended Read Sectors + ; + ; Arguments: + ; AH = 0x42 + ; DL = drive number (80h + drive unit) + ; DS:SI = pointer to Disk Address Packet + ; + ; Returns: + ; AH = return status (sucess is 0) + ; carry = 0 success + ; 1 error + ; + ; Packet offset 2 indicates the number of sectors read + ; successfully. + ; + mov si, sp + mov ah, 0x42 + int 0x13 + + jnc .exit + + DebugChar('R') ; indicate INT13/F42 error + + ; + ; Issue a disk reset on error. + ; Should this be changed to Func 0xD to skip the diskette controller + ; reset? + ; + xor ax, ax ; Func 0 + int 0x13 ; INT 13 + stc ; set carry to indicate error + +.exit: + mov sp, bp ; restore SP + popad + ret + + +;-------------------------------------------------------------------------- +; Write a string with 'boot0: ' prefix to the console. +; +; Arguments: +; ES:DI pointer to a NULL terminated string. +; +; Clobber list: +; DI +; +log_string: + pusha + + push di + mov si, log_title_str + call print_string + + pop si + call print_string + + popa + + ret + + +;-------------------------------------------------------------------------- +; Write a string to the console. +; +; Arguments: +; DS:SI pointer to a NULL terminated string. +; +; Clobber list: +; AX, BX, SI +; +print_string: + mov bx, 1 ; BH=0, BL=1 (blue) + cld ; increment SI after each lodsb call +.loop: + lodsb ; load a byte from DS:SI into AL + cmp al, 0 ; Is it a NULL? + je .exit ; yes, all done + mov ah, 0xE ; INT10 Func 0xE + int 0x10 ; display byte in tty mode + jmp short .loop +.exit: + ret + + +%if DEBUG + +;-------------------------------------------------------------------------- +; Write a ASCII character to the console. +; +; Arguments: +; AL = ASCII character. +; +print_char: + pusha + mov bx, 1 ; BH=0, BL=1 (blue) + mov ah, 0x0e ; bios INT 10, Function 0xE + int 0x10 ; display byte in tty mode + popa + ret + + +;-------------------------------------------------------------------------- +; Write the 4-byte value to the console in hex. +; +; Arguments: +; EAX = Value to be displayed in hex. +; +print_hex: + pushad + mov cx, WORD 4 + bswap eax +.loop: + push ax + ror al, 4 + call print_nibble ; display upper nibble + pop ax + call print_nibble ; display lower nibble + ror eax, 8 + loop .loop + + mov al, 10 ; carriage return + call print_char + mov al, 13 + call print_char + + popad + ret + +print_nibble: + and al, 0x0f + add al, '0' + cmp al, '9' + jna .print_ascii + add al, 'A' - '9' - 1 +.print_ascii: + call print_char + ret + +getc: + pusha + mov ah, 0 + int 0x16 + popa + ret +%endif ;DEBUG + + +;-------------------------------------------------------------------------- +; NULL terminated strings. +; +log_title_str db 10, 13, 'boot0: ', 0 + +%if VERBOSE +gpt_str db 'GPT', 0 +test_str db 'test', 0 +done_str db 'done', 0 +%endif + +boot_error_str db 'error', 0 + +;-------------------------------------------------------------------------- +; Pad the rest of the 512 byte sized booter with zeroes. The last +; two bytes is the mandatory boot sector signature. +; +; If the booter code becomes too large, then nasm will complain +; that the 'times' argument is negative. + +; +; According to EFI specification, maximum boot code size is 440 bytes +; + +; +; XXX - compilation errors with debug enabled (see comment above about nasm) +; Azi: boot0.s:808: error: TIMES value -111 is negative +; boot0.s:811: error: TIMES value -41 is negative +; +pad_boot: + times 440-($-$$) db 0 + +pad_table_and_sig: + times 510-($-$$) db 0 + dw kBootSignature + + + ABSOLUTE 0xE400 + +; +; In memory variables. +; +my_lba resd 1 ; Starting LBA for read_lba function + +; END diff --git a/i386/boot1/boot1h.s b/i386/boot1/boot1h.s new file mode 100644 index 0000000..2676767 --- /dev/null +++ b/i386/boot1/boot1h.s @@ -0,0 +1,1487 @@ +; Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. +; +; @APPLE_LICENSE_HEADER_START@ +; +; Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights +; Reserved. This file contains Original Code and/or Modifications of +; Original Code as defined in and that are subject to the Apple Public +; Source License Version 2.0 (the "License"). You may not use this file +; except in compliance with the License. Please obtain a copy of the +; License at http://www.apple.com/publicsource and read it before using +; this file. +; +; The Original Code and all software distributed under the License are +; distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +; EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +; INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the +; License for the specific language governing rights and limitations +; under the License. +; +; @APPLE_LICENSE_HEADER_END@ +; +; Partition Boot Loader: boot1h +; +; This program is designed to reside in sector 0+1 of an HFS+ partition. +; It expects that the MBR has left the drive number in DL +; and a pointer to the partition entry in SI. +; +; This version requires a BIOS with EBIOS (LBA) support. +; +; This code is written for the NASM assembler. +; nasm boot1h.s -o boot1h + +; +; This version of boot1h tries to find a stage2 boot file in the root folder. +; +; NOTE: this is an experimental version with multiple extent support. +; +; Written by Tamás Kosárszky on 2008-04-14 +; + +; +; Set to 1 to enable obscure debug messages. +; +DEBUG EQU 0 + +; +; Set to 1 to enable unused code. +; +UNUSED EQU 0 + +; +; Set to 1 to enable verbose mode. +; +VERBOSE EQU 0 + +; +; Various constants. +; +NULL EQU 0 +CR EQU 0x0D +LF EQU 0x0A + +mallocStart EQU 0x1000 ; start address of local workspace area +maxSectorCount EQU 64 ; maximum sector count for readSectors +maxNodeSize EQU 16384 + +kSectorBytes EQU 512 ; sector size in bytes +kBootSignature EQU 0xAA55 ; boot sector signature + +kBoot1StackAddress EQU 0xFFF0 ; boot1 stack pointer +kBoot1LoadAddr EQU 0x7C00 ; boot1 load address +kBoot1RelocAddr EQU 0xE000 ; boot1 relocated address +kBoot1Sector1Addr EQU kBoot1RelocAddr + kSectorBytes ; boot1 load address for sector 1 +kHFSPlusBuffer EQU kBoot1Sector1Addr + kSectorBytes ; HFS+ Volume Header address + +kBoot2Sectors EQU (145 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors +kBoot2Segment EQU 0x2000 ; boot2 load segment +kBoot2Address EQU kSectorBytes ; boot2 load address + +; +; Format of fdisk partition entry. +; +; The symbol 'part_size' is automatically defined as an `EQU' +; giving the size of the structure. +; + struc part +.bootid resb 1 ; bootable or not +.head resb 1 ; starting head, sector, cylinder +.sect resb 1 ; +.cyl resb 1 ; +.type resb 1 ; partition type +.endhead resb 1 ; ending head, sector, cylinder +.endsect resb 1 ; +.endcyl resb 1 ; +.lba resd 1 ; starting lba +.sectors resd 1 ; size in sectors + endstruc + +;------------------------------------------------------------------------- +; HFS+ related structures and constants +; +kHFSPlusSignature EQU 'H+' ; HFS+ volume signature +kHFSPlusCaseSignature EQU 'HX' ; HFS+ volume case-sensitive signature +kHFSPlusCaseSigX EQU 'X' ; upper byte of HFS+ volume case-sensitive signature +kHFSPlusExtentDensity EQU 8 ; 8 extent descriptors / extent record + +; +; HFSUniStr255 +; + struc HFSUniStr255 +.length resw 1 +.unicode resw 255 + endstruc + +; +; HFSPlusExtentDescriptor +; + struc HFSPlusExtentDescriptor +.startBlock resd 1 +.blockCount resd 1 + endstruc + +; +; HFSPlusForkData +; + struc HFSPlusForkData +.logicalSize resq 1 +.clumpSize resd 1 +.totalBlocks resd 1 +.extents resb kHFSPlusExtentDensity * HFSPlusExtentDescriptor_size + endstruc + +; +; HFSPlusVolumeHeader +; + struc HFSPlusVolumeHeader +.signature resw 1 +.version resw 1 +.attributes resd 1 +.lastMountedVersion resd 1 +.journalInfoBlock resd 1 +.createDate resd 1 +.modifyDate resd 1 +.backupDate resd 1 +.checkedDate resd 1 +.fileCount resd 1 +.folderCount resd 1 +.blockSize resd 1 +.totalBlocks resd 1 +.freeBlocks resd 1 +.nextAllocation resd 1 +.rsrcClumpSize resd 1 +.dataClumpSize resd 1 +.nextCatalogID resd 1 +.writeCount resd 1 +.encodingsBitmap resq 1 +.finderInfo resd 8 +.allocationFile resb HFSPlusForkData_size +.extentsFile resb HFSPlusForkData_size +.catalogFile resb HFSPlusForkData_size +.attributesFile resb HFSPlusForkData_size +.startupFile resb HFSPlusForkData_size + endstruc + +; +; B-tree related structures and constants +; + +kBTIndexNode EQU 0 +kBTMaxRecordLength EQU 264 ; sizeof(kHFSPlusFileThreadRecord) +kHFSRootParentID EQU 1 ; Parent ID of the root folder +kHFSRootFolderID EQU 2 ; Folder ID of the root folder +kHFSExtentsFileID EQU 3 ; File ID of the extents overflow file +kHFSCatalogFileID EQU 4 ; File ID of the catalog file +kHFSPlusFileRecord EQU 0x200 +kForkTypeData EQU 0 +kForkTypeResource EQU 0xFF + +; +; BTNodeDescriptor +; + struc BTNodeDescriptor +.fLink resd 1 +.bLink resd 1 +.kind resb 1 +.height resb 1 +.numRecords resw 1 +.reserved resw 1 + endstruc + +; +; BTHeaderRec +; + struc BTHeaderRec +.treeDepth resw 1 +.rootNode resd 1 +.leafRecords resd 1 +.firstLeafNode resd 1 +.lastLeafNode resd 1 +.nodeSize resw 1 +.maxKeyLength resw 1 +.totalNodes resd 1 +.freeNodes resd 1 +.reserved1 resw 1 +.clumpSize resd 1 +.btreeType resb 1 +.keyCompareType resb 1 +.attributes resd 1 +.reserved3 resd 16 + endstruc + +; +; BTIndexRec +; + struc BTIndexRec +.childID resd 1 + endstruc + +; +; HFSPlusCatalogKey +; + struc HFSPlusCatalogKey +; +; won't use the keyLength field for easier addressing data inside this structure +; +;.keyLength resw 1 + +.parentID resd 1 +.nodeName resb HFSUniStr255_size + endstruc + +; +; HFSPlusExtentKey +; + struc HFSPlusExtentKey +; +; won't use the keyLength field for easier addressing data inside this structure +; +;.keyLength resw 1 + +.forkType resb 1 +.pad resb 1 +.fileID resd 1 +.startBlock resd 1 + endstruc + +; +; HFSPlusBSDInfo +; + struc HFSPlusBSDInfo +.ownerID resd 1 +.groupID resd 1 +.adminFlags resb 1 +.ownerFlags resb 1 +.fileMode resw 1 +.special resd 1 + endstruc + +; +; FileInfo +; + struc FileInfo +.fileType resd 1 +.fileCreator resd 1 +.finderFlags resw 1 +.location resw 2 +.reservedField resw 1 + endstruc + +; +; ExtendedFileInfo +; + struc ExtendedFileInfo +.reserved1 resw 4 +.extFinderFlags resw 1 +.reserved2 resw 1 +.putAwayFolderID resd 1 + endstruc + +; +; HFSPlusCatalogFile +; + struc HFSPlusCatalogFile +.recordType resw 1 +.flags resw 1 +.reserved1 resd 1 +.fileID resd 1 +.createDate resd 1 +.contentModDate resd 1 +.attributeModDate resd 1 +.accessDate resd 1 +.backupDate resd 1 +.permissions resb HFSPlusBSDInfo_size +.userInfo resb FileInfo_size +.finderInfo resb ExtendedFileInfo_size +.textEncoding resd 1 +.reserved2 resd 1 +.dataFork resb HFSPlusForkData_size +.resourceFork resb HFSPlusForkData_size + endstruc + +; +; Macros. +; +%macro jmpabs 1 + push WORD %1 + ret +%endmacro + +%macro DebugCharMacro 1 + pushad + mov al, %1 + call print_char + call getc + popad +%endmacro + +%macro PrintCharMacro 1 + pushad + mov al, %1 + call print_char + popad +%endmacro + +%macro PutCharMacro 1 + call print_char +%endmacro + +%macro PrintHexMacro 1 + call print_hex +%endmacro + +%macro PrintString 1 + mov si, %1 + call print_string +%endmacro + +%macro LogString 1 + mov di, %1 + call log_string +%endmacro + +%if DEBUG + %define DebugChar(x) DebugCharMacro x + %define PrintChar(x) PrintCharMacro x + %define PutChar(x) PutCharMacro + %define PrintHex(x) PrintHexMacro x +%else + %define DebugChar(x) + %define PrintChar(x) + %define PutChar(x) + %define PrintHex(x) +%endif + +;-------------------------------------------------------------------------- +; Start of text segment. + + SEGMENT .text + + ORG kBoot1RelocAddr + +;-------------------------------------------------------------------------- +; Boot code is loaded at 0:7C00h. +; +start: + ; + ; Set up the stack to grow down from kBoot1StackSegment:kBoot1StackAddress. + ; Interrupts should be off while the stack is being manipulated. + ; + + cli ; interrupts off + xor ax, ax ; zero ax + mov ss, ax ; ss <- 0 + mov sp, kBoot1StackAddress ; sp <- top of stack + sti ; reenable interrupts + + mov ds, ax ; ds <- 0 + mov es, ax ; es <- 0 + + ; + ; Relocate boot1 code. + ; + push si + mov si, kBoot1LoadAddr ; si <- source + mov di, kBoot1RelocAddr ; di <- destination + cld ; auto-increment SI and/or DI registers + mov cx, kSectorBytes ; copy 256 words + rep movsb ; repeat string move (word) operation + pop si + + ; + ; Code relocated, jump to startReloc in relocated location. + ; + ; FIXME: Is there any way to instruct NASM to compile a near jump + ; using absolute address instead of relative displacement? + ; + jmpabs startReloc + +;-------------------------------------------------------------------------- +; Start execution from the relocated location. +; +startReloc: + + ; + ; Initializing global variables. + ; + mov eax, [si + part.lba] + mov [gPartLBA], eax ; save the current partition LBA offset + mov [gBIOSDriveNumber], dl ; save BIOS drive number + mov WORD [gMallocPtr], mallocStart ; set free space pointer + + ; + ; Loading upper 512 bytes of boot1h and HFS+ Volume Header. + ; + xor ecx, ecx ; sector 1 of current partition + inc ecx + mov al, 2 ; read 2 sectors: sector 1 of boot1h + HFS+ Volume Header + mov edx, kBoot1Sector1Addr + call readLBA + + ; + ; Initializing more global variables. + ; + mov eax, [kHFSPlusBuffer + HFSPlusVolumeHeader.blockSize] + bswap eax ; convert to little-endian + shr eax, 9 ; convert to sector unit + mov [gBlockSize], eax ; save blockSize as little-endian sector unit! + + ; + ; Looking for HFSPlus ('H+') or HFSPlus case-sensitive ('HX') signature. + ; + mov ax, [kHFSPlusBuffer + HFSPlusVolumeHeader.signature] + cmp ax, kHFSPlusCaseSignature + je findRootBoot + cmp ax, kHFSPlusSignature + jne error + +;-------------------------------------------------------------------------- +; Find stage2 boot file in a HFS+ Volume's root folder. +; +findRootBoot: + mov al, kHFSCatalogFileID + lea si, [searchCatalogKey] + lea di, [kHFSPlusBuffer + HFSPlusVolumeHeader.catalogFile + HFSPlusForkData.extents] + call lookUpBTree + jne error + + lea si, [bp + BTree.recordDataPtr] + mov si, [si] + cmp WORD [si], kHFSPlusFileRecord + jne error + +; EAX = Catalog File ID +; BX = read size in sectors +; ECX = file offset in sectors +; EDX = address of read buffer +; DI = address of HFSPlusForkData + + ; + ; Use the second big-endian double-word as the file length in HFSPlusForkData.logicalSize + ; + mov ebx, [si + HFSPlusCatalogFile.dataFork + HFSPlusForkData.logicalSize + 4] + bswap ebx ; convert file size to little-endian + add ebx, kSectorBytes - 1 ; adjust size before unit conversion + shr ebx, 9 ; convert file size to sector unit + cmp bx, kBoot2Sectors ; check if bigger than max stage2 size + ja error + mov eax, [si + HFSPlusCatalogFile.fileID] + bswap eax ; convert fileID to little-endian + xor ecx, ecx + mov edx, (kBoot2Segment << 4) + kBoot2Address + lea di, [si + HFSPlusCatalogFile.dataFork + HFSPlusForkData.extents] + call readExtent + +%if VERBOSE + LogString(root_str) +%endif + +boot2: + +%if DEBUG + DebugChar ('!') +%endif + +%if UNUSED + ; + ; Waiting for a key press. + ; + + mov ah, 0 + int 0x16 +%endif + + mov dl, [gBIOSDriveNumber] ; load BIOS drive number + jmp kBoot2Segment:kBoot2Address + +error: + +%if VERBOSE + LogString(error_str) +%endif + +hang: + hlt + jmp hang + +;-------------------------------------------------------------------------- +; readSectors - Reads more than 127 sectors using LBA addressing. +; +; Arguments: +; AX = number of 512-byte sectors to read (valid from 1-1280). +; EDX = pointer to where the sectors should be stored. +; ECX = sector offset in partition +; +; Returns: +; CF = 0 success +; 1 error +; +readSectors: + pushad + mov bx, ax + +.loop: + xor eax, eax ; EAX = 0 + mov al, bl ; assume we reached the last block. + cmp bx, maxSectorCount ; check if we really reached the last block + jb .readBlock ; yes, BX < MaxSectorCount + mov al, maxSectorCount ; no, read MaxSectorCount + +.readBlock: + call readLBA + sub bx, ax ; decrease remaning sectors with the read amount + jz .exit ; exit if no more sectors left to be loaded + add ecx, eax ; adjust LBA sector offset + shl ax, 9 ; convert sectors to bytes + add edx, eax ; adjust target memory location + jmp .loop ; read remaining sectors + +.exit: + popad + ret + +;-------------------------------------------------------------------------- +; readLBA - Read sectors from a partition using LBA addressing. +; +; Arguments: +; AL = number of 512-byte sectors to read (valid from 1-127). +; EDX = pointer to where the sectors should be stored. +; ECX = sector offset in partition +; [bios_drive_number] = drive number (0x80 + unit number) +; +; Returns: +; CF = 0 success +; 1 error +; +readLBA: + pushad ; save all registers + push es ; save ES + mov bp, sp ; save current SP + + ; + ; Convert EDX to segment:offset model and set ES:BX + ; + ; Some BIOSes do not like offset to be negative while reading + ; from hard drives. This usually leads to "boot1: error" when trying + ; to boot from hard drive, while booting normally from USB flash. + ; The routines, responsible for this are apparently different. + ; Thus we split linear address slightly differently for these + ; capricious BIOSes to make sure offset is always positive. + ; + + mov bx, dx ; save offset to BX + and bh, 0x0f ; keep low 12 bits + shr edx, 4 ; adjust linear address to segment base + xor dl, dl ; mask low 8 bits + mov es, dx ; save segment to ES + + ; + ; Create the Disk Address Packet structure for the + ; INT13/F42 (Extended Read Sectors) on the stack. + ; + + ; push DWORD 0 ; offset 12, upper 32-bit LBA + push ds ; For sake of saving memory, + push ds ; push DS register, which is 0. + + add ecx, [gPartLBA] ; offset 8, lower 32-bit LBA + push ecx + + push es ; offset 6, memory segment + + push bx ; offset 4, memory offset + + xor ah, ah ; offset 3, must be 0 + push ax ; offset 2, number of sectors + + push WORD 16 ; offset 0-1, packet size + + ; + ; INT13 Func 42 - Extended Read Sectors + ; + ; Arguments: + ; AH = 0x42 + ; [bios_drive_number] = drive number (0x80 + unit number) + ; DS:SI = pointer to Disk Address Packet + ; + ; Returns: + ; AH = return status (sucess is 0) + ; carry = 0 success + ; 1 error + ; + ; Packet offset 2 indicates the number of sectors read + ; successfully. + ; + mov dl, [gBIOSDriveNumber] ; load BIOS drive number + mov si, sp + mov ah, 0x42 + int 0x13 + + jc error + + ; + ; Issue a disk reset on error. + ; Should this be changed to Func 0xD to skip the diskette controller + ; reset? + ; +; xor ax, ax ; Func 0 +; int 0x13 ; INT 13 +; stc ; set carry to indicate error + +.exit: + mov sp, bp ; restore SP + pop es ; restore ES + popad + ret + +%if VERBOSE + +;-------------------------------------------------------------------------- +; Write a string with 'boot1: ' prefix to the console. +; +; Arguments: +; ES:DI pointer to a NULL terminated string. +; +; Clobber list: +; DI +; +log_string: + pushad + + push di + mov si, log_title_str + call print_string + + pop si + call print_string + + popad + + ret + +;------------------------------------------------------------------------- +; Write a string to the console. +; +; Arguments: +; DS:SI pointer to a NULL terminated string. +; +; Clobber list: +; AX, BX, SI +; +print_string: + mov bx, 1 ; BH=0, BL=1 (blue) + +.loop: + lodsb ; load a byte from DS:SI into AL + cmp al, 0 ; Is it a NULL? + je .exit ; yes, all done + mov ah, 0xE ; INT10 Func 0xE + int 0x10 ; display byte in tty mode + jmp .loop + +.exit: + ret + +%endif ; VERBOSE + +%if DEBUG + +;-------------------------------------------------------------------------- +; Write the 4-byte value to the console in hex. +; +; Arguments: +; EAX = Value to be displayed in hex. +; +print_hex: + pushad + mov cx, WORD 4 + bswap eax +.loop: + push ax + ror al, 4 + call print_nibble ; display upper nibble + pop ax + call print_nibble ; display lower nibble + ror eax, 8 + loop .loop + +%if UNUSED + mov al, 10 ; carriage return + call print_char + mov al, 13 + call print_char +%endif ; UNUSED + + popad + ret + +print_nibble: + and al, 0x0f + add al, '0' + cmp al, '9' + jna .print_ascii + add al, 'A' - '9' - 1 +.print_ascii: + call print_char + ret + +;-------------------------------------------------------------------------- +; getc - wait for a key press +; +getc: + pushad + mov ah, 0 + int 0x16 + popad + ret + +;-------------------------------------------------------------------------- +; Write a ASCII character to the console. +; +; Arguments: +; AL = ASCII character. +; +print_char: + pushad + mov bx, 1 ; BH=0, BL=1 (blue) + mov ah, 0x0e ; bios INT 10, Function 0xE + int 0x10 ; display byte in tty mode + popad + ret + +%endif ; DEBUG + +%if UNUSED + +;-------------------------------------------------------------------------- +; Convert null terminated string to HFSUniStr255 +; +; Arguments: +; DS:DX pointer to a NULL terminated string. +; ES:DI pointer to result. +; +ConvertStrToUni: + pushad ; save registers + push di ; save DI for unicode string length pointer + mov si, dx ; use SI as source string pointer + xor ax, ax ; AX = unicode character + mov cl, al ; CL = string length + +.loop: + stosw ; store unicode character (length 0 at first run) + lodsb ; load next character to AL + inc cl ; increment string length count + cmp al, NULL ; check for string terminator + jne .loop + + pop di ; restore unicode string length pointer + dec cl ; ignoring terminator from length count + mov [di], cl ; save string length + popad ; restore registers + ret + +%endif ; UNUSED + +;-------------------------------------------------------------------------- +; Convert big-endian HFSUniStr255 to little-endian +; +; Arguments: +; DS:SI = pointer to big-endian HFSUniStr255 +; ES:DI = pointer to result buffer +; +ConvertHFSUniStr255ToLE: + pushad + lodsw + xchg ah, al + stosw + cmp al, 0 + je .exit + mov cx, ax + +.loop: + lodsw + xchg ah, al ; convert AX to little-endian + + ; + ; When working with a case-sensitive HFS+ (HX) filesystem, we shouldn't change the case. + ; + cmp BYTE [kHFSPlusBuffer + HFSPlusVolumeHeader.signature + 1], kHFSPlusCaseSigX + je .keepcase + + or ax, ax + jne .convertToLE + dec ax ; NULL must be the strongest char + +.convertToLE: + cmp ah, 0 + ja .keepcase + cmp al, 'A' + jb .keepcase + cmp al, 'Z' + ja .keepcase + add al, 32 ; convert to lower-case + +.keepcase: + stosw + loop .loop + +.exit: + popad + ret + +;-------------------------------------------------------------------------- +; compare HFSPlusExtentKey structures +; +; Arguments: +; DS:SI = search key +; ES:DI = trial key +; +; Returns: +; [BTree.searchResult] = result +; FLAGS = relation between search and trial keys +; +compareHFSPlusExtentKeys: + pushad + + mov dl, 0 ; DL = result of comparison, DH = bestGuess + mov eax, [si + HFSPlusExtentKey.fileID] + cmp eax, [di + HFSPlusExtentKey.fileID] + jne .checkFlags + + cmp BYTE [si + HFSPlusExtentKey.forkType], kForkTypeData + jne .checkFlags + + mov eax, [si + HFSPlusExtentKey.startBlock] + cmp eax, [di + HFSPlusExtentKey.startBlock] + je compareHFSPlusCatalogKeys.exit + +.checkFlags: + ja compareHFSPlusCatalogKeys.searchKeyGreater ; search key > trial key + jb compareHFSPlusCatalogKeys.trialKeyGreater ; search key < trial key + +;-------------------------------------------------------------------------- +; Compare HFSPlusCatalogKey structures +; +; Arguments: +; DS:SI = search key +; ES:DI = trial key +; +; Returns: +; [BTree.searchResult] = result +; FLAGS = relation between search and trial keys +; +compareHFSPlusCatalogKeys: + pushad + xor dx, dx ; DL = result of comparison, DH = bestGuess + xchg si, di + lodsd + mov ecx, eax ; ECX = trial parentID + xchg si, di + lodsd ; EAX = search parentID + cmp eax, ecx + ja .searchKeyGreater ; search parentID > trial parentID + jb .trialKeyGreater ; search parentID < trial parentID + +.compareNodeName: ; search parentID = trial parentID + xchg si, di + lodsw + mov cx, ax ; CX = trial nodeName.length + xchg si, di + lodsw ; AX = search nodeName.length + cmp cl, 0 ; trial nodeName.length = 0? + je .searchKeyGreater + + cmp ax, cx + je .strCompare + ja .searchStrLonger + +.trialStrLonger: + dec dh + mov cx, ax + jmp .strCompare + +.searchStrLonger: + inc dh + +.strCompare: + repe cmpsw + ja .searchKeyGreater + jb .trialKeyGreater + mov dl, dh + jmp .exit + +.trialKeyGreater: + dec dl + jmp .exit + +.searchKeyGreater: + inc dl + +.exit: + mov [bp + BTree.searchResult], dl + cmp dl, 0 ; set flags to check relation between keys + + popad + ret + +;-------------------------------------------------------------------------- +; Allocate memory +; +; Arguments: +; CX = size of requested memory +; +; Returns: +; BP = start address of allocated memory +; +; Clobber list: +; CX +; +malloc: + push ax ; save AX + push di ; save DI + mov di, [gMallocPtr] ; start address of free space + push di ; save free space start address + inc di ; + inc di ; keep the first word untouched + dec cx ; for the last memory block pointer. + dec cx ; + mov al, NULL ; fill with zero + rep stosb ; repeat fill + mov [gMallocPtr], di ; adjust free space pointer + pop bp ; BP = start address of allocated memory + mov [di], bp ; set start address of allocated memory at next + ; allocation block's free space address. + pop di ; restore DI + pop ax ; restore AX + ret + +%if UNUSED + +;-------------------------------------------------------------------------- +; Free allocated memory +; +; Returns: +; BP = start address of previously allocated memory +; +free: + lea bp, [gMallocPtr] + mov bp, [bp] + mov [gMallocPtr], bp + ret + +%endif ; UNUSED + +;-------------------------------------------------------------------------- +; Static data. +; + +%if VERBOSE +root_str db '/boot', CR, LF, NULL +%endif + +;-------------------------------------------------------------------------- +; Pad the rest of the 512 byte sized sector with zeroes. The last +; two bytes is the mandatory boot sector signature. +; +; If the booter code becomes too large, then nasm will complain +; that the 'times' argument is negative. + +; +; XXX - compilation errors with debug enabled (see comment above about nasm) +; Azi: boot1h.s:994: error: TIMES value -67 is negative +; +pad_table_and_sig: + times 510-($-$$) db 0 + dw kBootSignature + +; +; Sector 1 code area +; + +;-------------------------------------------------------------------------- +; lookUpBTree - initializes a new BTree instance and +; look up for HFSPlus Catalog File or Extent Overflow keys +; +; Arguments: +; AL = kHFSPlusFileID (Catalog or Extents Overflow) +; SI = address of searchKey +; DI = address of HFSPlusForkData.extents +; +; Returns: +; BP = address of BTree instance +; ECX = rootNode's logical offset in sectors +; +lookUpBTree: + mov cx, BTree_size ; allocate memory with BTree_size + call malloc ; BP = start address of allocated memory. + mov [bp + BTree.fileID], al ; save fileFileID + mov edx, [di] ; first extent of current file + call blockToSector ; ECX = converted to sector unit + mov al, 1 ; 1 sector is enough for + xor edx, edx ; reading current file's header. + lea dx, [bp + BTree.BTHeaderBuffer] ; load into BTreeHeaderBuffer + call readLBA ; read + mov ax, [bp + BTree.BTHeaderBuffer + BTNodeDescriptor_size + BTHeaderRec.nodeSize] + xchg ah, al ; convert to little-endian + mov [bp + BTree.nodeSize], ax ; save nodeSize + + ; + ; Always start the lookup process with the root node. + ; + mov edx, [bp + BTree.BTHeaderBuffer + BTNodeDescriptor_size + BTHeaderRec.rootNode] + +.readNode: + ; + ; Converting nodeID to sector unit + ; + mov ax, [bp + BTree.nodeSize] + shr ax, 9 ; convert nodeSize to sectors + mov bx, ax ; BX = read sector count + cwde + bswap edx ; convert node ID to little-endian + mul edx ; multiply with nodeSize converted to sector unit + mov ecx, eax ; ECX = file offset in BTree + + mov eax, [bp + BTree.fileID] + lea edx, [bp + BTree.nodeBuffer] + call readExtent + + ; + ; AX = lowerBound = 0 + ; + xor ax, ax + + ; + ; BX = upperBound = numRecords - 1 + ; + mov bx, [bp + BTree.nodeBuffer + BTNodeDescriptor.numRecords] + xchg bh, bl + dec bx + +.bsearch: + cmp ax, bx + ja .checkResult ; jump if lowerBound > upperBound + + mov cx, ax + add cx, bx + shr cx, 1 ; test index = (lowerBound + upperBound / 2) + + call getBTreeRecord + +%if UNUSED + pushad + jl .csearchLessThanTrial + jg .csearchGreaterThanTrial + PrintChar('=') + jmp .csearchCont +.csearchGreaterThanTrial: + PrintChar('>') + jmp .csearchCont +.csearchLessThanTrial: + PrintChar('<') +.csearchCont: + popad +%endif ; UNUSED + +.adjustBounds: + je .checkResult + jl .searchLessThanTrial + jg .searchGreaterThanTrial + jmp .bsearch + +.searchLessThanTrial: + mov bx, cx + dec bx ; upperBound = index - 1 + jmp .bsearch + +.searchGreaterThanTrial: + mov ax, cx + inc ax ; lowerBound = index + 1 + jmp .bsearch + +.checkResult: + cmp BYTE [bp + BTree.searchResult], 0 + jge .foundKey + + mov cx, bx + call getBTreeRecord + +.foundKey: + cmp BYTE [bp + BTree.nodeBuffer + BTNodeDescriptor.kind], kBTIndexNode + jne .exit + + lea bx, [bp + BTree.recordDataPtr] + mov bx, [bx] + mov edx, [bx] + jmp .readNode + +.exit: + cmp BYTE [bp + BTree.searchResult], 0 + ret + +;-------------------------------------------------------------------------- +; getBTreeRecord - read and compare BTree record +; +; Arguments: +; CX = record index +; SI = address of search key +; +; Returns: +; [BTree.searchResult] = result of key compare +; [BTree.recordDataPtr] = address of record data +; +getBTreeRecord: + pushad + push si ; save SI + lea di, [bp + BTree.nodeBuffer] ; DI = start of nodeBuffer + push di ; use later + mov ax, [bp + BTree.nodeSize] ; get nodeSize + add di, ax ; DI = beyond nodeBuffer + inc cx ; increment index + shl cx, 1 ; * 2 + sub di, cx ; DI = pointer to record + mov ax, [di] ; offset to record + xchg ah, al ; convert to little-endian + pop di ; start of nodeBuffer + add di, ax ; DI = address of record key + mov si, di ; save to SI + mov ax, [di] ; keyLength + xchg ah, al ; convert to little-endian + inc ax ; suppress keySize (2 bytes) + inc ax ; + add di, ax ; DI = address of record data + mov [bp + BTree.recordDataPtr], di ; save address of record data + lea di, [bp + BTree.trialKey] + push di ; save address of trialKey + lodsw ; suppress keySize (2 bytes) + ; + ; Don't need to compare as DWORD since all reserved CNIDs fits to a single byte + ; + cmp BYTE [bp + BTree.fileID], kHFSCatalogFileID + je .prepareTrialCatalogKey + +.prepareTrialExtentKey: + mov bx, compareHFSPlusExtentKeys + movsw ; copy forkType + pad + mov cx, 2 ; copy fileID + startBlock + +.extentLoop: + lodsd + bswap eax ; convert to little-endian + stosd + loop .extentLoop + jmp .exit + +.prepareTrialCatalogKey: + mov bx, compareHFSPlusCatalogKeys + lodsd + bswap eax ; convert ParentID to little-endian + stosd + call ConvertHFSUniStr255ToLE ; convert nodeName to little-endian + +.exit: + pop di ; restore address of trialKey + +%if UNUSED +; +; Print catalog trial key +; + pushad + mov si, di + lodsd + PrintChar('k') + PrintHex() + lodsw + cmp ax, 0 + je .printExit + mov cx, ax +.printLoop: + lodsw + call print_char + loop .printLoop +.printExit: + popad +; +; +; +%endif ; UNUSED + +%if UNUSED +; +; Print extent trial key +; + pushad + PrintChar('k') + mov si, di + xor eax, eax + lodsw + PrintHex() + lodsd + PrintHex() + lodsd + PrintHex() + popad +; +; +; +%endif ; UNUSED + + pop si ; restore SI + call bx ; call key compare proc + popad + ret + +;-------------------------------------------------------------------------- +; readExtent - read extents from a HFS+ file (multiple extent support) +; +; Arguments: +; EAX = Catalog File ID +; BX = read size in sectors +; ECX = file offset in sectors +; EDX = address of read buffer +; DI = address of HFSPlusForkData.extents +; +readExtent: + pushad + ; + ; Save Catalog File ID as part of a search HFSPlusExtentKey + ; for a possible Extents Overflow lookup. + ; + mov [bp + BTree.searchExtentKey + HFSPlusExtentKey.fileID], eax + mov [bp + BTree.readBufferPtr], edx + mov ax, bx + cwde + mov [bp + BTree.readSize], eax + mov ebx, ecx ; EBX = file offset + xor eax, eax + mov [bp + BTree.currentExtentOffs], eax + +.beginExtentBlock: + mov BYTE [bp + BTree.extentCount], 0 + +.extentSearch: + cmp BYTE [bp + BTree.extentCount], kHFSPlusExtentDensity + jb .continue + +.getNextExtentBlock: + push ebx + mov eax, [bp + BTree.currentExtentOffs] + + ; + ; Converting sector unit to HFS+ allocation block unit. + ; + xor edx, edx + div DWORD [gBlockSize] ; divide with blockSize + + ; + ; Preparing searchExtentKey's startBlock field. + ; + mov [bp + BTree.searchExtentKey + HFSPlusExtentKey.startBlock], eax + + mov al, kHFSExtentsFileID + lea si, [bp + BTree.searchExtentKey] + lea di, [kHFSPlusBuffer + HFSPlusVolumeHeader.extentsFile + HFSPlusForkData.extents] + call lookUpBTree + jnz NEAR .exit + + ; + ; BP points to the new workspace allocated by lookUpBTree. + ; + lea di, [bp + BTree.recordDataPtr] + mov di, [di] + + ; + ; Switch back to the previous workspace. + ; + lea bp, [gMallocPtr] + mov bp, [bp] + mov [gMallocPtr], bp + + pop ebx + jmp .beginExtentBlock + +.continue: + mov edx, [di + HFSPlusExtentDescriptor.blockCount] + call blockToSector ; ECX = converted current extent's blockCount to sectors + mov eax, [bp + BTree.currentExtentOffs] ; EAX = current extent's start offset (sector) + mov edx, eax + add edx, ecx ; EDX = next extent's start offset (sector) + cmp ebx, edx + mov [bp + BTree.currentExtentOffs], edx ; set currentExtentOffs as the next extent's start offset + jae .nextExtent ; jump to next extent if file offset > next extent's start offset + +.foundExtent: + mov edx, ebx + sub edx, eax ; EDX = relative offset within current extent + mov eax, edx ; will be used below to determine read size + mov esi, [bp + BTree.readSize] ; ESI = remaining sectors to be read + add edx, esi + cmp edx, ecx ; test if relative offset + readSize fits to this extent + jbe .read ; read all remaining sectors from this extent + +.splitRead: + sub ecx, eax ; read amount of sectors beginning at relative offset + mov esi, ecx ; of current extent up to the end of current extent + +.read: + mov edx, [di + HFSPlusExtentDescriptor.startBlock] + call blockToSector ; ECX = converted to sectors + add ecx, eax ; file offset converted to sectors + + push si + mov ax, si + mov edx, [bp + BTree.readBufferPtr] + call readSectors + pop si + + add ebx, esi + mov ax, si + cwde + shl ax, 9 ; convert SI (read sector count) to byte unit + add [bp + BTree.readBufferPtr], eax + sub [bp + BTree.readSize], esi + + jz .exit + +.nextExtent: + add di, kHFSPlusExtentDensity + inc BYTE [bp + BTree.extentCount] + jmp .extentSearch + +.exit: + popad + ret + +;-------------------------------------------------------------------------- +; Convert big-endian HFSPlus allocation block to sector unit +; +; Arguments: +; EDX = allocation block +; +; Returns: +; ECX = allocation block converted to sector unit +; +; Clobber list: +; EDX +; +blockToSector: + push eax + mov eax, [gBlockSize] + bswap edx ; convert allocation block to little-endian + mul edx ; multiply with block number + mov ecx, eax ; result in EAX + pop eax + ret + +%if UNUSED + +;-------------------------------------------------------------------------- +; Convert sector unit to HFSPlus allocation block unit +; +; Arguments: +; EDX = sector +; +; Returns: +; ECX = converted to allocation block unit +; +; Clobber list: +; EDX +; +sectorToBlock: + push eax + mov eax, edx + xor edx, edx + div DWORD [gBlockSize] ; divide with blockSize + mov ecx, eax ; result in EAX + pop eax + ret + +%endif ; UNUSED + +%if UNUSED + +;-------------------------------------------------------------------------- +; Convert big-endian BTree node ID to sector unit +; +; Arguments: +; EDX = node ID +; +; Returns: +; ECX = node ID converted to sector unit +; +; Clobber list: +; EDX +; +nodeToSector: + push eax + mov ax, [bp + BTree.nodeSize] + shr ax, 9 ; convert nodeSize to sectors + cwde + bswap edx ; convert node ID to little-endian + mul edx ; multiply with node ID + mov ecx, eax ; result in EAX + pop eax + ret + +%endif ; UNUSED + +;-------------------------------------------------------------------------- +; Static data. +; + +%if VERBOSE +log_title_str db 'boot1: ', NULL +error_str db 'error', NULL +%endif + +searchCatalogKey dd kHFSRootFolderID + dw searchCatKeyNameLen +searchCatKeyName dw 'b', 'o', 'o', 't' ; must be lower case +searchCatKeyNameLen EQU ($ - searchCatKeyName) / 2 + +;-------------------------------------------------------------------------- +; Pad the rest of the 512 byte sized sector with zeroes. The last +; two bytes is the mandatory boot sector signature. +; + +; +; XXX - compilation errors with debug enabled +; Azi: boot1h.s:1452: error: TIMES value -64 is negative +; +pad_sector_1: + times 1022-($-$$) db 0 + dw kBootSignature + +; +; Local BTree variables +; + struc BTree +.mallocLink resw 1 ; pointer to previously allocated memory block +.fileID resd 1 ; will use as BYTE +.nodeSize resd 1 ; will use as WORD +.searchExtentKey resb HFSPlusExtentKey_size +.searchResult resb 1 +.trialKey resb kBTMaxRecordLength +.recordDataPtr resw 1 +.readBufferPtr resd 1 +.currentExtentOffs resd 1 +.readSize resd 1 +.extentCount resb 1 + ALIGNB 2 +.BTHeaderBuffer resb kSectorBytes +.nodeBuffer resb maxNodeSize + endstruc + +; +; Global variables +; + + ABSOLUTE kHFSPlusBuffer + HFSPlusVolumeHeader_size + +gPartLBA resd 1 +gBIOSDriveNumber resw 1 +gBlockSize resd 1 +gMallocPtr resw 1 + +; END diff --git a/i386/boot2/Makefile b/i386/boot2/Makefile index 0c368d7..6d11e76 100644 --- a/i386/boot2/Makefile +++ b/i386/boot2/Makefile @@ -1,98 +1,91 @@ -# Makefile for i386 boot program -# define FLOPPY and SMALL using DEFINES macro as necessary +# +# File: RevoBoot/i386/boot2/Makefile +# +# Updates: +# +# - Support for self compiled libcc_kext.a added (PikerAlpha, October 2012). +# - Major cleanup (PikerAlpha, October 2012). +# - Fixed clang compilation (dgsga, November 2012. Credits to Evan Lojewski for original work). +# - BOOT2ADDR moved to RevoBoot/i386/util/segsize.c (PikerAlpha, November 2012). +# - Simplified calls to RevoBoot/i386/util/segsize (PikerAlpha, November 2012). +# - Reformatted output, include directory dependency lifted (PikerAlpha, November 2012). +# - BOOT2ADDR removed, static compilation and some white space changes (PikerAlpha, November 2012). +# -DIR = boot2 include ../MakePaths.dir OPTIM = -Os -Oz CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror \ -fno-builtin -DSAIO_INTERNAL_USER -static $(OMIT_FRAME_POINTER_CFLAG) \ -DMAKE_TARGET_OS=$(PRODUCT_OS_TARGET) \ - -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \ - -march=pentium4 -msse2 -mfpmath=sse -msoft-float + -DSETTINGS_FILE=SETTINGS/$(MAKE_TARGET_MODEL).h \ + -fno-stack-protector \ + -march=pentium4 -msse2 -msoft-float -DEFINES= -CONFIG = hd -SYMDIR = $(SYMROOT) LIBSADIR = ../libsa LIBSAIODIR = ../libsaio UTILDIR = ../util -INC = -I. -I.. -I$(SYMDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(UTILDIR) - -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif - -AS = as -LD = gcc +INC = -I. -I.. -I$(SYMROOT) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(UTILDIR) +LIBS = -L$(SYMROOT) -lsaio -lsa +LIBDEP = $(SYMROOT)/libsaio.a $(SYMROOT)/libsa.a -LIBS= -L$(SYMDIR) -lsaio -lsa -LIBDEP= $(SYMDIR)/libsaio.a $(SYMDIR)/libsa.a +VPATH = $(OBJROOT):$(SYMROOT) # -# build_gcc no longer builds libgcc.a and libcc_kext.a with 'all' target -# and thus we have to provide it, or people will have to build gcc. +# The order of object filenames below is important; # +OBJS = boot2.o boot.o bootlogo.o graphics.o drivers.o options.o lzss.o lzvn.o -LIBCC= $(UTILDIR)/libcc_kext.a +DIRS_NEEDED = $(OBJROOT) $(SYMROOT) # -# Check ../util/ for a self compiled copy of libcc_kext.a -# - -ifeq ($(wildcard $(LIBCC)),) - # - # Not found: Use Xcode supplied file. - # - LIBCC= `find /usr/llvm-gcc-*/lib/gcc/*/*/ -name \libcc_kext.a` -endif - -OTHER_FILES = -INSTALLDIR = $(DSTROOT)/usr/standalone/i386 -VPATH = $(OBJROOT):$(SYMROOT) - +# Set maximum size of the booter to 128KB (should be more than sufficient). # -# The ordering is important; -# - -OBJS = boot2.o boot.o bootlogo.o graphics.o drivers.o options.o lzss.o +MAXBOOTSIZE = 131072 + +$(MAKEGOAL): $(DIRS_NEEDED) boot + +boot: $(OBJS) + + @echo "\t[LD] boot.sys" + @$(CC) -nostdlib -arch i386 -static \ + -Wl,-preload \ + -Wl,-pie \ + -Wl,-segalign,20 \ + -Wl,-read_only_relocs,suppress \ + -lcc_kext \ + $(filter %.o,$^) $(LIBS) -o ${SYMROOT}/$@.sys + + @echo "\t[LD] boot.sys" + @$(CC) -nostdlib -arch i386 -static -v \ + -Wl,-preload \ + -Wl,-pie \ + -Wl,-segalign,20 \ + -Wl,-segaddr,__INIT,`$(UTILDIR)/segaddr __INIT` \ + -Wl,-segaddr,__TEXT,`$(UTILDIR)/segaddr __TEXT` \ + -Wl,-segaddr,__DATA,`$(UTILDIR)/segaddr __DATA` \ + -Wl,-read_only_relocs,suppress \ + -lcc_kext \ + $(filter %.o,$^) $(LIBS) -o ${SYMROOT}/$@.sys + + @echo "\t[MACHOCONV] boot" + @$(SYMROOT)/machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot + + @echo "============================================" + @size $(SYMROOT)/boot.sys -UTILDIR = ../util -SFILES = boot2.s -CFILES = boot.c bootlogo.c graphics.c drivers.c options.c -HFILES = boot.h bootlogo.h - -OTHERFILES = Makefile -ALLSRC = $(FOREIGNSRC) $(FOREIGNBIN) $(SFILES) $(CFILES) $(HFILES) $(OTHERFILES) -DIRS_NEEDED = $(OBJROOT) $(SYMROOT) -BOOT2ADDR = 20200 -MAXBOOTSIZE = 392704 - -lion: all -mountain-lion: all - -all: $(DIRS_NEEDED) boot - -boot: machOconv $(OBJS) $(LIBDEP) - $(UTILDIR)/ld_classic -static -preload -segaddr __INIT $(BOOT2ADDR) \ - -arch i386 -segalign 20 \ - -o $(SYMROOT)/boot.sys $(filter %.o,$^) $(LIBS) $(LIBCC) - machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot - size $(SYMROOT)/boot.sys - ls -l $(SYMROOT)/boot @( size=`ls -l $(SYMROOT)/boot | awk '{ print $$5}'` ; \ - if expr "$$size" ">" "$(MAXBOOTSIZE)" > /dev/null ;\ - then \ - echo "Booter executable larger than $(MAXBOOTSIZE) bytes" ;\ - rm $(SYMROOT)/boot ;\ - exit 1;\ - fi) + if expr "$$size" ">" "$(MAXBOOTSIZE)" > /dev/null ;\ + then \ + echo "Boot ($$size) larger than $(MAXBOOTSIZE) bytes" ;\ + rm $(SYMROOT)/boot ;\ + exit 1;\ + else \ + echo "=========== boot is $$size bytes ============"; \ + fi) \ -include ../MakeInc.dir + @../../c -#dependencies --include $(OBJROOT)/Makedep +include ../MakeInc.dir diff --git a/i386/boot2/appleClut8.h b/i386/boot2/appleClut8.h deleted file mode 100755 index 50416f7..0000000 --- a/i386/boot2/appleClut8.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 2.0 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * - * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#ifndef __BOOT2_APPLECLUT8_H -#define __BOOT2_APPLECLUT8_H - -static const unsigned char appleClut8[ 256 * 3 ] = -{ - 0xff,0xff,0xff, 0xbf,0xbf,0xbf, 0xbe,0xbe,0xbe, 0xbd,0xbd,0xbd, - 0xbc,0xbc,0xbc, 0xff,0xff,0x00, 0xba,0xba,0xba, 0xb9,0xb9,0xb9, - 0xb8,0xb8,0xb8, 0xb7,0xb7,0xb7, 0xb6,0xb6,0xb6, 0xb5,0xb5,0xb5, - 0xb4,0xb4,0xb4, 0xb3,0xb3,0xb3, 0xb2,0xb2,0xb2, 0x00,0x00,0x00, - 0xb1,0xb1,0xb1, 0xb0,0xb0,0xb0, 0xaf,0xaf,0xaf, 0xae,0xae,0xae, - 0xad,0xad,0xad, 0xac,0xac,0xac, 0xab,0xab,0xab, 0xaa,0xaa,0xaa, - 0xff,0x00,0xff, 0xa9,0xa9,0xa9, 0xa8,0xa8,0xa8, 0xa7,0xa7,0xa7, - 0xa6,0xa6,0xa6, 0xa5,0xa5,0xa5, 0xa4,0xa4,0xa4, 0xa3,0xa3,0xa3, - 0xa2,0xa2,0xa2, 0xa1,0xa1,0xa1, 0xa0,0xa0,0xa0, 0xff,0x00,0x00, - 0x9f,0x9f,0x9f, 0x9e,0x9e,0x9e, 0x9d,0x9d,0x9d, 0x9c,0x9c,0x9c, - 0x9b,0x9b,0x9b, 0x9a,0x9a,0x9a, 0xcc,0xcc,0xff, 0xcc,0xcc,0xcc, - 0x99,0x99,0x99, 0x98,0x98,0x98, 0x97,0x97,0x97, 0x96,0x96,0x96, - 0x95,0x95,0x95, 0x94,0x94,0x94, 0x93,0x93,0x93, 0x92,0x92,0x92, - 0x91,0x91,0x91, 0x90,0x90,0x90, 0x8f,0x8f,0x8f, 0x8e,0x8e,0x8e, - 0x8d,0x8d,0x8d, 0x8c,0x8c,0x8c, 0x8b,0x8b,0x8b, 0x8a,0x8a,0x8a, - 0x89,0x89,0x89, 0x87,0x87,0x87, 0x86,0x86,0x86, 0x85,0x85,0x85, - 0x84,0x84,0x84, 0x83,0x83,0x83, 0x82,0x82,0x82, 0x81,0x81,0x81, - 0x80,0x80,0x80, 0x7f,0x7f,0x7f, 0x7e,0x7e,0x7e, 0x7d,0x7d,0x7d, - 0x7c,0x7c,0x7c, 0x7b,0x7b,0x7b, 0x7a,0x7a,0x7a, 0x79,0x79,0x79, - 0x78,0x78,0x78, 0x76,0x76,0x76, 0x75,0x75,0x75, 0x74,0x74,0x74, - 0x73,0x73,0x73, 0x72,0x72,0x72, 0x71,0x71,0x71, 0x70,0x70,0x70, - 0x6f,0x6f,0x6f, 0x6e,0x6e,0x6e, 0x6d,0x6d,0x6d, 0x6c,0x6c,0x6c, - 0x6b,0x6b,0x6b, 0x6a,0x6a,0x6a, 0x69,0x69,0x69, 0x68,0x68,0x68, - 0x67,0x67,0x67, 0x66,0x66,0x66, 0x64,0x64,0x64, 0x63,0x63,0x63, - 0x62,0x62,0x62, 0x61,0x61,0x61, 0x60,0x60,0x60, 0x5f,0x5f,0x5f, - 0x5e,0x5e,0x5e, 0x5d,0x5d,0x5d, 0x5c,0x5c,0x5c, 0x5b,0x5b,0x5b, - 0x5a,0x5a,0x5a, 0x59,0x59,0x59, 0x58,0x58,0x58, 0x57,0x57,0x57, - 0x56,0x56,0x56, 0x54,0x54,0x54, 0x53,0x53,0x53, 0x52,0x52,0x52, - 0x51,0x51,0x51, 0x50,0x50,0x50, 0x4f,0x4f,0x4f, 0x4e,0x4e,0x4e, - 0x4d,0x4d,0x4d, 0x4c,0x4c,0x4c, 0x4b,0x4b,0x4b, 0x4a,0x4a,0x4a, - 0x49,0x49,0x49, 0x48,0x48,0x48, 0x47,0x47,0x47, 0x46,0x46,0x46, - 0x45,0x45,0x45, 0x43,0x43,0x43, 0x42,0x42,0x42, 0x41,0x41,0x41, - 0x40,0x40,0x40, 0x3f,0x3f,0x3f, 0x3e,0x3e,0x3e, 0x3d,0x3d,0x3d, - 0x3c,0x3c,0x3c, 0x3b,0x3b,0x3b, 0x3a,0x3a,0x3a, 0x39,0x39,0x39, - 0x38,0x38,0x38, 0x37,0x37,0x37, 0x36,0x36,0x36, 0x35,0x35,0x35, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x00,0xff,0xff, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x00,0xff,0x00, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x00,0x00,0xff, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0xdd,0x00,0x00, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x00,0xbb,0x00, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0xbb,0xbb,0xbb, - 0x65,0x65,0x65, 0x88,0x88,0x88, 0x77,0x77,0x77, 0x55,0x55,0x55, - 0x44,0x44,0x44, 0x22,0x22,0x22, 0x65,0x65,0x65, 0x00,0x00,0x00 -}; - -#endif /* !__BOOT2_APPLECLUT8_H */ diff --git a/i386/boot2/boot.c b/i386/boot2/boot.c index 50f3e56..0056cc6 100755 --- a/i386/boot2/boot.c +++ b/i386/boot2/boot.c @@ -30,35 +30,42 @@ */ /* - * INTEL CORPORATION PROPRIETARY INFORMATION + * INTEL CORPORATION PROPRIETARY INFORMATION * - * This software is supplied under the terms of a license agreement or - * nondisclosure agreement with Intel Corporation and may not be copied - * nor disclosed except in accordance with the terms of that agreement. + * This software is supplied under the terms of a license agreement or + * nondisclosure agreement with Intel Corporation and may not be copied + * nor disclosed except in accordance with the terms of that agreement. + * + * Copyright 1988, 1989 by Intel Corporation * - * Copyright 1988, 1989 by Intel Corporation - */ - -/* * Copyright 1993 NeXT Computer, Inc. All rights reserved. * * Completely reworked by Sam Streeper (sam_s@NeXT.com) * Reworked again by Curtis Galloway (galloway@NeXT.com) + * + * Updates: + * - Refactorized by DHP in 2010 and 2011. + * - Optionally include Recovery HD support code (PikerAlpha, November 2012). + * - Fixed clang compilation (PikerAlpha, November 2012). + * - Unused sysConfigValid removed and white space fix (PikerAlpha, November 2012). + * - Fixed boot failure for InstallESD/BaseSystem.dmg/patched kernelcache (PikerAlpha, April 2013). + * - Renamed LION_INSTALL_SUPPORT to INSTALL_ESD_SUPPORT (PikerAlpha, April 2013). + * */ -/* - * Refactorized by DHP in 2010 and 2011. - */ - - #include "boot.h" #include "bootstruct.h" #include "sl.h" #include "libsa.h" -// DHP: Dump all global junk a.s.a.p. +#if DISABLE_LEGACY_XHCI + #include "pci.h" + #include "xhci.h" +#endif -long gBootMode = kBootModeQuiet; // no longer defaults to 0 aka kBootModeNormal +#if PATCH_APIC_RET + #include "backup/apic.h" +#endif //============================================================================== // Local adler32 function. @@ -87,7 +94,7 @@ unsigned long Adler32(unsigned char *buf, long len) k = len < NMAX ? len : NMAX; len -= k; - while (k >= 16) + while (k >= 16) { DO16(buf); buf += 16; @@ -117,11 +124,13 @@ unsigned long Adler32(unsigned char *buf, long len) static void zeroBSS() { - extern char _DATA__bss__begin, _DATA__bss__end; - extern char _DATA__common__begin, _DATA__common__end; + extern int _DATA_bss__start __asm("section$start$__DATA$__bss"); + extern int _DATA_bss__end __asm("section$end$__DATA$__bss"); + extern int _DATA_common__start __asm("section$start$__DATA$__common"); + extern int _DATA_common__end __asm("section$end$__DATA$__common"); - bzero( &_DATA__bss__begin, (&_DATA__bss__end - &_DATA__bss__begin) ); - bzero( &_DATA__common__begin, (&_DATA__common__end - &_DATA__common__begin) ); + bzero(&_DATA_bss__start, (&_DATA_bss__end - &_DATA_bss__start)); + bzero(&_DATA_common__start, (&_DATA_common__end - &_DATA_common__start)); } /* @@ -132,13 +141,13 @@ static void zeroBSS() #if SAFE_MALLOC static void mallocError(char *addr, size_t size, const char *file, int line) { - stop("\nMemory allocation error! Addr=0x%x, Size=0x%x, File=%s, Line=%d\n", (unsigned)addr, (unsigned)size, file, line); + stop("\nMemory allocation error! Addr=0x%x, Size=0x%x, File=%s, Line=%d\n", (unsigned)addr, (unsigned)size, file, line); } #else static void mallocError(char *addr, size_t size) { - printf("\nMemory allocation error (0x%x, 0x%x)\n", (unsigned)addr, (unsigned)size); - asm volatile ("hlt"); + printf("\nMemory allocation error (0x%x, 0x%x)\n", (unsigned)addr, (unsigned)size); + asm volatile ("hlt"); } #endif @@ -148,11 +157,11 @@ static void mallocError(char *addr, size_t size) void boot(int biosdev) { - zeroBSS(); - mallocInit(0, 0, 0, mallocError); + zeroBSS(); + mallocInit(0, 0, 0, mallocError); #if MUST_ENABLE_A20 - // Enable A20 gate before accessing memory above 1 MB. + // Enable A20 gate before accessing memory above 1 MB. if (fastEnableA20() != 0) { enableA20(); // Fast enable failed. Try legacy method. @@ -162,7 +171,7 @@ void boot(int biosdev) bool haveCABootPlist = false; bool quietBootMode = true; - void *fileLoadBuffer = (void *)kLoadAddr; + void *loadBuffer = (void *)kLoadAddr; char bootFile[256]; char rootUUID[37]; @@ -177,40 +186,83 @@ void boot(int biosdev) bootFile[0] = '\0'; rootUUID[0] = '\0'; -#if PRE_LINKED_KERNEL_SUPPORT +#if PRELINKED_KERNEL_SUPPORT bool mayUseKernelCache = false; + bool flushCaches = false; + bool kernelSpecified = false; +#endif long flags, cachetime; -#endif - initPlatform(biosdev); // Passing on the boot drive. + initPlatform(biosdev); -#if DEBUG_STATE_ENABLED - // Don't switch graphics mode / show boot logo when DEBUG is set to 1. - printf("\ngArchCPUType (CPU): %s\n", (gArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386"); - sleep(3); // Silent sleep. -#else +#if DEBUG_BOOT + /* + * In DEBUG mode we don't switch to graphics mode and do not show the Apple boot logo. + */ + printf("\nModel: %s\n", gPlatform.ModelID); + + #if ((MAKE_TARGET_OS & LION) != LION) + printf("\nArchCPUType (CPU): %s\n", (gPlatform.ArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386"); + sleep(3); // Silent sleep. + #endif +#endif + +#if (DEBUG_STATE_ENABLED == 0) showBootLogo(); #endif - // A bit ugly maybe, but this will be changed sometime soon. - while (readKeyboardStatus()) - { - int key = (bgetc() & 0xff); +#if (LOAD_MODEL_SPECIFIC_EFI_DATA == 0 && BLACKMODE == 0) + /* + * We can only make this call here when static EFI is included from: + * RevoBoot/i386/config/EFI/[MacModelNN.h] Not when the data is read from: + * /Extra/EFI/ because then RevoBoot/i386/libsaio/platform.c makes the call. + * + * We can also not call it here if BLACKMODE is enabled, because + * then it fails to load: /usr/standalone/i386/EfiLoginUI/appleLogo.efires + */ + initPartitionChain(); +#endif - if ((key |= 0x20) == 'r') +#if STARTUP_DISK_SUPPORT + // Booting from a Recovery HD ignores the Startup Disk setting (as it should). + if (gPlatform.BootRecoveryHD == false) + { + /* + * sudo nano /etc/rc.shutdown.local + * #!/bin/sh + * /usr/sbin/nvram -x -p > /Extra/NVRAM/nvramStorage.plist + */ + config_file_t nvramStorage; + const char * path = "/Extra/NVRAM/nvramStorage.plist"; + + if (loadConfigFile(path, &nvramStorage) == EFI_SUCCESS) { - gPlatform.BootRecoveryHD = true; - } - } + _BOOT_DEBUG_DUMP("nvramStorage.plist found\n"); - initPartitionChain(); + if (getValueForConfigTableKey(&nvramStorage, "efi-boot-device-data", &val, &length)) + { + _BOOT_DEBUG_DUMP("Key 'efi-boot-device-data' found %d\n", length); - #define loadCABootPlist() loadSystemConfig(&bootInfo->bootConfig) + char * uuid = getStartupDiskUUID((char *)val); - // Loading: /Library/Preferences/SystemConfiguration/com.apple.Boot.plist - // TODO: Check if everything works without having this plist. - if (loadCABootPlist() == STATE_SUCCESS) + if (uuid) + { + _BOOT_DEBUG_DUMP("GUID: %s\n", uuid); + _BOOT_DEBUG_SLEEP(1); + + strlcpy(rootUUID, uuid, 37); + } + } + } + } + else + { + _BOOT_DEBUG_DUMP("Warning: unable to locate nvramStorage.plist\n"); + } +#endif // #if STARTUP_DISK_SUPPORT + + if (loadCABootPlist() == EFI_SUCCESS) { _BOOT_DEBUG_DUMP("com.apple.Boot.plist located.\n"); @@ -234,9 +286,9 @@ void boot(int biosdev) // Is 'arch=' specified as kernel flag? if (getValueForBootKey(kernelFlags, "arch", &val, &length)) // && len >= 4) { - gArchCPUType = (strncmp(val, "x86_64", 6) == 0) ? CPU_TYPE_X86_64 : CPU_TYPE_I386; + gPlatform.ArchCPUType = (strncmp(val, "x86_64", 6) == 0) ? CPU_TYPE_X86_64 : CPU_TYPE_I386; - _BOOT_DEBUG_DUMP("gArchCPUType (c.a.B.plist): %s\n", (gArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386"); + _BOOT_DEBUG_DUMP("ArchCPUType (c.a.B.plist): %s\n", (gPlatform.ArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386"); } // Check for -v (verbose) and -s (single user mode) flags. @@ -245,57 +297,77 @@ void boot(int biosdev) if (gVerboseMode) { -#if DEBUG_BOOT == false + _BOOT_DEBUG_DUMP("Notice: -s (single user mode) and/or -v (verbose mode) specified!\n"); +#if (DEBUG_BOOT == false) setVideoMode(VGA_TEXT_MODE); #endif } - // Check for -x (safe) and -f (flush cache) flags. - if (getValueForBootKey(kernelFlags, kSafeModeFlag, &val, &length) || - getValueForBootKey(kernelFlags, kIgnoreCachesFlag, &val, &length)) + // Check for -x (safe) flag. + if (getValueForBootKey(kernelFlags, kSafeModeFlag, &val, &length)) { - gBootMode = kBootModeSafe; + gPlatform.BootMode = kBootModeSafe; } - // Is 'boot-uuid=' specified as kernel flag? - if (getValueForBootKey(kernelFlags, kBootUUIDKey, &val, &length) && length == 36) + // Check for -f (flush cache) flag. + if (getValueForBootKey(kernelFlags, kIgnoreCachesFlag, &val, &length)) + { + _BOOT_DEBUG_DUMP("Notice: -f (flush cache) specified!\n"); +#if PRELINKED_KERNEL_SUPPORT + flushCaches = true; +#endif + } + + // Is rootUUID still empty and 'boot-uuid=' specified as kernel flag? + if (rootUUID[0] == '\0' && (getValueForBootKey(kernelFlags, kBootUUIDKey, &val, &length) && length == 36)) { _BOOT_DEBUG_DUMP("Target boot-uuid=<%s>\n", val); // Yes. Copy its value into rootUUID. strlcpy(rootUUID, val, 37); } - /* else +#if INSTALL_ESD_SUPPORT + /* + * boot-arg scheme: + * + * container-dmg: optional DMG that contains the root-dmg. + * root-dmg: the DMG that will be the root filesystem. + */ + if (getValueForBootKey(kernelFlags, "container-dmg", &val, &length) && + getValueForBootKey(kernelFlags, "root-dmg", &val, &length)) { - strlcpy(rootUUID, "3453E0E5-017B-38AD-A0AA-D0BBD8565D6", 37); - _BOOT_DEBUG_DUMP("Target boot-uuid=<%s>\n", rootUUID); - } */ - } - } - -#if PRE_LINKED_KERNEL_SUPPORT - /* Look for 'Kernel Cache' key. */ - if (getValueForKey(kKernelCacheKey, &val, &length, &bootInfo->bootConfig)) - { - _BOOT_DEBUG_DUMP("Kernel Cache set to: %s\n", val); + _BOOT_DEBUG_DUMP("Target container-dmg/root-dmg=%s\n", val); - // Key found. Check if the given filepath/name exists. - if (length && GetFileInfo(NULL, val, &flags, &cachetime) == 0) - { - // File located. Init kernelCacheFile so that we can use it as boot file. - gPlatform.KernelCachePath = strdup(val); + gPlatform.BootVolume->flags |= kBVFlagInstallVolume; + } + else if (getValueForBootKey(kernelFlags, "auth-root-dmg", &val, &length)) + { + _BOOT_DEBUG_DUMP("Target auth-root-dmg=%s\n", val); - // Set flag to inform the load process to skip parts of the code. - gPlatform.KernelCacheSpecified = true; + gPlatform.BootVolume->flags |= kBVFlagInstallVolume; + } + else if (getValueForBootKey(kernelFlags, "rp=file:///", &val, &length)) + { + _BOOT_DEBUG_DUMP("Target rp=%s\n", val); - _BOOT_DEBUG_DUMP("kernelcache file found.\n"); + gPlatform.BootVolume->flags |= kBVFlagInstallVolume; + } + else + { + gPlatform.BootVolume->flags = ~kBVFlagInstallVolume; + } +#endif } - - _BOOT_DEBUG_ELSE_DUMP("Error: kernelcache file not found.\n"); + } + // Check for Root UUID (required for Fusion Drives). + if (rootUUID[0] == '\0' && (getValueForKey(kHelperRootUUIDKey, &val, &length, &bootInfo->bootConfig) && length == 36)) + { + _BOOT_DEBUG_DUMP("Target boot-uuid=<%s>\n", val); + + // Yes. Copy its value into rootUUID. + strlcpy(rootUUID, val, 37); } - // _BOOT_DEBUG_ELSE_DUMP("No 'Kernel Cache' key given.\n"); -#endif /* Enable touching of a single BIOS device by setting 'Scan Single Drive' to yes. if (getBoolForKey(kScanSingleDriveKey, &gScanSingleDrive, &bootInfo->bootConfig) && gScanSingleDrive) { @@ -305,12 +377,13 @@ void boot(int biosdev) else { _BOOT_DEBUG_DUMP("No com.apple.Boot.plist found.\n"); + _BOOT_DEBUG_SLEEP(5); } - + // Was a target drive (per UUID) specified in com.apple.Boot.plist? if (rootUUID[0] == '\0') { - _BOOT_DEBUG_DUMP("No UUID specified in com.apple.Boot.plist\n"); + _BOOT_DEBUG_DUMP("No NVRAM-Startup Disk / rd=uuid bootuuid= in com.apple.Boot.plist\n"); // No, so are we booting from a System Volume? if (gPlatform.BootVolume->flags & kBVFlagSystemVolume) @@ -318,12 +391,21 @@ void boot(int biosdev) _BOOT_DEBUG_DUMP("Booting from a System Volume, getting UUID.\n"); // Yes, then let's get the UUID. - if (HFSGetUUID(gPlatform.BootVolume, rootUUID) == STATE_SUCCESS) + if (HFSGetUUID(gPlatform.BootVolume, rootUUID) == EFI_SUCCESS) + { + _BOOT_DEBUG_DUMP("Success [%s]\n", rootUUID); + } + } + else if (gPlatform.BootVolume->flags & kBVFlagInstallVolume) + { + _BOOT_DEBUG_DUMP("Booting from a disk image in the installation directory\n"); + + if (HFSGetUUID(gPlatform.BootVolume, rootUUID) == EFI_SUCCESS) { _BOOT_DEBUG_DUMP("Success [%s]\n", rootUUID); } } - else // Booting from USB-stick or SDboot media. + else // Booting from USB-stick or SDboot media { _BOOT_DEBUG_DUMP("Booting from a Non System Volume, getting UUID.\n"); @@ -358,45 +440,112 @@ void boot(int biosdev) * non-default system setting and thus is this the place to update our EFI tree. */ - updateEFITree(rootUUID); + updateEFITree(rootUUID); if (haveCABootPlist) // Check boolean before doing more time consuming tasks. { +#if PRELINKED_KERNEL_SUPPORT + /* + * We cannot use the kernelcache from the Yosemite installer, not yet, + * and thus we load: /System/Library/Caches/Startup/kernelcache instead + */ +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite, El Capitan and Sierra. + // Installation directory located? + if (flushCaches == false) // && (gPlatform.BootVolume->flags != kBVFlagInstallVolume)) + { +#endif // #if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) + _BOOT_DEBUG_DUMP("Checking Kernel Cache key in com.apple.Boot.plist\n"); + + if (getValueForKey(kKernelCacheKey, &val, &length, &bootInfo->bootConfig)) + { + _BOOT_DEBUG_DUMP("Kernel Cache key located in com.apple.Boot.plist\n"); + _BOOT_DEBUG_DUMP("length: %d, val: %s\n", length, val); +#if RECOVERY_HD_SUPPORT + // XXX: Required for booting from the Recovery HD. +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite, El Capitan and Sierra. + // FIXME: This static check sucks! + if (strncmp(val, "\\com.apple.recovery.boot\\prelinkedkernel", length) == 0) + { + val = "/com.apple.recovery.boot/prelinkedkernel"; + } +#else + if (strncmp(val, "\\com.apple.recovery.boot\\kernelcache", length) == 0) + { + val = "/com.apple.recovery.boot/kernelcache"; + } +#endif // #if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite, El Capitan and Sierra. +#endif // #if RECOVERY_HD_SUPPORT + if (length && GetFileInfo(NULL, val, &flags, &cachetime) == 0) + { + _BOOT_DEBUG_DUMP("Kernel Cache set to: %s\n", val); + + // File located. Init kernelCacheFile so that we can use it as boot file. + gPlatform.KernelCachePath = strdup(val); + + // Set flag to inform the load process to skip parts of the code. + gPlatform.KernelCacheSpecified = true; + } + } +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite, El Capitan and Sierra. + } + else + { + if (getValueForKey(kKernelNameKey, &val, &length, &bootInfo->bootConfig)) + { + _BOOT_DEBUG_DUMP("Kernel key located in com.apple.Boot.plist\n"); + _BOOT_DEBUG_DUMP("length: %d, val: %s\n", length, val); + strcpy(bootFile, val); + kernelSpecified = true; + } + } +#endif // #if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) + +#else // #if PRELINKED_KERNEL_SUPPORT + #if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite, El Capitan and Sierra. + sprintf(bootFile, "/System/Library/Kernels/%s", bootInfo->bootFile); + #else + // Set to mach_kernel for Mavericks and earlier versions of OS X. + sprintf(bootFile, "/%s", bootInfo->bootFile); + #endif +#endif // #if PRELINKED_KERNEL_SUPPORT + if (getBoolForKey(kQuietBootKey, &quietBootMode, &bootInfo->bootConfig) && !quietBootMode) { - gBootMode = kBootModeNormal; // Reversed from: gBootMode |= kBootModeQuiet; + gPlatform.BootMode = kBootModeNormal; // Reversed from: gPlatform.BootMode |= kBootModeQuiet; } } - // Parse args, load and start kernel. - while (1) - { + // Parse args, load and start kernel. + while (1) + { // Initialize globals. + gErrors = 0; - sysConfigValid = 0; - gErrors = 0; + int retStatus = -1; - int retStatus = -1; + uint32_t adler32 = 0; getAndProcessBootArguments(kernelFlags); - // Initialize bootFile (defaults to: mach_kernel). + /* Initialize bootFile (defaults to: mach_kernel). strcpy(bootFile, bootInfo->bootFile); + _BOOT_DEBUG_DUMP("bootFile: %s\n", bootFile); + _BOOT_DEBUG_DUMP("bootInfo->bootFile: %s\n", bootInfo->bootFile); + _BOOT_DEBUG_SLEEP(5); */ -#if PRE_LINKED_KERNEL_SUPPORT - - _BOOT_DEBUG_DUMP("gBootMode = %d\n", gBootMode); +#if PRELINKED_KERNEL_SUPPORT + _BOOT_DEBUG_DUMP("gPlatform.BootMode = %d\n", gPlatform.BootMode); // Preliminary checks to prevent us from doing useless things. - mayUseKernelCache = ((gBootMode & kBootModeSafe) == 0); + mayUseKernelCache = ((flushCaches == false) && ((gPlatform.BootMode & kBootModeSafe) == 0)); _BOOT_DEBUG_DUMP("mayUseKernelCache = %s\n", mayUseKernelCache ? "true" : "false"); /* - * A pre-linked kernel, or kernelcache, requires you to have all essential kexts for your + * A prelinkedkernel or kernelcache requires you to have all essential kexts for your * configuration, including FakeSMC.kext in: /System/Library/Extensions/ * Not in /Extra/Extensions/ because this directory will be ignored, completely when a - * pre-linked kernel or kernelcache is used! + * prelinkedkernel or kernelcache is used! * * Note: Not following this word of advise will render your system incapable of booting! */ @@ -410,49 +559,102 @@ void boot(int biosdev) { sprintf(bootFile, "%s", bootInfo->bootFile); } +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite, El Capitan and Sierra. + else + { + if (!kernelSpecified) + { + sprintf(bootFile, "/System/Library/Kernels/%s", bootInfo->bootFile); + } + } +#endif } else { // True when 'Kernel Cache' is set in com.apple.Boot.plist if (gPlatform.KernelCacheSpecified == true) { - _BOOT_DEBUG_DUMP("kernelcache: %s\n", gPlatform.KernelCachePath); + _BOOT_DEBUG_DUMP("kernelcache path: %s\n", gPlatform.KernelCachePath); /* * Starting with Lion, we can take a shortcut by simply pointing * the 'bootFile' to the kernel cache and we are done. */ - sprintf(bootFile, "%s", gPlatform.KernelCachePath); } + else // Try to find a prelinkedkernel/kernelcache + { + char * preLinkedKernelPath = malloc(128); - /* - * We might have been fired up from a USB thumbdrive (kickstart boot) and - * thus we have to check the kernel cache path first (might not be there). - */ + if (gPlatform.HelperPath) // com.apple.boot.[RPS] + { + sprintf(preLinkedKernelPath, "%s%s", gPlatform.HelperPath, gPlatform.KernelCachePath); + } + else + { + sprintf(preLinkedKernelPath, "%s", gPlatform.KernelCachePath); + } - else if (GetFileInfo(NULL, gPlatform.KernelCachePath, &flags, &cachetime) == 0) - { + // Check kernelcache directory + if (GetFileInfo(NULL, preLinkedKernelPath, &flags, &cachetime) == 0) + { + static char adler32Key[PLATFORM_NAME_LEN + ROOT_PATH_LEN]; + + _BOOT_DEBUG_DUMP("Checking for prelinkedkernel...\n"); + + // Zero out platform info (name and kernel root path). + bzero(adler32Key, sizeof(adler32Key)); + + // Construct key for the pre-linked kernel checksum (generated by adler32). + sprintf(adler32Key, gPlatform.ModelID); + sprintf(adler32Key + PLATFORM_NAME_LEN, "%s", BOOT_DEVICE_PATH); + sprintf(adler32Key + (PLATFORM_NAME_LEN + 38), "%s", bootInfo->bootFile); + + adler32 = Adler32((unsigned char *)adler32Key, sizeof(adler32Key)); + + _BOOT_DEBUG_DUMP("adler32: %08X\n", adler32); -#if ((MAKE_TARGET_OS & LION) == LION) // Also for Mountain Lion, which has bit 2 set like Lion. +#if ((MAKE_TARGET_OS & LION) == LION) // Sierra, El Capitan, Yosemite, Mavericks and Mountain Lion also have bit 1 set (like Lion). - _BOOT_DEBUG_DUMP("Checking for kernelcache...\n"); + _BOOT_DEBUG_DUMP("Checking for kernelcache...\n"); - if (GetFileInfo(gPlatform.KernelCachePath, (char *)kKernelCache, &flags, &cachetime) == 0) + // if (GetFileInfo(gPlatform.KernelCachePath, (char *)kKernelCache, &flags, &cachetime) == 0) + if (GetFileInfo(preLinkedKernelPath, (char *)kKernelCache, &flags, &cachetime) == 0) + { + sprintf(bootFile, "%s/%s", preLinkedKernelPath, kKernelCache); + + _BOOT_DEBUG_DUMP("Kernelcache located.\n"); + } + else + { + mayUseKernelCache = false; + _BOOT_DEBUG_DUMP("Failed to locate the kernelcache!\n"); + } + } + else { - sprintf(bootFile, "%s/%s", gPlatform.KernelCachePath, kKernelCache); + mayUseKernelCache = false; + _BOOT_DEBUG_DUMP("Failed to locate the kernelcache directory!\n"); + } + + if (mayUseKernelCache == false) + { + _BOOT_DEBUG_DUMP("No kernelcache found, will load: %s!\n", bootInfo->bootFile); - _BOOT_DEBUG_DUMP("Kernelcache located.\n"); +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite, El Capitan and Sierra. + sprintf(bootFile, "/System/Library/Kernels/%s", bootInfo->bootFile); +#else + // Set to mach_kernel for Mavericks and earlier versions of OS X. + sprintf(bootFile, "/%s", bootInfo->bootFile); +#endif } - _BOOT_DEBUG_ELSE_DUMP("Failed to locate the kernelcache. Will load: %s!\n", bootInfo->bootFile); + free(preLinkedKernelPath); } - - _BOOT_DEBUG_ELSE_DUMP("Failed to locate the kernelcache (directory)!\n"); } -#else // Not for (Mountain) Lion, go easy with the Snow Leopard. +#else // Not for Mavericks/Mountain Lion/Lion, go easy with the Snow Leopard. - static char preLinkedKernelPath[128]; + /* static char preLinkedKernelPath[128]; static char adler32Key[PLATFORM_NAME_LEN + ROOT_PATH_LEN]; unsigned long adler32 = 0; @@ -471,11 +673,11 @@ void boot(int biosdev) adler32 = Adler32((unsigned char *)adler32Key, sizeof(adler32Key)); - _BOOT_DEBUG_DUMP("adler32: %08X\n", adler32); + _BOOT_DEBUG_DUMP("adler32: %08X\n", adler32); */ // Create path to pre-linked kernel. sprintf(preLinkedKernelPath, "%s/%s_%s.%08lX", gPlatform.KernelCachePath, kKernelCache, - ((gArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386"), adler32); + ((gPlatform.ArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386"), adler32); // Check if this file exists. if ((GetFileInfo(NULL, preLinkedKernelPath, &flags, &cachetime) == 0) && ((flags & kFileTypeMask) == kFileTypeFlat)) @@ -486,7 +688,7 @@ void boot(int biosdev) if (LoadFile((const char *)preLinkedKernelPath)) { retStatus = 1; - fileLoadBuffer = (void *)kLoadAddr; + loadBuffer = (void *)kLoadAddr; bootFile[0] = 0; } @@ -500,30 +702,44 @@ void boot(int biosdev) } #endif // #if ((MAKE_TARGET_OS & LION) == LION) -#endif // PRE_LINKED_KERNEL_SUPPORT +#endif // PRELINKED_KERNEL_SUPPORT /* - * The bootFile normally points to 'mach_kernel' but it will be empty when a - * pre-linked kernel was processed, and that is why we check the length here. + * The 'bootFile' normally points to (mach_)kernel but will be empty when + * a prelinkedkernel was processed, or when prelinkedkernel support is + * disabled in the settings file, which is why we check the length here. */ - if (strlen(bootFile)) + if (strlen(bootFile) == 0) { - retStatus = LoadThinFatFile(bootFile, &fileLoadBuffer); - - if (retStatus <= 0 && gArchCPUType == CPU_TYPE_X86_64) +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite, El Capitan and Sierra. + sprintf(bootFile, "/System/Library/Kernels/%s", bootInfo->bootFile); +#else + // Set to mach_kernel for Mavericks and earlier versions of OS X. + sprintf(bootFile, "/%s", bootInfo->bootFile); +#endif + if (GetFileInfo(NULL, bootFile, &flags, &cachetime)) { - _BOOT_DEBUG_DUMP("Load failed for arch=x86_64, trying arch=i386 now.\n"); + stop("ERROR: %s not found!\n", bootFile); + } + } - gArchCPUType = CPU_TYPE_I386; + _BOOT_DEBUG_DUMP("About to load: %s\n", bootFile); - retStatus = LoadThinFatFile(bootFile, &fileLoadBuffer); - } + retStatus = LoadThinFatFile(bootFile, &loadBuffer); - _BOOT_DEBUG_DUMP("LoadStatus(%d): %s\n", retStatus, bootFile); +#if SUPPORT_32BIT_MODE + if (retStatus <= 0 && gPlatform.ArchCPUType == CPU_TYPE_X86_64) + { + _BOOT_DEBUG_DUMP("Load failed for arch=x86_64, trying arch=i386 now.\n"); + + gPlatform.ArchCPUType = CPU_TYPE_I386; + + retStatus = LoadThinFatFile(bootFile, &loadBuffer); } +#endif // SUPPORT_32BIT_MODE - _BOOT_DEBUG_ELSE_DUMP("bootFile empty!\n"); // Should not happen, but helped me once already. + _BOOT_DEBUG_DUMP("LoadStatus(%d): %s\n", retStatus, bootFile); /* * Time to fire up the kernel - previously known as execKernel() @@ -541,12 +757,12 @@ void boot(int biosdev) _BOOT_DEBUG_DUMP("execKernel-1\n"); - if (decodeKernel(fileLoadBuffer, &kernelEntry, (char **) &bootArgs->kaddr, (int *)&bootArgs->ksize) != 0) + if (decodeKernel(loadBuffer, &kernelEntry, (char **) &bootArgs->kaddr, (int *)&bootArgs->ksize) != 0) { stop("DecodeKernel() failed!"); } - _BOOT_DEBUG_DUMP("execKernel-2\n"); + _BOOT_DEBUG_DUMP("execKernel-2 address: 0x%x\n", kernelEntry); // Allocate and copy boot args. moveKernelBootArgs(); @@ -565,7 +781,7 @@ void boot(int biosdev) _BOOT_DEBUG_DUMP("execKernel-4\n"); - finalizeEFITree(); // rootUUID); + finalizeEFITree(adler32); // rootUUID); _BOOT_DEBUG_DUMP("execKernel-5\n"); @@ -577,24 +793,28 @@ void boot(int biosdev) sleep(kBootErrorTimeout); } #endif - _BOOT_DEBUG_DUMP("execKernel-6\n"); finalizeKernelBootConfig(); _BOOT_DEBUG_DUMP("execKernel-7 / gVerboseMode is %s\n", gVerboseMode ? "true" : "false"); - + +#if DISABLE_LEGACY_XHCI + disableLegacyXHCI(); +#endif + +#if PATCH_APIC_RET + patchApicRedirectionTables(); +#endif + // Did we switch to graphics mode yet (think verbose mode)? - if (gVerboseMode || bootArgs->Video.v_display == VGA_TEXT_MODE) + if (gVerboseMode || bootArgs->Video_V1.v_display != GRAPHICS_MODE) { - - _BOOT_DEBUG_SLEEP(6); - - // Switch to graphics mode and show the Apple logo on a gray-ish background. - showBootLogo(); // formerly drawBootGraphics(); + // _BOOT_DEBUG_SLEEP(5); + + // Switch to graphics mode and show the (white) Apple logo on a black/gray background. + showBootLogo(); } - - _BOOT_DEBUG_DUMP("execKernel-8\n"); startMachKernel(kernelEntry, bootArgs); // asm.s } diff --git a/i386/boot2/boot.h b/i386/boot2/boot.h index b841f20..c7604bc 100755 --- a/i386/boot2/boot.h +++ b/i386/boot2/boot.h @@ -20,9 +20,13 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ - */ -/* + * * Copyright 1994 NeXT Computer, Inc. All rights reserved. + * + * Updates: + * - Unused sysConfigValid removed (PikerAlpha, November 2012). + * - STATE_SUCCESS moved to libsaio.h (PikerAlpha, November 2012). + * */ #ifndef __BOOT2_BOOT_H @@ -30,8 +34,6 @@ #include "platform.h" -#define STATE_SUCCESS 0 // Move this to a more appropriate header file. - #if USE_STATIC_DISPLAY_RESOLUTION #define DEFAULT_SCREEN_WIDTH STATIC_SCREEN_WIDTH #define DEFAULT_SCREEN_HEIGHT STATIC_SCREEN_HEIGHT @@ -40,19 +42,6 @@ #define DEFAULT_SCREEN_HEIGHT 1200 #endif -#define APPLE_LOGO_WIDTH 128 -#define APPLE_LOGO_HEIGHT 128 - -/* - * Used in showBootLogo. Now using the VIDEO() macro instead of the static - * values. This way the logo should be properly positioned. With or without - * specifying a "Graphics Mode" in com.apple.Boot.plist And no matter what - * values you've set in RevoBoot/i386/config/settings.h Should all be fine now. - */ - -#define APPLE_LOGO_X ((VIDEO(width) - APPLE_LOGO_WIDTH) / 2) -#define APPLE_LOGO_Y ((VIDEO(height) - APPLE_LOGO_HEIGHT) / 2) - /* * How long to wait (in seconds) to load the kernel after displaying the "boot:" prompt. */ @@ -79,7 +68,6 @@ #define kACPIKey "acpi" #define kScanSingleDriveKey "Scan Single Drive" #define kInsantMenuKey "Instant Menu" -#define kDefaultKernel "mach_kernel" #define kWaitForKeypressKey "Wait" /* @@ -99,21 +87,8 @@ #define kBootTimeout -1 -// A global set by boot() to record the device that the booter was loaded from. - -extern long gBootMode; -extern bool sysConfigValid; extern char bootPrompt[]; -// Kernel Boot Modes -enum -{ - kBootModeNormal = 0, - kBootModeSafe = 1, - kBootModeSecure = 2, - kBootModeQuiet = 4 -}; - /* * Note well that we take an easier approice, and this should not be * confused with /chosen/boot-file-path because this is what we want. @@ -176,6 +151,12 @@ extern long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p); extern int decompressLZSS(u_int8_t *dst, u_int8_t *src, u_int32_t srclen); +/* + * lzss.c + */ + +extern int lzvn_decode(void * decompressedData, uint32_t decompressedSize, void * compressedData, uint32_t compressedSize); + /* * options.c */ diff --git a/i386/boot2/boot2.s b/i386/boot2/boot2.s index b9e1519..98de95f 100755 --- a/i386/boot2/boot2.s +++ b/i386/boot2/boot2.s @@ -61,7 +61,7 @@ # # Returns: # -LABEL(boot2) # Entry point at 0:BOOTER_ADDR (will be called by boot1) +LABEL(start) # Entry point at 0:BOOTER_ADDR (will be called by boot1) pushl %ecx # Save general purpose registers pushl %ebx pushl %ebp diff --git a/i386/boot2/bootlogo.c b/i386/boot2/bootlogo.c index 6244a67..649de2d 100755 --- a/i386/boot2/bootlogo.c +++ b/i386/boot2/bootlogo.c @@ -28,145 +28,117 @@ #include "boot.h" #include "bootlogo.h" -#include "appleClut8.h" #include "bootstruct.h" +#define DEBUG 0 //============================================================================== -unsigned long lookUpCLUTIndex(unsigned char index, unsigned char depth) +unsigned long lookUpCLUTIndex(unsigned char index) { long colorIndex = (index * 3); - long red = appleClut8[ colorIndex ]; - long green = appleClut8[ colorIndex++ ]; - long blue = appleClut8[ colorIndex++ ]; - +#if (((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) && (BLACKMODE == 1)) // Yosemite, El Capitan and Sierra. + long red = AppleLogoBlackClut[ colorIndex ]; + long green = AppleLogoBlackClut[ colorIndex++ ]; + long blue = AppleLogoBlackClut[ colorIndex++ ]; +#else + long red = AppleLogoClut[ colorIndex ]; + long green = AppleLogoClut[ colorIndex++ ]; + long blue = AppleLogoClut[ colorIndex++ ]; +#endif + return (red << 16) | (green << 8) | blue; } - -//============================================================================== - -int convertImage(unsigned short width, unsigned short height, const unsigned char *imageData, unsigned char **newImageData) -{ - int index = 0; - int size = (width * height); // 16384 - int depth = VIDEO(depth); - - unsigned char *img = 0; - unsigned long *img32; - - switch (depth) - { - case 32: - img32 = malloc(size * 4); - - if (!img32) - { - break; - } - - for (; index < size; index++) - { - img32[index] = lookUpCLUTIndex(imageData[index], depth); - } - - img = (unsigned char *)img32; - break; - } - - *newImageData = img; - - return 0; -} - - //============================================================================== -void * stosl(void * dst, long val, long len) +void * stosl(void *dst, long val, long len) { asm volatile ("rep; stosl" : "=c" (len), "=D" (dst) : "0" (len), "1" (dst), "a" (val) : "memory" ); - + return dst; } - //============================================================================== -void drawColorRectangle(unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char colorIndex) +void setBackgroundColor(uint32_t aBackGroundColor) { - long color = lookUpCLUTIndex(colorIndex, VIDEO(depth)); long pixelBytes = VIDEO(depth) / 8; - - char * vram = (char *) VIDEO(baseAddr) + VIDEO(rowBytes) * y + pixelBytes * x; - - width = MIN(width, VIDEO(width) - x); - height = MIN(height, VIDEO(height) - y); - - int rem = (pixelBytes * width) % 4; + + char * vram = (char *) VIDEO(baseAddr) + VIDEO(rowBytes) + pixelBytes; + + int width = VIDEO(width); + int height = VIDEO(height); + + int rem = (pixelBytes * width) % 4; int length = pixelBytes * width / 4; + bcopy(&aBackGroundColor, vram, rem); + while (height--) { - bcopy(&color, vram, rem); - stosl(vram + rem, color, length); + stosl(vram + rem, aBackGroundColor, length); vram += VIDEO(rowBytes); } } - //============================================================================== -void drawDataRectangle(unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char * data) +void drawDataRectangle(unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char *data) { - unsigned short drawWidth; - long pixelBytes = VIDEO(depth) / 8; - - unsigned char * vram = (unsigned char *) VIDEO(baseAddr) + VIDEO(rowBytes) * y + pixelBytes * x; - drawWidth = MIN(width, VIDEO(width) - x); + char * vram = (char *) VIDEO(baseAddr) + VIDEO(rowBytes) * y + pixelBytes * x; + height = MIN(height, VIDEO(height) - y); - while (height--) + if (data) { - bcopy( data, vram, drawWidth * pixelBytes ); - vram += VIDEO(rowBytes); - data += width * pixelBytes; + while (height--) + { + bcopy(data, vram, (width * pixelBytes)); + vram += VIDEO(rowBytes); + data += (width * pixelBytes); + } } } - //============================================================================== -char * decodeRLE(const void * rleData, int rleBlocks, int outBytes) +int convertImage(unsigned short width, unsigned short height, const unsigned char *imageData, unsigned char **newImageData) { - char *out, *cp; + int index = 0; + int size = (width * height); // 16384 + int depth = VIDEO(depth); - struct RLEBlock + unsigned char *img = 0; + unsigned long *img32; + + switch (depth) { - unsigned char count; - unsigned char value; - } * bp = (struct RLEBlock *) rleData; + case 32: + img32 = malloc(size * 4); - out = cp = (char *) malloc(outBytes); + if (!img32) + { + break; + } - if (out == NULL) - { - return NULL; - } - - while (rleBlocks--) - { - memset( cp, bp->value, bp->count ); - cp += bp->count; - bp++; + for (; index < size; index++) + { + img32[index] = lookUpCLUTIndex(imageData[index]); + } + + img = (unsigned char *)img32; + break; } - return out; + *newImageData = img; + + return 0; } @@ -174,18 +146,30 @@ char * decodeRLE(const void * rleData, int rleBlocks, int outBytes) void showBootLogo() { - uint8_t *bootImageData = NULL; - uint8_t *appleBootLogo = (uint8_t *) decodeRLE(appleLogoRLE, 686, 16384); - setVideoMode(GRAPHICS_MODE); - // Fill the background to 75% grey (same as BootX). - drawColorRectangle(0, 0, VIDEO(width), VIDEO(height), 0x01); - - convertImage(APPLE_LOGO_WIDTH, APPLE_LOGO_HEIGHT, appleBootLogo, &bootImageData); +#if (((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) && (BLACKMODE == 1)) // Yosemite, El Capitan and Sierra. + setBackgroundColor(0x030000); + uint32_t compressedSize = sizeof(AppleLogoBlackPacked); + void *logoData = (void *)AppleLogoBlackPacked; +#else + setBackgroundColor(0xbfbfbf); + uint32_t compressedSize = sizeof(AppleLogoPacked); + void *logoData = (void *)AppleLogoPacked; +#endif - drawDataRectangle(APPLE_LOGO_X, APPLE_LOGO_Y, APPLE_LOGO_WIDTH, APPLE_LOGO_HEIGHT, bootImageData); + int logoSize = (APPLE_LOGO_WIDTH * APPLE_LOGO_HEIGHT); + void * decompressedData = malloc(logoSize); - free(bootImageData); - free(appleBootLogo); + if (decompressedData) + { + if (lzvn_decode(decompressedData, logoSize, logoData, compressedSize) == logoSize) + { + uint8_t *bootImageData = NULL; + convertImage(APPLE_LOGO_WIDTH, APPLE_LOGO_HEIGHT, decompressedData, &bootImageData); + drawDataRectangle(APPLE_LOGO_X, APPLE_LOGO_Y, APPLE_LOGO_WIDTH, APPLE_LOGO_HEIGHT, bootImageData); + } + + free(decompressedData); + } } diff --git a/i386/boot2/bootlogo.h b/i386/boot2/bootlogo.h index fbf18d4..342fa85 100755 --- a/i386/boot2/bootlogo.h +++ b/i386/boot2/bootlogo.h @@ -1,125 +1,142 @@ +#define APPLE_LOGO_WIDTH 84 +#define APPLE_LOGO_HEIGHT 103 + +#define VIDEO(x) (bootArgs->Video_V1.v_ ## x) + +/* + * Used in showBootLogo(). Now using the VIDEO() macro instead of the static + * values. This way the logo should be properly positioned. With or without + * specifying a "Graphics Mode" in com.apple.Boot.plist And no matter what + * values you've set in RevoBoot/i386/config/settings.h Should all be fine now. + */ + +#define APPLE_LOGO_X ((VIDEO(width) - APPLE_LOGO_WIDTH) / 2) +#define APPLE_LOGO_Y ((VIDEO(height) - APPLE_LOGO_HEIGHT) / 2) + #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) -#define VIDEO(x) (bootArgs->Video.v_ ## x) +#if (((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) && (BLACKMODE == 1)) + +// +// LZVN packed data for white Apple logo (blackmode). +// -const unsigned char appleLogoRLE[] = +static UInt8 AppleLogoBlackPacked[ 912 ] = { - 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0x50, 0x01, 0x01, 0x02, 0x01, 0x17, - 0x01, 0x34, 0x01, 0x47, 0x03, 0x50, 0x01, 0x13, 0x76, 0x01, 0x01, 0x03, - 0x01, 0x20, 0x01, 0x40, 0x06, 0x50, 0x01, 0x13, 0x75, 0x01, 0x01, 0x1a, - 0x01, 0x42, 0x07, 0x50, 0x01, 0xfa, 0x01, 0x0a, 0x73, 0x01, 0x01, 0x07, - 0x01, 0x34, 0x09, 0x50, 0x01, 0x43, 0x01, 0x02, 0x72, 0x01, 0x01, 0x0e, - 0x01, 0x43, 0x0a, 0x50, 0x01, 0x36, 0x72, 0x01, 0x01, 0x14, 0x01, 0x4a, - 0x0b, 0x50, 0x01, 0x20, 0x71, 0x01, 0x01, 0x12, 0x01, 0x4b, 0x0b, 0x50, - 0x01, 0x4d, 0x01, 0x0b, 0x70, 0x01, 0x01, 0x0b, 0x01, 0x48, 0x0c, 0x50, - 0x01, 0xf9, 0x70, 0x01, 0x01, 0x03, 0x01, 0x3e, 0x0d, 0x50, 0x01, 0x1f, - 0x70, 0x01, 0x01, 0x2f, 0x0d, 0x50, 0x01, 0x48, 0x01, 0x06, 0x6f, 0x01, - 0x01, 0x15, 0x01, 0x4f, 0x0d, 0x50, 0x01, 0x27, 0x6f, 0x01, 0x01, 0x02, - 0x01, 0x3f, 0x0d, 0x50, 0x01, 0x45, 0x01, 0xf7, 0x6f, 0x01, 0x01, 0x1d, - 0x0e, 0x50, 0x01, 0x19, 0x6f, 0x01, 0x01, 0x02, 0x01, 0x40, 0x0d, 0x50, - 0x01, 0x2f, 0x70, 0x01, 0x01, 0x15, 0x0d, 0x50, 0x01, 0x3b, 0x01, 0x03, - 0x70, 0x01, 0x01, 0x34, 0x0c, 0x50, 0x01, 0x3f, 0x01, 0x07, 0x70, 0x01, - 0x01, 0xf7, 0x01, 0x47, 0x0b, 0x50, 0x01, 0xf9, 0x01, 0x07, 0x71, 0x01, - 0x01, 0x14, 0x0b, 0x50, 0x01, 0x36, 0x01, 0xf7, 0x72, 0x01, 0x01, 0x24, - 0x09, 0x50, 0x01, 0x4d, 0x01, 0x28, 0x74, 0x01, 0x01, 0x33, 0x08, 0x50, - 0x01, 0x3f, 0x01, 0x14, 0x75, 0x01, 0x01, 0x3a, 0x06, 0x50, 0x01, 0x41, - 0x01, 0x1f, 0x01, 0x02, 0x76, 0x01, 0x01, 0x3a, 0x03, 0x50, 0x01, 0x48, - 0x01, 0x35, 0x01, 0x17, 0x01, 0x02, 0x78, 0x01, 0x01, 0x15, 0x01, 0x33, - 0x01, 0x27, 0x01, 0x15, 0x01, 0xf7, 0x67, 0x01, 0x01, 0x02, 0x01, 0x08, - 0x01, 0x0e, 0x01, 0x13, 0x01, 0x14, 0x01, 0x12, 0x01, 0x0d, 0x01, 0x06, - 0x01, 0x02, 0x1c, 0x01, 0x01, 0x04, 0x01, 0x0b, 0x01, 0x12, 0x01, 0x17, - 0x01, 0x19, 0x01, 0x15, 0x01, 0x11, 0x01, 0x08, 0x01, 0x02, 0x4e, 0x01, - 0x01, 0x02, 0x01, 0x11, 0x01, 0x26, 0x01, 0x39, 0x01, 0x44, 0x01, 0x4c, - 0x01, 0x4f, 0x02, 0x50, 0x01, 0x4f, 0x01, 0x4d, 0x01, 0x4a, 0x01, 0x3f, - 0x01, 0x31, 0x01, 0x19, 0x01, 0xf7, 0x15, 0x01, 0x01, 0x0b, 0x01, 0x1c, - 0x01, 0x2e, 0x01, 0xf9, 0x01, 0x46, 0x01, 0x4d, 0x04, 0x50, 0x01, 0x4f, - 0x01, 0x4b, 0x01, 0x42, 0x01, 0x34, 0x01, 0x1f, 0x01, 0x0a, 0x49, 0x01, - 0x01, 0xf7, 0x01, 0x21, 0x01, 0x3f, 0x01, 0x4f, 0x0d, 0x50, 0x01, 0x47, - 0x01, 0x2d, 0x01, 0x0d, 0x10, 0x01, 0x01, 0x0d, 0x01, 0x25, 0x01, 0x3d, - 0x01, 0xfa, 0x0e, 0x50, 0x01, 0x4c, 0x01, 0x37, 0x01, 0x15, 0x45, 0x01, - 0x01, 0x04, 0x01, 0x25, 0x01, 0x45, 0x12, 0x50, 0x01, 0x4d, 0x01, 0x39, - 0x01, 0x19, 0x01, 0x02, 0x0a, 0x01, 0x01, 0x09, 0x01, 0x21, 0x01, 0xf9, - 0x01, 0x4d, 0x14, 0x50, 0x01, 0xf9, 0x01, 0x15, 0x42, 0x01, 0x01, 0x17, - 0x01, 0x42, 0x17, 0x50, 0x01, 0x42, 0x01, 0x27, 0x01, 0x0e, 0x01, 0x02, - 0x03, 0x01, 0x01, 0x02, 0x01, 0x0b, 0x01, 0x1f, 0x01, 0x38, 0x01, 0x4b, - 0x19, 0x50, 0x01, 0x33, 0x01, 0x06, 0x3e, 0x01, 0x01, 0x03, 0x01, 0x2e, - 0x1b, 0x50, 0x01, 0x4d, 0x01, 0x43, 0x01, 0x3a, 0x01, 0x37, 0x01, 0x3a, - 0x01, 0x42, 0x01, 0x4d, 0x1d, 0x50, 0x01, 0x42, 0x01, 0x0e, 0x3c, 0x01, - 0x01, 0x0a, 0x01, 0xf9, 0x41, 0x50, 0x01, 0x48, 0x01, 0x13, 0x3a, 0x01, - 0x01, 0x0d, 0x01, 0x45, 0x43, 0x50, 0x01, 0x4b, 0x01, 0x12, 0x38, 0x01, - 0x01, 0x10, 0x01, 0x48, 0x45, 0x50, 0x01, 0x48, 0x01, 0x0b, 0x36, 0x01, - 0x01, 0x0c, 0x01, 0x48, 0x47, 0x50, 0x01, 0x3d, 0x01, 0x03, 0x34, 0x01, - 0x01, 0x07, 0x01, 0x42, 0x49, 0x50, 0x01, 0x21, 0x34, 0x01, 0x01, 0x37, - 0x49, 0x50, 0x01, 0x42, 0x01, 0x12, 0x33, 0x01, 0x01, 0x22, 0x49, 0x50, - 0x01, 0x34, 0x01, 0xf7, 0x33, 0x01, 0x01, 0x0b, 0x01, 0x4b, 0x48, 0x50, - 0x01, 0x2c, 0x35, 0x01, 0x01, 0x36, 0x48, 0x50, 0x01, 0x29, 0x35, 0x01, - 0x01, 0x11, 0x01, 0x4f, 0x47, 0x50, 0x01, 0x2e, 0x36, 0x01, 0x01, 0x36, - 0x47, 0x50, 0x01, 0x3a, 0x01, 0x02, 0x35, 0x01, 0x01, 0x0b, 0x01, 0xfa, - 0x46, 0x50, 0x01, 0x46, 0x01, 0x08, 0x36, 0x01, 0x01, 0x26, 0x46, 0x50, - 0x01, 0x4e, 0x01, 0x15, 0x36, 0x01, 0x01, 0x02, 0x01, 0x40, 0x46, 0x50, - 0x01, 0x31, 0x37, 0x01, 0x01, 0x0e, 0x01, 0x4e, 0x45, 0x50, 0x01, 0x49, - 0x01, 0x08, 0x37, 0x01, 0x01, 0x25, 0x46, 0x50, 0x01, 0x29, 0x38, 0x01, - 0x01, 0x39, 0x45, 0x50, 0x01, 0x4c, 0x01, 0x0a, 0x37, 0x01, 0x01, 0xf7, - 0x01, 0x47, 0x45, 0x50, 0x01, 0x3a, 0x38, 0x01, 0x01, 0x10, 0x01, 0x4f, - 0x45, 0x50, 0x01, 0x22, 0x38, 0x01, 0x01, 0x1d, 0x46, 0x50, 0x01, 0x12, - 0x38, 0x01, 0x01, 0x29, 0x45, 0x50, 0x01, 0x4b, 0x01, 0x07, 0x38, 0x01, - 0x01, 0x36, 0x45, 0x50, 0x01, 0x42, 0x01, 0x02, 0x38, 0x01, 0x01, 0xf9, - 0x45, 0x50, 0x01, 0x3e, 0x39, 0x01, 0x01, 0x42, 0x45, 0x50, 0x01, 0x3c, - 0x39, 0x01, 0x01, 0x46, 0x45, 0x50, 0x01, 0x3b, 0x39, 0x01, 0x01, 0x48, - 0x45, 0x50, 0x01, 0xf9, 0x39, 0x01, 0x01, 0x48, 0x45, 0x50, 0x01, 0x3f, - 0x01, 0x02, 0x38, 0x01, 0x01, 0x46, 0x45, 0x50, 0x01, 0x48, 0x01, 0xf7, - 0x38, 0x01, 0x01, 0x43, 0x45, 0x50, 0x01, 0x4e, 0x01, 0x0e, 0x38, 0x01, - 0x01, 0x3f, 0x46, 0x50, 0x01, 0x1c, 0x38, 0x01, 0x01, 0x3a, 0x46, 0x50, - 0x01, 0x33, 0x38, 0x01, 0x01, 0x34, 0x46, 0x50, 0x01, 0x46, 0x01, 0x04, - 0x37, 0x01, 0x01, 0x2c, 0x47, 0x50, 0x01, 0x19, 0x37, 0x01, 0x01, 0x1f, - 0x47, 0x50, 0x01, 0x3a, 0x37, 0x01, 0x01, 0x15, 0x47, 0x50, 0x01, 0x4e, - 0x01, 0x11, 0x36, 0x01, 0x01, 0x0a, 0x01, 0xfa, 0x47, 0x50, 0x01, 0x37, - 0x36, 0x01, 0x01, 0x02, 0x01, 0x42, 0x47, 0x50, 0x01, 0x4f, 0x01, 0x15, - 0x36, 0x01, 0x01, 0x37, 0x48, 0x50, 0x01, 0x42, 0x01, 0x04, 0x35, 0x01, - 0x01, 0x25, 0x49, 0x50, 0x01, 0x2c, 0x35, 0x01, 0x01, 0x13, 0x49, 0x50, - 0x01, 0x4e, 0x01, 0x15, 0x34, 0x01, 0x01, 0xf7, 0x01, 0x47, 0x49, 0x50, - 0x01, 0x48, 0x01, 0x0b, 0x34, 0x01, 0x01, 0x37, 0x4a, 0x50, 0x01, 0x44, - 0x01, 0x0a, 0x33, 0x01, 0x01, 0x1f, 0x4b, 0x50, 0x01, 0x44, 0x01, 0x0d, - 0x32, 0x01, 0x01, 0x0a, 0x01, 0xfa, 0x4b, 0x50, 0x01, 0x48, 0x01, 0x17, - 0x32, 0x01, 0x01, 0x3a, 0x4c, 0x50, 0x01, 0x4f, 0x01, 0x2c, 0x01, 0x04, - 0x30, 0x01, 0x01, 0x1f, 0x4e, 0x50, 0x01, 0x41, 0x01, 0x19, 0x2f, 0x01, - 0x01, 0x07, 0x01, 0x4a, 0x4e, 0x50, 0x01, 0x44, 0x30, 0x01, 0x01, 0x33, - 0x4e, 0x50, 0x01, 0x36, 0x30, 0x01, 0x01, 0x14, 0x4e, 0x50, 0x01, 0x1f, - 0x30, 0x01, 0x01, 0x02, 0x01, 0x3f, 0x4c, 0x50, 0x01, 0x4d, 0x01, 0x0b, - 0x31, 0x01, 0x01, 0x1e, 0x4c, 0x50, 0x01, 0x3c, 0x32, 0x01, 0x01, 0x04, - 0x01, 0x44, 0x4b, 0x50, 0x01, 0x20, 0x33, 0x01, 0x01, 0x20, 0x4a, 0x50, - 0x01, 0x4a, 0x01, 0x07, 0x33, 0x01, 0x01, 0x04, 0x01, 0x43, 0x49, 0x50, - 0x01, 0x30, 0x35, 0x01, 0x01, 0x1c, 0x48, 0x50, 0x01, 0x4d, 0x01, 0x0e, - 0x35, 0x01, 0x01, 0x02, 0x01, 0x3e, 0x47, 0x50, 0x01, 0x36, 0x37, 0x01, - 0x01, 0x14, 0x01, 0x4f, 0x45, 0x50, 0x01, 0x4d, 0x01, 0x0e, 0x38, 0x01, - 0x01, 0x32, 0x45, 0x50, 0x01, 0x33, 0x39, 0x01, 0x01, 0x07, 0x01, 0x47, - 0x43, 0x50, 0x01, 0x4b, 0x01, 0x0b, 0x3a, 0x01, 0x01, 0x1c, 0x43, 0x50, - 0x01, 0x26, 0x3c, 0x01, 0x01, 0x37, 0x41, 0x50, 0x01, 0x41, 0x01, 0x04, - 0x3c, 0x01, 0x01, 0x08, 0x01, 0x48, 0x3f, 0x50, 0x01, 0x4e, 0x01, 0x13, - 0x3e, 0x01, 0x01, 0x19, 0x3f, 0x50, 0x01, 0x2d, 0x40, 0x01, 0x01, 0x2e, - 0x3d, 0x50, 0x01, 0x3f, 0x01, 0x03, 0x40, 0x01, 0x01, 0x03, 0x01, 0xf9, - 0x3b, 0x50, 0x01, 0x4a, 0x01, 0x0d, 0x42, 0x01, 0x01, 0x09, 0x01, 0x46, - 0x39, 0x50, 0x01, 0x4e, 0x01, 0x19, 0x44, 0x01, 0x01, 0x11, 0x01, 0x4b, - 0x38, 0x50, 0x01, 0x25, 0x46, 0x01, 0x01, 0x17, 0x01, 0x4d, 0x36, 0x50, - 0x01, 0x2e, 0x48, 0x01, 0x01, 0x1b, 0x01, 0x4d, 0x34, 0x50, 0x01, 0x31, - 0x4a, 0x01, 0x01, 0x17, 0x01, 0x4a, 0x14, 0x50, 0x01, 0x4d, 0x01, 0x44, - 0x01, 0x3b, 0x01, 0x34, 0x01, 0x2e, 0x01, 0x2c, 0x01, 0x2e, 0x01, 0x35, - 0x01, 0x3e, 0x01, 0x4a, 0x14, 0x50, 0x01, 0x2e, 0x4c, 0x01, 0x01, 0x0e, - 0x01, 0x41, 0x10, 0x50, 0x01, 0x4a, 0x01, 0x37, 0x01, 0x1f, 0x01, 0x0c, - 0x01, 0x03, 0x07, 0x01, 0x01, 0x06, 0x01, 0x15, 0x01, 0x2d, 0x01, 0x41, - 0x0f, 0x50, 0x01, 0x4a, 0x01, 0x1f, 0x4e, 0x01, 0x01, 0xf7, 0x01, 0x2e, - 0x01, 0xfa, 0x0b, 0x50, 0x01, 0x4f, 0x01, 0xf9, 0x01, 0x1e, 0x01, 0x07, - 0x0e, 0x01, 0x01, 0x02, 0x01, 0x14, 0x01, 0x31, 0x01, 0x48, 0x0b, 0x50, - 0x01, 0x37, 0x01, 0x0c, 0x51, 0x01, 0x01, 0x0d, 0x01, 0x2f, 0x01, 0x45, - 0x01, 0x4f, 0x05, 0x50, 0x01, 0x4f, 0x01, 0x43, 0x01, 0x2e, 0x01, 0x11, - 0x14, 0x01, 0x01, 0x07, 0x01, 0x1f, 0x01, 0x3c, 0x01, 0x4c, 0x04, 0x50, - 0x01, 0x4f, 0x01, 0x46, 0x01, 0x33, 0x01, 0x13, 0x55, 0x01, 0x01, 0x04, - 0x01, 0x12, 0x01, 0x1f, 0x01, 0x26, 0x01, 0x28, 0x01, 0x26, 0x01, 0x1e, - 0x01, 0x10, 0x01, 0x02, 0x19, 0x01, 0x01, 0x09, 0x01, 0x16, 0x01, 0x1e, - 0x01, 0x1f, 0x01, 0x1c, 0x01, 0x11, 0x01, 0x04, 0xff, 0x01, 0xff, 0x01, - 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, - 0xff, 0x01, 0xb3, 0x01 + 0x68, 0x01, 0x00, 0xF0, 0xFF, 0xF0, 0xB7, 0xE4, 0x01, 0x02, 0x01, 0x00, 0xFA, 0xF0, 0x33, 0xE7, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x00, 0xFA, 0xF0, 0x30, 0xE4, 0x08, 0x07, 0x05, 0x06, 0xF4, + 0x38, 0x54, 0xF0, 0x31, 0x58, 0x52, 0x09, 0x38, 0x54, 0xF0, 0x31, 0xC8, 0x01, 0x01, 0x0A, 0x06, 0xF4, 0x38, 0x54, 0xF0, 0x2E, 0x68, 0xA5, 0x03, 0x00, 0x01, 0x68, 0xA5, 0x02, 0xF0, 0x2D, 0xC8, + 0x01, 0x00, 0x0B, 0x06, 0xF7, 0x39, 0xF8, 0xF0, 0x2C, 0x38, 0x53, 0xF3, 0x6E, 0x0C, 0xF0, 0x2D, 0x6E, 0x0D, 0xF4, 0x9E, 0x06, 0x0E, 0xF0, 0x2E, 0x9E, 0x08, 0x0C, 0xF6, 0x9E, 0x06, 0x0D, 0xF0, + 0x2D, 0x9E, 0x00, 0x0E, 0xF7, 0x6E, 0x0A, 0xF0, 0x2C, 0x6E, 0x01, 0xF5, 0x9E, 0x06, 0x0B, 0xF0, 0x2D, 0x9E, 0x00, 0x04, 0xF7, 0x6E, 0x0F, 0xF0, 0x2C, 0x38, 0xA7, 0xF5, 0x39, 0x4E, 0xF0, 0x39, + 0x3B, 0x44, 0xF0, 0x2C, 0x39, 0xF5, 0xF3, 0x38, 0xFA, 0xF0, 0x2B, 0x38, 0xFB, 0xF4, 0xCE, 0x0A, 0x08, 0x00, 0xF0, 0x30, 0x6E, 0x03, 0xF3, 0x38, 0x53, 0xF0, 0x2D, 0x9E, 0x00, 0x07, 0xF4, 0x6E, + 0x04, 0xF0, 0x2F, 0x38, 0x54, 0xC8, 0x01, 0x05, 0x03, 0x00, 0xF0, 0x34, 0x20, 0x54, 0x98, 0xA5, 0x05, 0x07, 0xF0, 0x32, 0x20, 0x54, 0xC8, 0x52, 0x05, 0x10, 0x0B, 0xF0, 0x37, 0x01, 0xF8, 0x98, + 0x50, 0x02, 0x02, 0xF0, 0x28, 0xE4, 0x02, 0x07, 0x04, 0x0F, 0x00, 0x01, 0x9D, 0xCB, 0x10, 0x07, 0xFF, 0xE4, 0x08, 0x0B, 0x04, 0x0F, 0x11, 0x09, 0xE4, 0x06, 0x0F, 0x04, 0x09, 0x3B, 0x50, 0xF0, + 0x0C, 0xC8, 0x01, 0x0B, 0x10, 0x06, 0xF6, 0x99, 0x93, 0x05, 0x04, 0xF9, 0xB1, 0x47, 0x1A, 0x08, 0x0B, 0x10, 0x01, 0x9D, 0xF0, 0x0C, 0x0E, 0xF0, 0x0A, 0x2F, 0x68, 0x07, 0x38, 0x01, 0xF1, 0x68, + 0x35, 0x05, 0xF3, 0x6C, 0x49, 0x02, 0xF6, 0x20, 0x01, 0x68, 0x56, 0x04, 0xF0, 0x05, 0x68, 0x52, 0x03, 0xF9, 0x10, 0x01, 0x88, 0x36, 0x0A, 0x0B, 0x9D, 0x95, 0x0D, 0x0E, 0xF8, 0x38, 0x01, 0xF1, + 0x3B, 0xFF, 0xF0, 0x00, 0x68, 0xF6, 0x08, 0xF4, 0x38, 0x01, 0xF5, 0x98, 0x6F, 0x0C, 0x0F, 0xF0, 0x00, 0x20, 0x01, 0x69, 0x58, 0x0A, 0xFF, 0x68, 0x87, 0x0D, 0xF0, 0x01, 0x38, 0x01, 0xF0, 0x09, + 0x68, 0x55, 0x05, 0xFD, 0x68, 0x89, 0x0D, 0xF0, 0x05, 0x38, 0x01, 0xF0, 0x07, 0x38, 0x55, 0xFA, 0x38, 0x53, 0xF0, 0x25, 0x38, 0x55, 0xFA, 0x68, 0x53, 0x01, 0xF0, 0x28, 0x3C, 0xAF, 0xF9, 0x3A, + 0x76, 0xF5, 0x38, 0x01, 0xF0, 0x1A, 0x6A, 0x53, 0x0C, 0xF7, 0x3C, 0xCB, 0xF1, 0x38, 0x01, 0xF0, 0x1E, 0x3D, 0x03, 0xF6, 0xA3, 0x04, 0x1B, 0x38, 0x01, 0xF0, 0x1A, 0x9E, 0x09, 0x00, 0xF9, 0x23, + 0xC0, 0x38, 0x01, 0xF0, 0x21, 0xA3, 0xBE, 0x1F, 0x98, 0x01, 0x02, 0x06, 0xF0, 0x2A, 0x38, 0x53, 0xF7, 0x9E, 0x00, 0x10, 0xF0, 0x2A, 0x6E, 0x04, 0xF9, 0x39, 0x4E, 0xF0, 0x27, 0xA4, 0xF0, 0x24, + 0x98, 0x01, 0x09, 0x06, 0xF0, 0x29, 0x3B, 0x43, 0xF9, 0x3A, 0x9C, 0xF0, 0x26, 0x38, 0xFA, 0xF8, 0x9E, 0x00, 0x08, 0xF0, 0x29, 0xA4, 0x15, 0x2E, 0xA2, 0x3D, 0x20, 0x38, 0x01, 0xF0, 0x1A, 0x38, + 0xA7, 0xF9, 0x3B, 0x44, 0xF0, 0x27, 0xA4, 0xC5, 0x1F, 0x3A, 0xF1, 0xF0, 0x26, 0x68, 0x01, 0x00, 0xFB, 0x39, 0xA3, 0xF0, 0x25, 0xA4, 0x92, 0x27, 0x68, 0x01, 0x06, 0xF0, 0x26, 0xA4, 0x32, 0x1A, + 0x68, 0x01, 0x06, 0xF0, 0x26, 0x38, 0x54, 0xFA, 0x3B, 0x46, 0xF0, 0x26, 0xA4, 0x61, 0x21, 0x3C, 0x41, 0xF0, 0x26, 0x38, 0x54, 0xF0, 0x8E, 0x6E, 0x09, 0xF0, 0x3B, 0x39, 0xF8, 0xF0, 0x3A, 0x6E, + 0x10, 0xFB, 0x38, 0x54, 0xF0, 0x26, 0x6E, 0x0C, 0xF0, 0x3B, 0x3C, 0x97, 0xFA, 0x3B, 0xF0, 0xF0, 0x27, 0x39, 0xA5, 0xFA, 0x38, 0x54, 0xF0, 0x26, 0x38, 0xFD, 0xFA, 0x6E, 0x07, 0xF0, 0x28, 0x6E, + 0x0B, 0xFA, 0xA2, 0x9A, 0x43, 0x38, 0x01, 0xF0, 0x1A, 0x38, 0xA9, 0xF9, 0xA2, 0x9F, 0x43, 0x38, 0x01, 0xF0, 0x1A, 0x3A, 0xA3, 0xF9, 0x3F, 0xD3, 0x09, 0xF0, 0x28, 0xA3, 0xE7, 0x1C, 0x3F, 0xDA, + 0x08, 0xF0, 0x28, 0xAB, 0xF2, 0x34, 0x0C, 0x3F, 0xE0, 0x07, 0xF0, 0x27, 0xA4, 0xF0, 0x29, 0x6E, 0x0D, 0xF0, 0x2A, 0x38, 0x55, 0xF8, 0x6E, 0x0C, 0xF0, 0x2B, 0x69, 0x54, 0x0C, 0xF7, 0xA4, 0x2A, + 0x35, 0x38, 0x01, 0xF0, 0x17, 0x39, 0xFE, 0xF4, 0x3F, 0x36, 0x08, 0xF0, 0x26, 0x20, 0x01, 0x6A, 0xFD, 0x0C, 0xF5, 0x3A, 0x4E, 0xF0, 0x28, 0x18, 0x01, 0x3C, 0xF8, 0xF2, 0xA2, 0xA7, 0x47, 0x38, + 0x01, 0xF0, 0x20, 0x3C, 0x4F, 0xF2, 0x3F, 0xD0, 0x0B, 0xF0, 0x29, 0x10, 0x01, 0x3C, 0xF7, 0xF3, 0x3A, 0xF7, 0xF0, 0x28, 0x08, 0x01, 0x3D, 0xF3, 0xF4, 0x3C, 0x48, 0xF0, 0x27, 0x10, 0x01, 0xA3, + 0x38, 0x26, 0x3A, 0xA3, 0xF0, 0x2B, 0x6E, 0x00, 0xF6, 0x38, 0xA9, 0xF0, 0x2A, 0x3D, 0x48, 0xF7, 0x38, 0xA9, 0xF0, 0x28, 0x3D, 0x47, 0xF8, 0x38, 0xA9, 0xF0, 0x28, 0x3D, 0xEF, 0xF9, 0x38, 0xA9, + 0xF0, 0x26, 0x3D, 0xEE, 0xF9, 0x3F, 0x90, 0x08, 0xF0, 0x27, 0x6E, 0x03, 0xFC, 0x6E, 0x10, 0xF0, 0x25, 0xA4, 0x4F, 0x54, 0x6B, 0xF6, 0x08, 0xF0, 0x24, 0xAC, 0xE9, 0x20, 0x05, 0x3C, 0x9F, 0xF0, + 0x25, 0xA4, 0xE5, 0x20, 0x10, 0x01, 0x3D, 0x48, 0xF0, 0x20, 0xA5, 0x37, 0x58, 0x69, 0xFC, 0x08, 0xF0, 0x20, 0xAB, 0x92, 0x1B, 0x05, 0x38, 0x01, 0x3F, 0x9A, 0x06, 0xF0, 0x1E, 0x39, 0xF4, 0xFB, + 0x28, 0x01, 0x3A, 0xFA, 0xF0, 0x1C, 0xA7, 0x3C, 0x65, 0x39, 0x53, 0xF0, 0x1A, 0xA7, 0x6A, 0x5D, 0x3D, 0x4A, 0xF0, 0x18, 0xA7, 0x1F, 0x5C, 0x6F, 0x2B, 0x0E, 0x08, 0xF0, 0x18, 0x68, 0x53, 0x05, + 0xF0, 0x09, 0x00, 0x55, 0x38, 0xAA, 0xF9, 0xE8, 0x0F, 0x0E, 0x09, 0x02, 0x02, 0x02, 0x0B, 0x07, 0x38, 0x1B, 0xF9, 0x6A, 0xED, 0x0A, 0xFF, 0x38, 0x01, 0xF5, 0xA3, 0xC8, 0x1B, 0xAA, 0x69, 0x5A, + 0x0F, 0x68, 0x57, 0x0B, 0xF7, 0x68, 0xA6, 0x10, 0xF0, 0x0B, 0x10, 0x01, 0x6A, 0xA8, 0x03, 0xF2, 0xAB, 0x16, 0x56, 0x05, 0x9B, 0xC4, 0x01, 0x0E, 0xF4, 0x6A, 0x45, 0x0C, 0xF0, 0x05, 0x38, 0x01, + 0xF5, 0x88, 0x39, 0x0B, 0x10, 0x98, 0x34, 0x0A, 0x04, 0xF0, 0x00, 0x8F, 0x62, 0x15, 0x03, 0x0E, 0x98, 0x52, 0x0F, 0x04, 0xF0, 0x16, 0x38, 0x01, 0xF0, 0xFF, 0xF0, 0x63, 0xE1, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +// +// CLUT (Color LookUp Table) for white Apple logo. +// + +static UInt8 AppleLogoBlackClut[ 64 ] = +{ + 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x40, 0x40, 0x40, 0x50, 0x50, 0x50, 0x9F, 0x9F, 0x9F, 0xEF, 0xEF, 0xEF, 0xFF, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x10, 0x10, 0x10, 0x70, 0x70, 0x70, 0xCF, 0xCF, + 0xCF, 0x60, 0x60, 0x60, 0xDF, 0xDF, 0xDF, 0x30, 0x30, 0x30, 0x8F, 0x8F, 0x8F, 0xBF, 0xBF, 0xBF, 0xAF, 0xAF, 0xAF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +#else + +// +// LZVN packed data for grey Apple logo. +// + +static UInt8 AppleLogoPacked[ 1392 ] = +{ + 0x68, 0x01, 0x00, 0xF0, 0xFF, 0xF0, 0xB7, 0xE4, 0x01, 0x02, 0x03, 0x00, 0xFA, 0xF0, 0x33, 0xE7, 0x04, 0x05, 0x06, 0x07, 0x07, 0x08, 0x00, 0xFA, 0xF0, 0x30, 0xEA, 0x09, 0x0A, 0x06, 0x0B, 0x0C, + 0x0D, 0x0D, 0x06, 0x0E, 0x00, 0xFA, 0xF0, 0x2F, 0xE9, 0x0F, 0x06, 0x10, 0x0D, 0x11, 0x12, 0x13, 0x13, 0x11, 0x38, 0x54, 0xF0, 0x2F, 0xEC, 0x01, 0x14, 0x0B, 0x0D, 0x15, 0x13, 0x16, 0x17, 0x17, + 0x18, 0x15, 0x19, 0xFA, 0xF0, 0x2D, 0xE8, 0x1A, 0x0D, 0x06, 0x11, 0x13, 0x18, 0x17, 0x17, 0xF4, 0x39, 0xA4, 0xF0, 0x2D, 0xE5, 0x1B, 0x0B, 0x0D, 0x12, 0x16, 0x08, 0x52, 0x00, 0x54, 0x9E, 0x11, + 0x09, 0xF0, 0x2F, 0xC8, 0xA5, 0x1B, 0x0B, 0x1C, 0xF2, 0x00, 0x01, 0xC8, 0xA5, 0x16, 0x1D, 0x1E, 0xF0, 0x2F, 0xE6, 0x00, 0x1F, 0x0B, 0x11, 0x13, 0x17, 0x28, 0x01, 0x69, 0xA3, 0x13, 0xF0, 0x2D, + 0xC8, 0x53, 0x09, 0x18, 0x1C, 0xF6, 0x98, 0xFB, 0x18, 0x15, 0xF0, 0x2F, 0x98, 0xF9, 0x20, 0x06, 0xF3, 0x00, 0xFB, 0x9E, 0x21, 0x22, 0xF0, 0x2D, 0xC8, 0x53, 0x01, 0x10, 0x15, 0xF6, 0xCE, 0x17, + 0x13, 0x23, 0xF0, 0x2F, 0x98, 0xFA, 0x00, 0x24, 0xF5, 0xE4, 0x17, 0x16, 0x25, 0x26, 0xFA, 0xF0, 0x29, 0xCE, 0x01, 0x0C, 0x12, 0xF6, 0xCE, 0x18, 0x12, 0x27, 0xF0, 0x2F, 0x98, 0xA7, 0x00, 0x28, + 0xF6, 0x99, 0x4E, 0x13, 0x04, 0xF0, 0x2E, 0x9E, 0x00, 0x29, 0xF5, 0xCE, 0x16, 0x25, 0x2A, 0xF0, 0x30, 0x9A, 0x48, 0x01, 0x06, 0xF5, 0x9E, 0x2B, 0x2C, 0xF0, 0x2E, 0xE4, 0x00, 0x2D, 0x1C, 0x16, + 0xF8, 0xE4, 0x16, 0x2B, 0x2E, 0x2F, 0xFA, 0xF0, 0x29, 0x04, 0xE2, 0x68, 0xFB, 0x11, 0x98, 0x53, 0x16, 0x30, 0xF0, 0x31, 0x99, 0x4F, 0x00, 0x0E, 0xF1, 0xE4, 0x18, 0x14, 0x31, 0x32, 0x38, 0x53, + 0xF0, 0x2D, 0x90, 0x54, 0x00, 0x19, 0xE6, 0x18, 0x33, 0x1A, 0x34, 0x35, 0x00, 0x38, 0x01, 0xF0, 0x2E, 0xE9, 0x0E, 0x11, 0x13, 0x16, 0x33, 0x36, 0x37, 0x34, 0x2A, 0x38, 0xA5, 0xF0, 0x2E, 0x00, + 0x01, 0xE7, 0x38, 0x39, 0x39, 0x3A, 0x3B, 0x34, 0x26, 0x38, 0x52, 0xF0, 0x20, 0xE4, 0x02, 0x36, 0x05, 0x3C, 0x00, 0x01, 0xE4, 0x3D, 0x36, 0x02, 0x00, 0xF8, 0xC8, 0x50, 0x1E, 0x3E, 0x3E, 0xF4, + 0xE5, 0x09, 0x3F, 0x05, 0x3C, 0x07, 0x10, 0x01, 0xE5, 0x3C, 0x05, 0x30, 0x1F, 0x00, 0xFA, 0xF0, 0x0A, 0xE7, 0x3F, 0x21, 0x07, 0x40, 0x0B, 0x0C, 0x06, 0xF3, 0xE7, 0x0C, 0x0B, 0x40, 0x06, 0x05, + 0x04, 0x00, 0xFA, 0xF3, 0xE4, 0x09, 0x3F, 0x29, 0x41, 0x00, 0x1E, 0x80, 0x01, 0x0D, 0x1C, 0x48, 0x22, 0x0D, 0xE4, 0x13, 0x42, 0x01, 0x00, 0x38, 0x01, 0xF0, 0x04, 0x0F, 0x68, 0x07, 0xE6, 0x06, + 0x1C, 0x11, 0x15, 0x12, 0x13, 0x00, 0x01, 0xE7, 0x12, 0x15, 0x11, 0x0D, 0x0C, 0x0B, 0x06, 0x38, 0x35, 0xF1, 0xC8, 0x1F, 0x02, 0x43, 0x41, 0x00, 0x1E, 0x40, 0x01, 0x16, 0x10, 0x22, 0xE4, 0x06, + 0x10, 0x41, 0x43, 0x38, 0x56, 0xF0, 0x03, 0x5F, 0x68, 0x07, 0x1A, 0x62, 0x8C, 0x16, 0xEA, 0x18, 0x16, 0x13, 0x12, 0x11, 0x0D, 0x10, 0x40, 0x14, 0x3F, 0x08, 0x36, 0xE7, 0x1F, 0x42, 0x13, 0x0B, + 0x0C, 0x1C, 0x15, 0x30, 0x1E, 0x08, 0x01, 0x00, 0x22, 0xE6, 0x15, 0x1C, 0x0C, 0x41, 0x0A, 0x00, 0x38, 0x01, 0xFE, 0x8F, 0x68, 0x07, 0x09, 0x21, 0x38, 0x32, 0xF1, 0x08, 0x01, 0x00, 0x35, 0x80, + 0xE3, 0x11, 0x06, 0xC8, 0x70, 0x44, 0x06, 0x40, 0xF1, 0x38, 0x1F, 0xF5, 0x00, 0x57, 0xE5, 0x13, 0x12, 0x1C, 0x10, 0x14, 0x39, 0x58, 0xFD, 0xE4, 0x1F, 0x13, 0x0C, 0x11, 0x38, 0x33, 0xF8, 0x18, + 0x8C, 0xC8, 0xF3, 0x11, 0x1C, 0x0D, 0x33, 0xA0, 0x38, 0x01, 0xF3, 0xE5, 0x18, 0x13, 0x11, 0x06, 0x0D, 0x38, 0x55, 0xFB, 0xE4, 0x1F, 0x1C, 0x06, 0x15, 0x38, 0x34, 0xFC, 0x10, 0x57, 0x68, 0xF4, + 0x13, 0xF5, 0x38, 0x01, 0xF5, 0xE4, 0x16, 0x12, 0x0D, 0x1C, 0x38, 0x55, 0xF9, 0xE4, 0x1F, 0x1C, 0x0D, 0x12, 0x38, 0x35, 0xF0, 0x00, 0x38, 0x01, 0xF0, 0x06, 0x98, 0x55, 0x18, 0x13, 0xFD, 0xE4, + 0x01, 0x1C, 0x0D, 0x13, 0x38, 0x53, 0xF0, 0x20, 0x10, 0x55, 0x9E, 0x33, 0x09, 0xF9, 0x68, 0x53, 0x33, 0xF0, 0x26, 0x00, 0xFF, 0xC8, 0x53, 0x11, 0x29, 0x31, 0xFA, 0xCE, 0x08, 0x06, 0x12, 0xF0, + 0x2A, 0xE5, 0x17, 0x13, 0x45, 0x46, 0x1E, 0xFA, 0xF3, 0xE4, 0x01, 0x10, 0x11, 0x16, 0xFA, 0xF0, 0x25, 0x6D, 0x03, 0x47, 0xF8, 0xAA, 0x05, 0x1B, 0x48, 0x38, 0x01, 0xF0, 0x1A, 0xE4, 0x13, 0x37, + 0x49, 0x00, 0xFA, 0xF4, 0x68, 0xFA, 0x47, 0xF0, 0x28, 0xB3, 0xBE, 0x1F, 0x13, 0x37, 0x68, 0xFA, 0x4A, 0xF0, 0x27, 0x98, 0x53, 0x16, 0x30, 0xFB, 0xCE, 0x01, 0x06, 0x12, 0xF0, 0x29, 0xCE, 0x18, + 0x2B, 0x32, 0xFC, 0x99, 0x4E, 0x00, 0x19, 0xF0, 0x29, 0xC8, 0x01, 0x13, 0x38, 0x00, 0xFD, 0x99, 0x4E, 0x4B, 0x15, 0xF0, 0x27, 0xB3, 0x57, 0x22, 0x16, 0x45, 0x98, 0xA7, 0x09, 0x06, 0xF0, 0x27, + 0xCE, 0x18, 0x12, 0x4C, 0xFE, 0x99, 0xA2, 0x4D, 0x1C, 0xF0, 0x27, 0xB4, 0x14, 0x2E, 0x16, 0x45, 0x3F, 0x0F, 0x08, 0x38, 0x01, 0xF0, 0x1B, 0xCE, 0x12, 0x37, 0x00, 0xFE, 0x69, 0x4F, 0x2B, 0xF0, + 0x25, 0xB4, 0xC5, 0x1F, 0x18, 0x11, 0x69, 0x4F, 0x48, 0xF0, 0x25, 0xC8, 0x01, 0x13, 0x25, 0x00, 0xFF, 0x39, 0xA3, 0xF0, 0x24, 0xC8, 0x01, 0x13, 0x4E, 0x00, 0xFF, 0x3A, 0x9E, 0xF0, 0x24, 0xAC, + 0x8D, 0x38, 0x12, 0x69, 0xF7, 0x01, 0xF0, 0x25, 0xA4, 0x8F, 0x38, 0x6B, 0xED, 0x23, 0xF0, 0x25, 0xE4, 0x18, 0x11, 0x4F, 0x00, 0x38, 0x01, 0xF8, 0x68, 0x54, 0x4F, 0xF0, 0x7B, 0x6E, 0x3F, 0xF0, + 0x3A, 0x9E, 0x15, 0x0E, 0xFD, 0x6E, 0x3E, 0xF0, 0x26, 0x6A, 0xA0, 0x12, 0xFD, 0x38, 0x54, 0xF0, 0x23, 0xCE, 0x17, 0x13, 0x33, 0xF0, 0x00, 0x6E, 0x1C, 0xF0, 0x26, 0x9E, 0x0D, 0x01, 0xFD, 0x6A, + 0xF4, 0x43, 0xF0, 0x25, 0x9A, 0xF5, 0x16, 0x11, 0xFE, 0x68, 0x54, 0x4A, 0xF0, 0x25, 0xCE, 0x18, 0x15, 0x29, 0xFF, 0x6E, 0x4E, 0xF0, 0x25, 0x00, 0xFD, 0x3B, 0xF2, 0xF9, 0x6F, 0x89, 0x07, 0x50, + 0xF0, 0x26, 0xE4, 0x18, 0x11, 0x51, 0x00, 0x38, 0x01, 0xF7, 0x6D, 0x94, 0x31, 0xF0, 0x26, 0x00, 0xA9, 0x6E, 0x08, 0xF9, 0x99, 0xF9, 0x22, 0x17, 0xF0, 0x27, 0x01, 0x52, 0x9E, 0x10, 0x1F, 0xFB, + 0x39, 0xF9, 0xF0, 0x24, 0x00, 0xA9, 0xCE, 0x11, 0x17, 0x09, 0xFC, 0x68, 0x54, 0x4D, 0xF0, 0x27, 0xA4, 0xF1, 0x29, 0x99, 0x51, 0x52, 0x15, 0xF0, 0x28, 0x03, 0xA1, 0x68, 0x55, 0x06, 0xF8, 0x99, + 0x51, 0x22, 0x4B, 0xF0, 0x28, 0x10, 0x55, 0x69, 0x54, 0x16, 0xF7, 0x68, 0xFD, 0x53, 0xF0, 0x27, 0x08, 0x55, 0xCE, 0x0D, 0x0B, 0x0A, 0xF9, 0x6F, 0x84, 0x09, 0x1F, 0xF0, 0x26, 0x08, 0x01, 0x07, + 0xD0, 0x0C, 0x9D, 0x4B, 0x10, 0x13, 0xF6, 0x98, 0xFD, 0x35, 0x51, 0xF0, 0x2A, 0x08, 0x55, 0xE4, 0x15, 0x06, 0x0B, 0x3D, 0xFA, 0xF1, 0x68, 0xFD, 0x19, 0xF0, 0x29, 0x19, 0x00, 0xA2, 0xC5, 0x3B, + 0x69, 0xFA, 0x2F, 0xF0, 0x28, 0x10, 0x01, 0xB2, 0x29, 0x4B, 0x16, 0x11, 0x98, 0xFD, 0x1E, 0x25, 0xF0, 0x2C, 0x00, 0x54, 0xAA, 0x3A, 0x26, 0x20, 0x68, 0xFD, 0x54, 0xF0, 0x2C, 0xC8, 0x01, 0x12, + 0x55, 0x00, 0xF8, 0x98, 0xA9, 0x26, 0x3C, 0xF0, 0x2C, 0xB3, 0x38, 0x26, 0x16, 0x3C, 0x68, 0xA9, 0x56, 0xF0, 0x2A, 0xC8, 0x01, 0x13, 0x56, 0x00, 0xFA, 0x38, 0xA9, 0xF0, 0x28, 0xB3, 0xF6, 0x31, + 0x16, 0x3C, 0x38, 0xA9, 0xF0, 0x27, 0x38, 0xA7, 0xF7, 0x38, 0xA9, 0xF0, 0x28, 0x38, 0xA7, 0xF9, 0x07, 0x2B, 0x0C, 0x38, 0xA9, 0xF0, 0x24, 0xAC, 0x81, 0x27, 0x13, 0x9E, 0x3E, 0x28, 0xF0, 0x26, + 0xB4, 0xD2, 0x4D, 0x16, 0x25, 0x9B, 0x4D, 0x49, 0x29, 0xF0, 0x24, 0xB4, 0xE7, 0x56, 0x18, 0x14, 0x98, 0xFE, 0x2F, 0x01, 0xF0, 0x24, 0xB4, 0x44, 0x33, 0x13, 0x02, 0x08, 0x01, 0x98, 0xFE, 0x35, + 0x45, 0xF0, 0x22, 0xB3, 0xAD, 0x3D, 0x16, 0x25, 0x30, 0x01, 0x98, 0xFE, 0x57, 0x44, 0xF0, 0x20, 0xB5, 0x37, 0x58, 0x18, 0x14, 0x9F, 0x15, 0x11, 0x2F, 0x2F, 0xF0, 0x20, 0xB6, 0xC0, 0x51, 0x13, + 0x01, 0x99, 0x53, 0x22, 0x37, 0xF0, 0x1E, 0xB6, 0xA2, 0x55, 0x13, 0x3F, 0x99, 0x53, 0x26, 0x30, 0xF0, 0x1C, 0xE4, 0x16, 0x25, 0x2E, 0x00, 0x38, 0x01, 0xF0, 0x03, 0x98, 0x55, 0x32, 0x58, 0xF0, + 0x1A, 0x3F, 0x5A, 0x17, 0xF0, 0x09, 0x98, 0x55, 0x2C, 0x2B, 0xFF, 0x50, 0x01, 0x18, 0x6E, 0x17, 0xFA, 0xB7, 0x1F, 0x5C, 0x18, 0x14, 0x98, 0xAA, 0x2F, 0x2E, 0xFB, 0xEB, 0x18, 0x16, 0x59, 0x1B, + 0x5A, 0x5B, 0x5B, 0x5B, 0x55, 0x1A, 0x59, 0xA3, 0xD2, 0x4E, 0x9F, 0x10, 0x16, 0x18, 0x5C, 0xF0, 0x0E, 0xC9, 0xA9, 0x2F, 0x5D, 0x3F, 0xF8, 0x00, 0x51, 0xED, 0x55, 0x3A, 0x5D, 0x2E, 0x49, 0x3E, + 0x3E, 0x3E, 0x26, 0x2A, 0x5D, 0x5E, 0x55, 0x38, 0x57, 0xF4, 0xCA, 0xED, 0x16, 0x5F, 0x2E, 0xF0, 0x03, 0x38, 0x01, 0xF5, 0xC8, 0xAB, 0x2E, 0x31, 0x60, 0xF3, 0xE6, 0x18, 0x16, 0x33, 0x30, 0x49, + 0x5D, 0x38, 0x8A, 0xF2, 0xE5, 0x26, 0x5D, 0x49, 0x3F, 0x33, 0x20, 0x57, 0xE5, 0x18, 0x16, 0x60, 0x31, 0x34, 0x38, 0xA6, 0xF0, 0x09, 0x10, 0x01, 0xED, 0x35, 0x61, 0x37, 0x36, 0x33, 0x13, 0x16, + 0x13, 0x62, 0x30, 0x31, 0x3B, 0x32, 0x38, 0x88, 0xF6, 0xED, 0x1E, 0x2E, 0x3B, 0x31, 0x3F, 0x59, 0x33, 0x13, 0x13, 0x59, 0x30, 0x31, 0x61, 0x3A, 0x45, 0xF0, 0x03, 0x38, 0x01, 0xF5, 0xE8, 0x26, + 0x34, 0x3B, 0x5E, 0x5E, 0x5E, 0x63, 0x32, 0x38, 0x34, 0xFC, 0xC0, 0x1F, 0x35, 0x2E, 0x5D, 0x98, 0x52, 0x5D, 0x32, 0xF0, 0x16, 0x38, 0x01, 0xF0, 0xFF, 0xF0, 0x0F, 0xE1, 0x00, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +// +// CLUT (Color LookUp Table) for grey Apple logo. +// + +static UInt8 AppleLogoClut[ 304 ] = +{ + 0xBF, 0xBF, 0xBF, 0xB3, 0xB3, 0xB3, 0xA6, 0xA6, 0xA6, 0xB2, 0xB2, 0xB2, 0xA0, 0xA0, 0xA0, 0x83, 0x83, 0x83, 0x67, 0x67, 0x67, 0x61, 0x61, 0x61, 0x90, 0x90, 0x90, 0xB9, 0xB9, 0xB9, 0x8F, 0x8F, + 0x8F, 0x64, 0x64, 0x64, 0x66, 0x66, 0x66, 0x68, 0x68, 0x68, 0x97, 0x97, 0x97, 0x95, 0x95, 0x95, 0x65, 0x65, 0x65, 0x6A, 0x6A, 0x6A, 0x6C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6D, 0x73, 0x73, 0x73, 0x6B, + 0x6B, 0x6B, 0x6E, 0x6E, 0x6E, 0x70, 0x70, 0x70, 0x6F, 0x6F, 0x6F, 0x98, 0x98, 0x98, 0xA1, 0xA1, 0xA1, 0x9B, 0x9B, 0x9B, 0x69, 0x69, 0x69, 0x76, 0x76, 0x76, 0xC2, 0xC2, 0xC2, 0xAD, 0xAD, 0xAD, + 0x8B, 0x8B, 0x8B, 0x7E, 0x7E, 0x7E, 0xC3, 0xC3, 0xC3, 0xAA, 0xAA, 0xAA, 0x87, 0x87, 0x87, 0x85, 0x85, 0x85, 0xC8, 0xC8, 0xC8, 0xBD, 0xBD, 0xBD, 0x8C, 0x8C, 0x8C, 0x72, 0x72, 0x72, 0xCB, 0xCB, + 0xCB, 0x7F, 0x7F, 0x7F, 0xCA, 0xCA, 0xCA, 0xA4, 0xA4, 0xA4, 0xCC, 0xCC, 0xCC, 0xC0, 0xC0, 0xC0, 0x94, 0x94, 0x94, 0xB5, 0xB5, 0xB5, 0xCE, 0xCE, 0xCE, 0x74, 0x74, 0x74, 0xCF, 0xCF, 0xCF, 0xC6, + 0xC6, 0xC6, 0x8E, 0x8E, 0x8E, 0xAE, 0xAE, 0xAE, 0xBE, 0xBE, 0xBE, 0xBB, 0xBB, 0xBB, 0xD0, 0xD0, 0xD0, 0xD5, 0xD5, 0xD5, 0x78, 0x78, 0x78, 0x7D, 0x7D, 0x7D, 0xC5, 0xC5, 0xC5, 0x9A, 0x9A, 0x9A, + 0x63, 0x63, 0x63, 0x62, 0x62, 0x62, 0x89, 0x89, 0x89, 0x84, 0x84, 0x84, 0x79, 0x79, 0x79, 0x93, 0x93, 0x93, 0xCD, 0xCD, 0xCD, 0xA7, 0xA7, 0xA7, 0x7B, 0x7B, 0x7B, 0xC9, 0xC9, 0xC9, 0x82, 0x82, + 0x82, 0x77, 0x77, 0x77, 0xC1, 0xC1, 0xC1, 0xA3, 0xA3, 0xA3, 0x9C, 0x9C, 0x9C, 0xAC, 0xAC, 0xAC, 0xA5, 0xA5, 0xA5, 0x71, 0x71, 0x71, 0xB7, 0xB7, 0xB7, 0x91, 0x91, 0x91, 0xA9, 0xA9, 0xA9, 0xAF, + 0xAF, 0xAF, 0xAB, 0xAB, 0xAB, 0xC7, 0xC7, 0xC7, 0x86, 0x86, 0x86, 0x88, 0x88, 0x88, 0xA8, 0xA8, 0xA8, 0xBC, 0xBC, 0xBC, 0x80, 0x80, 0x80, 0xD1, 0xD1, 0xD1, 0xD7, 0xD7, 0xD7, 0x8D, 0x8D, 0x8D, + 0x7A, 0x7A, 0x7A, 0xD4, 0xD4, 0xD4, 0x81, 0x81, 0x81, 0xD2, 0xD2, 0xD2, 0x00, 0x00, 0x00, 0x00 +}; + +#endif diff --git a/i386/boot2/debug.h b/i386/boot2/debug.h index a015167..0c439ed 100755 --- a/i386/boot2/debug.h +++ b/i386/boot2/debug.h @@ -9,9 +9,9 @@ #define __REVO_CONFIG_SETTINGS #include "../config/settings.h" -#define DEBUG_STATE_ENABLED DEBUG_ACPI || DEBUG_BOOT || DEBUG_CPU || DEBUG_DISK || \ +#define DEBUG_STATE_ENABLED (DEBUG_ACPI || DEBUG_BOOT || DEBUG_CPU || DEBUG_DISK || \ DEBUG_DRIVERS|| DEBUG_EFI || DEBUG_BOOT_GRAPHICS || \ - DEBUG_PLATFORM || DEBUG_SMBIOS + DEBUG_PLATFORM || DEBUG_SMBIOS) #endif // __REVO_CONFIG_SETTINGS @@ -109,5 +109,41 @@ #endif -#endif // __REVO_DEBUG_H +#if (DEBUG_KERNEL_PATCHER & 1) + #define DEBUG_SYMBOL_FOUND(symbol, offset, vmaddr, fileoff, start, end) \ + printf("Symbol %s found!\n", symbol); \ + printf("offset..............: 0x%llx\n", offset); \ + printf("textSegment->vmaddr.: 0x%llx\n", vmaddr); \ + printf("textSegment->fileoff: 0x%llx\n", fileoff); \ + printf("startAddress........: 0x%llx\n", start); \ + printf("endAddress..........: 0x%llx\n", end); \ + sleep(1); +#else + #define DEBUG_SYMBOL_FOUND(symbol, offset, vmaddr, fileoff, start, end) +#endif + +#if (DEBUG_KERNEL_PATCHER & 2) + #define DEBUG_PATCH_STATUS(symbol, address, seconds) \ + printf("Patched %s(@ 0x%x)\n", symbol, address); \ + \ + if (seconds) \ + { \ + sleep(seconds); \ + } +#else + #define DEBUG_PATCH_STATUS(symbol, address, seconds) +#endif +#if (DEBUG_KERNEL_PATCHER & 4) + #define DEBUG_DISABLED_MSR(msr, seconds) \ + printf("Disabling MSR: 0x%x\n", msr); \ + \ + if (seconds) \ + { \ + sleep(seconds); \ + } +#else + #define DEBUG_DISABLED_MSR(msr, seconds) +#endif + +#endif // __REVO_DEBUG_H diff --git a/i386/boot2/drivers.c b/i386/boot2/drivers.c index 620e9a3..c675718 100755 --- a/i386/boot2/drivers.c +++ b/i386/boot2/drivers.c @@ -27,6 +27,10 @@ * Copyright (c) 2000 Apple Computer, Inc. * * DRI: Josh de Cesare + * + * Updates: + * - Use Lower Camel Case for function names (Pike R. Alpha, July 2016) + * */ #include @@ -95,7 +99,7 @@ enum // Private functions. static unsigned long localAdler32(unsigned char * buffer, long length); -#if (MAKE_TARGET_OS == 1) // Snow Leopard only! +#if (MAKE_TARGET_OS == SNOW_LEOPARD) static int loadMultiKext(char *fileSpec); #endif @@ -106,7 +110,7 @@ static long matchLibraries(void); #ifdef NOTDEF static ModulePtr findModule(char *name); - static void ThinFatFile(void **loadAddrP, unsigned long *lengthP); + static void thinFatFile(void **loadAddrP, unsigned long *lengthP); #endif static long parseXML(char *buffer, ModulePtr *module, TagPtr *personalities); @@ -168,19 +172,19 @@ static long initDriverSupport(void) long loadDrivers(char * dirSpec) { - if (initDriverSupport() != STATE_SUCCESS) + if (initDriverSupport() != EFI_SUCCESS) { return -1; } -#if (MAKE_TARGET_OS == 1) // Snow Leopard only! +#if (MAKE_TARGET_OS == SNOW_LEOPARD) bool shouldLoadMKext = ((gBootMode & kBootModeSafe) == 0); _DRIVERS_DEBUG_DUMP("shouldLoadMKext: %s\n", shouldLoadMKext ? "true" : "false"); if (shouldLoadMKext) // Skipped in "Safe Boot" mode. { - if (loadMultiKext(gPlatform.KernelCachePath) == STATE_SUCCESS) + if (loadMultiKext(gPlatform.KernelCachePath) == EFI_SUCCESS) { gKextLoadStatus |= 1; @@ -197,15 +201,39 @@ long loadDrivers(char * dirSpec) { _DRIVERS_DEBUG_DUMP("gKextLoadStatus != 3\n"); +// #if (PATCH_LOAD_EXTRA_KEXTS && ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN)) // El Capitan and Sierra. +#if ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN) // El Capitan and Sierra. + // Yes we do. Start by looking for kexts in: /Extra/Extensions/ + if ((gKextLoadStatus & 2) == 0) + { + _DRIVERS_DEBUG_DUMP("Calling loadKexts(\"/Extra/Extensions\");\n"); + + if (loadKexts("/Extra/Extensions", 0) == EFI_SUCCESS) + { + _DRIVERS_DEBUG_DUMP("loadKexts(2) OK.\n"); + } + + _DRIVERS_DEBUG_DUMP("\n"); + } +#endif + // Now progress to the system kexts. if ((gKextLoadStatus & 1) == 0) { - _DRIVERS_DEBUG_DUMP("\nCalling loadKexts(\"/System/Library/Extensions\");\n"); +#if ((MAKE_TARGET_OS & MAVERICKS) == MAVERICKS) // Mavericks, Yosemite and El Capitan specifics. + _DRIVERS_DEBUG_DUMP("\nCalling loadKexts(\"/Library/Extensions\");\n"); - if (loadKexts("/System/Library/Extensions", 0) == STATE_SUCCESS) + /* For Mavericks we first load the signed kexts. + if (loadKexts("/Library/Extensions", 0) == EFI_SUCCESS) + { + _DRIVERS_DEBUG_DUMP("loadKexts(2) OK.\n"); + } */ +#endif + _DRIVERS_DEBUG_DUMP("\nCalling loadKexts(\"/System/Library/Extensions\");\n"); + // System kexts + if (loadKexts("/System/Library/Extensions", 0) == EFI_SUCCESS) { - _DRIVERS_DEBUG_DUMP("loadKexts(1) OK.\n"); + _DRIVERS_DEBUG_DUMP("loadKexts(3) OK.\n"); } - _DRIVERS_DEBUG_DUMP("\n"); } } @@ -215,11 +243,11 @@ long loadDrivers(char * dirSpec) _DRIVERS_DEBUG_SLEEP(15); - return STATE_SUCCESS; + return EFI_SUCCESS; } -#if (MAKE_TARGET_OS == 1) // Snow Leopard only! +#if (MAKE_TARGET_OS == SNOW_LEOPARD) //============================================================================== // Returns 0 on success, -1 when not found, -2 on load failures and -3 on // verification (signatures, length, adler32) errors. @@ -243,7 +271,7 @@ static int loadMultiKext(char * path) long ret = GetFileInfo(path, fileName, &flags, &time); // Pre-flight checks; Does the file exists, and is it something we can use? - if ((ret == STATE_SUCCESS) && ((flags & kFileTypeMask) == kFileTypeFlat)) + if ((ret == EFI_SUCCESS) && ((flags & kFileTypeMask) == kFileTypeFlat)) { unsigned long driversAddr, driversLength; char segName[32]; @@ -301,11 +329,11 @@ static int loadMultiKext(char * path) // Add the MKext to the memory map. sprintf(segName, "DriversPackage-%lx", driversAddr); - AllocateMemoryRange(segName, driversAddr, driversLength, kBootDriverTypeMKEXT); + AllocateMemoryRange(segName, driversAddr, driversLength); _DRIVERS_DEBUG_DUMP("loadMultiKext(Success : 0) @ 0x%08x\n", driversAddr); - return STATE_SUCCESS; + return EFI_SUCCESS; } _DRIVERS_DEBUG_DUMP("loadMultiKext(File Not Found Error: -1)\n"); @@ -347,11 +375,20 @@ static int loadKexts(char * targetFolder, bool isPluginRun) { sprintf(gPlatform.KextFileName, "%s/%s", targetFolder, dirEntryName); -#if DEBUG_DRIVERS if (strlen(gPlatform.KextFileName) >= MAX_KEXT_PATH_LENGTH) { stop("Error: gPlatform.KextFileName >= %d chars. Change MAX_KEXT_PATH_LENGTH!", MAX_KEXT_PATH_LENGTH); } + +#if DEBUG_DRIVERS + // Show essential kexts. + if (!isPluginRun && ((strcmp(dirEntryName, "AppleEmulator.kext") == 0) || + (strcmp(dirEntryName, "FakeSMC.kext") == 0) || + (strcmp(dirEntryName, "AppleSMC.kext") == 0) || + (strcmp(dirEntryName, "IONVMeFamily.kext") == 0))) + { + printf("loadKext(%s) found\n", dirEntryName); + } #endif // Determine bundle type. isBundleType2 = (GetFileInfo(gPlatform.KextFileName, "Contents", &dirEntryFlags, &dirEntryTime) == 0); @@ -364,12 +401,12 @@ static int loadKexts(char * targetFolder, bool isPluginRun) // Setup plug-ins path. sprintf(gPlatform.KextFileSpec, "%s/%sPlugIns", gPlatform.KextFileName, (isBundleType2) ? "Contents/" : ""); -#if DEBUG_DRIVERS +// #if DEBUG_DRIVERS if (strlen(gPlatform.KextFileSpec) >= MAX_KEXT_PATH_LENGTH) { stop("Error: gPlatform.KextFileSpec >= %d chars. Change MAX_KEXT_PATH_LENGTH!", MAX_KEXT_PATH_LENGTH); } -#endif +// #endif _DRIVERS_DEBUG_DUMP("R"); // Recursive call for kexts in the PlugIns folder. @@ -388,11 +425,11 @@ static int loadKexts(char * targetFolder, bool isPluginRun) static int loadPlist(char * targetFolder, bool isBundleType2) { ModulePtr module; - TagPtr personalities; + TagPtr personalities = NULL; - char * plistBuffer = 0; - char * tmpExecutablePath = 0; - char * tmpBundlePath = 0; + char * plistBuffer = NULL; + char * tmpExecutablePath = NULL; + char * tmpBundlePath = NULL; long plistLength, bundlePathLength, result = -1; @@ -444,16 +481,20 @@ static int loadPlist(char * targetFolder, bool isBundleType2) if (plistLength > 0) { + _DRIVERS_DEBUG_DUMP("p"); + plistLength += 1; plistBuffer = malloc(plistLength); if (plistBuffer) { + _DRIVERS_DEBUG_DUMP("1"); strlcpy(plistBuffer, (char *)kLoadAddr, plistLength); // parseXML returns 0 on success so we check that here. if (parseXML(plistBuffer, &module, &personalities) == 0) { + _DRIVERS_DEBUG_DUMP("2"); // Allocate memory for the driver path and the plist. module->executablePath = tmpExecutablePath; module->bundlePath = tmpBundlePath; @@ -462,6 +503,7 @@ static int loadPlist(char * targetFolder, bool isBundleType2) if (module->plistAddr) { + _DRIVERS_DEBUG_DUMP("3"); // Tell free() to take no action for these two (by passing 0 as argument). tmpBundlePath = tmpExecutablePath = 0; @@ -515,6 +557,7 @@ static int loadPlist(char * targetFolder, bool isBundleType2) // Free on failure only. free(tmpBundlePath); } + // Free on failure only. free(tmpExecutablePath); } @@ -547,12 +590,12 @@ static long loadMatchedModules(void) fileName = prop->string; sprintf(gPlatform.KextFileSpec, "%s%s", module->executablePath, fileName); -#if DEBUG_DRIVERS +// #if DEBUG_DRIVERS if (strlen(gPlatform.KextFileSpec) >= MAX_KEXT_PATH_LENGTH) { stop("Error: gPlatform.KextFileSpec >= %d chars. Change MAX_KEXT_PATH_LENGTH!", MAX_KEXT_PATH_LENGTH); } -#endif +// #endif length = LoadThinFatFile(gPlatform.KextFileSpec, &executableAddr); if (length == 0) @@ -571,7 +614,7 @@ static long loadMatchedModules(void) //driverModuleAddr = (void *)kLoadAddr; //if (length != 0) //{ - // ThinFatFile(&driverModuleAddr, &length); + // thinFatFile(&driverModuleAddr, &length); //} // Make room in the image area. @@ -608,10 +651,11 @@ static long loadMatchedModules(void) strcpy(driver->bundlePathAddr, module->bundlePath); // Add an entry to the memory map. - sprintf(segName, "Driver-%lx", (unsigned long)driver); - AllocateMemoryRange(segName, driverAddr, driverLength, kBootDriverTypeKEXT); + sprintf(segName, "Driver-%lx", (unsigned long)driver); + AllocateMemoryRange(segName, driverAddr, driverLength); } } + module = module->nextModule; } @@ -735,17 +779,21 @@ const char * gRequiredKexts[] = static bool isLoadableInSafeBoot(char * OSBundleRequired) { - if (gBootMode == kBootModeNormal) +// if (gBootMode == kBootModeNormal) + if (gBootMode == kBootModeSafe) { return (strcmp(OSBundleRequired, kOSBundleRequiredSafeBoot) != 0); + // return (strcmp(OSBundleRequired, kOSBundleRequiredRoot) != 0); } - else if (gBootMode == kBootModeSafe) +// else if (gBootMode == kBootModeSafe) + else { if (strcmp(OSBundleRequired, kOSBundleRequiredRoot) == 0 || - strcmp(OSBundleRequired, kOSBundleRequiredLocalRoot) == 0 || + strcmp(OSBundleRequired, kOSBundleRequiredLocalRoot) == 0 / * || strcmp(OSBundleRequired, kOSBundleRequiredNetworkRoot) == 0 || strcmp(OSBundleRequired, kOSBundleRequiredSafeBoot) == 0 || - strcmp(OSBundleRequired, kOSBundleRequiredConsole)) + strcmp(OSBundleRequired, kOSBundleRequiredConsole) * / + ) { return true; @@ -761,7 +809,7 @@ static bool isLoadableInSafeBoot(char * OSBundleRequired) static long parseXML(char * buffer, ModulePtr * module, TagPtr * personalities) { long length, pos = 0; - TagPtr moduleDict, required; + TagPtr moduleDict, required, identifier; ModulePtr tmpModule; while (1) @@ -793,16 +841,68 @@ static long parseXML(char * buffer, ModulePtr * module, TagPtr * personalities) return -1; } + /* #define kAppleKernelExternalComponentKey "AppleKernelExternalComponent" + #define kAppleSecurityExtensionKey "AppleSecurityExtension" + + TagPtr isKernelExternalComponent = XMLGetProperty(moduleDict, kAppleSecurityExtensionKey); + + if (isKernelExternalComponent->type == kTagTypeTrue) + { + XMLFreeTag(moduleDict); + //#if DEBUG_DRIVERS + printf("Dropping AppleKernelExternalComponent(1)\n"); + sleep(1); + //#endif + return -2; + } + + TagPtr isSecurityKext = XMLGetProperty(moduleDict, kAppleSecurityExtensionKey); + + if (isSecurityKext->type == kTagTypeTrue) + { + XMLFreeTag(moduleDict); +//#if DEBUG_DRIVERS + printf("Dropping AppleSecurityExtension\n"); + sleep(1); +//#endif + return -2; + } + + #define COM_APPLE_KEC "com.apple.kec." + + TagPtr bundle_id = XMLGetProperty(moduleDict, kPropCFBundleIdentifier); + + if (strncmp(bundle_id, COM_APPLE_KEC, strlen(COM_APPLE_KEC)) == 0)) + { +//#if DEBUG_DRIVERS + printf("Dropping AppleKernelExternalComponent(2)\n"); + sleep(1); +//#endif + return -2; + } */ + required = XMLGetProperty(moduleDict, kPropOSBundleRequired); if ((required == 0) || (required->type != kTagTypeString) || !strcmp(required->string, "Safe Boot")) + // if ((required == 0) || (required->type != kTagTypeString) || !strcmp(required->string, "Root")) // if ((required == 0) || (required->type != kTagTypeString) || !isLoadableInSafeBoot(required->string)) + // if ( (required != NULL) && (required->type == kTagTypeString) && !strcmp(required->string, "Safe Boot")) { - XMLFreeTag(moduleDict); - return -2; + identifier = XMLGetProperty(moduleDict, "CFBundleIdentifier"); + + if (strcmp(identifier->string, "com.apple.driver.AppleSMC") == 0) + { + _DRIVERS_DEBUG_DUMP("Forced load of: AppleSMC.kext\n"); + } + else + { + XMLFreeTag(moduleDict); + return -2; + } } - tmpModule = (ModulePtr)malloc(sizeof(Module)); + // tmpModule = (ModulePtr)malloc(sizeof(Module)); + tmpModule = malloc(sizeof(Module)); if (tmpModule == 0) { @@ -828,16 +928,14 @@ static long parseXML(char * buffer, ModulePtr * module, TagPtr * personalities) //============================================================================== -long decodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize) +long decodeKernel(void *fileLoadBuffer, entry_t *rentry, char **raddr, int *rsize) { // return DecodeMachO(binary, rentry, raddr, rsize); - - void *buffer; long ret; unsigned long len; - u_int32_t uncompressedSize, size; - compressed_kernel_header * kernel_header = (compressed_kernel_header *) binary; + u_int32_t compressedSize, uncompressedSize, size = 0; + compressed_kernel_header * kernel_header = (compressed_kernel_header *) fileLoadBuffer; #if DEBUG_DRIVERS printf("Kernel header data.\n"); @@ -850,12 +948,16 @@ long decodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize) printf("platformName : %s\n", kernel_header->platformName); printf("rootPath : %s\n", kernel_header->rootPath); printf("Sleeping for 5 seconds...\n"); - sleep(5); #endif if (kernel_header->signature == OSSwapBigToHostConstInt32('comp')) { - if (kernel_header->compressType != OSSwapBigToHostConstInt32('lzss')) + if (kernel_header->compressType != OSSwapBigToHostConstInt32('lzss') +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite and El Capitan + && kernel_header->compressType != OSSwapBigToHostConstInt32('lzvn') +#endif + ) + { error("kernel compression is bad\n"); return -1; @@ -872,40 +974,59 @@ long decodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize) return -1; } #endif - + compressedSize = OSSwapBigToHostInt32(kernel_header->compressedSize); uncompressedSize = OSSwapBigToHostInt32(kernel_header->uncompressedSize); - binary = buffer = malloc(uncompressedSize); + fileLoadBuffer = malloc(uncompressedSize); - size = decompressLZSS((u_int8_t *) binary, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressedSize)); +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite and El Capitan + if (kernel_header->compressType == OSSwapBigToHostConstInt32('lzvn')) + { + void *tmpBuffer = malloc(uncompressedSize); + size = lzvn_decode(tmpBuffer, uncompressedSize, &kernel_header->data[0], compressedSize); + memcpy(fileLoadBuffer, tmpBuffer, uncompressedSize); + free(tmpBuffer); + } else +#endif + if (kernel_header->compressType == OSSwapBigToHostConstInt32('lzss')) + { + size = decompressLZSS((u_int8_t *) fileLoadBuffer, &kernel_header->data[0], compressedSize); + } if (uncompressedSize != size) { - error("Size mismatch from lzss: 0x08%x\n", size); + error("Size mismatch, is 0x%x but 0x%x is expected!\n", size, uncompressedSize); return -1; } - if (OSSwapBigToHostInt32(kernel_header->adler32) != localAdler32(binary, uncompressedSize)) + if (OSSwapBigToHostInt32(kernel_header->adler32) != localAdler32(fileLoadBuffer, uncompressedSize)) { - printf("Adler mismatch\n"); + printf("Adler mismatch, is 0x%x but 0x%x is expected\n", OSSwapBigToHostInt32(kernel_header->adler32), localAdler32(fileLoadBuffer, uncompressedSize)); return -1; } } - ret = ThinFatFile(&binary, &len); + ret = thinFatFile(&fileLoadBuffer, &len); - if (ret == 0 && len == 0 && gArchCPUType == CPU_TYPE_X86_64) + if (ret == 0 && len == 0 && gPlatform.ArchCPUType == CPU_TYPE_X86_64) { - gArchCPUType = CPU_TYPE_I386; - ret = ThinFatFile(&binary, &len); + gPlatform.ArchCPUType = CPU_TYPE_I386; + ret = thinFatFile(&fileLoadBuffer, &len); } - ret = DecodeMachO(binary, rentry, raddr, rsize); + if (ret && len) + { + ret = decodeMachO(fileLoadBuffer, rentry, raddr, rsize); + } - if (ret < 0 && gArchCPUType == CPU_TYPE_X86_64) + if (ret < 0 && gPlatform.ArchCPUType == CPU_TYPE_X86_64) { - gArchCPUType = CPU_TYPE_I386; - ret = DecodeMachO(binary, rentry, raddr, rsize); + gPlatform.ArchCPUType = CPU_TYPE_I386; + ret = decodeMachO(fileLoadBuffer, rentry, raddr, rsize); } +#if DEBUG_DRIVERS + printf("decodeKernel(ret = %d)\n", ret); + sleep(5); +#endif return ret; } diff --git a/i386/boot2/graphics.c b/i386/boot2/graphics.c index d07f353..3277b01 100755 --- a/i386/boot2/graphics.c +++ b/i386/boot2/graphics.c @@ -28,7 +28,6 @@ #include "boot.h" #include "vbe.h" - #include "bootstruct.h" @@ -36,7 +35,7 @@ bool inGraphicsMode(void) { - return (bootArgs->Video.v_display == GRAPHICS_MODE); + return (bootArgs->Video_V1.v_display == GRAPHICS_MODE); } @@ -65,7 +64,7 @@ static unsigned short getVESAModeWithProperties(unsigned short width, unsigned s strcpy((char*)&vbeInfo, "VBE2"); status = getVBEInfo(&vbeInfo); - if (status != STATE_SUCCESS) + if (status != EFI_SUCCESS) { return modeEndOfList; } @@ -86,7 +85,7 @@ static unsigned short getVESAModeWithProperties(unsigned short width, unsigned s bzero(&modeInfo, sizeof(modeInfo)); status = getVBEModeInfo(*modePtr, &modeInfo); - if (status != STATE_SUCCESS) + if (status != EFI_SUCCESS) { continue; } @@ -94,7 +93,7 @@ static unsigned short getVESAModeWithProperties(unsigned short width, unsigned s #if DEBUG printf("Mode %x: %dx%dx%d mm:%d attr:%x\n", * modePtr, modeInfo.XResolution, modeInfo.YResolution, modeInfo.BitsPerPixel, modeInfo.MemoryModel, modeInfo.ModeAttributes); - sleep(1); + sleep(10); #endif // Filter out unwanted modes based on mode attributes. @@ -187,7 +186,7 @@ static int setVESATextMode(unsigned short cols, unsigned short rows, unsigned ch getc(); #endif - if ((mode == modeEndOfList) || (setVBEMode(mode, NULL) != STATE_SUCCESS)) + if ((mode == modeEndOfList) || (setVBEMode(mode, NULL) != EFI_SUCCESS)) { video_mode(2); // VGA BIOS, 80x25 text mode. minfo.XResolution = 80; @@ -196,27 +195,27 @@ static int setVESATextMode(unsigned short cols, unsigned short rows, unsigned ch // Update bootArgs with the data provided by the selected VESA mode. - bootArgs->Video.v_display = VGA_TEXT_MODE; - bootArgs->Video.v_width = minfo.XResolution; - bootArgs->Video.v_height = minfo.YResolution; - bootArgs->Video.v_depth = 8; - bootArgs->Video.v_baseAddr = 0xb8000; - bootArgs->Video.v_rowBytes = 0x8000; + bootArgs->Video_V1.v_display = VGA_TEXT_MODE; + bootArgs->Video_V1.v_width = minfo.XResolution; + bootArgs->Video_V1.v_height = minfo.YResolution; + bootArgs->Video_V1.v_depth = 8; + bootArgs->Video_V1.v_baseAddr = 0xb8000; + bootArgs->Video_V1.v_rowBytes = 0x8000; - return STATE_SUCCESS; // always return success + return EFI_SUCCESS; // always return success } //============================================================================== -static int setVESAGraphicsMode(unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate) +long setVESAGraphicsMode(unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate) { VBEModeInfoBlock minfo; - unsigned short mode = 280; // Default to 1024 * 768 * 32 (1920 * 1200 * 32 would be 330) - unsigned short vesaVersion; + unsigned short mode = 280; // Defaults to 1024 * 768 * 32 (1920 * 1200 * 32 would be 330) + unsigned short vesaVersion; - int status = STATE_FUNCTION_NOT_SUPPORTED; + long status = (long)EFI_UNSUPPORTED; do { @@ -224,9 +223,9 @@ static int setVESAGraphicsMode(unsigned short width, unsigned short height, unsi maColorModeBit | maModeIsSupportedBit | maGraphicsModeBit | maLinearFrameBufferAvailBit, 0, &minfo, &vesaVersion); #if DEBUG - printf("\nsetVESAGraphicsMode: %d\n%d\n%d\n%d\n%d\n%x\n%x\nPress a key...", mode, minfo.XResolution, - minfo.YResolution, minfo.BitsPerPixel, minfo.BytesPerScanline, minfo.PhysBasePtr_low, minfo.PhysBasePtr_high); - getc(); + printf("\nsetVESAGraphicsMode: %d\n%d\n%d\n%d\n%d\n%x\n%x\nSleeping for 25 seconds...", mode, minfo.XResolution, + minfo.YResolution, minfo.BitsPerPixel, minfo.BytesPerScanline, minfo.PhysBasePtr_low, minfo.PhysBasePtr_high, VBEMakeUInt32(minfo.PhysBasePtr)); + sleep(25); #endif if (mode == modeEndOfList) @@ -236,10 +235,16 @@ static int setVESAGraphicsMode(unsigned short width, unsigned short height, unsi status = setVBEMode(mode | kLinearFrameBufferBit, NULL); - if (status != STATE_SUCCESS) + if (status != EFI_SUCCESS) { break; } +#if DEBUG_BOOT_GRAPHICS + else + { + printf ("VESA Graphics mode: %d\n", mode); + } +#endif // Is this required for buggy Video BIOS implementations? If so for which adapter? @@ -249,13 +254,12 @@ static int setVESAGraphicsMode(unsigned short width, unsigned short height, unsi } // Update bootArgs with the data provided by the selected VESA mode. - bootArgs->Video.v_display = GRAPHICS_MODE; - bootArgs->Video.v_width = minfo.XResolution; // 1920 or 1600 - bootArgs->Video.v_height = minfo.YResolution; // 1200 or 900 - bootArgs->Video.v_depth = minfo.BitsPerPixel; // 32 - bootArgs->Video.v_rowBytes = minfo.BytesPerScanline; // 7680 or 6400 - - bootArgs->Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr); + bootArgs->Video_V1.v_display = GRAPHICS_MODE; + bootArgs->Video_V1.v_width = minfo.XResolution; /* Examples: 1920, 1600, 1680 */ + bootArgs->Video_V1.v_height = minfo.YResolution; /* Examples: 1200, 1050 900 */ + bootArgs->Video_V1.v_depth = minfo.BitsPerPixel; /* Examples: 8, 30, 32, 64 */ + bootArgs->Video_V1.v_rowBytes = minfo.BytesPerScanline; /* Examples: 7680, 6720, 6400 */ + bootArgs->Video_V1.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr); } while (0); @@ -305,34 +309,33 @@ static int getNumberArrayFromProperty(const char * propKey, unsigned long numbe //============================================================================== -int initGraphicsMode() +long initGraphicsMode() { unsigned long params[4]; - int count = getNumberArrayFromProperty(kGraphicsModeKey, params, 4); - -#if DEBUG - printf("\nwidth: %d height: %d depth: %d\n", params[0], params[1], params[2]); -#endif + params[2] = 32; // Default depth + params[3] = 0; // Do we have a "Graphics Mode" property in com.apple.Boot.plist? - if (count < 3) + if (getNumberArrayFromProperty(kGraphicsModeKey, params, 4) < 3) { #if USE_STATIC_DISPLAY_RESOLUTION params[0] = DEFAULT_SCREEN_WIDTH; params[1] = DEFAULT_SCREEN_HEIGHT; #else - unsigned long resolutionCombo = getResolutionFromEDID(); - printf("EDID width :%l\n", resolutionCombo); - /* params[0] = */ printf("EDID width :%l\n", (resolutionCombo << 16)); - /* params[1] = */ printf("EDID height:%l\n", (resolutionCombo & 0xFFF)); - // sleep(15); + UInt32 resolutionCombo = getResolutionFromEDID(); + #if DEBUG_BOOT_GRAPHICS + printf("EDID resolution (0x%04x)\n", resolutionCombo); + #endif + params[0] = (resolutionCombo >> 16); + params[1] = (resolutionCombo & 0xFFFF); + #if DEBUG_BOOT_GRAPHICS + printf("Width: %d, Height: %d, Depth: %d\n", params[0], params[1], params[2]); + sleep(10); + #endif #endif } - params[2] = 32; // Don't bother. Use the de facto standard. - params[3] = 0; - return setVESAGraphicsMode(params[0], params[1], params[2], 0); } @@ -341,24 +344,24 @@ int initGraphicsMode() void setVideoMode(int mode) { - int status = STATE_SUCCESS; + long status = EFI_SUCCESS; unsigned long params[4]; if (mode == GRAPHICS_MODE) { - if ((status = initGraphicsMode()) == STATE_SUCCESS) + if ((status = initGraphicsMode()) == EFI_SUCCESS) { - bootArgs->Video.v_display = (gVerboseMode) ? FB_TEXT_MODE : GRAPHICS_MODE; + bootArgs->Video_V1.v_display = (gVerboseMode) ? /* 2 */ FB_TEXT_MODE : /* 1 */ GRAPHICS_MODE; } } - if (mode == VGA_TEXT_MODE || status != STATE_SUCCESS) + if (mode == VGA_TEXT_MODE || status != EFI_SUCCESS) { params[0] = 80; // Default text mode is 80x25. params[1] = 25; setVESATextMode(params[0], params[1], 4); - bootArgs->Video.v_display = VGA_TEXT_MODE; + bootArgs->Video_V1.v_display = VGA_TEXT_MODE; } } diff --git a/i386/boot2/lzvn.c b/i386/boot2/lzvn.c new file mode 100644 index 0000000..2560c3b --- /dev/null +++ b/i386/boot2/lzvn.c @@ -0,0 +1,556 @@ +/* + * Copyright (c) 2014 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Portions Copyright (c) 2003 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 2.0 (the "License"). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. + * + * The Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + * + * The lzvn_decode function was first located and disassembled by Pike R. + * Alpha and later converted to flat C code by someone using the handle + * 'MinusZwei' over at insanelymac.com. This after Andy Vandijcke published + * a working version at the for mentioned website. + * + * Thanks to Andy Vandijcke and 'MinusZwei' for their work, but I (Pike + * R. Alpha) will not claim ownership of this work, other than the work + * that I have done, for educational purpose, to improve the readability + * so that it is understandable for everyone. + * + */ + +#include +#include + +#include + +#define DEBUG_STATE_ENABLED 0 + + +#if DEBUG_STATE_ENABLED + #define _LZVN_DEBUG_DUMP(x...) printf(x) +#else + #define _LZVN_DEBUG_DUMP(x...) +#endif + +#define LZVN_0 0 +#define LZVN_1 1 +#define LZVN_2 2 +#define LZVN_3 3 +#define LZVN_4 4 +#define LZVN_5 5 +#define LZVN_6 6 +#define LZVN_7 7 +#define LZVN_8 8 +#define LZVN_9 9 +#define LZVN_10 10 +#define LZVN_11 11 + +#define CASE_TABLE 127 + +//============================================================================== + +size_t lzvn_decode(void * decompressedData, size_t decompressedSize, void * compressedData, size_t compressedSize) +{ + const uint64_t decompBuffer = (const uint64_t)decompressedData; + + size_t length = 0; // xor %rax,%rax + + uint64_t compBuffer = (uint64_t)compressedData; + + uint64_t compBufferPointer = 0; // use p(ointer)? + uint64_t caseTableIndex = 0; + uint64_t r10 = 0; + uint64_t currentLength = 0; // xor %r12,%r12 + uint64_t r12 = 0; + + uint64_t address = 0; // ((uint64_t)compBuffer + compBufferPointer) + unsigned char byte_data = 0; + + uint8_t jmpTo = CASE_TABLE; + + /* + * This jump table was developed by someone using the handle 'MinusZwei' + * over at insanelymac.com + */ + static short caseTable[ 256 ] = + { + 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 4, 3, + 1, 1, 1, 1, 1, 1, 4, 3, 1, 1, 1, 1, 1, 1, 5, 3, + 1, 1, 1, 1, 1, 1, 5, 3, 1, 1, 1, 1, 1, 1, 5, 3, + 1, 1, 1, 1, 1, 1, 5, 3, 1, 1, 1, 1, 1, 1, 5, 3, + 1, 1, 1, 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 0, 3, + 1, 1, 1, 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 0, 3, + 1, 1, 1, 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 0, 3, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 1, 1, 1, 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 0, 3, + 1, 1, 1, 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 0, 3, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 1, 1, 1, 1, 1, 1, 0, 3, 1, 1, 1, 1, 1, 1, 0, 3, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 + }; + + decompressedSize -= 8; // sub $0x8,%rsi + + if (decompressedSize < 8) // jb Llzvn_exit + { + return 0; + } + + compressedSize = (compBuffer + compressedSize - 8); // lea -0x8(%rdx,%rcx,1),%rcx + + if (compBuffer > compressedSize) // cmp %rcx,%rdx + { + return 0; // ja Llzvn_exit + } + + compBufferPointer = *(uint64_t *)compBuffer; // mov (%rdx),%r8 + caseTableIndex = (compBufferPointer & 255); // movzbq (%rdx),%r9 + + do // jmpq *(%rbx,%r9,8) + { + switch (jmpTo) // our jump table + { + case CASE_TABLE: /******************************************************/ + + switch (caseTable[(uint8_t)caseTableIndex]) + { + case 0: _LZVN_DEBUG_DUMP("caseTable[0]\n"); + + caseTableIndex >>= 6; // shr $0x6,%r9 + compBuffer = (compBuffer + caseTableIndex + 1); // lea 0x1(%rdx,%r9,1),%rdx + + if (compBuffer > compressedSize) // cmp %rcx,%rdx + { + return 0; // ja Llzvn_exit + } + + r10 = 56; // mov $0x38,%r10 + r10 &= compBufferPointer; // and %r8,%r10 + compBufferPointer >>= 8; // shr $0x8,%r8 + r10 >>= 3; // shr $0x3,%r10 + r10 += 3; // add $0x3,%r10 + + jmpTo = LZVN_10; // jmp Llzvn_l10 + break; + + case 1: _LZVN_DEBUG_DUMP("caseTable[1]\n"); + + caseTableIndex >>= 6; // shr $0x6,%r9 + compBuffer = (compBuffer + caseTableIndex + 2); // lea 0x2(%rdx,%r9,1),%rdx + + if (compBuffer > compressedSize) // cmp %rcx,%rdx + { + return 0; // ja Llzvn_exit + } + + r12 = compBufferPointer; // mov %r8,%r12 + r12 = OSSwapInt64(r12); // bswap %r12 + r10 = r12; // mov %r12,%r10 + r12 <<= 5; // shl $0x5,%r12 + r10 <<= 2; // shl $0x2,%r10 + r12 >>= 53; // shr $0x35,%r12 + r10 >>= 61; // shr $0x3d,%r10 + compBufferPointer >>= 16; // shr $0x10,%r8 + r10 += 3; // add $0x3,%r10 + + jmpTo = LZVN_10; // jmp Llzvn_l10 + break; + + case 2: _LZVN_DEBUG_DUMP("caseTable[2]\n"); + + return length; + + case 3: _LZVN_DEBUG_DUMP("caseTable[3]\n"); + + caseTableIndex >>= 6; // shr $0x6,%r9 + compBuffer = (compBuffer + caseTableIndex + 3); // lea 0x3(%rdx,%r9,1),%rdx + + if (compBuffer > compressedSize) // cmp %rcx,%rdx + { + return 0; // ja Llzvn_exit + } + + r10 = 56; // mov $0x38,%r10 + r12 = 65535; // mov $0xffff,%r12 + r10 &= compBufferPointer; // and %r8,%r10 + compBufferPointer >>= 8; // shr $0x8,%r8 + r10 >>= 3; // shr $0x3,%r10 + r12 &= compBufferPointer; // and %r8,%r12 + compBufferPointer >>= 16; // shr $0x10,%r8 + r10 += 3; // add $0x3,%r10 + + jmpTo = LZVN_10; // jmp Llzvn_l10 + break; + + case 4: _LZVN_DEBUG_DUMP("caseTable[4]\n"); + + compBuffer += 1; // add $0x1,%rdx + + if (compBuffer > compressedSize) // cmp %rcx,%rdx + { + return 0; // ja Llzvn_exit + } + + compBufferPointer = *(uint64_t *)compBuffer; // mov (%rdx),%r8 + caseTableIndex = (compBufferPointer & 255); // movzbq (%rdx),%r9 + + jmpTo = CASE_TABLE; // continue; + break; // jmpq *(%rbx,%r9,8) + + case 5: _LZVN_DEBUG_DUMP("caseTable[5]\n"); + + return 0; // Llzvn_table5; + + case 6: _LZVN_DEBUG_DUMP("caseTable[6]\n"); + + caseTableIndex >>= 3; // shr $0x3,%r9 + caseTableIndex &= 3; // and $0x3,%r9 + compBuffer = (compBuffer + caseTableIndex + 3); // lea 0x3(%rdx,%r9,1),%rdx + + if (compBuffer > compressedSize) // cmp %rcx,%rdx + { + return 0; // ja Llzvn_exit + } + + r10 = compBufferPointer; // mov %r8,%r10 + r10 &= 775; // and $0x307,%r10 + compBufferPointer >>= 10; // shr $0xa,%r8 + r12 = (r10 & 255); // movzbq %r10b,%r12 + r10 >>= 8; // shr $0x8,%r10 + r12 <<= 2; // shl $0x2,%r12 + r10 |= r12; // or %r12,%r10 + r12 = 16383; // mov $0x3fff,%r12 + r10 += 3; // add $0x3,%r10 + r12 &= compBufferPointer; // and %r8,%r12 + compBufferPointer >>= 14; // shr $0xe,%r8 + + jmpTo = LZVN_10; // jmp Llzvn_l10 + break; + + case 7: _LZVN_DEBUG_DUMP("caseTable[7]\n"); + + compBufferPointer >>= 8; // shr $0x8,%r8 + compBufferPointer &= 255; // and $0xff,%r8 + compBufferPointer += 16; // add $0x10,%r8 + compBuffer = (compBuffer + compBufferPointer + 2); // lea 0x2(%rdx,%r8,1),%rdx + + jmpTo = LZVN_0; // jmp Llzvn_l0 + break; + + case 8: _LZVN_DEBUG_DUMP("caseTable[8]\n"); + + compBufferPointer &= 15; // and $0xf,%r8 + compBuffer = (compBuffer + compBufferPointer + 1); // lea 0x1(%rdx,%r8,1),%rdx + + jmpTo = LZVN_0; // jmp Llzvn_l0 + break; + + case 9: _LZVN_DEBUG_DUMP("caseTable[9]\n"); + + compBuffer += 2; // add $0x2,%rdx + + if (compBuffer > compressedSize) // cmp %rcx,%rdx + { + return 0; // ja Llzvn_exit + } + + r10 = compBufferPointer; // mov %r8,%r10 + r10 >>= 8; // shr $0x8,%r10 + r10 &= 255; // and $0xff,%r10 + r10 += 16; // add $0x10,%r10 + + jmpTo = LZVN_11; // jmp Llzvn_l11 + break; + + case 10:_LZVN_DEBUG_DUMP("caseTable[10]\n"); + + compBuffer += 1; // add $0x1,%rdx + + if (compBuffer > compressedSize) // cmp %rcx,%rdx + { + return 0; // ja Llzvn_exit + } + + r10 = compBufferPointer; // mov %r8,%r10 + r10 &= 15; // and $0xf,%r10 + + jmpTo = LZVN_11; // jmp Llzvn_l11 + break; +#if DEBUG_STATE_ENABLED + default:printf("default() caseTableIndex[%d]\n", (uint8_t)caseTableIndex); +#endif + } // switch (caseTable[caseTableIndex]) + + break; + + case LZVN_0: /**********************************************************/ + + _LZVN_DEBUG_DUMP("jmpTable(0)\n"); + + if (compBuffer > compressedSize) // cmp %rcx,%rdx + { + return 0; // ja Llzvn_exit + } + + currentLength = (length + compBufferPointer); // lea (%rax,%r8,1),%r11 + compBufferPointer = -compBufferPointer; // neg %r8 + + if (currentLength > decompressedSize) // cmp %rsi,%r11 + { + jmpTo = LZVN_2; // ja Llzvn_l2 + break; + } + + currentLength = (decompBuffer + currentLength); // lea (%rdi,%r11,1),%r11 + + case LZVN_1: /**********************************************************/ + + do // Llzvn_l1: + { + _LZVN_DEBUG_DUMP("jmpTable(1)\n"); + +// address = (compBuffer + compBufferPointer); // mov (%rdx,%r8,1),%r9 +// caseTableIndex = *(uint64_t *)address; + caseTableIndex = *(uint64_t *)((uint64_t)compBuffer + compBufferPointer); + +// address = (currentLength + compBufferPointer); // mov %r9,(%r11,%r8,1) +// *(uint64_t *)address = caseTableIndex; + *(uint64_t *)((uint64_t)currentLength + compBufferPointer) = caseTableIndex; + + compBufferPointer += 8; // add $0x8,%r8 + + } while ((UINT64_MAX - (compBufferPointer - 8)) >= 8); // jae Llzvn_l1 + + length = currentLength; // mov %r11,%rax + length -= decompBuffer; // sub %rdi,%rax + + compBufferPointer = *(uint64_t *)compBuffer; // mov (%rdx),%r8 + caseTableIndex = (compBufferPointer & 255); // movzbq (%rdx),%r9 + + jmpTo = CASE_TABLE; + break; // jmpq *(%rbx,%r9,8) + + case LZVN_2: /**********************************************************/ + + _LZVN_DEBUG_DUMP("jmpTable(2)\n"); + + currentLength = (decompressedSize + 8); // lea 0x8(%rsi),%r11 + + case LZVN_3: /***********************************************************/ + + do // Llzvn_l3: + { + _LZVN_DEBUG_DUMP("jmpTable(3)\n"); + + address = (compBuffer + compBufferPointer); // movzbq (%rdx,%r8,1),%r9 + caseTableIndex = *((uint64_t *)address); + caseTableIndex &= 255; + + address = (decompBuffer + length); // mov %r9b,(%rdi,%rax,1) + byte_data = (unsigned char)caseTableIndex; + memcpy((void *)address, &byte_data, sizeof(byte_data)); + + length += 1; // add $0x1,%rax + + if (currentLength == length) // cmp %rax,%r11 + { + return length; // je Llzvn_exit2 + } + + compBufferPointer += 1; // add $0x1,%r8 + + } while ((int64_t)compBufferPointer != 0); // jne Llzvn_l3 + + compBufferPointer = *(uint64_t *)compBuffer; // mov (%rdx),%r8 + caseTableIndex = (compBufferPointer & 255); // movzbq (%rdx),%r9 + + jmpTo = CASE_TABLE; + break; // jmpq *(%rbx,%r9,8) + + case LZVN_4: /**********************************************************/ + + _LZVN_DEBUG_DUMP("jmpTable(4)\n"); + + currentLength = (decompressedSize + 8); // lea 0x8(%rsi),%r11 + + case LZVN_9: /**********************************************************/ + + do // Llzvn_l9: + { + _LZVN_DEBUG_DUMP("jmpTable(9)\n"); + + address = (decompBuffer + compBufferPointer); // movzbq (%rdi,%r8,1),%r9 + byte_data = *((unsigned char *)address); + caseTableIndex = byte_data; + caseTableIndex &= 255; + compBufferPointer += 1; // add $0x1,%r8 + + address = (decompBuffer + length); // mov %r9,(%rdi,%rax,1) + byte_data = (unsigned char)caseTableIndex; + memcpy((void *)address, &byte_data, sizeof(byte_data)); + + length += 1; // add $0x1,%rax + + if (length == currentLength) // cmp %rax,%r11 + { + return length; // je Llzvn_exit2 + } + + r10 -= 1; // sub $0x1,%r10 + + } while (r10); // jne Llzvn_l9 + + compBufferPointer = *(uint64_t *)compBuffer; // mov (%rdx),%r8 + caseTableIndex = (compBufferPointer & 255); // movzbq (%rdx),%r9 + + jmpTo = CASE_TABLE; + break; // jmpq *(%rbx,%r9,8) + + case LZVN_5: /**********************************************************/ + + do + { + _LZVN_DEBUG_DUMP("jmpTable(5)\n"); + + address = (decompBuffer + compBufferPointer); // mov (%rdi,%r8,1),%r9 + caseTableIndex = *((uint64_t *)address); + compBufferPointer += 8; // add $0x8,%r8 + + address = (decompBuffer + length); // mov %r9,(%rdi,%rax,1) + memcpy((void *)address, &caseTableIndex, sizeof(caseTableIndex)); + + length += 8; // add $0x8,%rax + r10 -= 8; // sub $0x8,%r10 + + } while ((r10 + 8) > 8); // ja Llzvn_l5 + + length += r10; // add %r10,%rax + compBufferPointer = *(uint64_t *)compBuffer; // mov (%rdx),%r8 + caseTableIndex = (compBufferPointer & 255); // movzbq (%rdx),%r9 + + jmpTo = CASE_TABLE; + break; // jmpq *(%rbx,%r9,8) + + case LZVN_10: /*********************************************************/ + + _LZVN_DEBUG_DUMP("jmpTable(10)\n"); + + currentLength = (length + caseTableIndex); // lea (%rax,%r9,1),%r11 + currentLength += r10; // add %r10,%r11 + + if (currentLength < decompressedSize) // cmp %rsi,%r11 (block_end: jae Llzvn_l8) + { + address = decompBuffer + length; // mov %r8,(%rdi,%rax,1) + memcpy((void *)address, &compBufferPointer, sizeof(compBufferPointer)); + + length += caseTableIndex; // add %r9,%rax + compBufferPointer = length; // mov %rax,%r8 + + if (compBufferPointer < r12) // jb Llzvn_exit + { + return 0; + } + + compBufferPointer -= r12; // sub %r12,%r8 + + if (r12 < 8) // cmp $0x8,%r12 + { + jmpTo = LZVN_4; // jb Llzvn_l4 + break; + } + + jmpTo = LZVN_5; // jmpq *(%rbx,%r9,8) + break; + } + + case LZVN_8: /**********************************************************/ + + _LZVN_DEBUG_DUMP("jmpTable(8)\n"); + + if (caseTableIndex == 0) // test %r9,%r9 + { + jmpTo = LZVN_7; // jmpq *(%rbx,%r9,8) + break; + } + + currentLength = (decompressedSize + 8); // lea 0x8(%rsi),%r11 + + case LZVN_6: /**********************************************************/ + + do + { + _LZVN_DEBUG_DUMP("jmpTable(6)\n"); + + address = (decompBuffer + length); // mov %r8b,(%rdi,%rax,1) + byte_data = (unsigned char)(compBufferPointer & 255); + memcpy((void *)address, &byte_data, sizeof(byte_data)); + length += 1; // add $0x1,%rax + + if (length == currentLength) // cmp %rax,%r11 + { + return length; // je Llzvn_exit2 + } + + compBufferPointer >>= 8; // shr $0x8,%r8 + caseTableIndex -= 1; // sub $0x1,%r9 + + } while (caseTableIndex != 1); // jne Llzvn_l6 + + case LZVN_7: /**********************************************************/ + + _LZVN_DEBUG_DUMP("jmpTable(7)\n"); + + compBufferPointer = length; // mov %rax,%r8 + compBufferPointer -= r12; // sub %r12,%r8 + + if (compBufferPointer < r12) // jb Llzvn_exit + { + return 0; + } + + jmpTo = LZVN_4; + break; // jmpq *(%rbx,%r9,8) + + case LZVN_11: /*********************************************************/ + + _LZVN_DEBUG_DUMP("jmpTable(11)\n"); + + compBufferPointer = length; // mov %rax,%r8 + compBufferPointer -= r12; // sub %r12,%r8 + currentLength = (length + r10); // lea (%rax,%r10,1),%r11 + + if (currentLength < decompressedSize) // cmp %rsi,%r11 + { + if (r12 >= 8) // cmp $0x8,%r12 + { + jmpTo = LZVN_5; // jae Llzvn_l5 + break; + } + } + + jmpTo = LZVN_4; // jmp Llzvn_l4 + break; + } // switch (jmpq) + + } while (1); + + return 0; +} diff --git a/i386/boot2/options.c b/i386/boot2/options.c index 6cd692a..fffa8eb 100755 --- a/i386/boot2/options.c +++ b/i386/boot2/options.c @@ -92,6 +92,7 @@ void getAndProcessBootArguments(char * configKernelFlags) int bootModes[6] = { -1, kBootModeNormal, kBootModeNormal, -1, kBootModeSafe, kBootModeNormal }; const char * bootFlags[6] = { "", kVerboseModeFlag, kSingleUserModeFlag, "", kSafeModeFlag, kIgnoreCachesFlag }; + bzero(gBootArgs, sizeof(gBootArgs)); skipblanks(&cp); while (readKeyboardStatus()) @@ -140,7 +141,7 @@ void getAndProcessBootArguments(char * configKernelFlags) // printf("And action...\n"); if (gBootArgsPtr + 3 < gBootArgsEnd) { - gBootMode = currentMode; + gPlatform.BootMode = currentMode; copyArgument(0, bootFlags[index], 3, &argP, &cntRemaining); } diff --git a/i386/config/ACPI/clean.h b/i386/config/ACPI/clean.h new file mode 100755 index 0000000..6a80eac --- /dev/null +++ b/i386/config/ACPI/clean.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2009 Master Chief. All rights reserved. + * + * Note: This is an essential part of the build process for Revolution v0.6.43 and greater. + * + * + * Latest cleanups and additional directives added by DHP in 2011 + */ + + +//--------------------------------------------------------- ESSENTIAL ACPI TABLES ------------------------------------------------------------- + + +#if STATIC_APIC_TABLE_INJECTION + #define STATIC_APIC_TABLE_DATA \ + /* 0x0000 */ // Insert your APIC table replacement here (optional). +#endif + + +#if STATIC_ECDT_TABLE_INJECTION + #define STATIC_ECDT_TABLE_DATA \ + /* 0x0000 */ // Insert your ECDT table replacement here (optional). +#endif + + +#if STATIC_HPET_TABLE_INJECTION + #define STATIC_HPET_TABLE_DATA \ + /* 0x0000 */ // Insert your HPET table replacement here (optional). +#endif + + +#if STATIC_MCFG_TABLE_INJECTION + #define STATIC_MCFG_TABLE_DATA \ + /* 0x0000 */ // Insert your MCFG table replacement here (optional). +#endif + + +#if STATIC_SBST_TABLE_INJECTION + #define STATIC_SBST_TABLE_DATA \ + /* 0x0000 */ // Insert your SBST table replacement here (optional). +#endif + + +#if STATIC_SSDT_TABLE_INJECTION + #define STATIC_SSDT_TABLE_DATA \ + /* 0x0000 */ // Insert your SSDT table replacement here (optional). +#endif + + +//--------------------------------------------------------- SECONDARY ACPI TABLES ------------------------------------------------------------- + + +#if STATIC_DSDT_TABLE_INJECTION + #define STATIC_DSDT_TABLE_DATA \ + /* 0x0000 */ // Insert your DSDT table replacement here (optional). +#endif + + +#if STATIC_FACS_TABLE_INJECTION + #define STATIC_FACS_TABLE_DATA \ + /* 0x0000 */ // Insert your FACS table replacement here (optional). +#endif + + +//---------------------------------------------------------- OPTIONAL ACPI TABLES ------------------------------------------------------------- + + +#if STATIC_APIC2_TABLE_INJECTION + #define STATIC_APIC2_TABLE_DATA \ + /* 0x0000 */ // Insert a second APIC table (replacement) here (optional). +#endif + + +#if STATIC_SSDT_GPU_TABLE_INJECTION + #define STATIC_SSDT_GPU_TABLE_DATA \ + /* 0x0000 */ // Insert your SSDT_GPU table replacement here (optional). +#endif + + +#if STATIC_SSDT_PR_TABLE_INJECTION + #define STATIC_SSDT_PR_TABLE_DATA \ + /* 0x0000 */ // Insert your SSDT_PR table replacement here (optional). +#endif + + +#if STATIC_SSDT_SATA_TABLE_INJECTION + #define STATIC_SSDT_SATA_TABLE_DATA \ + /* 0x0000 */ // Insert your SSDT_SATA table replacement here (optional). +#endif + + +#if STATIC_SSDT_USB_TABLE_INJECTION + #define STATIC_SSDT_USB_TABLE_DATA \ + /* 0x0000 */ // Insert your SSDT_USB table replacement here (optional). +#endif + +//================================================================= END ==================================================================== diff --git a/i386/config/ACPI/data.h b/i386/config/ACPI/data.h index 6a80eac..e69de29 100755 --- a/i386/config/ACPI/data.h +++ b/i386/config/ACPI/data.h @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2009 Master Chief. All rights reserved. - * - * Note: This is an essential part of the build process for Revolution v0.6.43 and greater. - * - * - * Latest cleanups and additional directives added by DHP in 2011 - */ - - -//--------------------------------------------------------- ESSENTIAL ACPI TABLES ------------------------------------------------------------- - - -#if STATIC_APIC_TABLE_INJECTION - #define STATIC_APIC_TABLE_DATA \ - /* 0x0000 */ // Insert your APIC table replacement here (optional). -#endif - - -#if STATIC_ECDT_TABLE_INJECTION - #define STATIC_ECDT_TABLE_DATA \ - /* 0x0000 */ // Insert your ECDT table replacement here (optional). -#endif - - -#if STATIC_HPET_TABLE_INJECTION - #define STATIC_HPET_TABLE_DATA \ - /* 0x0000 */ // Insert your HPET table replacement here (optional). -#endif - - -#if STATIC_MCFG_TABLE_INJECTION - #define STATIC_MCFG_TABLE_DATA \ - /* 0x0000 */ // Insert your MCFG table replacement here (optional). -#endif - - -#if STATIC_SBST_TABLE_INJECTION - #define STATIC_SBST_TABLE_DATA \ - /* 0x0000 */ // Insert your SBST table replacement here (optional). -#endif - - -#if STATIC_SSDT_TABLE_INJECTION - #define STATIC_SSDT_TABLE_DATA \ - /* 0x0000 */ // Insert your SSDT table replacement here (optional). -#endif - - -//--------------------------------------------------------- SECONDARY ACPI TABLES ------------------------------------------------------------- - - -#if STATIC_DSDT_TABLE_INJECTION - #define STATIC_DSDT_TABLE_DATA \ - /* 0x0000 */ // Insert your DSDT table replacement here (optional). -#endif - - -#if STATIC_FACS_TABLE_INJECTION - #define STATIC_FACS_TABLE_DATA \ - /* 0x0000 */ // Insert your FACS table replacement here (optional). -#endif - - -//---------------------------------------------------------- OPTIONAL ACPI TABLES ------------------------------------------------------------- - - -#if STATIC_APIC2_TABLE_INJECTION - #define STATIC_APIC2_TABLE_DATA \ - /* 0x0000 */ // Insert a second APIC table (replacement) here (optional). -#endif - - -#if STATIC_SSDT_GPU_TABLE_INJECTION - #define STATIC_SSDT_GPU_TABLE_DATA \ - /* 0x0000 */ // Insert your SSDT_GPU table replacement here (optional). -#endif - - -#if STATIC_SSDT_PR_TABLE_INJECTION - #define STATIC_SSDT_PR_TABLE_DATA \ - /* 0x0000 */ // Insert your SSDT_PR table replacement here (optional). -#endif - - -#if STATIC_SSDT_SATA_TABLE_INJECTION - #define STATIC_SSDT_SATA_TABLE_DATA \ - /* 0x0000 */ // Insert your SSDT_SATA table replacement here (optional). -#endif - - -#if STATIC_SSDT_USB_TABLE_INJECTION - #define STATIC_SSDT_USB_TABLE_DATA \ - /* 0x0000 */ // Insert your SSDT_USB table replacement here (optional). -#endif - -//================================================================= END ==================================================================== diff --git a/i386/config/EFI/clean.h b/i386/config/EFI/clean.h new file mode 100755 index 0000000..9807da6 --- /dev/null +++ b/i386/config/EFI/clean.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2009 Master Chief. All rights reserved. + * + * Note: This is an essential part of the build process for Revolution v0.6.43 and greater. + * + * + * Latest cleanups and additional directives added by DHP in 2011 + */ + + +//----------------------------------------------------------------- EFI -------------------------------------------------------------------- + +#define STATIC_EFI_DEVICE_PROPERTIES \ +/* 0x0000 */ // Insert your EFI device-property data here (optional). + +//================================================================= END ==================================================================== diff --git a/i386/config/README b/i386/config/README index dfacdef..57fd990 100644 --- a/i386/config/README +++ b/i386/config/README @@ -4,8 +4,9 @@ RevoBoot comes with configuration templates of which some you need to change: ACPI/data-template.h -------------------- -This file is optional. Only required when you want to inject static ACPI table data. -Copy/rename the file to data.h and add your (modified) ACPI tables. +RevoBoot's build process will copy this file for new configurations to the target modelidentifier +and use it, but only when you didn't already do this yourself. Make all required changes in +the new file only or it won't be used at all. Note: We use 'factory tables' for the original ACPI tables in the BIOS and 'modified' for new/modified ACPI tables. @@ -14,8 +15,9 @@ Note: We use 'factory tables' for the original ACPI tables in the BIOS and 'modi EFI/data-template.h ------------------- -This file is optional. Only required when you want/need to inject EFI device properties. -Copy/rename the file to data.h and add your EFI device properties. +RevoBoot's build process will copy this file for new configurations to the target modelidentifier +and use it, but only when you didn't already do this yourself. Make all required changes in +the new file only or it won't be used at all. Note: A simple HOWTO will (hopefully) soon be added to the EFI directory. @@ -23,36 +25,45 @@ Note: A simple HOWTO will (hopefully) soon be added to the EFI directory. SMBIOS/data-template.h ---------------------- -This file is optional. Only required when you want to inject static ACPI table data. -Copy/rename the file to data.h and add your static SMBIOS data. +RevoBoot's build process will copy this file for new configurations to the target modelidentifier +and use it, but only when you didn't already do this yourself. Make all required changes in +the new file only or it won't be used at all. Note: You can extract the SMBIOS table data with: /smbios/tools/smbios2struct2 Make instruction are included in the source code. +settings.h +---------- + +This file selects the target settings file based on the specified model identifier. Using +make MODEL=Macmini51 or use ./r Macmini51 (examples) makes it select RevoBoot/i386/config/SETTINGS/Macmini51.h +All future changes need to be made in this file, or they won't be picked up. + + settings-template.h ------------------- -This is the default configuration template for RevoBoot. Every possible option can be found in it. -You have to either copy or rename this file to settings.h and change it so that it matches your -hardware configuration. +RevoBoot's build process first checks RevoBoot/i386/config/SETTINGS/*.h per target model identifier +(example: Macmini51,h) and use it, or copies RevoBoot/i386/config/settings-template.h to the target model +identifier (when the file is missing) to prevent build errors. +People with working RevoBoot configurations can simply copy their settings.h to SETTINGS/[your model].h +This will allow the RevoBoot build process to compile without errors, but make sure to use the latest +preprocessor options. -data-template.h ---------------- +Important: Open settings-template.h and search for: -RevoBoot has one main include file for static data in the ACPI, EFI and SMBIOS directories. -This enables you to add files for different target configurations there. Here's an example -for two setups: +#define STATIC_NVRAM_ROM { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0xNN, 0xNN, 0xNN, 0xNN, 0xNN, 0xNN } // Example only! + // sudo nvram 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ROM=%01%02%03%04%05%06%07%08%09%0A%0B%NN%NN%NN%NN%NN%NN + // Note: Use your MAC address for the last six bytes! -#include "ACPI/data-hp.h" -#include "EFI/data-hp.h" -#include "SMBIOS/data-hp.h" +You must change this, or RevoBoot won't compile! + +ACPI/EFI/SMBIOS/data.h +---------------------- -or (not both): +These are RevoBoot's main data selector files to support (optional) static data. -#include "ACPI/data-asus.h" -#include "EFI/data-asus.h" -#include "SMBIOS/data-asus.h" +Note: Do not change this file! -Note: We plan to add a make option for this. To let it select the files for the target configuration. diff --git a/i386/config/SMBIOS/clean.h b/i386/config/SMBIOS/clean.h new file mode 100755 index 0000000..d388f10 --- /dev/null +++ b/i386/config/SMBIOS/clean.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2009 Master Chief. All rights reserved. + * + * Note: This is an essential part of the build process for Revolution v0.6.44 and greater. + * + * + * Update: - Cleanups and additional directives added by DHP in 2011. + * - Tip / Note added by DHP (march 2012). + * + * Tip: The idea is to use dynamic SMBIOS generation in RevoBoot only to + * let it strip your factory table, after which you should do this: + * + * 1.) Extract the new OS X compatible SMBIOS table with: tools/smbios2struct + * 2.) Add the data structure to: RevoBoot/i386/config/SMBIOS/data.h + * 3.) Recompile RevoBoot, and be happy with your quicker boot time. + * + * Note: Repeat this procedure after adding memory or other SMBIOS relevant + * hardware changes, like replacing the motherboard and/or processor. + * + */ + +//--------------------------------------------------------------- SMBIOS ------------------------------------------------------------------- + +#define STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE 0 + +#define STATIC_SMBIOS_DMI_STRUCTURE_COUNT 0 + +#define STATIC_SMBIOS_DATA \ +/* 0x0000 */ // Insert your SMBIOS data here. + +//================================================================= END ==================================================================== diff --git a/i386/config/SMBIOS/data-template.h b/i386/config/SMBIOS/data-template.h index 0d0cb7a..d388f10 100755 --- a/i386/config/SMBIOS/data-template.h +++ b/i386/config/SMBIOS/data-template.h @@ -21,9 +21,9 @@ //--------------------------------------------------------------- SMBIOS ------------------------------------------------------------------- -#define STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE NNN +#define STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE 0 -#define STATIC_SMBIOS_DMI_STRUCTURE_COUNT NN +#define STATIC_SMBIOS_DMI_STRUCTURE_COUNT 0 #define STATIC_SMBIOS_DATA \ /* 0x0000 */ // Insert your SMBIOS data here. diff --git a/i386/config/data-template.h b/i386/config/data-template.h index c3a566c..e69de29 100755 --- a/i386/config/data-template.h +++ b/i386/config/data-template.h @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2009 Master Chief. - * Refactored by DHP in 2010-2011. - */ - - -#if PATCH_ACPI_TABLE_DATA && INCLUDE_ACPI_DATA - #undef INCLUDE_ACPI_DATA - #include "acpi/data.h" - -#elif INJECT_EFI_DEVICE_PROPERTIES && INCLUDE_EFI_DATA - #undef INCLUDE_EFI_DATA - #include "efi/data.h" - -#elif USE_STATIC_SMBIOS_DATA && INCLUDE_SMBIOS_DATA - #undef INCLUDE_SMBIOS_DATA - #include "smbios/data.h" - -#endif diff --git a/i386/config/data.h b/i386/config/data.h index c3a566c..40de3d1 100755 --- a/i386/config/data.h +++ b/i386/config/data.h @@ -1,19 +1,36 @@ /* * Copyright (c) 2009 Master Chief. - * Refactored by DHP in 2010-2011. + * + * This file, included by acpi.c, efi.c and smbios.c includes data files + * for the target build model (based on MODEL=MacModelNN) or default.h + * + * Updates: + * + * - Refactored by DHP in 2010-2011. + * - Automatic model data selection (PikerAlpha, October 2012). + * - Static ACPI data selector moved to RevoBoot/i386/libsaio/ACPI/static_data.h (PikerAlpha, October 2012). + * - Static EFI data selector moved to RevoBoot/i386/libsaio/efi.c (PikerAlpha, October 2012). + * - Static SMBIOS data selector moved to RevoBoot/i386/libsaio/SMBIOS/dynamic_data.h (PikerAlpha, October 2012). + * - This file is no longer included with RevoBoot v1.5.25 (PikerAlpha, October 2012). */ -#if PATCH_ACPI_TABLE_DATA && INCLUDE_ACPI_DATA +!!__WHEN_YOU_SEE_THIS_STUPID_ERROR_THAN_SOMETHING_IS_WRONG__!! + +#if (PATCH_ACPI_TABLE_DATA && INCLUDE_ACPI_DATA) #undef INCLUDE_ACPI_DATA - #include "acpi/data.h" + // The STRING (macro) is defined in RevoBoot/i386/config/settings.h + #include STRING(ACPI_DATA_FILE) +#endif -#elif INJECT_EFI_DEVICE_PROPERTIES && INCLUDE_EFI_DATA +#if (INJECT_EFI_DEVICE_PROPERTIES && INCLUDE_EFI_DATA) #undef INCLUDE_EFI_DATA - #include "efi/data.h" -#elif USE_STATIC_SMBIOS_DATA && INCLUDE_SMBIOS_DATA + #include STRING(EFI_DATA_FILE) +#endif + +#if (USE_STATIC_SMBIOS_DATA && INCLUDE_SMBIOS_DATA) #undef INCLUDE_SMBIOS_DATA - #include "smbios/data.h" + #include STRING(SMBIOS_DATA_FILE) #endif diff --git a/i386/config/settings-template.h b/i386/config/settings-template.h old mode 100644 new mode 100755 index 263eba5..2df55d1 --- a/i386/config/settings-template.h +++ b/i386/config/settings-template.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2009 Master Chief. All rights reserved. * - * Note: This is an essential part of the build process for RevoBoot v1.5.00 and greater. + * Note: This is an essential part of the build process for RevoBoot v1.5.39 and greater. * * Updates: * @@ -9,13 +9,41 @@ * - Static CPU data simplified by DHP in Juni 2011 (thanks to MC and flAked for the idea). * - Automatic creation / injection of SSDT_PR.aml added by DHP in June 2011. * - New compiler directive (BOOT_TURBO_BOOST_RATIO) added by Jeroen (June 2011). - * - SMBIOS data logic moved to preprocessor code (PikerAlpha, October 2012). - * - STATIC_MODEL_NAME moved to libsaio/i386/SMBIOS/model_data.h (PikerAlpha, October 2012). - * - STATIC_MAC_PRODUCT_NAME moved to libsaio/i386/SMBIOS/model_data.h (PikerAlpha, October 2012). - * - STATIC_SMBIOS_MODEL_ID rrenamed to TARGET_MODEL (PikerAlpha, October 2012). - * - OVERRIDE_DYNAMIC_PRODUCT_DETECTION removed/no longer supported (PikerAlpha, October 2012). - * - INTEL_CORE_TECHNOLOGY per default set to 1 (PikerAlpha, October 2012). - * + * - SMBIOS data logic moved to preprocessor code (Pike R. Alpha, October 2012). + * - STATIC_MODEL_NAME moved to libsaio/i386/SMBIOS/model_data.h (Pike R. Alpha, October 2012). + * - STATIC_MAC_PRODUCT_NAME moved to libsaio/i386/SMBIOS/model_data.h (Pike R. Alpha, October 2012). + * - STATIC_SMBIOS_MODEL_ID renamed to TARGET_MODEL (Pike R. Alpha, October 2012). + * - OVERRIDE_DYNAMIC_PRODUCT_DETECTION removed/no longer supported (Pike R. Alpha, October 2012). + * - INTEL_CORE_TECHNOLOGY per default set to 1 (Pike R. Alpha, October 2012). + * - INJECT_EFI_DEVICE_PROPERTIES per default set to 1 (Pike R. Alpha, October 2012). + * - SMBIOS base board serial# (SMB_BOARD_SERIAL_NUMBER) feature added (dgsga, October 2012). + * - LOAD_STATIC_EFI_DATA_FROM_EXTRA feature added (Pike R. Alpha, October 2012). + * - LOAD_STATIC_SMBIOS_DATA_FROM_EXTRA feature added (Pike R. Alpha, October 2012). + * - STATIC_SYSTEM_SERIAL_NUMBER renamed to EFI_SYSTEM_SERIAL_NUMBER (Pike R. Alpha, October 2012). + * - Restored lost STATIC_SMSERIALNUMBER (Pike R. Alpha, October 2012). + * - STATIC_SMSERIALNUMBER renamed to SMB_SYSTEM_SERIAL_NUMBER (Pike R. Alpha, October 2012). + * - LOAD_STATIC_ACPI_DATA_FROM_EXTRA added (Pike R. Alpha, October 2012). + * - LOAD_STATIC_EFI_DATA_FROM_EXTRA renamed to LOAD_MODEL_SPECIFIC_EFI_DATA (Pike R. Alpha, October 2012). + * - LOAD_STATIC_SMBIOS_DATA_FROM_EXTRA renamed to LOAD_MODEL_SPECIFIC_SMBIOS_DATA (Pike R. Alpha, October 2012). + * - LOAD_MODEL_SPECIFIC_STATIC_DATA added (Pike R. Alpha, October 2012). + * - Option SET_MAX_STRUCTURE_LENGTH added (Pike R. Alpha, November 2012). + * - Option DISK_TARGET_SUPPORT added (Pike R. Alpha, November 2012). + * - DISK_TARGET_SUPPORT renamed to STARTUP_DISK_SUPPORT (Pike R. Alpha, November 2012). + * - New compiler directive USE_DEVICE_PATH in boot section (Pike R. Alpha, November 2012). + * - Always inject SMB_BOARD_SERIAL_NUMBER, required for iMessage (Pike R. Alpha, January 2013). + * - New compiler directives in EFI section added (Pike R. Alpha, January 2013). + * - STATIC_SYSTEM_ID renamed to SMB_STATIC_SYSTEM_UUID and moved to SMBIOS section (Pike R. Alpha, January 2013). + * - Renamed LION_INSTALL_SUPPORT to INSTALL_ESD_SUPPORT (Pike R. Alpha, April 2013). + * - Renamed LION_RECOVERY_SUPPORT to RECOVERY_HD_SUPPORT (Pike R. Alpha, October 2013). + * - PRE_LINKED_KERNEL_SUPPORT renamed to PRELINKED_KERNEL_SUPPORT (Pike R. Alpha, October 2015). + * - DYNAMIC_RAM_OVERRIDE_TYPE renamed to STATIC_RAM_OVERRIDE_TYPE (Pike R. Alpha, July 2016). + * - DYNAMIC_RAM_OVERRIDE_SIZE renamed to STATIC_RAM_OVERRIDE_SIZE + * - DYNAMIC_RAM_OVERRIDE_SIZES renamed to STATIC_RAM_OVERRIDE_SIZES + * - DYNAMIC_RAM_OVERRIDE_FREQUENCY renamed to STATIC_RAM_OVERRIDE_FREQUENCY + * - PATCH_XCPI_SCOPE_MSRS renamed to PATCH_XCPM_SCOPE_MSRS + * - PATCH_XCPI_SCOPE_MSRS removed (Pike R. Alpha, August 2016). + * - PATCH_KERNEL, DEBUG_KERNEL_PATCHER, PATCH_XCPM_BOOTSTRAP and PATCH_CPUID_SET_INFO added. + * - Moving targetMSRs to configuration file. */ @@ -28,10 +56,10 @@ // and requires you to set PATCH_ACPI_TABLE_DATA to 1. -#define PATCH_ACPI_TABLE_DATA 1 // Set to 1 by default (enabling patching). Use 0 to keep the original - // unmodified ACPI tables, but please note (very well) that this is - // only supported by very few motherboards / BIOS'es. You may also - // need a kext like OSXRestart.kext to be able to restart your system, +#define PATCH_ACPI_TABLE_DATA 1 // Set to 1 by default (enabling patching). Use 0 to keep the original + // unmodified ACPI tables, but please note (very well) that this is + // only supported by very few motherboards / BIOS'es. You may also + // need a kext like OSXRestart.kext to be able to restart your system, // this due to a possibly broken FACP table in your BIOS! // // Note: Requires one of the following STATIC_* and/or LOAD_* settings: @@ -46,13 +74,13 @@ #endif -#define STATIC_APIC_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject a modified copy +#define STATIC_APIC_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject a modified copy // with say stripped out unused CPU's or other required modifications. // // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. -#define STATIC_APIC2_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject a second APIC +#define STATIC_APIC2_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject a second APIC // (ACPI-1) table data for additional CPU core support. // // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. @@ -71,7 +99,7 @@ // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. -#define STATIC_HPET_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject a static copy +#define STATIC_HPET_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject a static copy // of a custom HPET table. // // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. @@ -89,7 +117,7 @@ // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. -#define STATIC_SSDT_PR_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject your Intel +#define STATIC_SSDT_PR_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject your Intel // SpeedStep related modifications (like I do). // // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. @@ -105,15 +133,15 @@ // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. -#define LOAD_DSDT_TABLE_FROM_EXTRA_ACPI 1 // Set to 0 by default. Use 1 when your setup requires a modified DSDT table - // and you want to load: /Extra/ACPI/dsdt.aml instead of injecting a static - // DSDT table from: RevoBoot/i386/config/ACPI/data.h +#define LOAD_DSDT_TABLE_FROM_EXTRA_ACPI 0 // Set to 0 by default. Use 1 when your setup requires a modified DSDT table + // and you want to load: /Extra/ACPI/dsdt.aml instead of injecting a static + // DSDT table from: RevoBoot/i386/config/ACPI/data.h // // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. -#define LOAD_SSDT_TABLE_FROM_EXTRA_ACPI 0 // Set to 1 by default. Use 0 only after you've converted your SSDT into - // STATIC_SSDT_TABLE_INJECTION in: RevoBoot/i386/config/ACPI/data.h +#define LOAD_SSDT_TABLE_FROM_EXTRA_ACPI 1 // Set to 1 by default. Use 0 only after you've converted your SSDT into + // STATIC_SSDT_TABLE_INJECTION in: RevoBoot/i386/config/ACPI/data.h // or when you don't want/need to load /Extra/ACPI/SSDT.aml // // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. @@ -121,8 +149,12 @@ #define LOAD_EXTRA_ACPI_TABLES (LOAD_DSDT_TABLE_FROM_EXTRA_ACPI || LOAD_SSDT_TABLE_FROM_EXTRA_ACPI) +#if LOAD_EXTRA_ACPI_TABLES + #define LOAD_MODEL_SPECIFIC_ACPI_DATA 0 // Set to 0 by default. Use 1 to read: /Extra/ACPI/[XXXX-MacModelNN].aml and + // falls back to: /Extra/ACPI/[XXXX].aml when model specific data is not available. +#endif -#define AUTOMATIC_SSDT_PR_CREATION 1 // Set to 0 by default (support for Sandy Bridge only). +#define AUTOMATIC_SSDT_PR_CREATION 0 // Set to 0 by default (support for Sandy Bridge only). // // This injects a custom SSDT (in configure mode) with: // @@ -132,13 +164,13 @@ // Use 4 to inject: Device (SBUS) {...} which is required for Power Management. // Use 5 to inject: P/C-State definition blocks plus the former (Device SBUS). // Use 7 to inject: All of the above. - // + // // Notes: Device SBUS can only be injected when it isn't part of other ACPI tables! // This feature should only be used once, to extract the SSDT_PR from ioreg // and use it as STATIC_SSDT_PR_TABLE_DATA in RevoBoot/i386/config/ACPI/data.h -#if AUTOMATIC_SSDT_PR_CREATION && STATIC_SSDT_PR_TABLE_INJECTION == 0 +#if (AUTOMATIC_SSDT_PR_CREATION == 1 && STATIC_SSDT_PR_TABLE_INJECTION == 0) #define MAX_NUMBER_OF_P_STATES 22 // The i5-2500K need 18 for the base-range (1600-3300) plus 4 for the Turbo modes. // The i7-2600K need 19 for the base-range (1600-3400) plus 4 for the Turbo modes. // The i7-2700K need 20 for the base-range (1600-3500) plus 4 for the Turbo modes. @@ -147,16 +179,16 @@ // // Note: AICPUPM wants a P-State for each 100 MHz bank or it will fail (see note below). -#define DROP_FACTORY_SSDT_TABLES 1 // Set to 1 by default (this setting is required). + #define DROP_FACTORY_SSDT_TABLES 1 // Set to 1 by default (this setting may be required on some boards). // // Note: Do not change this setting (must drop SSDT tables). -#define NUMBER_OF_TURBO_STATES 4 // Set to 4 by default. + #define NUMBER_OF_TURBO_STATES 4 // Set to 4 by default. Use any number to override the number of Turbo States. // // Note: Make sure to add a full range, one P-State for each 100 MHz when OC'ing // or AICPIPM will fail with: "P-State Stepper Error 18 at step N on CPU N" -#define OVERRIDE_ACPI_METHODS 0 // Set to 0 by default (do nothing). + #define OVERRIDE_ACPI_METHODS 0 // Set to 0 by default (do nothing). // Use 1 to override Method _PTS in a static SSDT or Extra/ACPI/SSDT.aml // Use 2 to override Method _WAK in a static SSDT or Extra/ACPI/SSDT.aml // Use 3 to override both _PTS and _WAK. @@ -166,18 +198,37 @@ #else #define OVERRIDE_ACPI_METHODS 0 // Set to 0 by default (do nothing). - #define DROP_FACTORY_SSDT_TABLES 0 // Set to 0 by default. Use 1 with caution (might disable SpeedStep). + #define DROP_FACTORY_SSDT_TABLES 0 // Set to 0 by default. Use 1 with caution (might disable CPU Power Management). #endif -#define REPLACE_EXISTING_SSDT_TABLES 0 // Set to 0 by default. Use 1 with caution (might disable SpeedStep). +#if DROP_FACTORY_SSDT_TABLES + #define DROP_SELECTED_SSDT_TABLE 1 // Set to 0 by default. + // + // Haswell (example) + // + // #define OEM_TABLE_ID_TARGETS { "CpuPm", "Cpu0Ist", 0 } + // + // Skylake (example) + // + // #define OEM_TABLE_ID_TARGETS { "sensrhub", "Ther_Rvp", "SaSsdt ", "CpuSsdt", "PtidDevc", "SataTabl", "xh_rvp10", 0 } + // #define OEM_TABLE_ID_TARGETS { "sensrhub", "Ther_Rvp", "PtidDevc", "SataTabl", "xh_rvp10", 0 } + #define OEM_TABLE_ID_TARGETS { "SataTabl", "PmMgt", 0 } +#endif + +#define REPLACE_EXISTING_SSDT_TABLES 0 // Set to 0 by default. Use 1 with caution (might disable CPU Power Management). // // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. #define APPLE_STYLE_ACPI 0 // Set to 0 by default. Use 1 to change the OEMID's to Mac likes. // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1 and keep in mind that this can + // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1 and keep in mind that this can // only change the headers of injected/replaced tables. Not the factory tables. +#define VERIFY_OPREGION_GNVS_ADDRESS 1 // Set to 0 by default. + +#if VERIFY_OPREGION_GNVS_ADDRESS + #define DUMP_OPREGION_GNVS_ADDRESS 0 // Set to 0 by default. +#endif #define DEBUG_ACPI 0 // Set to 0 by default. Use 1 when things don't seem to work for you. @@ -185,142 +236,174 @@ //--------------------------------------------------------------- BOOT.C ------------------------------------------------------------------- -#define PRE_LINKED_KERNEL_SUPPORT 1 // Set to 1 by default. Change this to 0 to disable the use of pre-linked kernels. +#define PRELINKED_KERNEL_SUPPORT 1 // Set to 1 by default. Change this to 0 to disable the use of pre-linked kernels. -#define MUST_ENABLE_A20 0 // Set to 0 by default. Change this to 1 when your hardware requires it. +#define MUST_ENABLE_A20 0 // Set to 0 by default. Change this to 1 when your hardware requires it. -#define SAFE_MALLOC 0 // Set to 0 by default. Change this to 1 when booting halts with a memory allocation error. +#define SAFE_MALLOC 0 // Set to 0 by default. Change this to 1 when booting halts with a memory allocation error. -#define DEBUG_BOOT 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. +#define RECOVERY_HD_SUPPORT 0 // Set to 0 by default. Change this to 1 to make RevoBoot search for the 'Recovery HD' + // partition and, when available, boot from it. +#if (RECOVERY_HD_SUPPORT == 1 && PRELINKED_KERNEL_SUPPORT == 0) + #define PRELINKED_KERNEL_SUPPORT 1 +#endif + +#define STARTUP_DISK_SUPPORT 0 // Set to 0 by default. Change this to 1 for System Preference/Startup Disk support. + +#if STARTUP_DISK_SUPPORT + #define USE_DEVICE_PATH 0 // Set to 0 by default. Change this to 1 when the Startup Disk feature fails to work. + // + // Note: This experimental switch will be removed in a next update/release. It is here + // only to give us feedback for a future release of RevoBoot. +#endif + +#define DISABLE_LEGACY_XHCI 0 // Set to 0 by default. Change this to 1 when you need to disable legacy XHCI. + +#define DEBUG_BOOT 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. //---------------------------------------------------------------- CPU.C ------------------------------------------------------------------- -#define USE_STATIC_CPU_DATA 1 // Set to 0 by default (dynamic data collection). Change this to 1 to use static data. +#define USE_STATIC_CPU_DATA 0 // Set to 0 by default (dynamic data collection). Change this to 1 to use static data. -#define CPU_VENDOR_ID CPU_VENDOR_INTEL // CPU_VENDOR_AMD is not supported. +#define CPU_VENDOR_ID CPU_VENDOR_INTEL // CPU_VENDOR_AMD is not supported. -#define INTEL_CORE_TECHNOLOGY 1 // Set to 1 by default. Use 0 for older non Intel Core CPU's (removes unused code). - // - // Warning: Do not use 0 on Core Technology CPU's or sysctl's machdep.tsc.frequency will be - // initialized with the wrong value (various things, like the spinner will go mad). +#define INTEL_CORE_TECHNOLOGY 1 // Set to 1 by default. Use 0 for older non Intel Core CPU's (removes unused code). + // + // Warning: Do not use 0 on Core Technology CPU's or sysctl's machdep.tsc.frequency will be + // initialized with the wrong value (various things, like the spinner will go mad). -#define OC_BUSRATIO_CORRECTION 0 // Set to 0 by default. Change this to busratio-100 (OC'ed systems with a changed busratio). +#define OC_BUSRATIO_CORRECTION 0 // Set to 0 by default. Change this to busratio-100 (OC'ed systems with a changed busratio). -#define BOOT_TURBO_RATIO 0 // Set to 0 by default. Change this to the desired (and supported) max turbo multiplier. - // - // Example: 0x2800 for 4.0 GHz on a i7-2600. +#define BOOT_TURBO_RATIO 0 // Set to 0 by default. Change this to the desired (and supported) max turbo multiplier. + // + // Example: 0x2800 for 4.0 GHz on a i7-2600. -#define DEBUG_CPU 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. - // Note: CPU info data will not be displayed when USE_STATIC_CPU_DATA is set to 1 +#define DEBUG_CPU 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. + // + // Note: CPU info data will not be displayed when USE_STATIC_CPU_DATA is set to 1 #if DEBUG_CPU -#define DEBUG_CPU_TURBO_RATIOS 0 // Set to 0 by default. Change this to 1 when you want to check the core ratio. + #define DEBUG_CPU_TURBO_RATIOS 0 // Set to 0 by default. Change this to 1 when you want to check the core ratio. -#define DEBUG_CST_SUPPORT 0 // Set to 0 by default. Change this to 1 to check the in BIOS enabled C-States. + #define DEBUG_CST_SUPPORT 0 // Set to 0 by default. Change this to 1 to check the in BIOS enabled C-States. -#define DEBUG_TSS_SUPPORT 0 // Set to 0 by default. Change this to 1 to check the T-State Clock Modulation. + #define DEBUG_TSS_SUPPORT 0 // Set to 0 by default. Change this to 1 to check the T-State Clock Modulation. -#define DEBUG_CPU_TDP 0 // Set to 0 by default. Change this to 1 when you want to check the TDP. + #define DEBUG_CPU_TDP 0 // Set to 0 by default. Change this to 1 when you want to check the TDP. #endif //---------------------------------------------------------- CPU/STATIC_DATA.C ------------------------------------------------------------- #if USE_STATIC_CPU_DATA - #define STATIC_CPU_Type 0x602 // kSMBTypeOemProcessorType - used in: libsaio/SMBIOS/dynamic_data.h + #define STATIC_CPU_Type 0x602 // kSMBTypeOemProcessorType - used in: libsaio/SMBIOS/dynamic_data.h - #define STATIC_CPU_NumThreads 4 // Used in: i386/libsaio/ACPI/ssdt_pr_generator.h + #define STATIC_CPU_NumThreads 4 // Used in: i386/libsaio/ACPI/ssdt_pr_generator.h - #define STATIC_CPU_FSBFrequency 100000000ULL // 9 digits + ULL - used in: i386/libsaio/efi.c + #define STATIC_CPU_FSBFrequency 100000000ULL // 9 digits + ULL - used in: i386/libsaio/efi.c - #define STATIC_CPU_QPISpeed 0 // kSMBTypeOemProcessorBusSpeed (0 for Sandy Bridge / Jaketown). + #define STATIC_CPU_QPISpeed 0 // kSMBTypeOemProcessorBusSpeed (0 for Sandy Bridge / Jaketown). #endif -#define STATIC_CPU_NumCores 4 // Set to 4 by default. Must be set to the number of cores for your processor! - // - // Note: Used in i386/libsaio/ACPI/ssdt_pr_generator.h, cpu.c and platform.c - // for both static and dynamic CPU data. +#define STATIC_CPU_NumCores 4 // Set to 4 by default. Must be set to the number of cores for your processor! + // + // Note: Used in i386/libsaio/ACPI/ssdt_pr_generator.h, cpu.c and platform.c + // for both static and dynamic CPU data. //--------------------------------------------------------------- DISK.C ------------------------------------------------------------------- -#define EFI_SYSTEM_PARTITION_SUPPORT 0 // Set to 0 by default. Set this to 1 when your system boots from the hidden EFI partition. +#define EFI_SYSTEM_PARTITION_SUPPORT 0 // Set to 0 by default. Set this to 1 when your system boots from the hidden EFI partition. -#define LEGACY_BIOS_READ_SUPPORT 0 // Set to 0 by default. Change this to 1 for crappy old BIOSes. +#define LEGACY_BIOS_READ_SUPPORT 0 // Set to 0 by default. Change this to 1 for crappy old BIOSes. -#define LION_FILEVAULT_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot skip encrypted boot partitions - // and boot from the Recovery HD partition instead (when available). +#if RECOVERY_HD_SUPPORT + #define CORE_STORAGE_SUPPORT 1 // Set to 1 by default since booting from a 'Recovery HD' partition may requires us to skip + // (encrypted) CoreStorage partitions. +#else + #define CORE_STORAGE_SUPPORT 0 // Set to 0 by default. Change this to 1 when you want RevoBoot to boot from the 'Boot OS X' + // (usually the third) partition on a Fusion Drive (requires Mountain Lion 10.8.2). +#endif -#define APPLE_RAID_SUPPORT 0 // Set to 0 by default. Change this to 1 for Apple Software RAID support. +#define APPLE_RAID_SUPPORT 0 // Set to 0 by default. Change this to 1 for Apple Software RAID support. -#define DEBUG_DISK 0 // Set to 0 by default. Change it to 1 when things don't seem to work for you. +#define DEBUG_DISK 0 // Set to 0 by default. Change it to 1 when things don't seem to work for you. //------------------------------------------------------------- DRIVERS.C ------------------------------------------------------------------- -#define DEBUG_DRIVERS 0 // Set to 0 by default. Change it to 1 when things don't seem to work for you. +#define DEBUG_DRIVERS 0 // Set to 0 by default. Change it to 1 when things don't seem to work for you. //---------------------------------------------------------------- EFI.C ------------------------------------------------------------------- -#define APPLE_STYLE_EFI 1 // Set to 1 by default. Change this to 1 to add additional 'Mac-like' properties. +#define APPLE_STYLE_EFI 1 // Set to 1 by default. Change this to 1 to add additional 'Mac-like' properties. -#define INJECT_EFI_DEVICE_PROPERTIES 0 // Set to 0 by default. Change this to 1 when you need to inject 'device-properties'. - // - // Note: Required when not setting device-properties from your DSDT/SSDT. +#define INJECT_EFI_DEVICE_PROPERTIES 0 // Set to 0 by default. Change this to 1 when you need to inject 'device-properties'. + // + // Note: Required when not setting device-properties from your DSDT/SSDT. -#define EFI_64_BIT 1 // Set to 1 by default for EFI64 on 64-bit platforms. Supporting both - // 32 and 64-bit boot modes (using arch=i386/x86_64 under Kernel Flags). - // - // Change this to 0 for 32-bit only platforms (think Intel Atom CPU) - // or when you want to boot with EFI32 (for testing) on a 64-bit - // platform, but then you must make a small change in platform.c (see comment in file). - // - // Note: Do not change this setting, unless you know what you are doing. +#if INJECT_EFI_DEVICE_PROPERTIES + #define LOAD_MODEL_SPECIFIC_EFI_DATA 0 // Set to 0 by default. Use 1 to read: /Extra/EFI/[-MacModelNN].bin +#endif -#define STATIC_SMSERIALNUMBER "SOMESRLNUMBR" // Example only! +#define EFI_64_BIT 1 // Set to 1 by default for EFI64 on 64-bit platforms. Supporting both + // 32 and 64-bit boot modes (using arch=i386/x86_64 under Kernel Flags). + // + // Change this to 0 for 32-bit only platforms (think Intel Atom CPU) + // or when you want to boot with EFI32 (for testing) on a 64-bit + // platform, but then you must make a small change in platform.c (see comment in file). + // + // Note: Do not change this setting, unless you know what you are doing. -#define STATIC_SYSTEM_SERIAL_NUMBER { 'S', 'O', 'M', 'E', 'S', 'R', 'L', 'N', 'U', 'M', 'B', 'R' } // Example only! +#define EFI_SYSTEM_SERIAL_NUMBER { 'S', 'O', 'M', 'E', 'S', 'R', 'L', 'N', 'U', 'M', 'B', 'R' } -#define STATIC_SYSTEM_ID { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F } // Example only! + // Note: You can check your serial number by visiting the following link: + // https://selfsolve.apple.com/agreementWarrantyDynamic.do -#define DEBUG_EFI 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. +#define STATIC_NVRAM_ROM { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } // Example only! + // sudo nvram 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ROM=%01%02%03%04%05%06%07%08%09%0A%0B%NN%NN%NN%NN%NN%NN + // + // Note: Use your MAC address for the last six bytes! -#define EFI_DEBUG_MODE 0 // Set to 0 by default (for OS X 10.7 LION only). +#define STATIC_NVRAM_MLB { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11 } // Example only! + // sudo nvram 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:MLB=%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11 + +#define DEBUG_EFI 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. + +#define EFI_DEBUG_MODE 0 // Set to 0 by default (for OS X 10.7 LION and greater). //------------------------------------------------------------- GRAPHICS.C ----------------------------------------------------------------- -#define USE_STATIC_DISPLAY_RESOLUTION 1 // Set to 0 by default. Use 1 when you need to override the resolution detection features - // in RevoBoot, which may not be supported by your BIOS and/or display (monitor). +#define USE_STATIC_DISPLAY_RESOLUTION 1 // Set to 0 by default. Use 1 when you need to override the resolution detection features + // in RevoBoot, which may not be supported by your BIOS and/or display (monitor). -#define STATIC_SCREEN_WIDTH 1900 // Used (in RevoBoot v1.0.35 and greater) when USE_STATIC_DISPLAY_RESOLUTION is 1 and when - // USE_STATIC_DISPLAY_RESOLUTION is 0 but getResolutionFromEDID() isn't supported (failed). +#define STATIC_SCREEN_WIDTH 1900 // Used (in RevoBoot v1.0.35 and greater) when USE_STATIC_DISPLAY_RESOLUTION is 1 and when + // USE_STATIC_DISPLAY_RESOLUTION is 0 but getResolutionFromEDID() isn't supported (failed). -#define STATIC_SCREEN_HEIGHT 1200 // Used (in RevoBoot v1.0.35 and greater) when USE_STATIC_DISPLAY_RESOLUTION is 1 and when - // USE_STATIC_DISPLAY_RESOLUTION is 0 but getResolutionFromEDID() isn't supported (failed). +#define STATIC_SCREEN_HEIGHT 1200 // Used (in RevoBoot v1.0.35 and greater) when USE_STATIC_DISPLAY_RESOLUTION is 1 and when + // USE_STATIC_DISPLAY_RESOLUTION is 0 but getResolutionFromEDID() isn't supported (failed). -#define DEBUG_BOOT_GRAPHICS 0 // Set to 0 by default. Use 1 when to see debug info. +#define BLACKMODE 1 // Show white Apple logo on a black background. Set to 0 for gray mode. +#define UISCALE_2X 0 // Set to 0 by default. Use 1 for HiDPI mode. -//------------------------------------------------------------ STRINGDATA.H ---------------------------------------------------------------- +#define DEBUG_BOOT_GRAPHICS 0 // Set to 0 by default. Use 1 when to see debug info. -#define LION_FILEVAULT_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot skip encrypted boot partitions - // and boot from the Recovery HD partition instead (when available). -#if LION_FILEVAULT_SUPPORT - #define LION_RECOVERY_SUPPORT 1 // Make RevoBoot search for the Recovery HD partition and boot from it (when available). -#else - #define LION_RECOVERY_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot search for the Recovery HD and - // try to boot from it, when it is properly setup and modified for RevoBoot. -#endif +//------------------------------------------------------------ STRINGTABLE.H ---------------------------------------------------------------- -#define LION_INSTALL_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot search in specific directories - // for com.apple.Boot.plist – required for Mac like Lion OS X installations. +#define INSTALL_ESD_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot search in specific directories + // for com.apple.Boot.plist – required for Mac like installations of OS X. + +#if (RECOVERY_HD_SUPPORT == 1 && INSTALL_ESD_SUPPORT == 0) + #define INSTALL_ESD_SUPPORT 1 // This setting is mandatory for RECOVERY_HD_SUPPORT +#endif //-------------------------------------------------------------- SMBIOS.C ------------------------------------------------------------------ @@ -331,33 +414,81 @@ #undef USE_STATIC_CPU_DATA // Prevent boot failures due to wrong settings (until I figured out what we are missing). #endif +#if USE_STATIC_SMBIOS_DATA + #define LOAD_MODEL_SPECIFIC_SMBIOS_DATA 0 // Set to 0 by default. Change this to 1 to load: /Extra/SMBIOS/[MacModelNN].bin +#endif + #define OVERRIDE_DYNAMIC_MEMORY_DETECTION 0 // Set to 0 by default. Change this to 0 only when your SMBIOS data (type 17) is correct, or when // you want/need to override some/all of the SMBIOS data. // // Note: Defaults to n MB 1066 DDR3 when set to 0 (to prevent errors in Profile Manager). -#define TARGET_MODEL MACMINI // Set to MACMINI by default. Supported models are: - // - // IMAC and IMAC_131, IMAC_122, IMAC_111, IMAC_121 - // MACBOOK and MACBOOK_41 - // MACBOOKAIR and MACBOOKAIR_42, MACBOOKAIR_41 - // MACBOOKPRO and MACBOOKPRO_101, MACBOOKPRO_91, MACBOOKPRO_83, MACBOOKPRO_82, - // MACBOOKPRO_81, MACBOOKPRO_61 - // MACMINI and MACMINI_53, MACMINI_52, MACMINI_51 - // MACPRO and MACPRO_51, MACPRO_41, MACPRO_31 - // - // Note: MACMINI (without _NNN) selects the default model (last one i.e. MACMINI_51). +#define TARGET_MODEL MACMINI // Set to MACMINI by default. Supported models are: + // + // IMAC and IMAC_171, IMAC_16n, IMAC_15n, IMAC_14n, IMAC_131, IMAC_12n, IMAC_111 + // MACBOOK and MACBOOK_41 + // MACBOOKAIR and MACBOOKAIR_42, MACBOOKAIR_41 + // MACBOOKPRO and MACBOOKPRO_101, MACBOOKPRO_91, MACBOOKPRO_83, MACBOOKPRO_82, + // MACBOOKPRO_81, MACBOOKPRO_61 + // MACMINI and MACMINI_53, MACMINI_52, MACMINI_51 + // MACPRO and MACPRO_51, MACPRO_41, MACPRO_31 + // + // Note: MACMINI (without _NNN) selects the default model (last one i.e. MACMINI_51). + +#define SMB_SYSTEM_SERIAL_NUMBER "SOMESRLNUMBR" // Example only! + +#define SMB_BOARD_SERIAL_NUMBER "SOMESRLNUMBR" // Example only! + // + // Note: Board serial injection is required for iMessage support! + +#define SMB_STATIC_SYSTEM_UUID { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 } // Example only! + +#define SET_MAX_STRUCTURE_LENGTH 0 // Set to 0 by default. Only change this to 1 when boot hangs without it. + // + // Note: Safe to keep at 0 since it is only available since RevoBoot v1.5.35 #define DEBUG_SMBIOS 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. + +//-------------------------------------------------------------- PATCHER.C ----------------------------------------------------------------- + +#define PATCH_KERNEL 1 // Set to 1 by default. + // + // Note: A value of 0 will trigger a panic without a prelinkedkernel, and your computer may + // not boot without patches. + + // + // Override value examples: + // + // Use -8 for Broadwell E to Broadwell H + // Use -3 for Haswell E to Haswell + // Use 3 for Ivy Bridge to Haswell (untested and unconfirmed). + // Use 2 for Ivy Bridge E to Haswell (untested and unconfirmed). + // +#define PATCH_XCPM_BOOTSTRAP 0 // Set to 0 by default. Change this to the value that you want for your processor. + +#define PATCH_CPUID_SET_INFO 0 // Set to 0 by default. Change this to the value that you want for your processor. + // + // Note: Not required for Haswell E and Ivy Bridge E processors. + // + +#define TARGET_XCPM_SCOPE_MSRS { 0xE2, 0x01A0, /* 0x01FC, */ 0x01AA, 0x0620, /* 0x064C, */ 0x063A, 0x0642 } + +#define DEBUG_KERNEL_PATCHER 0 // Set to 0 by default, and the following bits can be set: + // + // A value of 1 (bit-0) shows the symbol name, offset and address range. + // A value of 2 (bit-1) shows the patch status. + // A value of 4 (bit-2) shows the disabled MSR's. + //-------------------------------------------------------------- PLATFORM.C ---------------------------------------------------------------- #if USE_STATIC_SMBIOS_DATA - // Do nothing. -#elif OVERRIDE_DYNAMIC_MEMORY_DETECTION + // Do nothing. +#elif OVERRIDE_DYNAMIC_MEMORY_DETECTION // See settings under SMBIOS.c + // Setup RAM module info. Please note that you may have to expand this when you have more RAM modules. #define STATIC_RAM_SLOTS 4 // Number of RAM slots on mainboard. @@ -368,20 +499,28 @@ #define DYNAMIC_RAM_OVERRIDE_SIZE 0 // Set to 0 by default. Change this to 1 when you want to use override values (see below). #if DYNAMIC_RAM_OVERRIDE_SIZE - #define DYNAMIC_RAM_OVERRIDE_SIZES { SMB_MEM_SIZE_2GB, SMB_MEM_BANK_EMPTY, SMB_MEM_SIZE_2GB, SMB_MEM_BANK_EMPTY, 0 } // See libsaio/platform.h for other values. + #define DYNAMIC_RAM_OVERRIDE_SIZES { SMB_MEM_SIZE_2GB, SMB_MEM_BANK_EMPTY, SMB_MEM_SIZE_2GB, SMB_MEM_BANK_EMPTY, 0 } // See libsaio/platform.h for other values. #endif #define DYNAMIC_RAM_OVERRIDE_FREQUENCY 0 // Set to 0 by default. Change this to the frequency that you want to use as override value. - #define STATIC_RAM_PART_NUMBERS { "PartNum#0", "N/A", "PartNum#2", "N/A", 0 } // Use "N/A" for empty RAM banks. + #define STATIC_RAM_PART_NUMBERS { "PartNum#0", "N/A", "PartNum#1", "N/A", 0 } // Use "N/A" for empty RAM banks. - #define STATIC_RAM_SERIAL_NUMBERS { "Serial#0", "N/A", "Serial#2", "N/A", 0 } // Use "N/A" for empty RAM banks. + #define STATIC_RAM_SERIAL_NUMBERS { "Serial#0", "N/A", "Serial#2", "N/A", 0 } // Use "N/A" for empty RAM banks. #endif #define INCLUDE_MPS_TABLE 0 // Set to 0 by default. Change this to 1 when you want to include the MP table. +#define LOAD_MODEL_SPECIFIC_STATIC_DATA (LOAD_MODEL_SPECIFIC_ACPI_DATA || LOAD_MODEL_SPECIFIC_EFI_DATA || LOAD_MODEL_SPECIFIC_SMBIOS_DATA) + #define DEBUG_PLATFORM 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. +//---------------------------------------------------------------- XHCI.H ------------------------------------------------------------------ -//================================================================= END ==================================================================== +#define DISABLE_LEGACY_XHCI 0 // Set to 0 by default. Change this to 1 when you need to disable legacy XHCI. + +#define DEBUG_XHCI 0 + + +//================================================================= END ==================================================================== diff --git a/i386/config/settings.h b/i386/config/settings.h index 263eba5..09da11a 100644 --- a/i386/config/settings.h +++ b/i386/config/settings.h @@ -1,387 +1,19 @@ /* - * Copyright (c) 2009 Master Chief. All rights reserved. - * - * Note: This is an essential part of the build process for RevoBoot v1.5.00 and greater. + * Copyright (c) 2009 Master Chief. * * Updates: * - * - Latest cleanups and additional directives added by DHP in 2011. - * - Static CPU data simplified by DHP in Juni 2011 (thanks to MC and flAked for the idea). - * - Automatic creation / injection of SSDT_PR.aml added by DHP in June 2011. - * - New compiler directive (BOOT_TURBO_BOOST_RATIO) added by Jeroen (June 2011). - * - SMBIOS data logic moved to preprocessor code (PikerAlpha, October 2012). - * - STATIC_MODEL_NAME moved to libsaio/i386/SMBIOS/model_data.h (PikerAlpha, October 2012). - * - STATIC_MAC_PRODUCT_NAME moved to libsaio/i386/SMBIOS/model_data.h (PikerAlpha, October 2012). - * - STATIC_SMBIOS_MODEL_ID rrenamed to TARGET_MODEL (PikerAlpha, October 2012). - * - OVERRIDE_DYNAMIC_PRODUCT_DETECTION removed/no longer supported (PikerAlpha, October 2012). - * - INTEL_CORE_TECHNOLOGY per default set to 1 (PikerAlpha, October 2012). - * + * - Read settings file based on given model identifier (PikerAlpha, October 2012). + * - COMMA_STRIPPED_MODEL_ID added (PikerAlpha, November 2012). */ +#define TO_STRING_DO(a) #a +#define STRING(a) TO_STRING_DO(a) -//--------------------------------------------------------------- ACPI.C ------------------------------------------------------------------- - - -#define ACPI_10_SUPPORT 0 // Set to 0 by Default. Set to 1 for ACPI 1.0 compliant BIOS versions. - // - // Note: Must go first (before acpi/essentials) since it is used there, - // and requires you to set PATCH_ACPI_TABLE_DATA to 1. - - -#define PATCH_ACPI_TABLE_DATA 1 // Set to 1 by default (enabling patching). Use 0 to keep the original - // unmodified ACPI tables, but please note (very well) that this is - // only supported by very few motherboards / BIOS'es. You may also - // need a kext like OSXRestart.kext to be able to restart your system, - // this due to a possibly broken FACP table in your BIOS! - // - // Note: Requires one of the following STATIC_* and/or LOAD_* settings: - - -#define USE_STATIC_ACPI_BASE_ADDRESS 0 // Set to 0 by default. Use 1 only after gathering the base address! - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#if USE_STATIC_ACPI_BASE_ADDRESS - #define STATIC_ACPI_BASE_ADDRESS 0x000f0450 // Set DEBUG_ACPI to 1 to get this address. -#endif - - -#define STATIC_APIC_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject a modified copy - // with say stripped out unused CPU's or other required modifications. - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define STATIC_APIC2_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject a second APIC - // (ACPI-1) table data for additional CPU core support. - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define STATIC_DSDT_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject static DSDT data. - - -#define STATIC_ECDT_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when want to inject a custom ECDT table. - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define STATIC_FACS_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when want to inject a custom FACS table. - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define STATIC_HPET_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject a static copy - // of a custom HPET table. - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define STATIC_SSDT_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject modifications - // that can / should be done from this ACPI table. - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define STATIC_SSDT_GPU_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject modifications - // for your graphics card (like I do for my ATI PCI-E card). - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define STATIC_SSDT_PR_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when you want to inject your Intel - // SpeedStep related modifications (like I do). - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define STATIC_SSDT_SATA_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when want to inject SATA related modifications. - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define STATIC_SSDT_USB_TABLE_INJECTION 0 // Set to 0 by default. Use 1 when want to inject USB related modifications. - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define LOAD_DSDT_TABLE_FROM_EXTRA_ACPI 1 // Set to 0 by default. Use 1 when your setup requires a modified DSDT table - // and you want to load: /Extra/ACPI/dsdt.aml instead of injecting a static - // DSDT table from: RevoBoot/i386/config/ACPI/data.h - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define LOAD_SSDT_TABLE_FROM_EXTRA_ACPI 0 // Set to 1 by default. Use 0 only after you've converted your SSDT into - // STATIC_SSDT_TABLE_INJECTION in: RevoBoot/i386/config/ACPI/data.h - // or when you don't want/need to load /Extra/ACPI/SSDT.aml - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - - -#define LOAD_EXTRA_ACPI_TABLES (LOAD_DSDT_TABLE_FROM_EXTRA_ACPI || LOAD_SSDT_TABLE_FROM_EXTRA_ACPI) - - -#define AUTOMATIC_SSDT_PR_CREATION 1 // Set to 0 by default (support for Sandy Bridge only). - // - // This injects a custom SSDT (in configure mode) with: - // - // Use 1 to inject: P/C-State definition blocks. - // Use 2 to inject: Processor (CPUn, 0x0n, 0x00000410, 0x06) {...} declaration blocks. - // Use 3 to inject: Both of the above. - // Use 4 to inject: Device (SBUS) {...} which is required for Power Management. - // Use 5 to inject: P/C-State definition blocks plus the former (Device SBUS). - // Use 7 to inject: All of the above. - // - // Notes: Device SBUS can only be injected when it isn't part of other ACPI tables! - // This feature should only be used once, to extract the SSDT_PR from ioreg - // and use it as STATIC_SSDT_PR_TABLE_DATA in RevoBoot/i386/config/ACPI/data.h - - -#if AUTOMATIC_SSDT_PR_CREATION && STATIC_SSDT_PR_TABLE_INJECTION == 0 - #define MAX_NUMBER_OF_P_STATES 22 // The i5-2500K need 18 for the base-range (1600-3300) plus 4 for the Turbo modes. - // The i7-2600K need 19 for the base-range (1600-3400) plus 4 for the Turbo modes. - // The i7-2700K need 20 for the base-range (1600-3500) plus 4 for the Turbo modes. - // The i7-3770K need 20 for the base-range (1600-3500) plus 4 for the Turbo modes. - // Low power (mobility) processors might need an extended range! - // - // Note: AICPUPM wants a P-State for each 100 MHz bank or it will fail (see note below). - -#define DROP_FACTORY_SSDT_TABLES 1 // Set to 1 by default (this setting is required). - // - // Note: Do not change this setting (must drop SSDT tables). - -#define NUMBER_OF_TURBO_STATES 4 // Set to 4 by default. - // - // Note: Make sure to add a full range, one P-State for each 100 MHz when OC'ing - // or AICPIPM will fail with: "P-State Stepper Error 18 at step N on CPU N" - -#define OVERRIDE_ACPI_METHODS 0 // Set to 0 by default (do nothing). - // Use 1 to override Method _PTS in a static SSDT or Extra/ACPI/SSDT.aml - // Use 2 to override Method _WAK in a static SSDT or Extra/ACPI/SSDT.aml - // Use 3 to override both _PTS and _WAK. - // - // Note: This changes the underscore of _PTS and/or _WAK into a "Z" which - // allows you to inject a customized copy from /Extra/ACPI/SSDT.aml -#else - #define OVERRIDE_ACPI_METHODS 0 // Set to 0 by default (do nothing). - - #define DROP_FACTORY_SSDT_TABLES 0 // Set to 0 by default. Use 1 with caution (might disable SpeedStep). -#endif - -#define REPLACE_EXISTING_SSDT_TABLES 0 // Set to 0 by default. Use 1 with caution (might disable SpeedStep). - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1. - -#define APPLE_STYLE_ACPI 0 // Set to 0 by default. Use 1 to change the OEMID's to Mac likes. - // - // Note: Don't forget to set PATCH_ACPI_TABLE_DATA to 1 and keep in mind that this can - // only change the headers of injected/replaced tables. Not the factory tables. - - -#define DEBUG_ACPI 0 // Set to 0 by default. Use 1 when things don't seem to work for you. - - -//--------------------------------------------------------------- BOOT.C ------------------------------------------------------------------- - - -#define PRE_LINKED_KERNEL_SUPPORT 1 // Set to 1 by default. Change this to 0 to disable the use of pre-linked kernels. - -#define MUST_ENABLE_A20 0 // Set to 0 by default. Change this to 1 when your hardware requires it. - -#define SAFE_MALLOC 0 // Set to 0 by default. Change this to 1 when booting halts with a memory allocation error. - -#define DEBUG_BOOT 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. - - -//---------------------------------------------------------------- CPU.C ------------------------------------------------------------------- - - -#define USE_STATIC_CPU_DATA 1 // Set to 0 by default (dynamic data collection). Change this to 1 to use static data. - -#define CPU_VENDOR_ID CPU_VENDOR_INTEL // CPU_VENDOR_AMD is not supported. - -#define INTEL_CORE_TECHNOLOGY 1 // Set to 1 by default. Use 0 for older non Intel Core CPU's (removes unused code). - // - // Warning: Do not use 0 on Core Technology CPU's or sysctl's machdep.tsc.frequency will be - // initialized with the wrong value (various things, like the spinner will go mad). - -#define OC_BUSRATIO_CORRECTION 0 // Set to 0 by default. Change this to busratio-100 (OC'ed systems with a changed busratio). - -#define BOOT_TURBO_RATIO 0 // Set to 0 by default. Change this to the desired (and supported) max turbo multiplier. - // - // Example: 0x2800 for 4.0 GHz on a i7-2600. - -#define DEBUG_CPU 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. - // Note: CPU info data will not be displayed when USE_STATIC_CPU_DATA is set to 1 - -#if DEBUG_CPU -#define DEBUG_CPU_TURBO_RATIOS 0 // Set to 0 by default. Change this to 1 when you want to check the core ratio. - -#define DEBUG_CST_SUPPORT 0 // Set to 0 by default. Change this to 1 to check the in BIOS enabled C-States. - -#define DEBUG_TSS_SUPPORT 0 // Set to 0 by default. Change this to 1 to check the T-State Clock Modulation. - -#define DEBUG_CPU_TDP 0 // Set to 0 by default. Change this to 1 when you want to check the TDP. -#endif - -//---------------------------------------------------------- CPU/STATIC_DATA.C ------------------------------------------------------------- - - -#if USE_STATIC_CPU_DATA - #define STATIC_CPU_Type 0x602 // kSMBTypeOemProcessorType - used in: libsaio/SMBIOS/dynamic_data.h - - #define STATIC_CPU_NumThreads 4 // Used in: i386/libsaio/ACPI/ssdt_pr_generator.h - - #define STATIC_CPU_FSBFrequency 100000000ULL // 9 digits + ULL - used in: i386/libsaio/efi.c - - #define STATIC_CPU_QPISpeed 0 // kSMBTypeOemProcessorBusSpeed (0 for Sandy Bridge / Jaketown). -#endif - -#define STATIC_CPU_NumCores 4 // Set to 4 by default. Must be set to the number of cores for your processor! - // - // Note: Used in i386/libsaio/ACPI/ssdt_pr_generator.h, cpu.c and platform.c - // for both static and dynamic CPU data. - -//--------------------------------------------------------------- DISK.C ------------------------------------------------------------------- - - -#define EFI_SYSTEM_PARTITION_SUPPORT 0 // Set to 0 by default. Set this to 1 when your system boots from the hidden EFI partition. - -#define LEGACY_BIOS_READ_SUPPORT 0 // Set to 0 by default. Change this to 1 for crappy old BIOSes. - -#define LION_FILEVAULT_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot skip encrypted boot partitions - // and boot from the Recovery HD partition instead (when available). - -#define APPLE_RAID_SUPPORT 0 // Set to 0 by default. Change this to 1 for Apple Software RAID support. - -#define DEBUG_DISK 0 // Set to 0 by default. Change it to 1 when things don't seem to work for you. - - -//------------------------------------------------------------- DRIVERS.C ------------------------------------------------------------------- - - -#define DEBUG_DRIVERS 0 // Set to 0 by default. Change it to 1 when things don't seem to work for you. - - -//---------------------------------------------------------------- EFI.C ------------------------------------------------------------------- - - -#define APPLE_STYLE_EFI 1 // Set to 1 by default. Change this to 1 to add additional 'Mac-like' properties. - -#define INJECT_EFI_DEVICE_PROPERTIES 0 // Set to 0 by default. Change this to 1 when you need to inject 'device-properties'. - // - // Note: Required when not setting device-properties from your DSDT/SSDT. - -#define EFI_64_BIT 1 // Set to 1 by default for EFI64 on 64-bit platforms. Supporting both - // 32 and 64-bit boot modes (using arch=i386/x86_64 under Kernel Flags). - // - // Change this to 0 for 32-bit only platforms (think Intel Atom CPU) - // or when you want to boot with EFI32 (for testing) on a 64-bit - // platform, but then you must make a small change in platform.c (see comment in file). - // - // Note: Do not change this setting, unless you know what you are doing. - -#define STATIC_SMSERIALNUMBER "SOMESRLNUMBR" // Example only! - -#define STATIC_SYSTEM_SERIAL_NUMBER { 'S', 'O', 'M', 'E', 'S', 'R', 'L', 'N', 'U', 'M', 'B', 'R' } // Example only! - -#define STATIC_SYSTEM_ID { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F } // Example only! - -#define DEBUG_EFI 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. - -#define EFI_DEBUG_MODE 0 // Set to 0 by default (for OS X 10.7 LION only). - - -//------------------------------------------------------------- GRAPHICS.C ----------------------------------------------------------------- - -#define USE_STATIC_DISPLAY_RESOLUTION 1 // Set to 0 by default. Use 1 when you need to override the resolution detection features - // in RevoBoot, which may not be supported by your BIOS and/or display (monitor). - -#define STATIC_SCREEN_WIDTH 1900 // Used (in RevoBoot v1.0.35 and greater) when USE_STATIC_DISPLAY_RESOLUTION is 1 and when - // USE_STATIC_DISPLAY_RESOLUTION is 0 but getResolutionFromEDID() isn't supported (failed). - -#define STATIC_SCREEN_HEIGHT 1200 // Used (in RevoBoot v1.0.35 and greater) when USE_STATIC_DISPLAY_RESOLUTION is 1 and when - // USE_STATIC_DISPLAY_RESOLUTION is 0 but getResolutionFromEDID() isn't supported (failed). - -#define DEBUG_BOOT_GRAPHICS 0 // Set to 0 by default. Use 1 when to see debug info. - - -//------------------------------------------------------------ STRINGDATA.H ---------------------------------------------------------------- - -#define LION_FILEVAULT_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot skip encrypted boot partitions - // and boot from the Recovery HD partition instead (when available). - -#if LION_FILEVAULT_SUPPORT - #define LION_RECOVERY_SUPPORT 1 // Make RevoBoot search for the Recovery HD partition and boot from it (when available). -#else - #define LION_RECOVERY_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot search for the Recovery HD and - // try to boot from it, when it is properly setup and modified for RevoBoot. -#endif - -#define LION_INSTALL_SUPPORT 0 // Set to 0 by default. Setting this to 1 will make RevoBoot search in specific directories - // for com.apple.Boot.plist – required for Mac like Lion OS X installations. - -//-------------------------------------------------------------- SMBIOS.C ------------------------------------------------------------------ - - -#define USE_STATIC_SMBIOS_DATA 0 // Set to 0 by default (dynamic data collection). Change this to 1 to use static data. - -#if (USE_STATIC_SMBIOS_DATA == 0 && USE_STATIC_CPU_DATA == 1) - #undef USE_STATIC_CPU_DATA // Prevent boot failures due to wrong settings (until I figured out what we are missing). -#endif - -#define OVERRIDE_DYNAMIC_MEMORY_DETECTION 0 // Set to 0 by default. Change this to 0 only when your SMBIOS data (type 17) is correct, or when - // you want/need to override some/all of the SMBIOS data. - // - // Note: Defaults to n MB 1066 DDR3 when set to 0 (to prevent errors in Profile Manager). - - -#define TARGET_MODEL MACMINI // Set to MACMINI by default. Supported models are: - // - // IMAC and IMAC_131, IMAC_122, IMAC_111, IMAC_121 - // MACBOOK and MACBOOK_41 - // MACBOOKAIR and MACBOOKAIR_42, MACBOOKAIR_41 - // MACBOOKPRO and MACBOOKPRO_101, MACBOOKPRO_91, MACBOOKPRO_83, MACBOOKPRO_82, - // MACBOOKPRO_81, MACBOOKPRO_61 - // MACMINI and MACMINI_53, MACMINI_52, MACMINI_51 - // MACPRO and MACPRO_51, MACPRO_41, MACPRO_31 - // - // Note: MACMINI (without _NNN) selects the default model (last one i.e. MACMINI_51). - -#define DEBUG_SMBIOS 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. - - -//-------------------------------------------------------------- PLATFORM.C ---------------------------------------------------------------- - - -#if USE_STATIC_SMBIOS_DATA - // Do nothing. -#elif OVERRIDE_DYNAMIC_MEMORY_DETECTION - // Setup RAM module info. Please note that you may have to expand this when you have more RAM modules. - #define STATIC_RAM_SLOTS 4 // Number of RAM slots on mainboard. - - #define STATIC_RAM_VENDORS { "Corsair", "N/A", "Corsair", "N/A", 0 } // Use "N/A" for empty RAM banks. - - #define DYNAMIC_RAM_OVERRIDE_TYPE 0 // Set to 0 by default. See libsaio/platform.h for supported values. - - #define DYNAMIC_RAM_OVERRIDE_SIZE 0 // Set to 0 by default. Change this to 1 when you want to use override values (see below). - -#if DYNAMIC_RAM_OVERRIDE_SIZE - #define DYNAMIC_RAM_OVERRIDE_SIZES { SMB_MEM_SIZE_2GB, SMB_MEM_BANK_EMPTY, SMB_MEM_SIZE_2GB, SMB_MEM_BANK_EMPTY, 0 } // See libsaio/platform.h for other values. -#endif - - #define DYNAMIC_RAM_OVERRIDE_FREQUENCY 0 // Set to 0 by default. Change this to the frequency that you want to use as override value. - - #define STATIC_RAM_PART_NUMBERS { "PartNum#0", "N/A", "PartNum#2", "N/A", 0 } // Use "N/A" for empty RAM banks. - - #define STATIC_RAM_SERIAL_NUMBERS { "Serial#0", "N/A", "Serial#2", "N/A", 0 } // Use "N/A" for empty RAM banks. -#endif - -#define INCLUDE_MPS_TABLE 0 // Set to 0 by default. Change this to 1 when you want to include the MP table. - -#define DEBUG_PLATFORM 0 // Set to 0 by default. Change this to 1 when things don't seem to work for you. - - -//================================================================= END ==================================================================== +#include STRING(SETTINGS_FILE) +/* + * gPlatform.ModelID is a char * initialized by a call to strdup(SMB_PRODUCT_NAME) in + * platform.c and we use strdup once more here so that gPlatform.ModelID is untouched. + */ +#define COMMA_STRIPPED_MODEL_ID removeChar(strdup(gPlatform.ModelID), ',') diff --git a/i386/libsa/Makefile b/i386/libsa/Makefile index 633e3b3..d444af7 100644 --- a/i386/libsa/Makefile +++ b/i386/libsa/Makefile @@ -1,70 +1,46 @@ -DIR = libsa +# +# File: RevoBoot/i386/libsa/Makefile +# +# Updates: +# +# - Major cleanup (PikerAlpha, October 2012). +# - Output added for rm/ar/ranlib actions (PikerAlpha, November 2012). +# - Enabled clang compilation (dgsga, November 2012. Credits to Evan Lojewski for original work). +# - Output change and now using libtool instead of ar/ranlib (PikerAlpha, November 2012). +# - efi_table.c renamed to crc32.c (PikerAlpha, November 2012). +# + include ../MakePaths.dir UTILDIR = ../util LIBSAIODIR = ../libsaio -INSTALL_SA_DIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/standalone -INSTALL_MD_DIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/machdep/i386 OPTIM = -Os -Oz -CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror \ - -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \ - -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \ - -march=pentium4 -msse2 -mfpmath=sse -msoft-float +CFLAGS = $(RC_CFLAGS) $(OPTIM) -arch i386 -g -Wmost -Werror \ + -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \ + -DSETTINGS_FILE=SETTINGS/$(MAKE_TARGET_MODEL).h \ + -fno-stack-protector \ + -march=pentium4 -msse2 -msoft-float INC = -I. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSAIODIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = ld -# LIBS= -lc_static -LIBS= VPATH = $(OBJROOT):$(SYMROOT) -#SA_OBJS = prf.o printf.o zalloc.o \ -# string.o strtol.o error.o \ -# setjmp.o qsort.o efi_tables.o -SA_OBJS = prf.o printf.o zalloc.o \ - string.o strtol.o \ - setjmp.o efi_tables.o - -SFILES = setjmp.s -#CFILES = prf.c printf.c zalloc.c \ -# string.c strtol.c error.c \ -# qsort.c efi_tables.c -CFILES = prf.c printf.c zalloc.c \ - string.c strtol.c \ - efi_tables.c +SA_OBJS = prf.o printf.o zalloc.o string.o strtol.o crc32.o -HFILES = allocate.h -EXPORTED_HFILES = libsa.h allocate.h -INSTALLED_SA_HFILES = libsa.h -OTHERFILES = Makefile -ALLSRC = $(SFILES) $(CFILES) $(HFILES) $(OTHERFILES) LIBS = libsa.a -DIRS_NEEDED = $(OBJROOT) $(SYMROOT) -lion: all -mountain-lion: all - -all: $(DIRS_NEEDED) $(LIBS) +DIRS_NEEDED = $(OBJROOT) $(SYMROOT) -libsa.a: $(SA_OBJS) - rm -f $(SYMROOT)/$(@F) - ar q $(SYMROOT)/$(@F) $^ - ranlib $(SYMROOT)/$(@F) +$(MAKEGOAL): $(DIRS_NEEDED) $(LIBS) -$(INSTALL_SA_DIR) $(INSTALL_MD_DIR): - $(MKDIRS) $@ +$(LIBS): $(SA_OBJS) + @if [ -f $(SYMROOT)/$@ ]; then \ + echo "\t[RM] $@"; \ + rm -f $(SYMROOT)/$@; \ + fi; -installhdrs:: $(INSTALL_SA_DIR) $(INSTALL_MD_DIR) - cp $(INSTALLED_SA_HFILES) $(INSTALL_SA_DIR) + @echo "\t[LIBTOOL] $@" + @libtool -o $(SYMROOT)/$@ $^ include ../MakeInc.dir - -# dependencies --include $(OBJROOT)/Makedep diff --git a/i386/libsa/efi_tables.c b/i386/libsa/crc32.c old mode 100755 new mode 100644 similarity index 66% rename from i386/libsa/efi_tables.c rename to i386/libsa/crc32.c index b6d5113..c906054 --- a/i386/libsa/efi_tables.c +++ b/i386/libsa/crc32.c @@ -1,15 +1,4 @@ -/*! @file efi_tables.c - Copyright 2007 David F. Elliott. All rights reserved. - */ -#include "libsa.h" -#include "efi_tables.h" - - -/*========================================================================== - * CRC32 implementation copied from xnu in turn copied from Gary S. Brown. - */ - -/*- +/* * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or * code or tables extracted from it, as desired without restriction. * @@ -47,22 +36,32 @@ * using byte-swap instructions * polynomial $edb88320 * + * Updates: + * - All but crc32 code moved to guid.c (PikerAlpha, November 2012) + * - File renamed from efi_tables.c to crc32.c (PikerAlpha, November 2012) + * - Copyright restored to original developer (PikerAlpha, November 2012) * - * CRC32 code derived from work by Gary S. Brown. */ -static uint32_t crc32_tab[] = { + +#include "libsa.h" + +//========================================================================== +// This data block can also be found in boot.efi + +static uint32_t crc32Table[] = +{ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, @@ -97,70 +96,19 @@ static uint32_t crc32_tab[] = { 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; -uint32_t crc32(uint32_t crc, const void *buf, size_t size) -{ - const uint8_t *p; - - p = buf; - crc = crc ^ ~0U; - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); +//========================================================================== - return crc ^ ~0U; -} - - -/*========================================================================== - * Utility function to make a device tree string from an EFI_GUID - */ - -void efi_guid_unparse_upper(EFI_GUID const *pGuid, char *out) +uint32_t crc32(uint32_t aCRC, const void *aBuffer, size_t aSize) { - sprintf(out, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", - pGuid->Data1, /* - */ - pGuid->Data2, /* - */ - pGuid->Data3, /* - */ - pGuid->Data4[0], pGuid->Data4[1], /* - */ - pGuid->Data4[2], pGuid->Data4[3], - pGuid->Data4[4], pGuid->Data4[5], - pGuid->Data4[6], pGuid->Data4[7]); -} + const uint8_t *p = aBuffer; -bool efi_guid_is_null(EFI_GUID const *pGuid) -{ - if (pGuid->Data1 == 0 && pGuid->Data2 == 0 && pGuid->Data3 == 0) - { - int i; + aCRC = aCRC ^ ~0U; - for (i = 0; i < 8; ++i) - { - if (pGuid->Data4[i] != 0) - return false; - } - return true; - } + while (aSize--) + { + aCRC = crc32Table[(aCRC ^ *p++) & 0xFF] ^ (aCRC >> 8); + } - return false; + return (aCRC ^ ~0U); } - -#define COMPARE_MEMBER_AND_RETURN_IF_NE(a,b,mem) \ - if( ((a)->mem) < ((b)->mem) ) \ - return -1; \ - else if( ((a)->mem) > ((b)->mem) ) \ - return 1; - -int efi_guid_compare(EFI_GUID const *pG1, EFI_GUID const *pG2) -{ - COMPARE_MEMBER_AND_RETURN_IF_NE(pG1, pG2, Data1); - COMPARE_MEMBER_AND_RETURN_IF_NE(pG1, pG2, Data2); - COMPARE_MEMBER_AND_RETURN_IF_NE(pG1, pG2, Data3); - int i; - - for(i = 0; i < 8; ++i) - { - COMPARE_MEMBER_AND_RETURN_IF_NE(pG1, pG2, Data4[i]); - } - return 0; -} - diff --git a/i386/libsa/efi_tables.h b/i386/libsa/efi_tables.h deleted file mode 100755 index 7976437..0000000 --- a/i386/libsa/efi_tables.h +++ /dev/null @@ -1,16 +0,0 @@ -/*! @file efi_tables.h - @abstract Utility functions for dealing with EFI tables - Copyright 2007 David F. Elliott. All rights reserved. - */ -#ifndef _LIBSA_EFI_TABLES_H__ -#define _LIBSA_EFI_TABLES_H__ - -#include "efi/essentials.h" - -uint32_t crc32(uint32_t crc, const void *buf, size_t size); - -void efi_guid_unparse_upper(EFI_GUID const *pGuid, char *out); -bool efi_guid_is_null(EFI_GUID const *pGuid); -int efi_guid_compare(EFI_GUID const *pG1, EFI_GUID const *pG2); - -#endif //ndef _LIBSA_EFI_TABLES_H__ diff --git a/i386/libsa/libsa.h b/i386/libsa/libsa.h index 14d3ef8..b164c19 100755 --- a/i386/libsa/libsa.h +++ b/i386/libsa/libsa.h @@ -20,6 +20,10 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ + * + * Updates: + * - Use size_t instead of int when required (PikerAlpha, November 2012) + * */ #ifndef __BOOT_LIBSA_H @@ -38,10 +42,34 @@ /* * boot.c */ - extern int fastEnableA20(void); +/* + * crc32.c + */ +uint32_t crc32(uint32_t crc, const void *buf, size_t size); + + +/* + * getsegbyname.c + */ +extern struct segment_command * getsegbynamefromheader(struct mach_header * mhp, char * segname); + + +/* + * prf.c + */ +extern void prf(const char * fmt, va_list ap, void (*putfn_p)(), void * putfn_arg); + + +/* + * printf.c + */ +extern int sprintf(char *s, const char * format, ...); +extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg); + + /* * string.c */ @@ -53,36 +81,34 @@ extern int fastEnableA20(void); extern void bzero(void * dst, size_t len); #endif -extern void * memset(void * dst, int c, size_t n); -extern void * memcpy(void * dst, const void * src, size_t len); -extern int memcmp(const void * p1, const void * p2, int len); -extern int strcmp(const char * s1, const char * s2); -extern int strncmp(const char * s1, const char * s2, size_t n); extern char * strcpy(char * s1, const char * s2); extern char * strncpy(char * s1, const char * s2, size_t n); -extern char * strlcpy(char * s1, const char * s2, size_t n); + extern char * strstr(const char *in, const char *str); -extern int atoi(const char * str); -extern int ptol(const char * str); -extern int strlen(const char * str); extern char * strcat(char * s1, const char * s2); extern char * strncat(char * s1, const char * s2, size_t n); extern char * strdup(const char *s1); +extern void * memset(void * dst, int c, size_t n); +extern void * memcpy(void * dst, const void * src, size_t len); + +extern int strcmp(const char * s1, const char * s2); +extern int strncmp(const char * s1, const char * s2, size_t n); +extern int atoi(const char * str); +extern int ptol(const char * str); + +extern int memcmp(const void * p1, const void * p2, size_t len); + +extern size_t strlcpy(char * s1, const char * s2, size_t n); +extern size_t strlen(const char * str); + #if STRNCASECMP extern int strncasecmp(const char * s1, const char * s2, size_t n); #endif -extern uint8_t checksum8( void * start, unsigned int length ); - -#if CHAMELEON - /* - * error.c - */ +extern uint8_t checksum8( void * start, unsigned int length); +char * removeChar(char *aSourceString, char aTargetChar); - extern int errno; - extern char * strerror(int errnum); -#endif /* * strtol.c @@ -91,16 +117,6 @@ extern long strtol(const char * nptr, char ** endptr, int base); extern unsigned long strtoul(const char * nptr, char ** endptr, int base); extern unsigned long long strtouq(const char *nptr, char ** endptr, int base); -/* - * prf.c - */ -extern void prf(const char * fmt, va_list ap, void (*putfn_p)(), void * putfn_arg); - -/* - * printf.c - */ -extern int sprintf(char *s, const char * format, ...); -extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg); /* * zalloc.c @@ -119,9 +135,4 @@ extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg); extern void free(void * start); extern void * realloc(void * ptr, size_t size); -/* - * getsegbyname.c - */ -extern struct segment_command * getsegbynamefromheader(struct mach_header * mhp, char * segname); - #endif /* !__BOOT_LIBSA_H */ diff --git a/i386/libsa/memory.h b/i386/libsa/memory.h index 13365e6..5d9fda6 100755 --- a/i386/libsa/memory.h +++ b/i386/libsa/memory.h @@ -86,13 +86,14 @@ #define HIB_LEN 0x00060000L // Size: 384 KB. // 0x000A0000L -#define VIDEO_ADDR (HIB_ADDR + HIB_LEN) // Unusable space. +#define VIDEO_ADDR (HIB_ADDR + HIB_LEN) // Unusable space. #define VIDEO_LEN 0x00060000L // Size: 384 KB. // 0x00100000L -#define KERNEL_ADDR (VIDEO_ADDR + VIDEO_LEN) // Kernel and MKexts/drivers. -#define KERNEL_LEN 0x04000000L // Size: 64 MB (128 MB for Chameleon). - +#define KERNEL_ADDR (VIDEO_ADDR + VIDEO_LEN) // Kernel and MKexts/drivers. +#define KERNEL_LEN 0x08000000L // Size: 128 MB. + // + // Note: Can cause a stop("Kernel overflows available space") // Based on KERNEL_LEN 0x04100000L #define ZALLOC_ADDR (KERNEL_ADDR + KERNEL_LEN) // Zalloc area. #define ZALLOC_LEN 0x10000000L // Size: 256 MB. @@ -106,7 +107,7 @@ #define PREBOOT_DATA (LOAD_ADDR + LOAD_LEN) // Room for a 195 MB RAM disk image (with 512 MB System Memory). -#define TFTP_ADDR LOAD_ADDR // TFTP download buffer (not used in Revolution). +#define TFTP_ADDR LOAD_ADDR // TFTP download buffer (not used in RevoBoot). #define TFTP_LEN LOAD_LEN @@ -120,17 +121,17 @@ #define vtop(vaddr) ((vaddr) + MEMBASE) // Extract segment/offset from a linear address. -#define OFFSET16(addr) ((addr) - BASE_ADDR) -#define OFFSET(addr) ((addr) & 0xFFFF) -#define SEGMENT(addr) (((addr) & 0xF0000) >> 4) +#define OFFSET16(addr) ((addr) - BASE_ADDR) +#define OFFSET(addr) ((addr) & 0xFFFF) +#define SEGMENT(addr) (((addr) & 0xF0000) >> 4) /* * Extract segment/offset in normalized form so that the resulting far pointer * will point to something that is very unlikely to straddle a segment. * This is sometimes known as a "huge" pointer. */ -#define NORMALIZED_OFFSET(addr) ((addr) & 0x000F) -#define NORMALIZED_SEGMENT(addr) (((addr) & 0xFFFF0) >> 4) +#define NORMALIZED_OFFSET(addr) ((addr) & 0x000F) +#define NORMALIZED_SEGMENT(addr) (((addr) & 0xFFFF0) >> 4) // We need a minimum of 32MB of system memory. #define MIN_SYS_MEM_KB (32 * 1024) diff --git a/i386/libsa/string.c b/i386/libsa/string.c index 6919fe9..5001837 100755 --- a/i386/libsa/string.c +++ b/i386/libsa/string.c @@ -20,11 +20,19 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ + * + * Updates: + * - Layout and white space changes (PikerAlpha, November 2012) + * - Use size_t instead of int when required (PikerAlpha, November 2012) + * */ -/* string operations */ + #include "libsa.h" + +//========================================================================== + void * memset(void * dst, int val, size_t len) { asm volatile ( "rep; stosb" @@ -36,6 +44,8 @@ void * memset(void * dst, int val, size_t len) } #if 0 +//========================================================================== + void * memcpy(void * dst, const void * src, size_t len) { asm volatile ( "rep; movsb" @@ -46,17 +56,25 @@ void * memcpy(void * dst, const void * src, size_t len) return dst; } + +//========================================================================== + void bcopy(const void * src, void * dst, size_t len) { memcpy(dst, src, len); } + +//========================================================================== + void bzero(void * dst, size_t len) { memset(dst, 0, len); } #else +//========================================================================== + void * memcpy(void * dst, const void * src, size_t len) { asm volatile ( "cld \n\t" @@ -73,6 +91,9 @@ void * memcpy(void * dst, const void * src, size_t len) return dst; } + +//========================================================================== + void bcopy(const void * src, void * dst, size_t len) { asm volatile ( "cld \n\t" @@ -87,6 +108,9 @@ void bcopy(const void * src, void * dst, size_t len) : "memory", "%edx" ); } + +//========================================================================== + void bzero(void * dst, size_t len) { asm volatile ( "xorl %%eax, %%eax \n\t" @@ -104,82 +128,140 @@ void bzero(void * dst, size_t len) #endif /* #if DONT_USE_GCC_BUILT_IN_STRLEN */ - #define tolower(c) ((int)((c) & ~0x20)) #define toupper(c) ((int)((c) | 0x20)) -int strlen(const char * s) +//========================================================================== + +size_t strlen(const char * s) { int n = 0; - while (*s++) n++; + + while (*s++) + { + n++; + } + return(n); } - /*#endif*/ + +//========================================================================== /* NOTE: Moved from ntfs.c */ -int memcmp(const void *p1, const void *p2, int len) + +int memcmp(const void *p1, const void *p2, size_t len) { - while (len--) { + while (len--) + { if (*(const char*)(p1++) != *(const char*)(p2++)) + { return -1; + } } + return 0; } + +//========================================================================== + int strcmp(const char * s1, const char * s2) { - while (*s1 && (*s1 == *s2)) { + while (*s1 && (*s1 == *s2)) + { s1++; s2++; } + return (*s1 - *s2); } + +//========================================================================== + int strncmp(const char * s1, const char * s2, size_t len) { register int n = len; + while (--n >= 0 && *s1 == *s2++) + { if (*s1++ == '\0') + { return(0); + } + } + return(n<0 ? 0 : *s1 - *--s2); } + +//========================================================================== + char * strcpy(char * s1, const char * s2) { register char *ret = s1; + while ((*s1++ = *s2++)) + { continue; + } + return ret; } + +//========================================================================== + char * strncpy(char * s1, const char * s2, size_t n) { register char *ret = s1; + while (n && (*s1++ = *s2++)) + { n--; + } + return ret; } -char * strlcpy(char * s1, const char * s2, size_t n) + +//========================================================================== + +size_t strlcpy(char * s1, const char * s2, size_t n) { register char *ret = s1; + while (n && (*s1++ = *s2++)) + { n--; - if (!n) *--s1=0; - return ret; + } + + if (!n) + { + *--s1=0; + } + + return strlen(ret); } + +//========================================================================== + char * strstr(const char *in, const char *str) { char c; size_t len; c = *str++; + if (!c) + { return (char *) in; // Trivial empty string case + } len = strlen(str); + do { char sc; @@ -193,72 +275,152 @@ char * strstr(const char *in, const char *str) return (char *) (in - 1); } + +//========================================================================== + int ptol(const char *str) { register int c = *str; if (c <= '7' && c >= '0') + { c -= '0'; + } else if (c <= 'h' && c >= 'a') + { c -= 'a'; - else c = 0; + } + else + { + c = 0; + } + return c; } + +//========================================================================== + int atoi(const char *str) { register int sum = 0; + while (*str == ' ' || *str == '\t') + { str++; - while (*str >= '0' && *str <= '9') { + } + + while (*str >= '0' && *str <= '9') + { sum *= 10; sum += *str++ - '0'; } return sum; } + +//========================================================================== + char *strncat(char *s1, const char *s2, size_t n) { register char *ret = s1; + while (*s1) + { s1++; + } + while (n-- && *s2) + { *s1++ = *s2++; + } + *s1 = '\0'; + return ret; } + +//========================================================================== + char *strcat(char *s1, const char *s2) { return(strncat(s1, s2, strlen(s2))); } -char *strdup(const char *s1) + +//========================================================================== + +char *strdup(const char *sourceString) { - return strcpy(malloc(strlen(s1) + 1), s1); + char * newString = (char *)malloc(strlen(sourceString) + 1); + + if (newString) + { + return strcpy(newString, sourceString); + } + + return NULL; } + #if STRNCASECMP +//========================================================================== int strncasecmp(const char *s1, const char *s2, size_t len) { register int n = len; + while (--n >= 0 && tolower(*s1) == tolower(*s2++)) + { if (*s1++ == '\0') + { return(0); + } + } + return(n<0 ? 0 : tolower(*s1) - tolower(*--s2)); } #endif + +//========================================================================== /* COPYRIGHT NOTICE: checksum8 from AppleSMBIOS */ -uint8_t checksum8( void * start, unsigned int length ) + +uint8_t checksum8(void * start, unsigned int length) { uint8_t csum = 0; uint8_t * cp = (uint8_t *) start; unsigned int i; - for ( i = 0; i < length; i++) + for (i = 0; i < length; i++) + { csum += *cp++; + } - return csum; + return (256 - csum); // ((255 - csum) + 1); } + +#if LOAD_MODEL_SPECIFIC_STATIC_DATA +//========================================================================== + +char * removeChar(char *aSourceString, char aTargetChar) +{ + char *source = aSourceString; + char *destination = aSourceString; + + for (; *source != '\0'; source++) + { + *destination = *source; + + if (*destination != aTargetChar) + { + destination++; + } + } + + *destination = '\0'; + + return (aSourceString); +} +#endif diff --git a/i386/libsa/strtol.c b/i386/libsa/strtol.c index 7ea6d3b..e321a21 100755 --- a/i386/libsa/strtol.c +++ b/i386/libsa/strtol.c @@ -65,90 +65,115 @@ * Removed dependency on _ctype_ by static versions of isupper()... * Added support for "0b101..." binary constants. * Commented out references to errno. + * + * Updates: + * - Layout and other readability improvements (PikerAlpha, November 2012). + * - Commented out references to errno removed (PikerAlpha, November 2012). + * - Unused #include libsa.h removed (PikerAlpha, November 2012). + * - Dependancy on removed (PikerAlpha, November 2012). + * */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ -#include "libsa.h" -#include +#define LONG_MAX 2147483647L /* max signed long */ +#define LONG_MIN (-2147483647L-1) /* min signed long */ + +#define ULONG_MAX 0xffffffffUL /* max unsigned long */ +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ + +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ + +#define UQUAD_MAX ULLONG_MAX +#define QUAD_MAX LLONG_MAX -static inline int -isupper(char c) -{ - return (c >= 'A' && c <= 'Z'); -} -static inline int -islower(char c) +//========================================================================== + +static inline int isupper(char c) { - return (c >= 'a' && c <= 'z'); + return (c >= 'A' && c <= 'Z'); } -static inline int -isalpha(char c) + +//========================================================================== + +static inline int isalpha(char c) { - return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); + return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); } -static inline int -isspace(char c) + +//========================================================================== + +static inline int isspace(char c) { - return (c == ' ' || c == '\t' || c == '\n' || c == '\12'); + return (c == ' ' || c == '\t' || c == '\n' || c == '\12'); } -static inline int -isdigit(char c) + +//========================================================================== + +static inline int isdigit(char c) { - return (c >= '0' && c <= '9'); + return (c >= '0' && c <= '9'); } -/* +/*========================================================================== * Convert a string to a long integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ -long -strtol(nptr, endptr, base) - const char *nptr; - char **endptr; - register int base; + +long strtol(const char *nptr, char **endptr, register int base) { register const char *s = nptr; - register unsigned long acc; + register int c; - register unsigned long cutoff; register int neg = 0, any, cutlim; + register unsigned long acc; + register unsigned long cutoff; + /* * Skip white space and pick up leading +/- sign if any. * If base is 0, allow 0x for hex and 0 for octal, else * assume decimal; if base is already 16, allow 0x. */ - do { + + do + { c = *s++; } while (isspace(c)); - if (c == '-') { + + if (c == '-') + { neg = 1; c = *s++; - } else if (c == '+') + } + else if (c == '+') + { c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { + } + + if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) + { c = s[1]; s += 2; base = 16; - } else if ((base == 0 || base == 2) && - c == '0' && (*s == 'b' || *s == 'B')) { + } + else if ((base == 0 || base == 2) && c == '0' && (*s == 'b' || *s == 'B')) + { c = s[1]; s += 2; base = 2; } + if (base == 0) + { base = c == '0' ? 8 : 10; + } /* * Compute the cutoff value between legal numbers and illegal @@ -167,175 +192,269 @@ strtol(nptr, endptr, base) * Set any if any `digits' consumed; make it negative to indicate * overflow. */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; cutlim = cutoff % (unsigned long)base; cutoff /= (unsigned long)base; - for (acc = 0, any = 0;; c = *s++) { + + for (acc = 0, any = 0;; c = *s++) + { if (isdigit(c)) + { c -= '0'; + } else if (isalpha(c)) + { c -= isupper(c) ? 'A' - 10 : 'a' - 10; + } else + { break; + } + if (c >= base) + { break; + } + if ((any < 0 || acc > cutoff) || (acc == cutoff && c > cutlim)) + { any = -1; - else { + } + else + { any = 1; acc *= base; acc += c; } } - if (any < 0) { + + if (any < 0) + { acc = neg ? LONG_MIN : LONG_MAX; -// errno = ERANGE; - } else if (neg) + } + else if (neg) + { acc = -acc; + } + if (endptr != 0) + { *endptr = (char *)(any ? s - 1 : nptr); + } + return (acc); } -/* +/*========================================================================== * Convert a string to an unsigned long integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ -unsigned long -strtoul(nptr, endptr, base) - const char *nptr; - char **endptr; - register int base; +unsigned long strtoul(const char *nptr, char **endptr, register int base) { register const char *s = nptr; - register unsigned long acc; + register int c; - register unsigned long cutoff; register int neg = 0, any, cutlim; + register unsigned long acc; + register unsigned long cutoff; + /* * See strtol for comments as to the logic used. */ - do { + do + { c = *s++; } while (isspace(c)); - if (c == '-') { + + if (c == '-') + { neg = 1; c = *s++; - } else if (c == '+') + } + else if (c == '+') + { c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { + } + + if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) + { c = s[1]; s += 2; base = 16; - } else if ((base == 0 || base == 2) && - c == '0' && (*s == 'b' || *s == 'B')) { + } + else if ((base == 0 || base == 2) && c == '0' && (*s == 'b' || *s == 'B')) + { c = s[1]; s += 2; base = 2; } + if (base == 0) + { base = c == '0' ? 8 : 10; + } + cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; - for (acc = 0, any = 0;; c = *s++) { + + for (acc = 0, any = 0;; c = *s++) + { if (isdigit(c)) + { c -= '0'; + } else if (isalpha(c)) + { c -= isupper(c) ? 'A' - 10 : 'a' - 10; + } else + { break; + } + if (c >= base) + { break; + } + if ((any < 0 || acc > cutoff) || (acc == cutoff && c > cutlim)) + { any = -1; - else { + } + else + { any = 1; acc *= base; acc += c; } } - if (any < 0) { + + if (any < 0) + { acc = ULONG_MAX; -// errno = ERANGE; - } else if (neg) + } + else if (neg) + { acc = -acc; + } + if (endptr != 0) + { *endptr = (char *)(any ? s - 1 : nptr); + } + return (acc); } -/* + +/*========================================================================== * Convert a string to an unsigned quad integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ -unsigned long long -strtouq(nptr, endptr, base) - const char *nptr; - char **endptr; - register int base; + +unsigned long long strtouq(const char *nptr, char **endptr, register int base) { register const char *s = nptr; - register unsigned long long acc; + register int c; - register unsigned long long qbase, cutoff; register int neg, any, cutlim; + register unsigned long long acc; + register unsigned long long qbase, cutoff; + /* * See strtoq for comments as to the logic used. */ s = nptr; - do { + + do + { c = *s++; } while (isspace(c)); - if (c == '-') { + + if (c == '-') + { neg = 1; c = *s++; - } else { + } + else + { neg = 0; + if (c == '+') + { c = *s++; + } } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { + + if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) + { c = s[1]; s += 2; base = 16; } + if (base == 0) + { base = c == '0' ? 8 : 10; + } + qbase = (unsigned)base; cutoff = (unsigned long long)UQUAD_MAX / qbase; cutlim = (unsigned long long)UQUAD_MAX % qbase; - for (acc = 0, any = 0;; c = *s++) { + + for (acc = 0, any = 0;; c = *s++) + { if (isdigit(c)) + { c -= '0'; + } else if (isalpha(c)) + { c -= isupper(c) ? 'A' - 10 : 'a' - 10; + } else + { break; + } + if (c >= base) + { break; + } + if ((any < 0 || acc > cutoff) || (acc == cutoff && c > cutlim)) + { any = -1; - else { + } + else + { any = 1; acc *= qbase; acc += c; } } - if (any < 0) { + + if (any < 0) + { acc = UQUAD_MAX; -// errno = ERANGE; - } else if (neg) + } + else if (neg) + { acc = -acc; + } + if (endptr != 0) + { *endptr = (char *)(any ? s - 1 : nptr); + } + return (acc); } diff --git a/i386/libsa/zalloc.c b/i386/libsa/zalloc.c index 533ccf9..70afdd2 100755 --- a/i386/libsa/zalloc.c +++ b/i386/libsa/zalloc.c @@ -52,9 +52,9 @@ static char * zalloc_base; static char * zalloc_end; #if SAFE_MALLOC - static void (*zerror)(char *, size_t, const char *, int); + static void (*zerror)(char *, size_t, const char *, int); #else - static void (*zerror)(char *, size_t); + static void (*zerror)(char *, size_t); #endif static void zallocate(char * start,int size); @@ -66,7 +66,8 @@ static void zcoalesce(void); size_t zalloced_size; #endif -#define ZALLOC_NODES 16384 +#define ZALLOC_NODES 32767 /* This was 16384 */ + #if SAFE_MALLOC static void mallocError(char *addr, size_t size, const char *file, int line) @@ -141,8 +142,9 @@ static void zcoalesce(void); for (i = 0; i < availableNodes; i++) { - // find node with equal size, or if not found, - // then smallest node that fits. + /* + * Find node with equal size, or if not found, then smallest node that fits. + */ if (zavailable[i].size == size) { zallocate(ret = zavailable[i].start, size); @@ -208,11 +210,13 @@ void free(void * pointer) "subl $4, %%eax\n\t" "movl 0(%%eax), %%eax" : "=a" (rp)); #else - rp = 0; + rp = 0; #endif if (!start) + { return; + } for (i = 0; i < allocedNodes; i++) { diff --git a/i386/libsaio/Makefile b/i386/libsaio/Makefile index 12e36a9..0e37b22 100644 --- a/i386/libsaio/Makefile +++ b/i386/libsaio/Makefile @@ -1,71 +1,64 @@ -DIR = libsaio +# +# File: RevoBoot/i386/libsaio/Makefile +# +# Updates: +# +# - Major cleanup (Pike R. Alpha, October 2012). +# - DMAKE_TARGET_MODEL added (Pike R. Alpha, October 2012). +# - Static data selectors added (Pike R. Alpha, October 2012). +# - STATIC_DATA_FILENAME added (Pike R> Alpha, October 2012). +# - Output added for rm/ar/ranlib actions (Pike R> Alpha, November 2012). +# - Enabled clang compilation (dgsga, PikerAlpha, November 2012. Credits to Evan Lojewski for original work). +# - Output change and now using libtool instead of ar/ranlib (Pike R. Alpha, November 2012). +# - SAIO_OBJS changed / base64.o added (Pike R. Alpha, November 2012). +# - MAKE_TARGET_OS_VER added (Pike R. Alpha, June 2014). +# - patcher.c added (Pike R. Alpha, August 2016). + include ../MakePaths.dir UTILDIR = ../util LIBSADIR = ../libsa -INSTALLDIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/standalone -#SYMROOT= OPTIM = -Os -Oz DEBUG = -DNOTHING -CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost \ - -D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \ - -DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \ - -DREVOBOOT_VERSION_INFO=\"RevoBoot\ v$(PRODUCT_VERSION_NUMBER)\" \ - -DMAKE_TARGET_OS=$(PRODUCT_OS_TARGET) \ - -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \ - -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \ - -march=pentium4 -msse2 -mfpmath=sse -msoft-float - +CFLAGS = $(RC_CFLAGS) $(OPTIM) -arch i386 -g -Wmost \ + -D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \ + -DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \ + -DREVOBOOT_VERSION_INFO=\"RevoBoot\ v$(PRODUCT_VERSION_NUMBER)\" \ + -DMAKE_TARGET_OS=$(PRODUCT_OS_TARGET) \ + -DMAKE_TARGET_OS_VER=$(PRODUCT_OS_TARGET_VERSION) \ + -DSETTINGS_FILE=SETTINGS/$(MAKE_TARGET_MODEL).h \ + -DSTATIC_DATA_FILENAME=$(MAKE_TARGET_MODEL).bin \ + -DACPI_DATA_FILE=../../config/$(MAKE_ACPI_DATA_FILE) \ + -DEFI_DATA_FILE=../config/$(MAKE_EFI_DATA_FILE) \ + -DSMBIOS_DATA_FILE=../config/$(MAKE_SMBIOS_DATA_FILE) \ + -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \ + -fno-stack-protector \ + -march=pentium4 -msse2 -msoft-float -DEFINES= -CONFIG = hd INC = -I. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSADIR) -ifneq "" "$(wildcard /bin/mkdirs)" - MKDIRS = /bin/mkdirs -else - MKDIRS = /bin/mkdir -p -endif -AS = as -LD = ld -# LIBS= -lc_static -LIBS= VPATH = $(OBJROOT):$(SYMROOT) -SAIO_OBJS = table.o asm.o bios.o biosfn.o \ - disk.o sys.o cache.o bootstruct.o \ - stringTable.o load.o pci.o allocate.o \ - vbe.o hfs.o hfs_compare.o \ - xml.o md5c.o device_tree.o \ - cpu.o platform.o acpi.o \ - smbios.o efi.o - -SAIO_EXTERN_OBJS = console.o +SAIO_OBJS = table.o asm.o bios.o biosfn.o guid.o disk.o sys.o cache.o \ + bootstruct.o base64.o stringTable.o patcher.o load.o pci.o allocate.o \ + vbe.o hfs.o hfs_compare.o xml.o md5c.o device_tree.o cpu.o \ + platform.o acpi.o smbios.o efi.o console.o -SFILES = -CFILES = -HFILES = -EXPORTED_HFILES = -INSTALLED_HFILES = -OTHERFILES = Makefile -ALLSRC = $(SFILES) $(CFILES) \ - $(HFILES) $(OTHERFILES) LIBS = libsaio.a + DIRS_NEEDED = $(OBJROOT) $(SYMROOT) -lion: all -mountain-lion: all +$(MAKEGOAL): $(DIRS_NEEDED) libsaio.h $(LIBS) -all: $(DIRS_NEEDED) libsaio.h $(LIBS) +$(LIBS): $(SAIO_OBJS) + @if [ -f $(SYMROOT)/$@ ]; then \ + echo "\t[RM] $@"; \ + rm -f $(SYMROOT)/$@; \ + fi; -libsaio.a: $(SAIO_EXTERN_OBJS) $(SAIO_OBJS) - rm -f $(SYMROOT)/$(@F) - ar q $(SYMROOT)/$(@F) $^ - ranlib $(SYMROOT)/$(@F) + @echo "\t[LIBTOOL] $@" + @libtool -o $(SYMROOT)/$@ $^ include ../MakeInc.dir - -# dependencies --include $(OBJROOT)/Makedep diff --git a/i386/libsaio/acpi.c b/i386/libsaio/acpi.c index 3b97a80..5be5df4 100755 --- a/i386/libsaio/acpi.c +++ b/i386/libsaio/acpi.c @@ -26,6 +26,9 @@ * EFI implementation for Revolution Copyright (c) 2010 by DHP. * All rights reserved. * + * Updates: + * + * - Moved #include to end of file, eliminating need of extern in patcher.h (PikerAlpha, October 2012). */ @@ -41,7 +44,7 @@ void updateACPITableData(struct acpi_2_rsdp * rsdp, struct acpi_2_xsdt * xsdt, i { #if ACPI_10_SUPPORT - _ACPI_DEBUG_DUMP("\nPatching RSDP and RSDT tables... "); + _ACPI_DEBUG_DUMP("\nPatching RSDP and XSDT tables... "); // Update revision info (fake ACPI 2.0). rsdp->Revision = 1; @@ -72,29 +75,19 @@ void updateACPITableData(struct acpi_2_rsdp * rsdp, struct acpi_2_xsdt * xsdt, i #if APPLE_STYLE_ACPI - //------------------------- Used in acpi/patcher.h ------------------------- - #define _ACPI_SET(target, str, len) strncpy(target, str, len) #define _ACPI_SET_APPLE_OEMID(target) _ACPI_SET((target)->OEMID, "Apple ", 6) - #define _ACPI_SET_APPLE_OEMTargetID(target) _ACPI_SET((target)->OEMTableID, "Apple00", 8) - + #define _ACPI_SET_APPLE_OEMTargetID(target) _ACPI_SET((target)->OEMTableID, gPlatform.CommaLessModelID, 8) //-------------------------------------------------------------------------- - #else - //--------------------------- Void replacements ---------------------------- - #define _ACPI_SET(target, str, len) #define _ACPI_SET_APPLE_OEMID(target) #define _ACPI_SET_APPLE_OEMTargetID(target) - //-------------------------------------------------------------------------- - #endif -#include "acpi/patcher.h" // Macro's in this include file must be live now. - //============================================================================== // Original version written by macerintel (?). Rewrite by Master Chief in 2009. @@ -136,4 +129,4 @@ struct acpi_2_rsdp * getACPIBaseAddress() #endif } - +#include "acpi/patcher.h" // Macro's in this include file must be live now. diff --git a/i386/libsaio/acpi/Tools/extractACPITables b/i386/libsaio/acpi/Tools/extractACPITables new file mode 100755 index 0000000..adb1be0 Binary files /dev/null and b/i386/libsaio/acpi/Tools/extractACPITables differ diff --git a/i386/libsaio/acpi/Tools/extractACPITables.c b/i386/libsaio/acpi/Tools/extractACPITables.c new file mode 100755 index 0000000..9b33a92 --- /dev/null +++ b/i386/libsaio/acpi/Tools/extractACPITables.c @@ -0,0 +1,95 @@ +/* + * Name : extractACPITables.c + * Version : 0.3 + * Type : Command line tool + * Copyright : Pike R. Alpha (c) September 2014 + * Description : ACPI table extractor. + * + * Usage : ./extractACPITables (writes all tables to: /tmp/XXXX.aml) + * : ./extractACPITables DSDT (writes DSDT.aml to: /tmp/DSDT.aml) + * : ./extractACPITables SSDT (writes all SSDT tables to: /tmp/SSDT.aml) + * : ./extractACPITables SSDT-2 (writes SSDT-2.aml to: /tmp/SSDT-2.aml) + * + * Compile with : cc -O2 extractACPITables.c -o extractACPITables -Wall -framework IOKit -framework CoreFoundation + * + * Updates: + * v0.1 initial version. + * v0.2 renamed from acpiTableExtract.c to extractAcpiTables.c + * v0.3 check arguments, use argv[1] as target table. + */ + +#include + +#include +#include + +//============================================================================== + +int main(int argc, char * argv[]) +{ + char dirspec[32]; + char tableName[8]; + int filedesc, status = 0; + bool allTables = true; + + io_service_t service; + CFDictionaryRef tableDictionary; + + //================================================================================== + + if (argc == 2) + { + allTables = false; + } + + if ((service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("AppleACPIPlatformExpert")))) + { + if ((tableDictionary = (CFDictionaryRef) IORegistryEntryCreateCFProperty(service, CFSTR("ACPI Tables"), kCFAllocatorDefault, kNilOptions))) + { + CFIndex tableCount = CFDictionaryGetCount(tableDictionary); + + CFStringRef tableNames[tableCount]; + CFDataRef tableData[tableCount]; + + CFDictionaryGetKeysAndValues(tableDictionary, (const void **)&tableNames, (const void **)&tableData); + + for (CFIndex i = 0; i < tableCount; i++) + { + UInt8 * buffer = (UInt8 *) CFDataGetBytePtr(tableData[i]); + UInt32 numBytes = (UInt32) CFDataGetLength(tableData[i]); + + strcpy(tableName, CFStringGetCStringPtr(tableNames[i], kCFStringEncodingMacRoman)); + + if (allTables || (strncasecmp(argv[1], (char *)tableName, strlen(argv[1])) == 0)) + { + sprintf(dirspec, "/tmp/%s.aml", tableName); + + if ((filedesc = open(dirspec, O_WRONLY|O_CREAT|O_TRUNC, 0644)) != -1) + { + write(filedesc, buffer, numBytes); + close(filedesc); + } + else + { + status = -3; + } + } + } + + CFRelease(tableDictionary); + } + else + { + status = -2; + } + + IOObjectRelease(service); + + // 0 = success. + // -2 = tableDictionary is NULL. + // -3 = one or more writes failed. + exit(status); + } + + exit(-1); // error (service is NULL). +} diff --git a/i386/libsaio/acpi/Tools/iasl b/i386/libsaio/acpi/Tools/iasl new file mode 100755 index 0000000..36fd8a9 Binary files /dev/null and b/i386/libsaio/acpi/Tools/iasl differ diff --git a/i386/libsaio/acpi/Tools/install.sh b/i386/libsaio/acpi/Tools/install.sh new file mode 100755 index 0000000..f4a9f3e --- /dev/null +++ b/i386/libsaio/acpi/Tools/install.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Installation script for ssdtPRGen.command +# +# Version 0.1 - Copyright (c) 2013 by Pike +# +# Updates: +# - +# +# Contributors: +# + +#-------------------------------------------------------------------------------- + +if [ -f ~/ssdtPRGen.command ]; + then + open ~/ssdtPRGen.command + else + # + # Download script + # + curl -o ~/ssdtPRGen.command https://raw.github.com/Piker-Alpha/RevoBoot/clang/i386/libsaio/acpi/Tools/ssdtPRGen.sh + + # + # Add execute rights + # + chmod +x ~/ssdtPRGen.command + + # + # Maintain backward compatibility with older versions + # + ln -sf ~/ssdtPRGen.command ~/ssdtPRGen.sh + + # + # Put a symbolic link to the script on the Desktop + # + ln -sf ~/ssdtPRGen.command ~/Desktop/ssdtPRGen.command +fi + +exit 0 diff --git a/i386/libsaio/acpi/Tools/ssdtPRGen copy.sh b/i386/libsaio/acpi/Tools/ssdtPRGen copy.sh new file mode 100755 index 0000000..28ae711 --- /dev/null +++ b/i386/libsaio/acpi/Tools/ssdtPRGen copy.sh @@ -0,0 +1,1436 @@ +#!/bin/bash +# +# Script (ssdtPRGen.sh) to create ssdt-pr.dsl for Apple Power Management Support. +# +# Version 0.9 - Copyright (c) 2012 by RevoGirl +# Version 3.6 - Copyright (c) 2013 by Pike +# +# Updates: +# - Added support for Ivybridge (Pike, January 2013) +# - Filename error fixed (Pike, January 2013) +# - Namespace error fixed in _printScopeStart (Pike, January 2013) +# - Model and board-id checks added (Pike, January 2013) +# - SMBIOS cpu-type check added (Pike, January 2013) +# - Copy/paste error fixed (Pike, January 2013) +# - Method ACST added to CPU scopes for IB CPUPM (Pike, January 2013) +# - Method ACST corrected for latest version of iasl (Dave, January 2013) +# - Changed path/filename to ~/Desktop/SSDT_PR.dsl (Dave, January 2013) +# - P-States are now one-liners instead of blocks (Pike, January 2013) +# - Support for flexible ProcessorNames added (Pike, Februari 2013) +# - Better feedback and Debug() injection added (Pike, Februari 2013) +# - Automatic processor type detection (Pike, Februari 2013) +# - TDP and processor type are now optional arguments (Pike, Februari 2013) +# - system-type check (used by X86PlatformPlugin) added (Pike, Februari 2013) +# - ACST injection for all logical processors (Pike, Februari 2013) +# - Introducing a stand-alone version of method _DSM (Pike, Februari 2013) +# - Fix incorrect turbo range (Pike, Februari 2013) +# - Restore IFS before return (Pike, Februari 2013) +# - Better/more complete feedback added (Jeroen, Februari 2013) +# - Processor data for desktop/mobile and server CPU's added (Jeroen, Februari 2013) +# - Improved power calculation, matching Apple's new algorithm (Pike, Februari 2013) +# - Fix iMac13,N latency and power values for C3 (Jeroen/Pike, Februari 2013) +# - IASL failed to launch when path included spaces (Pike, Februari 2013) +# - Typo in cpu-type check fixed (Jeroen, Februari 2013) +# - Error in CPU data (i5-3317U) fixed (Pike, Februari 2013) +# - Setting added for the target path/filename (Jeroen, Februari 2013) +# - Initial implementation of auto-copy (Jeroen, Februari 2013) +# - Additional checks added for cpu data/turbo modes (Jeroen, Februari 2013) +# - Undo filename change done by Jeroen (Pike, Februari 2013) +# +# Contributors: +# - Thanks to Dave, toleda and Francis for their help (bug fixes and other improvements). +# - Many thanks to Jeroen for the CPU data, cleanups and renaming stuff. +# + +# set -x # Used for tracing errors (can be used anywhere in the script). + +#================================= GLOBAL VARS ================================== + +# +# Change this to 0 when your CPU isn't stuck in Low Frequency Mode! +# +gIvyWorkAround=1 + +# +# Change this to 1 when you want SSDT.aml to get copied to the target location. +# +gAutoCopy=0 + +# +# This is the target location that SSDT.aml will be copied to. +# +# Note: Do no change this - will be updated automatically for Clover/RevoBoot! +# +gDestinationPath="/Extra/" + +# +# This is the filename used for the copy process +# +gDestinationFile="SSDT.aml" + +# +# A value of 1 will make this script call iasl (compiles SSDT_PR.dsl) +# +# Note: Will be set to 0 when we failed to locate a copy of iasl! +# +gCallIasl=1 + +# +# A value of 1 will make this script open SSDT_PR.dsl in the editor of your choice. +# +gCallOpen=0 + +# +# Change this to 0 to stop it from injecting debug data. +# +gDebug=1 + +# +# Lowest possible idle frequency (user configurable). Also known as Low Frequency Mode. +# +gBaseFrequency=1600 + +# +# Change this label to "P00" when your DSDT uses 'P00n' instead of 'CPUn'. +# +gProcLabel="CPU" + +# +# Other global variables. +# + +gScriptVersion=3.6 + +# +# Path and filename setup. +# + +gPath=~/Desktop +gSsdtID=SSDT_PR +gSsdtPR=${gPath}/${gSsdtID}.dsl + +gDesktopCPU=1 +gMobileCPU=2 +gServerCPU=3 + +let gSystemType=0 + +gACST_CPU0=13 +gACST_CPU1=7 + +gMacModelIdentifier="" + +IVY_BRIDGE=4 +SANDY_BRIDGE=2 + +gTypeCPU=0 +gProcessorData="Unknown CPU" +gProcessorNumber="" + +# +# Processor Number, Max TDP, Low Frequency Mode, Clock Speed, Max Turbo Frequency, Cores, Threads +# + +gSandyBridgeCPUList=( +# E3-1200 Xeon Processor Series +E3-1290,95,0,3600,4000,4,8 +E3-1280,95,0,3500,3900,4,8 +E3-1275,95,0,3400,3800,4,8 +E3-1270,80,0,3400,3800,4,8 +E3-1260L,45,0,2400,3300,4,8 +E3-1245,95,0,3300,3700,4,8 +E3-1240,80,0,3300,3700,4,8 +E3-1235,95,0,3200,3600,4,8 +E3-1230,80,0,3200,3600,4,8 +E3-1225,95,0,3100,3400,4,4 +E3-1220L,20,0,2200,3400,2,4 +E3-1220,80,0,3100,3400,4,4 +) + +# +# Processor Number, Max TDP, Low Frequency Mode, Clock Speed, Max Turbo Frequency, Cores, Threads +# + +gServerIvyBridgeCPUList=( +# E3-1200 Xeon Processor Series +'E3-1290 V2',87,0,3700,4100,4,8 +'E3-1285 V2',65,0,3600,4000, +'E3-1285L V2',0,0,3200,3900, +'E3-1280 V2',69,0,3600,4000,4,8 +'E3-1275 V2',77,0,3500,3900,4,8 +'E3-1270 V2',69,0,3500,3900,4,8 +'E3-1265L V2',45,0,2500,3500,4,8 +'E3-1245 V2',77,0,3400,3800,4,8 +'E3-1240 V2',69,0,3400,3800,4,8 +'E3-1230 V2',69,0,3300,3700,4,8 +'E3-1225 V2',77,0,3200,3600,4,4 +'E3-1220 V2',69,0,3100,3500,4,4 +'E3-1220L V2',17,0,2300,3500,2,4 +) + +gDesktopIvyBridgeCPUList=( +# i7-3700 Desktop Processor Series +i7-3770T,45,1600,2500,3700,4,8 +i7-3770S,65,1600,3100,3900,4,8 +i7-3770K,77,1600,3500,4600,4,8 +i7-3770,77,1600,3400,3900,4,8 +# i5-3500 Desktop Processor Series +i5-3570T,45,1600,2300,3300,4,4 +i5-3570K,77,1600,3400,3800,4,4 +i5-3570S,65,1600,3100,3800,4,4 +i5-3570,77,1600,3400,3800,4,4 +i5-3550S,65,1600,3000,3700,4,4 +i5-3550,77,1600,3300,3700,4,4 +# i5-3400 Desktop Processor Series +i5-3475S,65,1600,2900,3600,4,4 +i5-3470S,65,1600,2900,3600,4,4 +i5-3470,77,1600,3200,3600,4,4 +i5-3470T,35,1600,2900,3600,2,4 +i5-3450S,65,1600,2800,3500,4,4 +i5-3450,77,1600,3100,3500,4,4 +# i5-3300 Desktop Processor Series +i5-3350P,69,1600,3100,3300,4,4 +i5-3330S,65,1600,2700,3200,4,4 +i5-3333S,65,1600,2700,3200,4,4 +i5-3330S,65,1600,3700,3200,4,4 +i5-3330,77,1600,3000,3200,4,4 +# i3-3200 Desktop Processor Series +i3-3240,55,1600,3400,0,2,4 +i3-3240T,35,1600,2900,0,2,4 +i3-3225,55,1600,3300,0,2,4 +i3-3220,55,1600,3300,0,2,4 +i3-3220T,35,1600,2800,0,2,4 +i3-3210,55,1600,3200,0,2,4 +) + +gMobileIvyBridgeCPUList=( +# i7-3800 Mobile Processor Series +i7-3840QM,45,1200,2800,3800,4,8 +i7-3820QM,45,1200,2700,3700,4,8 +# i7-3700 Mobile Processor Series +i7-3740QM,45,1200,2700,3700,4,8 +i7-3720QM,45,1200,2600,3600,4,8 +# i7-3600 Mobile Processor Series +i7-3689Y,13,0,1500,2600,2,4 +i7-3687U,17,800,2100,3300,2,4 +i7-3667U,17,800,2000,3200,2,4 +i7-3635QM,45,0,2400,3400,4,8 +i7-3620QM,35,0,2200,3200,4,8 +i7-3632QM,35,0,2200,3200,4,8 +i7-3630QM,45,0,2400,3400,4,8 +i7-3615QM,45,0,2300,3300,4,8 +i7-3615QE,45,0,2300,3300,4,8 +i7-3612QM,35,0,2100,3100,4,8 +i7-3612QE,35,0,2100,3100,4,8 +i7-3610QM,45,0,2300,3300,4,8 +i7-3610QE,45,0,2300,3300,4,8 +# i7-3500 Mobile Processor Series +i7-3555LE,25,0,2500,3200,2,4 +i7-3540M,35,1200,3000,3700,2,4 +i7-3537U,17,800,2000,3100,2,4 +i7-3520M,35,1200,2900,3600,2,4 +i7-3517UE,17,0,1700,2800,2,4 +i7-3517U,17,0,1900,3000,2,4 +# i5-3600 Mobile Processor Series +i5-3610ME,35,0,2700,3300,2,4 +# i5-3400 Mobile Processor Series +i5-3439Y,13,0,1500,2300,2,4 +i5-3437U,17,800,1900,2900,2,4 +i5-3427U,17,800,1800,2800,2,4 +# i5-3300 Mobile Processor Series +i5-3380M,35,1200,2900,3600,2,4 +i5-3360M,35,1200,2800,3500,2,4 +i5-3340M,35,1200,2700,3400,2,4 +i5-3339Y,13,0,1500,2000,2,4 +i5-3337U,17,0,1800,2700,2,4 +i5-3320M,35,1200,2600,3300,2,4 +i5-3317U,17,0,1700,2600,2,4 +# i5-3200 Mobile Processor Series +i5-3230M,35,1200,2600,3200,2,4 +i5-3210M,35,1200,2500,3100,2,4 +# i3-3200 Mobile Processor Series +i3-3239Y,13,0,1400,0,2,4 +i3-3227U,17,800,1900,0,2,4 +i3-3217UE,17,0,1600,0,2,4 +i3-3217U,17,0,1800,0,2,4 +# i3-3100 Mobile Processor Series +i3-3130M,35,1200,2600,0,2,4 +i3-3120ME,35,0,2400,0,2,4 +i3-3120M,35,0,2500,0,2,4 +i3-3110M,35,0,2400,0,2,4 +) + +#-------------------------------------------------------------------------------- + +function _printHeader() +{ + echo '/*' > $gSsdtPR + echo ' * Intel ACPI Component Architecture' >> $gSsdtPR + echo ' * AML Disassembler version 20130210-00 [Feb 10 2013]' >> $gSsdtPR + echo ' * Copyright (c) 2000 - 2013 Intel Corporation' >> $gSsdtPR + echo ' * ' >> $gSsdtPR + echo ' * Original Table Header:' >> $gSsdtPR + echo ' * Signature "SSDT"' >> $gSsdtPR + echo ' * Length 0x0000036A (874)' >> $gSsdtPR + echo ' * Revision 0x01' >> $gSsdtPR + echo ' * Checksum 0x00' >> $gSsdtPR + echo ' * OEM ID "APPLE "' >> $gSsdtPR + echo ' * OEM Table ID "CpuPm"' >> $gSsdtPR + echo ' * OEM Revision 0x00003000 (4096)' >> $gSsdtPR + echo ' * Compiler ID "INTL"' >> $gSsdtPR + echo ' * Compiler Version 0x20130210 (538116624)' >> $gSsdtPR + echo ' */' >> $gSsdtPR + echo '' >> $gSsdtPR + echo 'DefinitionBlock ("'$gSsdtID'.aml", "SSDT", 1, "APPLE ", "CpuPm", 0x00003000)' >> $gSsdtPR + echo '{' >> $gSsdtPR +} + + +#-------------------------------------------------------------------------------- + +function _printExternals() +{ + currentCPU=0; + + while [ $currentCPU -lt $1 ]; do + echo ' External (\_PR_.'$gProcLabel$currentCPU', DeviceObj)' >> $gSsdtPR + let currentCPU+=1 + done + + echo '' >> $gSsdtPR +} + + +#-------------------------------------------------------------------------------- + +function _printDebugInfo() +{ + if ((gDebug)); then + echo ' Store ("ssdtPRGen.sh v'$gScriptVersion'", Debug)' >> $gSsdtPR + echo ' Store ("baseFrequency : '$gBaseFrequency'", Debug)' >> $gSsdtPR + echo ' Store ("frequency : '$frequency'", Debug)' >> $gSsdtPR + echo ' Store ("logicalCPUs : '$logicalCPUs'", Debug)' >> $gSsdtPR + echo ' Store ("tdp : '$gTdp'", Debug)' >> $gSsdtPR + echo ' Store ("packageLength : '$packageLength'", Debug)' >> $gSsdtPR + echo ' Store ("turboStates : '$turboStates'", Debug)' >> $gSsdtPR + echo ' Store ("maxTurboFrequency: '$maxTurboFrequency'", Debug)' >> $gSsdtPR + echo '' >> $gSsdtPR + fi +} + +#-------------------------------------------------------------------------------- + +function _printProcessorDefinitions() +{ + let currentCPU=0; + + while [ $currentCPU -lt $1 ]; do + echo ' External (\_PR_.'$gProcLabel$currentCPU', DeviceObj)' >> $gSsdtPR + let currentCPU+=1 + done + + echo '' >> $gSsdtPR +} + +#-------------------------------------------------------------------------------- + +function _printScopeStart() +{ + let turboStates=$1 + let packageLength=$2 + + # TODO: Remove this when CPUPM for IB works properly! + let useWorkArounds=0 + + echo ' Scope (\_PR.'$gProcLabel'0)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + + # + # Do we need to create additional (Low Frequency) P-States? + # + + if [ $gBridgeType -eq $IVY_BRIDGE ]; + then + let lowFrequencyPStates=($gBaseFrequency/100)-8 + let packageLength=($2+$lowFrequencyPStates) + + printf " Name (APLF, 0x%02x" $lowFrequencyPStates >> $gSsdtPR + echo ')' >> $gSsdtPR + + # TODO: Remove this when CPUPM for IB works properly! + if ((gIvyWorkAround)); then + let useWorkArounds=1 + fi + fi + + # + # Check number of Turbo states (for IASL optimization). + # + + if [ $turboStates -eq 0 ]; + then + # TODO: Remove this when CPUPM for IB works properly! + if (($useWorkArounds)); + then + echo ' Name (APSN, One)' >> $gSsdtPR + else + echo ' Name (APSN, Zero)' >> $gSsdtPR + fi + else + # TODO: Remove this when CPUPM for IB works properly! + if ((useWorkArounds)); then + let turboStates+=1 + fi + + printf " Name (APSN, 0x%02X)\n" $turboStates >> $gSsdtPR + fi + + # TODO: Remove this when CPUPM for IB works properly! + if (($useWorkArounds)); then + let packageLength+=1 + fi + + printf " Name (APSS, Package (0x%02X)\n" $packageLength >> $gSsdtPR + echo ' {' >> $gSsdtPR + + # TODO: Remove this when CPUPM for IB works properly! + if (($useWorkArounds)); then + let extraF=($maxTurboFrequency+1) + let maxTDP=($gTdp*1000) + let extraR=($maxTurboFrequency/100)+1 + echo ' /* Workaround for Ivy Bridge PM bug */' >> $gSsdtPR + printf " Package (0x06) { 0x%04X, 0x%06X, 0x0A, 0x0A, 0x%02X00, 0x%02X00 },\n" $extraF $maxTDP $extraR $extraR >> $gSsdtPR + fi +} + + +#-------------------------------------------------------------------------------- + +function _printPackages() +{ + let maxTDP=($1*1000) + local maxNonTurboFrequency=$2 + local frequency=$3 + + let minRatio=($gBaseFrequency/100) + let p1Ratio=($maxNonTurboFrequency/100) + let ratio=($frequency/100) + let powerRatio=($p1Ratio-1) + + # + # Do we need to create additional (Low Frequency) P-States for Ivy bridge? + # + if [ $gBridgeType -eq $IVY_BRIDGE ]; then + let minRatio=8 + fi + + if (($turboStates)); then + echo ' /* High Frequency Modes (turbo) */' >> $gSsdtPR + fi + + while [ $ratio -ge $minRatio ]; + do + if [ $frequency -eq $gBaseFrequency ]; + then + echo ' /* Low Frequency Mode */' >> $gSsdtPR + fi + + if [ $frequency -eq $maxNonTurboFrequency ]; + then + echo ' /* High Frequency Modes (non-turbo) */' >> $gSsdtPR + fi + + printf " Package (0x06) { 0x%04X, " $frequency >> $gSsdtPR + + if [ $frequency -lt $maxNonTurboFrequency ]; + then + power=$(echo "scale=6;m=((1.1-(($p1Ratio-$powerRatio)*0.00625))/1.1);(($powerRatio/$p1Ratio)*(m*m)*$maxTDP);" | bc | sed -e 's/.[0-9A-F]*$//') + let powerRatio-=1 + else + power=$maxTDP + fi + + if [ $frequency -ge $gBaseFrequency ]; + then + printf "0x%06X, " $power >> $gSsdtPR + else + printf ' Zero, ' >> $gSsdtPR + fi + + printf "0x0A, 0x0A, 0x%02X00, 0x%02X00 }" $ratio $ratio >> $gSsdtPR + + let ratio-=1 + let frequency-=100 + + if [ $ratio -ge $minRatio ]; + then + echo ',' >> $gSsdtPR + else + echo '' >> $gSsdtPR + fi + + done + + echo ' })' >> $gSsdtPR + echo '' >> $gSsdtPR +} + + +#-------------------------------------------------------------------------------- + +function _printMethodDSM() +{ + # + # New stand-alone version of Method _DSM - Copyright (c) 2009 by Master Chief + # + echo '' >> $gSsdtPR + echo ' Method (_DSM, 4, NotSerialized)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' If (LEqual (Arg2, Zero))' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Return (Buffer (One)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' 0x03' >> $gSsdtPR + echo ' })' >> $gSsdtPR + echo ' }' >> $gSsdtPR + echo '' >> $gSsdtPR + # + # This property is required to get X86Platform[Plugin/Shim].kext loaded. + # + echo ' Return (Package (0x02)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' "plugin-type",' >> $gSsdtPR + echo ' One' >> $gSsdtPR + echo ' })' >> $gSsdtPR + echo ' }' >> $gSsdtPR + echo ' }' >> $gSsdtPR +} + +#-------------------------------------------------------------------------------- + +function _printScopeACST() +{ + let C1=0 + let C2=0 + let C3=0 + let C6=0 + let C7=0 + local pkgLength=2 + local numberOfCStates=0 + +# echo '' >> $gSsdtPR + echo ' Method (ACST, 0, NotSerialized)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + + # + # Are we injecting C-States for CPU1? + # + if [ $1 -eq 1 ]; + then + # Yes (also used by CPU2, CPU3 and greater). + let targetCStates=$gACST_CPU1 + latency_C1=0x03E8 + latency_C2=0x94 + latency_C3=0xC6 + + if ((gDebug)); then + echo ' Store ("CPU1 C-States : '$targetCStates'", Debug)' >> $gSsdtPR + echo '' >> $gSsdtPR + fi + else + # + # C-States override for Mobile processors (CPU0 only) + # + if (($gTypeCPU == $gMobileCPU)); + then + echo 'Adjusting C-States for detected (mobile) processor' + gACST_CPU0=29 + fi + + let targetCStates=$gACST_CPU0 + latency_C1=Zero + latency_C3=0xCD + latency_C6=0xF5 + latency_C7=0xF5 + + if ((gDebug)); then + echo ' Store ("CPU0 C-States : '$targetCStates'", Debug)' >> $gSsdtPR + echo '' >> $gSsdtPR + fi + fi + + # + # Checks to determine which C-State(s) we should inject. + # + if (($targetCStates & 1)); then + let C1=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + if (($targetCStates & 2)); then + let C2=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + if (($targetCStates & 4)); then + let C3=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + if (($targetCStates & 8)); then + let C6=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + if (($targetCStates & 16)); then + let C7=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + let hintCode=0x00 + + echo ' /* Low Power Modes for '$gProcLabel$1' */' >> $gSsdtPR + printf " Return (Package (0x%02x)\n" $pkgLength >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' One,' >> $gSsdtPR + printf " 0x%02x,\n" $numberOfCStates >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x01, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' One,' >> $gSsdtPR + echo ' '$latency_C1',' >> $gSsdtPR + echo ' 0x03E8' >> $gSsdtPR + + if (($C2)); then + let hintCode+=0x10 + echo ' },' >> $gSsdtPR + echo '' >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x03, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' 0x02,' >> $gSsdtPR + echo ' '$latency_C2',' >> $gSsdtPR + echo ' 0x01F4' >> $gSsdtPR + fi + + if (($C3)); then + let hintCode+=0x10 + local power_C3=0x01F4 + # + # Is this for CPU1? + # + if (($1)); then + if [[ ${modelID:0:7} == "iMac13," ]]; + then + local power_C3=0x15E + latency_C3=0xA9 + else + local power_C3=0xC8 + let hintCode+=0x10 + fi + fi + + echo ' },' >> $gSsdtPR + echo '' >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x03, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' 0x03,' >> $gSsdtPR + echo ' '$latency_C3',' >> $gSsdtPR + echo ' '$power_C3 >> $gSsdtPR + fi + + if (($C6)); then + let hintCode+=0x10 + echo ' },' >> $gSsdtPR + echo '' >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x03, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' 0x06,' >> $gSsdtPR + echo ' '$latency_C6',' >> $gSsdtPR + echo ' 0x015E' >> $gSsdtPR + fi + + if (($C7)); then + # + # If $hintCode is already 0x30 then use 0x31 otherwise 0x30 + # + if [ $hintCode -eq 48 ]; + then + let hintCode+=0x01 + else + let hintCode+=0x10 + fi + echo ' },' >> $gSsdtPR + echo '' >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x03, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' 0x07,' >> $gSsdtPR + echo ' '$latency_C7',' >> $gSsdtPR + echo ' 0xC8' >> $gSsdtPR + fi + + echo ' }' >> $gSsdtPR + echo ' })' >> $gSsdtPR + echo ' }' >> $gSsdtPR + + # + # We don't need a closing bracket here when we add method _DSM for Ivy Bridge. + # + + if [ $gBridgeType -eq $SANDY_BRIDGE ]; then + echo ' }' >> $gSsdtPR + fi +} + + +#-------------------------------------------------------------------------------- + +function _printScopeCPUn() +{ + let currentCPU=1; + + while [ $currentCPU -lt $1 ]; do + echo '' >> $gSsdtPR + echo ' Scope (\_PR.'$gProcLabel$currentCPU')' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Method (APSS, 0, NotSerialized) { Return (\_PR.'$gProcLabel'0.APSS) }' >> $gSsdtPR + + # + # IB CPUPM tries to parse/execute CPUn.ACST (see debug data) and thus we add + # this method, conditionally, since SB CPUPM doesn't seem to care about it. + # + if [ $gBridgeType -eq $IVY_BRIDGE ] + then + if [ $currentCPU -eq 1 ]; + then + _printScopeACST 1 + else + echo ' Method (ACST, 0, NotSerialized) { Return (\_PR.'$gProcLabel'1.ACST ()) }' >> $gSsdtPR + fi + fi + + echo ' }' >> $gSsdtPR + let currentCPU+=1 + done + + echo '}' >> $gSsdtPR +} + +#-------------------------------------------------------------------------------- + +function _getModelName() +{ + # + # Grab 'compatible' property from ioreg (stripped with sed / RegEX magic). + # + echo `ioreg -p IODeviceTree -d 2 -k compatible | grep compatible | sed -e 's/ *["=<>]//g' -e 's/compatible//'` +# echo "iMac13,2" +} + +#-------------------------------------------------------------------------------- + +function _getBoardID() +{ + # + # Grab 'board-id' property from ioreg (stripped with sed / RegEX magic). + # + boardID=`ioreg -p IODeviceTree -d 2 -k board-id | grep board-id | sed -e 's/ *["=<>]//g' -e 's/board-id//'` +} + +#-------------------------------------------------------------------------------- + +function _getCPUtype() +{ + # + # Grab 'cpu-type' property from ioreg (stripped with sed / RegEX magic). + # + local grepStr=`ioreg -p IODeviceTree -n CPU0@0 -k cpu-type | grep cpu-type | sed -e 's/ *[-|="]//g'` + # + # Swap bytes with help of ${str:pos:num} + # + echo ${grepStr:2:2}${grepStr:0:2} +} + +#-------------------------------------------------------------------------------- + +function _getCPUModel() +{ + # + # Returns the hexadecimal value of machdep.cpu.model + # + echo 0x$(echo "obase=16; `sysctl machdep.cpu.model | sed -e 's/^machdep.cpu.model: //'`" | bc) +} + +#-------------------------------------------------------------------------------- + +function _getSystemType() +{ + # + # Grab 'system-type' property from ioreg (stripped with sed / RegEX magic). + # + # Note: This property is checked (cmpb $0x02) in X86PlatformPlugin::configResourceCallback + # + echo `ioreg -p IODeviceTree -d 2 -k system-type | grep system-type | sed -e 's/ *[-="<0a-z>]//g'` +} + +#-------------------------------------------------------------------------------- + +function _findIasl() +{ + if ((gCallIasl)); then + iasl=`find /Applications -name iasl -print -quit` + + if [ "$iasl" == "" ]; then + gCallIasl=0 + fi + fi +} + +#-------------------------------------------------------------------------------- + +function _setDestinationPath +{ + # + # Checking for RevoBoot + # + if [ -d /EFI/ACPI ]; then + gDestinationPath="/Extra/ACPI/" + fi + + # + # Checking for Clover + # + if [ -d /EFI/ACPI/patched ]; then + gDestinationPath="/EFI/ACPI/patched/" + fi +} + +#-------------------------------------------------------------------------------- + +function _getCPUNumberFromBrandString +{ + # + # Get CPU brandstring + # + local brandString=$(echo `sysctl machdep.cpu.brand_string` | sed -e 's/machdep.cpu.brand_string: //') + # + # Save default (0) delimiter + # + local ifs=$IFS + # + # Change delimiter to a space character + # + IFS=" " + # + # Split brandstring into array (data) + # + local data=($brandString) +# local data=("Intel(R)" "Xeon(R)" "CPU" "E3-1220" "V2" "@" "2.5GHz") +# local data=("Intel(R)" "Xeon(R)" "CPU" "E3-1220" "@" "2.5GHz") + # + # Example from a MacBookPro10,2 + # + # echo "${data[0]}" # Intel(R) + # echo "${data[1]}" # Core(TM) + # echo "${data[2]}" # i5-3210M + # echo "${data[3]}" # CPU + # echo "${data[4]}" # @ + # echo "${data[5]}" # 2.50GHz + # + # or: "Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz" + # + # echo "${data[0]}" # Intel(R) + # echo "${data[1]}" # Xeon(R) + # echo "${data[2]}" # CPU + # echo "${data[3]}" # E3-12XX + # echo "${data[4]}" # V2 + # echo "${data[5]}" # @ + # echo "${data[6]}" # 3.30GHz + + # + # Restore the default delimiter + # + IFS=$ifs + + let length=${#data[@]} + + if ((length > 6)); then + echo 'Warning: Unexpected brandstring > "'${data[@]}'"' + fi + + if [[ ${data[1]} == "Xeon(R)" && ${data[4]} == "V2" ]]; + then + gProcessorNumber="${data[3]} ${data[4]}" + else + gProcessorNumber="${data[2]}" + fi + +# echo $gProcessorNumber +} + +#-------------------------------------------------------------------------------- + +function _getCPUDataByProcessorNumber +{ + # + # Local function definition + # + function __searchList() + { + local ifs=$IFS + local targetCPUList=("${!1}") + + for cpuData in "${targetCPUList[@]}" + do + IFS="," + data=($cpuData) + + if [[ ${data[0]} == $gProcessorNumber ]]; then + gProcessorData="$cpuData" + let gTypeCPU=$2 + IFS=$ifs + return + fi + done + + IFS=$ifs + } + + # + # Local function callers (passing array and cpu type) + # + __searchList gDesktopIvyBridgeCPUList[@] $gDesktopCPU + + if (!(($gTypeCPU))); then + __searchList gMobileIvyBridgeCPUList[@] $gMobileCPU + fi + + if (!(($gTypeCPU))); then + __searchList "gServerIvyBridgeCPUList[@]" $gServerCPU + fi + +# echo "gTypeCPU is $gTypeCPU" +} + +#-------------------------------------------------------------------------------- + +function _showLowPowerStates() +{ + # + # Local function definition + # + function __print() + { + local mask=1 + local cStates=$1 + + printf "Injected C-States for ${gProcLabel}${2} (" + + for state in C1 C2 C3 C6 C7 + do + if (($cStates & $mask)); then + if (($mask > 1)); then + printf "," + fi + + printf "$state" + fi + + let mask=$(($mask << 1)) + done + + echo ')' + } + + # + # Local function callers + # + __print $gACST_CPU0 0 + + if ((gBridgeType == $IVY_BRIDGE)); then + __print $gACST_CPU1 1 + fi +} + +#-------------------------------------------------------------------------------- + +function _checkSMCKeys() +{ + # + # TODO: Check SMC keys to see if they are there and properly initialized! + # + # Note: Do not dump SMC keys with HWSensors/iStat or other SMC plug-ins installed! + # + local filename="/System/Library/Extensions/FakeSMC.kext/Contents/Info.plist" + local data=`grep -so '[a-zA-Z]*' $filename | sed -e 's///' -e 's/<\/key>//g'` + + local status=`echo $data | grep -oe 'DPLM'` + + if [ $status == 'DPLM' ]; then + # DPLM [{lim] (bytes 00 00 00 00 00) + # CPU, Idle, IGPU, EGPU and Memory P-State limits + echo "SMC key 'DPLM' found (OK)" + fi +set -x + local status=`echo $data | grep -oe 'MSAL'` + + if [ $status == 'MSAL' ]; then + # MSAL [hex_] (bytes 4b) + echo "SMC key 'MSAL' found (OK)" + fi +} + +#-------------------------------------------------------------------------------- + +function _initSandyBridgeSetup() +{ + case $boardID in + Mac-942B59F58194171B) + gSystemType=1 + gMacModelIdentifier="iMac12,1" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-942B5BF58194151B) + gSystemType=1 + gMacModelIdentifier="iMac12,2" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-8ED6AF5B48C039E1) + gSystemType=1 + gMacModelIdentifier="Macmini5,1" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-4BC72D62AD45599E) + gSystemType=1 + gMacModelIdentifier="Macmini5,2" + gACST_CPU0=13 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-7BA5B2794B2CDB12) + gSystemType=1 + gMacModelIdentifier="Macmini5,3" + gACST_CPU0=13 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-94245B3640C91C81) + gSystemType=2 + gMacModelIdentifier="MacBookPro8,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-94245A3940C91C80) + gSystemType=2 + gMacModelIdentifier="MacBookPro8,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-942459F5819B171B) + gSystemType=2 + gMacModelIdentifier="MacBookPro8,3" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-C08A6BB70A942AC2) + gSystemType=2 + gMacModelIdentifier="MacBookAir4,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-742912EFDBEE19B3) + gSystemType=2 + gMacModelIdentifier="MacBookAir4,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + esac +} + +#-------------------------------------------------------------------------------- + +function _initIvyBridgeSetup() +{ + case $boardID in + Mac-00BE6ED71E35EB86) + gSystemType=1 + gMacModelIdentifier="iMac13,1" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-FC02E91DDD3FA6A4) + gSystemType=1 + gMacModelIdentifier="iMac13,2" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-031AEE4D24BFF0B1) + gSystemType=1 + gMacModelIdentifier="Macmini6,1" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-F65AE981FFA204ED) + gSystemType=1 + gMacModelIdentifier="Macmini6,2" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-4B7AC7E43945597E) + gSystemType=2 + gMacModelIdentifier="MacBookPro9,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-6F01561E16C75D06) + gSystemType=2 + gMacModelIdentifier="MacBookPro9,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-C3EC7CD22292981F) + gSystemType=2 + gMacModelIdentifier="MacBookPro10,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-AFD8A9D944EA4843) + gSystemType=2 + gMacModelIdentifier="MacBookPro10,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-66F35F19FE2A0D05) + gSystemType=2 + gMacModelIdentifier="MacBookAir5,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-2E6FAB96566FE58C) + gSystemType=2 + gMacModelIdentifier="MacBookAir5,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + esac +} + +#-------------------------------------------------------------------------------- +# +# Only administrators (root) are allowed to run this script. +# +#-------------------------------------------------------------------------------- + +function _isRoot() +{ + if [ $(id -u) != 0 ]; then + echo "This script must be run as root" 1>&2 + exit 1 + fi + + echo 1 +} + +#-------------------------------------------------------------------------------- + +function main() +{ + printf "\nsdtPRGen.sh v$gScriptVersion Copyright (c) 2013 by Pike R. Alpha\n" + echo '-----------------------------------------------------' + + let modelSpecified=0 + let maxTurboFrequency=0 + + # + # Get installed CPU model, set bridge type and default TDP. + # + local model=$(_getCPUModel) + + _getCPUNumberFromBrandString + + if [[ $# -eq 1 ]]; then + if [[ $1 == "" ]]; + then + if [[ $gProcessorNumber != 0 ]]; then + let model=0x3A + fi + else + if (( ("${1:0:4}" == "i3-3") || (${1:0:4} == "i5-3") || (${1:0:4} == "i7-3") || (${1:0:1} == "E") )); then + let model=0x3A + let modelSpecified=1 + gProcessorNumber=$1 + fi + fi + fi + + if (($model==0x2A || $model==0x2D)); + then + let gTdp=95 + let gBridgeType=2 + local bridgeTypeString="Sandy Bridge" + else + let gTdp=77 + let gBridgeType=4 + local bridgeTypeString="Ivy Bridge" + + if (($model==0x3A || $model==0x3B)); then + _getCPUDataByProcessorNumber + fi + fi + + echo "$bridgeTypeString Core $gProcessorNumber processor installed" + + # + # gTypeCPU is greater than 0 when the processor is found in one of the CPU lists + # + if (($gTypeCPU)); + then + local ifs=$IFS + IFS="," + local cpuData=($gProcessorData) + let gTdp=${cpuData[1]} + let lfm=${cpuData[2]} + let frequency=${cpuData[3]} + let maxTurboFrequency=${cpuData[4]} + + if [ $maxTurboFrequency == 0 ]; then + let maxTurboFrequency=$frequency + fi + + let logicalCPUs=${cpuData[6]} + IFS=$ifs + + echo 'Using a maximum TDP of '$gTdp' Watt, as specified by Intel' + + # + # Check Low Frequency Mode (may be 0 aka still unknown) + # + if (($lfm == 0)); then + echo 'Warning: Low Frequency Mode is 0 (unknown)' + + if (($gTypeCPU == gMobileCPU)); + then + echo 'Now using 1200 MHz for Mobile processor' + let gBaseFrequency=1200 + else + echo 'Now using 1600 MHz for Server/Desktop processor' + let gBaseFrequency=1600 + fi + fi + else + let logicalCPUs=$(echo `sysctl machdep.cpu.thread_count` | sed -e 's/^machdep.cpu.thread_count: //') + let frequency=$(echo `sysctl hw.cpufrequency` | sed -e 's/^hw.cpufrequency: //') + let frequency=($frequency / 1000000) + fi + + if (!(($modelSpecified))); then + # + # Command line arguments (used as override values). + # + if [[ $# -ge 1 && $1 != "" ]]; then + let maxTurboFrequency=$1 + fi + + if [ $# -ge 2 ]; then + let gTdp=$2 + echo "Max TDP override, now using: $gTdp Watt" + fi + + if [ $# -eq 3 ]; then + if [ $3 -eq 0 ]; + then + let gBridgeType=2 + echo "CPU type override, now using: Sandy Bridge" + else + let gBridgeType=4 + echo "CPU type override, now using: Ivy Bridge" + fi + fi + fi + + echo "$logicalCPUs logical CPU's detected with a Core Frequency of $frequency MHz" + + # + # Check maxTurboFrequency + # + if [ $maxTurboFrequency == 0 ]; then + printf "\nError: Unknown processor number... exiting\n" + echo "Try: $0 MaxTurboFrequency [TDP (Watts) CPU (0=SandyBridge, 1=IvyBridge)]" + exit 1 + fi + + # + # Get number of Turbo states. + # + let turboStates=$(echo "(($maxTurboFrequency - $frequency) / 100)" | bc) + + # + # Check number of Turbo states. + # + if [ $turboStates -lt 0 ]; then + let turboStates=0 + fi + + # + # Report number of Turbo States + # + if [ $turboStates -gt 0 ]; + then + let minTurboFrequency=($frequency+100) + echo "Number of Turbo States: $turboStates ($minTurboFrequency-$maxTurboFrequency MHz)" + + else + echo "Number of Turbo States: 0" + fi + + local packageLength=$(echo "((($maxTurboFrequency - $gBaseFrequency)+100) / 100)" | bc) + + echo "Number of P-States: $packageLength ($gBaseFrequency-$maxTurboFrequency MHz)" + + _printHeader + _printExternals $logicalCPUs + _printDebugInfo $logicalCPUs $gTdp $packageLength $turboStates $maxTurboFrequency + _printScopeStart $turboStates $packageLength + _printPackages $gTdp $frequency $maxTurboFrequency + + _getBoardID + + local modelID=$(_getModelName) + + local cpu_type=$(_getCPUtype) + local currentSystemType=$(_getSystemType) + + if [ $gBridgeType -eq $IVY_BRIDGE ]; + then + local cpuTypeString="07" + + _initIvyBridgeSetup + + _printScopeACST 0 + _printMethodDSM + _printScopeCPUn $logicalCPUs + else + local cpuTypeString="06" + + _initSandyBridgeSetup + + _printScopeACST 0 + _printScopeCPUn $logicalCPUs + fi + + _showLowPowerStates + + if [ ${cpu_type:0:2} -ne $cpuTypeString ]; then + echo "Warning: 'cpu-type' may be set improperly (0x$cpu_type instead of 0x$cpuTypeString${cpu_type:2:2})" + fi + + if [ $gSystemType -eq 0 ]; + then + echo "Warning: 'board-id' [$boardID] is not supported by $bridgeTypeString PM" + else + if [ "$gMacModelIdentifier" != "$modelID" ]; then + echo "Error: board-id [$boardID] and model [$modelID] mismatch" + fi + + if [ $currentSystemType -ne $gSystemType ]; then + echo "Warning: 'system-type' may be set improperly ($currentSystemType instead of $gSystemType)" + fi + fi +} + +#==================================== START ===================================== + +main "$1" $2 $3 + +_findIasl + +if ((gCallIasl)); then + # + # Compile SSDT.dsl + # + "$iasl" $gSsdtPR + + # + # Copy SSDT_PR.aml to target location + # + if (($gAutoCopy)); then + _setDestinationPath + cp $gSsdtPR ${gDestinationPath}${gDestinationFile} + fi + +fi + +if ((gCallOpen)); then + open $gSsdtPR +fi + +exit 0 + +#================================================================================ diff --git a/i386/libsaio/acpi/Tools/ssdtPRGen.app/Contents/MacOS/ssdtPRGen b/i386/libsaio/acpi/Tools/ssdtPRGen.app/Contents/MacOS/ssdtPRGen new file mode 100755 index 0000000..499c981 Binary files /dev/null and b/i386/libsaio/acpi/Tools/ssdtPRGen.app/Contents/MacOS/ssdtPRGen differ diff --git "a/i386/libsaio/acpi/Tools/ssdtPRGen.app/Icon\r" "b/i386/libsaio/acpi/Tools/ssdtPRGen.app/Icon\r" new file mode 100644 index 0000000..e69de29 diff --git a/i386/libsaio/acpi/Tools/ssdtPRGen.sh b/i386/libsaio/acpi/Tools/ssdtPRGen.sh new file mode 100755 index 0000000..7ca0a48 --- /dev/null +++ b/i386/libsaio/acpi/Tools/ssdtPRGen.sh @@ -0,0 +1,2390 @@ +#!/bin/bash +# +# Script (ssdtPRGen.sh) to create ssdt-pr.dsl for Apple Power Management Support. +# +# Version 0.9 - Copyright (c) 2012 by RevoGirl +# Version 9.1 - Copyright (c) 2014 by Pike +# +# Updates: +# - Added support for Ivy Bridge (Pike, January 2013) +# - Filename error fixed (Pike, January 2013) +# - Namespace error fixed in _printScopeStart (Pike, January 2013) +# - Model and board-id checks added (Pike, January 2013) +# - SMBIOS cpu-type check added (Pike, January 2013) +# - Copy/paste error fixed (Pike, January 2013) +# - Method ACST added to CPU scopes for IB CPUPM (Pike, January 2013) +# - Method ACST corrected for latest version of iasl (Dave, January 2013) +# - Changed path/filename to ~/Desktop/SSDT_PR.dsl (Dave, January 2013) +# - P-States are now one-liners instead of blocks (Pike, January 2013) +# - Support for flexible ProcessorNames added (Pike, Februari 2013) +# - Better feedback and Debug() injection added (Pike, Februari 2013) +# - Automatic processor type detection (Pike, Februari 2013) +# - TDP and processor type are now optional arguments (Pike, Februari 2013) +# - system-type check (used by X86PlatformPlugin) added (Pike, Februari 2013) +# - ACST injection for all logical processors (Pike, Februari 2013) +# - Introducing a stand-alone version of method _DSM (Pike, Februari 2013) +# - Fix incorrect turbo range (Pike, Februari 2013) +# - Restore IFS before return (Pike, Februari 2013) +# - Better/more complete feedback added (Jeroen, Februari 2013) +# - Processor data for desktop/mobile and server CPU's added (Jeroen, Februari 2013) +# - Improved power calculation, matching Apple's new algorithm (Pike, Februari 2013) +# - Fix iMac13,N latency and power values for C3 (Jeroen/Pike, Februari 2013) +# - IASL failed to launch when path included spaces (Pike, Februari 2013) +# - Typo in cpu-type check fixed (Jeroen, Februari 2013) +# - Error in CPU data (i5-3317U) fixed (Pike, Februari 2013) +# - Setting added for the target path/filename (Jeroen, Februari 2013) +# - Initial implementation of auto-copy (Jeroen, Februari 2013) +# - Additional checks added for cpu data/turbo modes (Jeroen, Februari 2013) +# - Undo filename change done by Jeroen (Pike, Februari 2013) +# - Improved/faster search algorithm to locate iasl (Jeroen, Februari 2013) +# - Bug fix, automatic revision update and better feedback (Pike, Februari 2013) +# - Turned auto copy on (Jeroen, Februari 2013) +# - Download IASL if it isn't there where we expect it (Pike, Februari 2013) +# - A sweet dreams update for Pike who wants better feedback (Jeroen, Februari 2013) +# - First set of Haswell processors added (Pike/Jeroen, Februari 2013) +# - More rigid testing for user errors (Pike/Jeroen, Februari 2013) +# - Getting ready for new Haswell setups (Pike/Jeroen, Februari 2013) +# - Typo and ssdtPRGen.command breakage fixed (Jeroen, Februari 2013) +# - Target folder check added for _findIASL (Pike, Februari 2013) +# - Set $baseFreqyency to $lfm when the latter isn't zero (Pike, Februari 2013) +# - Check PlatformSupport.plist for supported model/board-id added (Jeroen, Februari 2013) +# - New/expanded Sandy Bridge CPU lists, thanks to Francis (Jeroen, Februari 2013) +# - More preparations for the official Haswell launch (Pike, Februari 2013) +# - Fix for home directory with space characters (Pike, Februari 2013) +# - Sandy Bridge CPU lists rearranged/extended, thanks to 'stinga11' (Jeroen, Februari 2013) +# - Now supporting up to 16 logical cores (Jeroen, Februari 2013) +# - Improved argument checking, now supporting a fourth argument (Jeroen/Pike, Februari 2013) +# - Suppress override output when possible (Jeroen, Februari 2013) +# - Get processor label from ioreg (Jeroen/Pike, Februari 2013) +# - Create /usr/local/bin when missing (Jeroen, Februari 2013) +# - Changed warnings to make them pop out in the on-screen log (Pike, March 2013) +# - Now using the ACPI processor names of the running system (Pike, March 2013) +# - Now supporting up to 256/0xff logical processors (Pike, March 2013) +# - Command line argument for processor labels added (Pike, March 2013) +# - Bug fix, overriding the cpu type displayed the wrong name (Jeroen, March 2013) +# - Automatic detection of CPU scopes added (Pike, March 2013) +# - Show warnings for Sandy Bridge systems as well (Jeroen, March 2013) +# - New Intel Haswell processors added (Jeroen, April 2013) +# - Improved Processor declaration detection (Jeroen/Pike, April 2013) +# - New path for Clover revision 1277 (Jeroen, April 2013) +# - Haswell's minimum core frequency is 800 MHz (Jeroen, April 2013) +# - CPU signature output added (Jeroen/Pike, April 2013) +# - Updating to v6.4 after Jeroen's accidental RM of my local RevoBoot directory (Pike, May 2013) +# - Updating to v6.5 with bugs fixes and EFI partition checking for Clover compatibility (Pike, May 2013) +# - Output of Clover ACPI directory detection fixed (Pike, June 2013) +# - Haswell CPUs added (Jeroen, June 2013) +# - board-id's for new MacBookAir6,[1/2] added (Pike, June 2013) +# - board-id's for new iMac14,[1/2/3] added (Pike, October 2013) +# - board-id's for new MacBookPro11,[1/2/3] added (Pike, October 2013) +# - Cleanups and board-id for new MacPro6,1 added (Pike, October 2013) +# – Frequency error in i7-4700MQ data fixed, thanks to RehabMan (Pike, November 2013) +# - Intel i5-4200M added (Pike, December 2013) +# - LFM fixed in the Intel i7-3930K data (Pike, December 2013) +# - Intel E5-2695 V2 added (Pike, December 2013) +# - Intel i3-3250 added (Pike, December 2013) +# - Sed RegEx error fixed in _getCPUtype (Pike, January 2014) +# - Fixed a typo 's/i7-2640M/i7-2674M/' (Pike, January 2014) +# - Fixed a typo 's/gHaswellCPUList/gServerHaswellCPUList/' (Pike, January 2014) +# - Intel E5-26nn v2 Xeon Processors added (Pike, January 2014) +# - Show the CPU brandstring at all times (Pike, January 2014) +# - Fixed cpu-type suggestion for MacPro6,1 (Pike, January 2014) +# - Intel i7-4771 added (Pike, January 2014) +# - A couple Intel Haswell/Crystal Well processor models added (Pike, January 2014) +# - Moved a couple of Ivy Bridge desktop model processors to the right spot (Pike, January 2014) +# - Experimental code added for Gringo Vermelho (Pike, January 2014) +# - Fixed a typo so that checking gIvyWorkAround really works (Pike, January 2014) +# - Added extra OS checks (as a test) to filter out possibly unwanted LFM P-States (Pike, January 2014) +# - Let gIvyWorkAround control the additional LFM P-States (Pike, January 2014) +# - Fixed a typo in processor data (i7-4960K should be i7-4960X) (Pike, January 2014) +# +# Contributors: +# - Thanks to Dave, toleda and Francis for their help (bug fixes and other improvements). +# - Thanks to 'stinga11' for Sandy Bridge (E5) data and processor list errors. +# - Many thanks to Jeroen († 2013) for the CPU data, cleanups, renaming stuff and other improvements. +# - Thanks to 'philip_petev' for his help with Snow Leopard/egrep incompatibility. +# - Thanks to 'RehabMan' for his help with Snow Leopard/egrep incompatibility. +# - Thanks to 'BigDonkey' for his help with LFM (800 MHz) for Sandy Bridge mobility models. +# - Thanks to 'rtcl777' on Github issues for the tip about a typo in the iMac12 board-id's. +# - Thanks to 'xpamamadeus' for the Clover boot.log tip. +# - Thanks to 'rileyfreeman' for the Intel i7-3930K LFM value. +# - Thanks to 'Klonkrieger2' aka Mark for the tip about the sed RegEx error in _getCPUtype. +# - Thanks to 'dhnguyen92' on Github issues for the tip about a typo in the i7-2640M model data. +# - Thanks to 'fabiosun' on Github issues for the tip about a typo in the cpu-type check. +# - Thanks to 'Hackmodford ' on Github issues for testing/confirming that PM in Mavericks was changed. +# +# Bugs: +# - Bug reports can be filed at https://github.com/Piker-Alpha/RevoBoot/issues +# Please provide clear steps to reproduce the bug, the output of the +# script and the resulting SSDT.dsl Thank you! +# +# Usage (v1.0 - v4.9): +# +# - ./ssdtPRGen.sh [max turbo frequency] [TDP] [CPU type] +# +# - ./ssdtPRGen.sh +# - ./ssdtPRGen.sh 3600 +# - ./ssdtPRGen.sh 3600 70 +# - ./ssdtPRGen.sh 3600 70 1 +# +# Usage (v5.0 and greater): +# +# - ./ssdtPRGen.sh [processor number] [max turbo frequency] [TDP] [CPU type] +# +# - ./ssdtPRGen.sh E5-1650 +# +# - ./ssdtPRGen.sh 'E3-1220 v2' +# - ./ssdtPRGen.sh 'E3-1220 v2' 3600 +# - ./ssdtPRGen.sh 'E3-1220 v2' 3600 70 +# - ./ssdtPRGen.sh 'E3-1220 v2' 3600 70 1 +# +# Usage (v5.5 and greater): +# +# - ./ssdtPRGen.sh [processor number] [max turbo frequency] [TDP] [CPU type] [ACPI Processor Name] +# +# - ./ssdtPRGen.sh E5-1650 +# +# - ./ssdtPRGen.sh 'E3-1220 v2' +# - ./ssdtPRGen.sh 'E3-1220 v2' 3600 +# - ./ssdtPRGen.sh 'E3-1220 v2' 3600 70 +# - ./ssdtPRGen.sh 'E3-1220 v2' 3600 70 1 +# - ./ssdtPRGen.sh 'E3-1220 v2' 3600 70 1 CPU +# + +# set -x # Used for tracing errors (can be used anywhere in the script). + +#================================= GLOBAL VARS ================================== + +# +# Script version info. +# +gScriptVersion=9.1 + +# +# Change this to 1 when your CPU is stuck in Low Frequency Mode! +# +# 1 - Injects one extra Turbo P-State at he top with max-Turbo frequency + 1 MHz. +# 2 - Injects N extra Turbo P-States at the bottom. +# 3 - Injects both of them. +# +let gIvyWorkAround=3 + +# +# Asks for your confirmation to copy ssdt_pr.aml to /Extra/ssdt.aml (example) +# +let gAutoCopy=1 + +# +# This is the target location that ssdt.aml will be copied to. +# +# Note: Do no change this - will be updated automatically for Clover/RevoBoot! +# +gDestinationPath="/Extra/" + +# +# This is the filename used for the copy process +# +gDestinationFile="ssdt_pr.aml" + +# +# A value of 1 will make this script call iasl (compiles ssdt_pr.dsl) +# +# Note: Will be set to 0 when we failed to locate a copy of iasl! +# +let gCallIasl=1 + +# +# A value of 1 will make this script open ssdt_pr.dsl in the editor of your choice. +# +let gCallOpen=1 + +# 0 = no debug injection/debug statements executed. +# 1 = inject debug data. +# 3 = inject debug data and execute _debugPrint statements. +# +let gDebug=1 + +# +# Lowest possible idle frequency (user configurable). Also known as Low Frequency Mode. +# +let gBaseFrequency=1600 + +# +# This is the default processor label (verified by _setProcessorLabel). +# +gProcLabel="CPU" + +# +# This is the default (ACPI 1.0 compliant) processor scope (verified by _getProcessorScope). +# +gScope="\_PR_" + +# +# Other global variables. +# + +gRevision='0x0000'${gScriptVersion:0:1}${gScriptVersion:2:1}'00' + +# +# Path and filename setup. +# + +gPath=~/Desktop +gSsdtID="ssdt_pr" +gSsdtPR="${gPath}/${gSsdtID}.dsl" + +let gDesktopCPU=1 +let gMobileCPU=2 +let gServerCPU=3 + +let gSystemType=0 + +let gACST_CPU0=13 +let gACST_CPU1=7 + +gMacModelIdentifier="" + +let HASWELL=8 +let IVY_BRIDGE=4 +let SANDY_BRIDGE=2 + +let gTypeCPU=0 +gProcessorData="Unknown CPU" +gProcessorNumber="" +gBusFrequency=100 +let gUnmountEFIPartition=0 + +gProductName=$(sw_vers -productName) +gProductVersion="$(sw_vers -productVersion)" +gBuildVersion=$(sw_vers -buildVersion) +let gOSVersion=$(echo $gProductVersion | tr -d '.') + +# +# Maximum Turbo Clock Speed (user configurable) +# +let gMaxOCFrequency=6300 + +let MAX_TURBO_FREQUENCY_ERROR=2 +let MAX_TDP_ERROR=3 +let TARGET_CPU_ERROR=4 +let PROCESSOR_NUMBER_ERROR=5 +let PROCESSOR_LABEL_LENGTH_ERROR=6 +let PROCESSOR_NAMES_ERROR=7 +let PROCESSOR_DECLARATION_ERROR=8 + +# +# First OS version number that no longer requires extra Low Frequency Mode P-States. +# +# Note: For future use (when we figured out what we need). +# +let LFM_REQUIRED_OS=1091 + +# +# Processor Number, Max TDP, Low Frequency Mode, Clock Speed, Max Turbo Frequency, Cores, Threads +# + +gServerSandyBridgeCPUList=( +# E5-2600 Xeon Processor Series +E5-2687W,150,0,3100,3800,8,16 +# E5-1600 Xeon Processor Series +E5-1660,130,0,3300,3900,6,12 +E5-1650,130,0,3200,3800,6,12 +E5-1620,130,0,3600,3800,4,8 +# E3-1200 Xeon Processor Series +E3-1290,95,0,3600,4000,4,8 +E3-1280,95,0,3500,3900,4,8 +E3-1275,95,0,3400,3800,4,8 +E3-1270,80,0,3400,3800,4,8 +E3-1260L,45,0,2400,3300,4,8 +E3-1245,95,0,3300,3700,4,8 +E3-1240,80,0,3300,3700,4,8 +E3-1235,95,0,3200,3600,4,8 +E3-1230,80,0,3200,3600,4,8 +E3-1225,95,0,3100,3400,4,4 +E3-1220L,20,0,2200,3400,2,4 +E3-1220,80,0,3100,3400,4,4 +) + +gDesktopSandyBridgeCPUList=( +i7-35355,120,1600,2666,2666,4,4 +# i7 Desktop Extreme Series +i7-3970X,150,1200,3500,4000,6,12 +i7-3960X,130,1200,3300,3900,6,12 +i7-3930K,130,1200,3200,3800,6,12 +i7-3820,130,1200,3600,3800,4,8 +# i7 Desktop series +i7-2600S,65,1600,2800,3800,4,8 +i7-2600,95,1600,3400,3800,4,8 +i7-2600K,95,1600,3400,3800,4,8 +i7-2700K,95,1600,3500,3900,4,8 +# i5 Desktop Series +i5-2300,95,1600,2800,3100,4,4 +i5-2310,95,1600,2900,3200,4,4 +i5-2320,95,1600,3000,3300,4,4 +i5-2380P,95,1600,3100,3400,4,4 +i5-2390T,35,1600,2700,3500,2,4 +i5-2400S,65,1600,2500,3300,4,4 +i5-2405S,65,1600,2500,3300,4,4 +i5-2400,95,1600,3100,3400,4,4 +i5-2450P,95,1600,3200,3500,4,4 +i5-2500T,45,1600,2300,3300,4,4 +i5-2500S,65,1600,2700,3700,4,4 +i5-2500,95,1600,3300,3700,4,4 +i5-2500K,95,1600,3300,3700,4,4 +i5-2550K,95,1600,3400,3800,4,4 +# i3 1200 Desktop Series +i3-2130,65,1600,3400,0,2,4 +i3-2125,65,1600,3300,0,2,4 +i3-2120T,35,1600,2600,0,2,4 +i3-2120,65,1600,3300,0,2,4 +i3-2115C,25,1600,2000,0,2,4 +i3-2105,65,1600,3100,0,2,4 +i3-2102,65,1600,3100,0,2,4 +i3-2100T,35,1600,2500,0,2,4 +i3-2100,65,1600,3100,0,2,4 +) + +gMobileSandyBridgeCPUList=( +# i7 Mobile Extreme Series +i7-2960XM,55,800,2700,3700,4,8 +i7-2920XM,55,800,2500,3500,4,8 +# i7 Mobile Series +i7-2860QM,45,800,2500,3600,4,8 +i7-2820QM,45,800,2300,3400,4,8 +i7-2760QM,45,800,2400,3500,4,8 +i7-2720QM,45,800,2200,3300,4,8 +i7-2715QE,45,800,2100,3000,4,8 +i7-2710QE,45,800,2100,3000,4,8 +i7-2677M,17,800,1800,2900,2,4 +i7-2675QM,45,800,2200,3100,4,8 +i7-2670QM,45,800,2200,3100,4,8 +i7-2675M,17,800,1600,2700,2,4 +i7-2655LE,25,800,2200,2900,2,4 +i7-2649M,25,800,2300,3200,2,4 +i7-2640M,35,800,2800,3500,2,4 +i7-2637M,17,800,1700,2800,2,4 +i7-2635QM,45,800,2000,2900,4,8 +i7-2630QM,45,800,2000,2900,4,8 +i7-2629M,25,800,2100,3000,2,4 +i7-2620M,35,800,2700,3400,2,4 +i7-2617M,17,800,1500,2600,2,4 +i7-2610UE,17,800,1500,2400,2,4 +# i5 Mobile Series +i5-2467M,17,800,1600,2300,2,4 +i5-2450M,35,800,2300,3100,2,4 +i5-2435M,35,800,2400,3000,2,4 +i5-2430M,35,800,2400,3000,2,4 +i5-2410M,35,800,2300,2900,2,4 +i5-2557M,17,800,1700,2700,2,4 +i5-2540M,35,800,2600,3300,2,4 +i5-2537M,17,800,1400,2300,2,4 +i5-2520M,35,800,2500,3200,2,4 +i5-2515E,35,800,2500,3100,2,4 +i5-2510E,35,800,2500,3100,2,4 +# i3 2300 Mobile Series +i3-2377M,17,800,1500,0,2,4 +i3-2370M,35,800,2400,0,2,4 +i3-2367M,17,800,1400,0,2,4 +i3-2365M,17,800,1400,0,2,4 +i3-2357M,17,800,1300,0,2,4 +i3-2350M,35,800,2300,0,2,4 +i3-2348M,35,800,2300,0,2,4 +i3-2340UE,17,800,1300,0,2,4 +i3-2330M,35,800,2200,0,2,4 +i3-2330E,35,800,2200,0,2,4 +i3-2328M,35,800,2200,0,2,4 +i3-2312M,35,800,2100,0,2,4 +i3-2310M,35,800,2100,0,2,4 +i3-2310E,35,800,2100,0,2,4 +) + + +# +# Processor Number, Max TDP, Low Frequency Mode, Clock Speed, Max Turbo Frequency, Cores, Threads +# + +gServerIvyBridgeCPUList=( +# E3-1200 Xeon Processor Series +'E3-1290 v2',87,1200,3700,4100,4,8 +'E3-1280 v2',69,1200,3600,4000,4,8 +'E3-1275 v2',77,1200,3500,3900,4,8 +'E3-1270 v2',69,1200,3500,3900,4,8 +'E3-1265L v2',45,1200,2500,3500,4,8 +'E3-1245 v2',77,1200,3400,3800,4,8 +'E3-1240 v2',69,1200,3400,3800,4,8 +'E3-1230 v2',69,1200,3300,3700,4,8 +'E3-1225 v2',77,1200,3200,3600,4,4 +'E3-1220 v2',69,1200,3100,3500,4,4 +'E3-1220L v2',17,1200,2300,3500,2,4 +# E5-2600 Xeon Processor Series +'E5-2687W v2',150,1200,3400,4000,8,16 +'E5-2658 v2 ',95,1200,2400,3000,10,20 +'E5-2648L v2',70,1200,1900,2500,10,20 +'E5-2628L v2',70,1200,1900,2400,8,16 +'E5-2603 v2',80,1200,1800,1800,4,4 +'E5-2637 v2',130,1200,3500,3800,4,8 +'E5-2630L v2',60,1200,2400,2800,6,12 +'E5-2630 v2',80,1200,2600,3100,6,12 +'E5-2620 v2',80,1200,2100,2600,6,12 +'E5-2618L v2',50,1200,2000,2000,6,12 +'E5-2609 v2',80,1200,2500,2500,4,4 +'E5-2697 v2',130,1200,2700,3500,12,24 +'E5-2695 v2',115,1200,2400,3200,12,24 +'E5-2690 v2',130,1200,3000,3600,10,20 +'E5-2680 v2',115,1200,2800,3600,10,20 +'E5-2670 v2',115,1200,2500,3300,10,20 +'E5-2667 v2',130,1200,3300,4000,6,16 +'E5-2660 v2',95,1200,2200,3000,10,20 +'E5-2650L v2',70,1200,1700,2100,10,20 +'E5-2650 v2',95,1200,2600,3400,8,16 +'E5-2643 v2',130,1200,3500,3800,6,12 +'E5-2640 v2',95,1200,2000,2500,8,16 +) + +gDesktopIvyBridgeCPUList=( +# Socket 2011 (Premium Power) +i7-4960X,130,1200,3600,4000,6,12 +i7-4930K,130,1200,3400,3900,6,12 +i7-4820K,130,1200,3700,3900,4,8 +# i7-3700 Desktop Processor Series +i7-3770T,45,1600,2500,3700,4,8 +i7-3770S,65,1600,3100,3900,4,8 +i7-3770K,77,1600,3500,3900,4,8 +i7-3770,77,1600,3400,3900,4,8 +# i5-3500 Desktop Processor Series +i5-3570T,45,1600,2300,3300,4,4 +i5-3570K,77,1600,3400,3800,4,4 +i5-3570S,65,1600,3100,3800,4,4 +i5-3570,77,1600,3400,3800,4,4 +i5-3550S,65,1600,3000,3700,4,4 +i5-3550,77,1600,3300,3700,4,4 +# i5-3400 Desktop Processor Series +i5-3475S,65,1600,2900,3600,4,4 +i5-3470S,65,1600,2900,3600,4,4 +i5-3470,77,1600,3200,3600,4,4 +i5-3470T,35,1600,2900,3600,2,4 +i5-3450S,65,1600,2800,3500,4,4 +i5-3450,77,1600,3100,3500,4,4 +# i5-3300 Desktop Processor Series +i5-3350P,69,1600,3100,3300,4,4 +i5-3330S,65,1600,2700,3200,4,4 +i5-3333S,65,1600,2700,3200,4,4 +i5-3330S,65,1600,3700,3200,4,4 +i5-3330,77,1600,3000,3200,4,4 +# i3-3200 Desktop Processor Series +i3-3250,55,1600,3500,0,2,4 +i3-3240,55,1600,3400,0,2,4 +i3-3240T,35,1600,2900,0,2,4 +i3-3225,55,1600,3300,0,2,4 +i3-3220,55,1600,3300,0,2,4 +i3-3220T,35,1600,2800,0,2,4 +i3-3210,55,1600,3200,0,2,4 +) + +gMobileIvyBridgeCPUList=( +# i7-3800 Mobile Processor Series +i7-3840QM,45,1200,2800,3800,4,8 +i7-3820QM,45,1200,2700,3700,4,8 +# i7-3700 Mobile Processor Series +i7-3740QM,45,1200,2700,3700,4,8 +i7-3720QM,45,1200,2600,3600,4,8 +# i7-3600 Mobile Processor Series +i7-3689Y,13,0,1500,2600,2,4 +i7-3687U,17,800,2100,3300,2,4 +i7-3667U,17,800,2000,3200,2,4 +i7-3635QM,45,0,2400,3400,4,8 +i7-3620QM,35,0,2200,3200,4,8 +i7-3632QM,35,0,2200,3200,4,8 +i7-3630QM,45,0,2400,3400,4,8 +i7-3615QM,45,0,2300,3300,4,8 +i7-3615QE,45,0,2300,3300,4,8 +i7-3612QM,35,0,2100,3100,4,8 +i7-3612QE,35,0,2100,3100,4,8 +i7-3610QM,45,0,2300,3300,4,8 +i7-3610QE,45,0,2300,3300,4,8 +# i7-3500 Mobile Processor Series +i7-3555LE,25,0,2500,3200,2,4 +i7-3540M,35,1200,3000,3700,2,4 +i7-3537U,17,800,2000,3100,2,4 +i7-3520M,35,1200,2900,3600,2,4 +i7-3517UE,17,0,1700,2800,2,4 +i7-3517U,17,0,1900,3000,2,4 +# i5-3600 Mobile Processor Series +i5-3610ME,35,0,2700,3300,2,4 +# i5-3400 Mobile Processor Series +i5-3439Y,13,0,1500,2300,2,4 +i5-3437U,17,800,1900,2900,2,4 +i5-3427U,17,800,1800,2800,2,4 +# i5-3300 Mobile Processor Series +i5-3380M,35,1200,2900,3600,2,4 +i5-3360M,35,1200,2800,3500,2,4 +i5-3340M,35,1200,2700,3400,2,4 +i5-3339Y,13,0,1500,2000,2,4 +i5-3337U,17,0,1800,2700,2,4 +i5-3320M,35,1200,2600,3300,2,4 +i5-3317U,17,0,1700,2600,2,4 +# i5-3200 Mobile Processor Series +i5-3230M,35,1200,2600,3200,2,4 +i5-3210M,35,1200,2500,3100,2,4 +# i3-3200 Mobile Processor Series +i3-3239Y,13,0,1400,0,2,4 +i3-3227U,17,800,1900,0,2,4 +i3-3217UE,17,0,1600,0,2,4 +i3-3217U,17,0,1800,0,2,4 +# i3-3100 Mobile Processor Series +i3-3130M,35,1200,2600,0,2,4 +i3-3120ME,35,0,2400,0,2,4 +i3-3120M,35,0,2500,0,2,4 +i3-3110M,35,0,2400,0,2,4 +) + +# +# New Haswell processors (with HD-4600 graphics) +# +gServerHaswellCPUList=( +# E3-1200 v3 Xeon Processor Series +'E3-1285L v3',65,800,3100,3900,4,8 +'E3-1285 v3',84,800,3600,4000,4,8 +'E3-1280 v3',82,800,3600,4000,4,8 +'E3-1275 v3',84,800,3500,3900,4,8 +'E3-1270 v3',80,800,3500,3900,4,8 +'E3-1268L v3',45,800,2300,3300,4,8 +'E3-1265L v3',45,800,2500,3700,4,8 +'E3-1245 v3',84,800,3400,3800,4,8 +'E3-1240 v3',80,800,3400,3800,4,8 +'E3-1230L v3',25,800,1800,2800,4,8 +'E3-1230 v3',80,800,3300,3700,4,8 +'E3-1225 v3',80,800,3200,3600,4,4 +'E3-1220 v3',80,800,3100,3500,4,4 +'E3-1220L v3',13,800,1100,1500,2,4 +) + +gDesktopHaswellCPUList=( +# Socket 1150 (Standard Power) +i7-4770K,84,800,3500,3900,4,8 +i7-4771,84,800,3500,3900,4,8 +i7-4770,84,800,3400,3900,4,8 +i5-4670K,84,800,3400,3800,4,4 +i5-4670,84,800,3400,3800,4,4 +i5-4570,84,800,3200,3600,4,4 +i5-4440,84,800,3100,3300,4,4 +i5-4430,84,800,3000,3200,4,4 +# Socket 1150 (Low Power) +i7-4770S,65,800,3100,3900,4,8 +i7-4770T,45,800,2500,3700,4,8 +i7-4765T,35,800,2000,3000,4,8 +i5-4670S,65,800,3100,3800,4,4 +i5-4670T,45,800,2300,3300,4,4 +i5-4570S,65,800,2900,3600,4,4 +i5-4570T,35,800,2900,3600,2,4 +i5-4430S,65,800,2700,3200,4,4 +# BGA +i7-4770R,65,800,3200,3900,4,8 +i5-4670R,65,800,3000,3700,4,4 +# Haswell ULT +i5-4288U,28,800,2600,3100,2,4 +i5-4258U,28,800,2400,2900,2,4 +i5-4250U,15,800,1300,2600,2,4 +i5-4200Y,12,800,1400,1900,2,4 +i5-4200U,15,800,1600,2600,2,4 +# +i3-4130T,35,800,2900,2900,2,4 +i3-4330T,35,800,3000,3000,2,4 +i3-4130,54,800,3400,3400,2,4 +i3-4330,54,800,3500,3500,2,4 +i3-4340,54,800,3600,3600,2,4 +) + +gMobileHaswellCPUList=( +# Socket FCBGA1364 +i7-4960HQ,47,800,2600,3800,4,8 +i7-4950HQ,47,800,2400,3600,4,8 +i7-4850HQ,47,800,2300,3500,4,8 +i7-4750HQ,47,800,2000,3200,4,8 +i7-4702HQ,37,800,2200,3200,4,8 +i7-4700HQ,47,800,2400,3600,4,8 +# Extreme Edition Series - socket FCPGA946 +i7-4930MX,57,800,3000,3900,4,8 +# Socket FCPGA946 +i7-4900MQ,47,800,2800,3800,4,8 +i7-4800MQ,47,800,2700,3700,4,8 +i7-4702MQ,37,800,2200,3200,4,8 +i7-4700MQ,47,800,2400,3400,4,8 +i5-4200M,37,800,2500,3100,2,4 +# Socket FCBGA1168 +i7-4650U,15,800,1700,3300,2,4 +i7-4650U,15,800,1700,3300,2,4 +i7-4600U,15,800,2100,3300,2,4 +i7-4558U,28,800,2800,3300,2,4 +i7-4550U,15,800,1500,3000,2,4 +i7-4500U,15,800,1800,3000,2,4 +i5-4350U,15,800,1400,2900,2,4 +i5-4288U,28,800,2600,3100,2,4 +i5-4258U,28,800,2400,2900,2,4 +i5-4250U,15,800,1300,2600,2,4 +i5-4200U,15,800,1600,2600,2,4 +i5-4200Y,12,800,1400,1900,2,4 +# Socket FCBGA1168 +i3-4158U,28,800,2000,2000,2,4 +i3-4100U,15,800,1800,1800,2,4 +i3-4010U,15,800,1700,1700,2,4 +i3-4010Y,12,800,1300,1300,2,4 +) + +#-------------------------------------------------------------------------------- + +function _printHeader() +{ + echo '/*' > $gSsdtPR + echo ' * Intel ACPI Component Architecture' >> $gSsdtPR + echo ' * AML Disassembler version 20130210-00 [Feb 10 2013]' >> $gSsdtPR + echo ' * Copyright (c) 2000 - 2013 Intel Corporation' >> $gSsdtPR + echo ' * ' >> $gSsdtPR + echo ' * Original Table Header:' >> $gSsdtPR + echo ' * Signature "SSDT"' >> $gSsdtPR + echo ' * Length 0x0000036A (874)' >> $gSsdtPR + echo ' * Revision 0x01' >> $gSsdtPR + echo ' * Checksum 0x00' >> $gSsdtPR + echo ' * OEM ID "APPLE "' >> $gSsdtPR + echo ' * OEM Table ID "CpuPm"' >> $gSsdtPR + printf ' * OEM Revision '$gRevision' (%d)\n' $gRevision >> $gSsdtPR + echo ' * Compiler ID "INTL"' >> $gSsdtPR + echo ' * Compiler Version 0x20130210 (538116624)' >> $gSsdtPR + echo ' */' >> $gSsdtPR + echo '' >> $gSsdtPR + echo 'DefinitionBlock ("'$gSsdtID'.aml", "SSDT", 1, "APPLE ", "CpuPm", '$gRevision')' >> $gSsdtPR + echo '{' >> $gSsdtPR +} + +#-------------------------------------------------------------------------------- + +function _printExternals() +{ + let currentCPU=0; + + while [ $currentCPU -lt $gLogicalCPUs ]; do + echo ' External ('${gScope}'.'${gProcessorNames[$currentCPU]}', DeviceObj)' >> $gSsdtPR + let currentCPU+=1 + done + + echo '' >> $gSsdtPR +} + +#-------------------------------------------------------------------------------- + +function _injectDebugInfo() +{ + xcpm=0 + + # + # Check OS version ('machdep.xcpm' is introduced in 10.8.5) + # + if [[ $gOSVersion > 1084 ]]; then + xcpm=$(/usr/sbin/sysctl -n machdep.xcpm.mode) + fi + + echo ' Method (_INI, 0, NotSerialized)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Store ("ssdtPRGen version: '$gScriptVersion' / '$gProductName' '$gProductVersion' ('$gBuildVersion')", Debug)' >> $gSsdtPR + echo ' Store ("target processor : '$gProcessorNumber'", Debug)' >> $gSsdtPR + echo ' Store ("running processor: '$gBrandString'", Debug)' >> $gSsdtPR + echo ' Store ("baseFrequency : '$gBaseFrequency'", Debug)' >> $gSsdtPR + echo ' Store ("frequency : '$frequency'", Debug)' >> $gSsdtPR + echo ' Store ("busFrequency : '$gBusFrequency'", Debug)' >> $gSsdtPR + echo ' Store ("logicalCPUs : '$gLogicalCPUs'", Debug)' >> $gSsdtPR + echo ' Store ("tdp : '$gTdp'", Debug)' >> $gSsdtPR + echo ' Store ("packageLength : '$packageLength'", Debug)' >> $gSsdtPR + echo ' Store ("turboStates : '$turboStates'", Debug)' >> $gSsdtPR + echo ' Store ("maxTurboFrequency: '$maxTurboFrequency'", Debug)' >> $gSsdtPR + echo ' Store ("gIvyWorkAround : '$gIvyWorkAround'", Debug)' >> $gSsdtPR + echo ' Store ("machdep.xcpm.mode: '$xcpm'", Debug)' >> $gSsdtPR + echo ' }' >> $gSsdtPR + echo '' >> $gSsdtPR +} + +#-------------------------------------------------------------------------------- + +function _printProcessorDefinitions() +{ + let currentCPU=0; + + while [ $currentCPU -lt $1 ]; do + echo ' External ('${gScope}'.'${gProcessorNames[$currentCPU]}', DeviceObj)' >> $gSsdtPR + let currentCPU+=1 + done + + echo '' >> $gSsdtPR +} + +#-------------------------------------------------------------------------------- + +function _printScopeStart() +{ + let turboStates=$1 + let packageLength=$2 + + # TODO: Remove this when CPUPM for IB works properly! + let useWorkArounds=0 + + echo ' Scope ('${gScope}'.'${gProcessorNames[0]}')' >> $gSsdtPR + echo ' {' >> $gSsdtPR + + if (( gDebug & 1 )); then + _injectDebugInfo + fi + + # + # Do we need to create additional (Low Frequency) P-States? + # + if [ $gBridgeType -ne $SANDY_BRIDGE ]; + then + let lowFrequencyPStates=0 + + # + # Do we need to add additional (Low Frequency) P-States for Ivy Bridge? + # + if (( $gBridgeType == $IVY_BRIDGE && $gIvyWorkAround & 2 )); then + let lowFrequencyPStates=($gBaseFrequency/100)-8 + fi + + let packageLength=($2+$lowFrequencyPStates) + + if [[ lowFrequencyPStates -gt 0 ]]; + then + printf " Name (APLF, 0x%02x)\n" $lowFrequencyPStates >> $gSsdtPR + else + # Prevent optimization warning. + echo " Name (APLF, Zero)" >> $gSsdtPR + fi + + # TODO: Remove this when CPUPM for IB works properly! + if (( $gBridgeType == $IVY_BRIDGE && $gIvyWorkAround & 1 )); then + let useWorkArounds=1 + fi + fi + + # + # Check number of Turbo states (for IASL optimization). + # + if [ $turboStates -eq 0 ]; + then + # TODO: Remove this when CPUPM for IB works properly! + if (($useWorkArounds)); + then + echo ' Name (APSN, One)' >> $gSsdtPR + else + echo ' Name (APSN, Zero)' >> $gSsdtPR + fi + else + # TODO: Remove this when CPUPM for IB works properly! + if ((useWorkArounds)); then + let turboStates+=1 + fi + + printf " Name (APSN, 0x%02X)\n" $turboStates >> $gSsdtPR + fi + + # TODO: Remove this when CPUPM for IB works properly! + if (($useWorkArounds)); then + let packageLength+=1 + fi + + printf " Name (APSS, Package (0x%02X)\n" $packageLength >> $gSsdtPR + echo ' {' >> $gSsdtPR + + # TODO: Remove this when CPUPM for IB works properly! + if (($useWorkArounds)); then + let extraF=($maxTurboFrequency+1) + let maxTDP=($gTdp*1000) + let extraR=($maxTurboFrequency/100)+1 + echo " /* Workaround for the Ivy Bridge PM 'bug' */" >> $gSsdtPR + printf " Package (0x06) { 0x%04X, 0x%06X, 0x0A, 0x0A, 0x%02X00, 0x%02X00 },\n" $extraF $maxTDP $extraR $extraR >> $gSsdtPR + fi +} + + +#-------------------------------------------------------------------------------- + +function _printPackages() +{ + let maxTDP=($1*1000) + local maxNonTurboFrequency=$2 + local frequency=$3 + + let minRatio=($gBaseFrequency/$gBusFrequency) + let p1Ratio=($maxNonTurboFrequency/$gBusFrequency) + let ratio=($frequency/$gBusFrequency) + let powerRatio=($p1Ratio-1) + + # + # Do we need to add additional (Low Frequency) P-States for Ivy Bridge? + # + if (( $gBridgeType == $IVY_BRIDGE && $gIvyWorkAround & 2 )); then + let minRatio=8 + fi + + if (($turboStates)); then + echo ' /* High Frequency Modes (turbo) */' >> $gSsdtPR + fi + + while [ $ratio -ge $minRatio ]; + do + if [ $frequency -eq $gBaseFrequency ]; + then + echo ' /* Low Frequency Mode */' >> $gSsdtPR + fi + + if [ $frequency -eq $maxNonTurboFrequency ]; + then + echo ' /* High Frequency Modes (non-turbo) */' >> $gSsdtPR + fi + + printf " Package (0x06) { 0x%04X, " $frequency >> $gSsdtPR + + if [ $frequency -lt $maxNonTurboFrequency ]; + then + power=$(echo "scale=6;m=((1.1-(($p1Ratio-$powerRatio)*0.00625))/1.1);(($powerRatio/$p1Ratio)*(m*m)*$maxTDP);" | bc | sed -e 's/.[0-9A-F]*$//') + let powerRatio-=1 + else + power=$maxTDP + fi + + if [ $frequency -ge $gBaseFrequency ]; + then + printf "0x%06X, " $power >> $gSsdtPR + else + printf ' Zero, ' >> $gSsdtPR + fi + + printf "0x0A, 0x0A, 0x%02X00, 0x%02X00 }" $ratio $ratio >> $gSsdtPR + + let ratio-=1 + let frequency-=$gBusFrequency + + if [ $ratio -ge $minRatio ]; + then + echo ',' >> $gSsdtPR + else + echo '' >> $gSsdtPR + fi + + done + + echo ' })' >> $gSsdtPR +} + + +#-------------------------------------------------------------------------------- + +function _printMethodDSM() +{ + # + # New stand-alone version of Method _DSM - Copyright (c) 2009 by Master Chief + # + echo '' >> $gSsdtPR + echo ' Method (_DSM, 4, NotSerialized)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + + if ((gDebug)); then + # + # Note: This will be called twice! + # + echo ' Store ("Method '${gProcessorNames[0]}'._DSM Called", Debug)' >> $gSsdtPR + echo '' >> $gSsdtPR + fi + + echo ' If (LEqual (Arg2, Zero))' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Return (Buffer (One)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' 0x03' >> $gSsdtPR + echo ' })' >> $gSsdtPR + echo ' }' >> $gSsdtPR + echo '' >> $gSsdtPR + # + # This property is required to get X86Platform[Plugin/Shim].kext loaded. + # + echo ' Return (Package (0x02)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' "plugin-type",' >> $gSsdtPR + echo ' One' >> $gSsdtPR + echo ' })' >> $gSsdtPR + echo ' }' >> $gSsdtPR + echo ' }' >> $gSsdtPR +} + +#-------------------------------------------------------------------------------- + +function _debugPrint() +{ + if (( gDebug & 2 )); then + printf "$1" + fi +} + +#-------------------------------------------------------------------------------- + +function _printScopeACST() +{ +# +# Intel values for Sandy / Ivy Bridge processors +# +# C-state : Power : SB Latency : IB Latency +#---------:---------:------------:------------ +# C1 : 0x3e8 : 0x01 : 0x03 +# C3 : 0x1f4 : 0x50 : 0xcd +# C6 : 0x15e : 0x68 : 0xf5 +# C7 : 0xc8 : 0x6d : 0xf5 +# +# Note: C-state latency in uS and C-state power in mW. + + let C1=0 + let C2=0 + let C3=0 + let C6=0 + let C7=0 + local pkgLength=2 + local numberOfCStates=0 + + # + # Are we injecting C-States for CPU1? + # + if [ $1 -eq 1 ]; + then + let targetCPU=1 + else + let targetCPU=0 + fi + + echo '' >> $gSsdtPR + echo ' Method (ACST, 0, NotSerialized)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + + if ((gDebug)); then + echo ' Store ("Method '${gProcessorNames[$targetCPU]}'.ACST Called", Debug)' >> $gSsdtPR + fi + + # + # Are we injecting C-States for CPU1? + # + if [ $targetCPU -eq 1 ]; + then + # Yes (also used by CPU2, CPU3 and greater). + let targetCStates=$gACST_CPU1 + latency_C1=0x03E8 + latency_C2=0x94 + latency_C3=0xC6 + else + # + # C-States override for Mobile processors (CPU0 only) + # + if (($gTypeCPU == $gMobileCPU)); then + echo 'Adjusting C-States for detected (mobile) processor' + let gACST_CPU0=29 + fi + + let targetCStates=$gACST_CPU0 + latency_C1=Zero + latency_C2=0x43 + latency_C3=0xCD + latency_C6=0xF5 + latency_C7=0xF5 + fi + + if ((gDebug)); then + echo ' Store ("'${gProcessorNames[$targetCPU]}' C-States : '$targetCStates'", Debug)' >> $gSsdtPR + echo '' >> $gSsdtPR + fi + + + _debugPrint "targetCStates: $targetCStates\n" + + # + # Checks to determine which C-State(s) we should inject. + # + if (($targetCStates & 1)); then + _debugPrint "Adding C1\n" + let C1=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + if (($targetCStates & 2)); then + _debugPrint "Adding C2\n" + let C2=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + if (($targetCStates & 4)); then + _debugPrint "Adding C3\n" + let C3=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + if (($targetCStates & 8)); then + _debugPrint "Adding C6\n" + let C6=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + if ((($targetCStates & 16) == 16)); then + _debugPrint "Adding C7\n" + let C7=1 + let numberOfCStates+=1 + let pkgLength+=1 + fi + + let hintCode=0x00 + + echo " /* Low Power Modes for ${gProcessorNames[$1]} */" >> $gSsdtPR + printf " Return (Package (0x%02x)\n" $pkgLength >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' One,' >> $gSsdtPR + printf " 0x%02x,\n" $numberOfCStates >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x01, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' One,' >> $gSsdtPR + echo ' '$latency_C1',' >> $gSsdtPR + echo ' 0x03E8' >> $gSsdtPR + + if (($C2)); then + let hintCode+=0x10 + echo ' },' >> $gSsdtPR + echo '' >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x03, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' 0x02,' >> $gSsdtPR + echo ' '$latency_C2',' >> $gSsdtPR + echo ' 0x01F4' >> $gSsdtPR + fi + + if (($C3)); then + let hintCode+=0x10 + local power_C3=0x01F4 + # + # Is this for CPU1? + # + if (($1)); then + if [[ ${modelID:0:7} == "iMac13," ]]; + then + local power_C3=0x15E + latency_C3=0xA9 + else + local power_C3=0xC8 + let hintCode+=0x10 + fi + fi + + echo ' },' >> $gSsdtPR + echo '' >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x03, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' 0x03,' >> $gSsdtPR + echo ' '$latency_C3',' >> $gSsdtPR + echo ' '$power_C3 >> $gSsdtPR + fi + + if (($C6)); then + let hintCode+=0x10 + echo ' },' >> $gSsdtPR + echo '' >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x03, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' 0x06,' >> $gSsdtPR + echo ' '$latency_C6',' >> $gSsdtPR + echo ' 0x015E' >> $gSsdtPR + fi + + if (($C7)); then + # + # If $hintCode is already 0x30 then use 0x31 otherwise 0x30 + # + if [ $hintCode -eq 48 ]; + then + let hintCode+=0x01 + else + let hintCode+=0x10 + fi + echo ' },' >> $gSsdtPR + echo '' >> $gSsdtPR + echo ' Package (0x04)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' ResourceTemplate ()' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Register (FFixedHW,' >> $gSsdtPR + echo ' 0x01, // Bit Width' >> $gSsdtPR + echo ' 0x02, // Bit Offset' >> $gSsdtPR + printf " 0x%016x, // Address\n" $hintCode >> $gSsdtPR + echo ' 0x03, // Access Size' >> $gSsdtPR + echo ' )' >> $gSsdtPR + echo ' },' >> $gSsdtPR + echo ' 0x07,' >> $gSsdtPR + echo ' '$latency_C7',' >> $gSsdtPR + echo ' 0xC8' >> $gSsdtPR + fi + + echo ' }' >> $gSsdtPR + echo ' })' >> $gSsdtPR + echo ' }' >> $gSsdtPR + + # + # We don't need a closing bracket here when we add method _DSM for Ivy Bridge. + # + + if [ $gBridgeType -eq $SANDY_BRIDGE ]; then + echo ' }' >> $gSsdtPR + fi +} + + +#-------------------------------------------------------------------------------- + +function _printScopeCPUn() +{ + let currentCPU=1; + + while [ $currentCPU -lt $gLogicalCPUs ]; do + echo '' >> $gSsdtPR + echo ' Scope ('${gScope}'.'${gProcessorNames[$currentCPU]}')' >> $gSsdtPR + echo ' {' >> $gSsdtPR + echo ' Method (APSS, 0, NotSerialized)' >> $gSsdtPR + echo ' {' >> $gSsdtPR + + if ((gDebug)); then + echo ' Store ("Method '${gProcessorNames[$currentCPU]}'.APSS Called", Debug)' >> $gSsdtPR + echo '' >> $gSsdtPR + fi + + echo ' Return ('${gScope}'.'${gProcessorNames[0]}'.APSS)' >> $gSsdtPR + echo ' }' >> $gSsdtPR + + # + # IB CPUPM tries to parse/execute CPUn.ACST (see debug data) and thus we add + # this method, conditionally, since SB CPUPM doesn't seem to care about it. + # + if [ $gBridgeType -ge $IVY_BRIDGE ]; then + if [ $currentCPU -eq 1 ]; + then + _printScopeACST 1 + else + echo '' >> $gSsdtPR + echo ' Method (ACST, 0, NotSerialized) { Return ('${gScope}'.'${gProcessorNames[1]}'.ACST ()) }' >> $gSsdtPR + fi + fi + + echo ' }' >> $gSsdtPR + let currentCPU+=1 + done + + echo '}' >> $gSsdtPR +} + +#-------------------------------------------------------------------------------- + +function _getModelName() +{ + # + # Grab 'compatible' property from ioreg (stripped with sed / RegEX magic). + # + echo `ioreg -p IODeviceTree -d 2 -k compatible | grep compatible | sed -e 's/ *["=<>]//g' -e 's/compatible//'` +} + +#-------------------------------------------------------------------------------- + +function _getBoardID() +{ + # + # Grab 'board-id' property from ioreg (stripped with sed / RegEX magic). + # + boardID=$(ioreg -p IODeviceTree -d 2 -k board-id | grep board-id | sed -e 's/ *["=<>]//g' -e 's/board-id//') +} + +#-------------------------------------------------------------------------------- + +function _getProcessorNames() +{ + local acpiNames=$(ioreg -p IODeviceTree -c IOACPIPlatformDevice -k cpu-type | egrep name | sed -e 's/ *[-|="]//g') + gProcessorNames=($acpiNames) + + if [[ ${#gProcessorNames[@]} -lt 2 ]]; then + _exitWithError $PROCESSOR_NAMES_ERROR + fi +} + +#-------------------------------------------------------------------------------- + +function _updateProcessorNames() +{ + if [[ $gLogicalCPUs -le 0x0f ]]; + then + local label=${gProcLabel:0:3} + else + local label=${gProcLabel:0:2} + fi + + if [[ $1 -gt ${#gProcessorNames[@]} ]]; then + echo -e "\nWarning: Target CPU has $gLogicalCPUs logical cores, the running system only ${#gProcessorNames[@]}" + echo " Now using '$label' to extent the current range to $gLogicalCPUs..." + echo -e " You may want to check/verify the generated $gSsdtID.dsl\n" + fi + + let currentCPU=0 + + while [ $currentCPU -lt $1 ]; + do + if [[ $1 -gt 0x0f && $currentCPU -le 0x0f ]]; + then + local filler='0' + else + local filler='' + fi + + gProcessorNames[$currentCPU]=${label}${filler}$(echo "obase=16; ${currentCPU}" | bc) + + let currentCPU+=1 + done +} + +#-------------------------------------------------------------------------------- + +function _getProcessorScope() +{ + # + # We run egrep twice here for Snow Leopard compatibility, otherwise it fails. + # + if [[ $(ioreg -c AppleACPIPlatformExpert -rd1 -w0 | egrep -o 'DSDT"=<[0-9a-f]+' | egrep -o '5b830b') ]]; then + echo 'Processor Declaration(s) Found in DSDT' + return + fi + + if [[ $(ioreg -c AppleACPIPlatformExpert -rd1 -w0 | egrep -o 'DSDT"=<[0-9a-f]+' | egrep -o '5f50525f') ]]; + then + gScope="\_PR_" + echo ' (ACPI 1.0 compliant)' + return + else + gScope="\_SB_" + return + fi + # + # Additional/experimental code for support of broken ACPI tables. + # + if [[ $(ioreg -c AppleACPIPlatformExpert -rd1 -w0 | egrep -o 'DSDT"=<[0-9a-f]+' | egrep -o '5f5052') ]]; + then + gScope="\_PR_" + echo ' (ACPI 1.0 compliant)' + fi +} + +#-------------------------------------------------------------------------------- + +function _getCPUtype() +{ + # + # Grab 'cpu-type' property from ioreg (stripped with sed / RegEX magic). + # + local grepStr=$(ioreg -p IODeviceTree -n "${gProcessorNames[0]}"@0 -k cpu-type | grep cpu-type | sed -e 's/["cputype" ,<>|=-]//g') + + # Swap bytes with help of ${str:pos:num} + # + echo ${grepStr:2:2}${grepStr:0:2} +} + +#-------------------------------------------------------------------------------- + +function _getCPUModel() +{ + # + # Returns the hexadecimal value of machdep.cpu.model + # + echo 0x$(echo "obase=16; `sysctl machdep.cpu.model | sed -e 's/^machdep.cpu.model: //'`" | bc) +} + +#-------------------------------------------------------------------------------- + +function _getCPUSignature() +{ + # + # Returns the hexadecimal value of machdep.cpu.signature + # + echo 0x$(echo "obase=16; `sysctl machdep.cpu.signature | sed -e 's/^machdep.cpu.signature: //'`" | bc) +} + +#-------------------------------------------------------------------------------- + +function _getSystemType() +{ + # + # Grab 'system-type' property from ioreg (stripped with sed / RegEX magic). + # + # Note: This property is checked (cmpb $0x02) in X86PlatformPlugin::configResourceCallback + # + echo `ioreg -p IODeviceTree -d 2 -k system-type | grep system-type | sed -e 's/ *[-="<0a-z>]//g'` +} + +#-------------------------------------------------------------------------------- + +function _findIasl() +{ + if (($gCallIasl)); then + # + # Then we do a quick lookup of iasl (should also be there after the first run) + # + if [ ! -f /usr/local/bin/iasl ]; then + printf "\nIASL not found. " + # + # First we check the target directory (should be there after the first run) + # + # XXX: Jeroen, try curl --create-dirs without the mkdir here ;) + if [ ! -d /usr/local/bin ]; then + printf "Creating target directory... " + sudo mkdir -p /usr/local/bin/ + sudo chown -R root:wheel /usr/local/bin/ + fi + + printf "Downloading iasl...\n" + sudo curl -o /usr/local/bin/iasl https://raw.github.com/Piker-Alpha/RevoBoot/clang/i386/libsaio/acpi/Tools/iasl +# sudo curl https://raw.github.com/Piker-Alpha/RevoBoot/clang/i386/libsaio/acpi/Tools/iasl -o /usr/local/bin/iasl --create-dirs + sudo chmod +x /usr/local/bin/iasl + echo 'Done.' + fi + + iasl=/usr/local/bin/iasl + fi +} + +#-------------------------------------------------------------------------------- + +function _setDestinationPath +{ + # + # Checking for RevoBoot + # + if [ -d /Extra/ACPI ]; then + gDestinationPath="/Extra/ACPI/" + echo -e '\nACPI target directory changed to: '$gDestinationPath + return + fi + + # + # Checking for Clover rev 1277 and greater (projectosx.com/forum/index.php?showtopic=2656&p=29129&#entry29129) + # + if [ -d /EFI/Clover/ACPI/patched ]; + then + gDestinationPath="/EFI/Clover/ACPI/patched/" + echo -e '\nACPI target directory changed to: $gDestinationPath' + return + else + if [ -d /Volumes/EFI ]; + then + if [ -d /Volumes/EFI/Clover/ACPI/patched ]; then + gDestinationPath="/Volumes/EFI/CLOVER/ACPI/patched/" + echo -e '\nACPI target directory changed to: '$gDestinationPath + return + fi + else + # + # http://www.tonymacx86.com/ssdt/86906-ssdt-generation-script-ivybridge-pm-40.html#post604496 + # + if [ -f /Library/Logs/CloverEFI/boot.log ]; + then + echo 'Clover boot.log found' + return + else + echo -e '\nWarning: Failed to locate the Clover boot.log' + echo 'Creating temporarily mount point: /Volumes/EFI' + sudo mkdir /Volumes/EFI + printf 'Mounting EFI partition...\n' + # + # TODO: Get target disk from diskutil list + # + sudo mount_hfs /dev/disk0s1 /Volumes/EFI + + if [ -f /Volumes/EFI/Clover/ACPI/patched ]; + then + let gUnmountEFIPartition=1 + gDestinationPath="/Volumes/EFI/CLOVER/ACPI/patched/" + echo 'ACPI target directory changed to: '$gDestinationPath + return + else + echo -e '\nUnmounting EFI partition...' + sudo umount -f /Volumes/EFI + echo 'Removing temporarily mount point...' +# sudo rm -r /Volumes/EFI + return + fi + fi + + fi + fi + + # + # Checking for Clover (older versions) + # + if [ -d /EFI/ACPI/patched ]; then + gDestinationPath="/EFI/ACPI/patched/" + echo 'ACPI target directory changed to: '$gDestinationPath + return + fi +} + +#-------------------------------------------------------------------------------- + +function _getCPUNumberFromBrandString +{ + # + # Get CPU brandstring + # + gBrandString=$(echo `sysctl machdep.cpu.brand_string` | sed -e 's/machdep.cpu.brand_string: //') + # + # Show brandstring (this helps me to debug stuff). + # + printf "Brandstring '${gBrandString}'\n" + # + # Save default (0) delimiter + # + local ifs=$IFS + # + # Change delimiter to a space character + # + IFS=" " + # + # Split brandstring into array (data) + # + local data=($gBrandString) + # + # Teststrings + # + # local data=("Intel(R)" "Xeon(R)" "CPU" "E3-1220" "@" "2.5GHz") + # local data=("Intel(R)" "Xeon(R)" "CPU" "E3-1220" "v2" "@" "2.5GHz") + # local data=("Intel(R)" "Xeon(R)" "CPU" "E3-1220" "v3" "@" "2.5GHz") + # local data=("Intel(R)" "Xeon(R)" "CPU" "E3-1220" "0" "@" "2.5GHz") + # local data=("Intel(R)" "Core(TM)" "i5-4670K" "CPU" "@" "3.40GHz") + + # + # Example from a MacBookPro10,2 + # + # echo "${data[0]}" # Intel(R) + # echo "${data[1]}" # Core(TM) + # echo "${data[2]}" # i5-3210M + # echo "${data[3]}" # CPU + # echo "${data[4]}" # @ + # echo "${data[5]}" # 2.50GHz + # + # or: "Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz" + # + # echo "${data[0]}" # Intel(R) + # echo "${data[1]}" # Xeon(R) + # echo "${data[2]}" # CPU + # echo "${data[3]}" # E3-12XX + # echo "${data[4]}" # V2 + # echo "${data[5]}" # @ + # echo "${data[6]}" # 3.30GHz + + # + # Restore the default delimiter + # + IFS=$ifs + + let length=${#data[@]} + + if ((length > 7)); then + echo 'Warning: The brandstring has an unexpected length!' + fi + + # + # Is this a Xeon processor model? + # + if [[ "${data[1]}" == "Xeon(R)" ]]; + then + # + # Yes. Check for lower/upper case 'v' or '0' for OEM processors. + # + if [[ "${data[4]}" =~ "v" || "${data[4]}" =~ "V" ]]; + then + # + # Use a lowercase 'v' because that is what we use in our data. + # + gProcessorNumber="${data[3]} v${data[4]:1:1}" + elif [[ "${data[4]}" == "0" ]]; + then + # + # OEM CPU's have been reported to use a "0" instead of "v2" + # and thus let's use that to make our data match the CPU. + # + gProcessorNumber="${data[3]} v2" + fi + else + # + # All other non-Xeon processor models. + # + gProcessorNumber="${data[2]}" + fi +} + +#-------------------------------------------------------------------------------- + +function _getCPUDataByProcessorNumber +{ + # + # Local function definition + # + function __searchList() + { + local ifs=$IFS + let targetType=0 + + case $1 in + 2) local cpuSpecLists=("gDesktopSandyBridgeCPUList[@]" "gMobileSandyBridgeCPUList[@]" "gServerSandyBridgeCPUList[@]") + ;; + 4) local cpuSpecLists=("gDesktopIvyBridgeCPUList[@]" "gMobileIvyBridgeCPUList[@]" "gServerIvyBridgeCPUList[@]") + ;; + 8) local cpuSpecLists=("gDesktopHaswellCPUList[@]" "gMobileHaswellCPUList[@]" "gServerHaswellCPUList[@]") + ;; + esac + + for cpuList in ${cpuSpecLists[@]} + do + let targetType+=1 + local targetCPUList=("${!cpuList}") + + for cpuData in "${targetCPUList[@]}" + do + IFS="," + data=($cpuData) + + if [[ ${data[0]} == $gProcessorNumber ]]; then + gProcessorData="$cpuData" + let gTypeCPU=$targetType + let gBridgeType=$1 + IFS=$ifs + return + fi + done + done + + IFS=$ifs + } + + # + # Local function callers + # + __searchList $SANDY_BRIDGE + + if (!(($gTypeCPU))); then + __searchList $IVY_BRIDGE + fi + + if (!(($gTypeCPU))); then + __searchList $HASWELL + fi +} + +#-------------------------------------------------------------------------------- + +function _showLowPowerStates() +{ + # + # Local function definition + # + function __print() + { + local mask=1 + local cStates=$1 + + printf "Injected C-States for ${gProcessorNames[$2]} (" + # + # Haswell : C0, C1, C1E, C2E, C3, C4, C6 and C7 + # Haswell-ULT: C0, C1, C1E, C2E, C3, C4, C6, C7, C8, C9 and C10 + # + for state in C1 C2 C3 C6 C7 C8 C9 C10 + do + if (($cStates & $mask)); then + if (($mask > 1)); then + printf "," + fi + + printf "$state" + fi + + let mask=$(($mask << 1)) + done + + echo ')' + } + + # + # Local function callers + # + __print $gACST_CPU0 0 + + if [ $gBridgeType -ge $IVY_BRIDGE ]; then + __print $gACST_CPU1 1 + fi +} + +#-------------------------------------------------------------------------------- + +function _checkPlatformSupport() +{ + # + # Local function definition + # + function __searchList() + { + local data=`awk '/'${1}'<\/key>.*/,/<\/array>/' /System/Library/CoreServices/PlatformSupport.plist` + local targetList=(`echo $data | egrep -o '(.*)' | sed -e 's/<\/*string>//g'`) + + for item in "${targetList[@]}" + do + if [ "$item" == "$2" ]; then + return 1 + fi + done + + return 0 + } + + # + # This check is required for Snow Leopard compatibility! + # + if [ -f /System/Library/CoreServices/PlatformSupport.plist ]; + then + __searchList 'SupportedModelProperties' $1 + + if (($? == 0)); then + __searchList 'SupportedBoardIds' $2 + + if (($? == 0)); then + echo 'Warning: Model identifier ['$1'] and board-id ['$2'] missing in: /S*/L*/CoreServices/PlatformSupport.plist' + fi + fi + else + echo 'Warning: /S*/L*/C*/PlatformSupport.plist not found (normal for Snow Leopard)!' + fi +} + +#-------------------------------------------------------------------------------- + +function _checkSMCKeys() +{ + # + # TODO: Check SMC keys to see if they are there and properly initialized! + # + # Note: Do not dump SMC keys with HWSensors/iStat or other SMC plug-ins installed! + # + local filename="/System/Library/Extensions/FakeSMC.kext/Contents/Info.plist" + local data=`grep -so '[a-zA-Z]*' $filename | sed -e 's///' -e 's/<\/key>//g'` + + local status=`echo $data | grep -oe 'DPLM'` + + if [ $status == 'DPLM' ]; then + # DPLM [{lim] (bytes 00 00 00 00 00) + # CPU, Idle, IGPU, EGPU and Memory P-State limits + echo "SMC key 'DPLM' found (OK)" + fi +set -x + local status=`echo $data | grep -oe 'MSAL'` + + if [ $status == 'MSAL' ]; then + # MSAL [hex_] (bytes 4b) + echo "SMC key 'MSAL' found (OK)" + fi +} + +#-------------------------------------------------------------------------------- + +function _initSandyBridgeSetup() +{ + case $boardID in + Mac-942B5BF58194151B) + gSystemType=1 + gMacModelIdentifier="iMac12,1" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-942B59F58194171B) + gSystemType=1 + gMacModelIdentifier="iMac12,2" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-8ED6AF5B48C039E1) + gSystemType=1 + gMacModelIdentifier="Macmini5,1" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-4BC72D62AD45599E) + gSystemType=1 + gMacModelIdentifier="Macmini5,2" + gACST_CPU0=13 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-7BA5B2794B2CDB12) + gSystemType=1 + gMacModelIdentifier="Macmini5,3" + gACST_CPU0=13 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-94245B3640C91C81) + gSystemType=2 + gMacModelIdentifier="MacBookPro8,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-94245A3940C91C80) + gSystemType=2 + gMacModelIdentifier="MacBookPro8,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-942459F5819B171B) + gSystemType=2 + gMacModelIdentifier="MacBookPro8,3" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-C08A6BB70A942AC2) + gSystemType=2 + gMacModelIdentifier="MacBookAir4,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-742912EFDBEE19B3) + gSystemType=2 + gMacModelIdentifier="MacBookAir4,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + esac +} + +#-------------------------------------------------------------------------------- + +function _initIvyBridgeSetup() +{ + case $boardID in + Mac-00BE6ED71E35EB86) + gSystemType=1 + gMacModelIdentifier="iMac13,1" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-FC02E91DDD3FA6A4) + gSystemType=1 + gMacModelIdentifier="iMac13,2" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-031AEE4D24BFF0B1) + gSystemType=1 + gMacModelIdentifier="Macmini6,1" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-F65AE981FFA204ED) + gSystemType=1 + gMacModelIdentifier="Macmini6,2" + gACST_CPU0=13 # C1, C3 and C6 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-4B7AC7E43945597E) + gSystemType=2 + gMacModelIdentifier="MacBookPro9,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-6F01561E16C75D06) + gSystemType=2 + gMacModelIdentifier="MacBookPro9,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-C3EC7CD22292981F) + gSystemType=2 + gMacModelIdentifier="MacBookPro10,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-AFD8A9D944EA4843) + gSystemType=2 + gMacModelIdentifier="MacBookPro10,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-66F35F19FE2A0D05) + gSystemType=2 + gMacModelIdentifier="MacBookAir5,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-2E6FAB96566FE58C) + gSystemType=2 + gMacModelIdentifier="MacBookAir5,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-F60DEB81FF30ACF6) + gSystemType=3 + gMacModelIdentifier="MacPro6,1" + gACST_CPU0=13 # C1, C3, C6 + gACST_CPU1=13 # C1, C3, C6 + ;; +esac +} + +#-------------------------------------------------------------------------------- + +function _initHaswellSetup() +{ + case $boardID in + Mac-031B6874CF7F642A) + gSystemType=1 + gMacModelIdentifier="iMac14,1" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-27ADBB7B4CEE8E61) + gSystemType=1 + gMacModelIdentifier="iMac14,2" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-77EB7D7DAF985301) + gSystemType=1 + gMacModelIdentifier="iMac14,3" + gACST_CPU0=29 # C1, C3, C6 and C7 + gACST_CPU1=7 # C1, C2 and C3 + ;; + + Mac-189A3D4F975D5FFC) + gSystemType=2 + gMacModelIdentifier="MacBookPro11,1" + gACST_CPU0=253 # C1, C3, C6, C7, C8, C9 and C10 + gACST_CPU1=31 # C1, C2, C3, C6 and C7 + ;; + + Mac-3CBD00234E554E41) + gSystemType=2 + gMacModelIdentifier="MacBookPro11,2" + gACST_CPU0=253 # C1, C3, C6, C7, C8, C9 and C10 + gACST_CPU1=31 # C1, C2, C3, C6 and C7 + ;; + + Mac-2BD1B31983FE1663) + gSystemType=2 + gMacModelIdentifier="MacBookPro11,3" + gACST_CPU0=253 # C1, C3, C6, C7, C8, C9 and C10 + gACST_CPU1=31 # C1, C2, C3, C6 and C7 + ;; + + Mac-35C1E88140C3E6CF) + gSystemType=2 + gMacModelIdentifier="MacBookAir6,1" + gACST_CPU0=29 # C1, C3, C6, C7 + gACST_CPU1=7 # C1, C2, C3 + ;; + + Mac-7DF21CB3ED6977E5) + gSystemType=2 + gMacModelIdentifier="MacBookAir6,2" + gACST_CPU0=29 # C1, C3, C6, C7 + gACST_CPU1=7 # C1, C2, C3 + ;; + + Mac-F60DEB81FF30ACF6) + gSystemType=3 + gMacModelIdentifier="MacPro6,1" + gACST_CPU0=13 # C1, C3, C6 + gACST_CPU1=13 # C1, C3, C6 + ;; + esac +} + +#-------------------------------------------------------------------------------- + +function _exitWithError() +{ + case "$1" in + 2) echo -e "\nError: 'MaxTurboFrequency' must be in the range of $frequency-$gMaxOCFrequency... exiting\n" 1>&2 + exit 2 + ;; + 3) echo -e "\nError: 'TDP' must be in the range of 10-150 Watts... exiting\n" 1>&2 + exit 3 + ;; + 4) echo -e "\nError: 'BridgeType' must be 0, 1 or 2... exiting\n" 1>&2 + exit 4 + ;; + 5) echo -e "\nError: Unknown processor number... exiting\n" 1>&2 + exit 5 + ;; + 6) echo -e "\nError: Processor label length is less than 3... exiting\n" 1>&2 + exit 6 + ;; + 7) echo -e "\nError: Processor label not found... exiting\n" 1>&2 + exit 7 + ;; + 8) echo -e "\nError: Processor Declaration not found... exiting\n" 1>&2 + exit 8 + ;; + *) exit 1 + ;; + esac +} + +#-------------------------------------------------------------------------------- + +function main() +{ + printf "\nssdtPRGen.sh v0.9 Copyright (c) 2011-2012 by † RevoGirl\n" + echo ' v6.6 Copyright (c) 2013 by † Jeroen' + printf " v$gScriptVersion Copyright (c) 2013-$(date "+%Y") by Pike R. Alpha\n" + echo '----------------------------------------------------------------' + printf "System information: $gProductName $gProductVersion ($gBuildVersion)\n" + + let assumedTDP=0 + let modelSpecified=0 + let maxTurboFrequency=0 + + _getCPUNumberFromBrandString + + _debugPrint "\ngProcessorNumber: $gProcessorNumber\n" + + if [[ "$1" != "" ]]; then + # Sandy Bridge checks + if [[ ${1:0:4} == "i3-2" || ${1:0:4} == "i5-2" || ${1:0:4} == "i7-2" ]]; then + let modelSpecified=1 + gProcessorNumber=$1 + fi + # Ivy Bridge checks + if [[ ${1:0:4} == "i3-3" || ${1:0:4} == "i5-3" || ${1:0:4} == "i7-3" ]]; then + let modelSpecified=1 + gProcessorNumber=$1 + fi + # Haswell checks + if [[ ${1:0:4} == "i3-4" || ${1:0:4} == "i5-4" || ${1:0:4} == "i7-4" ]]; then + let modelSpecified=1 + gProcessorNumber=$1 + fi + # Xeon check + if [[ ${1:0:1} == "E" ]]; then + let modelSpecified=1 + gProcessorNumber=$1 + fi + fi + + _getCPUDataByProcessorNumber + + if [[ $modelSpecified -eq 1 && $gTypeCPU -eq 0 ]]; then + _exitWithError $PROCESSOR_NUMBER_ERROR + fi + + if [[ $gBridgeType -eq 0 ]]; then + local model=$(_getCPUModel) + + if (($model==0x2A)); then + let gTdp=95 + let gBridgeType=2 + fi + + if (($model==0x2D)); then + let assumedTDP=1 + let gTdp=130 + let gBridgeType=2 + fi + + if (($model==0x3A || $model==0x3B || $model==0x3E)); then + let assumedTDP=1 + let gTdp=77 + let gBridgeType=4 + fi + + # Haswell + if (($model==0x3C)); then + let assumedTDP=1 + let gTdp=84 + let gBridgeType=8 + let gMaxOCFrequency=8000 + fi + + # Haswell SVR + if (($model==0x3F)); then + let assumedTDP=1 + let gTdp=130 + let gBridgeType=8 + fi + + # Haswell ULT + if (($model==0x45)); then + let assumedTDP=1 + let gTdp=15 + let gBridgeType=8 + fi + fi + + case $gBridgeType in + 2) local bridgeTypeString="Sandy Bridge" + ;; + 4) local bridgeTypeString="Ivy Bridge" + ;; + 8) local bridgeTypeString="Haswell" + ;; + *) local bridgeTypeString="Unknown" + ;; + esac + + _getBoardID + _getProcessorNames + _getProcessorScope + + local modelID=$(_getModelName) + local cpu_type=$(_getCPUtype) + local currentSystemType=$(_getSystemType) + local cpuSignature=$(_getCPUSignature) + + echo "Generating ${gSsdtID}.dsl for a $modelID [$boardID]" + echo "$bridgeTypeString Core $gProcessorNumber processor [$cpuSignature] setup [0x$cpu_type]" + + # + # gTypeCPU is greater than 0 when the processor is found in one of the CPU lists + # + if (($gTypeCPU)); + then + local ifs=$IFS + IFS="," + local cpuData=($gProcessorData) + let gTdp=${cpuData[1]} + let lfm=${cpuData[2]} + let frequency=${cpuData[3]} + let maxTurboFrequency=${cpuData[4]} + + if [ $maxTurboFrequency == 0 ]; then + let maxTurboFrequency=$frequency + fi + + let gLogicalCPUs=${cpuData[6]} + + IFS=$ifs + + echo 'With a maximum TDP of '$gTdp' Watt, as specified by Intel' + + # + # Check Low Frequency Mode (may be 0 aka still unknown) + # + if (($lfm > 0)); + then + let gBaseFrequency=$lfm + else + echo -e "\nWarning: Low Frequency Mode is 0 (unknown/unconfirmed)" + + if (($gTypeCPU == gMobileCPU)); + then + echo -e " Now using 1200 MHz for Mobile processor\n" + let gBaseFrequency=1200 + else + echo -e " Now using 1600 MHz for Server/Desktop processors\n" + let gBaseFrequency=1600 + fi + fi + else + let gLogicalCPUs=$(echo `sysctl machdep.cpu.thread_count` | sed -e 's/^machdep.cpu.thread_count: //') + let frequency=$(echo `sysctl hw.cpufrequency` | sed -e 's/^hw.cpufrequency: //') + let frequency=($frequency / 1000000) + + if [[ $assumedTDP -eq 1 ]]; then + echo "With a maximum TDP of ${gTdp} Watt - assumed/undetected CPU may require override value!" + fi + fi + + # + # Script argument checks + # + + if [[ $# -ge 2 ]]; then + if [[ "$2" =~ ^[0-9]+$ ]]; then + if [[ $2 -lt $frequency || $2 -gt $gMaxOCFrequency ]]; + then + _exitWithError $MAX_TURBO_FREQUENCY_ERROR + else + if [[ $2 -gt $maxTurboFrequency ]]; then + echo "Override value: Max Turbo Frequency, now using: $2 MHz!" + let maxTurboFrequency=$2 + fi + fi + fi + fi + + if [ $# -ge 3 ]; then + if [[ "$3" =~ ^[0-9]+$ ]]; + then + if [[ $3 -lt 10 || $3 -gt 150 ]]; + then + _exitWithError $MAX_TDP_ERROR + else + if [[ $gTdp != $3 ]]; then + let gTdp=$3 + echo "Override value: Max TDP, now using: $gTdp Watt!" + fi + fi + else + _exitWithError $MAX_TDP_ERROR + fi + fi + + if [ $# -ge 4 ]; then + if [[ "$4" =~ ^[0-9]+$ ]]; + then + local detectedBridgeType=$gBridgeType + + case "$4" in + 0) let gBridgeType=2 + local bridgeTypeString='Sandy Bridge' + ;; + 1) let gBridgeType=4 + local bridgeTypeString='Ivy Bridge' + ;; + 2) let gBridgeType=8 + local bridgeTypeString='Haswell' + ;; + *) _exitWithError $TARGET_CPU_ERROR + ;; + esac + + if [[ $detectedBridgeType -ne $((2 << $4)) ]]; then + echo "Override value: CPU type, now using: $bridgeTypeString" + fi + else + _exitWithError $TARGET_CPU_ERROR + fi + fi + + if [ $# -eq 5 ]; then + if [ ${#5} -eq 3 ]; + then + gProcLabel=$(echo "$5" | tr '[:lower:]' '[:upper:]') + echo "Override value: Now using '$gProcLabel' for ACPI processor names!" + _updateProcessorNames ${#gProcessorNames[@]} + else + _exitWithError $PROCESSOR_LABEL_LENGTH_ERROR + fi + fi + + echo "Number logical CPU's: $gLogicalCPUs (Core Frequency: $frequency MHz)" + + if [ $gLogicalCPUs -gt ${#gProcessorNames[@]} ]; then + _updateProcessorNames $gLogicalCPUs + fi + + # + # Check maxTurboFrequency + # + if [ $maxTurboFrequency -eq 0 ]; then + _exitWithError $MAX_TURBO_FREQUENCY_ERROR + fi + + # + # Get number of Turbo states. + # + let turboStates=$(echo "(($maxTurboFrequency - $frequency) / 100)" | bc) + + # + # Check number of Turbo states. + # + if [ $turboStates -lt 0 ]; then + let turboStates=0 + fi + + # + # Report number of Turbo States + # + if [ $turboStates -gt 0 ]; + then + let minTurboFrequency=($frequency+100) + echo "Number of Turbo States: $turboStates ($minTurboFrequency-$maxTurboFrequency MHz)" + + else + echo "Number of Turbo States: 0" + fi + + local packageLength=$(echo "((($maxTurboFrequency - $gBaseFrequency)+100) / 100)" | bc) + + echo "Number of P-States: $packageLength ($gBaseFrequency-$maxTurboFrequency MHz)" + + _printHeader + _printExternals + _printScopeStart $turboStates $packageLength + _printPackages $gTdp $frequency $maxTurboFrequency + + case "$gBridgeType" in + $SANDY_BRIDGE) + local cpuTypeString="06" + _initSandyBridgeSetup + _printScopeACST 0 + _printScopeCPUn + ;; + $IVY_BRIDGE) + local cpuTypeString="07" + _initIvyBridgeSetup + _printScopeACST 0 + _printMethodDSM + _printScopeCPUn + ;; + $HASWELL) + local cpuTypeString="08" + _initHaswellSetup + _printScopeACST 0 + _printMethodDSM + _printScopeCPUn + ;; + esac + # + # Is this a MacPro6,1 model? + # + if [[ $modelID == 'MacPro6,1' ]]; + then + # + # Yes. Use the correct string/value for the cpu-type suggestion. + # + local cpuTypeString="0a" + fi + + _showLowPowerStates + _checkPlatformSupport $modelID $boardID + + # + # Some Sandy Bridge/Ivy Bridge CPUPM specific configuration checks + # + if [ $gBridgeType -ne $HASWELL ]; + then + if [ ${cpu_type:0:2} != $cpuTypeString ]; + then + echo -e "\nWarning: 'cpu-type' may be set improperly (0x$cpu_type instead of 0x$cpuTypeString${cpu_type:2:2})" + elif [[ $gSystemType -eq 0 ]]; + then + echo -e "\nWarning: 'board-id' [$boardID] is not supported by $bridgeTypeString PM" + else + if [ "$gMacModelIdentifier" != "$modelID" ]; then + echo "Error: board-id [$boardID] and model [$modelID] mismatch" + fi + fi + fi + + if [ $currentSystemType -ne $gSystemType ]; then + echo -e "\nWarning: 'system-type' may be set improperly ($currentSystemType instead of $gSystemType)" + fi +} + +#==================================== START ===================================== + +clear + +if [ $# -eq 0 ]; + then + main "" $1 $2 $3 $4 + else + if [[ "$1" =~ ^[0-9]+$ ]]; + then + main "" $1 $2 $3 $4 + else + main "$1" $2 $3 $4 $5 + fi +fi + +_findIasl + +if (($gCallIasl)); then + # + # Compile ssdt.dsl + # + sudo "$iasl" $gSsdtPR + + # + # Copy ssdt_pr.aml to /Extra/ssdt.aml (example) + # + if (($gAutoCopy)); then + if [ -f ${gPath}/${gSsdtID}.aml ]; then + _setDestinationPath + echo -e + read -p "Do you want to copy ${gPath}/${gSsdtID}.aml to ${gDestinationPath}${gDestinationFile}? (y/n)?" choice + case "$choice" in + y|Y ) sudo cp ${gPath}/${gSsdtID}.aml ${gDestinationPath}${gDestinationFile} + ;; + esac + + if (($gUnmountEFIPartition)); then + echo -e '\nUnmounting EFI partition...' + sudo umount -f /Volumes/EFI + echo 'Removing temporarily mount point...' + sudo rm -r /Volumes/EFI + fi + fi + fi + +fi + +if ((gCallOpen)); then + open $gSsdtPR +fi + +exit 0 +#================================================================================ diff --git a/i386/libsaio/acpi/essentials.h b/i386/libsaio/acpi/essentials.h index 5d1486b..d6bfbcf 100644 --- a/i386/libsaio/acpi/essentials.h +++ b/i386/libsaio/acpi/essentials.h @@ -53,30 +53,57 @@ typedef struct static_acpi_2_table int tableLength; bool loaded; void * tableAddress; +#if LOAD_MODEL_SPECIFIC_ACPI_DATA + char fileName[32]; +#endif } __attribute__((packed)) ACPITable; static ACPITable customTables[] = { +#if LOAD_MODEL_SPECIFIC_ACPI_DATA // Essential tables. - { "APIC", APIC_Table, sizeof(APIC_Table), false, 0 }, - { "ECDT", ECDT_Table, sizeof(ECDT_Table), false, 0 }, - { "HPET", HPET_Table, sizeof(HPET_Table), false, 0 }, - { "MCFG", MCFG_Table, sizeof(MCFG_Table), false, 0 }, - { "SBST", SBST_Table, sizeof(SBST_Table), false, 0 }, - { "SSDT", SSDT_Table, sizeof(SSDT_Table), false, 0 }, + { "APIC", APIC_Table, sizeof(APIC_Table), false, 0, "" }, + { "DMAR", DMAR_Table, sizeof(DMAR_Table), false, 0, "" }, + { "ECDT", ECDT_Table, sizeof(ECDT_Table), false, 0, "" }, + { "HPET", HPET_Table, sizeof(HPET_Table), false, 0, "" }, + { "MCFG", MCFG_Table, sizeof(MCFG_Table), false, 0, "" }, + { "SBST", SBST_Table, sizeof(SBST_Table), false, 0, "" }, + { "SSDT", SSDT_Table, sizeof(SSDT_Table), false, 0, "" }, // Special essential tables. - { "DSDT", DSDT_Table, sizeof(DSDT_Table), false, 0 }, - { "FACS", FACS_Table, sizeof(FACS_Table), false, 0 }, + { "DSDT", DSDT_Table, sizeof(DSDT_Table), false, 0, "" }, + { "FACS", FACS_Table, sizeof(FACS_Table), false, 0, "" }, // Optional tables. - { "APIC-1", APIC2_Table, sizeof(APIC2_Table), false, 0 }, - { "SSDT_GPU", SSDT_GPU_Table, sizeof(SSDT_GPU_Table), false, 0 }, - { "SSDT_PR", SSDT_PR_Table, sizeof(SSDT_PR_Table), false, 0 }, - { "SSDT_SATA", SSDT_SATA_Table, sizeof(SSDT_SATA_Table), false, 0 }, - { "SSDT_USB", SSDT_USB_Table, sizeof(SSDT_USB_Table), false, 0 }, - { "", 0, 0, false, 0 } + { "APIC-1", APIC2_Table, sizeof(APIC2_Table), false, 0, "" }, + { "SSDT_GPU", SSDT_GPU_Table, sizeof(SSDT_GPU_Table), false, 0, "" }, + { "SSDT_PR", SSDT_PR_Table, sizeof(SSDT_PR_Table), false, 0, "" }, + { "SSDT_SATA", SSDT_SATA_Table, sizeof(SSDT_SATA_Table), false, 0, "" }, + { "SSDT_USB", SSDT_USB_Table, sizeof(SSDT_USB_Table), false, 0, "" }, + { "", 0, 0, false, 0, "" } +#else + // Essential tables. + { "APIC", APIC_Table, sizeof(APIC_Table), false, 0 }, + { "DMAR", DMAR_Table, sizeof(DMAR_Table), false, 0 }, + { "ECDT", ECDT_Table, sizeof(ECDT_Table), false, 0 }, + { "HPET", HPET_Table, sizeof(HPET_Table), false, 0 }, + { "MCFG", MCFG_Table, sizeof(MCFG_Table), false, 0 }, + { "SBST", SBST_Table, sizeof(SBST_Table), false, 0 }, + { "SSDT", SSDT_Table, sizeof(SSDT_Table), false, 0 }, + + // Special essential tables. + { "DSDT", DSDT_Table, sizeof(DSDT_Table), false, 0 }, + { "FACS", FACS_Table, sizeof(FACS_Table), false, 0 }, + + // Optional tables. + { "APIC-1", APIC2_Table, sizeof(APIC2_Table), false, 0 }, + { "SSDT_GPU", SSDT_GPU_Table, sizeof(SSDT_GPU_Table), false, 0 }, + { "SSDT_PR", SSDT_PR_Table, sizeof(SSDT_PR_Table), false, 0 }, + { "SSDT_SATA", SSDT_SATA_Table, sizeof(SSDT_SATA_Table), false, 0 }, + { "SSDT_USB", SSDT_USB_Table, sizeof(SSDT_USB_Table), false, 0 }, + { "", 0, 0, false, 0 } +#endif }; @@ -87,6 +114,7 @@ typedef enum // Essential tables. APIC, + DMAR, ECDT, HPET, MCFG, @@ -118,19 +146,19 @@ typedef enum // ACPI table signatures in little endian format. -#define RSDP_TABLE_SIGNATURE 0x50445352 -#define RSDT_TABLE_SIGNATURE 0x54445352 -#define XSDT_TABLE_SIGNATURE 0x54445358 #define APIC_TABLE_SIGNATURE 0x43495041 -#define ECDT_TABLE_SIGNATURE 0x54444345 +#define DMAR_TABLE_SIGNATURE 0x52414d44 #define DSDT_TABLE_SIGNATURE 0x54445344 +#define ECDT_TABLE_SIGNATURE 0x54444345 #define FACP_TABLE_SIGNATURE 0x50434146 #define FACS_TABLE_SIGNATURE 0x53434146 #define HPET_TABLE_SIGNATURE 0x54455048 -#define SBST_TABLE_SIGNATURE 0x54534253 #define MCFG_TABLE_SIGNATURE 0x4746434d +#define RSDP_TABLE_SIGNATURE 0x50445352 +#define RSDT_TABLE_SIGNATURE 0x54445352 +#define SBST_TABLE_SIGNATURE 0x54534253 #define SSDT_TABLE_SIGNATURE 0x54445353 - +#define XSDT_TABLE_SIGNATURE 0x54445358 typedef struct acpi_2_tables { @@ -144,6 +172,11 @@ typedef struct acpi_2_tables static ACPITables essentialTables[] = { { APIC, APIC_TABLE_SIGNATURE, replaceTable, kReplaceTable | kAddTable }, +#if DROP_FACTORY_DMAR_TABLE + { DMAR, DMAR_TABLE_SIGNATURE, NULL, kDropTable }, +#else + { DMAR, DMAR_TABLE_SIGNATURE, NULL, kReplaceTable | kAddTable }, +#endif { NONE, FACP_TABLE_SIGNATURE, patchFACPTable, kPatchTable }, { HPET, HPET_TABLE_SIGNATURE, replaceTable, kReplaceTable }, { MCFG, MCFG_TABLE_SIGNATURE, NULL, kReplaceTable }, @@ -236,7 +269,7 @@ typedef struct acpi_2_fadt { char Signature[4]; // FADT uint32_t Length; // Length varies per revision. - uint8_t Revision; // 1-4. + uint8_t Revision; // 1-5. uint8_t Checksum; char OEMID[6]; char OEMTableID[8]; diff --git a/i386/libsaio/acpi/examples/MAXIMUS V GENE/DSDT.dsl b/i386/libsaio/acpi/examples/MAXIMUS V GENE/DSDT.dsl new file mode 100644 index 0000000..0649962 --- /dev/null +++ b/i386/libsaio/acpi/examples/MAXIMUS V GENE/DSDT.dsl @@ -0,0 +1,3483 @@ +DefinitionBlock ("DSDT.aml", "DSDT", 3, "APPLE ", "iMac", 0x00310001) +{ + Scope (_PR) + { + Processor (CPU0, 0x01, 0x00000410, 0x06) {} + Processor (CPU1, 0x02, 0x00000410, 0x06) {} + Processor (CPU2, 0x03, 0x00000410, 0x06) {} + Processor (CPU3, 0x04, 0x00000410, 0x06) {} + Processor (CPU4, 0x05, 0x00000410, 0x06) {} + Processor (CPU5, 0x06, 0x00000410, 0x06) {} + Processor (CPU6, 0x07, 0x00000410, 0x06) {} + Processor (CPU7, 0x08, 0x00000410, 0x06) {} + } + + OperationRegion (GNVS, SystemMemory, 0xC8B89E18, 0x01D1) + Field (GNVS, AnyAcc, Lock, Preserve) + { + Offset (0x02), + SMIF, 8, + Offset (0x0B), + P80D, 32, + Offset (0x1A), + DTSE, 8, + Offset (0x1D), + DTSF, 8, + Offset (0x29), + TCNT, 8, + Offset (0x3C), + IGDS, 8, + Offset (0x75), + DSTS, 8, + Offset (0xEF), + L01C, 8, + Offset (0x15F), + TBAB, 32, + Offset (0x16B), + PFLV, 8, + Offset (0x172), + ESEL, 8, + Offset (0x1B2), + XHCI, 8, + XHPM, 8, + Offset (0x1C8), + AOAC, 8, + Offset (0x1CD), + ECTM, 32 + } + + OperationRegion (DEB0, SystemIO, 0x80, One) + Field (DEB0, ByteAcc, NoLock, Preserve) + { + DBG8, 8 + } + + OperationRegion (DEB1, SystemIO, 0x90, 0x02) + Field (DEB1, WordAcc, NoLock, Preserve) + { + DBG9, 16 + } + + OperationRegion (PRT0, SystemIO, 0x80, 0x04) + Field (PRT0, DWordAcc, Lock, Preserve) + { + P80H, 32 + } + + Method (DTGP, 2, NotSerialized) + { + If (LEqual (Arg0, Zero)) + { + Store (Buffer (One) + { + 0x03 + }, Arg1) + } + } + + Method (P8XH, 2, Serialized) + { + If (LEqual (Arg0, Zero)) + { + Store (Or (And (P80D, 0xFFFFFF00), Arg1), P80D) + } + + If (LEqual (Arg0, One)) + { + Store (Or (And (P80D, 0xFFFF00FF), ShiftLeft (Arg1, 0x08) + ), P80D) + } + + If (LEqual (Arg0, 0x02)) + { + Store (Or (And (P80D, 0xFF00FFFF), ShiftLeft (Arg1, 0x10) + ), P80D) + } + + If (LEqual (Arg0, 0x03)) + { + Store (Or (And (P80D, 0x00FFFFFF), ShiftLeft (Arg1, 0x18) + ), P80D) + } + + Store (P80D, P80H) + } + + OperationRegion (SPRT, SystemIO, 0xB2, 0x02) + Field (SPRT, ByteAcc, Lock, Preserve) + { + SSMP, 8 + } + + Method (_PIC, 1, NotSerialized) // _PIC: Interrupt Model + { + } + + OperationRegion (IO_T, SystemIO, 0x1000, 0x10) + Field (IO_T, ByteAcc, NoLock, Preserve) + { + Offset (0x08), + TRP0, 8 + } + + OperationRegion (IO_D, SystemIO, 0x0810, 0x04) + Field (IO_D, ByteAcc, NoLock, Preserve) + { + TRPD, 8 + } + + OperationRegion (IO_H, SystemIO, 0x1000, 0x04) + Field (IO_H, ByteAcc, NoLock, Preserve) + { + TRPH, 8 + } + + OperationRegion (PMIO, SystemIO, 0x0400, 0x80) + Field (PMIO, ByteAcc, NoLock, Preserve) + { + Offset (0x42), + , 1, + GPEC, 1 + } + + OperationRegion (GPIO, SystemIO, 0x0500, 0x64) + Field (GPIO, ByteAcc, NoLock, Preserve) + { + Offset (0x0F), + , 1, + , 2, + GP27, 1 + } + + OperationRegion (RCRB, SystemMemory, 0xFED1C000, 0x4000) + Field (RCRB, DWordAcc, Lock, Preserve) + { + Offset (0x341A), + RP1D, 1, + RP2D, 1, + RP3D, 1, + RP4D, 1, + RP5D, 1, + RP6D, 1, + RP7D, 1, + RP8D, 1 + } + + Scope (_SB) + { + Name (PW94, Package (0x02) + { + 0x09, + 0x04 + }) + Name (PWD4, Package (0x02) + { + 0x0D, + 0x04 + }) + Device (PCI0) + { + Name (_HID, EisaId ("PNP0A08")) // _HID: Hardware ID + Name (_CID, EisaId ("PNP0A03")) // _CID: Compatible ID + Name (_ADR, Zero) // _ADR: Address + Name (_BBN, Zero) // _BBN: BIOS Bus Number + Name (_UID, Zero) // _UID: Unique ID + Name (_PRT, Package (0x24) // _PRT: PCI Routing Table + { + Package (0x04) + { + 0x001FFFFF, + Zero, + Zero, + 0x15 + }, + + Package (0x04) + { + 0x001FFFFF, + One, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x001FFFFF, + 0x02, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x001FFFFF, + 0x03, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x0014FFFF, + Zero, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x001DFFFF, + Zero, + Zero, + 0x17 + }, + + Package (0x04) + { + 0x001DFFFF, + One, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x001DFFFF, + 0x02, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x001DFFFF, + 0x03, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x001AFFFF, + Zero, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x001AFFFF, + One, + Zero, + 0x15 + }, + + Package (0x04) + { + 0x001AFFFF, + 0x02, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x001AFFFF, + 0x03, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x001BFFFF, + Zero, + Zero, + 0x16 + }, + + Package (0x04) + { + 0x0019FFFF, + Zero, + Zero, + 0x14 + }, + + Package (0x04) + { + 0x0016FFFF, + Zero, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x0016FFFF, + One, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x0016FFFF, + 0x02, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x0016FFFF, + 0x03, + Zero, + 0x11 + }, + + Package (0x04) + { + 0x001CFFFF, + Zero, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x001CFFFF, + One, + Zero, + 0x11 + }, + + Package (0x04) + { + 0x001CFFFF, + 0x02, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x001CFFFF, + 0x03, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x0001FFFF, + Zero, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x0001FFFF, + One, + Zero, + 0x11 + }, + + Package (0x04) + { + 0x0001FFFF, + 0x02, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x0001FFFF, + 0x03, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x0006FFFF, + Zero, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x0006FFFF, + One, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x0006FFFF, + 0x02, + Zero, + 0x11 + }, + + Package (0x04) + { + 0x0006FFFF, + 0x03, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x0004FFFF, + Zero, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x0004FFFF, + One, + Zero, + 0x11 + }, + + Package (0x04) + { + 0x0004FFFF, + 0x02, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x0004FFFF, + 0x03, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x0002FFFF, + Zero, + Zero, + 0x10 + } + }) + OperationRegion (HBUS, PCI_Config, Zero, 0x0100) + Field (HBUS, DWordAcc, NoLock, Preserve) + { + Offset (0x40), + , 1, + , 11, + EPBR, 20, + Offset (0x48), + , 1, + , 14, + MHBR, 17, + Offset (0x60), + , 1, + PXSZ, 2, + , 23, + PXBR, 6, + Offset (0x68), + , 1, + , 11, + DIBR, 20, + Offset (0x70), + , 20, + MEBR, 12, + Offset (0x80), + , 4, + PM0H, 2, + Offset (0x81), + PM1L, 2, + , 2, + PM1H, 2, + Offset (0x82), + PM2L, 2, + , 2, + PM2H, 2, + Offset (0x83), + PM3L, 2, + , 2, + PM3H, 2, + Offset (0x84), + PM4L, 2, + , 2, + PM4H, 2, + Offset (0x85), + PM5L, 2, + , 2, + PM5H, 2, + Offset (0x86), + PM6L, 2, + , 2, + PM6H, 2, + Offset (0xA8), + , 20, + TUUD, 19, + Offset (0xBC), + , 20, + TLUD, 12 + } + + Name (BUF0, ResourceTemplate () + { + WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, + 0x0000, // Granularity + 0x0000, // Range Minimum + 0x00FF, // Range Maximum + 0x0000, // Translation Offset + 0x0100, // Length + ,, _Y00) + DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, + 0x00000000, // Granularity + 0x00000000, // Range Minimum + 0x00000CF7, // Range Maximum + 0x00000000, // Translation Offset + 0x00000CF8, // Length + ,, , TypeStatic) + IO (Decode16, + 0x0CF8, // Range Minimum + 0x0CF8, // Range Maximum + 0x01, // Alignment + 0x08, // Length + ) + DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, + 0x00000000, // Granularity + 0x00000D00, // Range Minimum + 0x0000FFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x0000F300, // Length + ,, , TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000A0000, // Range Minimum + 0x000BFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00020000, // Length + ,, , AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000C0000, // Range Minimum + 0x000C3FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y01, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000C4000, // Range Minimum + 0x000C7FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y02, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000C8000, // Range Minimum + 0x000CBFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y03, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000CC000, // Range Minimum + 0x000CFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y04, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000D0000, // Range Minimum + 0x000D3FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y05, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000D4000, // Range Minimum + 0x000D7FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y06, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000D8000, // Range Minimum + 0x000DBFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y07, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000DC000, // Range Minimum + 0x000DFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y08, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000E0000, // Range Minimum + 0x000E3FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y09, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000E4000, // Range Minimum + 0x000E7FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y0A, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000E8000, // Range Minimum + 0x000EBFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y0B, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000EC000, // Range Minimum + 0x000EFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y0C, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000F0000, // Range Minimum + 0x000FFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00010000, // Length + ,, _Y0D, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0xFEAFFFFE, // Range Minimum + 0xFEAFFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00000002, // Length + ,, _Y0E, AddressRangeMemory, TypeStatic) + QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x0000000000000000, // Granularity + 0x0000000000010000, // Range Minimum + 0x000000000001FFFF, // Range Maximum + 0x0000000000000000, // Translation Offset + 0x0000000000010000, // Length + ,, _Y0F, AddressRangeMemory, TypeStatic) + }) + Method (_CRS, 0, Serialized) // _CRS: Current Resource Settings + { + CreateWordField (BUF0, \_SB.PCI0._Y00._MAX, PBMX) // _MAX: Maximum Base Address + Store (0x3E, PBMX) + CreateWordField (BUF0, \_SB.PCI0._Y00._LEN, PBLN) // _LEN: Length + Store (0x3F, PBLN) + If (PM1L) + { + CreateDWordField (BUF0, \_SB.PCI0._Y01._LEN, C0LN) // _LEN: Length + Store (Zero, C0LN) + } + + If (LEqual (PM1L, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y01._RW, C0RW) // _RW_: Read-Write Status + Store (Zero, C0RW) + } + + If (PM1H) + { + CreateDWordField (BUF0, \_SB.PCI0._Y02._LEN, C4LN) // _LEN: Length + Store (Zero, C4LN) + } + + If (LEqual (PM1H, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y02._RW, C4RW) // _RW_: Read-Write Status + Store (Zero, C4RW) + } + + If (PM2L) + { + CreateDWordField (BUF0, \_SB.PCI0._Y03._LEN, C8LN) // _LEN: Length + Store (Zero, C8LN) + } + + If (LEqual (PM2L, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y03._RW, C8RW) // _RW_: Read-Write Status + Store (Zero, C8RW) + } + + If (PM2H) + { + CreateDWordField (BUF0, \_SB.PCI0._Y04._LEN, CCLN) // _LEN: Length + Store (Zero, CCLN) + } + + If (LEqual (PM2H, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y04._RW, CCRW) // _RW_: Read-Write Status + Store (Zero, CCRW) + } + + If (PM3L) + { + CreateDWordField (BUF0, \_SB.PCI0._Y05._LEN, D0LN) // _LEN: Length + Store (Zero, D0LN) + } + + If (LEqual (PM3L, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y05._RW, D0RW) // _RW_: Read-Write Status + Store (Zero, D0RW) + } + + If (PM3H) + { + CreateDWordField (BUF0, \_SB.PCI0._Y06._LEN, D4LN) // _LEN: Length + Store (Zero, D4LN) + } + + If (LEqual (PM3H, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y06._RW, D4RW) // _RW_: Read-Write Status + Store (Zero, D4RW) + } + + If (PM4L) + { + CreateDWordField (BUF0, \_SB.PCI0._Y07._LEN, D8LN) // _LEN: Length + Store (Zero, D8LN) + } + + If (LEqual (PM4L, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y07._RW, D8RW) // _RW_: Read-Write Status + Store (Zero, D8RW) + } + + If (PM4H) + { + CreateDWordField (BUF0, \_SB.PCI0._Y08._LEN, DCLN) // _LEN: Length + Store (Zero, DCLN) + } + + If (LEqual (PM4H, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y08._RW, DCRW) // _RW_: Read-Write Status + Store (Zero, DCRW) + } + + If (PM5L) + { + CreateDWordField (BUF0, \_SB.PCI0._Y09._LEN, E0LN) // _LEN: Length + Store (Zero, E0LN) + } + + If (LEqual (PM5L, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y09._RW, E0RW) // _RW_: Read-Write Status + Store (Zero, E0RW) + } + + If (PM5H) + { + CreateDWordField (BUF0, \_SB.PCI0._Y0A._LEN, E4LN) // _LEN: Length + Store (Zero, E4LN) + } + + If (LEqual (PM5H, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y0A._RW, E4RW) // _RW_: Read-Write Status + Store (Zero, E4RW) + } + + If (PM6L) + { + CreateDWordField (BUF0, \_SB.PCI0._Y0B._LEN, E8LN) // _LEN: Length + Store (Zero, E8LN) + } + + If (LEqual (PM6L, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y0B._RW, E8RW) // _RW_: Read-Write Status + Store (Zero, E8RW) + } + + If (PM6H) + { + CreateDWordField (BUF0, \_SB.PCI0._Y0C._LEN, ECLN) // _LEN: Length + Store (Zero, ECLN) + } + + If (LEqual (PM6H, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y0C._RW, ECRW) // _RW_: Read-Write Status + Store (Zero, ECRW) + } + + If (PM0H) + { + CreateDWordField (BUF0, \_SB.PCI0._Y0D._LEN, F0LN) // _LEN: Length + Store (Zero, F0LN) + } + + If (LEqual (PM0H, One)) + { + CreateBitField (BUF0, \_SB.PCI0._Y0D._RW, F0RW) // _RW_: Read-Write Status + Store (Zero, F0RW) + } + + CreateDWordField (BUF0, \_SB.PCI0._Y0E._MIN, M1MN) // _MIN: Minimum Base Address + CreateDWordField (BUF0, \_SB.PCI0._Y0E._MAX, M1MX) // _MAX: Maximum Base Address + CreateDWordField (BUF0, \_SB.PCI0._Y0E._LEN, M1LN) // _LEN: Length + ShiftLeft (TLUD, 0x14, M1MN) + Add (Subtract (M1MX, M1MN), One, M1LN) + CreateQWordField (BUF0, \_SB.PCI0._Y0F._LEN, MSLN) // _LEN: Length + Store (Zero, MSLN) + Return (BUF0) + } + + Name (GUID, Buffer (0x10) + { + /* 0000 */ 0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, + /* 0008 */ 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66 + }) + Name (PA0H, Zero) + Name (PA1H, Zero) + Name (PA2H, Zero) + Name (PA3H, Zero) + Name (PA4H, Zero) + Name (PA5H, Zero) + Name (PA6H, Zero) + Method (NPTS, 1, NotSerialized) + { + Store (PM0H, PA0H) + Store (PM1H, PA1H) + Store (PM2H, PA2H) + Store (PM3H, PA3H) + Store (PM4H, PA4H) + Store (PM5H, PA5H) + Store (PM6H, PA6H) + } + + Method (NWAK, 1, NotSerialized) + { + Store (PA0H, PM0H) + Store (PA1H, PM1H) + Store (PA2H, PM2H) + Store (PA3H, PM3H) + Store (PA4H, PM4H) + Store (PA5H, PM5H) + Store (PA6H, PM6H) + } + + Device (MCHC) + { + Name (_ADR, Zero) // _ADR: Address + } + + Device (PDRC) + { + Name (_HID, EisaId ("PNP0C02")) // _HID: Hardware ID + Name (_UID, One) // _UID: Unique ID + Name (BUF0, ResourceTemplate () + { + Memory32Fixed (ReadWrite, + 0x00000000, // Address Base + 0x00004000, // Address Length + _Y10) + Memory32Fixed (ReadWrite, + 0x00000000, // Address Base + 0x00008000, // Address Length + _Y12) + Memory32Fixed (ReadWrite, + 0x00000000, // Address Base + 0x00001000, // Address Length + _Y13) + Memory32Fixed (ReadWrite, + 0x00000000, // Address Base + 0x00001000, // Address Length + _Y14) + Memory32Fixed (ReadWrite, + 0x00000000, // Address Base + 0x00000000, // Address Length + _Y15) + Memory32Fixed (ReadWrite, + 0xFED20000, // Address Base + 0x00020000, // Address Length + ) + Memory32Fixed (ReadOnly, + 0xFED90000, // Address Base + 0x00004000, // Address Length + ) + Memory32Fixed (ReadWrite, + 0xFED45000, // Address Base + 0x0004B000, // Address Length + ) + Memory32Fixed (ReadOnly, + 0xFF000000, // Address Base + 0x01000000, // Address Length + ) + Memory32Fixed (ReadOnly, + 0xFEE00000, // Address Base + 0x00100000, // Address Length + ) + Memory32Fixed (ReadWrite, + 0x00000000, // Address Base + 0x00001000, // Address Length + _Y11) + }) + Method (_CRS, 0, Serialized) // _CRS: Current Resource Settings + { + CreateDWordField (BUF0, \_SB.PCI0.PDRC._Y10._BAS, RBR0) // _BAS: Base Address + ShiftLeft (^^LPCB.RCBA, 0x0E, RBR0) + CreateDWordField (BUF0, \_SB.PCI0.PDRC._Y11._BAS, TBR0) // _BAS: Base Address + Store (TBAB, TBR0) + CreateDWordField (BUF0, \_SB.PCI0.PDRC._Y11._LEN, TBLN) // _LEN: Length + If (LEqual (TBAB, Zero)) + { + Store (Zero, TBLN) + } + + CreateDWordField (BUF0, \_SB.PCI0.PDRC._Y12._BAS, MBR0) // _BAS: Base Address + ShiftLeft (MHBR, 0x0F, MBR0) + CreateDWordField (BUF0, \_SB.PCI0.PDRC._Y13._BAS, DBR0) // _BAS: Base Address + ShiftLeft (DIBR, 0x0C, DBR0) + CreateDWordField (BUF0, \_SB.PCI0.PDRC._Y14._BAS, EBR0) // _BAS: Base Address + ShiftLeft (EPBR, 0x0C, EBR0) + CreateDWordField (BUF0, \_SB.PCI0.PDRC._Y15._BAS, XBR0) // _BAS: Base Address + ShiftLeft (PXBR, 0x1A, XBR0) + CreateDWordField (BUF0, \_SB.PCI0.PDRC._Y15._LEN, XSZ0) // _LEN: Length + ShiftRight (0x10000000, PXSZ, XSZ0) + Return (BUF0) + } + } + + Device (GIGE) + { + Name (_ADR, 0x00190000) // _ADR: Address + Alias (PWD4, _PRW) + } + + Device (EHC1) + { + Name (_ADR, 0x001D0000) // _ADR: Address + Name (_S3D, 0x03) // _S3D: S3 Device State + Name (_S4D, 0x03) // _S4D: S4 Device State + Name (AAPL, Package (0x0B) + { + "AAPL,current-available", + 0x0834, + "AAPL,current-extra", + 0x0898, + "AAPL,current-extra-in-sleep", + 0x0640, + "AAPL,max-port-current-in-sleep", + 0x0834, + "AAPL,device-internal", + 0x02, + Buffer (One) + { + 0x00 + } + }) + OperationRegion (PWKE, PCI_Config, 0x62, 0x04) + Field (PWKE, DWordAcc, NoLock, Preserve) + { + , 1, + PWUC, 8 + } + + Method (_PSW, 1, NotSerialized) // _PSW: Power State Wake + { + If (Arg0) + { + Store (Ones, PWUC) + } + Else + { + Store (Zero, PWUC) + } + } + + Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method + { + If (LEqual (Arg2, Zero)) + { + Return (Buffer (One) + { + 0x03 + }) + } + + Return (RefOf (AAPL)) + } + + Device (RHUB) + { + Name (_ADR, Zero) // _ADR: Address + Device (PRT1) + { + Name (_ADR, One) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + Zero, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x30, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 00 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 06 */ + /* VerticalPosition : 00 */ + /* HorizontalPosition : 00 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + Device (PRT1) + { + Name (_ADR, One) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xE1, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 04 */ + /* VerticalPosition : 03 */ + /* HorizontalPosition : 00 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT2) + { + Name (_ADR, 0x02) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xE1, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 04 */ + /* VerticalPosition : 03 */ + /* HorizontalPosition : 01 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT3) + { + Name (_ADR, 0x03) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xE1, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 04 */ + /* VerticalPosition : 03 */ + /* HorizontalPosition : 01 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT4) + { + Name (_ADR, 0x04) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xE1, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 04 */ + /* VerticalPosition : 03 */ + /* HorizontalPosition : 02 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT5) + { + Name (_ADR, 0x05) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xB1, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 06 */ + /* VerticalPosition : 02 */ + /* HorizontalPosition : 02 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT6) + { + Name (_ADR, 0x06) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xB1, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 06 */ + /* VerticalPosition : 02 */ + /* HorizontalPosition : 02 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT7) + { + Name (_ADR, 0x07) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xB1, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 06 */ + /* VerticalPosition : 02 */ + /* HorizontalPosition : 02 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT8) + { + Name (_ADR, 0x08) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xB1, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 06 */ + /* VerticalPosition : 02 */ + /* HorizontalPosition : 02 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + } + } + + Alias (PWD4, _PRW) + } + + Device (EHC2) + { + Name (_ADR, 0x001A0000) // _ADR: Address + Name (_S3D, 0x03) // _S3D: S3 Device State + Name (_S4D, 0x03) // _S4D: S4 Device State + OperationRegion (PWKE, PCI_Config, 0x62, 0x04) + Field (PWKE, DWordAcc, NoLock, Preserve) + { + , 1, + PWUC, 6 + } + + Method (_PSW, 1, NotSerialized) // _PSW: Power State Wake + { + If (Arg0) + { + Store (Ones, PWUC) + } + Else + { + Store (Zero, PWUC) + } + } + + Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method + { + If (LEqual (Arg2, Zero)) + { + Return (Buffer (One) + { + 0x03 + }) + } + + Return (RefOf (^^EHC1.AAPL)) + } + + Device (RHUB) + { + Name (_ADR, Zero) // _ADR: Address + Device (PRT1) + { + Name (_ADR, One) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + Zero, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x30, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 00 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 06 */ + /* VerticalPosition : 00 */ + /* HorizontalPosition : 00 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + Device (PRT1) + { + Name (_ADR, One) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xE1, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 04 */ + /* VerticalPosition : 03 */ + /* HorizontalPosition : 00 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT2) + { + Name (_ADR, 0x02) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xE1, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 04 */ + /* VerticalPosition : 03 */ + /* HorizontalPosition : 01 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT3) + { + Name (_ADR, 0x03) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xE1, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 04 */ + /* VerticalPosition : 03 */ + /* HorizontalPosition : 01 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT4) + { + Name (_ADR, 0x04) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xE1, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 04 */ + /* VerticalPosition : 03 */ + /* HorizontalPosition : 02 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT5) + { + Name (_ADR, 0x05) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xB1, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 06 */ + /* VerticalPosition : 02 */ + /* HorizontalPosition : 02 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (PRT6) + { + Name (_ADR, 0x06) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0xFF, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0xB1, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 01 */ + /* Color : 000000 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 06 */ + /* VerticalPosition : 02 */ + /* HorizontalPosition : 02 */ + /* Shape : 07 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 00 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + } + } + + Alias (PWD4, _PRW) + } + + Device (XHC1) + { + Name (_ADR, 0x00140000) // _ADR: Address + OperationRegion (XPRT, PCI_Config, 0x74, 0x6C) + Field (XPRT, DWordAcc, NoLock, Preserve) + { + Offset (0x01), + PMEE, 1, + , 6, + PMES, 1, + Offset (0x5C), + PR2, 32, + PR2M, 32, + PR3, 32, + PR3M, 32 + } + + Name (_S3D, 0x03) // _S3D: S3 Device State + Name (_S4D, 0x03) // _S4D: S4 Device State + Name (XRST, Zero) + Method (CUID, 1, Serialized) + { + If (LEqual (Arg0, Buffer (0x10) + { + /* 0000 */ 0xA9, 0x12, 0x95, 0x7C, 0x05, 0x17, 0xB4, 0x4C, + /* 0008 */ 0xAF, 0x7D, 0x50, 0x6A, 0x24, 0x23, 0xAB, 0x71 + })) + { + Return (One) + } + + Return (Zero) + } + + Method (POSC, 3, Serialized) + { + CreateDWordField (Arg2, Zero, CDW1) + CreateDWordField (Arg2, 0x08, CDW3) + If (LNotEqual (Arg1, One)) + { + Or (CDW1, 0x08, CDW1) + } + + If (LEqual (XHCI, Zero)) + { + Or (CDW1, 0x02, CDW1) + } + + If (LNot (And (CDW1, One))) + { + If (And (CDW3, One)) + { + ESEL () + } + Else + { + XSEL () + } + } + + Return (Arg2) + } + + Method (XSEL, 0, Serialized) + { + If (LOr (LEqual (XHCI, 0x02), LEqual (XHCI, 0x03))) + { + Store (One, ^^LPCB.XUSB) + Store (One, XRST) + Store (Zero, Local0) + And (PR3, 0xFFFFFFF0, Local0) + Or (Local0, XHPM, Local0) + And (Local0, PR3M, PR3) + Store (Zero, Local0) + And (PR2, 0xFFFFFFF0, Local0) + Or (Local0, XHPM, Local0) + And (Local0, PR2M, PR2) + } + } + + Method (ESEL, 0, Serialized) + { + If (LOr (LEqual (XHCI, 0x02), LEqual (XHCI, 0x03))) + { + And (PR3, 0xFFFFFFF0, PR3) + And (PR2, 0xFFFFFFF0, PR2) + Store (Zero, ^^LPCB.XUSB) + Store (Zero, XRST) + } + } + + Method (XWAK, 0, Serialized) + { + If (LOr (LEqual (^^LPCB.XUSB, One), LEqual (XRST, One))) + { + XSEL () + } + } + + Device (RHUB) + { + Name (_ADR, Zero) // _ADR: Address + Device (HSP1) + { + Name (_ADR, One) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0x03, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x01, 0xC6, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x69, 0x0C, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 00 */ + /* Color : 0072C6 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 05 */ + /* VerticalPosition : 01 */ + /* HorizontalPosition : 00 */ + /* Shape : 03 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 01 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (HSP2) + { + Name (_ADR, 0x02) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0x03, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x01, 0xC6, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x69, 0x0C, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 00 */ + /* Color : 0072C6 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 05 */ + /* VerticalPosition : 01 */ + /* HorizontalPosition : 00 */ + /* Shape : 03 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 02 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (HSP3) + { + Name (_ADR, 0x03) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0x03, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x01, 0xC6, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x69, 0x0C, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 00 */ + /* Color : 0072C6 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 05 */ + /* VerticalPosition : 01 */ + /* HorizontalPosition : 00 */ + /* Shape : 03 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 03 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (HSP4) + { + Name (_ADR, 0x04) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0x03, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x01, 0xC6, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x69, 0x0C, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 00 */ + /* Color : 0072C6 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 05 */ + /* VerticalPosition : 01 */ + /* HorizontalPosition : 00 */ + /* Shape : 03 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 04 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (SSP1) + { + Name (_ADR, 0x05) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0x03, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x01, 0xC6, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x69, 0x0C, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 00 */ + /* Color : 0072C6 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 05 */ + /* VerticalPosition : 01 */ + /* HorizontalPosition : 00 */ + /* Shape : 03 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 01 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (SSP2) + { + Name (_ADR, 0x06) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0x03, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x01, 0xC6, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x69, 0x0C, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 00 */ + /* Color : 0072C6 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 05 */ + /* VerticalPosition : 01 */ + /* HorizontalPosition : 00 */ + /* Shape : 03 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 02 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (SSP3) + { + Name (_ADR, 0x07) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0x03, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x01, 0xC6, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x69, 0x0C, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 00 */ + /* Color : 0072C6 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 05 */ + /* VerticalPosition : 01 */ + /* HorizontalPosition : 00 */ + /* Shape : 03 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 03 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + + Device (SSP4) + { + Name (_ADR, 0x08) // _ADR: Address + Name (_UPC, Package (0x04) // _UPC: USB Port Capabilities + { + 0xFF, + 0x03, + Zero, + Zero + }) + Name (_PLD, Package (0x01) // _PLD: Physical Location of Device + { + Buffer (0x10) + { + /* 0000 */ 0x01, 0xC6, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0008 */ 0x69, 0x0C, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 + /* Revision : 01 */ + /* IgnoreColor : 00 */ + /* Color : 0072C6 */ + /* Width : 0000 */ + /* Height : 0000 */ + /* UserVisible : 01 */ + /* Dock : 00 */ + /* Lid : 00 */ + /* Panel : 05 */ + /* VerticalPosition : 01 */ + /* HorizontalPosition : 00 */ + /* Shape : 03 */ + /* GroupOrientation : 00 */ + /* GroupToken : 00 */ + /* GroupPosition : 04 */ + /* Bay : 00 */ + /* Ejectable : 00 */ + /* OspmEjectRequired : 00 */ + /* CabinetNumber : 00 */ + /* CardCageNumber : 00 */ + /* Reference : 00 */ + /* Rotation : 00 */ + /* Order : 00 */ + /* VerticalOffset : 0000 */ + /* HorizontalOffset : 0000 */ + } + }) + } + } + + Alias (PWD4, _PRW) + } + + Device (HDEF) + { + Name (_ADR, 0x001B0000) // _ADR: Address + OperationRegion (HDAR, PCI_Config, Zero, 0x60) + Field (HDAR, WordAcc, NoLock, Preserve) + { + VID0, 16, + DID0, 16, + Offset (0x4C), + DCKA, 1, + Offset (0x4D), + DCKM, 1, + , 6, + DCKS, 1, + Offset (0x54), + , 15, + PMES, 1 + } + + Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method + { + If (LEqual (Arg0, Buffer (0x10) + { + /* 0000 */ 0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44, + /* 0008 */ 0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B + })) + { + If (LNotEqual (And (VID0, 0xFFFF), 0xFFFF)) + { + Store (Package (0x02) + { + "hda-gfx", + Buffer (0x0A) + { + "onboard-1" + } + }, Local0) + DTGP (Arg2, RefOf (Local0)) + Return (Local0) + } + } + + Return (Zero) + } + + Alias (PWD4, _PRW) + } + + Device (SATA) + { + Name (_ADR, 0x001F0002) // _ADR: Address + } + + Device (SBUS) + { + Name (_ADR, 0x001F0003) // _ADR: Address + Device (BUS0) + { + Name (_CID, "smbus") // _CID: Compatible ID + Name (_ADR, Zero) // _ADR: Address + Device (DVL0) + { + Name (_ADR, 0x57) // _ADR: Address + Name (_CID, "diagsvault") // _CID: Compatible ID + } + } + } + + Device (IGPU) + { + Name (_ADR, 0x00020000) // _ADR: Address + Device (^^MEM2) + { + Name (_HID, EisaId ("PNP0C01")) // _HID: Hardware ID + Name (_UID, 0x02) // _UID: Unique ID + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + Memory32Fixed (ReadWrite, + 0x20000000, // Address Base + 0x00200000, // Address Length + ) + Memory32Fixed (ReadWrite, + 0x40000000, // Address Base + 0x00200000, // Address Length + ) + }) + Method (_STA, 0, NotSerialized) // _STA: Status + { + If (IGDS) + { + Return (0x0F) + } + + Return (Zero) + } + } + + OperationRegion (GFXH, PCI_Config, Zero, 0x40) + Field (GFXH, ByteAcc, NoLock, Preserve) + { + VID0, 16, + DID0, 16 + } + + Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method + { + If (LEqual (Arg0, Buffer (0x10) + { + /* 0000 */ 0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44, + /* 0008 */ 0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B + })) + { + If (LNotEqual (And (VID0, 0xFFFF), 0xFFFF)) + { + Store (Package (0x02) + { + "hda-gfx", + Buffer (0x0A) + { + "onboard-1" + } + }, Local0) + DTGP (Arg2, RefOf (Local0)) + Return (Local0) + } + } + + Return (Zero) + } + } + + Device (LPCB) + { + Name (_ADR, 0x001F0000) // _ADR: Address + OperationRegion (LPC0, PCI_Config, 0x40, 0xC0) + Field (LPC0, AnyAcc, NoLock, Preserve) + { + Offset (0x40), + IOD0, 8, + IOD1, 8, + Offset (0xB0), + RAEN, 1, + , 13, + RCBA, 18 + } + + OperationRegion (LPC1, PCI_Config, 0x40, 0xC0) + Field (LPC1, AnyAcc, NoLock, Preserve) + { + Offset (0x6E), + XUSB, 1 + } + + OperationRegion (CPSB, SystemMemory, 0xDDA55E18, 0x10) + Field (CPSB, AnyAcc, NoLock, Preserve) + { + RTCX, 1 + } + + Method (SPTS, 1, NotSerialized) + { + Store (One, SLPX) + Store (One, SLPE) + } + + Method (SWAK, 1, NotSerialized) + { + Store (Zero, SLPE) + If (RTCX) {} + Else + { + Notify (PWRB, 0x02) + } + } + + OperationRegion (SMIE, SystemIO, 0x0400, 0x04) + Field (SMIE, ByteAcc, NoLock, Preserve) + { + , 10, + RTCS, 1, + , 3, + PEXS, 1, + WAKS, 1, + Offset (0x03), + PWBT, 1, + Offset (0x04) + } + + OperationRegion (SLPR, SystemIO, 0x0430, 0x08) + Field (SLPR, ByteAcc, NoLock, Preserve) + { + , 4, + SLPE, 1, + , 31, + SLPX, 1, + Offset (0x08) + } + + Method (S1RS, 1, NotSerialized) + { + Store (Zero, PLED) + If (LEqual (Arg0, One)) + { + ECWB (0xFF, 0x02) + ECWB (0x62, 0x06) + ECWB (0xFF, Zero) + } + } + + OperationRegion (GPBX, SystemIO, 0x0500, 0x80) + Field (GPBX, ByteAcc, NoLock, Preserve) + { + Offset (0x18), + , 27, + PLED, 1 + } + + Mutex (MUEC, 0x00) + OperationRegion (DLYP, SystemIO, 0xE1, One) + Field (DLYP, ByteAcc, NoLock, Preserve) + { + DELY, 8 + } + + OperationRegion (KBCP, SystemIO, Zero, 0xFF) + Field (KBCP, ByteAcc, Lock, Preserve) + { + Offset (0x62), + EC62, 8, + Offset (0x66), + EC66, 8 + } + + Field (KBCP, ByteAcc, Lock, Preserve) + { + Offset (0x66), + ECOF, 1, + ECIE, 1, + Offset (0x67) + } + + OperationRegion (ECOR, EmbeddedControl, Zero, 0x0100) + Field (ECOR, ByteAcc, Lock, Preserve) + { + Offset (0x4A), + TWKT, 8, + Offset (0xFF), + BNKD, 8 + } + + Method (IBFX, 0, Serialized) + { + Store (0x1000, Local0) + While (LAnd (Decrement (Local0), ECIE)) + { + Store (Zero, DELY) + } + } + + Method (ECWB, 2, Serialized) + { + If (LNot (Acquire (MUEC, 0xFFFF))) + { + IBFX () + Store (0x81, EC66) + IBFX () + Store (Arg0, EC62) + IBFX () + Store (Arg1, EC62) + IBFX () + Release (MUEC) + } + } + + Device (DMAC) + { + Name (_HID, EisaId ("PNP0200")) // _HID: Hardware ID + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + IO (Decode16, + 0x0000, // Range Minimum + 0x0000, // Range Maximum + 0x01, // Alignment + 0x20, // Length + ) + IO (Decode16, + 0x0081, // Range Minimum + 0x0081, // Range Maximum + 0x01, // Alignment + 0x11, // Length + ) + IO (Decode16, + 0x0093, // Range Minimum + 0x0093, // Range Maximum + 0x01, // Alignment + 0x0D, // Length + ) + IO (Decode16, + 0x00C0, // Range Minimum + 0x00C0, // Range Maximum + 0x01, // Alignment + 0x20, // Length + ) + DMA (Compatibility, NotBusMaster, Transfer8_16, ) + {4} + }) + } + + Device (FWHD) + { + Name (_HID, EisaId ("INT0800")) // _HID: Hardware ID + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + Memory32Fixed (ReadOnly, + 0xFF000000, // Address Base + 0x01000000, // Address Length + ) + }) + } + + Device (HPET) + { + Name (_HID, EisaId ("PNP0103")) // _HID: Hardware ID + Name (_CID, EisaId ("PNP0C01")) // _CID: Compatible ID + Name (_STA, 0x0F) // _STA: Status + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + IRQNoFlags () + {0} + IRQNoFlags () + {8} + Memory32Fixed (ReadWrite, + 0xFED00000, // Address Base + 0x00000400, // Address Length + ) + }) + } + + Device (IPIC) + { + Name (_HID, EisaId ("PNP0000")) // _HID: Hardware ID + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + IO (Decode16, + 0x0020, // Range Minimum + 0x0020, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x0024, // Range Minimum + 0x0024, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x0028, // Range Minimum + 0x0028, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x002C, // Range Minimum + 0x002C, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x0030, // Range Minimum + 0x0030, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x0034, // Range Minimum + 0x0034, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x0038, // Range Minimum + 0x0038, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x003C, // Range Minimum + 0x003C, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x00A0, // Range Minimum + 0x00A0, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x00A4, // Range Minimum + 0x00A4, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x00A8, // Range Minimum + 0x00A8, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x00AC, // Range Minimum + 0x00AC, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x00B0, // Range Minimum + 0x00B0, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x00B4, // Range Minimum + 0x00B4, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x00B8, // Range Minimum + 0x00B8, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x00BC, // Range Minimum + 0x00BC, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x04D0, // Range Minimum + 0x04D0, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IRQNoFlags () + {2} + }) + } + + Device (LDRC) + { + Name (_HID, EisaId ("PNP0C02")) // _HID: Hardware ID + Name (_UID, 0x02) // _UID: Unique ID + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + IO (Decode16, + 0x002E, // Range Minimum + 0x002E, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x004E, // Range Minimum + 0x004E, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x0061, // Range Minimum + 0x0061, // Range Maximum + 0x01, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0x0063, // Range Minimum + 0x0063, // Range Maximum + 0x01, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0x0065, // Range Minimum + 0x0065, // Range Maximum + 0x01, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0x0067, // Range Minimum + 0x0067, // Range Maximum + 0x01, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0x0070, // Range Minimum + 0x0070, // Range Maximum + 0x01, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0x0080, // Range Minimum + 0x0080, // Range Maximum + 0x01, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0x0092, // Range Minimum + 0x0092, // Range Maximum + 0x01, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0x00B2, // Range Minimum + 0x00B2, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + IO (Decode16, + 0x0680, // Range Minimum + 0x0680, // Range Maximum + 0x01, // Alignment + 0x20, // Length + ) + IO (Decode16, + 0x1000, // Range Minimum + 0x1000, // Range Maximum + 0x01, // Alignment + 0x10, // Length + ) + IO (Decode16, + 0xFFFF, // Range Minimum + 0xFFFF, // Range Maximum + 0x01, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0xFFFF, // Range Minimum + 0xFFFF, // Range Maximum + 0x01, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0x0400, // Range Minimum + 0x0400, // Range Maximum + 0x01, // Alignment + 0x54, // Length + ) + IO (Decode16, + 0x0458, // Range Minimum + 0x0458, // Range Maximum + 0x01, // Alignment + 0x28, // Length + ) + IO (Decode16, + 0x0500, // Range Minimum + 0x0500, // Range Maximum + 0x01, // Alignment + 0x80, // Length + ) + IO (Decode16, + 0x164E, // Range Minimum + 0x164E, // Range Maximum + 0x01, // Alignment + 0x02, // Length + ) + }) + } + + Device (RTC) + { + Name (_HID, EisaId ("PNP0B00")) // _HID: Hardware ID + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + IO (Decode16, + 0x0070, // Range Minimum + 0x0070, // Range Maximum + 0x01, // Alignment + 0x08, // Length + ) + }) + } + + Device (TIMR) + { + Name (_HID, EisaId ("PNP0100")) // _HID: Hardware ID + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + IO (Decode16, + 0x0040, // Range Minimum + 0x0040, // Range Maximum + 0x01, // Alignment + 0x04, // Length + ) + IO (Decode16, + 0x0050, // Range Minimum + 0x0050, // Range Maximum + 0x10, // Alignment + 0x04, // Length + ) + }) + } + + Device (EC) + { + Name (_HID, EisaId ("PNP0C09")) // _HID: Hardware ID + Name (_UID, Zero) // _UID: Unique ID + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + IO (Decode16, + 0x0062, // Range Minimum + 0x0062, // Range Maximum + 0x00, // Alignment + 0x01, // Length + ) + IO (Decode16, + 0x0066, // Range Minimum + 0x0066, // Range Maximum + 0x00, // Alignment + 0x01, // Length + ) + }) + Name (_GPE, 0x18) // _GPE: General Purpose Events + } + + Device (MATH) + { + Name (_HID, EisaId ("PNP0C04")) // _HID: Hardware ID + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + IO (Decode16, + 0x00F0, // Range Minimum + 0x00F0, // Range Maximum + 0x00, // Alignment + 0x10, // Length + ) + IRQNoFlags () + {13} + }) + } + } + + Device (P0P1) + { + Name (_ADR, 0x001E0000) // _ADR: Address + Name (_PRW, Package (0x02) // _PRW: Power Resources for Wake + { + 0x0B, + 0x04 + }) + Name (_PRT, Package (0x10) // _PRT: PCI Routing Table + { + Package (0x04) + { + 0xFFFF, + Zero, + Zero, + 0x15 + }, + + Package (0x04) + { + 0xFFFF, + One, + Zero, + 0x16 + }, + + Package (0x04) + { + 0xFFFF, + 0x02, + Zero, + 0x17 + }, + + Package (0x04) + { + 0xFFFF, + 0x03, + Zero, + 0x14 + }, + + Package (0x04) + { + 0x0001FFFF, + Zero, + Zero, + 0x16 + }, + + Package (0x04) + { + 0x0001FFFF, + One, + Zero, + 0x15 + }, + + Package (0x04) + { + 0x0001FFFF, + 0x02, + Zero, + 0x14 + }, + + Package (0x04) + { + 0x0001FFFF, + 0x03, + Zero, + 0x17 + }, + + Package (0x04) + { + 0x0002FFFF, + Zero, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x0002FFFF, + One, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x0002FFFF, + 0x02, + Zero, + 0x11 + }, + + Package (0x04) + { + 0x0002FFFF, + 0x03, + Zero, + 0x10 + }, + + Package (0x04) + { + 0x0003FFFF, + Zero, + Zero, + 0x13 + }, + + Package (0x04) + { + 0x0003FFFF, + One, + Zero, + 0x12 + }, + + Package (0x04) + { + 0x0003FFFF, + 0x02, + Zero, + 0x15 + }, + + Package (0x04) + { + 0x0003FFFF, + 0x03, + Zero, + 0x16 + } + }) + } + + Device (RP01) + { + Name (_ADR, 0x001C0000) // _ADR: Address + Device (ARPT) + { + Name (_ADR, Zero) // _ADR: Address + Name (_PRW, Package (0x02) // _PRW: Power Resources for Wake + { + 0x09, + 0x04 + }) + } + + Name (_PRT, Package (0x04) // _PRT: PCI Routing Table + { + Package (0x04) + { + 0xFFFF, + Zero, + Zero, + 0x10 + }, + + Package (0x04) + { + 0xFFFF, + One, + Zero, + 0x11 + }, + + Package (0x04) + { + 0xFFFF, + 0x02, + Zero, + 0x12 + }, + + Package (0x04) + { + 0xFFFF, + 0x03, + Zero, + 0x13 + } + }) + Alias (PW94, _PRW) + } + + Device (RP08) + { + Name (_ADR, 0x001C0007) // _ADR: Address + Name (_PRT, Package (0x04) // _PRT: PCI Routing Table + { + Package (0x04) + { + 0xFFFF, + Zero, + Zero, + 0x13 + }, + + Package (0x04) + { + 0xFFFF, + One, + Zero, + 0x10 + }, + + Package (0x04) + { + 0xFFFF, + 0x02, + Zero, + 0x11 + }, + + Package (0x04) + { + 0xFFFF, + 0x03, + Zero, + 0x12 + } + }) + Alias (PW94, _PRW) + } + + Device (PEG0) + { + Name (_ADR, 0x00010000) // _ADR: Address + Name (_PRT, Package (0x04) // _PRT: PCI Routing Table + { + Package (0x04) + { + 0xFFFF, + Zero, + Zero, + 0x10 + }, + + Package (0x04) + { + 0xFFFF, + One, + Zero, + 0x11 + }, + + Package (0x04) + { + 0xFFFF, + 0x02, + Zero, + 0x12 + }, + + Package (0x04) + { + 0xFFFF, + 0x03, + Zero, + 0x13 + } + }) + Alias (PW94, _PRW) + Device (GFX0) + { + Name (_ADR, Zero) // _ADR: Address + OperationRegion (DGFX, PCI_Config, Zero, 0xF0) + Field (DGFX, DWordAcc, Lock, Preserve) + { + Offset (0x0B), + LNKV, 8 + } + + OperationRegion (PEGH, PCI_Config, Zero, 0x40) + Field (PEGH, ByteAcc, NoLock, Preserve) + { + VID0, 16, + DID0, 16 + } + + Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method + { + If (LEqual (Arg0, Buffer (0x10) + { + /* 0000 */ 0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44, + /* 0008 */ 0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B + })) + { + If (LNotEqual (And (VID0, 0xFFFF), 0xFFFF)) + { + Store (Package (0x02) + { + "hda-gfx", + Buffer (0x0A) + { + "onboard-2" + } + }, Local0) + DTGP (Arg2, RefOf (Local0)) + Return (Local0) + } + } + + Return (0x80000002) + } + + Alias (PW94, _PRW) + } + + Device (HDAU) + { + Name (_ADR, One) // _ADR: Address + OperationRegion (HDAH, PCI_Config, Zero, 0x40) + Field (HDAH, ByteAcc, NoLock, Preserve) + { + VID0, 16, + DID0, 16 + } + + Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method + { + If (LEqual (Arg0, Buffer (0x10) + { + /* 0000 */ 0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44, + /* 0008 */ 0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B + })) + { + If (LNotEqual (And (VID0, 0xFFFF), 0xFFFF)) + { + Store (Package (0x02) + { + "hda-gfx", + Buffer (0x0A) + { + "onboard-2" + } + }, Local0) + DTGP (Arg2, RefOf (Local0)) + Return (Local0) + } + } + + Return (0x80000002) + } + + Alias (PW94, _PRW) + } + } + + Device (PEG1) + { + Name (_ADR, 0x00010001) // _ADR: Address + Name (_PRT, Package (0x04) // _PRT: PCI Routing Table + { + Package (0x04) + { + 0xFFFF, + Zero, + Zero, + 0x11 + }, + + Package (0x04) + { + 0xFFFF, + One, + Zero, + 0x12 + }, + + Package (0x04) + { + 0xFFFF, + 0x02, + Zero, + 0x13 + }, + + Package (0x04) + { + 0xFFFF, + 0x03, + Zero, + 0x10 + } + }) + Alias (PW94, _PRW) + } + } + + Device (PWRB) + { + Name (_HID, EisaId ("PNP0C0C")) // _HID: Hardware ID + Name (_UID, 0xAA) // _UID: Unique ID + Name (_STA, 0x0B) // _STA: Status + Alias (PWD4, _PRW) + } + + Device (SLPB) + { + Name (_HID, EisaId ("PNP0C0E")) // _HID: Hardware ID + Name (_STA, 0x0B) // _STA: Status + } + } + + Scope (_GPE) + { + Method (_L01, 0, NotSerialized) // _Lxx: Level-Triggered GPE + { + Add (L01C, One, L01C) + P8XH (Zero, One) + P8XH (One, L01C) + } + + Method (_L02, 0, NotSerialized) // _Lxx: Level-Triggered GPE + { + Store (Zero, GPEC) + } + + Method (_L09, 0, NotSerialized) // _Lxx: Level-Triggered GPE + { + Notify (\_SB.PCI0.RP01, 0x02) + Notify (\_SB.PCI0.RP08, 0x02) + Notify (\_SB.PCI0.PEG0, 0x02) + Notify (\_SB.PCI0.PEG0.GFX0, 0x02) + Notify (\_SB.PCI0.PEG1, 0x02) + } + + Method (_L0B, 0, NotSerialized) // _Lxx: Level-Triggered GPE + { + Notify (\_SB.PCI0.P0P1, 0x02) + } + + Method (_L0D, 0, NotSerialized) // _Lxx: Level-Triggered GPE + { + Notify (\_SB.PCI0.EHC1, 0x02) + Notify (\_SB.PCI0.EHC2, 0x02) + Notify (\_SB.PCI0.HDEF, 0x02) + Notify (\_SB.PCI0.GIGE, 0x02) + Notify (\_SB.PCI0.XHC1, 0x02) + If (LAnd (\_SB.PCI0.XHC1.PMES, \_SB.PCI0.XHC1.PMES)) + { + Store (One, \_SB.PCI0.XHC1.PMES) + } + } + } + + Method (TRAP, 2, Serialized) + { + Store (Arg1, SMIF) + If (LEqual (Arg0, One)) + { + Store (Zero, TRP0) + } + + If (LEqual (Arg0, 0x02)) + { + Store (Arg1, DTSF) + Store (Zero, TRPD) + Return (DTSF) + } + + If (LEqual (Arg0, 0x03)) + { + Store (Zero, TRPH) + } + + Return (SMIF) + } + + Method (PTS, 1, NotSerialized) + { + If (Arg0) + { + \_SB.PCI0.LPCB.SPTS (Arg0) + \_SB.PCI0.NPTS (Arg0) + } + } + + Method (WAK, 1, NotSerialized) + { + \_SB.PCI0.LPCB.SWAK (Arg0) + \_SB.PCI0.NWAK (Arg0) + \_SB.PCI0.LPCB.S1RS (Arg0) + } + + Method (_PTS, 1, NotSerialized) // _PTS: Prepare To Sleep + { + Store (Zero, P80D) + P8XH (Zero, Arg0) + PTS (Arg0) + If (And (AOAC, One)) {} + If (LEqual (Arg0, 0x03)) + { + If (LAnd (DTSE, LGreater (TCNT, One))) + { + TRAP (0x02, 0x1E) + } + } + + If (LOr (LOr (LEqual (Arg0, 0x03), LEqual (Arg0, 0x04)), LEqual ( + Arg0, 0x05))) + { + If (LEqual (PFLV, 0x02)) + { + Store (One, GP27) + } + } + } + + Method (_WAK, 1, Serialized) // _WAK: Wake + { + ShiftLeft (Arg0, 0x04, DBG8) + WAK (Arg0) + If (LEqual (AOAC, 0x11)) + { + If (CondRefOf (ECTM)) + { + Store (Zero, ECTM) + } + } + + If (LOr (LEqual (Arg0, 0x03), LEqual (Arg0, 0x04))) + { + If (LAnd (DTSE, LGreater (TCNT, One))) + { + TRAP (0x02, 0x14) + } + + If (LEqual (RP1D, Zero)) + { + Notify (\_SB.PCI0.RP01, Zero) + } + + If (LEqual (RP8D, Zero)) + { + If (LEqual (DSTS, Zero)) + { + Notify (\_SB.PCI0.RP08, Zero) + } + } + } + + If (LOr (LEqual (Arg0, 0x03), LEqual (Arg0, 0x04))) + { + \_SB.PCI0.XHC1.XWAK () + } + + Return (Package (0x02) + { + Zero, + Zero + }) + } + + Name (_S0, Package (0x03) // _S0_: S0 System State + { + Zero, + Zero, + Zero + }) + Name (_S3, Package (0x03) // _S3_: S3 System State + { + 0x05, + 0x05, + Zero + }) + Name (_S4, Package (0x03) // _S4_: S4 System State + { + 0x06, + 0x06, + Zero + }) + Name (_S5, Package (0x03) // _S5_: S5 System State + { + 0x07, + 0x07, + Zero + }) +} + diff --git a/i386/libsaio/acpi/examples/P8Z68-V PRO/dsdt.dsl b/i386/libsaio/acpi/examples/P8Z68-V PRO/dsdt.dsl new file mode 100644 index 0000000..19edd67 --- /dev/null +++ b/i386/libsaio/acpi/examples/P8Z68-V PRO/dsdt.dsl @@ -0,0 +1,1196 @@ +/* + * Intel ACPI Component Architecture + * AML Disassembler version 20110316-64 [Mar 16 2011] + * Copyright (c) 2000 - 2011 Intel Corporation + * + * Original Table Header: + * Signature "DSDT" + * Length 0x00001EE2 (7906) + * Revision 0x02 + * Checksum 0x7F + * OEM ID "APPLE" + * OEM Table ID "Macmini" + * OEM Revision 0x00050001 (327681) + * Compiler ID "INTL" + * Compiler Version 0x20110316 (537985814) + */ + +DefinitionBlock ("dsdt.aml", "DSDT", 2, "APPLE", "Macmini", 0x00050001) +{ + Name (HPTB, 0xFED00000) + Name (SRCB, 0xFED1C000) + Name (HPTC, 0xFED1F404) + Name (MCHB, 0xFED10000) + Name (EGPB, 0xFED19000) + Name (PEBS, 0xF8000000) + Name (PELN, 0x04000000) + Name (VTBS, 0xFED90000) + Name (VTLN, 0x4000) + Name (LAPB, 0xFEE00000) + Name (APCB, 0xFEC00000) + Name (TCBR, 0xFED08000) + Name (PMBS, 0x0400) + Name (SMCR, 0x0430) + Name (GPBS, 0x0500) + Name (RCLN, 0x4000) + Name (TCLT, 0x1000) + Name (OPRE, 0xDCBB2E18) + + OperationRegion (GNVS, SystemMemory, OPRE, 0x0163) + Field (GNVS, AnyAcc, Lock, Preserve) + { + Offset (0x3C), + IGDS, 8, + Offset (0xAA), + ASLB, 32, + Offset (0xEF), + L01C, 8, + Offset (0x15F), + TBAB, 32, + } + + OperationRegion (PMIO, SystemIO, PMBS, 0x43) + Field (PMIO, ByteAcc, NoLock, Preserve) + { + Offset (0x42), + , 1, + GPEC, 1 + } + + OperationRegion (GPIO, SystemIO, GPBS, 0x10) + Field (GPIO, ByteAcc, NoLock, Preserve) + { + Offset (0x0F), + GP24, 1, + , 2, + GP27, 1 + } + + Method (_PIC, 1, NotSerialized) + { + } + + Scope (\_PR) + { + Processor (CPU0, 0x01, 0x00000410, 0x06) {} + Processor (CPU1, 0x02, 0x00000410, 0x06) {} + Processor (CPU2, 0x03, 0x00000410, 0x06) {} + Processor (CPU3, 0x04, 0x00000410, 0x06) {} + } + + Scope (_SB) + { + OperationRegion (IOB2, SystemIO, 0xB2, One) + Field (IOB2, ByteAcc, NoLock, Preserve) + { + SMIC, 8 + } + + Device (PCI0) + { + Name (_ADR, Zero) + Name (_UID, Zero) + Name (_BBN, Zero) + Name (_CID, EisaId ("PNP0A03")) + Name (_HID, EisaId ("PNP0A08")) + Name (_PRT, Package (0x24) + { + Package (0x04) { 0x001FFFFF, Zero, Zero, 0x15 }, + Package (0x04) { 0x001FFFFF, One, Zero, 0x13 }, + Package (0x04) { 0x001FFFFF, 0x02, Zero, 0x12 }, + Package (0x04) { 0x001FFFFF, 0x03, Zero, 0x10 }, + Package (0x04) { 0x0014FFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0x001DFFFF, One, Zero, 0x13 }, + Package (0x04) { 0x001DFFFF, 0x02, Zero, 0x10 }, + Package (0x04) { 0x001DFFFF, 0x03, Zero, 0x12 }, + Package (0x04) { 0x001DFFFF, Zero, Zero, 0x17 }, + Package (0x04) { 0x001AFFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0x001AFFFF, One, Zero, 0x15 }, + Package (0x04) { 0x001AFFFF, 0x02, Zero, 0x12 }, + Package (0x04) { 0x001AFFFF, 0x03, Zero, 0x13 }, + Package (0x04) { 0x001BFFFF, Zero, Zero, 0x16 }, + Package (0x04) { 0x0016FFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0x0016FFFF, One, Zero, 0x13 }, + Package (0x04) { 0x0016FFFF, 0x02, Zero, 0x12 }, + Package (0x04) { 0x0016FFFF, 0x03, Zero, 0x11 }, + Package (0x04) { 0x001CFFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0x001CFFFF, One, Zero, 0x11 }, + Package (0x04) { 0x001CFFFF, 0x02, Zero, 0x12 }, + Package (0x04) { 0x001CFFFF, 0x03, Zero, 0x13 }, + Package (0x04) { 0x0001FFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0x0001FFFF, One, Zero, 0x11 }, + Package (0x04) { 0x0001FFFF, 0x02, Zero, 0x12 }, + Package (0x04) { 0x0001FFFF, 0x03, Zero, 0x13 }, + Package (0x04) { 0x0006FFFF, Zero, Zero, 0x13 }, + Package (0x04) { 0x0006FFFF, One, Zero, 0x10 }, + Package (0x04) { 0x0006FFFF, 0x02, Zero, 0x11 }, + Package (0x04) { 0x0006FFFF, 0x03, Zero, 0x12 }, + Package (0x04) { 0x0004FFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0x0004FFFF, One, Zero, 0x11 }, + Package (0x04) { 0x0004FFFF, 0x02, Zero, 0x12 }, + Package (0x04) { 0x0004FFFF, 0x03, Zero, 0x13 }, + Package (0x04) { 0x0002FFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0x0019FFFF, Zero, Zero, 0x14 } + }) + OperationRegion (HBUS, PCI_Config, Zero, 0x0100) + Field (HBUS, DWordAcc, NoLock, Preserve) + { + Offset (0x40), + EPEN, 1, + , 11, + EPBR, 20, + Offset (0x48), + MHEN, 1, + , 14, + MHBR, 17, + Offset (0x50), + GCLK, 1, + Offset (0x54), + D0EN, 1, + Offset (0x60), + PXEN, 1, + PXSZ, 2, + , 23, + PXBR, 6, + Offset (0x68), + DIEN, 1, + , 11, + DIBR, 20, + Offset (0x70), + , 20, + MEBR, 12, + Offset (0x80), + , 4, + PM0H, 2, + Offset (0x81), + PM1L, 2, + , 2, + PM1H, 2, + Offset (0x82), + PM2L, 2, + , 2, + PM2H, 2, + Offset (0x83), + PM3L, 2, + , 2, + PM3H, 2, + Offset (0x84), + PM4L, 2, + , 2, + PM4H, 2, + Offset (0x85), + PM5L, 2, + , 2, + PM5H, 2, + Offset (0x86), + PM6L, 2, + , 2, + PM6H, 2, + Offset (0x87), + Offset (0xA8), + , 20, + TUUD, 19, + Offset (0xBC), + , 20, + TLUD, 12, + Offset (0xC8), + , 7, + HTSE, 1 + } + + OperationRegion (MCHT, SystemMemory, 0xFED10000, 0x1100) + Field (MCHT, ByteAcc, NoLock, Preserve) + { + } + + Name (BUF0, ResourceTemplate () + { + WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, + 0x0000, // Granularity + 0x0000, // Range Minimum + 0x00FF, // Range Maximum + 0x0000, // Translation Offset + 0x0100, // Length + ,, _Y00) + DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, + 0x00000000, // Granularity + 0x00000000, // Range Minimum + 0x00000CF7, // Range Maximum + 0x00000000, // Translation Offset + 0x00000CF8, // Length + ,, , TypeStatic) + IO (Decode16, + 0x0CF8, // Range Minimum + 0x0CF8, // Range Maximum + 0x01, // Alignment + 0x08, // Length + ) + DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, + 0x00000000, // Granularity + 0x00000D00, // Range Minimum + 0x0000FFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x0000F300, // Length + ,, , TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000A0000, // Range Minimum + 0x000BFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00020000, // Length + ,, , AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000C0000, // Range Minimum + 0x000C3FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y01, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000C4000, // Range Minimum + 0x000C7FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y02, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000C8000, // Range Minimum + 0x000CBFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y03, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000CC000, // Range Minimum + 0x000CFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y04, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000D0000, // Range Minimum + 0x000D3FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y05, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000D4000, // Range Minimum + 0x000D7FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y06, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000D8000, // Range Minimum + 0x000DBFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y07, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000DC000, // Range Minimum + 0x000DFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y08, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000E0000, // Range Minimum + 0x000E3FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y09, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000E4000, // Range Minimum + 0x000E7FFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y0A, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000E8000, // Range Minimum + 0x000EBFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y0B, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000EC000, // Range Minimum + 0x000EFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00004000, // Length + ,, _Y0C, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x000F0000, // Range Minimum + 0x000FFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0x00010000, // Length + ,, _Y0D, AddressRangeMemory, TypeStatic) + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x00000000, // Granularity + 0x00000000, // Range Minimum + 0xFEAFFFFF, // Range Maximum + 0x00000000, // Translation Offset + 0xFEB00000, // Length + ,, _Y0E, AddressRangeMemory, TypeStatic) + QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, + 0x0000000000000000, // Granularity + 0x0000000000010000, // Range Minimum + 0x000000000001FFFF, // Range Maximum + 0x0000000000000000, // Translation Offset + 0x0000000000010000, // Length + ,, _Y0F, AddressRangeMemory, TypeStatic) + }) + Method (_CRS, 0, Serialized) + { + CreateWordField (BUF0, ^_Y00._MAX, PBMX) + Store (Subtract (ShiftRight (PELN, 0x14), 0x02), PBMX) + CreateWordField (BUF0, ^_Y00._LEN, PBLN) + Store (Subtract (ShiftRight (PELN, 0x14), One), PBLN) + If (PM1L) + { + CreateDWordField (BUF0, ^_Y01._LEN, C0LN) + Store (Zero, C0LN) + } + + If (LEqual (PM1L, One)) + { + CreateBitField (BUF0, ^_Y01._RW, C0RW) + Store (Zero, C0RW) + } + + If (PM1H) + { + CreateDWordField (BUF0, ^_Y02._LEN, C4LN) + Store (Zero, C4LN) + } + + If (LEqual (PM1H, One)) + { + CreateBitField (BUF0, ^_Y02._RW, C4RW) + Store (Zero, C4RW) + } + + If (PM2L) + { + CreateDWordField (BUF0, ^_Y03._LEN, C8LN) + Store (Zero, C8LN) + } + + If (LEqual (PM2L, One)) + { + CreateBitField (BUF0, ^_Y03._RW, C8RW) + Store (Zero, C8RW) + } + + If (PM2H) + { + CreateDWordField (BUF0, ^_Y04._LEN, CCLN) + Store (Zero, CCLN) + } + + If (LEqual (PM2H, One)) + { + CreateBitField (BUF0, ^_Y04._RW, CCRW) + Store (Zero, CCRW) + } + + If (PM3L) + { + CreateDWordField (BUF0, ^_Y05._LEN, D0LN) + Store (Zero, D0LN) + } + + If (LEqual (PM3L, One)) + { + CreateBitField (BUF0, ^_Y05._RW, D0RW) + Store (Zero, D0RW) + } + + If (PM3H) + { + CreateDWordField (BUF0, ^_Y06._LEN, D4LN) + Store (Zero, D4LN) + } + + If (LEqual (PM3H, One)) + { + CreateBitField (BUF0, ^_Y06._RW, D4RW) + Store (Zero, D4RW) + } + + If (PM4L) + { + CreateDWordField (BUF0, ^_Y07._LEN, D8LN) + Store (Zero, D8LN) + } + + If (LEqual (PM4L, One)) + { + CreateBitField (BUF0, ^_Y07._RW, D8RW) + Store (Zero, D8RW) + } + + If (PM4H) + { + CreateDWordField (BUF0, ^_Y08._LEN, DCLN) + Store (Zero, DCLN) + } + + If (LEqual (PM4H, One)) + { + CreateBitField (BUF0, ^_Y08._RW, DCRW) + Store (Zero, DCRW) + } + + If (PM5L) + { + CreateDWordField (BUF0, ^_Y09._LEN, E0LN) + Store (Zero, E0LN) + } + + If (LEqual (PM5L, One)) + { + CreateBitField (BUF0, ^_Y09._RW, E0RW) + Store (Zero, E0RW) + } + + If (PM5H) + { + CreateDWordField (BUF0, ^_Y0A._LEN, E4LN) + Store (Zero, E4LN) + } + + If (LEqual (PM5H, One)) + { + CreateBitField (BUF0, ^_Y0A._RW, E4RW) + Store (Zero, E4RW) + } + + If (PM6L) + { + CreateDWordField (BUF0, ^_Y0B._LEN, E8LN) + Store (Zero, E8LN) + } + + If (LEqual (PM6L, One)) + { + CreateBitField (BUF0, ^_Y0B._RW, E8RW) + Store (Zero, E8RW) + } + + If (PM6H) + { + CreateDWordField (BUF0, ^_Y0C._LEN, ECLN) + Store (Zero, ECLN) + } + + If (LEqual (PM6H, One)) + { + CreateBitField (BUF0, ^_Y0C._RW, ECRW) + Store (Zero, ECRW) + } + + If (PM0H) + { + CreateDWordField (BUF0, ^_Y0D._LEN, F0LN) + Store (Zero, F0LN) + } + + If (LEqual (PM0H, One)) + { + CreateBitField (BUF0, ^_Y0D._RW, F0RW) + Store (Zero, F0RW) + } + + CreateDWordField (BUF0, ^_Y0E._MIN, M1MN) + CreateDWordField (BUF0, ^_Y0E._MAX, M1MX) + CreateDWordField (BUF0, ^_Y0E._LEN, M1LN) + ShiftLeft (TLUD, 0x14, M1MN) + Add (Subtract (M1MX, M1MN), One, M1LN) + CreateQWordField (BUF0, ^_Y0F._LEN, MSLN) + Store (Zero, MSLN) + + Return (BUF0) + } + + Device (MCHC) + { + Name (_ADR, Zero) + } + + Device (PEG0) + { + Name (_ADR, 0x00010000) + Name (_PRW, Package (0x02) { 0x0D, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0xFFFF, One, Zero, 0x11 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x12 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x13 } + }) + Device (PEGP) + { + Name (_ADR, 0xFFFF) + } + } + + Device (PEG1) + { + Name (_ADR, 0x00010001) + Name (_PRW, Package (0x02) { 0x0D, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x11 }, + Package (0x04) { 0xFFFF, One, Zero, 0x12 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x13 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x10 } + }) + } + + Device (PEG2) + { + Name (_ADR, 0x00010002) + Name (_PRW, Package (0x02) { 0x0D, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x12 }, + Package (0x04) { 0xFFFF, One, Zero, 0x13 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x10 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x11 } + }) + } + + Device (IGPU) + { + Name (_ADR, 0x00020000) + Device (^^MEM2) + { + Name (_HID, EisaId ("PNP0C01")) + Name (_UID, 0x02) + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0x20000000, 0x00200000, ) + Memory32Fixed (ReadWrite, 0x40000000, 0x00200000, ) + }) + Method (_STA, 0, NotSerialized) + { + If (IGDS) // Uncore enabled? + { + Return (0x0F) + } + + Return (Zero) + } + } + } + + Device (PEG3) + { + Name (_ADR, 0x00060000) + Name (_PRW, Package (0x02) { 0x0D, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x13 }, + Package (0x04) { 0xFFFF, One, Zero, 0x10 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x11 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x12 } + }) + } + + Device (GIGE) + { + Name (_ADR, 0x00190000) + Name (_PRW, Package (0x02) { 0x0D, 0x04 }) + } + + Device (RP01) + { + Name (_ADR, 0x001C0000) + Name (_PRW, Package (0x02) { 0x09, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0xFFFF, One, Zero, 0x11 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x12 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x13 } + }) + } + + Device (RP02) + { + Name (_ADR, 0x001C0001) + Name (_PRW, Package (0x02) { 0x09, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x11 }, + Package (0x04) { 0xFFFF, One, Zero, 0x12 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x13 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x10 } + }) + } + + Device (RP03) + { + Name (_ADR, 0x001C0002) + Name (_PRW, Package (0x02) { 0x09, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x12 }, + Package (0x04) { 0xFFFF, One, Zero, 0x13 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x10 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x11 } + }) + } + + Device (RP04) + { + Name (_ADR, 0x001C0003) + Name (_PRW, Package (0x02) { 0x09, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x13 }, + Package (0x04) { 0xFFFF, One, Zero, 0x10 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x11 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x12 } + }) + } + + Device (RP05) + { + Name (_ADR, 0x001C0004) + Name (_PRW, Package (0x02) { 0x09, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x10 }, + Package (0x04) { 0xFFFF, One, Zero, 0x11 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x12 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x13} + }) + } + + Device (RP06) + { + Name (_ADR, 0x001C0005) + Name (_PRW, Package (0x02) { 0x09, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x11 }, + Package (0x04) { 0xFFFF, One, Zero, 0x12 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x13 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x10 } + }) + } + + Device (EHC2) + { + Name (_ADR, 0x001A0000) + Name (_S3D, 0x02) + Name (_S4D, 0x02) + + OperationRegion (PWKE, PCI_Config, 0x62, One) // PWAKE_CAP—Port Wake Capability Register (datasheet 324645-006, page 652) + Field (PWKE, ByteAcc, NoLock, Preserve) + { + PWI, 1, // Port Wake Implemented + PWUC, 7 // Port Wake Up Capability Mask + } + + Method (_PSW, 1, NotSerialized) + { + Multiply (0x7E, Arg0, PWUC) // Set bit 0-8 based on Arg0 (0 disable- or 1 enable wake capabilities). + } + + Device (HUBN) + { + Name (_ADR, Zero) + Device (PR01) + { + Name (_ADR, One) + Name (_UPC, Package (0x04) { 0xFF, Zero, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0x30, 0x1C, Zero, Zero, Zero, Zero, Zero, Zero }}) + Device (PR11) + { + Name (_ADR, One) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xE1, 0x1C, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR12) + { + Name (_ADR, 0x02) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xE1, 0x1D, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR13) + { + Name (_ADR, 0x03) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xE1, 0x1D, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR14) + { + Name (_ADR, 0x04) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xE1, 0x1E, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR15) + { + Name (_ADR, 0x05) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xB1, 0x1E, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR16) + { + Name (_ADR, 0x06) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xB1, 0x1E, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + } + } + + Name (_PRW, Package (0x02) { 0x0D, 0x04 }) + } + + Device (HDEF) + { + Name (_ADR, 0x001B0000) + Name (_PRW, Package (0x02) { 0x0D, 0x04 }) + } + + Device (RP07) + { + Name (_ADR, 0x001C0006) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x12 }, + Package (0x04) { 0xFFFF, One, Zero, 0x13 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x10 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x11 } + }) + } + + Device (RP08) + { + Name (_ADR, 0x001C0007) + Name (_PRW, Package (0x02) { 0x09, 0x04 }) + Name (_PRT, Package (0x04) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x13 }, + Package (0x04) { 0xFFFF, One, Zero, 0x10 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x11 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x12 } + }) + } + + Device (EHC1) + { + Name (_ADR, 0x001D0000) + Name (_S4D, 0x02) + Name (_S3D, 0x02) + + Device (HUBN) + { + Name (_ADR, Zero) + Device (PR01) + { + Name (_ADR, One) + Name (_UPC, Package (0x04) { 0xFF, Zero, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0x30, 0x1C, Zero, Zero, Zero, Zero, Zero, Zero }}) + Device (PR11) + { + Name (_ADR, One) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xE1, 0x1C, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR12) + { + Name (_ADR, 0x02) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xE1, 0x1D, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR13) + { + Name (_ADR, 0x03) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xE1, 0x1D, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR14) + { + Name (_ADR, 0x04) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xE1, 0x1E, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR15) + { + Name (_ADR, 0x05) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xB1, 0x1E, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR16) + { + Name (_ADR, 0x06) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xB1, 0x1E, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR17) + { + Name (_ADR, 0x07) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xB1, 0x1E, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + + Device (PR18) + { + Name (_ADR, 0x08) + Name (_UPC, Package (0x04) { 0xFF, 0xFF, Zero, Zero }) + Name (_PLD, Package (One) { Buffer (0x10) { 0x81, Zero, Zero, Zero, Zero, Zero, Zero, Zero, 0xB1, 0x1E, Zero, Zero, Zero, Zero, Zero, Zero }}) + } + } + } + } + + Device (P0P1) + { + Name (_ADR, 0x001E0000) + Name (_PRW, Package (0x02) { 0x0B, 0x04 }) + Name (_PRT, Package (0x08) + { + Package (0x04) { 0x0002FFFF, Zero, Zero, 0x12 }, + Package (0x04) { 0x0002FFFF, One, Zero, 0x13 }, + Package (0x04) { 0x0002FFFF, 0x02, Zero, 0x11 }, + Package (0x04) { 0x0002FFFF, 0x03, Zero, 0x10 }, + Package (0x04) { 0x0003FFFF, Zero, Zero, 0x13 }, + Package (0x04) { 0x0003FFFF, One, Zero, 0x12 }, + Package (0x04) { 0x0003FFFF, 0x02, Zero, 0x15 }, + Package (0x04) { 0x0003FFFF, 0x03, Zero, 0x16 } + }) + } + + Device (LPCB) + { + Name (_ADR, 0x001F0000) + OperationRegion (LPC1, PCI_Config, 0xAE, One) + Field (LPC1, AnyAcc, NoLock, Preserve) + { + XUSB, 1 + } + + OperationRegion (LPC0, PCI_Config, 0xF0, 0xC0) + Field (LPC0, AnyAcc, NoLock, Preserve) + { + RAEN, 1, + , 13, + RCBA, 18 + } + + OperationRegion (SMIE, SystemIO, PMBS, 0x02) // PM1_STS—Power Management 1 Status Register (). + Field (SMIE, ByteAcc, NoLock, Preserve) + { + , 10, + RTCS, 1 // Bit 10 - RTC Status (see page 520). + } + + OperationRegion (SLPR, SystemIO, SMCR, 0x08) + Field (SLPR, ByteAcc, NoLock, Preserve) + { + , 4, + SLPE, 1, + , 31, + SLPX, 1 + } + + OperationRegion (GPBX, SystemIO, GPBS, 0x1C) + Field (GPBX, ByteAcc, NoLock, Preserve) + { + Offset (0x18), + , 27, + PLED, 1 + } + + Method (SWAK, 1, NotSerialized) + { + Store (Zero, SLPE) + If (LNot (RTCS)) + { + Notify (PWRB, 0x02) + } + } + + Device (FWHD) + { + Name (_HID, EisaId ("INT0800")) + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadOnly, 0xFF000000, 0x01000000, ) + }) + } + + Device (HPET) + { + Name (_HID, EisaId ("PNP0103")) + Name (_UID, Zero) + Name (_STA, 0x0F) + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0xFED00000, 0x00000400, ) + }) + } + + Device (IPIC) + { + Name (_HID, EisaId ("PNP0000")) + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x0020, 0x0020, 0x01, 0x02, ) + IO (Decode16, 0x0024, 0x0024, 0x01, 0x02, ) + IO (Decode16, 0x0028, 0x0028, 0x01, 0x02, ) + IO (Decode16, 0x002C, 0x002C, 0x01, 0x02, ) + IO (Decode16, 0x0030, 0x0030, 0x01, 0x02, ) + IO (Decode16, 0x0034, 0x0034, 0x01, 0x02, ) + IO (Decode16, 0x0038, 0x0038, 0x01, 0x02, ) + IO (Decode16, 0x003C, 0x003C, 0x01, 0x02, ) + IO (Decode16, 0x00A0, 0x00A0, 0x01, 0x02, ) + IO (Decode16, 0x00A4, 0x00A4, 0x01, 0x02, ) + IO (Decode16, 0x00A8, 0x00A8, 0x01, 0x02, ) + IO (Decode16, 0x00AC, 0x00AC, 0x01, 0x02, ) + IO (Decode16, 0x00B0, 0x00B0, 0x01, 0x02, ) + IO (Decode16, 0x00B4, 0x00B4, 0x01, 0x02, ) + IO (Decode16, 0x00B8, 0x00B8, 0x01, 0x02, ) + IO (Decode16, 0x00BC, 0x00BC, 0x01, 0x02, ) + IO (Decode16, 0x04D0, 0x04D0, 0x01, 0x02, ) + IRQNoFlags () {2} + }) + } + + Device (LDRC) + { + Name (_HID, EisaId ("PNP0C02")) + Name (_UID, 0x02) + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x002E, 0x002E, 0x01, 0x02, ) + IO (Decode16, 0x004E, 0x004E, 0x01, 0x02, ) + IO (Decode16, 0x0061, 0x0061, 0x01, 0x01, ) + IO (Decode16, 0x0063, 0x0063, 0x01, 0x01, ) + IO (Decode16, 0x0065, 0x0065, 0x01, 0x01, ) + IO (Decode16, 0x0067, 0x0067, 0x01, 0x01, ) + IO (Decode16, 0x0070, 0x0070, 0x01, 0x01, ) + IO (Decode16, 0x0080, 0x0080, 0x01, 0x01, ) + IO (Decode16, 0x0092, 0x0092, 0x01, 0x01, ) + IO (Decode16, 0x00B2, 0x00B2, 0x01, 0x02, ) + IO (Decode16, 0x0680, 0x0680, 0x01, 0x20, ) + IO (Decode16, 0x0200, 0x0200, 0x01, 0x10, ) + IO (Decode16, 0xFFFF, 0xFFFF, 0x01, 0x01, ) + IO (Decode16, 0xFFFF, 0xFFFF, 0x01, 0x01, ) + IO (Decode16, 0x0400, 0x0400, 0x01, 0x54, ) + IO (Decode16, 0x0458, 0x0458, 0x01, 0x28, ) + IO (Decode16, 0x0500, 0x0500, 0x01, 0x80, ) + IO (Decode16, 0x164E, 0x164E, 0x01, 0x02, ) + }) + } + + Device (PDRC) + { + Name (_HID, EisaId ("PNP0C02")) + Name (_UID, One) + Name (BUF0, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0x00000000, 0x00004000, _Y10) + Memory32Fixed (ReadWrite, 0x00000000, 0x00001000, _Y11) + Memory32Fixed (ReadWrite, 0x00000000, 0x00008000, _Y12) + Memory32Fixed (ReadWrite, 0x00000000, 0x00001000, _Y13) + Memory32Fixed (ReadWrite, 0x00000000, 0x00001000, _Y14) + Memory32Fixed (ReadWrite, 0x00000000, 0x00000000, _Y15) + + Memory32Fixed (ReadWrite, 0xFED20000, 0x00020000, ) + Memory32Fixed (ReadOnly, 0xFED90000, 0x00004000, ) + Memory32Fixed (ReadWrite, 0xFED45000, 0x0004B000, ) + Memory32Fixed (ReadOnly, 0xFF000000, 0x01000000, ) + Memory32Fixed (ReadOnly, 0xFEE00000, 0x00100000, ) + + }) + Method (_CRS, 0, Serialized) + { + CreateDWordField (BUF0, ^_Y10._BAS, RBR0) + ShiftLeft (RCBA, 0x0E, RBR0) + CreateDWordField (BUF0, ^_Y11._BAS, TBR0) + Store (TBAB, TBR0) + CreateDWordField (BUF0, ^_Y11._LEN, TBLN) + If (LEqual (TBAB, Zero)) + { + Store (Zero, TBLN) + } + + CreateDWordField (BUF0, ^_Y12._BAS, MBR0) + ShiftLeft (MHBR, 0x0F, MBR0) + CreateDWordField (BUF0, ^_Y13._BAS, DBR0) + ShiftLeft (DIBR, 0x0C, DBR0) + CreateDWordField (BUF0, ^_Y14._BAS, EBR0) + ShiftLeft (EPBR, 0x0C, EBR0) + CreateDWordField (BUF0, ^_Y15._BAS, XBR0) + ShiftLeft (PXBR, 0x1A, XBR0) + CreateDWordField (BUF0, ^_Y15._LEN, XSZ0) + ShiftRight (0x10000000, PXSZ, XSZ0) + Return (BUF0) + } + } + + Device (RTC) + { + Name (_HID, EisaId ("PNP0B00")) + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x0070, 0x0070, 0x01, 0x08, ) + IRQNoFlags () {8} + }) + } + + Device (TIMR) + { + Name (_HID, EisaId ("PNP0100")) + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x0040, 0x0040, 0x01, 0x04, ) + IO (Decode16, 0x0050, 0x0050, 0x10, 0x04, ) + IRQNoFlags () {0} + }) + } + + Device (EC) + { + Name (_HID, EisaId ("PNP0C09")) + Name (_GPE, 0x18) + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x0062, 0x0062, 0x00, 0x01, ) + IO (Decode16, 0x0066, 0x0066, 0x00, 0x01, ) + }) + } + + Device (MATH) + { + Name (_HID, EisaId ("PNP0C04")) + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x00F0, 0x00F0, 0x00, 0x10, ) + IRQNoFlags () {13} + }) + } + } + + Device (SATA) + { + Name (_ADR, 0x001F0002) + } + + Device (SBUS) + { + Name (_ADR, 0x001F0003) + Device (BUS0) + { + Name (_CID, "smbus") + Name (_ADR, Zero) + Device (DVL0) + { + Name (_ADR, 0x57) + Name (_CID, "diagsvault") + } + } + } + } + + Device (PWRB) + { + Name (_HID, EisaId ("PNP0C0C")) + Name (_UID, 0xAA) + Name (_STA, 0x0B) + Name (_PRW, Package (0x02) { 0x1D, 0x04 }) + } + } + + Scope (_GPE) + { + Method (_L01, 0, NotSerialized) + { + Add (L01C, One, L01C) + } + + Method (_L02, 0, NotSerialized) + { + Store (Zero, GPEC) + } + + Method (_L09, 0, NotSerialized) + { + Notify (\_SB.PCI0.PEG0, 0x02) + Notify (\_SB.PCI0.PEG0.PEGP, 0x02) + Notify (\_SB.PCI0.PEG1, 0x02) + Notify (\_SB.PCI0.PEG2, 0x02) + Notify (\_SB.PCI0.PEG3, 0x02) + } + + Method (_L0B, 0, NotSerialized) + { + Notify (\_SB.PCI0.P0P1, 0x02) + Notify (\_SB.PWRB, 0x02) + } + + Method (_L0D, 0, NotSerialized) + { + Notify (\_SB.PCI0.EHC1, 0x02) + Notify (\_SB.PCI0.EHC2, 0x02) + Notify (\_SB.PCI0.HDEF, 0x02) + Notify (\_SB.PCI0.GIGE, 0x02) + } + + Method (_L1D, 0, NotSerialized) + { + Notify (\_SB.PWRB, 0x02) + } + } + + Name (_S0, Package (0x03) { Zero, Zero, Zero }) + Name (_S3, Package (0x03) { 0x05, 0x05, Zero }) + Name (_S4, Package (0x03) { 0x06, 0x06, Zero }) + Name (_S5, Package (0x03) { 0x07, 0x07, Zero }) + + Method (_PTS, 1, NotSerialized) + { + If (Arg0) + { + Store (One, \_SB.PCI0.LPCB.SLPX) + Store (One, \_SB.PCI0.LPCB.SLPE) + If (LAnd (LGreater (Arg0, 0x03), LLess (Arg0, 0x06))) + { + Store (Arg0, \_SB.SMIC) + Store (One, GP27) + } + } + } + + Method (_WAK, 1, Serialized) + { + \_SB.PCI0.LPCB.SWAK (Arg0) + Store (Zero, \_SB.PCI0.LPCB.PLED) + Return (Package (0x02) + { + Zero, + Zero + }) + } +} diff --git a/i386/libsaio/acpi/examples/P8Z68-V PRO/ssdt.dsl b/i386/libsaio/acpi/examples/P8Z68-V PRO/ssdt.dsl new file mode 100644 index 0000000..3a92b59 --- /dev/null +++ b/i386/libsaio/acpi/examples/P8Z68-V PRO/ssdt.dsl @@ -0,0 +1,199 @@ +/* + * Intel ACPI Component Architecture + * AML Disassembler version 20130214-64 [Mar 24 2013] + * Copyright (c) 2000 - 2013 Intel Corporation + * + * Disassembly of ssdt.aml, Mon Mar 25 08:07:55 2013 + * + * Original Table Header: + * Signature "SSDT" + * Length 0x000004FF (1279) + * Revision 0x01 + * Checksum 0x72 + * OEM ID "APPLE " + * OEM Table ID "general" + * OEM Revision 0x00001000 (4096) + * Compiler ID "INTL" + * Compiler Version 0x20130214 (538116628) + */ +DefinitionBlock ("ssdt.aml", "SSDT", 1, "APPLE ", "general", 0x00001000) +{ + External (_SB_.PCI0.EHC1, DeviceObj) + External (_SB_.PCI0.EHC2, DeviceObj) + External (_SB_.PCI0.LPCB.HPET, DeviceObj) + External (_SB_.PCI0.RP02, DeviceObj) + External (_SB_.PCI0.RP04, DeviceObj) + External (_SB_.PCI0.RP05, DeviceObj) + External (_SB_.PCI0.RP07, DeviceObj) + External (HPTC, IntObj) + + Scope (\_SB.PCI0.EHC2) + { + Name (AAPL, Package (0x0B) + { + "AAPL,current-available", + 0x0834, + "AAPL,current-extra", + 0x0898, + "AAPL,current-extra-in-sleep", + 0x0640, + "AAPL,max-port-current-in-sleep", + 0x0834, + "AAPL,device-internal", + 0x02, + Buffer (One) { 0x00 } + }) + + Method (_DSM, 4, NotSerialized) + { + If (LEqual (Arg2, Zero)) + { + Return (Buffer (One) { 0x03 }) + } + + Return (RefOf (AAPL)) + } + } + + Scope (\_SB.PCI0.RP02) + { + Device (XHC1) + { + Name (_ADR, Zero) + Name (_PRW, Package(0x02) { 0x0D, 0x04 }) + Name (_S4D, 0x03) + Name (_S3D, 0x03) + Name (MBSD, One) + Name (XHCN, One) + } + } + + Scope (\_SB.PCI0.RP04) + { + Device (JMB0) + { + Name (_ADR, Zero) + OperationRegion (CF40, PCI_Config, 0x40, 0x04) + Field (CF40, ByteAcc, NoLock, Preserve) + { + CHE0, 1, + MULT, 1, + , 1, + CAB0, 1, + CHE1, 1, + Offset (0x01), + AHEN, 1, + , 3, + PRT0, 1, + AHM0, 1, + PRT1, 1, + AHM1, 1, + CF42, 6, + SWAP, 1, + PATA, 1, + , 6, + WTEN, 1, + Offset (0x04) + } + } + + Device (JMB1) + { + Name (_ADR, One) + OperationRegion (CF40, PCI_Config, 0x40, 0x04) + Field (CF40, ByteAcc, NoLock, Preserve) + { + CHE0, 1, + MULT, 1, + , 1, + CAB0, 1, + CHE1, 1, + Offset (0x01), + AHEN, 1, + , 3, + PRT0, 1, + AHM0, 1, + PRT1, 1, + AHM1, 1, + CF42, 6, + SWAP, 1, + PATA, 1, + , 6, + WTEN, 1, + Offset (0x04) + } + } + } + + Scope (\_SB.PCI0.RP05) + { + Device (XHC1) + { + Name (_ADR, Zero) + Name (_PRW, Package (0x02) { 0x0D, 0x04 }) + Name (_S4D, 0x03) + Name (_S3D, 0x03) + Name (MBSD, One) + Name (XHCN, One) + } + } + + Scope (\_SB.PCI0.RP07) + { + Device (FWBR) + { + Name (_ADR, Zero) + Name (_PRW, Package (0x02) { 0x0B, 0x04 }) + Name (_PRT, Package (0x0C) + { + Package (0x04) { 0xFFFF, Zero, Zero, 0x12 }, + Package (0x04) { 0xFFFF, One, Zero, 0x13 }, + Package (0x04) { 0xFFFF, 0x02, Zero, 0x10 }, + Package (0x04) { 0xFFFF, 0x03, Zero, 0x11 }, + Package (0x04) { 0x0001FFFF, Zero, Zero, 0x13 }, + Package (0x04) { 0x0001FFFF, One, Zero, 0x10 }, + Package (0x04) { 0x0001FFFF, 0x02, Zero, 0x11 }, + Package (0x04) { 0x0001FFFF, 0x03, Zero, 0x12 }, + Package (0x04) { 0x0002FFFF, Zero, Zero, 0x11 }, + Package (0x04) { 0x0002FFFF, One, Zero, 0x12 }, + Package (0x04) { 0x0002FFFF, 0x02, Zero, 0x13 }, + Package (0x04) { 0x0002FFFF, 0x03, Zero, 0x10 } + }) + + Device (FRWR) + { + Name (_ADR, 0x00020000) + } + } + } + + Scope (\_SB.PCI0.EHC1) + { + Method (_DSM, 4, NotSerialized) + { + If (LEqual (Arg2, Zero)) + { + Return (Buffer (One) { 0x03 }) + } + + Return (RefOf (\_SB.PCI0.EHC2.AAPL)) + } + } + + /* Optional code to activate the HPET */ + Scope (\_SB.PCI0.LPCB.HPET) + { + OperationRegion (RCRB, SystemMemory, HPTC, One) + Field (RCRB, ByteAcc, Lock, Preserve) + { + , 7, + HPAE, 1 + } + + Method (_INI, 0, NotSerialized) + { + Store (One, HPAE) + } + } +} + diff --git a/i386/libsaio/acpi/patcher.h b/i386/libsaio/acpi/patcher.h index f1617a8..79aca88 100644 --- a/i386/libsaio/acpi/patcher.h +++ b/i386/libsaio/acpi/patcher.h @@ -7,52 +7,96 @@ * - Refactorized for Revolution by DHP in 2010. * - A complete new implementation written for RevoBoot by DHP in 2011. * - Automatic SSDT_PR creation added by DHP in June 2011. + * - Call loadBinaryData from loadACPITable (PikerAlpha, October 2012). + * - Moved extern declarations to saio_internal.h (PikerAlpha, October 2012). + * - Now using gPlatform.CommaLessModelID instead of gPlatform.ModelID (PikerAlpha, October 2012). + * - Fall back to non-model specific file when model specific file is unavailable (PikerAlpha, October 2012). */ -extern ACPI_RSDP * getACPIBaseAddress(); - - #if PATCH_ACPI_TABLE_DATA #if AUTOMATIC_SSDT_PR_CREATION #include "ssdt_pr_generator.h" #endif -#if LOAD_EXTRA_ACPI_TABLES && (LOAD_DSDT_TABLE_FROM_EXTRA_ACPI || LOAD_SSDT_TABLE_FROM_EXTRA_ACPI) + +#if VERIFY_OPREGION_GNVS_ADDRESS //============================================================================== -int loadACPITable(int tableIndex) +unsigned int search64bitPattern(unsigned int aStartAddress, int aNumberOfBytes, uint64_t aSearchPattern) { - _ACPI_DEBUG_DUMP("loadACPITable(%s / ", customTables[tableIndex].name); + unsigned char * baseAddress = (unsigned char *) aStartAddress; + unsigned char * endAddress = (baseAddress + aNumberOfBytes); - char dirspec[32]; - sprintf (dirspec, "/Extra/ACPI/%s.aml", customTables[tableIndex].name); - int fd = open(dirspec, 0); - - if (fd < 0) + for (; baseAddress <= endAddress; baseAddress++) { - _ACPI_DEBUG_DUMP("Error: File not found.)\n"); + if (*(uint64_t *)baseAddress == aSearchPattern) + { + _ACPI_DEBUG_DUMP("GNVS Address Found @ 0x%x\n", baseAddress); - return -1; + return (unsigned int)baseAddress; // Found! + } } - int fileSize = file_size(fd); - void * kernelAddress = malloc(fileSize); + return 0; // Not found! +} +#endif // VERIFY_OPREGION_GNVS_ADDRESS + + +#if (LOAD_EXTRA_ACPI_TABLES && (LOAD_DSDT_TABLE_FROM_EXTRA_ACPI || LOAD_SSDT_TABLE_FROM_EXTRA_ACPI)) +//============================================================================== + +int loadACPITable(int tableIndex) +{ + char dirSpec[48]; + long fileSize = 0; + void * tableAddress = (void *)kLoadAddr; + + bzero(dirSpec, 48); +#if LOAD_MODEL_SPECIFIC_ACPI_DATA + // Example: /Extra/ACPI/DSDT-MacBookPro101.aml + // 0123456789 0123456789 0123456789 1 + sprintf(dirSpec, "/Extra/ACPI/%s-%s.aml", customTables[tableIndex].name, gPlatform.CommaLessModelID); + + /* + * loadBinaryData calls LoadFile (both in sys.c) to load table data into a + * load buffer at kLoadAddr (defined in memory.h) and copies it into a new + * allocated memory block (kLoadAddr gets overwritten by the next call). + */ + fileSize = loadBinaryData(dirSpec, &tableAddress); - if (kernelAddress) + if (fileSize == -1) { - read(fd, kernelAddress, fileSize); +#endif + // File: /Extra/ACPI/DSDT-MacBookPro101.aml not found. Try: /Extra/ACPI/dsdt.aml + sprintf(dirSpec, "/Extra/ACPI/%s.aml", customTables[tableIndex].name); + fileSize = loadBinaryData(dirSpec, &tableAddress); +#if LOAD_MODEL_SPECIFIC_ACPI_DATA } +#endif - close(fd); + if (fileSize > 0) + { + _ACPI_DEBUG_DUMP("Loading: %s (%d bytes).\n", dirSpec, fileSize); + _ACPI_DEBUG_SLEEP(1); + + // 'tableAddress' is copied into kernel memory later on (see setupACPI). + customTables[tableIndex].table = tableAddress; + customTables[tableIndex].tableLength = fileSize; + +#if (DEBUG_ACPI && LOAD_MODEL_SPECIFIC_ACPI_DATA) + // Update table name from DSDT.aml to DSDT-Macmini51.aml (DSDT example). + sprintf(customTables[tableIndex].fileName, gPlatform.CommaLessModelID); +#endif - _ACPI_DEBUG_DUMP("%d bytes).\n", fileSize); + return 0; + } - customTables[tableIndex].table = kernelAddress; - customTables[tableIndex].tableLength = fileSize; + _ACPI_DEBUG_DUMP("Error: File %s not found.)\n", dirSpec); + _ACPI_DEBUG_SLEEP(5); - return 0; + return -1; } @@ -67,6 +111,7 @@ void loadACPITables(void) #endif // LOAD_DSDT_TABLE_FROM_EXTRA_ACPI #if LOAD_SSDT_TABLE_FROM_EXTRA_ACPI + // loadACPITable(APIC); Table load example! loadACPITable(SSDT); loadACPITable(SSDT_PR); // Overrides STATIC_SSDT_PR_TABLE_DATA / AUTOMATIC_SSDT_PR_CREATION when found! loadACPITable(SSDT_USB); @@ -173,7 +218,7 @@ void overrideACPIMethods(ACPI_FADT *patchedFADT) } // Fix checksum. patchedDSDT->Checksum = 0; - patchedDSDT->Checksum = 256 - checksum8(patchedDSDT, sizeof(patchedDSDT)); + patchedDSDT->Checksum = checksum8(patchedDSDT, sizeof(patchedDSDT)); // We're done. Using the patched factory DSDT now. patchedFADT->DSDT = patchedFADT->X_DSDT = (uint32_t)patchedDSDT; @@ -236,6 +281,45 @@ bool patchFACPTable(ENTRIES * xsdtEntries, int tableIndex, int dropOffset) overrideACPIMethods(patchedFADT); #elif STATIC_DSDT_TABLE_INJECTION || (LOAD_EXTRA_ACPI_TABLES && LOAD_DSDT_TABLE_FROM_EXTRA_ACPI) patchedFADT->DSDT = (uint32_t)customTables[DSDT].tableAddress; // The original DSDT without DSDT table injection! + +#if VERIFY_OPREGION_GNVS_ADDRESS + #define OP_REGION_GNVS_ADDRESS_LE 0x0C0053564E47805B + // First try to locate the OperationRegion (GNVS, SystemMemory, 0xNNNNNNNN, 0xNNNN) in the factory DSDT. + unsigned int opRegFactoryDSDTAddress = search64bitPattern(factoryFADT->DSDT + sizeof(ACPI_DSDT), 2000, OP_REGION_GNVS_ADDRESS_LE); + + if (opRegFactoryDSDTAddress) // Found? + { + // Yes. Get the GNVS address. + unsigned int factoryDSDT_GNVS_Address = (*(uint32_t *)(opRegFactoryDSDTAddress + 8)); +#if (DEBUG_ACPI || DUMP_OPREGION_GNVS_ADDRESS) + printf("GNVS address (0x%x) found @: 0x%x\n", factoryDSDT_GNVS_Address, opRegFactoryDSDTAddress); +#endif + // Now try to locate the OperationRegion (GNVS, SystemMemory, 0xNNNNNNNN, 0xNNNN) in the patched DSDT. + unsigned int opRegPatchedDSDTAddress = search64bitPattern(patchedFADT->DSDT + sizeof(ACPI_DSDT), 2000, OP_REGION_GNVS_ADDRESS_LE); + + if (opRegPatchedDSDTAddress) // Found? + { + // Yes. Get the GNVS address. + unsigned int patchedDSDT_GNVS_Address = (*(uint32_t *)(opRegPatchedDSDTAddress + 8)); +#if (DEBUG_ACPI || DUMP_OPREGION_GNVS_ADDRESS) + printf("GNVS address (0x%x) found @: 0x%08x\n", patchedDSDT_GNVS_Address, opRegPatchedDSDTAddress); +#endif + // Are both GNVS address values the same? + if (patchedDSDT_GNVS_Address != factoryDSDT_GNVS_Address) + { + _ACPI_DEBUG_DUMP("Patching GNVS address ... "); + // Copy the 4 address bytes from the factory DSDT into the patched DSDT. + // Note: We do not copy the length (may be different for a patched DSDT). + memcpy((void *)opRegPatchedDSDTAddress, (void *)opRegFactoryDSDTAddress, 4); + + _ACPI_DEBUG_DUMP("Done.\n"); + } + } +#if (DEBUG_ACPI || DUMP_OPREGION_GNVS_ADDRESS) + sleep(1); +#endif + } +#endif // VERIFY_OPREGION_GNVS_ADDRESS _ACPI_DEBUG_DUMP("Replacing factory DSDT with "); @@ -243,8 +327,8 @@ bool patchFACPTable(ENTRIES * xsdtEntries, int tableIndex, int dropOffset) { #if STATIC_DSDT_TABLE_INJECTION _ACPI_DEBUG_DUMP("static DSDT data"); -#else // STATIC_DSDT_TABLE_INJECTION - _ACPI_DEBUG_DUMP("loaded DSDT.aml"); +#elif LOAD_MODEL_SPECIFIC_ACPI_DATA + _ACPI_DEBUG_DUMP("%s", customTables[DSDT].fileName); #endif // STATIC_DSDT_TABLE_INJECTION _ACPI_DEBUG_DUMP(" @ 0x%x\n", customTables[DSDT].tableAddress); @@ -264,15 +348,27 @@ bool patchFACPTable(ENTRIES * xsdtEntries, int tableIndex, int dropOffset) #if STATIC_FACS_TABLE_INJECTION // Replace the factory FACS table. _ACPI_DEBUG_DUMP("patchedFADT->FIRMWARE_CTRL: 0x%08x\n", patchedFADT->FIRMWARE_CTRL); - - patchedFADT->FIRMWARE_CTRL = (uint32_t)customTables[FACS].tableAddress; - // Zero out this field conform the ACPI specification. - patchedFADT->X_FIRMWARE_CTRL = (uint64_t) 0; + + /* + * factoryFADT->FIRMWARE_CTRL is usually non zero on systems with less than 4GB. + */ + if (factoryFADT->FIRMWARE_CTRL > 0) + { + // In which case we must use this value + patchedFADT->FIRMWARE_CTRL = (uint32_t) customTables[FACS].tableAddress; + // And we must zero out this field (conform the ACPI specification). + patchedFADT->X_FIRMWARE_CTRL = (uint64_t) 0; + } + else + { + patchedFADT->FIRMWARE_CTRL = (uint32_t) 0; + patchedFADT->X_FIRMWARE_CTRL = (uint64_t) customTables[FACS].tableAddress; + } customTables[FACS].table = NULL; #endif // STATIC_FACS_TABLE_INJECTION patchedFADT->Checksum = 0; - patchedFADT->Checksum = 256 - checksum8(patchedFADT, sizeof(ACPI_FADT)); + patchedFADT->Checksum = checksum8(patchedFADT, sizeof(ACPI_FADT)); xsdtEntries[tableIndex - dropOffset] = (uint32_t)patchedFADT; @@ -316,6 +412,10 @@ void setupACPI(void) _ACPI_DEBUG_DUMP("\n"); +#if DROP_SELECTED_SSDT_TABLE + const char * oemTableIdTargets[] = OEM_TABLE_ID_TARGETS; +#endif + int cti = 0; // CustomTableIndex for (; customTables[cti].table; cti++) @@ -443,9 +543,38 @@ void setupACPI(void) } else if (essentialTables[idx].action & kDropTable) { - _ACPI_DEBUG_DUMP("Dropping table: %s (on request)\n", tableName); - - dropOffset++; +#if DROP_SELECTED_SSDT_TABLE + short tid = 0; + + if (tableSignature == SSDT_TABLE_SIGNATURE) + { + ACPI_SSDT * currentTable = (ACPI_SSDT *)table; + + _ACPI_DEBUG_DUMP("Checking SSDT(%s)\n", currentTable->OEMTableId); + + do + { + if (strncmp(currentTable->OEMTableId, oemTableIdTargets[tid], strlen(currentTable->OEMTableId)) == 0) + { + _ACPI_DEBUG_DUMP("Dropping table: %s (on request)\n", tableName); + + dropOffset++; + + break; + } + + tid++; + } while (oemTableIdTargets[tid] != 0); + } + else + { +#endif + _ACPI_DEBUG_DUMP("Dropping table: %s (on request)\n", tableName); + + dropOffset++; +#if DROP_SELECTED_SSDT_TABLE + } +#endif } } @@ -471,7 +600,7 @@ void setupACPI(void) int newTableEntries = 0; // Now wade through the custom table entries to see if they have been assigned already. - for (cti = 0; cti < 13; cti++) + for (cti = 0; cti < 14; cti++) { // We need an address so check it. if (customTables[cti].table) @@ -512,24 +641,24 @@ void setupACPI(void) // Yes, fix length. patchedXSDT->Length -= (ADDRESS_WIDTH * dropOffset); - _ACPI_DEBUG_DUMP("patchedXSDT->Length (changed): %d\n", patchedXSDT->Length); + _ACPI_DEBUG_DUMP("patchedXSDT->Length (changed): %d/%d\n", patchedXSDT->Length, (patchedXSDT->Length / ADDRESS_WIDTH)); } _ACPI_DEBUG_DUMP("\nRecalculating checksums / "); // Patch the checksum of the new XSDP table. patchedXSDT->Checksum = 0; - patchedXSDT->Checksum = 256 - checksum8(patchedXSDT, patchedXSDT->Length); + patchedXSDT->Checksum = checksum8(patchedXSDT, patchedXSDT->Length); // Patch the checksum of the new RSDP table. patchedRSDP->Checksum = 0; - patchedRSDP->Checksum = 256 - checksum8(patchedRSDP, 20); + patchedRSDP->Checksum = checksum8(patchedRSDP, 20); // Patch the (extended) checksum of the RSDP for table revision 1 and greater. if (patchedRSDP->Revision) { patchedRSDP->ExtendedChecksum = 0; - patchedRSDP->ExtendedChecksum = 256 - checksum8(patchedRSDP, patchedRSDP->Length); + patchedRSDP->ExtendedChecksum = checksum8(patchedRSDP, patchedRSDP->Length); } } diff --git a/i386/libsaio/acpi/ssdt_pr_generator.h b/i386/libsaio/acpi/ssdt_pr_generator.h index 6bd183d..e58f2c4 100644 --- a/i386/libsaio/acpi/ssdt_pr_generator.h +++ b/i386/libsaio/acpi/ssdt_pr_generator.h @@ -94,9 +94,12 @@ void generateSSDT_PR(void) #endif #if AUTOMATIC_PROCESSOR_BLOCK_CREATION - uint8_t SCOPE_PR[] = // Scope (\_PR) { } + uint8_t SCOPE_PR[] = // Scope (\_PR_) { } { /* 0000 */ 0x10, 0xFF, 0xFF, 0x5C, 0x5F, 0x50, 0x52, 0x5F + + /* 0000 * / 0x10, 0xFF, 0xFF, 0x5C, 0x2E, 0x5F, 0x50, 0x52 + / *0008 * / 0x5F */ }; uint8_t PROCESSOR_DEF_BLOCK[] = @@ -116,8 +119,8 @@ void generateSSDT_PR(void) uint8_t SCOPE_PR_CPU0[] = // Scope (\_PR.CPU0) { } { - /* 0000 */ 0x10, 0xFF, 0xFF, 0x2E, 0x5F, 0x50, 0x52, 0x5F, - /* 0008 */ _CPU_LABEL_REPLACEMENT + /* 0000 */ 0x10, 0xFF, 0xFF, 0x5C, 0x2E, 0x5F, 0x50, 0x52, + /* 0008 */ 0x5F, _CPU_LABEL_REPLACEMENT }; uint8_t NAME_APSN[] = // Name (APSN, 0xFF) @@ -678,7 +681,7 @@ void generateSSDT_PR(void) header->Length = bufferSize; header->Checksum = 0; - header->Checksum = 256 - checksum8(buffer, header->Length); + header->Checksum = checksum8(buffer, header->Length); //-------------------------------------------------------------------------- // Updating customTables with the required data. diff --git a/i386/libsaio/acpi/static_data.h b/i386/libsaio/acpi/static_data.h index 8bf28d2..8aa3ce0 100755 --- a/i386/libsaio/acpi/static_data.h +++ b/i386/libsaio/acpi/static_data.h @@ -1,19 +1,18 @@ /* - * Copyright 2009 by Master Chief. + * Static data overrides for ACPI tables. Copyright 2009 by Master Chief. * - * Refactored (dynamic and static ACPI patching) by DHP in 2010/2011. + * Updates: + * - Refactored (dynamic and static ACPI patching) by DHP in 2010/2011. + * - Data selector moved over from RevoBoot/i386/config/data.h (PikerAlpha, October 2012). */ #ifndef __LIBSAIO_ACPI_STATIC_DATA_H #define __LIBSAIO_ACPI_STATIC_DATA_H -#define INCLUDE_ACPI_DATA 1 +// The STRING (macro) is defined in RevoBoot/i386/config/settings.h +#include STRING(ACPI_DATA_FILE) -#include "../config/data.h" - -// The STATIC_xxx_TABLE_DATA's here will get replaced with the data from private_data.h - -// Static data overrides for essential tables. +// The STATIC_xxx_TABLE_DATA's here will get replaced with the data from RevoBoot/i386/config/ACPI/[default/MacmodelNN].h static uint32_t APIC_Table[] = { @@ -22,6 +21,12 @@ static uint32_t APIC_Table[] = #endif }; +static uint32_t DMAR_Table[] = +{ +#if STATIC_DMAR_TABLE_INJECTION + STATIC_DMAR_TABLE_DATA +#endif +}; static uint32_t ECDT_Table[] = { diff --git a/i386/libsaio/allocate.c b/i386/libsaio/allocate.c index f986219..fda989b 100755 --- a/i386/libsaio/allocate.c +++ b/i386/libsaio/allocate.c @@ -20,6 +20,11 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ + * + * + * Updates: + * - Layout only change (PikerAlpha, November 2012) + * */ #include "sl.h" @@ -28,43 +33,40 @@ #include "device_tree.h" #include "platform.h" -#define kPageSize 4096 -#define RoundPage(x) ((((unsigned)(x)) + kPageSize - 1) & ~(kPageSize - 1)) +#define kPageSize 4096 +#define RoundPage(x) ((((unsigned)(x)) + kPageSize - 1) & ~(kPageSize - 1)) //============================================================================== -long AllocateMemoryRange(char * rangeName, long start, long length, long type) +long AllocateMemoryRange(char * rangeName, long start, long length) { - char *nameBuf; - uint32_t *buffer; - - nameBuf = malloc(strlen(rangeName) + 1); - - if (nameBuf == 0) - { - return -1; - } - - strcpy(nameBuf, rangeName); - - buffer = malloc(2 * sizeof(uint32_t)); - - if (buffer == 0) + if (rangeName) { - return -1; - } - - buffer[0] = start; - buffer[1] = length; - + char *nameBuf = malloc(strlen(rangeName) + 1); + + if (nameBuf) + { + strcpy(nameBuf, rangeName); + uint32_t *buffer = malloc(2 * sizeof(uint32_t)); + + if (buffer) + { + buffer[0] = start; + buffer[1] = length; #if DEBUG - printf("AllocateMemoryRange : %s - 0x%lx - 0x%lx\n", nameBuf, length, start); + printf("AllocateMemoryRange(%s) @0x%lx, length 0x%lx\n", rangeName, start, length); #endif + DT__AddProperty(gPlatform.EFI.Nodes.MemoryMap, nameBuf, 2 * sizeof(uint32_t), (char *)buffer); + + return 0; + } + + free(nameBuf); + } + } - DT__AddProperty(gPlatform.EFI.Nodes.MemoryMap, nameBuf, 2 * sizeof(uint32_t), (char *)buffer); - - return 0; + return -1; } @@ -89,7 +91,7 @@ long AllocateKernelMemory(long inSize) #if DEBUG printf("AllocateKernelMemory: 0x%lx - 0x%lx\n", address, inSize); - getchar(); + sleep(3); #endif return address; diff --git a/i386/libsaio/asm.s b/i386/libsaio/asm.s index 768ba43..cc6e08d 100755 --- a/i386/libsaio/asm.s +++ b/i386/libsaio/asm.s @@ -334,24 +334,27 @@ LABEL(_halt) call _bgetc jmp _halt -#if ((MAKE_TARGET_OS & LION) == LION) +#if ((MAKE_TARGET_OS & LION) == LION) // El Capitan, Yosemite, Mavericks, Mountain Lion and Lion // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // disableIRQs() // -// Port of a two liner hack in xnu/pexpert/i386/pe_init.c -> PE_init_platform() +// Port of a two liner hack in xnu-1504.15.3/pexpert/i386/pe_init.c -> PE_init_platform() // -// Note: Thanks to cparm for locating it and copying it to Chameleons' boot.c +// Note: Thanks to 'cparm' for locating it and copying it to Chameleons' boot.c // LABEL(_disableIRQs) // The ACPI specification dictates that the 8259 (PC-AT compatible) vectors // must be disabled (that is, masked) when enabling the ACPI APIC operation // but this isn't done (apparently) on all mobo's and thus we do that here. + // + // Vectors 0-7 are used in 16-bit real mode, vectors 0-31 in protected mode/ + // long mode (vectors 32-255 are available for software defined interrupts). push %eax // Saving register data movb $0xff, %al // Load mask - outb %al, $0x21 // Disable IRQ's 0-7 on Master PIC - outb %al, $0xa1 // Disable IRQ's 8-15 on Slave PIC + outb %al, $0x21 // Disable IRQ's 0-7 on Master PIC (0x21) + outb %al, $0xa1 // Disable IRQ's 8-15 on Slave PIC (0xa1) popl %eax // Restore register data @@ -365,13 +368,13 @@ LABEL(_disableIRQs) // Passes boot arguments in %eax. // LABEL(_startMachKernel) -#if ((MAKE_TARGET_OS & LION) == LION) - call _disableIRQs // Taking care of a ACPI bug. +#if ((MAKE_TARGET_OS & LION) == LION) // El Capitan, Yosemite, Mavericks, Lion and Mountain Lion + call _disableIRQs // Taking care of an early reboot bug. #endif push %ebp mov %esp, %ebp - mov 0xc(%ebp), %eax // bootargs to mach_kernel + mov 0xc(%ebp), %eax // bootargs to (mach_)kernel mov 0x8(%ebp), %ecx // entry offset mov $0x28, %ebx // segment push %ebx @@ -424,3 +427,29 @@ LABEL(__switch_stack) xorl %edi, %edi ret + +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite and El Capitan +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// computeRand() +// + +LABEL(_computeRand) + pushl %edx + mov $0xa, %edx + +Repeat: + rdrand %eax + jae Ok + jmp Exit + +Ok: + dec %edx + pause + jne Repeat + mov $0x0, %eax + +Exit: + popl %edx + + ret +#endif diff --git a/i386/libsaio/base64.c b/i386/libsaio/base64.c new file mode 100755 index 0000000..2ffd0b6 --- /dev/null +++ b/i386/libsaio/base64.c @@ -0,0 +1,412 @@ +/* + * + * Name : guidTest.c + * Version : 0.4 + * Type : Command line test tool + * Copyright : Sam aka RevoGirl (c) 18 March 2011 + * + * Compile with : cc base64.c -o base64 -Wall -framework IOKit -framework CoreFoundation + * + * See also : http://www.projectosx.com/forum/index.php?showtopic=2008&st=120&p=13378&#entry13378 + * + * Updates - guidTest.c included as RevoBootr/i386/libsaio/base64.c (PikerAlpha, November 2012) + * - DEBUG renamed to DEBUG_BASE64_DECODE (PikerAlpha, November 2012) + * - STAND_ALONE check added (PikerAlpha, November 2012) + * - Workaround for "___bzero" undefined error in RevoBoot (PikerAlpha, November 2012) + * - base64Charset moved to function decodeQuantum (PikerAlpha, November 2012) + * - base64 length check and character checking added (PikerAlpha, November 2012) + * + */ + +#ifdef REVOBOOT_VERSION_INFO + #define STAND_ALONE 0 + #define DEBUG_BASE64_DECODE 0 +#else + #define STAND_ALONE 1 + #define DEBUG_BASE64_DECODE 1 +#endif + +#if STAND_ALONE + #include + #include +#else + #include "libsaio.h" +#endif + +#define FULL_BASE64_DATA_CHECK 0 + +#if DEBUG_BASE64_DECODE + int quickLookups = 0; +#endif + +#define PADDINGCHAR '=' // 61 - 0x3d + +#define TABLELEN 64 + + +//============================================================================== +// Helper function for base64Decode + +bool validBase64Length(char * aDataPtr) +{ + size_t length = (strlen(aDataPtr) - 1); + + if (length && (length % 4)) + { + return true; + } + + return false; +} + + +//============================================================================== +// Helper function for base64Decode + +char *cleanupBase64Data(char *aDataPtr) +{ + int index = 0; +#if DEBUG_BASE64_DECODE + int i = 0; + int junkChars = 0; +#endif + + size_t length = strlen(aDataPtr); + + char *cleanedUpData = malloc(length); + bzero(cleanedUpData, length); + + // Main loop + while (*aDataPtr) + { + /* + * This check acts as a first pass filter. Its purpose is to strip invalid + * characters from the base64 encoded data, but we are mainly using it to + * get rid of the layout enhancement characters (think line feeds and tabs). + */ + if (*aDataPtr > 42 && *aDataPtr < 123) + { +#if FULL_BASE64_DATA_CHECK + /* + * Additional checking is normally not required, but may help people + * getting passed messed up plist data fields (think hand editing). + */ + if (*aDataPtr > 43 && *aDataPtr < 47) // ,-. + { + aDataPtr++; +#if DEBUG_BASE64_DECODE + junkChars++; +#endif + } + else if (*aDataPtr > 57 && *aDataPtr < 65) // :'<=>?@ + { + if (*aDataPtr == PADDINGCHAR) + { + cleanedUpData[index++] = *aDataPtr; +#if DEBUG_BASE64_DECODE + printf("%c", cleanedUpData[length]); +#endif + } + else + { + aDataPtr++; +#if DEBUG_BASE64_DECODE + junkChars++; +#endif + } + } + else if (*aDataPtr > 90 && *aDataPtr < 97) // [\]^_` + { + aDataPtr++; +#if DEBUG_BASE64_DECODE + junkChars++; +#endif + } + else + { +#endif + cleanedUpData[index++] = *aDataPtr; +#if DEBUG_BASE64_DECODE + printf("%c", cleanedUpData[index]); +#endif +#if FULL_BASE64_DATA_CHECK + } +#endif + } +#if DEBUG_BASE64_DECODE + else + { + junkChars++; + } +#endif + aDataPtr++; + } + + cleanedUpData[index] = 0; + +#if DEBUG_BASE64_DECODE + printf("\njunkChars : %d\n", junkChars); + + length = strlen(cleanedUpData); + + for (i = 0; i < length; i++) + { + printf("%c", cleanedUpData[i]); + } +#endif + + return cleanedUpData; +} + + +//============================================================================== +// Helper function for base64Decode + +void decodeQuantum(char *input, unsigned char *output) +{ + int i = 0; + int j = 0; +#if DEBUG_BASE64_DECODE + int found = 0; +#endif + + unsigned int x = 0; // We use a 32 bit wide variable for our bit shifting. + const char * base64Charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + for (i = 0; i < 4; i++) + { + if (input[i] == PADDINGCHAR) + { + x = (x << 6); +#if DEBUG_BASE64_DECODE + found++; +#endif + } + else if (input[(i - 1)] == input[i]) // Same character as last one? + { +#if DEBUG_BASE64_DECODE + found++; + quickLookups++; +#endif + x = (x << 6) + j; + } + else // Dig for next valid target character. + { + for (j = 0; j < TABLELEN; j++) + { + if (base64Charset[j] == input[i]) + { + x = (x << 6) + j; +#if DEBUG_BASE64_DECODE + found++; +#endif + break; + } + } + } + } +#if DEBUG_BASE64_DECODE + if (found < 4) + { + printf("ERROR "); + } +#endif + + output[2] = x; + output[1] = (x >>= 8); + output[0] = (x >>= 8); +} + + +//============================================================================== + +int base64Decode(char *input, unsigned char **decodedData) +{ + size_t bytes = 0; + + unsigned char *buffer = NULL; + + input = cleanupBase64Data(input); + + if (validBase64Length(input)) + { + int numQuantums = (strlen(input) / 4); + + if (numQuantums) + { +#if DEBUG_BASE64_DECODE + printf("\nnumQuantums : %d\n\n", numQuantums); +#endif + buffer = (unsigned char *)malloc(numQuantums * 3); + + if (buffer) + { + int i = 0; + + *decodedData = buffer; + + while (bytes < (numQuantums / 3)) + { + for (i = 0; i < numQuantums; i++) + { + decodeQuantum(input, buffer); +#if DEBUG_BASE64_DECODE + printf("%2ld : %02x %02x %02x\n", (bytes / 3), *buffer++, *buffer++, *buffer++); +#else + buffer += 3; +#endif + input += 4; + bytes += 3; + } + } + } + } + } +#if DEBUG_BASE64_DECODE + else + { + printf("\nError: Invalid length of base64 data!\n"); + } +#endif + + return bytes; +} + + +#if STAND_ALONE +//============================================================================== + +#include "efi/essentials.h" + +void convertEFIGUIDToString(EFI_GUID const *aGuid, char **aUUIDString) +{ + // Do we need to allocate memory? + if (*aUUIDString == NULL) + { + // 1 2 3 + // 123456789 123456789 123456789 123456 + // 00000000-0000-0000-0000-000000000000 + *aUUIDString = (char *)malloc(36); + } + + if (*aUUIDString) + { + bzero(*aUUIDString, 36); + sprintf(*aUUIDString, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", + aGuid->Data1, /* - */ + aGuid->Data2, /* - */ + aGuid->Data3, /* - */ + aGuid->Data4[0], aGuid->Data4[1], /* - */ + aGuid->Data4[2], aGuid->Data4[3], + aGuid->Data4[4], aGuid->Data4[5], + aGuid->Data4[6], aGuid->Data4[7]); + } +} + + +//============================================================================== + +#if USE_DEVICE_PATH +void *getUUIDFromDevicePath(EFI_DEVICE_PATH_PROTOCOL *devicePath) +#else +void *getUUIDFromDevicePath(EFI_GUID *aGUID) +#endif +{ + char * uuid = NULL; + +#if USE_DEVICE_PATH + if (devicePath != NULL) + { + while (!IsDevicePathEndType(devicePath) && + !(DevicePathType(devicePath) == MEDIA_DEVICE_PATH && DevicePathSubType(devicePath) == MEDIA_HARDDRIVE_DP)) + { + devicePath = NextDevicePathNode(devicePath); + } + + if (DevicePathType(devicePath) == MEDIA_DEVICE_PATH && DevicePathSubType(devicePath) == MEDIA_HARDDRIVE_DP) + { + HARDDRIVE_DEVICE_PATH * HDDevicePath = (HARDDRIVE_DEVICE_PATH *) devicePath; + + if (HDDevicePath->SignatureType == SIGNATURE_TYPE_GUID) // 0x02 + { + EFI_GUID * aGUID = (EFI_GUID*)HDDevicePath->Signature; + + convertEFIGUIDToString(aGUID, &uuid); + } + } + } +#else + convertEFIGUIDToString(aGUID, &uuid); +#endif + + return uuid; +} + + +//============================================================================== +// Used in RevoBoot/i386/boot2/boot.c + +char * getStartupDiskUUID(char * aDataPtr) +{ + char * startupDiskUUID = NULL; + + unsigned char * decodedData = NULL; + + int rc = base64Decode(aDataPtr, &decodedData); + + if ((rc == 75) && (decodedData != NULL)) + { +#if USE_DEVICE_PATH + EFI_DEVICE_PATH_PROTOCOL * dp = (EFI_DEVICE_PATH_PROTOCOL *) decodedData; + + startupDiskUUID = getUUIDFromDevicePath(dp); +#else + EFI_GUID * guid = (EFI_GUID *) (decodedData + 52); + + convertEFIGUIDToString(guid, &startupDiskUUID); +#endif + } + + free(decodedData); + + return startupDiskUUID; +} + +//============================================================================== + +int main(void) +{ + // Test example: DE91E8DA-30B6-4B11-B8DC-76DC067BB57A (taken from a Macmini) + + char * input = " AgEMANBBAwoAAAAAAQEGAAIfA\n\r\t\ + xIKAAIAAAAAAAQBKgACAAAAKE\n\v\ + AGAAAAAABASyklAAAAANrokd6\n\ + 2MBFLuNx23AZ7tXoCAn//BAA="; + + // 02 01 0c 00 d0 41 03 0a 00 00 00 00 + // 01 01 06 00 02 1f + // 03 12 0a 00 02 00 00 00 00 00 + // 04 01 2a 00 02 00 00 00 28 40 06 00 00 00 00 00 40 4b 29 25 00 00 00 00 da e8 91 de b6 30 11 4b b8 dc 76 dc 06 7b b5 7a 02 02 + // 7f ff 04 00 + + // 02 01 0c 00 d0 41 03 0a 00 00 00 00 + // 01 01 06 00 00 19 + // 03 0b 25 00 c8 2a 14 01 02 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + // 03 0c 13 00 00 00 00 00 c0 a8 c0 01 00 00 00 00 00 00 00 + // 7f ff 04 00 + // + // c8 2a 14 01 02 03 = Mac Address (example) + // c0 a8 c0 01 = IP address 192.168.192.1 (example) + + char * uuid = getStartupDiskUUID(input); + + if (uuid) + { +#if DEBUG_BASE64_DECODE + printf("\nUUID: %s\n", uuid); +#endif + } + + exit(0); +} +#endif // #if STAND_ALONE diff --git a/i386/libsaio/bios.h b/i386/libsaio/bios.h index 0a0c927..ff49ad5 100755 --- a/i386/libsaio/bios.h +++ b/i386/libsaio/bios.h @@ -32,7 +32,7 @@ typedef union { - unsigned int rx; + unsigned int rx; unsigned short rr; struct @@ -87,13 +87,13 @@ typedef struct #define EBIOS_LOCKING_ACCESS 0x02 #define EBIOS_ENHANCED_DRIVE_INFO 0x04 -#define BASE_HD_DRIVE 0x80 +#define BASE_HD_DRIVE 0x80 /* - * Used in saio_types.h and in StringTable.c (function loadSystemConfig). + * Used in saio_types.h and in StringTable.c (function loadCABootPlist). */ -#define IO_CONFIG_DATA_SIZE 4096 +#define IO_CONFIG_DATA_SIZE 4096 /* diff --git a/i386/libsaio/biosfn.c b/i386/libsaio/biosfn.c index 32a5c82..3da65e9 100755 --- a/i386/libsaio/biosfn.c +++ b/i386/libsaio/biosfn.c @@ -51,8 +51,8 @@ static biosBuf_t bb; int fastEnableA20(void) { - bb.intno = 0x15; - bb.eax.rx = 0x2401; + bb.intno = 0x15; + bb.eax.rx = 0x2401; bios(&bb); // If successful: CF clear, AH = 00h. On error: CF set, AH = status @@ -72,8 +72,8 @@ int bgetc(void) */ while(!readKeyboardStatus()); - bb.intno = 0x16; - bb.eax.r.h = 0x00; + bb.intno = 0x16; + bb.eax.r.h = 0x00; bios(&bb); return bb.eax.rr; @@ -150,7 +150,9 @@ unsigned long getMemoryMap(MemoryRange * rangeArray, unsigned long maxRangeCount // printf("Get memory map 0x%x, %d\n", rangeArray); // getchar(); if (maxRangeCount > (BIOS_LEN / sizeof(MemoryRange))) + { maxRangeCount = (BIOS_LEN / sizeof(MemoryRange)); + } bb.ebx.rx = 0; // Initial continuation value must be zero. @@ -160,14 +162,13 @@ unsigned long getMemoryMap(MemoryRange * rangeArray, unsigned long maxRangeCount bb.eax.rx = 0xe820; bb.ecx.rx = kDescriptorSizeMin; bb.edx.rx = kMemoryMapSignature; - bb.edi.rr = NORMALIZED_OFFSET( (unsigned long) range ); - bb.es = NORMALIZED_SEGMENT( (unsigned long) range ); + bb.edi.rr = NORMALIZED_OFFSET( (unsigned long) range); + bb.es = NORMALIZED_SEGMENT( (unsigned long) range); bios(&bb); // Check for errors. - if ( bb.flags.cf || bb.eax.rx != kMemoryMapSignature - || bb.ecx.rx != kDescriptorSizeMin ) + if (bb.flags.cf || bb.eax.rx != kMemoryMapSignature || bb.ecx.rx != kDescriptorSizeMin) { //printf("Got an error %x %x %x\n", bb.flags.cf, // bb.eax.rx, bb.ecx.rx); @@ -176,16 +177,19 @@ unsigned long getMemoryMap(MemoryRange * rangeArray, unsigned long maxRangeCount // Tally up the conventional/extended memory sizes. - if (range->type == kMemoryRangeUsable || range->type == kMemoryRangeACPI || - range->type == kMemoryRangeNVS ) + if (range->type == kMemoryRangeUsable || range->type == kMemoryRangeACPI || range->type == kMemoryRangeNVS) { // Tally the conventional memory ranges. if (range->base + range->length <= 0xa0000) + { conMemSize += range->length; + } // Record the top of extended memory. if (range->base >= EXTENDED_ADDR) + { extMemSize += range->length; + } } range++; @@ -193,13 +197,15 @@ unsigned long getMemoryMap(MemoryRange * rangeArray, unsigned long maxRangeCount // Is this the last address range? - if ( bb.ebx.rx == 0 ) { + if (bb.ebx.rx == 0) + { //printf("last range\n"); break; } } - *conMemSizePtr = conMemSize / 1024; // size in KB - *extMemSizePtr = extMemSize / 1024; // size in KB + + *conMemSizePtr = (conMemSize / 1024); // size in KB + *extMemSizePtr = (extMemSize / 1024); // size in KB // Copy out data bcopy((char *)BIOS_ADDR, rangeArray, ((char *)range - (char *)BIOS_ADDR)); @@ -339,7 +345,7 @@ int biosread(int dev, int cyl, int head, int sec, int num) bb.intno = 0x13; sec += 1; // sector numbers start at 1. - for (i=0;;) + for (i = 0; ;) { bb.ecx.r.h = cyl; bb.ecx.r.l = ((cyl & 0x300) >> 2) | (sec & 0x3F); @@ -430,11 +436,11 @@ int ebiosread(int dev, unsigned long long sec, int count) void putc(int ch) { - bb.intno = 0x10; - bb.ebx.r.h = 0x00; /* background black */ - bb.ebx.r.l = 0x0F; /* foreground white */ - bb.eax.r.h = 0x0e; - bb.eax.r.l = ch; + bb.intno = 0x10; + bb.ebx.r.h = 0x00; /* background black */ + bb.ebx.r.l = 0x0F; /* foreground white */ + bb.eax.r.h = 0x0e; + bb.eax.r.l = ch; bios(&bb); } @@ -516,9 +522,10 @@ int is_no_emulation(int drive) int get_drive_info(int drive, struct driveInfo *dp) { - boot_drive_info_t *di = &dp->di; int ret = 0; + boot_drive_info_t *di = &dp->di; + #if UNUSED if (maxhd == 0) { @@ -528,11 +535,15 @@ int get_drive_info(int drive, struct driveInfo *dp) bios(&bb); if (bb.flags.cf == 0) + { maxhd = 0x7f + bb.edx.r.l; + } }; if (drive > maxhd) + { return 0; + } #endif bzero(dp, sizeof(struct driveInfo)); @@ -549,18 +560,21 @@ int get_drive_info(int drive, struct driveInfo *dp) bios(&bb); if ((bb.ebx.rr == 0xaa55) && (bb.flags.cf == 0)) + { dp->uses_ebios = bb.ecx.r.l; // Get flags for supported operations. + } if (dp->uses_ebios & (EBIOS_ENHANCED_DRIVE_INFO | EBIOS_LOCKING_ACCESS | EBIOS_FIXED_DISK_ACCESS)) { // Get EBIOS drive info. static struct drive_params params; params.buf_size = sizeof(params); - bb.intno = 0x13; - bb.eax.r.h = 0x48; - bb.edx.r.l = drive; - bb.esi.rr = NORMALIZED_OFFSET((unsigned)¶ms); - bb.ds = NORMALIZED_SEGMENT((unsigned)¶ms); + + bb.intno = 0x13; + bb.eax.r.h = 0x48; + bb.edx.r.l = drive; + bb.esi.rr = NORMALIZED_OFFSET((unsigned)¶ms); + bb.ds = NORMALIZED_SEGMENT((unsigned)¶ms); bios(&bb); if (bb.flags.cf != 0 /* || params.phys_sectors < 2097152 */) @@ -600,7 +614,9 @@ int get_drive_info(int drive, struct driveInfo *dp) #endif if (ret == 0) + { dp->valid = 1; + } return ret; } @@ -610,8 +626,11 @@ int get_drive_info(int drive, struct driveInfo *dp) void sleep(int n) { - unsigned int endtime = (time18() + 18*n); - while (time18() < endtime); + if (n < 60) + { + unsigned int endtime = (time18() + (18*n)); + while (time18() < endtime); + } } @@ -619,10 +638,20 @@ void sleep(int n) void delay(int ms) { - bb.intno = 0x15; - bb.eax.r.h = 0x86; - bb.ecx.rr = ms >> 16; - bb.edx.rr = ms & 0xFFFF; + bb.intno = 0x15; + bb.eax.r.h = 0x86; + bb.ecx.rr = ms >> 16; + bb.edx.rr = ms & 0xFFFF; bios(&bb); } + +//============================================================================== + +void setCursorType(int type) +{ + bb.intno = 0x10; + bb.eax.r.h = 0x01; + bb.ecx.rr = type; + bios(&bb); +} diff --git a/i386/libsaio/bootstruct.c b/i386/libsaio/bootstruct.c index 664d33d..7d05a14 100755 --- a/i386/libsaio/bootstruct.c +++ b/i386/libsaio/bootstruct.c @@ -34,13 +34,18 @@ PrivateBootInfo_t *bootInfo; //============================================================================== -// Called from: boot() (common_boot() in Chameleon) in boot.c +// Called from function initPlatform in platform.c void initKernelBootConfig(void) { - bootArgs = (kernel_boot_args *)malloc(sizeof(boot_args)); + bootArgs = (kernel_boot_args *)malloc(sizeof(kernel_boot_args)); bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t)); + if (sizeof(kernel_boot_args) != sizeof(boot_args)) + { + printf("Warning: sizeof(%d != %d)\n", sizeof(kernel_boot_args), sizeof(boot_args)); + } + if (bootArgs == 0 || bootInfo == 0) { stop("Couldn't allocate boot info\n"); @@ -49,15 +54,15 @@ void initKernelBootConfig(void) bzero(bootArgs, sizeof(boot_args)); bzero(bootInfo, sizeof(PrivateBootInfo_t)); - // Set the default kernel name to: 'mach_kernel'. - strcpy(bootInfo->bootFile, kDefaultKernel); + // Set kernel name to: '/System/Library/Kernels/kernel' for 10.10 and greater + // and 'mach_kernel' for all previous versions of OS X. + // strcpy(bootInfo->bootFile, kDefaultKernel); + sprintf(bootInfo->bootFile, "%s", kDefaultKernel); // Get system memory map. Also update the size of the // conventional/extended memory for backwards compatibility. - bootInfo->memoryMapCount = getMemoryMap(bootInfo->memoryMap, kMemoryMapCountMax, - (unsigned long *) &bootInfo->convmem, - (unsigned long *) &bootInfo->extmem); + bootInfo->memoryMapCount = getMemoryMap(bootInfo->memoryMap, kMemoryMapCountMax, (unsigned long *) &bootInfo->convmem, (unsigned long *) &bootInfo->extmem); if (bootInfo->memoryMapCount == 0) { @@ -70,8 +75,9 @@ void initKernelBootConfig(void) bootInfo->configEnd = bootInfo->config; - bootArgs->Video.v_display = VGA_TEXT_MODE; - + bootArgs->Video_V1.v_display = VGA_TEXT_MODE; + // bootArgs->Video_V2.v_display = VGA_TEXT_MODE; + // What Lion species is screaming here? if ((gPlatform.OSType & LION) == LION) { @@ -87,10 +93,74 @@ void initKernelBootConfig(void) // EFI selection is based on the CPU type. bootArgs->efiMode = (gPlatform.ArchCPUType == CPU_TYPE_X86_64) ? kBootArgsEfiMode64 : kBootArgsEfiMode32; -#if ((MAKE_TARGET_OS & LION) == LION) +#if ((MAKE_TARGET_OS & LION) == LION) // El Capitan, Yosemite, Mavericks and Mountain Lion also have bit 1 set like Lion. // Lion's new debug output (replacing a couple of former boot arguments). bootArgs->debugMode = EFI_DEBUG_MODE; // Defined in config/settings.h #endif + +#if ((MAKE_TARGET_OS & LION) == LION) // El Capitan, Yosemite, Mavericks and Mountain Lion also have bit 1 set like Lion. + // Adding a 16 KB log space. + bootArgs->performanceDataSize = 0; + bootArgs->performanceDataStart = 0; + + // AppleKeyStore.kext + bootArgs->keyStoreDataSize = 0; + bootArgs->keyStoreDataStart = 0; + + bootArgs->bootMemSize = 0; + bootArgs->bootMemStart = 0; + +#if ((MAKE_TARGET_OS & MOUNTAIN_LION) == MOUNTAIN_LION) + bootArgs->flags = 0; + +#if REBOOT_ON_PANIC + bootArgs- >flags |= kBootArgsFlagRebootOnPanic; +#endif + +#if UISCALE_2X + bootArgs->flags |= kBootArgsFlagHiDPI; +#endif + +#if BLACKMODE + bootArgs->flags |= kBootArgsFlagBlackTheme; +#endif + +#endif // #if ((MAKE_TARGET_OS & MOUNTAIN_LION) == MOUNTAIN_LION) + +#if ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN) // El Capitan, Sierra and High Sierra. + // csr_init() checks for: kBootArgsFlagCSRActiveConfig and kBootArgsFlagCSRConfigMode + // csr_get_active_config() checks for: kBootArgsFlagCSRActiveConfig + // csr_check(csr_config_t mask) checks for: kBootArgsFlagCSRConfigMode + bootArgs->flags |= (kBootArgsFlagCSRActiveConfig + kBootArgsFlagCSRConfigMode + kBootArgsFlagCSRBoot + kBootArgsFlagInstallUI); + + bootArgs->csrActiveConfig = CSR_ALWAYS_ENFORCED_FLAGS; + + bootArgs->csrCapabilities = CSR_VALID_CAPABILITIES; + + bootArgs->boot_SMC_plimit = 0; + + bootArgs->bootProgressMeterStart = 0; + bootArgs->bootProgressMeterEnd = 0; // 1024; + +/* enum + { + kProgressMeterMax = 1024, + kProgressMeterEnd = 512, + }; + + if (bootArgs->flags & kBootArgsFlagInstallUI) + { + // Values from 0 to 1024 + vc_progress_meter_start = (bootargs->bootProgressMeterStart * kProgressMeterMax) / 65535; + vc_progress_meter_end = (bootargs->bootProgressMeterEnd * kProgressMeterMax) / 65535; + + bootArgs->bootProgressMeterStart = 0; + bootArgs->bootProgressMeterEnd = 1024; + } */ + +#endif + bootArgs->kslide = 0; +#endif // #if ((MAKE_TARGET_OS & LION) == LION) } @@ -171,21 +241,31 @@ void finalizeKernelBootConfig(void) bootArgs->deviceTreeP = (uint32_t)addr; bootArgs->deviceTreeLength = size; -#if ((MAKE_TARGET_OS & LION) == LION) +#if ((MAKE_TARGET_OS & LION) == LION) // All OS versions greater than Lion have bit 1 set. // Adding a 16 KB log space. bootArgs->performanceDataSize = 0; bootArgs->performanceDataStart = 0; // AppleKeyStore.kext - bootArgs->keyStoreDataSize = 0; - bootArgs->keyStoreDataStart = 0; + bootArgs->keyStoreDataSize = 0; + bootArgs->keyStoreDataStart = 0; - bootArgs->bootMemSize = 0; - bootArgs->bootMemStart = 0; + bootArgs->bootMemSize = 0; + bootArgs->bootMemStart = 0; + + bootArgs->kslide = 0; #endif - -#if ((MAKE_TARGET_OS & LION) == LION) - bootArgs->FSBFrequency = gPlatform.CPU.FSBFrequency; + +/* #if (((MAKE_TARGET_OS & MOUNTAIN_LION) == MOUNTAIN_LION) && (BLACKMODE == 1)) + // + // Note: Hides the white progressbar and efi://chosen/IOProgressBackbuffer is missing. + // + bootArgs->flags |= kBootArgsFlagBlack; +#endif */ + +#if ((MAKE_TARGET_OS & LION) == LION) // El Capitan, Yosemite, Mavericks and Mountain Lion also have bit 1 set like Lion. + bootArgs->PhysicalMemorySize = gPlatform.RAM.MemorySize; + bootArgs->FSBFrequency = gPlatform.CPU.FSBFrequency; #endif } diff --git a/i386/libsaio/bootstruct.h b/i386/libsaio/bootstruct.h index 282a674..3281cb9 100755 --- a/i386/libsaio/bootstruct.h +++ b/i386/libsaio/bootstruct.h @@ -20,6 +20,13 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ + * + * Updates: + * + * - Yosemite support added (Pike R. Alpha, June 2014). + * - El Capitan support added (Pike R. Alpha, June 2015). + * - Sierra support added (Pike R. Alpha, August 2016). + * - High Sierra support added (Pike R. Alpha, June 2017). */ #ifndef __BOOTSTRUCT_H @@ -30,7 +37,131 @@ #include "bios.h" #include "platform.h" -#define kDefaultKernel "mach_kernel" +/* + * Video information (from boot.h) + */ + +struct Boot_Video_V1 +{ + uint32_t v_baseAddr; // Base address (32-bit) of video memory. + uint32_t v_display; // Display Code (if Applicable). + uint32_t v_rowBytes; // Number of bytes per pixel row. + uint32_t v_width; // Width. + uint32_t v_height; // Height. + uint32_t v_depth; // Pixel Depth. +}; +typedef struct Boot_Video_V1 Boot_Video_V1; + +struct Boot_Video_V2 +{ + uint32_t v_display; // Display Code (if Applicable). + uint32_t v_rowBytes; // Number of bytes per pixel row. + uint32_t v_width; // Width. + uint32_t v_height; // Height. + uint32_t v_depth; // Pixel Depth. + uint32_t v_resv[7]; // Reserved. + uint64_t v_baseAddr; // Base address (64-bit) of video memory. +}; +typedef struct Boot_Video_V2 Boot_Video_V2; + + +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // El Capitan and Yosemite + #define kDefaultKernel "kernel" +#else + #define kDefaultKernel "mach_kernel" +#endif + +// Bitfields for boot_args->flags +#ifndef kBootArgsFlagRebootOnPanic + #define kBootArgsFlagRebootOnPanic (1 << 0) // 1 +#endif + +#ifndef kBootArgsFlagHiDPI + #define kBootArgsFlagHiDPI (1 << 1) // 2 +#endif + +#ifndef kBootArgsFlagBlack + #define kBootArgsFlagBlack (1 << 2) // 4 (Boot without the white progressbar) +#endif + +#ifndef kBootArgsFlagCSRActiveConfig + #define kBootArgsFlagCSRActiveConfig (1 << 3) // 8 +#endif + +#ifndef kBootArgsFlagCSRConfigMode + #define kBootArgsFlagCSRConfigMode (1 << 4) // 16 +#endif + +#ifndef kBootArgsFlagCSRBoot + #define kBootArgsFlagCSRBoot (1 << 5) // 32 +#endif + +/* #define kBootArgsFlagBlackBg (1 << 6) */ + +#ifndef kBootArgsFlagBlackTheme + #define kBootArgsFlagBlackTheme (1 << 6) // 64 + // Selects the white progressbar (xnu/osfmk/console/video_console.c) +#endif + +#ifndef kBootArgsFlagLoginUI + #define kBootArgsFlagLoginUI (1 << 7) // 128 + // Selects the white progressbar (xnu/osfmk/console/video_console.c) +#endif + +#ifndef kBootArgsFlagInstallUI + #define kBootArgsFlagInstallUI (1 << 8) // 256 +#endif + +#ifndef kBootArgsFlagUnknownHS + #define kBootArgsFlagUnknownHS (1 << 9) // 512 (High Sierra only) +#endif + +/* SIP (System Integrity Protection) booter configuration flags */ +#ifndef CSR_VALID_FLAGS + #define CSR_ALLOW_UNTRUSTED_KEXTS (1 << 0) // 1 + #define CSR_ALLOW_UNRESTRICTED_FS (1 << 1) // 2 + #define CSR_ALLOW_TASK_FOR_PID (1 << 2) // 4 + #define CSR_ALLOW_KERNEL_DEBUGGER (1 << 3) // 8 + #define CSR_ALLOW_APPLE_INTERNAL (1 << 4) // 16 + #define CSR_ALLOW_UNRESTRICTED_DTRACE (1 << 5) // 32 + #define CSR_ALLOW_UNRESTRICTED_NVRAM (1 << 6) // 64 + #define CSR_ALLOW_DEVICE_CONFIGURATION (1 << 7) // 128 + #define CSR_ALLOW_ANY_RECOVERY_OS (1 << 8) // 256 + #define CSR_ALLOW_UNAPPROVED_KEXTS (1 << 9) // 512 (High Sierra only) + + #if ((MAKE_TARGET_OS & HIGH_SIERRA) == HIGH_SIERRA) + #define CSR_VALID_FLAGS (CSR_ALLOW_UNTRUSTED_KEXTS | \ + CSR_ALLOW_UNRESTRICTED_FS | \ + CSR_ALLOW_TASK_FOR_PID | \ + CSR_ALLOW_KERNEL_DEBUGGER | \ + CSR_ALLOW_APPLE_INTERNAL | \ + CSR_ALLOW_UNRESTRICTED_DTRACE | \ + CSR_ALLOW_UNRESTRICTED_NVRAM | \ + CSR_ALLOW_DEVICE_CONFIGURATION | \ + CSR_ALLOW_ANY_RECOVERY_OS | \ + CSR_ALLOW_UNAPPROVED_KEXTS) + #else + #define CSR_VALID_FLAGS (CSR_ALLOW_UNTRUSTED_KEXTS | \ + CSR_ALLOW_UNRESTRICTED_FS | \ + CSR_ALLOW_TASK_FOR_PID | \ + CSR_ALLOW_KERNEL_DEBUGGER | \ + CSR_ALLOW_APPLE_INTERNAL | \ + CSR_ALLOW_UNRESTRICTED_DTRACE | \ + CSR_ALLOW_UNRESTRICTED_NVRAM | \ + CSR_ALLOW_DEVICE_CONFIGURATION | \ + CSR_ALLOW_ANY_RECOVERY_OS) + #endif +#endif + +/* Used in csr_check(csr_config_t mask) */ +#define CSR_ALWAYS_ENFORCED_FLAGS (CSR_ALLOW_DEVICE_CONFIGURATION | CSR_ALLOW_ANY_RECOVERY_OS) + +/* CSR capabilities that a booter can give to the system */ +#define CSR_CAPABILITY_UNLIMITED (1 << 0) +#define CSR_CAPABILITY_CONFIG (1 << 1) +#define CSR_CAPABILITY_APPLE_INTERNAL (1 << 2) + +#define CSR_VALID_CAPABILITIES (CSR_CAPABILITY_UNLIMITED | CSR_CAPABILITY_CONFIG | CSR_CAPABILITY_APPLE_INTERNAL) // Snapshot constants with supported version / revision info. #define kBootArgsVersion_SnowLeopard 1 @@ -114,107 +245,127 @@ enum */ typedef struct PrivateBootInfo { - int convmem; // conventional memory - int extmem; // extended memory + int convmem; // conventional memory + int extmem; // extended memory - char bootFile[128]; // kernel file name + char bootFile[128]; // kernel file name - unsigned long memoryMapCount; - MemoryRange memoryMap[kMemoryMapCountMax]; + unsigned long memoryMapCount; + MemoryRange memoryMap[kMemoryMapCountMax]; - PCI_bus_info_t pciInfo; + PCI_bus_info_t pciInfo; - char * configEnd; // pointer to end of config files - char config[CONFIG_SIZE]; + char * configEnd; // pointer to end of config files + char config[CONFIG_SIZE]; - config_file_t bootConfig; // com.apple.Boot.plist + config_file_t bootConfig; // com.apple.Boot.plist - config_file_t smbiosConfig; // smbios.plist + config_file_t smbiosConfig; // smbios.plist #if RAMDISK_SUPPORT - config_file_t ramdiskConfig; // RAMDisk.plist + config_file_t ramdiskConfig; // RAMDisk.plist #endif } PrivateBootInfo_t; extern PrivateBootInfo_t *bootInfo; - typedef struct boot_args_new { - uint16_t Revision; // Revision of boot_args structure. - uint16_t Version; // Version of boot_args structure. + uint16_t Revision; // Revision of boot_args structure. + uint16_t Version; // Version of boot_args structure. -#if ((MAKE_TARGET_OS & LION) == LION) - uint8_t efiMode; // 32 = 32-bit, 64 = 64-bit. +#if ((MAKE_TARGET_OS & LION) == LION) // El Capitan, Yosemite, Mavericks and Mountain Lion also have bit 1 set like Lion. + uint8_t efiMode; // 32 = 32-bit, 64 = 64-bit. - uint8_t debugMode; // Bit field with behavior changes. + uint8_t debugMode; // Bit field with behavior changes. #if ((MAKE_TARGET_OS & MOUNTAIN_LION) == MOUNTAIN_LION) - uint8_t __reserved0; - uint8_t __reserved1; + uint16_t flags; #else - uint8_t __reserved1[2]; + uint8_t __reserved1[2]; #endif #endif - char CommandLine[BOOT_LINE_LENGTH]; // Passed in command line. - - uint32_t MemoryMap; // Physical address of memory map. - uint32_t MemoryMapSize; - uint32_t MemoryMapDescriptorSize; - uint32_t MemoryMapDescriptorVersion; - - Boot_Video Video; // Video Information. - - uint32_t deviceTreeP; // Physical address of flattened device tree. - uint32_t deviceTreeLength; // Length of flattened tree. + char CommandLine[BOOT_LINE_LENGTH]; // Passed in command line. - uint32_t kaddr; // Physical address of beginning of kernel text. - uint32_t ksize; // Size of combined kernel text+data+efi. - - uint32_t efiRuntimeServicesPageStart; // Physical address of defragmented runtime pages. - uint32_t efiRuntimeServicesPageCount; + uint32_t MemoryMap; // Physical address of memory map. + uint32_t MemoryMapSize; + uint32_t MemoryMapDescriptorSize; + uint32_t MemoryMapDescriptorVersion; + + Boot_Video_V1 Video_V1; // Video V1 Information (for backward compatibility). + + uint32_t deviceTreeP; // Physical address of flattened device tree. + uint32_t deviceTreeLength; // Length of flattened tree. + + uint32_t kaddr; // Physical address of beginning of kernel text. + uint32_t ksize; // Size of combined kernel text+data+efi. -#if ((MAKE_TARGET_OS & LION) == LION) - uint64_t efiRuntimeServicesVirtualPageStart; // Virtual address of defragmented runtime pages. + uint32_t efiRuntimeServicesPageStart; // Physical address of defragmented runtime pages. + uint32_t efiRuntimeServicesPageCount; + +#if ((MAKE_TARGET_OS & LION) == LION) // El Capitan, Yosemite, Mavericks and Mountain Lion also have bit 1 set like Lion. + uint64_t efiRuntimeServicesVirtualPageStart; // Virtual address of defragmented runtime pages. #endif - uint32_t efiSystemTable; // Physical address of system table in runtime area. + uint32_t efiSystemTable; // Physical address of system table in runtime area. -#if ((MAKE_TARGET_OS & LION) == LION) - uint32_t __reserved2; +#if ((MAKE_TARGET_OS & LION) == LION) // El Capitan, Yosemite, Mavericks and Mountain Lion also have bit 1 set like Lion. + uint32_t kslide; - uint32_t performanceDataStart; // Physical address of log. - uint32_t performanceDataSize; + uint32_t performanceDataStart; // Physical address of log. + uint32_t performanceDataSize; - uint32_t keyStoreDataStart; // Physical address of key store data. - uint32_t keyStoreDataSize; + uint32_t keyStoreDataStart; // Physical address of key store data. + uint32_t keyStoreDataSize; - uint64_t bootMemStart; // Physical address of interperter boot memory. - uint64_t bootMemSize; + uint64_t bootMemStart; // Physical address of interperter boot memory. + uint64_t bootMemSize; - uint64_t PhysicalMemorySize; - uint64_t FSBFrequency; - -#if ((MAKE_TARGET_OS & MOUNTAIN_LION) == MOUNTAIN_LION) - uint64_t pciConfigSpaceBaseAddress; - uint32_t pciConfigSpaceStartBusNumber; - uint32_t pciConfigSpaceEndBusNumber; - uint32_t __reserved4[730]; + uint64_t PhysicalMemorySize; + uint64_t FSBFrequency; + + uint64_t pciConfigSpaceBaseAddress; + uint32_t pciConfigSpaceStartBusNumber; + uint32_t pciConfigSpaceEndBusNumber; + +#if ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN) // El Capitan and Sierra. + uint32_t csrActiveConfig; + uint32_t csrCapabilities; + uint32_t boot_SMC_plimit; + uint16_t bootProgressMeterStart; + uint16_t bootProgressMeterEnd; +#endif + +#if ((MAKE_TARGET_OS & HIGH_SIERRA) == HIGH_SIERRA) // High Sierra only. + Boot_Video_V2 Video_V2; // Video V2 Information (with a 64-bit v_baseAddr). + + uint32_t apfsDataStart; // Physical address of apfs volume key structure. + uint32_t apfsDataSize; + + uint32_t __reserved4[710]; +#elif ((MAKE_TARGET_OS & SIERRA) == SIERRA) // Sierra only. + Boot_Video_V2 Video_V2; // Video V2 Information (with a 64-bit v_baseAddr). + + uint32_t __reserved4[712]; +#elif ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN) + uint32_t __reserved4[726]; +#elif ((MAKE_TARGET_OS & MOUNTAIN_LION) == MOUNTAIN_LION) + uint32_t __reserved4[730]; #else - uint32_t __reserved4[734]; + uint32_t __reserved4[734]; #endif #else - uint8_t efiMode; // 32 = 32-bit, 64 = 64-bit. + uint8_t efiMode; // 32 = 32-bit, 64 = 64-bit. - uint8_t __reserved1[3]; - uint32_t __reserved2[3]; + uint8_t __reserved1[3]; + uint32_t __reserved2[3]; - uint64_t efiRuntimeServicesVirtualPageStart; // Virtual address of defragmented runtime pages. + uint64_t efiRuntimeServicesVirtualPageStart; // Virtual address of defragmented runtime pages. - uint32_t __reserved3[2]; -#endif + uint32_t __reserved3[2]; +#endif // #if ((MAKE_TARGET_OS & LION) == LION) } kernel_boot_args; kernel_boot_args *bootArgs; diff --git a/i386/libsaio/console.c b/i386/libsaio/console.c index 0d5db5d..ded983b 100755 --- a/i386/libsaio/console.c +++ b/i386/libsaio/console.c @@ -118,7 +118,7 @@ int printf(const char * fmt, ...) va_list ap; va_start(ap, fmt); - if (bootArgs->Video.v_display == VGA_TEXT_MODE) + if (bootArgs->Video_V1.v_display == VGA_TEXT_MODE) { prf(fmt, ap, putchar, 0); } @@ -139,7 +139,7 @@ int verbose(const char * fmt, ...) { va_start(ap, fmt); - if (bootArgs->Video.v_display == VGA_TEXT_MODE) + if (bootArgs->Video_V1.v_display == VGA_TEXT_MODE) { prf(fmt, ap, putchar, 0); } @@ -159,7 +159,7 @@ int error(const char * fmt, ...) gErrors = true; va_start(ap, fmt); - if (bootArgs->Video.v_display == VGA_TEXT_MODE) + if (bootArgs->Video_V1.v_display == VGA_TEXT_MODE) { prf(fmt, ap, putchar, 0); } @@ -179,7 +179,7 @@ void stop(const char * fmt, ...) printf("\n"); va_start(ap, fmt); - if (bootArgs->Video.v_display == VGA_TEXT_MODE) + if (bootArgs->Video_V1.v_display == VGA_TEXT_MODE) { prf(fmt, ap, putchar, 0); } diff --git a/i386/libsaio/cpu.c b/i386/libsaio/cpu.c index a4e3dad..0fb5cd8 100644 --- a/i386/libsaio/cpu.c +++ b/i386/libsaio/cpu.c @@ -1,12 +1,14 @@ /* * Copyright (c) 2009 by Master Chief. * - * Refactoring for Revolution done by DHP in 2010/2011. - * Expanded (requestMaxTurbo added) by DHP in May 2011. - * Simplified by DHP in Juni 2011 (thanks to MC and flAked for the idea). - * Code copied from Intel/dynamic_data.h by DHP in juni 2011. - * New compiler directive (BOOT_TURBO_RATIO) added by Jeroen (June 2011). - * Function checkFlexRatioMSR added by DHP (August 2011). + * Updates: + * - Refactoring for Revolution done by DHP in 2010/2011. + * - Expanded (requestMaxTurbo added) by DHP in May 2011. + * - Simplified by DHP in Juni 2011 (thanks to MC and flAked for the idea). + * - Code copied from Intel/dynamic_data.h by DHP in juni 2011. + * - New compiler directive (BOOT_TURBO_RATIO) added by Jeroen (June 2011). + * - Function checkFlexRatioMSR added by DHP (August 2011). + * - Fixed error: use of undeclared identifier 'NUMBER_OF_TURBO_STATES' (Pike, January 2013). */ @@ -14,6 +16,7 @@ #include "cpu/cpuid.h" #include "cpu/proc_reg.h" + #if INTEL_CORE_TECHNOLOGY #if AUTOMATIC_SSDT_PR_CREATION || DEBUG_CPU_TDP @@ -23,7 +26,7 @@ uint8_t getTDP(void) { uint8_t powerUnit = bitfield32(rdmsr64(MSR_RAPL_POWER_UNIT), 3, 0); - uint32_t powerLimit = bitfield32(rdmsr64(MSR_PKG_RAPL_POWER_LIMIT), 14, 0); + uint32_t powerLimit = bitfield32(rdmsr64(MSR_PKG_POWER_LIMIT), 14, 0); uint8_t tdp = (powerLimit / (1 << powerUnit)); @@ -53,7 +56,7 @@ void initTurboRatios() { // Get turbo ratio(s). uint64_t msr = rdmsr64(MSR_TURBO_RATIO_LIMIT); - + #if AUTOMATIC_SSDT_PR_CREATION || DEBUG_CPU_TURBO_RATIOS // All CPU's have at least two cores (think mobility CPU here). gPlatform.CPU.CoreTurboRatio[0] = bitfield32(msr, 7, 0); @@ -78,6 +81,36 @@ void initTurboRatios() // Westmere-EX support (E7-2820/E7-2830). gPlatform.CPU.CoreTurboRatio[6] = ((msr >> 48) & 0xff); gPlatform.CPU.CoreTurboRatio[7] = ((msr >> 56) & 0xff); +#endif + +#if STATIC_CPU_NumCores >= 10 // 20 threads. + msr = rdmsr64(MSR_TURBO_RATIO_LIMIT_1); + + gPlatform.CPU.CoreTurboRatio[8] = bitfield32(msr, 7, 0); + gPlatform.CPU.CoreTurboRatio[9] = bitfield32(msr, 15, 8); +#endif + +#if STATIC_CPU_NumCores >= 12 // 24 threads. + gPlatform.CPU.CoreTurboRatio[10] = bitfield32(msr, 23, 16); + gPlatform.CPU.CoreTurboRatio[11] = bitfield32(msr, 31, 24); +#endif + +#if STATIC_CPU_NumCores >= 16 // 32 threads. + gPlatform.CPU.CoreTurboRatio[12] = ((msr >> 32) & 0xff); + gPlatform.CPU.CoreTurboRatio[13] = ((msr >> 40) & 0xff); + gPlatform.CPU.CoreTurboRatio[14] = ((msr >> 48) & 0xff); + gPlatform.CPU.CoreTurboRatio[15] = ((msr >> 56) & 0xff); +#endif + +#if STATIC_CPU_NumCores >= 18 // 36 threads. + // Intel® Xeon® Processor E5 v3 Family (0x3F – based on the Haswell-E microarchitecture) + // Intel® Xeon® Processor E7 v2 Family (0x3E – based on the Ivy Bridge-E microarchitecture) + // can check bit-64 to see if the two extra Turbo MSR's are being used or not. + msr = rdmsr64(MSR_TURBO_RATIO_LIMIT_2); + + gPlatform.CPU.CoreTurboRatio[16] = bitfield32(msr, 7, 0); + gPlatform.CPU.CoreTurboRatio[17] = bitfield32(msr, 15, 8); + #endif } @@ -90,10 +123,11 @@ void initTurboRatios() // We need to have something to work with so check for it, and the // way we do that (trying to be smart) supports any number of cores. + uint8_t numberOfCores = gPlatform.CPU.NumCores; + if (gPlatform.CPU.CoreTurboRatio[0] != 0) { uint8_t i, duplicatedRatios = 0; - uint8_t numberOfCores = gPlatform.CPU.NumCores; // Simple check to see if all ratios are the same. for (i = 0; i < numberOfCores; i++) @@ -107,15 +141,20 @@ void initTurboRatios() duplicatedRatios++; } +#ifdef NUMBER_OF_TURBO_STATES + uint8_t numberOfTurboStates = NUMBER_OF_TURBO_STATES; +#else + uint8_t numberOfTurboStates = numberOfCores; +#endif // Should we add only one turbo P-State? if (duplicatedRatios == 0) { - gPlatform.CPU.NumberOfTurboRatios = NUMBER_OF_TURBO_STATES; // Default for AICPUPM. + gPlatform.CPU.NumberOfTurboRatios = numberOfTurboStates; // Default for AICPUPM. } else // Meaning that we found duplicated ratios. { // Do we need to inject one Turbo P-State only? - if (duplicatedRatios == NUMBER_OF_TURBO_STATES) + if (duplicatedRatios == numberOfTurboStates) { // Yes. Wipe the rest (keeping the one with the highest multiplier). for (i = 1; i < numberOfCores; i++) // i set to 1 to preserve the first one. @@ -133,7 +172,7 @@ void initTurboRatios() } // Jeroen: Used in ACPI/ssdt_pr_generator.h / for DEBUG_CPU_TURBO_RATIOS. - gPlatform.CPU.NumberOfTurboRatios = (NUMBER_OF_TURBO_STATES - duplicatedRatios); + gPlatform.CPU.NumberOfTurboRatios = (numberOfTurboStates - duplicatedRatios); /* if (duplicatedRatios == 4) { @@ -187,14 +226,16 @@ void checkFlexRatioMSR(void) // The processor’s maximum non-turbo core frequency is configured during power-on reset // by using its manufacturing default value. This value is the highest non-turbo core // multiplier at which the processor can operate. If lower maximum speeds are desired, - // the appropriate ratio can be configured using the FLEX_RATIO MSR. + // then the appropriate ratio can be configured using the FLEX_RATIO MSR. uint64_t msr = rdmsr64(MSR_FLEX_RATIO); if (msr & bit(16)) // Flex ratio enabled? { uint8_t flexRatio = ((msr >> 8) & 0xff); - +#if DEBUG_CPU + printf("MSR(%x) Flex ratio enabled!\n", MSR_FLEX_RATIO); +#endif // Sanity checks. if (flexRatio < gPlatform.CPU.MinBusRatio || flexRatio > gPlatform.CPU.MaxBusRatio) { @@ -207,23 +248,32 @@ void checkFlexRatioMSR(void) gPlatform.CPU.MaxBusRatio = flexRatio; } } -} +#if DEBUG_CPU + else + { + printf("MSR(%x) Flex ratio NOT Enabled\n", MSR_FLEX_RATIO); + } + + sleep(1); #endif +} +#endif // INTEL_CORE_TECHNOLOGY + #if USE_STATIC_CPU_DATA #if CPU_VENDOR_ID == CPU_VENDOR_INTEL - #include "cpu/intel/static_data.h" + #include "cpu/Intel/static_data.h" #else - #include "cpu/amd/static_data.h" + #include "cpu/AMD/static_data.h" #endif #else #if CPU_VENDOR_ID == CPU_VENDOR_INTEL - #include "cpu/intel/dynamic_data.h" + #include "cpu/Intel/dynamic_data.h" #else - #include "cpu/amd/dynamic_data.h" + #include "cpu/AMD/dynamic_data.h" #endif #endif diff --git a/i386/libsaio/cpu/Intel/dynamic_data.h b/i386/libsaio/cpu/Intel/dynamic_data.h index d8c4c8c..5b80535 100644 --- a/i386/libsaio/cpu/Intel/dynamic_data.h +++ b/i386/libsaio/cpu/Intel/dynamic_data.h @@ -21,92 +21,118 @@ #define DEFAULT_FSB 100000 // Hardcoded to 100MHz #define BASE_NHM_CLOCK_SOURCE 133333333ULL -#define DEBUG_CPU_EXTREME 0 +#define BASE_ART_CLOCK_SOURCE 24000000ULL // 24Mhz //============================================================================== -// DFE: Measures the TSC frequency in Hz (64-bit) using the ACPI PM timer +// Measures TSC frequency using the i8254 Programmable Interval Timer counter 2 static uint64_t getTSCFrequency(void) { - // DFE: This constant comes from older xnu: - #define CLKNUM 1193182 // formerly 1193167 - - // DFE: These two constants come from Linux except CLOCK_TICK_RATE replaced with CLKNUM - #define CALIBRATE_TIME_MSEC 30 - #define CALIBRATE_LATCH ((CLKNUM * CALIBRATE_TIME_MSEC + 1000/2)/1000) - + int i; + + uint64_t retval = 0; uint64_t tscStart; uint64_t tscEnd; uint64_t tscDelta = 0xffffffffffffffffULL; + unsigned long pollCount; - uint64_t retval = 0; - int i; - - /* Time how many TSC ticks elapse in 30 msec using the 8254 PIT - * counter 2. We run this loop 3 times to make sure the cache - * is hot and we take the minimum delta from all of the runs. - * That is to say that we're biased towards measuring the minimum - * number of TSC ticks that occur while waiting for the timer to - * expire. That theoretically helps avoid inconsistencies when - * running under a VM if the TSC is not virtualized and the host - * steals time. The TSC is normally virtualized for VMware. - */ - - for (i = 0; i < 10; ++i) + + if (getCachedCPUID(LEAF_0, eax) > 0x14) // Intel Skylake Processors. { - enable_PIT2(); - set_PIT2_mode0(CALIBRATE_LATCH); - tscStart = rdtsc64(); - pollCount = poll_PIT2_gate(); - tscEnd = rdtsc64(); - /* The poll loop must have run at least a few times for accuracy */ - - if (pollCount <= 1) +#if DEBUG_CPU + printf("LEAF_15[eax]: 0x%x\n", getCachedCPUID(LEAF_15, eax)); // 0x02 (numerator is always 2) + printf("LEAF_15[ebx]: 0x%x\n", getCachedCPUID(LEAF_15, ebx)); // 0x11c (denominator i.e. 284 = 3.4GHz and 334 = 4GHz) + printf("LEAF_15[ecx]: 0x%x\n", getCachedCPUID(LEAF_15, ecx)); // 0x00 (frequency = Intel reserved) + printf("LEAF_15[edx]: 0x%x\n", getCachedCPUID(LEAF_15, edx)); // 0x00 + + printf("LEAF_16[eax]: 0x%x\n", getCachedCPUID(LEAF_16, eax)); // 0xd48 (clock speed i.e. 3408MHz for the i7-6700) + printf("LEAF_16[ebx]: 0x%x\n", getCachedCPUID(LEAF_16, ebx)); // 0xfa0 (maximum turbo clock speed i.e. 4GHz for the i7-6700) + printf("LEAF_16[ecx]: 0x%x\n", getCachedCPUID(LEAF_16, ecx)); // 0x64 (bus speed i.e. 100MHz) + printf("LEAF_16[edx]: 0x%x\n", getCachedCPUID(LEAF_16, edx)); // 0x00 +#endif + // + // Examples: + // + // 24000000 * 284 / 2 = 3408000000 for the Intel i7-6700 @ 3.4GHz + // 24000000 * 334 / 2 = 4008000000 for the Intel i7-6700K @ 4.0GHz + // + return (BASE_ART_CLOCK_SOURCE * getCachedCPUID(LEAF_15, ebx) / getCachedCPUID(LEAF_15, eax)); + } + else + { + // DFE: This constant comes from older xnu: + #define CLKNUM 1193182 // formerly 1193167 + + // DFE: These two constants come from Linux except CLOCK_TICK_RATE replaced with CLKNUM + #define CALIBRATE_TIME_MSEC 30 + #define CALIBRATE_LATCH ((CLKNUM * CALIBRATE_TIME_MSEC + 1000/2)/1000) + + /* Time how many TSC ticks elapse in 30 msec using the 8254 PIT + * counter 2. We run this loop 3 times to make sure the cache + * is hot and we take the minimum delta from all of the runs. + * That is to say that we're biased towards measuring the minimum + * number of TSC ticks that occur while waiting for the timer to + * expire. That theoretically helps avoid inconsistencies when + * running under a VM if the TSC is not virtualized and the host + * steals time. The TSC is normally virtualized for VMware. + */ + + for (i = 0; i < 10; ++i) { - continue; + enable_PIT2(); + set_PIT2_mode0(CALIBRATE_LATCH); + tscStart = rdtsc64(); + pollCount = poll_PIT2_gate(); + tscEnd = rdtsc64(); + /* The poll loop must have run at least a few times for accuracy */ + + if (pollCount <= 1) + { + continue; + } + + /* The TSC must increment at LEAST once every millisecond. We + * should have waited exactly 30 msec so the TSC delta should + * be >= 30. Anything less and the processor is way too slow. + */ + + if ((tscEnd - tscStart) <= CALIBRATE_TIME_MSEC) + { + continue; + } + + // tscDelta = min(tscDelta, (tscEnd - tscStart)) + if ((tscEnd - tscStart) < tscDelta) + { + tscDelta = tscEnd - tscStart; + } } - /* The TSC must increment at LEAST once every millisecond. We - * should have waited exactly 30 msec so the TSC delta should - * be >= 30. Anything less and the processor is way too slow. + /* tscDelta is now the least number of TSC ticks the processor made in + * a timespan of 0.03 s (e.g. 30 milliseconds) + * Linux thus divides by 30 which gives the answer in kiloHertz because + * 1 / ms = kHz. But we're xnu and most of the rest of the code uses + * Hz so we need to convert our milliseconds to seconds. Since we're + * dividing by the milliseconds, we simply multiply by 1000. + */ + + /* Unlike linux, we're not limited to 32-bit, but we do need to take care + * that we're going to multiply by 1000 first so we do need at least some + * arithmetic headroom. For now, 32-bit should be enough. + * Also unlike Linux, our compiler can do 64-bit integer arithmetic. */ - if ((tscEnd - tscStart) <= CALIBRATE_TIME_MSEC) + if (tscDelta > (1ULL << 32)) { - continue; + retval = 0; } - - // tscDelta = min(tscDelta, (tscEnd - tscStart)) - if ((tscEnd - tscStart) < tscDelta) + else { - tscDelta = tscEnd - tscStart; + retval = tscDelta * 1000 / 30; } - } - /* tscDelta is now the least number of TSC ticks the processor made in - * a timespan of 0.03 s (e.g. 30 milliseconds) - * Linux thus divides by 30 which gives the answer in kiloHertz because - * 1 / ms = kHz. But we're xnu and most of the rest of the code uses - * Hz so we need to convert our milliseconds to seconds. Since we're - * dividing by the milliseconds, we simply multiply by 1000. - */ - - /* Unlike linux, we're not limited to 32-bit, but we do need to take care - * that we're going to multiply by 1000 first so we do need at least some - * arithmetic headroom. For now, 32-bit should be enough. - * Also unlike Linux, our compiler can do 64-bit integer arithmetic. - */ - - if (tscDelta > (1ULL << 32)) - { - retval = 0; + disable_PIT2(); } - else - { - retval = tscDelta * 1000 / 30; - } - - disable_PIT2(); return retval; } @@ -162,17 +188,16 @@ unsigned long getQPISpeed(uint64_t aFSBFrequency) void initCPUStruct(void) { - bool SandyBridge = false; - bool IvyBridge = false; + // bool SandyBridge = false; + // bool IvyBridge = false; + uint8_t CoreBridgeType = 0; - uint8_t maxcoef, maxdiv, currcoef, currdiv; + uint8_t maxdiv, currcoef, currdiv; uint32_t qpiSpeed = 0; uint64_t tscFrequency, fsbFrequency, cpuFrequency, msr; - maxcoef = maxdiv = currcoef = currdiv = 0; - // Get and cache CPUID data. do_cpuid( 0x00000000, gPlatform.CPU.ID[LEAF_0]); // Vendor-ID and Largest Standard Function (Function 0h). do_cpuid( 0x00000001, gPlatform.CPU.ID[LEAF_1]); // Feature Information (Function 01h). @@ -186,16 +211,18 @@ void initCPUStruct(void) printf("C-State limit : %d\n", (msr & 7)); - printf("C1-State enabled: %s\n", ((getCachedCPUID(LEAF_5, edx) >> 4) & 0xf) ? "true" : "false"); // C1 - printf("C3-State enabled: %s\n", ((getCachedCPUID(LEAF_5, edx) >> 8) & 0xf) ? "true" : "false"); // C3 - printf("C6-State enabled: %s\n", ((getCachedCPUID(LEAF_5, edx) >> 12) & 0xf) ? "true" : "false"); // C6 - printf("C7-State enabled: %s\n", ((getCachedCPUID(LEAF_5, edx) >> 16) & 0xf) ? "true" : "false"); // C7 - - printf("MWAIT supported : %s\n", (getCachedCPUID(LEAF_5, ecx) & 1) ? "true" : "false"); + printf("Number of C0 sub C-states supported using MWAIT: %d\n", ( getCachedCPUID(LEAF_5, edx) & 0xf)); + printf("Number of C1 sub C-states supported using MWAIT: %d\n", ((getCachedCPUID(LEAF_5, edx) >> 4) & 0xf)); + printf("Number of C2 sub C-states supported using MWAIT: %d\n", ((getCachedCPUID(LEAF_5, edx) >> 8) & 0xf)); + printf("Number of C3 sub C-states supported using MWAIT: %d\n", ((getCachedCPUID(LEAF_5, edx) >> 12) & 0xf)); + printf("Number of C4 sub C-states supported using MWAIT: %d\n", ((getCachedCPUID(LEAF_5, edx) >> 16) & 0xf)); _CPU_DEBUG_SLEEP(5); #endif + do_cpuid(0x00000015, gPlatform.CPU.ID[LEAF_15]); + do_cpuid(0x00000016, gPlatform.CPU.ID[LEAF_16]); + #if DEBUG_TSS_SUPPORT do_cpuid(0x00000006, gPlatform.CPU.ID[LEAF_6]); // Thermal and Power Leaf (Function 06h). @@ -214,6 +241,14 @@ void initCPUStruct(void) if ((getCachedCPUID(LEAF_80, eax) & 0x0000000f) >= 1) { do_cpuid(0x80000001, gPlatform.CPU.ID[LEAF_81]); // Extended Feature Bits (Function 80000001h). + + #if DEBUG_CPU + // Test if the LongMode-bit is set or not. + if ((getCachedCPUID(LEAF_81, edx) & 0x20000000) == 0x20000000) + { + _CPU_DEBUG_DUMP("CPU: LongMode (64-bit) is support\n"); + } + #endif } #if DEBUG_CPU_EXTREME { @@ -301,11 +336,11 @@ void initCPUStruct(void) //-------------------------------------------------------------------------- // Setup features. - gPlatform.CPU.Features |= getCachedCPUID(LEAF_1, ecx); - gPlatform.CPU.Features |= getCachedCPUID(LEAF_1, edx); + // gPlatform.CPU.Features |= getCachedCPUID(LEAF_1, ecx); + // gPlatform.CPU.Features |= getCachedCPUID(LEAF_1, edx); // Add extended features. - gPlatform.CPU.Features |= getCachedCPUID(LEAF_81, ecx); - gPlatform.CPU.Features |= getCachedCPUID(LEAF_81, edx); + // gPlatform.CPU.Features |= getCachedCPUID(LEAF_81, ecx); + // gPlatform.CPU.Features |= getCachedCPUID(LEAF_81, edx); fsbFrequency = 0; cpuFrequency = 0; @@ -322,24 +357,71 @@ void initCPUStruct(void) switch (gPlatform.CPU.Model) { - case CPU_MODEL_SB_CORE: - case CPU_MODEL_SB_JAKETOWN: - SandyBridge = true; - case CPU_MODEL_DALES_32NM: - case CPU_MODEL_WESTMERE: - case CPU_MODEL_WESTMERE_EX: + CoreBridgeType = DALES_BRIDGE; /* * This should be the same as Nehalem but an A0 silicon bug returns * invalid data in the top 12 bits. Hence, we use only bits [19..16] - * rather than [31..16] for core count - which actually can't exceed 8. - */ + * rather than [31..16] for core count - which actually can't exceed 8. + */ + hiBit = 19; + break; + + case CPU_MODEL_SB_CORE: + case CPU_MODEL_SB_JAKETOWN: + CoreBridgeType = SANDY_BRIDGE; + hiBit = 19; + break; + + case CPU_MODEL_WESTMERE: + case CPU_MODEL_WESTMERE_EX: hiBit = 19; break; case CPU_MODEL_IB_CORE: case CPU_MODEL_IB_CORE_EX: - IvyBridge = true; + case CPU_MODEL_IB_CORE_XEON: + CoreBridgeType = IVY_BRIDGE; + hiBit = 31; + break; + + case CPU_MODEL_HASWELL: + case CPU_MODEL_HASWELL_E: + case CPU_MODEL_HASWELL_ULT: + CoreBridgeType = HASWELL; + hiBit = 31; + break; + + case CPU_MODEL_BROADWELL: +// case CPU_MODEL_BROADWELL_ULT: + case CPU_MODEL_BROADWELL_H: + case CPU_MODEL_BRYSTALWELL: + case CPU_MODEL_BROADWELL_E: + case CPU_MODEL_BROADWELL_DE: + CoreBridgeType = BROADWELL; + hiBit = 31; + break; + + case CPU_MODEL_SKYLAKE: +// case CPU_MODEL_SKYLAKE_ULT: +// case CPU_MODEL_SKYLAKE_ULX: + case CPU_MODEL_SKYLAKE_DT: + case CPU_MODEL_SKYLAKE_W: + CoreBridgeType = SKYLAKE; + hiBit = 31; + // gPlatform.CPU.ARTFrequency = (3427489466 * 2 / 284) = 24137249,76056338028169 MHz + // 3427489466 / 34 = 100808513,705882352941176 + // 100808498 * 2 = 201616996 + // 201616996 / 284 = 709919 + // 709919 * 284 = 201616996 / 2 = 100808498 + gPlatform.CPU.ARTFrequency = 0; // BASE_ART_CLOCK_SOURCE; // (tscFrequency * getCachedCPUID(LEAF_x15, eax) / getCachedCPUID(LEAF_x15, ebx)); + break; + + case CPU_MODEL_KABYLAKE: + case CPU_MODEL_KABYLAKE_DT: + CoreBridgeType = KABYLAKE; + hiBit = 31; + break; case CPU_MODEL_NEHALEM: case CPU_MODEL_NEHALEM_EX: @@ -366,15 +448,19 @@ void initCPUStruct(void) // Get 'cpu-type' for our SMBIOS patcher. if (strstr(gPlatform.CPU.BrandString, "Core(TM) i7")) { - gPlatform.CPU.Type = 0x701; // Core i7 + gPlatform.CPU.Type = (0x700 + CoreBridgeType); // Core i7 } else if (strstr(gPlatform.CPU.BrandString, "Core(TM) i5")) { - gPlatform.CPU.Type = 0x601; // Core i5 + gPlatform.CPU.Type = (0x600 + 5); // CoreBridgeType); // Core i5 } else if (strstr(gPlatform.CPU.BrandString, "Core(TM) i3")) { - gPlatform.CPU.Type = 0x901; // Core i3 + gPlatform.CPU.Type = (0x900 + CoreBridgeType); // Core i3 + } + else if (strstr(gPlatform.CPU.BrandString, "Xeon(R)")) + { + gPlatform.CPU.Type = (0xA00 + CoreBridgeType); } msr = rdmsr64(MSR_PLATFORM_INFO); @@ -388,20 +474,23 @@ void initCPUStruct(void) requestMaxTurbo(maxBusRatio); } - if (SandyBridge || IvyBridge) + if (CoreBridgeType) // (SandyBridge || IvyBridge || Haswell || Broadwell || SkyLake || KabyLake) { - gPlatform.CPU.Type |= 0x02; // Note: Use 0x01 here for the new Macmini5,1 (to get cpu-type = 0x602). + // gPlatform.CPU.Type += CoreBridgeType; #if AUTOMATIC_SSDT_PR_CREATION || DEBUG_CPU_TDP gPlatform.CPU.TDP = getTDP(); #endif - qpiSpeed = 0; // No QPI but DMI for Sandy Bridge processors. - - // Disable EIST Hardware coordination (letting AICPUPM.kext handle it). - msr = rdmsr64(MSR_MISC_PWR_MGMT); - wrmsr64(MSR_MISC_PWR_MGMT, msr | 1); + qpiSpeed = 0; // No QPI but DMI for Sandy Bridge and greater processors. + + // Check bit-15 of MSR 0xE2 to see if it is locked. + msr = rdmsr64(MSR_PKG_CST_CONFIG_CONTROL); - checkFlexRatioMSR(); + gPlatform.CPU.CstConfigMsrLocked = (msr & 0x8000); +#if DEBUG_CPU + printf("MSR_PKG_CST_CONFIG_CONTROL(locked): 0x%x\n", msr); +#endif + checkFlexRatioMSR(); } #endif // #if INTEL_CORE_TECHNOLOGY fsbFrequency = ((tscFrequency / maxBusRatio) - OC_BUSRATIO_CORRECTION); @@ -409,6 +498,8 @@ void initCPUStruct(void) } else // For all other (mostly older) Intel CPU models. { + uint8_t maxcoef = maxdiv = currcoef = currdiv = 0; + //-------------------------------------------------------------------------- // Get core and thread count - the old way. @@ -476,7 +567,7 @@ void initCPUStruct(void) } } - if (!fsbFrequency && !SandyBridge && !IvyBridge) + if (!fsbFrequency && !CoreBridgeType) // !SandyBridge && !IvyBridge) { fsbFrequency = (DEFAULT_FSB * 1000); cpuFrequency = tscFrequency; @@ -497,7 +588,7 @@ void initCPUStruct(void) } } -#if DEBUG_CPU +#if (DEBUG_CPU && INTEL_CORE_TECHNOLOGY == 0) gPlatform.CPU.MaxCoef = maxcoef; gPlatform.CPU.MaxDiv = maxdiv; gPlatform.CPU.CurrCoef = currcoef; @@ -511,7 +602,7 @@ void initCPUStruct(void) _CPU_DEBUG_DUMP(" 123456789 123456789 123456789 123456789 12345678\n"); _CPU_DEBUG_DUMP("CPU: Brandstring : %s\n", gPlatform.CPU.BrandString); - _CPU_DEBUG_DUMP("CPU: Vendor/Model/ExtModel : 0x%x/0x%x/0x%x\n", gPlatform.CPU.Vendor, gPlatform.CPU.Model, gPlatform.CPU.ExtModel); + _CPU_DEBUG_DUMP("CPU: Vendor/Model/ExtModel : 0x%x/0x%x/0x%x\n", gPlatform.CPU.Vendor, gPlatform.CPU.Model, gPlatform.CPU.ExtModel); _CPU_DEBUG_DUMP("CPU: Stepping / Signature : 0x%x/0x%x\n", gPlatform.CPU.Stepping, gPlatform.CPU.Signature); _CPU_DEBUG_DUMP("CPU: Family/ExtFamily : 0x%x/0x%x\n", gPlatform.CPU.Family, gPlatform.CPU.ExtFamily); _CPU_DEBUG_DUMP("CPU: Type : 0x%x\n", gPlatform.CPU.Type); @@ -523,7 +614,7 @@ void initCPUStruct(void) _CPU_DEBUG_DUMP("CPU: NumCores/NumThreads : %d/%d\n", gPlatform.CPU.NumCores, gPlatform.CPU.NumThreads); - if (SandyBridge) + if (CoreBridgeType) { _CPU_DEBUG_DUMP("CPU: Min/Max busratio : %d/%d\n", gPlatform.CPU.MinBusRatio, gPlatform.CPU.MaxBusRatio); } diff --git a/i386/libsaio/cpu/Intel/static_data.h b/i386/libsaio/cpu/Intel/static_data.h index 483f4e7..69d28db 100644 --- a/i386/libsaio/cpu/Intel/static_data.h +++ b/i386/libsaio/cpu/Intel/static_data.h @@ -17,7 +17,8 @@ void initCPUStruct(void) { gPlatform.CPU.Vendor = CPU_VENDOR_ID; // Used in ACPI/patcher.h - gPlatform.CPU.Type = STATIC_CPU_Type; // Used in SMBIOS/dynamic_data.h, 'About This Mac' and System Profiler. + gPlatform.CPU.Type = STATIC_CPU_Type; // Used in SMBIOS/dynamic_data.h and ACPI/SSDT_PR + // Affects CPU type in 'About This Mac' and System Profiler. gPlatform.CPU.NumCores = STATIC_CPU_NumCores; // machdep.cpu.cores_per_package - used in: ACPI/ssdt_pm_generator.h gPlatform.CPU.NumThreads = STATIC_CPU_NumThreads; // machdep.cpu.logical_per_package - used in: ACPI/ssdt_pm_generator.h diff --git a/i386/libsaio/cpu/essentials.h b/i386/libsaio/cpu/essentials.h index 1a9cd01..ebc8f03 100755 --- a/i386/libsaio/cpu/essentials.h +++ b/i386/libsaio/cpu/essentials.h @@ -24,9 +24,12 @@ * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ - */ -/* + * * @OSF_COPYRIGHT@ + * + * Updates: + * + * - New Haswell (ULT) specific MSR's added (Pike, April 2013). */ #ifndef __LIBSAIO_CPU_ESSENTIALS_H @@ -50,14 +53,23 @@ // Copied from xnu/osfmk/proc_reg.h #define MSR_IA32_PLATFORM_ID 0x17 #define MSR_CORE_THREAD_COUNT 0x35 -#define MSR_PLATFORM_INFO 0xCE + +#ifndef MSR_PLATFORM_INFO + #define MSR_PLATFORM_INFO 0xCE +#endif + #define MSR_PKG_CST_CONFIG_CONTROL 0xE2 // MSR_PKG_CST_CONFIG_CONTROL #define MSR_PMG_IO_CAPTURE_BASE 0xE4 +#define IA32_MPERF 0xE7 +#define IA32_APERF 0xE8 #define MSR_IA32_PERF_STATUS 0x0198 // MSR_IA32_PERF_STS in XNU #define MSR_IA32_PERF_CONTROL 0x0199 // IA32_PERF_CTL -#define MSR_FLEX_RATIO 0x0194 +#ifndef MSR_FLEX_RATIO + #define MSR_FLEX_RATIO 0x0194 +#endif + #define IA32_CLOCK_MODULATION 0x019A #define IA32_THERM_STATUS 0x019C @@ -65,19 +77,59 @@ #define MSR_TEMPERATURE_TARGET 0x01A2 #define MSR_MISC_PWR_MGMT 0x01AA #define MSR_TURBO_RATIO_LIMIT 0x01AD +#define MSR_TURBO_RATIO_LIMIT_1 0x01AE +#define MSR_TURBO_RATIO_LIMIT_2 0x01AF #define IA32_ENERGY_PERF_BIAS 0x01B0 #define IA32_PLATFORM_DCA_CAP 0x01F8 +#define MSR_POWER_CTL 0x01FC + +#define MSR_PKGC3_IRTL 0x60A +#define MSR_PKGC6_IRTL 0x60B +#define MSR_PKGC7_IRTL 0x60C + +#define MSR_PKG_C2_RESIDENCY 0x60D +#define MSR_PKG_C3_RESIDENCY 0x3F8 +#define MSR_PKG_C6_RESIDENCY 0x3F9 +#define MSR_PKG_C7_RESIDENCY 0x3FA + +#define MSR_CORE_C3_RESIDENCY 0x3FC +#define MSR_CORE_C6_RESIDENCY 0x3FD +#define MSR_CORE_C7_RESIDENCY 0x3FE +#define MSR_PP0_CURRENT_CONFIG 0x601 +#define MSR_PP1_CURRENT_CONFIG 0x602 // Sandy Bridge & JakeTown specific 'Running Average Power Limit' MSR's. #define MSR_RAPL_POWER_UNIT 0x606 -#define MSR_PKG_RAPL_POWER_LIMIT 0x610 +#define MSR_PKG_POWER_LIMIT 0x610 #define MSR_PKG_ENERGY_STATUS 0x611 #define MSR_PKG_PERF_STATUS 0x613 #define MSR_PKG_POWER_INFO 0x614 +// JakeTown only Memory MSR's. +#define MSR_DRAM_POWER_LIMIT 0x618 +#define MSR_DRAM_ENERGY_STATUS 0x619 +#define MSR_DRAM_PERF_STATUS 0x61B +#define MSR_DRAM_POWER_INFO 0x61C + +// Haswell-ULT Package residency +#define MSR_PKG_C8_RESIDENCY 0x630 +#define MSR_PKG_C9_RESIDENCY 0x631 +#define MSR_PKG_C10_RESIDENCY 0x632 + +// Haswell-ULT C state latency control. +#define MSR_PKG_C8_LATENCY 0x633 +#define MSR_PKG_C9_LATENCY 0x634 +#define MSR_PKG_C10_LATENCY 0x635 + +// Haswell-ULT VR configurations. +#define VR_MISC_CONFIG2 0x636 + +// Haswell-ULT Alternate BCLK in deep Package C states. +#define MSR_COUNTER_24_MHZ 0x637 + // Sandy Bridge IA (Core) domain MSR's. #define MSR_PP0_POWER_LIMIT 0x638 #define MSR_PP0_ENERGY_STATUS 0x639 @@ -89,27 +141,28 @@ #define MSR_PP1_ENERGY_STATUS 0x641 #define MSR_PP1_POLICY 0x642 -// JakeTown only Memory MSR's. -#define MSR_DRAM_POWER_LIMIT 0x618 -#define MSR_DRAM_ENERGY_STATUS 0x619 -#define MSR_DRAM_PERF_STATUS 0x61B -#define MSR_DRAM_POWER_INFO 0x61C - +// Ivy Bridge Specific MSR's +#define MSR_CONFIG_TDP_NOMINAL 0x648 +#define MSR_CONFIG_TDP_LEVEL1 0x649 +#define MSR_CONFIG_TDP_LEVEL2 0x64A +#define MSR_CONFIG_TDP_CONTROL 0x64B +#define MSR_TURBO_ACTIVATION_RATIO 0x64C // CPUID leaf index values (pointing to the right spot in CPUID/LEAF array). -#define LEAF_0 0 // DHP: Formerly known as CPUID_n +#define LEAF_0 0 // Basic CPUID Information #define LEAF_1 1 #define LEAF_2 2 -#define LEAF_4 3 -#define LEAF_5 4 -#define LEAF_6 5 -#define LEAF_B 6 -#define LEAF_80 7 -#define LEAF_81 8 - -#define MAX_CPUID_LEAVES 9 // DHP: Formerly known as MAX_CPUID +#define LEAF_4 3 // Deterministic Cache Parameters Leaf +#define LEAF_5 4 // MONITOR/MWAIT Leaf +#define LEAF_6 5 // Thermal and Power Management Leaf +#define LEAF_B 6 // Extended Topology Enumeration Leaf +#define LEAF_15 7 // Time Stamp Counter/Core Crystal Clock Information-leaf +#define LEAF_16 8 // Processor Frequency Information Leaf +#define LEAF_80 9 // Extended Function CPUID Information +#define LEAF_81 10 +#define MAX_CPUID_LEAVES 11 // DHP: Formerly known as MAX_CPUID /* Copied from: xnu/osfmk/i386/cpuid.h */ #define CPU_MODEL_YONAH 0x0E @@ -122,10 +175,45 @@ #define CPU_MODEL_DALES_32NM 0x25 // Clarkdale, Arrandale #define CPU_MODEL_SB_CORE 0x2A // Sandy Bridge Core Processors (LGA 1155) #define CPU_MODEL_WESTMERE 0x2C // Gulftown, Westmere-EP, Westmere-WS -#define CPU_MODEL_SB_JAKETOWN 0x2D // Sandy Bridge Xeon Processors (LGA 2011) +#define CPU_MODEL_SB_JAKETOWN 0x2D // Sandy Bridge-EP, Sandy Bridge Xeon Processors (LGA 2011) #define CPU_MODEL_NEHALEM_EX 0x2E #define CPU_MODEL_WESTMERE_EX 0x2F #define CPU_MODEL_IB_CORE 0x3A // Ivy Bridge Core Processors (LGA 1155) #define CPU_MODEL_IB_CORE_EX 0x3B // Ivy Bridge Core Processors (LGA 2011) +#define CPU_MODEL_IB_CORE_XEON 0x3E + +#define CPU_MODEL_HASWELL 0x3C +#define CPU_MODEL_HASWELL_E 0x3F +#define CPU_MODEL_HASWELL_ULT 0x45 +#define CPU_MODEL_CRYSTALWELL 0x46 + +#define CPU_MODEL_BROADWELL 0x3D +#define CPU_MODEL_BROADWELL_ULX 0x3D +#define CPU_MODEL_BROADWELL_ULT 0x3D +#define CPU_MODEL_BROADWELL_H 0x47 +#define CPU_MODEL_BRYSTALWELL 0x4C +#define CPU_MODEL_BROADWELL_E 0x4F +#define CPU_MODEL_BROADWELL_DE 0x56 + +#define CPU_MODEL_SKYLAKE 0x4E +#define CPU_MODEL_SKYLAKE_ULT 0x4E +#define CPU_MODEL_SKYLAKE_ULX 0x4E +#define CPU_MODEL_SKYLAKE_DT 0x5E +#define CPU_MODEL_SKYLAKE_W 0x55 + +#define CPU_MODEL_KABYLAKE 0x8E +#define CPU_MODEL_KABYLAKE_ULT 0x8E +#define CPU_MODEL_KABYLAKE_ULX 0x8E +#define CPU_MODEL_KABYLAKE_DT 0x9E + +#define CPU_MODEL_CANNONLAKE 0x66 + +#define DALES_BRIDGE 1 +#define SANDY_BRIDGE 2 +#define IVY_BRIDGE 4 +#define HASWELL 8 +#define BROADWELL 16 +#define SKYLAKE 32 +#define KABYLAKE 64 #endif /* !__LIBSAIO_CPU_ESSENTIALS_H */ diff --git a/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo.xcodeproj/project.pbxproj b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..64dbaed --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo.xcodeproj/project.pbxproj @@ -0,0 +1,303 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 5600B62D138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5600B62C138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.h */; }; + 5600B62F138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5600B62E138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 5600B620138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AppleIntelCPUPowerManagementInfo.kext; sourceTree = BUILT_PRODUCTS_DIR; }; + 5600B624138A9BC80001A2BC /* Kernel.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Kernel.framework; path = System/Library/Frameworks/Kernel.framework; sourceTree = SDKROOT; }; + 5600B627138A9BC80001A2BC /* Info-AppleIntelCPUPowerManagementInfo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-AppleIntelCPUPowerManagementInfo.plist"; sourceTree = ""; }; + 5600B62B138A9BC80001A2BC /* InfoPlist.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = InfoPlist.strings; sourceTree = ""; }; + 5600B62C138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleIntelCPUPowerManagementInfo.h; sourceTree = ""; }; + 5600B62E138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AppleIntelCPUPowerManagementInfo.cpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 5600B61B138A9BC80001A2BC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 5600B613138A9BC80001A2BC = { + isa = PBXGroup; + children = ( + 5600B625138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo */, + 5600B621138A9BC80001A2BC /* Products */, + 5600B624138A9BC80001A2BC /* Kernel.framework */, + ); + sourceTree = ""; + }; + 5600B621138A9BC80001A2BC /* Products */ = { + isa = PBXGroup; + children = ( + 5600B620138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.kext */, + ); + name = Products; + sourceTree = ""; + }; + 5600B625138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo */ = { + isa = PBXGroup; + children = ( + 9015B9A516DCCD8700FCE81D /* Headers */, + 9015B9A416DCCD7800FCE81D /* Source */, + 5600B626138A9BC80001A2BC /* Resources */, + ); + name = AppleIntelCPUPowerManagementInfo; + path = AppleIntelCPUPowerManagementInfo; + sourceTree = ""; + }; + 5600B626138A9BC80001A2BC /* Resources */ = { + isa = PBXGroup; + children = ( + 5600B627138A9BC80001A2BC /* Info-AppleIntelCPUPowerManagementInfo.plist */, + 5600B62B138A9BC80001A2BC /* InfoPlist.strings */, + ); + name = Resources; + sourceTree = ""; + }; + 9015B9A416DCCD7800FCE81D /* Source */ = { + isa = PBXGroup; + children = ( + 5600B62E138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.cpp */, + ); + name = Source; + sourceTree = ""; + }; + 9015B9A516DCCD8700FCE81D /* Headers */ = { + isa = PBXGroup; + children = ( + 5600B62C138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.h */, + ); + name = Headers; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 5600B61C138A9BC80001A2BC /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 5600B62D138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 5600B61F138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5600B632138A9BC80001A2BC /* Build configuration list for PBXNativeTarget "AppleIntelCPUPowerManagementInfo" */; + buildPhases = ( + 5600B61A138A9BC80001A2BC /* Sources */, + 5600B61B138A9BC80001A2BC /* Frameworks */, + 5600B61C138A9BC80001A2BC /* Headers */, + 5600B61D138A9BC80001A2BC /* Resources */, + 5600B61E138A9BC80001A2BC /* Rez */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AppleIntelCPUPowerManagementInfo; + productName = AppleIntelCPUPowerManagementInfo; + productReference = 5600B620138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.kext */; + productType = "com.apple.product-type.kernel-extension"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 5600B615138A9BC80001A2BC /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0460; + }; + buildConfigurationList = 5600B618138A9BC80001A2BC /* Build configuration list for PBXProject "AppleIntelCPUPowerManagementInfo" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 5600B613138A9BC80001A2BC; + productRefGroup = 5600B621138A9BC80001A2BC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 5600B61F138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 5600B61D138A9BC80001A2BC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXRezBuildPhase section */ + 5600B61E138A9BC80001A2BC /* Rez */ = { + isa = PBXRezBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXRezBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 5600B61A138A9BC80001A2BC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5600B62F138A9BC80001A2BC /* AppleIntelCPUPowerManagementInfo.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 5600B630138A9BC80001A2BC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALTERNATE_GROUP = wheel; + ALTERNATE_OWNER = root; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = NO; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; + GCC_OPTIMIZATION_LEVEL = s; + GCC_PREPROCESSOR_DEFINITIONS = DEBUG; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INSTALL_GROUP = wheel; + INSTALL_OWNER = root; + MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + VALID_ARCHS = x86_64; + }; + name = Debug; + }; + 5600B631138A9BC80001A2BC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALTERNATE_GROUP = wheel; + ALTERNATE_OWNER = root; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = NO; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INSTALL_GROUP = wheel; + INSTALL_OWNER = root; + MACOSX_DEPLOYMENT_TARGET = 10.8; + SDKROOT = macosx; + VALID_ARCHS = x86_64; + }; + name = Release; + }; + 5600B633138A9BC80001A2BC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALTERNATE_GROUP = wheel; + ALTERNATE_OWNER = root; + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1.0.0d1; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + GCC_VERSION = ""; + INFOPLIST_FILE = "AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist"; + MODULE_NAME = com.apple.kext.AppleIntelCPUPowerManagementInfo; + MODULE_VERSION = 1.0.0d1; + PRODUCT_NAME = AppleIntelCPUPowerManagementInfo; + VALID_ARCHS = x86_64; + VERSION_INFO_BUILDER = root; + WRAPPER_EXTENSION = kext; + }; + name = Debug; + }; + 5600B634138A9BC80001A2BC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALTERNATE_GROUP = wheel; + ALTERNATE_OWNER = root; + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = 1.0.0d1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + GCC_VERSION = ""; + INFOPLIST_FILE = "AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist"; + MODULE_NAME = com.apple.kext.AppleIntelCPUPowerManagementInfo; + MODULE_VERSION = 1.0.0d1; + PRODUCT_NAME = AppleIntelCPUPowerManagementInfo; + VALID_ARCHS = x86_64; + VERSION_INFO_BUILDER = root; + WRAPPER_EXTENSION = kext; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 5600B618138A9BC80001A2BC /* Build configuration list for PBXProject "AppleIntelCPUPowerManagementInfo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5600B630138A9BC80001A2BC /* Debug */, + 5600B631138A9BC80001A2BC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5600B632138A9BC80001A2BC /* Build configuration list for PBXNativeTarget "AppleIntelCPUPowerManagementInfo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5600B633138A9BC80001A2BC /* Debug */, + 5600B634138A9BC80001A2BC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 5600B615138A9BC80001A2BC /* Project object */; +} diff --git a/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp new file mode 100644 index 0000000..41ae48a --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp @@ -0,0 +1,584 @@ +/* + * Copyright (c) 2012-2014 Pike R. Alpha. All rights reserved. + * + * Original idea and initial development of MSRDumper.kext (c) 2011 by RevoGirl. + * + * Thanks to George for his help and continuation of Sam's work, but it is + * time for us to push the envelope and add some really interesting stuff. + * + */ + +#include "AppleIntelCPUPowerManagementInfo.h" + + +//============================================================================== + +void AppleIntelCPUPowerManagementInfo::reportMSRs(UInt8 aCPUModel) +{ + IOLog("AICPUPMI: MSR_CORE_THREAD_COUNT......(0x35) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_CORE_THREAD_COUNT)); + + IOLog("AICPUPMI: MSR_PLATFORM_INFO..........(0xCE) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PLATFORM_INFO)); + + IOLog("AICPUPMI: MSR_PMG_CST_CONFIG_CONTROL.(0xE2) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_CST_CONFIG_CONTROL)); + IOLog("AICPUPMI: MSR_PMG_IO_CAPTURE_BASE....(0xE4) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PMG_IO_CAPTURE_BASE)); + IOLog("AICPUPMI: IA32_MPERF.................(0xE7) : 0x%llX\n", (unsigned long long)rdmsr64(IA32_MPERF)); + IOLog("AICPUPMI: IA32_APERF.................(0xE8) : 0x%llX\n", (unsigned long long)rdmsr64(IA32_APERF)); + + IOLog("AICPUPMI: MSR_FLEX_RATIO.............(0x194) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_FLEX_RATIO)); + IOLog("AICPUPMI: MSR_IA32_PERF_STATUS.......(0x198) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_IA32_PERF_STATUS)); + IOLog("AICPUPMI: MSR_IA32_PERF_CONTROL......(0x199) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_IA32_PERF_CONTROL)); + IOLog("AICPUPMI: IA32_CLOCK_MODULATION......(0x19A) : 0x%llX\n", (unsigned long long)rdmsr64(IA32_CLOCK_MODULATION)); + IOLog("AICPUPMI: IA32_THERM_STATUS..........(0x19C) : 0x%llX\n", (unsigned long long)rdmsr64(IA32_THERM_STATUS)); + + IOLog("AICPUPMI: IA32_MISC_ENABLES..........(0x1A0) : 0x%llX\n", (unsigned long long)rdmsr64(IA32_MISC_ENABLES)); + IOLog("AICPUPMI: MSR_MISC_PWR_MGMT..........(0x1AA) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_MISC_PWR_MGMT)); + IOLog("AICPUPMI: MSR_TURBO_RATIO_LIMIT......(0x1AD) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_TURBO_RATIO_LIMIT)); + + IOLog("AICPUPMI: IA32_ENERGY_PERF_BIAS......(0x1B0) : 0x%llX\n", (unsigned long long)rdmsr64(IA32_ENERGY_PERF_BIAS)); + + IOLog("AICPUPMI: MSR_POWER_CTL..............(0x1FC) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_POWER_CTL)); + + IOLog("AICPUPMI: MSR_RAPL_POWER_UNIT........(0x606) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_RAPL_POWER_UNIT)); + IOLog("AICPUPMI: MSR_PKG_POWER_LIMIT........(0x610) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_POWER_LIMIT)); + IOLog("AICPUPMI: MSR_PKG_ENERGY_STATUS......(0x611) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_ENERGY_STATUS)); + + IOLog("AICPUPMI: MSR_PKGC3_IRTL.............(0x60a) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKGC3_IRTL)); + IOLog("AICPUPMI: MSR_PKGC6_IRTL.............(0x60b) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKGC6_IRTL)); + + if (gCheckC7) + { + IOLog("AICPUPMI: MSR_PKGC7_IRTL.............(0x60c) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKGC7_IRTL)); + } + + IOLog("AICPUPMI: MSR_PP0_CURRENT_CONFIG.....(0x601) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PP0_CURRENT_CONFIG)); + IOLog("AICPUPMI: MSR_PP0_POWER_LIMIT........(0x638) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PP0_POWER_LIMIT)); + IOLog("AICPUPMI: MSR_PP0_ENERGY_STATUS......(0x639) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PP0_ENERGY_STATUS)); + IOLog("AICPUPMI: MSR_PP0_POLICY.............(0x63a) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PP0_POLICY)); + +#if REPORT_IGPU_P_STATES + if (igpuEnabled) + { + switch (aCPUModel) + { + case CPU_MODEL_SB_CORE: // 0x2A - Intel 325462.pdf Vol.3C 35-120 + case CPU_MODEL_IB_CORE: // 0x3A - Intel 325462.pdf Vol.3C 35-125 (Referring to Table 35-13) + IOLog("AICPUPMI: MSR_PP1_CURRENT_CONFIG.....(0x602) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PP1_CURRENT_CONFIG)); + + case CPU_MODEL_HASWELL: // 0x3C - Intel 325462.pdf Vol.3C 35-140 + case CPU_MODEL_HASWELL_ULT: // 0x45 - Intel 325462.pdf Vol.3C 35-140 + case CPU_MODEL_CRYSTALWELL: // 0x46 - Intel 325462.pdf Vol.3C 35-140 + + IOLog("AICPUPMI: MSR_PP1_POWER_LIMIT........(0x640) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PP1_POWER_LIMIT)); + IOLog("AICPUPMI: MSR_PP1_ENERGY_STATUS......(0x641) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PP1_ENERGY_STATUS)); + IOLog("AICPUPMI: MSR_PP1_POLICY.............(0x642) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PP1_POLICY)); + break; + } + } +#endif + + switch (aCPUModel) + { + case CPU_MODEL_IB_CORE: // 0x3A - Intel 325462.pdf Vol.3C 35-126 + case CPU_MODEL_IB_CORE_EX: // 0x3B - Intel 325462.pdf Vol.3C 35-126 + // case CPU_MODEL_IB_CORE_XEON: // 0x3E - Intel 325462.pdf Vol.3C 35-126 + case CPU_MODEL_HASWELL: // 0x3C - Intel 325462.pdf Vol.3C 35-133 + case CPU_MODEL_HASWELL_ULT: // 0x45 - Intel 325462.pdf Vol.3C 35-133 + case CPU_MODEL_CRYSTALWELL: // 0x46 - Intel 325462.pdf Vol.3C 35-133 + + IOLog("AICPUPMI: MSR_CONFIG_TDP_NOMINAL.....(0x648) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_CONFIG_TDP_NOMINAL)); + IOLog("AICPUPMI: MSR_CONFIG_TDP_LEVEL1......(0x649) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_CONFIG_TDP_LEVEL1)); + IOLog("AICPUPMI: MSR_CONFIG_TDP_LEVEL2......(0x64a) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_CONFIG_TDP_LEVEL2)); + IOLog("AICPUPMI: MSR_CONFIG_TDP_CONTROL.....(0x64b) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_CONFIG_TDP_CONTROL)); + IOLog("AICPUPMI: MSR_TURBO_ACTIVATION_RATIO.(0x64c) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_TURBO_ACTIVATION_RATIO)); + break; + } + + IOLog("AICPUPMI: MSR_PKG_C2_RESIDENCY.......(0x60d) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C2_RESIDENCY)); + IOLog("AICPUPMI: MSR_PKG_C3_RESIDENCY.......(0x3f8) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C3_RESIDENCY)); + IOLog("AICPUPMI: MSR_PKG_C6_RESIDENCY.......(0x3f9) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C6_RESIDENCY)); + + if (gCheckC7) + { + IOLog("AICPUPMI: MSR_PKG_C7_RESIDENCY.......(0x3fa) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C7_RESIDENCY)); + } + + if (aCPUModel == CPU_MODEL_HASWELL_ULT) // 0x45 - Intel 325462.pdf Vol.3C 35-136 + { + IOLog("AICPUPMI: MSR_PKG_C8_RESIDENCY.......(0x630) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C8_RESIDENCY)); + IOLog("AICPUPMI: MSR_PKG_C9_RESIDENCY.......(0x631) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C9_RESIDENCY)); + IOLog("AICPUPMI: MSR_PKG_C10_RESIDENCY......(0x632) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C10_RESIDENCY)); + + IOLog("AICPUPMI: MSR_PKG_C8_LATENCY.........(0x633) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C8_RESIDENCY)); + IOLog("AICPUPMI: MSR_PKG_C9_LATENCY.........(0x634) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C9_RESIDENCY)); + IOLog("AICPUPMI: MSR_PKG_C10_LATENCY........(0x635) : 0x%llX\n", (unsigned long long)rdmsr64(MSR_PKG_C10_RESIDENCY)); + } +} + +//============================================================================== + +inline void getCStates(void *magic) +{ + UInt32 logicalCoreNumber = cpu_number(); + + if (gCheckC3 && rdmsr64(MSR_CORE_C3_RESIDENCY) > 0) + { + gC3Cores |= (1 << logicalCoreNumber); + } + + if (gCheckC6 && rdmsr64(MSR_CORE_C6_RESIDENCY) > 0) + { + gC6Cores |= (1 << logicalCoreNumber); + } + + if (gCheckC7 && rdmsr64(MSR_CORE_C7_RESIDENCY) > 0) + { + gC7Cores |= (1 << logicalCoreNumber); + } +} + +//============================================================================== + +IOReturn AppleIntelCPUPowerManagementInfo::loopTimerEvent(void) +{ + UInt8 currentMultiplier = (rdmsr64(MSR_IA32_PERF_STS) >> 8); + gCoreMultipliers |= (1ULL << currentMultiplier); + +#if REPORT_IGPU_P_STATES + UInt8 currentIgpuMultiplier = 0; + + if (igpuEnabled) + { + currentIgpuMultiplier = (UInt8)gMchbar[1]; + gIGPUMultipliers |= (1ULL << currentIgpuMultiplier); + } +#endif + + timerEventSource->setTimeoutTicks(Interval); + + if (loopLock) + { + return kIOReturnTimeout; + } + + loopLock = true; + +#if REPORT_IPG_STYLE + if (logIPGStyle) + { + UInt64 mPerf = (rdmsr64(IA32_MPERF)); + UInt64 aPerf = (rdmsr64(IA32_APERF)); + wrmsr64(IA32_MPERF, 0ULL); + wrmsr64(IA32_APERF, 0ULL); +// UInt16 busy = ((aPerf * 100) / mPerf); + float busy = ((aPerf * 100) / mPerf); + UInt8 pState = (UInt8)(((gClockRatio + 0.5) * busy) / 100); + +/* if (pState != currentMultiplier) + { */ + gCoreMultipliers |= (1ULL << pState); + + if ((pState < currentMultiplier) && (pState < 8)) + { + pState = 8; + } + /* + * Commented out after fabio67 (fabiosun) confirmed that + * the wrmsr() below triggered a KP on his configuration + * wrmsr64(199, (pState << 8)); + */ + // } + } +#endif + +#if REPORT_C_STATES + if (logCStates) + { + UInt32 magic = 0; + mp_rendezvous_no_intrs(getCStates, &magic); + IOSleep(1); + } +#endif + + int currentBit = 0; + UInt64 value = 0ULL; + +#if REPORT_IGPU_P_STATES + if ((gCoreMultipliers != gTriggeredPStates) || (gIGPUMultipliers != gTriggeredIGPUPStates)) +#else + #if REPORT_IPG_STYLE + if ((gCoreMultipliers != gTriggeredPStates) || (currentMultiplier != pState)) + #else + if (gCoreMultipliers != gTriggeredPStates) + #endif +#endif + { + gTriggeredPStates = gCoreMultipliers; + IOLog("AICPUPMI: CPU P-States [ "); + + for (currentBit = gMinRatio; currentBit <= gMaxRatio; currentBit++) + { + value = (1ULL << currentBit); + + if ((gTriggeredPStates & value) == value) + { + if (currentBit == currentMultiplier) + { + IOLog("(%d) ", currentBit); + } + else + { + IOLog("%d ", currentBit); + } + } + } + +#if REPORT_IGPU_P_STATES + if (igpuEnabled) + { + gTriggeredIGPUPStates = gIGPUMultipliers; + IOLog("] iGPU P-States [ "); + + for (currentBit = 1; currentBit <= 32; currentBit++) + { + value = (1ULL << currentBit); + + if ((gTriggeredIGPUPStates & value) == value) + { + if (currentBit == currentIgpuMultiplier) + { + IOLog("(%d) ", currentBit); + } + else + { + IOLog("%d ", currentBit); + } + } + } + } +#endif + IOLog("]\n"); + } + +#if REPORT_C_STATES + if (gCheckC3 && (gTriggeredC3Cores != gC3Cores)) + { + gTriggeredC3Cores = gC3Cores; + IOLog("AICPUPMI: CPU C3-Cores [ "); + + for (currentBit = 0; currentBit <= 16; currentBit++) + { + value = (1ULL << currentBit); + + if ((gTriggeredC3Cores & value) == value) + { + IOLog("%d ", currentBit); + } + } + + IOLog("]\n"); + } + + if (gCheckC6 && (gTriggeredC6Cores != gC6Cores)) + { + gTriggeredC6Cores = gC6Cores; + IOLog("AICPUPMI: CPU C6-Cores [ "); + + for (currentBit = 0; currentBit <= 16; currentBit++) + { + value = (1ULL << currentBit); + + if ((gTriggeredC6Cores & value) == value) + { + IOLog("%d ", currentBit); + } + } + + IOLog("]\n"); + } + + if (gCheckC7 && (gTriggeredC7Cores != gC7Cores)) + { + gTriggeredC7Cores = gC7Cores; + IOLog("AICPUPMI: CPU C7-Cores [ "); + + for (currentBit = 0; currentBit <= 16; currentBit++) + { + value = (1ULL << currentBit); + + if ((gTriggeredC7Cores & value) == value) + { + IOLog("%d ", currentBit); + } + } + + IOLog("]\n"); + } +#endif + + loopLock = false; + + return kIOReturnSuccess; +} + +//============================================================================== + +IOService* AppleIntelCPUPowerManagementInfo::probe(IOService *provider, SInt32 *score) +{ + IOService *ret = super::probe(provider, score); + + if (ret != this) + { + return 0; + } + + return ret; +} + +//============================================================================== + +bool AppleIntelCPUPowerManagementInfo::start(IOService *provider) +{ + if (IOService::start(provider)) + { + simpleLock = IOSimpleLockAlloc(); + + if (simpleLock) + { + IOLog("AICPUPMI: v%s Copyright © 2012-2014 Pike R. Alpha. All rights reserved\n", VERSION); +#if REPORT_MSRS + OSBoolean * key_logMSRs = OSDynamicCast(OSBoolean, getProperty("logMSRs")); + + if (key_logMSRs) + { + logMSRs = (bool)key_logMSRs->getValue(); + } + + IOLog("AICPUPMI: logMSRs............................: %d\n", logMSRs); +#endif + +#if REPORT_IGPU_P_STATES + OSBoolean * key_logIGPU = OSDynamicCast(OSBoolean, getProperty("logIGPU")); + + if (key_logIGPU) + { + igpuEnabled = (bool)key_logIGPU->getValue(); + } + + if (igpuEnabled) + { + if ((READ_PCI8_NB(DEVEN) & DEVEN_D2EN_MASK) == 0) // Is the IGPU enabled and visible? + { + igpuEnabled = false; + } + } + + IOLog("AICPUPMI: logIGPU............................: %d\n", igpuEnabled); +#endif + +#if REPORT_C_STATES + OSBoolean * key_logCStates = OSDynamicCast(OSBoolean, getProperty("logCStates")); + + if (key_logCStates) + { + logCStates = (bool)key_logCStates->getValue(); + } + + IOLog("AICPUPMI: logCStates.........................: %d\n", logCStates); +#endif + +#if REPORT_IPG_STYLE + OSBoolean * key_logIPGStyle = OSDynamicCast(OSBoolean, getProperty("logIPGStyle")); + + if (key_logIPGStyle) + { + logIPGStyle = (bool)key_logIPGStyle->getValue(); + } + + IOLog("AICPUPMI: logIPGStyle........................: %d\n", logIPGStyle); +#endif + UInt64 msr = rdmsr64(MSR_PLATFORM_INFO); + gClockRatio = (UInt8)((msr >> 8) & 0xff); + + timerEventSource = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &AppleIntelCPUPowerManagementInfo::loopTimerEvent)); + workLoop = getWorkLoop(); + + if (timerEventSource && workLoop && (kIOReturnSuccess == workLoop->addEventSource(timerEventSource))) + { + this->registerService(0); + + msr = rdmsr64(MSR_IA32_PERF_STS); + gCoreMultipliers |= (1ULL << (msr >> 8)); + + uint32_t cpuid_reg[4]; + do_cpuid(0x00000001, cpuid_reg); + + UInt8 cpuModel = bitfield32(cpuid_reg[eax], 7, 4) + (bitfield32(cpuid_reg[eax], 19, 16) << 4); + +#if REPORT_C_STATES + switch (cpuModel) // TODO: Verify me! + { + case CPU_MODEL_SB_CORE: // 0x2A - Intel 325462.pdf Vol.3C 35-111 + case CPU_MODEL_SB_JAKETOWN: // 0x2D - Intel 325462.pdf Vol.3C 35-111 + case CPU_MODEL_IB_CORE: // 0x3A - Intel 325462.pdf Vol.3C 35-125 (Refering to Table 35-12) + case CPU_MODEL_IB_CORE_EX: // 0x3B - Intel 325462.pdf Vol.3C 35-125 (Refering to Table 35-12) + // No C7 support for Intel® Xeon® Processor E5-1600 v2/E5-2600 v2 (Product Families Datasheet Volume One of Two page 19) + // case CPU_MODEL_IB_CORE_XEON: // 0x3E - Intel 325462.pdf Vol.3C 35-125 (Refering to Table 35-12) + case CPU_MODEL_HASWELL: // 0x3C - Intel 325462.pdf Vol.3C 35-136 + case CPU_MODEL_HASWELL_ULT: // 0x45 - Intel 325462.pdf Vol.3C 35-136 + case CPU_MODEL_CRYSTALWELL: // 0x46 + + gCheckC7 = true; + break; + } +#endif + +#if REPORT_MSRS + // MWAIT information + do_cpuid(0x00000005, cpuid_reg); + uint32_t supportedMwaitCStates = bitfield32(cpuid_reg[edx], 31, 0); + + IOLog("AICPUPMI: MWAIT C-States.....................: %d\n", supportedMwaitCStates); + + if (logMSRs) + { + reportMSRs(cpuModel); + } +#endif + msr = rdmsr64(MSR_PLATFORM_INFO); + gMinRatio = (UInt8)((msr >> 40) & 0xff); + IOLog("AICPUPMI: CPU Low Frequency Mode.............: %d00 MHz\n", gMinRatio); + + gClockRatio = (UInt8)((msr >> 8) & 0xff); + IOLog("AICPUPMI: CPU Maximum non-Turbo Frequency....: %d00 MHz\n", gClockRatio); + + if (!((rdmsr64(IA32_MISC_ENABLES) >> 32) & 0x40)) // Turbo Mode Enabled? + { + msr = rdmsr64(MSR_TURBO_RATIO_LIMIT); + gMaxRatio = (UInt8)(msr & 0xff); + IOLog("AICPUPMI: CPU Maximum Turbo Frequency........: %d00 MHz\n", gMaxRatio); + } + else + { + gMaxRatio = gClockRatio; + IOLog("AICPUPMI: CPU Maximum Frequency..............: %d00 MHz\n", gMaxRatio); + } + +#if REPORT_IGPU_P_STATES + if (igpuEnabled) + { + IOPhysicalAddress address = (IOPhysicalAddress)(0xFED10000 + 0x5948); + memDescriptor = IOMemoryDescriptor::withPhysicalAddress(address, 0x53, kIODirectionInOut); + + if (memDescriptor != NULL) + { + if ((result = memDescriptor->prepare()) == kIOReturnSuccess) + { + memoryMap = memDescriptor->map(); + + if (memoryMap != NULL) + { + gMchbar = (UInt8 *)memoryMap->getVirtualAddress(); + + // Preventing a stupid (UEFI) BIOS limit. + if (gMchbar[0x4C] < gMchbar[0x50]) + { + gMchbar[0x4C] = gMchbar[0x50]; + } + + // + // Examples IGPU multiplier: 17 (multiplier) * 50 (frequency in MHz) = 850 MHz + // 22 (multiplier) * 50 (frequency in MHz) = 1100 MHz + // 6 P-States: 850, 900, 950, 1000, 1050 and 1100 MHz + // + // Current RP-State, when the graphics engine is in RC6, this reflects the last used ratio. + IOLog("AICPUPMI: IGPU Current Frequency.............: %4d MHz\n", IGPU_RATIO_TO_FREQUENCY((UInt8)gMchbar[0x01])); // RP_STATE_RATIO (CURRENT_FREQUENCY) + // Maximum RPN base frequency capability for the Integrated GFX Engine (GT). + IOLog("AICPUPMI: IGPU Minimum Frequency.............: %4d MHz\n", IGPU_RATIO_TO_FREQUENCY((UInt8)gMchbar[0x52])); // RPN_CAP (MIN_FREQUENCY) + // Maximum RP1 base frequency capability for the Integrated GFX Engine (GT). + IOLog("AICPUPMI: IGPU Maximum Non-Turbo Frequency...: %4d MHz\n", IGPU_RATIO_TO_FREQUENCY((UInt8)gMchbar[0x51])); // RP1_CAP (MAX_NON_TURBO) + // Maximum RP0 base frequency capability for the Integrated GFX Engine (GT). + IOLog("AICPUPMI: IGPU Maximum Turbo Frequency.......: %4d MHz\n", IGPU_RATIO_TO_FREQUENCY((UInt8)gMchbar[0x50])); // RP0_CAP (MAX_TURBO)) + + // Maximum base frequency limit for the Integrated GFX Engine (GT) allowed during run-time. + if (gMchbar[0x4C] == 255) + { + IOLog("AICPUPMI: IGPU Maximum limit.................: No Limit\n"); // RPSTT_LIM + } + else + { + IOLog("AICPUPMI: IGPU Maximum limit.................: %4d MHz\n", IGPU_RATIO_TO_FREQUENCY((UInt8)gMchbar[0x4C])); // RPSTT_LIM + } + } + else + { + IOLog("AICPUPMI: Error: memoryMap == NULL\n"); + } + } + else + { + IOLog("AICPUPMI: Error: memDescriptor->prepare() failed!\n"); + } + } + else + { + IOLog("AICPUPMI: Error: memDescriptor == NULL\n"); + } + } +#endif + timerEventSource->setTimeoutMS(1000); + + return true; + } + } + } + + return false; +} + +//============================================================================== + +void AppleIntelCPUPowerManagementInfo::stop(IOService *provider) +{ + if (simpleLock) + { + IOSimpleLockFree(simpleLock); + } + + if (timerEventSource) + { + if (workLoop) + { + timerEventSource->cancelTimeout(); + workLoop->removeEventSource(timerEventSource); + } + + timerEventSource->release(); + timerEventSource = NULL; + } + + super::stop(provider); +} + +//============================================================================== + +void AppleIntelCPUPowerManagementInfo::free() +{ +#if REPORT_IGPU_P_STATES + if (igpuEnabled) + { + if (memoryMap) + { + memoryMap->release(); + memoryMap = NULL; + } + + if (memDescriptor) + { + memDescriptor->release(); + memDescriptor = NULL; + } + } +#endif + + super::free(); +} diff --git a/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.h b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.h new file mode 100644 index 0000000..d3d35d4 --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.h @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2012-2014 Pike R. Alpha. All rights reserved. + * + * Original idea and initial development of MSRDumper.kext (c) 2011 by RevoGirl. + * + * Thanks to George for his help and continuation of Sam's work, but it is + * time for us to push the envelope and add some really interesting stuff. + * + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include "../../../essentials.h" + +#define super IOService + +#define VERSION "3.3" + +#define REPORT_MSRS 1 +#define REPORT_IGPU_P_STATES 1 +#define REPORT_C_STATES 1 +#define REPORT_IPG_STYLE 1 + +#define NB_BUS 0x00 +#define NB_DEV 0x00 +#define NB_FUN 0x00 + +#define DEVEN (0x54) +#define DEVEN_D2EN_MASK (0x10) + +#define NB_PCICFG_SPACE_INDEX_REG 0xcf8 +#define NB_PCICFG_SPACE_DATA_REG 0xcfc + +#define BIT31 0x80000000 + +#define PCIEX_BASE_ADDRESS 0xF8000000 +#define NB_MCH_BASE_ADDRESS 0xFED10000 // (G)MCH Memory Mapped Register Range Base Address (D0:F0:Rx48). + +#define READ_PCI8(Bx, Dx, Fx, Rx) ReadPci8(Bx, Dx, Fx, Rx) +#define READ_PCI8_NB(Rx) READ_PCI8(NB_BUS, NB_DEV, NB_FUN, Rx) +#define MMIO_READ8(Address) (*(volatile UInt8 *)(Address)) + +#define IGPU_RATIO_TO_FREQUENCY(ratio) ((ratio * 100) / 2) + +#define NB_PCI_CFG_ADDRESS(bus, dev, func, reg) \ +(UInt64) ((((UInt8)(bus) << 24) + ((UInt8)(dev) << 16) + \ +((UInt8)(func) << 8) + ((UInt8)(reg))) & 0xffffffff) + +#define NB_PCIE_CFG_ADDRESS(bus, dev, func, reg) \ +((UInt32)(PCIEX_BASE_ADDRESS + ((UInt8)(bus) << 20) + \ +((UInt8)(dev) << 15) + ((UInt8)(func) << 12) + (reg))) + +static __inline__ unsigned char inb(UInt16 port) +{ + UInt8 value; + __asm__ volatile("inb %w1, %b0" : "=a" (value) : "Nd" (port)); + return (value); +} + +static __inline__ void outl(UInt16 port, UInt32 value) +{ + __asm__ volatile("outl %0, %w1" : : "a" (value), "Nd" (port)); +} + +UInt8 ReadPci8(UInt8 Bus, UInt8 Dev, UInt8 Fun, UInt16 Reg) +{ + if (Reg >= 0x100) + { + return MMIO_READ8((UInt64)NB_PCIE_CFG_ADDRESS(Bus, Dev, Fun, Reg)); + } + else + { + outl(NB_PCICFG_SPACE_INDEX_REG, BIT31 | (Bus << 16) | (Dev << 11) | (Fun << 8) | (Reg & 0xfc)); + return inb(NB_PCICFG_SPACE_DATA_REG | (UInt8)(Reg & 3)); + } +} + +extern "C" void mp_rendezvous_no_intrs(void (*action_func)(void *), void * arg); +extern "C" int cpu_number(void); + +class AppleIntelCPUPowerManagementInfo : public IOService +{ + OSDeclareDefaultStructors (AppleIntelCPUPowerManagementInfo); + +private: + IOSimpleLock *simpleLock; + IOWorkLoop *workLoop; + IOTimerEventSource *timerEventSource; + +#if REPORT_IGPU_P_STATES + IOMemoryDescriptor *memDescriptor; + IOMemoryMap *memoryMap; + + bool igpuEnabled = false; // Set logIGPU to in Info.plist to enable this feature. +#endif + + IOReturn result = kIOReturnSuccess; + + virtual IOReturn loopTimerEvent(void); + +#if REPORT_MSRS + void reportMSRs(UInt8 aCPUModel); + + bool logMSRs = true; // Set logIGPU to in Info.plist to disable this feature. +#endif + + bool loopLock = false; + +#if REPORT_C_STATES + bool logCStates = true; // Set logCStates to in Info.plist to disable this feature. +#endif + +#if REPORT_IPG_STYLE + bool logIPGStyle = true; // Set logIPGStyle to in Info.plist to disable this feature. +#endif + + UInt16 Interval = 50; + + UInt64 gCoreMultipliers = 0ULL; + UInt64 gTriggeredPStates = 0ULL; + + UInt64 gIGPUMultipliers = 0ULL; + UInt64 gTriggeredIGPUPStates = 0ULL; + +public: + virtual IOService * probe(IOService * provider, SInt32 * score); + virtual bool start(IOService * provider); + virtual void stop(IOService * provider); + virtual void free(void); + + UInt8 gMinRatio = 0; + UInt8 gClockRatio = 0; + UInt8 gMaxRatio = 0; +}; + +OSDefineMetaClassAndStructors(AppleIntelCPUPowerManagementInfo, IOService) + +UInt8 gCoreStates = 0ULL; + +#if REPORT_C_STATES +bool gCheckC3 = true; +bool gCheckC6 = true; +bool gCheckC7 = false; + +UInt32 gC3Cores = 0; +UInt32 gC6Cores = 0; +UInt32 gC7Cores = 0; + +UInt32 gTriggeredC3Cores = 0; +UInt32 gTriggeredC6Cores = 0; +UInt32 gTriggeredC7Cores = 0; +#endif + +UInt64 gCoreMultipliers = 0ULL; + +#if REPORT_IGPU_P_STATES +UInt8 * gMchbar = NULL; +#endif \ No newline at end of file diff --git a/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist new file mode 100644 index 0000000..f40f1d7 --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist @@ -0,0 +1,63 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.apple.driver.${PRODUCT_NAME:identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + KEXT + CFBundleShortVersionString + 4.0.0 + CFBundleSignature + ???? + OSBundleRequired + Root + CFBundleVersion + 1 + IOKitPersonalities + + AppleIntelCPUPowerManagementInfo + + CFBundleIdentifier + com.apple.driver.${PRODUCT_NAME:identifier} + IOClass + ${PRODUCT_NAME:identifier} + IOMatchCategory + ${PRODUCT_NAME:identifier} + IOProviderClass + IOResources + IOResourceMatch + IOKit + logMSRs + + logIGPU + + logCStates + + logIPGStyle + + + + OSBundleLibraries + + com.apple.kpi.bsd + 10.4 + com.apple.kpi.iokit + 10.4 + com.apple.kpi.libkern + 10.4 + com.apple.kpi.mach + 10.4 + com.apple.kpi.unsupported + 10.4 + + + diff --git a/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/InfoPlist.strings b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/InfoPlist.strings new file mode 100644 index 0000000..8788023 --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ +NSHumanReadableCopyright = "Copyright © 2012-2014 Pike R. Alpha. All rights reserved"; \ No newline at end of file diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-all-target-headers.hmap b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-all-target-headers.hmap new file mode 100644 index 0000000..2616108 Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-all-target-headers.hmap differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-generated-files.hmap b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-generated-files.hmap new file mode 100644 index 0000000..94e5e7e Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-generated-files.hmap differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-own-target-headers.hmap b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-own-target-headers.hmap new file mode 100644 index 0000000..9be379b Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-own-target-headers.hmap differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-project-headers.hmap b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-project-headers.hmap new file mode 100644 index 0000000..06a2f13 Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-project-headers.hmap differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo.dep b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo.dep new file mode 100644 index 0000000..2448927 --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo.dep @@ -0,0 +1,5 @@ +ffffffffffffffffffffffffffffffff 0a61d4086202b8aa99802dd5a07619a2 ffffffffffffffffffffffffffffffff 0 /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext +ffffffffffffffffffffffffffffffff 4b0a69eb869f94de6761d3cbb0fc8dca ffffffffffffffffffffffffffffffff 0 /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/MacOS/AppleIntelCPUPowerManagementInfo +00000000000ac43a000000000000e9a6 314954ecc1dd4fb7a62e8166e69d217a ffffffffffffffffffffffffffffffff 0 /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o +00000000501047ea000000000001a941 f53fdd286d6471c23068262ffb3e025c ffffffffffffffffffffffffffffffff 0 /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o +00000000000000000000000000000000 9a5b9dc0f3dffe1c13b61e6a2886150c ffffffffffffffffffffffffffffffff 0 /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/Info.plist diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo.hmap b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo.hmap new file mode 100644 index 0000000..8394b61 Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo.hmap differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c new file mode 100644 index 0000000..d3c9c40 --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c @@ -0,0 +1,9 @@ +#include + +extern kern_return_t _start(kmod_info_t *ki, void *data); +extern kern_return_t _stop(kmod_info_t *ki, void *data); + +__attribute__((visibility("default"))) KMOD_EXPLICIT_DECL(com.apple.kext.AppleIntelCPUPowerManagementInfo, "1.0.0d1", _start, _stop) +__private_extern__ kmod_start_func_t *_realmain = 0; +__private_extern__ kmod_stop_func_t *_antimain = 0; +__private_extern__ int _kext_apple_cc = __APPLE_CC__ ; diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.LinkFileList b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.LinkFileList new file mode 100644 index 0000000..569a184 --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.LinkFileList @@ -0,0 +1 @@ +/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.d b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.d new file mode 100644 index 0000000..74eeadd --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.d @@ -0,0 +1,178 @@ +dependencies: \ + /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp \ + /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOLib.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/stdarg.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/cdefs.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/appleapiopts.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/system.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/stdint.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/message.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/port.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/boolean.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/boolean.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/boolean.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/vm_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/vm_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/vm_param.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/kern_return.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/kern_return.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/kern_return.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_statistics.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/time_value.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_notify.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_special_ports.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/memory_object_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_prot.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_sync.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/exception_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/exception.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/exception.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_status.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/thread_status.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/thread_status.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/_structs.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/fp_reg.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/thread_state.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/eflags.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/thread_state.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/processor_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/processor_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/processor_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/policy.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/Availability.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/AvailabilityInternal.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task_policy.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task_special_ports.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_policy.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_special_ports.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/clock_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_attributes.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_inherit.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_purgable.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_behavior.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_region.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/vm_param.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/kmod.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_param.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/std_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_interface.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/clock.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/string.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/endian.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/endian.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/_endian.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/_OSByteOrder.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/i386/_OSByteOrder.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/_structs.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/ndr.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSByteOrder.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/i386/OSByteOrder.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/notify.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mig_errors.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mig.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/clock_priv.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/clock_reply_server.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/exc_server.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_priv.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/mach_debug_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/ipc_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/vm_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/zone_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/page_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/hash_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/lockgroup_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_security.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/lock_set.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_exc_server.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_host.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_port.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/notify_server.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/processor.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/processor_set.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/semaphore.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/sync_policy.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_act.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_map.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/assert.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/assert.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/macro_help.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/kern_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/thread.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/debug.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/task.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/sched_prim.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/clock.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_time.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/locks.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/locks.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/locks.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/queue.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/ipc_mig.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/libkern.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOReturn.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/error.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOTypes.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/stdbool.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSTypes.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSBase.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/device/device_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOLocks.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/locks.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/machine_routines.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/machine_routines.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/pexpert/pexpert.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOInterrupts.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/pexpert/boot.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/pexpert/machine/boot.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/pexpert/i386/boot.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSAtomic.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/thread_call.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOService.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IORegistryEntry.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSContainers.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSObject.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSMetaClass.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSReturn.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/TargetConditionals.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSBoolean.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSString.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSymbol.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSData.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSNumber.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSArray.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSCollection.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSet.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSOrderedSet.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSCollectionIterator.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSIterator.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSDictionary.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSerialize.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSUnserialize.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IODeviceMemory.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMemoryDescriptor.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IONotifier.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOKitDebug.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/pwr_mgt/IOPMpowerState.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/pwr_mgt/IOPM.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMessage.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOServicePM.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOWorkLoop.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOTimerEventSource.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOEventSource.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/cpuid.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/proc_reg.h \ + /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/../../../essentials.h diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.dia b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.dia new file mode 100644 index 0000000..bb0ec51 Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.dia differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o new file mode 100644 index 0000000..d0871ee Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.d b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.d new file mode 100644 index 0000000..27e90c5 --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.d @@ -0,0 +1,63 @@ +dependencies: \ + /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/stdint.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/cdefs.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/message.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/port.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/boolean.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/boolean.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/boolean.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/vm_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/vm_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/vm_param.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/kern_return.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/kern_return.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/kern_return.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/appleapiopts.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_statistics.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/time_value.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_notify.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_special_ports.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/memory_object_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_prot.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_sync.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/exception_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/exception.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/exception.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_status.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/thread_status.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/thread_status.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/_structs.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/fp_reg.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/thread_state.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/eflags.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/thread_state.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/processor_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/processor_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/processor_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/policy.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/Availability.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/AvailabilityInternal.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task_policy.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task_special_ports.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_info.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_policy.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_special_ports.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/clock_types.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_attributes.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_inherit.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_purgable.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_behavior.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_region.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/vm_param.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/kmod.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_param.h \ + /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/std_types.h diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.dia b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.dia new file mode 100644 index 0000000..bb0ec51 Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.dia differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o new file mode 100644 index 0000000..c55ec6c Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/build-state.dat b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/build-state.dat new file mode 100644 index 0000000..1490c37 --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/build-state.dat @@ -0,0 +1,996 @@ +TAppleIntelCPUPowerManagementInfo +v5 +r1 +cCheck dependencies +cProcessInfoPlistFile /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/Info.plist AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist +cCompileC DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler +cCompileC DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler +cLd /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/MacOS/AppleIntelCPUPowerManagementInfo normal x86_64 +cTouch /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk +c00000000510D0CDA00000000000000AA +t1359809754 +s170 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/Availability.h +c00000000501047EA0000000000001B50 +t1343244266 +s6992 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/AvailabilityInternal.h +c00000000501047EA000000000001E923 +t1343244266 +s125219 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IODeviceMemory.h +c00000000501047EA0000000000001287 +t1343244266 +s4743 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOEventSource.h +c00000000501047EA0000000000002991 +t1343244266 +s10641 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOInterrupts.h +c00000000501047EA00000000000007AA +t1343244266 +s1962 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOKitDebug.h +c00000000501047EA00000000000012D3 +t1343244266 +s4819 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOLib.h +c00000000501047EA0000000000004C71 +t1343244266 +s19569 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOLocks.h +c00000000501047EA00000000000045C6 +t1343244266 +s17862 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMemoryDescriptor.h +c00000000505CB8B3000000000000BF23 +t1348253875 +s48931 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOMessage.h +c00000000501047EA000000000000250D +t1343244266 +s9485 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IONotifier.h +c00000000501047EA0000000000000CC1 +t1343244266 +s3265 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IORegistryEntry.h +c00000000501047EA0000000000010602 +t1343244266 +s67074 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOReturn.h +c00000000501047EA0000000000001D9C +t1343244266 +s7580 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOService.h +c00000000501047EA000000000001F776 +t1343244266 +s128886 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOServicePM.h +c00000000501047EA0000000000000652 +t1343244266 +s1618 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOTimerEventSource.h +c00000000501047EA0000000000002A4C +t1343244266 +s10828 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOTypes.h +c00000000501047EA0000000000001759 +t1343244266 +s5977 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/IOWorkLoop.h +c00000000501047EA0000000000003B4C +t1343244266 +s15180 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/assert.h +c00000000501047EA00000000000006CC +t1343244266 +s1740 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/pwr_mgt/IOPM.h +c00000000505CB8B30000000000008B53 +t1348253875 +s35667 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/pwr_mgt/IOPMpowerState.h +c00000000501047EA0000000000000EB0 +t1343244266 +s3760 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/IOKit/system.h +c00000000501047EA000000000000085B +t1343244266 +s2139 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/TargetConditionals.h +c00000000501047EC00000000000031E9 +t1343244268 +s12777 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/device/device_types.h +c00000000501047EA0000000000000F5E +t1343244266 +s3934 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/_types.h +c00000000501047EA0000000000001197 +t1343244266 +s4503 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/cpuid.h +c00000000501047EA00000000000034DA +t1343244266 +s13530 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/eflags.h +c00000000501047EA0000000000000E1E +t1343244266 +s3614 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/endian.h +c00000000501047EA0000000000001031 +t1343244266 +s4145 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/locks.h +c00000000501047EA0000000000000666 +t1343244266 +s1638 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/machine_routines.h +c00000000501047EA00000000000008A0 +t1343244266 +s2208 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/proc_reg.h +c00000000501047EA00000000000046F7 +t1343244266 +s18167 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/i386/types.h +c00000000501047EA00000000000018BD +t1343244266 +s6333 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/assert.h +c00000000501047EA0000000000000C13 +t1343244266 +s3091 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/clock.h +c00000000501047EA0000000000000C0C +t1343244266 +s3084 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/debug.h +c00000000501047EA000000000000104A +t1343244266 +s4170 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/ipc_mig.h +c00000000501047EA00000000000008AA +t1343244266 +s2218 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/kern_types.h +c00000000501047EA00000000000009EA +t1343244266 +s2538 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/locks.h +c00000000501047EA0000000000001B86 +t1343244266 +s7046 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/macro_help.h +c00000000501047EA0000000000000B23 +t1343244266 +s2851 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/queue.h +c00000000501047EA0000000000003B1C +t1343244266 +s15132 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/sched_prim.h +c00000000501047EA000000000000109A +t1343244266 +s4250 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/task.h +c00000000501047EA0000000000001007 +t1343244266 +s4103 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/thread.h +c00000000501047EA00000000000013A4 +t1343244266 +s5028 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/kern/thread_call.h +c00000000501047EA0000000000002522 +t1343244266 +s9506 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSAtomic.h +c00000000501047EA000000000000662A +t1343244266 +s26154 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSBase.h +c00000000501047EA000000000000063D +t1343244266 +s1597 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSByteOrder.h +c00000000501047EA0000000000002938 +t1343244266 +s10552 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSReturn.h +c00000000501047EA000000000000189B +t1343244266 +s6299 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/OSTypes.h +c00000000501047EA0000000000000E59 +t1343244266 +s3673 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/_OSByteOrder.h +c00000000501047EA00000000000010FF +t1343244266 +s4351 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSArray.h +c00000000501047EA0000000000005BEE +t1343244266 +s23534 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSBoolean.h +c00000000501047EA0000000000001E3A +t1343244266 +s7738 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSCollection.h +c00000000501047EA0000000000003885 +t1343244266 +s14469 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSCollectionIterator.h +c00000000501047EA000000000000191A +t1343244266 +s6426 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSContainers.h +c00000000501047EA000000000000079F +t1343244266 +s1951 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSData.h +c00000000501047EA00000000000058EA +t1343244266 +s22762 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSDictionary.h +c00000000501047EA000000000000791E +t1343244266 +s31006 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSIterator.h +c00000000501047EA00000000000010F2 +t1343244266 +s4338 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSMetaClass.h +c00000000501047EA0000000000010F15 +t1343244266 +s69397 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSNumber.h +c00000000501047EA0000000000003218 +t1343244266 +s12824 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSObject.h +c00000000501047EA0000000000003950 +t1343244266 +s14672 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSOrderedSet.h +c00000000501047EA0000000000006595 +t1343244266 +s26005 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSerialize.h +c00000000501047EA0000000000002633 +t1343244266 +s9779 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSet.h +c00000000501047EA00000000000063F0 +t1343244266 +s25584 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSString.h +c00000000501047EA000000000000345F +t1343244266 +s13407 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSSymbol.h +c00000000501047EA0000000000002F5E +t1343244266 +s12126 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/c++/OSUnserialize.h +c00000000501047EA0000000000000A1E +t1343244266 +s2590 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/i386/OSByteOrder.h +c00000000501047EA0000000000000B8D +t1343244266 +s2957 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/i386/_OSByteOrder.h +c00000000501047EA0000000000000AA7 +t1343244266 +s2727 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/libkern.h +c00000000501047EA0000000000001C53 +t1343244266 +s7251 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/libkern/locks.h +c00000000501047EA00000000000005D7 +t1343244266 +s1495 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/boolean.h +c00000000501047EA0000000000000B08 +t1343244266 +s2824 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/clock.h +c00000000501047EA000000000000147C +t1343244266 +s5244 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/clock_priv.h +c00000000501047EA0000000000001110 +t1343244266 +s4368 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/clock_reply_server.h +c00000000501047EA0000000000000E53 +t1343244266 +s3667 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/clock_types.h +c00000000501047EA0000000000001019 +t1343244266 +s4121 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/error.h +c00000000501047EA0000000000000F22 +t1343244266 +s3874 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/exc_server.h +c00000000501047EA00000000000019A7 +t1343244266 +s6567 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/exception_types.h +c00000000501047EA0000000000001913 +t1343244266 +s6419 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_info.h +c00000000501047EA0000000000001FD7 +t1343244266 +s8151 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_notify.h +c00000000501047EA0000000000000608 +t1343244266 +s1544 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_priv.h +c00000000501047EA0000000000006CFA +t1343244266 +s27898 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_security.h +c00000000501047EA000000000000152D +t1343244266 +s5421 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/host_special_ports.h +c00000000501047EA0000000000001C61 +t1343244266 +s7265 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/_structs.h +c00000000501047EA00000000000062D1 +t1343244266 +s25297 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/boolean.h +c00000000501047EA0000000000000A1C +t1343244266 +s2588 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/exception.h +c00000000501047EA00000000000010EE +t1343244266 +s4334 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/fp_reg.h +c00000000501047EA00000000000011B3 +t1343244266 +s4531 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/kern_return.h +c00000000501047EA0000000000000AAC +t1343244266 +s2732 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/processor_info.h +c00000000501047EA000000000000061C +t1343244266 +s1564 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/thread_state.h +c00000000501047EA00000000000006AC +t1343244266 +s1708 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/thread_status.h +c00000000501047EA0000000000002745 +t1343244266 +s10053 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/vm_param.h +c00000000501047EA0000000000001727 +t1343244266 +s5927 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/i386/vm_types.h +c00000000501047EA0000000000001266 +t1343244266 +s4710 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/kern_return.h +c00000000501047EA00000000000023B2 +t1343244266 +s9138 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/kmod.h +c00000000501047EA0000000000001A2E +t1343244266 +s6702 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/lock_set.h +c00000000501047EA0000000000001B1A +t1343244266 +s6938 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_exc_server.h +c00000000501047EA0000000000001ABE +t1343244266 +s6846 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_host.h +c00000000501047EA0000000000005294 +t1343244266 +s21140 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_interface.h +c00000000501047EA0000000000000782 +t1343244266 +s1922 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_port.h +c00000000501047EA00000000000077E0 +t1343244266 +s30688 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_time.h +c00000000501047EA00000000000006C3 +t1343244266 +s1731 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mach_types.h +c00000000501047EA0000000000002059 +t1343244266 +s8281 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine.h +c00000000501047EA0000000000003085 +t1343244266 +s12421 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/boolean.h +c00000000501047EA000000000000064E +t1343244266 +s1614 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/exception.h +c00000000501047EA0000000000000658 +t1343244266 +s1624 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/kern_return.h +c00000000501047EA0000000000000662 +t1343244266 +s1634 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/processor_info.h +c00000000501047EA0000000000000671 +t1343244266 +s1649 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/thread_state.h +c00000000501047EA0000000000000667 +t1343244266 +s1639 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/thread_status.h +c00000000501047EA000000000000066C +t1343244266 +s1644 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/vm_param.h +c00000000501047EA0000000000000653 +t1343244266 +s1619 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/machine/vm_types.h +c00000000501047EA0000000000000653 +t1343244266 +s1619 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/memory_object_types.h +c00000000501047EA0000000000003997 +t1343244266 +s14743 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/message.h +c00000000501047EA0000000000006311 +t1343244266 +s25361 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mig.h +c00000000501047EA000000000000150D +t1343244266 +s5389 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/mig_errors.h +c00000000501047EA0000000000001192 +t1343244266 +s4498 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/ndr.h +c00000000501047EA00000000000019EC +t1343244266 +s6636 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/notify.h +c00000000501047EA00000000000013EC +t1343244266 +s5100 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/notify_server.h +c00000000501047EA0000000000001AB5 +t1343244266 +s6837 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/policy.h +c00000000501047EA0000000000001BCF +t1343244266 +s7119 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/port.h +c00000000501047EA0000000000003264 +t1343244266 +s12900 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/processor.h +c00000000501047EA0000000000001E9E +t1343244266 +s7838 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/processor_info.h +c00000000501047EA00000000000016A8 +t1343244266 +s5800 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/processor_set.h +c00000000501047EA0000000000003005 +t1343244266 +s12293 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/semaphore.h +c00000000501047EA00000000000009EC +t1343244266 +s2540 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/std_types.h +c00000000501047EA0000000000000A85 +t1343244266 +s2693 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/sync_policy.h +c00000000501047EA0000000000000704 +t1343244266 +s1796 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task.h +c00000000501047EA0000000000008BC5 +t1343244266 +s35781 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task_info.h +c00000000501047EA00000000000033B3 +t1343244266 +s13235 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task_policy.h +c00000000501047EA00000000000010C1 +t1343244266 +s4289 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/task_special_ports.h +c00000000501047EA0000000000001072 +t1343244266 +s4210 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_act.h +c00000000501047EA0000000000006436 +t1343244266 +s25654 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_info.h +c00000000501047EA0000000000001566 +t1343244266 +s5478 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_policy.h +c00000000501047EA0000000000001CDD +t1343244266 +s7389 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_special_ports.h +c00000000501047EA0000000000000C35 +t1343244266 +s3125 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/thread_status.h +c00000000501047EA0000000000000DA4 +t1343244266 +s3492 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/time_value.h +c00000000501047EA0000000000000D00 +t1343244266 +s3328 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_attributes.h +c00000000501047EA0000000000000E52 +t1343244266 +s3666 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_behavior.h +c00000000501047EA0000000000000B62 +t1343244266 +s2914 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_inherit.h +c00000000501047EA0000000000000C84 +t1343244266 +s3204 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_map.h +c00000000501047EA000000000000721E +t1343244266 +s29214 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_param.h +c00000000501047EA0000000000002223 +t1343244266 +s8739 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_prot.h +c00000000501047EA0000000000001211 +t1343244266 +s4625 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_purgable.h +c00000000501047EA00000000000016F0 +t1343244266 +s5872 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_region.h +c00000000501047EA0000000000002DFD +t1343244266 +s11773 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_statistics.h +c00000000501047EA0000000000003238 +t1343244266 +s12856 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_sync.h +c00000000501047EA0000000000000BD5 +t1343244266 +s3029 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach/vm_types.h +c00000000501047EA0000000000000C02 +t1343244266 +s3074 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/hash_info.h +c00000000501047EA0000000000000AE6 +t1343244266 +s2790 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/ipc_info.h +c00000000501047EA0000000000000F87 +t1343244266 +s3975 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/lockgroup_info.h +c00000000501047EA00000000000009BB +t1343244266 +s2491 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/mach_debug_types.h +c00000000501047EA0000000000000B14 +t1343244266 +s2836 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/page_info.h +c00000000501047EA0000000000000A18 +t1343244266 +s2584 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/vm_info.h +c00000000501047EA00000000000016C7 +t1343244266 +s5831 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/mach_debug/zone_info.h +c00000000501047EA00000000000013E9 +t1343244266 +s5097 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/_types.h +c00000000501047EA000000000000063B +t1343244266 +s1595 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/endian.h +c00000000501047EA000000000000067D +t1343244266 +s1661 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/locks.h +c00000000501047EA000000000000062B +t1343244266 +s1579 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/machine_routines.h +c00000000501047EA000000000000065E +t1343244266 +s1630 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/machine/types.h +c00000000501047EA0000000000000678 +t1343244266 +s1656 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/pexpert/boot.h +c00000000501047EA00000000000005AA +t1343244266 +s1450 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/pexpert/i386/boot.h +c00000000501047EA0000000000001628 +t1343244266 +s5672 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/pexpert/machine/boot.h +c00000000501047EA000000000000064A +t1343244266 +s1610 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/pexpert/pexpert.h +c00000000501047EA0000000000001ECE +t1343244266 +s7886 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/stdarg.h +c00000000501047EA00000000000007CD +t1343244266 +s1997 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/stdbool.h +c00000000501047EA00000000000006D8 +t1343244266 +s1752 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/stdint.h +c00000000501047EA0000000000001A29 +t1343244266 +s6697 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/string.h +c00000000501047EA0000000000000C73 +t1343244266 +s3187 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/_endian.h +c00000000501047EA000000000000165C +t1343244266 +s5724 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/_structs.h +c00000000501047EA0000000000002AAE +t1343244266 +s10926 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/_types.h +c00000000501047EA00000000000018AC +t1343244266 +s6316 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/appleapiopts.h +c00000000501047EA0000000000000816 +t1343244266 +s2070 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/cdefs.h +c00000000501047EA0000000000004975 +t1343244266 +s18805 + +N/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/types.h +c00000000501047EA0000000000002905 +t1343244266 +s10501 + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/../../../essentials.h +c000000005131D4050000000000001533 +t1362220037 +s5427 + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp +c00000000513B103900000000000025A0 +t1362825273 +s9632 +i"AppleIntelCPUPowerManagementInfo.h" + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.h +c00000000513B1039000000000000066C +t1362825273 +s1644 + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c +c00000000513B10A400000000000001B9 +t1362825380 +s441 + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.LinkFileList +c00000000513B10A40000000000000101 +t1362825380 +s257 + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o +t2 +s0 + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o +t2 +s0 + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext +t2 +s0 + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/Info.plist +t2 +s0 + +N/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/MacOS/AppleIntelCPUPowerManagementInfo +t2 +s0 + +NAppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist +c000000005131D4050000000000000652 +t1362220037 +s1618 + +CBuild AST from /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp +r0 + +CCheck dependencies +r0 +lSLF05#21%IDEActivityLogSection1@2#32"com.apple.dt.IDE.BuildLogSection18"Check dependencies5fb53e2448ebb641^56d8402448ebb641^---0#1#0#--18"Check dependencies36"4BBBCCFD-71FD-4E14-BB47-E3A68AE10C87- + +CCompileC DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler +s384518180.271168 +e384518180.386185 +r1 +xCompileC +xDerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o +x/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp +xnormal +xx86_64 +xc++ +xcom.apple.compilers.llvm.clang.1_0.compiler +lSLF05#21%IDEActivityLogSection1@2#32"com.apple.dt.IDE.BuildLogSection128"Compile /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cppa393452448ebb641^a0dc622448ebb641^---0#0#0#-19%DVTDocumentLocation2@136"file://localhost/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp0000000000000000^4669"CompileC DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler cd /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo setenv LANG en_US.US-ASCII /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 -fmessage-length=0 -nostdinc -fno-builtin -Wno-trigraphs -fno-exceptions -fno-rtti -msoft-float -Os -fno-common -mkernel -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-empty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wenum-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DDEBUG -DKERNEL -DKERNEL_PRIVATE -DDRIVER_PRIVATE -DAPPLE -DNeXT -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -fapple-kext -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.8 -g -Wno-sign-conversion -iquote /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-generated-files.hmap -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-own-target-headers.hmap -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-all-target-headers.hmap -iquote /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-project-headers.hmap -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/System/Library/Frameworks/Kernel.framework/PrivateHeaders -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/x86_64 -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources -F/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug -MMD -MT dependencies -MF /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.d --serialize-diagnostics /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.dia -c /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.cpp -o /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o 36"F635FAD4-0E31-4C90-B178-F5F53333FC8B- + +CCompileC DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler +s384518180.271157 +e384518180.291712 +r1 +xCompileC +xDerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o +x/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c +xnormal +xx86_64 +xc +xcom.apple.compilers.llvm.clang.1_0.compiler +lSLF05#21%IDEActivityLogSection1@2#32"com.apple.dt.IDE.BuildLogSection262"Compile /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c5f7c452448ebb641^43ac4a2448ebb641^---0#0#0#-19%DVTDocumentLocation2@270"file://localhost/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c0000000000000000^4815"CompileC DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler cd /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo setenv LANG en_US.US-ASCII /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -arch x86_64 -fmessage-length=0 -nostdinc -fno-builtin -Wno-trigraphs -msoft-float -Os -fno-common -mkernel -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-empty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DDEBUG -DKERNEL -DKERNEL_PRIVATE -DDRIVER_PRIVATE -DAPPLE -DNeXT -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -mmacosx-version-min=10.8 -g -Wno-sign-conversion -iquote /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-generated-files.hmap -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-own-target-headers.hmap -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-all-target-headers.hmap -iquote /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-project-headers.hmap -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/System/Library/Frameworks/Kernel.framework/PrivateHeaders -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Kernel.framework/Headers -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/x86_64 -I/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources -F/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug -MMD -MT dependencies -MF /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.d --serialize-diagnostics /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.dia -c /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c -o /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o 36"8C3C8E36-9716-4A76-A07E-9F25E38F513C- + +CLd /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/MacOS/AppleIntelCPUPowerManagementInfo normal x86_64 +s384518180.392332 +e384518180.403175 +r1 +xLd +x/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/MacOS/AppleIntelCPUPowerManagementInfo +xnormal +xx86_64 +lSLF05#21%IDEActivityLogSection1@2#32"com.apple.dt.IDE.BuildLogSection207"Link /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/MacOS/AppleIntelCPUPowerManagementInfo187a642448ebb641^3736672448ebb641^---0#0#0#--1551"Ld DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/MacOS/AppleIntelCPUPowerManagementInfo normal x86_64 cd /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo setenv MACOSX_DEPLOYMENT_TARGET 10.8 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug -F/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug -filelist /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.LinkFileList -mmacosx-version-min=10.8 -Xlinker -kext -nostdlib -lkmodc++ /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o -lkmod -lcc_kext -o /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/MacOS/AppleIntelCPUPowerManagementInfo 36"2202B136-B2BE-467F-B634-E73E67DD3F6B- + +CProcessInfoPlistFile /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/Info.plist AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist +s384518180.257482 +e384518180.259892 +r1 +xProcessInfoPlistFile +x/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/Info.plist +xAppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist +lSLF05#21%IDEActivityLogSection1@2#32"com.apple.dt.IDE.BuildLogSection84"Process AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plistc3f4412448ebb641^0588422448ebb641^---0#0#0#-19%DVTDocumentLocation2@143"file://localhost/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist0000000000000000^602"ProcessInfoPlistFile DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/Info.plist AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist cd /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo builtin-infoPlistUtility AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist -expandbuildsettings -platform macosx -o /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/Info.plist 36"BCBA7FDC-11DE-4A8B-A76F-66D11EE98742- + +CTouch /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext +s384518180.411069 +e384518180.415237 +r1 +xTouch +x/Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext +lSLF05#21%IDEActivityLogSection1@2#32"com.apple.dt.IDE.BuildLogSection160"Touch /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext5b43692448ebb641^c74c6a2448ebb641^---0#0#0#--345"Touch DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext cd /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo /usr/bin/touch -c /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext 36"1020B3C7-5E5E-40D6-B89C-B816F744FFDC- + diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/AC062B99-9E9E-41C9-966B-1B327D5EC5DC.xcactivitylog b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/AC062B99-9E9E-41C9-966B-1B327D5EC5DC.xcactivitylog new file mode 100644 index 0000000..07a4dab Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/AC062B99-9E9E-41C9-966B-1B327D5EC5DC.xcactivitylog differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/Cache.db b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/Cache.db new file mode 100644 index 0000000..2375615 Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/Cache.db differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/8BE2DAD6-DF4F-4F8E-9FCF-211E10D22EAE.xcactivitylog b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/8BE2DAD6-DF4F-4F8E-9FCF-211E10D22EAE.xcactivitylog new file mode 100644 index 0000000..b0088af Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/8BE2DAD6-DF4F-4F8E-9FCF-211E10D22EAE.xcactivitylog differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/Cache.db b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/Cache.db new file mode 100644 index 0000000..538b23a Binary files /dev/null and b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/Cache.db differ diff --git a/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/info.plist b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/info.plist new file mode 100644 index 0000000..cfcf71f --- /dev/null +++ b/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/info.plist @@ -0,0 +1,8 @@ + + + + + WorkspacePath + /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo.xcodeproj + + diff --git a/i386/libsaio/device_tree.c b/i386/libsaio/device_tree.c index d80dd3e..4e8a252 100755 --- a/i386/libsaio/device_tree.c +++ b/i386/libsaio/device_tree.c @@ -79,14 +79,14 @@ Property * DT__AddProperty(Node *node, const char *name, uint32_t length, void * { Property *prop; - _EFI_DEBUG_DUMP("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value); - if (freeProperties == NULL) { void *buf = malloc(kAllocSize); int i; + #if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("Allocating more free properties\n"); + #endif if (buf == 0) { @@ -109,6 +109,10 @@ Property * DT__AddProperty(Node *node, const char *name, uint32_t length, void * } } +#if (DEBUG_EFI & 2) + _EFI_DEBUG_DUMP("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value); +#endif + prop = freeProperties; freeProperties = prop->next; @@ -129,7 +133,9 @@ Property * DT__AddProperty(Node *node, const char *name, uint32_t length, void * node->last_prop = prop; prop->next = 0; - // _EFI_DEBUG_DUMP("Done [0x%x]\n", prop); +#if (DEBUG_EFI & 8) + _EFI_DEBUG_DUMP("Done [0x%x]\n", prop); +#endif DTInfo.numProperties++; DTInfo.totalPropertySize += RoundToLong(length); @@ -155,7 +161,9 @@ Node * DT__AddChild(Node *parent, const char *name) int i; +#if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("Allocating more free nodes\n"); +#endif bzero(buf, kAllocSize); node = (Node *)buf; @@ -174,13 +182,17 @@ Node * DT__AddChild(Node *parent, const char *name) } } +#if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("DT__AddChild(0x%x, '%s')\n", parent, name); +#endif node = freeNodes; freeNodes = node->next; +#if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("Got free node 0x%x\n", node); _EFI_DEBUG_DUMP("prop = 0x%x, children = 0x%x, next = 0x%x\n", node->properties, node->children, node->next); +#endif if (parent == NULL) { @@ -194,6 +206,7 @@ Node * DT__AddChild(Node *parent, const char *name) } DTInfo.numNodes++; + DT__AddProperty(node, "name", strlen(name) + 1, (void *) name); return node; @@ -252,7 +265,9 @@ void DT__Finalize(void) Node *node; Property *prop; - // _EFI_DEBUG_DUMP("DT__Finalize\n"); +#if (DEBUG_EFI & 8) + _EFI_DEBUG_DUMP("DT__Finalize\n"); +#endif for (prop = allocedProperties; prop != NULL; prop = prop->next) { @@ -332,7 +347,9 @@ void DT__FlattenDeviceTree(void **buffer_p, uint32_t *length) uint32_t totalSize; void * buf; +#if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("DT__FlattenDeviceTree(0x%x, 0x%x)\n", buffer_p, length); +#endif #if (DEBUG_EFI & 4) if (buffer_p) @@ -341,11 +358,11 @@ void DT__FlattenDeviceTree(void **buffer_p, uint32_t *length) } #endif - totalSize = DTInfo.numNodes * sizeof(DeviceTreeNode) + - DTInfo.numProperties * sizeof(DeviceTreeNodeProperty) + - DTInfo.totalPropertySize; + totalSize = DTInfo.numNodes * sizeof(DeviceTreeNode) + DTInfo.numProperties * sizeof(DeviceTreeNodeProperty) + DTInfo.totalPropertySize; +#if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("Total size 0x%x\n", totalSize); +#endif if (buffer_p != 0) { @@ -385,11 +402,16 @@ char * DT__GetName(Node *node) { Property *prop; - //_EFI_DEBUG_DUMP("DT__GetName(0x%x)\n", node); - //_EFI_DEBUG_DUMP("Node properties = 0x%x\n", node->properties); +#if (DEBUG_EFI & 8) + _EFI_DEBUG_DUMP("DT__GetName(0x%x)\n", node); + _EFI_DEBUG_DUMP("Node properties = 0x%x\n", node->properties); +#endif + for (prop = node->properties; prop; prop = prop->next) { - //_EFI_DEBUG_DUMP("Prop '%s'\n", prop->name); +#if (DEBUG_EFI & 8) + _EFI_DEBUG_DUMP("Prop '%s'\n", prop->name); +#endif if (strcmp(prop->name, "name") == 0) { return prop->value; @@ -410,8 +432,10 @@ Node * DT__FindNode(const char *path, bool createIfMissing) char *bp; int i; +#if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("DT__FindNode('%s', %d)\n", path, createIfMissing); - +#endif + // Start at root node = gPlatform.DT.RootNode; @@ -436,13 +460,15 @@ Node * DT__FindNode(const char *path, bool createIfMissing) { break; // last path entry } - +#if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("Node '%s'\n", nameBuf); +#endif for (child = node->children; child != 0; child = child->next) { +#if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("Child 0x%x\n", child); - +#endif if (strcmp(DT__GetName(child), nameBuf) == 0) { break; @@ -451,7 +477,9 @@ Node * DT__FindNode(const char *path, bool createIfMissing) if (child == 0 && createIfMissing) { +#if (DEBUG_EFI & 2) _EFI_DEBUG_DUMP("Creating node\n"); +#endif char *str = malloc(strlen(nameBuf) + 1); // XXX this will leak diff --git a/i386/libsaio/device_tree.h b/i386/libsaio/device_tree.h index 0bfbf23..b33a6fb 100755 --- a/i386/libsaio/device_tree.h +++ b/i386/libsaio/device_tree.h @@ -50,7 +50,6 @@ typedef struct _Node struct _Node * next; } Node; - extern Property * DT__AddProperty(Node *node, const char *name, uint32_t length, void *value); extern Node * DT__AddChild(Node *parent, const char *name); diff --git a/i386/libsaio/disk.c b/i386/libsaio/disk.c index 8ba0d5c..85b902f 100644 --- a/i386/libsaio/disk.c +++ b/i386/libsaio/disk.c @@ -30,45 +30,74 @@ */ /* - * INTEL CORPORATION PROPRIETARY INFORMATION + * INTEL CORPORATION PROPRIETARY INFORMATION * - * This software is supplied under the terms of a license agreement or - * nondisclosure agreement with Intel Corporation and may not be copied - * nor disclosed except in accordance with the terms of that agreement. + * This software is supplied under the terms of a license agreement or + * nondisclosure agreement with Intel Corporation and may not be copied + * nor disclosed except in accordance with the terms of that agreement. + * + * Copyright 1988, 1989 Intel Corporation + * + * Copyright 1993 NeXT Computer, Inc. All rights reserved. + * + * Copyright 2007 VMware Inc. + * "Preboot" ramdisk support added by David Elliott + * GPT support added by David Elliott. Based on IOGUIDPartitionScheme.cpp. + * + * Updates: + * - Cleanups and refactoring by DHP in 2010 and 2011. + * - Renamed LION_RECOVERY_SUPPORT to CORE_STORAGE_SUPPORT (Pike R. Alpha, November 2012). + * - Renamed LION_FILEVAULT_SUPPORT to CORE_STORAGE_SUPPORT (Pike R. Alpha, November 2012). + * - Renamed encryptedBootPartition to coreStoragePartition (Pike R. Alpha, November 2012). + * - OSBigEndian removed and some minor style nits (Pike R. Alpha, November 2012). + * - Unused #include removed (Pike R. Alpha, November 2012). * - * Copyright 1988, 1989 Intel Corporation - */ - -/* - * Copyright 1993 NeXT Computer, Inc. - * All rights reserved. - */ - -/* Copyright 2007 VMware Inc. - "Preboot" ramdisk support added by David Elliott - GPT support added by David Elliott. Based on IOGUIDPartitionScheme.cpp. */ -/*** - * Cleanups and refactoring by DHP in 2010 and 2011. - */ - #include "bootstruct.h" #include "fdisk.h" #include "hfs.h" -#include - #define DPISTRLEN 32 // Defined in: IOKit/storage/IOApplePartitionScheme.h #include +/* Partition map from: IOGUIDPartitionScheme.h +struct gpt_hdr +{ + uint8_t hdr_sig[8]; + uint32_t hdr_revision; + uint32_t hdr_size; + uint32_t hdr_crc_self; + uint32_t __reserved; + uint64_t hdr_lba_self; + uint64_t hdr_lba_alt; + uint64_t hdr_lba_start; + uint64_t hdr_lba_end; + uuid_t hdr_uuid; + uint64_t hdr_lba_table; + uint32_t hdr_entries; + uint32_t hdr_entsz; + uint32_t hdr_crc_table; + uint32_t padding; +}; */ + typedef struct gpt_hdr gpt_hdr; -typedef struct gpt_ent gpt_ent; -#include "efi_tables.h" +/* Partition map entry from: IOGUIDPartitionScheme.h +struct gpt_ent +{ + uuid_t ent_type; + uuid_t ent_uuid; + uint64_t ent_lba_start; + uint64_t ent_lba_end; + uint64_t ent_attr; + uint16_t ent_name[36]; +}; */ + +typedef struct gpt_ent gpt_ent; #define BPS 512 // sector size of the device. @@ -117,7 +146,10 @@ static struct disk_blk0 * gBootSector = NULL; // Apple_HFS EFI_GUID const GPT_HFS_GUID = { 0x48465300, 0x0000, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } }; -#if LION_RECOVERY_SUPPORT || APPLE_RAID_SUPPORT +// Apple TV +EFI_GUID const GPT_HFSX_GUID = { 0x5265636F, 0x7665, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } }; + +#if CORE_STORAGE_SUPPORT || APPLE_RAID_SUPPORT || RECOVERY_HD_SUPPORT // Apple_Boot (RAID helper partition and the 650 MB 'Recovery HD' partition). EFI_GUID const GPT_BOOT_GUID = { 0x426F6F74, 0x0000, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } }; #endif @@ -140,11 +172,15 @@ EFI_GUID const GPT_HFS_GUID = { 0x48465300, 0x0000, 0x11AA, { 0xAA, 0x11, 0x EFI_GUID const GPT_EFISYS_GUID = { 0xC12A7328, 0xF81F, 0x11D2, { 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } }; #endif -#if LION_FILEVAULT_SUPPORT - // Apple_CoreStorage (FileVault 2) +#if CORE_STORAGE_SUPPORT + // Apple_CoreStorage (FileVault 2 and Fusion Drive) EFI_GUID const GPT_CORESTORAGE_GUID = { 0x53746F72, 0x6167, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } }; #endif +#if APFS_SUPPORT + // Aople File System (7C3457EF-0000-11AA-AA11-00306543ECAC) + EFI_GUID const APFS_GUID = { 0x7C3457EF, 0x0000, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } }; +#endif //============================================================================== @@ -500,7 +536,7 @@ static BVRef newGPTBVRef(int biosdev, int partno, unsigned int blkoff, const gpt static bool isPartitionUsed(gpt_ent * partition) { - return efi_guid_is_null((EFI_GUID const*)partition->ent_type) ? false : true; + return isEFIGUIDNull((EFI_GUID const*)partition->ent_type) ? false : true; } @@ -560,10 +596,9 @@ BVRef diskScanGPTBootVolumes(int biosdev, int * countPtr) map->next = gDiskBVMap; gDiskBVMap = map; -#if LION_FILEVAULT_SUPPORT - bool encryptedBootPartition = false; +#if CORE_STORAGE_SUPPORT + bool coreStoragePartition = false; #endif - for (; gptID <= gptCount; gptID++) { gptMap = (gpt_ent *) (buffer + ((gptID - 1) * gptSize)); @@ -573,14 +608,14 @@ BVRef diskScanGPTBootVolumes(int biosdev, int * countPtr) BVRef bvr = NULL; int bvrFlags = -1; #if DEBUG_DISK - char stringuuid[100]; - efi_guid_unparse_upper((EFI_GUID*)gptMap->ent_type, stringuuid); - printf("Reading GPT partition %d, type %s\n", gptID, stringuuid); + char *uuidString = NULL; + convertEFIGUIDToString((EFI_GUID*)gptMap->ent_uuid, &uuidString); + printf("Partition[%d] UUID: %s\n", gptID, uuidString); sleep(1); #endif #if EFI_SYSTEM_PARTITION_SUPPORT // First check for the EFI partition. - if (efi_guid_compare(&GPT_EFISYS_GUID, (EFI_GUID const *)gptMap->ent_type) == 0) + if (compareEFIGUID(&GPT_EFISYS_GUID, (EFI_GUID const *)gptMap->ent_type) == 0) { _DISK_DEBUG_DUMP("Matched: EFI GUID, probing for HFS format...\n"); @@ -615,28 +650,28 @@ BVRef diskScanGPTBootVolumes(int biosdev, int * countPtr) else #endif -#if LION_FILEVAULT_SUPPORT // Is this an encrypted boot partition? - if (efi_guid_compare(&GPT_CORESTORAGE_GUID, (EFI_GUID const *)gptMap->ent_type) == 0) +#if CORE_STORAGE_SUPPORT // Is this a CoreStorage partition? + if (compareEFIGUID(&GPT_CORESTORAGE_GUID, (EFI_GUID const *)gptMap->ent_type) == 0) { _DISK_DEBUG_DUMP("Matched: CoreStorage GUID\n"); - encryptedBootPartition = true; + coreStoragePartition = true; - continue; // Start searching for the Recovery HD partition. + continue; // Start searching for the Recovery HD/Boot OS X partition. } - else if (!encryptedBootPartition && + else if (!coreStoragePartition && #else // Check for HFS+ partitions. if ( #endif - !gPlatform.BootRecoveryHD && (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const *)gptMap->ent_type) == 0)) + !gPlatform.BootRecoveryHD && (compareEFIGUID(&GPT_HFS_GUID, (EFI_GUID const *)gptMap->ent_type) == 0)) { _DISK_DEBUG_DUMP("Matched: HFS+ GUID\n"); bvrFlags = kBVFlagZero; } #if APPLE_RAID_SUPPORT - else if (efi_guid_compare(&GPT_RAID_GUID, (EFI_GUID const *)gptMap->ent_type) == 0) + else if (compareEFIGUID(&GPT_RAID_GUID, (EFI_GUID const *)gptMap->ent_type) == 0) { _DISK_DEBUG_DUMP("Skipping: GPT_RAID_GUID\n"); @@ -644,8 +679,8 @@ BVRef diskScanGPTBootVolumes(int biosdev, int * countPtr) } #endif -#if LION_RECOVERY_SUPPORT || APPLE_RAID_SUPPORT - else if (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const *)gptMap->ent_type) == 0) +#if CORE_STORAGE_SUPPORT || APPLE_RAID_SUPPORT || RECOVERY_HD_SUPPORT + else if (compareEFIGUID(&GPT_BOOT_GUID, (EFI_GUID const *)gptMap->ent_type) == 0) { _DISK_DEBUG_DUMP("Matched: GPT_BOOT_GUID\n"); @@ -677,7 +712,7 @@ BVRef diskScanGPTBootVolumes(int biosdev, int * countPtr) // Initialize with the first bootable volume. gPlatform.BootVolume = gPlatform.RootVolume = bvr; - _DISK_DEBUG_DUMP("Init B/RootVolume - partition: %d, flags: %d, gptID: %d\n", bvr->part_no, bvr->flags, gptID); + _DISK_DEBUG_DUMP("Init Boot/RootVolume - partition: %d, flags: %d, gptID: %d\n", bvr->part_no, bvr->flags, gptID); } // Bail out after finding the first System Volume. @@ -706,9 +741,16 @@ BVRef diskScanGPTBootVolumes(int biosdev, int * countPtr) } } } - _DISK_DEBUG_ELSE_DUMP("Failed to read boot sector from BIOS device %02xh\n", biosdev); + else + { + _DISK_DEBUG_DUMP("Failed to read boot sector from BIOS device %02xh\n", biosdev); + + if (buffer) + { + free(buffer); + } + } - free(buffer); *countPtr = 0; _DISK_DEBUG_SLEEP(5); @@ -727,7 +769,16 @@ bool hasBootEFI(BVRef bvr) sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/", BIOS_DEV_UNIT(bvr), bvr->part_no); +#if RECOVERY_HD_SUPPORT + if (gPlatform.BootRecoveryHD) + { + sprintf(dirSpec, "hd(%d,%d)/com.apple.recovery.boot/", BIOS_DEV_UNIT(bvr), bvr->part_no); + + _DISK_DEBUG_DUMP("Checking for boot.efi on Recovery HD\n"); + } +#else _DISK_DEBUG_DUMP("In hasBootEFI(%d,%d)\n", BIOS_DEV_UNIT(bvr), bvr->part_no); +#endif if (GetFileInfo(dirSpec, "boot.efi", &flags, &time) == 0) { diff --git a/i386/libsaio/efi.c b/i386/libsaio/efi.c index d19557b..4b83600 100755 --- a/i386/libsaio/efi.c +++ b/i386/libsaio/efi.c @@ -28,20 +28,32 @@ * * Updates: * - * - STATIC_MODEL_NAME moved over from settings.h (PikerAlpha, October 2012). - * - STATIC_MODEL_NAME renamed to EFI_MODEL_NAME (PikerAlpha, October 2012). - * - Now no longer includes platform.h (PikerAlpha, October 2012). + * - STATIC_MODEL_NAME moved over from settings.h (Pike R. Alpha, October 2012). + * - STATIC_MODEL_NAME renamed to EFI_MODEL_NAME (Pike R. Alpha, October 2012). + * - Now no longer includes platform.h (Pike R. Alpha, October 2012). + * - Data selector moved over from RevoBoot/i386/config/data.h (Pike R. Alpha, October 2012). + * - Get static EFI data (optional) from /Extra/EFI/[MacModelNN].bin (Pike R. Alpha, October 2012). + * - STATIC_SYSTEM_SERIAL_NUMBER renamed to EFI_SYSTEM_SERIAL_NUMBER (Pike R. Alpha, October 2012). + * - Check return of malloc call (Pike R. Alpha, November 2012). + * - Sam's workaround for iMessage breakage added (Pike R. Alpha, January 2013). * */ - #include "efi/fake_efi.h" -#define INCLUDE_EFI_DATA 1 +//============================================================================== -#include "../config/data.h" +EFI_UINT32 getCPUTick(void) +{ + uint32_t value = 0; + + __asm__ volatile("rdtsc" : "=A" (value)); + + return value; +} //============================================================================== +// Called from RevoBoot/i386/libsaio/platform.c void initEFITree(void) { @@ -49,9 +61,9 @@ void initEFITree(void) static char ACPI[] = "ACPI"; - // The required information should be added to private_data.h + // The information from RevoBoot/i386/libsaio/SMBIOS/model_data.h is used here. static EFI_CHAR16 const MODEL_NAME[] = EFI_MODEL_NAME; - static EFI_CHAR16 const SYSTEM_SERIAL_NUMBER[] = STATIC_SYSTEM_SERIAL_NUMBER; + static EFI_CHAR16 const SYSTEM_SERIAL_NUMBER[] = EFI_SYSTEM_SERIAL_NUMBER; DT__Initialize(); // Add and initialize gPlatform.DT.RootNode @@ -63,6 +75,7 @@ void initEFITree(void) DT__AddProperty(gPlatform.DT.RootNode, "model", 5, ACPI); DT__AddProperty(gPlatform.DT.RootNode, "compatible", 5, ACPI); + // DT__AddProperty(gPlatform.DT.RootNode, "has-safe-sleep", 1, 0); Node * efiNode = DT__AddChild(gPlatform.DT.RootNode, "efi"); @@ -85,11 +98,38 @@ void initEFITree(void) // Satisfying AppleACPIPlatform.kext static EFI_UINT8 const DEVICE_PATHS_SUPPORTED[] = { 0x01, 0x00, 0x00, 0x00 }; + DT__AddProperty(platformNode, "device-colors", sizeof(DEVICE_PATHS_SUPPORTED), (EFI_UINT8*) &DEVICE_PATHS_SUPPORTED); + DT__AddProperty(platformNode, "DevicePathsSupported", sizeof(DEVICE_PATHS_SUPPORTED), (EFI_UINT8*) &DEVICE_PATHS_SUPPORTED); // The use of sizeof() here is mandatory (to prevent breakage). DT__AddProperty(platformNode, "Model", sizeof(MODEL_NAME), (EFI_CHAR16*) MODEL_NAME); + + // Satisfying X86PlatformPlugin.kext + static EFI_UINT8 const STARTUP_POWER_EVENTS[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + /* + * IOPPF - IODeviceTree:/efi/platform/StartupPowerEvents: [value below] + * 0x01 = Shutdown cause was a PWROK event (Same as GEN_PMCON_2 bit 0) + * 0x02 = Shutdown cause was a SYS_PWROK event (Same as GEN_PMCON_2 bit 1) + * 0x04 = Shutdown cause was a THRMTRIP# event (Same as GEN_PMCON_2 bit 3) + * 0x08 = Rebooted due to a SYS_RESET# event (Same as GEN_PMCON_2 bit 4) + * 0x10 = Power Failure (Same as GEN_PMCON_3 bit 1 PWR_FLR) + * 0x20 = Loss of RTC Well Power (Same as GEN_PMCON_3 bit 2 RTC_PWR_STS) + * 0x40 = General Reset Status (Same as GEN_PMCON_3 bit 9 GEN_RST_STS) + * 0xffffff80 = SUS Well Power Loss (Same as GEN_PMCON_3 bit 14) + * 0x10000 = Wake cause was a ME Wake event (Same as PRSTS bit 0, ME_WAKE_STS) + * 0x20000 = Cold Reboot was ME Induced event (Same as PRSTS bit 1 ME_HRST_COLD_STS) = { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 }; + * 0x40000 = Warm Reboot was ME Induced event (Same as PRSTS bit 2 ME_HRST_WARM_STS) + * 0x80000 = Shutdown was ME Induced event (Same as PRSTS bit 3 ME_HOST_PWRDN) + * 0x100000 = Global reset ME Wachdog Timer event (Same as PRSTS bit 6) + * 0x200000 = Global reset PowerManagment Wachdog Timer event (Same as PRSTS bit 15) + */ + + DT__AddProperty(platformNode, "StartupPowerEvents", sizeof(STARTUP_POWER_EVENTS), (EFI_UINT8*) &STARTUP_POWER_EVENTS); + DT__AddProperty(platformNode, "InitialTSC", sizeof(uint64_t), &gPlatform.CPU.TSCFrequency); DT__AddProperty(platformNode, "SystemSerialNumber", sizeof(SYSTEM_SERIAL_NUMBER), (EFI_CHAR16*) SYSTEM_SERIAL_NUMBER); + // DT__AddProperty(platformNode, "nv-edid", sizeof(EFI_UINT8), (EFI_CHAR8*) 0); if (gPlatform.CPU.FSBFrequency) { @@ -97,8 +137,13 @@ void initEFITree(void) DT__AddProperty(platformNode, "FSBFrequency", sizeof(uint64_t), &gPlatform.CPU.FSBFrequency); } - Node * chosenNode = DT__AddChild(gPlatform.DT.RootNode, "chosen"); + if (gPlatform.CPU.ARTFrequency) + { + DT__AddProperty(platformNode, "ARTFrequency", sizeof(uint64_t), &gPlatform.CPU.ARTFrequency); + } + Node * chosenNode = DT__AddChild(gPlatform.DT.RootNode, "chosen"); + if (chosenNode == 0) { stop("Couldn't create /chosen node"); // Mimics boot.efi @@ -136,16 +181,13 @@ void initEFITree(void) }; DT__AddProperty(chosenNode, "boot-file-path", sizeof(BOOT_FILE_PATH), (EFI_UINT8*) &BOOT_FILE_PATH); - - static EFI_UINT8 const BOOT_ARGS[] = { 0x00 }; - - DT__AddProperty(chosenNode, "boot-args", sizeof(BOOT_ARGS), (EFI_UINT8*) &BOOT_ARGS); - + DT__AddProperty(chosenNode, "boot-args", sizeof(bootArgs->CommandLine), (EFI_UINT8*)bootArgs->CommandLine); + /* Adding kIOHibernateMachineSignatureKey (IOHibernatePrivate.h). * * This 'Hardware Signature' (offset 8 in the FACS table) is calculated by the BIOS on a best effort * basis to indicate the base hardware configuration of the system such that different base hardware - * configurations can have different hardware signature values. OSPM uses this information in waking + * configurations can have different hardware signature values. OSPM uses this information in waking * from an S4 state, by comparing the current hardware signature to the signature values saved in the * non-volatile sleep image. If the values are not the same, OSPM assumes that the saved non-volatile * image is from a different hardware configuration and cannot be restored. @@ -155,150 +197,170 @@ void initEFITree(void) DT__AddProperty(chosenNode, "machine-signature", sizeof(MACHINE_SIGNATURE), (EFI_UINT8*) &MACHINE_SIGNATURE); -#if ((MAKE_TARGET_OS & LION) == LION) +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // El Capitan and Yosemite + UInt8 index = 0; + + uint64_t randomValue = 0; + uint64_t cpuTick = 0; + + EFI_UINT16 PMTimerValue = 0; + + EFI_UINT32 ecx, esi, edi = 0; + EFI_UINT32 rcx, rdx, rdi, rsi = 0; + + ecx = 0; // xor %ecx, %ecx + + // LEAF_1 - Feature Information (Function 01h). + if (gPlatform.CPU.ID[LEAF_1][2] & 0x40000000) // Checking ecx:bit-30 + { + EFI_UINT32 seedBuffer[16] = {0}; + // + // Main loop to get 16 qwords (four bytes each). + // + for (index = 0; index < 16; index++) // 0x17e12: + { + randomValue = computeRand(); // callq 0x18e20 + cpuTick = getCPUTick(); // callq 0x121a7 + randomValue = (randomValue ^ cpuTick); // xor %rdi, %rax + seedBuffer[index] = randomValue; // mov %rax,(%r15,%rsi,8) + } // jb 0x17e12 + + DT__AddProperty(chosenNode, "random-seed", sizeof(seedBuffer), (EFI_UINT32*) &seedBuffer); + } + else + { + EFI_UINT8 seedBufferAlternative[64]; + bzero(seedBufferAlternative, 64); + // + // Main loop to get the 64 bytes. + // + do // 0x17e55: + { + PMTimerValue = inw(0x408); // in (%dx), %ax + esi = PMTimerValue; // movzwl %ax, %esi + + if (esi < ecx) // cmp %ecx, %esi + { + continue; // jb 0x17e55 (retry) + } + + cpuTick = getCPUTick(); // callq 0x121a7 + rcx = (cpuTick >> 8); // mov %rax, %rcx + // shr $0x8, %rcx + rdx = (cpuTick >> 10); // mov %rax, %rdx + // shr $0x10, %rdx + rdi = rsi; // mov %rsi, %rdi + rdi = (rdi ^ cpuTick); // xor %rax, %rdi + rdi = (rdi ^ rcx); // xor %rcx, %rdi + rdi = (rdi ^ rdx); // xor %rdx, %rdi + + seedBufferAlternative[index] = (rdi & 0xff); // mov %dil, (%r15,%r12,1) + + edi = (edi & 0x2f); // and $0x2f, %edi + edi = (edi + esi); // add %esi, %edi + index++; // inc r12 + ecx = (edi & 0xffff); // movzwl %di, %ecx + + } while (index < 64); // cmp %r14d, %r12d + // jne 0x17e55 (next) + + DT__AddProperty(chosenNode, "random-seed", sizeof(seedBufferAlternative), (EFI_UINT8*) &seedBufferAlternative); + } + + static EFI_UINT8 const booterName[] = + { + 0x62, 0x6f, 0x6f, 0x74, 0x2e, 0x65, 0x66, 0x69, 0x00 + }; + + DT__AddProperty(chosenNode, "booter-name", sizeof(booterName), (EFI_UINT8*) &booterName); + + static EFI_UINT8 const booterVersion[] = + { + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x33, 0x32, 0x34, 0x2e, 0x33, 0x30, 0x2e, 0x32, 0x00 + }; + + DT__AddProperty(chosenNode, "booter-version", sizeof(booterVersion), (EFI_UINT8*) &booterVersion); + + static EFI_UINT8 const booterBuildTime[] = + { + 0x54, 0x68, 0x75, 0x20, 0x4E, 0x6F, 0x76, 0x20, 0x31, 0x30, 0x20, 0x31, 0x35, 0x3A, 0x34, 0x33, 0x3A, + 0x32, 0x38, 0x20, 0x50, 0x53, 0x54, 0x20, 0x32, 0x30, 0x31, 0x36, 0x00 + }; + + DT__AddProperty(chosenNode, "booter-build-time", sizeof(booterBuildTime), (EFI_UINT8*) &booterBuildTime); +#endif + +#if ((MAKE_TARGET_OS & LION) == LION) // El Capitan, Yosemite, Mavericks and Mountain Lion also have bit 1 set like Lion. // Used by boot.efi - cosmetic only node/properties on hacks. Node * kernelCompatNode = DT__AddChild(efiNode, "kernel-compatibility"); static EFI_UINT8 const COMPAT_MODE[] = { 0x01, 0x00, 0x00, 0x00 }; - DT__AddProperty(kernelCompatNode, "i386", sizeof(COMPAT_MODE), (EFI_UINT8*) &COMPAT_MODE); - DT__AddProperty(kernelCompatNode, "x86_64", sizeof(COMPAT_MODE), (EFI_UINT8*) &COMPAT_MODE); + #if ((MAKE_TARGET_OS & MAVERICKS) == MAVERICKS) // El Capitan, Yosemite and Mavericks. + DT__AddProperty(kernelCompatNode, "x86_64", sizeof(COMPAT_MODE), (EFI_UINT8*) &COMPAT_MODE); + #else + DT__AddProperty(kernelCompatNode, "i386", sizeof(COMPAT_MODE), (EFI_UINT8*) &COMPAT_MODE); + DT__AddProperty(kernelCompatNode, "x86_64", sizeof(COMPAT_MODE), (EFI_UINT8*) &COMPAT_MODE); + #endif #endif - // Adding the options node breaks AppleEFINVRAM (missing hardware UUID). // Node *optionsNode = DT__AddChild(gPlatform.DT.RootNode, "options"); // DT__AddProperty(optionsNode, "EFICapsuleResult", 4, "STAR"); // 53 54 41 52 - #endif - // DT__AddProperty(chosenNode, "boot-kernelcache-adler32", sizeof(uint64_t), adler32); - gPlatform.EFI.Nodes.Chosen = chosenNode; #if INJECT_EFI_DEVICE_PROPERTIES + _EFI_DEBUG_DUMP("Injecting static EFI device-properties\n"); - static EFI_UINT8 const EFI_DEVICE_PROPERTIES[] = - { - STATIC_EFI_DEVICE_PROPERTIES - }; + #if LOAD_MODEL_SPECIFIC_EFI_DATA + char dirSpec[32] = ""; + sprintf(dirSpec, "/Extra/EFI/%s.bin", gPlatform.CommaLessModelID); - _EFI_DEBUG_DUMP("Injecting EFI device-properties\n"); + _EFI_DEBUG_DUMP("Loading: %s\n", dirSpec); - DT__AddProperty(efiNode, "device-properties", sizeof(EFI_DEVICE_PROPERTIES), (EFI_CHAR8*) &EFI_DEVICE_PROPERTIES); -#endif + void * staticEFIData = (void *)kLoadAddr; - _EFI_DEBUG_DUMP("Exiting initEFITree()\n"); - _EFI_DEBUG_SLEEP(5); -} - - -#if UNUSED_EFI_CODE -//============================================================================== + long fileSize = loadBinaryData(dirSpec, &staticEFIData); -void *convertHexStr2Binary(const char *hexStr, int *outLength) -{ - int len; - char hexNibble; - char hexByte[2]; - uint8_t binChar; - uint8_t *binStr; - int hexStrIdx, binStrIdx, hexNibbleIdx; - - len = strlen(hexStr); - - if (len > 1) - { - // the resulting binary will be the half size of the input hex string - binStr = malloc(len / 2); - binStrIdx = 0; - hexNibbleIdx = 0; - - for (hexStrIdx = 0; hexStrIdx < len; hexStrIdx++) + if (fileSize > 0) { - hexNibble = hexStr[hexStrIdx]; - - // ignore all chars except valid hex numbers - if ((hexNibble >= '0' && hexNibble <= '9') || (hexNibble >= 'A' && hexNibble <= 'F') || (hexNibble >= 'a' && hexNibble <= 'f')) - { - hexByte[hexNibbleIdx++] = hexNibble; - - // found both two nibbles, convert to binary - if (hexNibbleIdx == 2) - { - binChar = 0; - - for (hexNibbleIdx = 0; hexNibbleIdx < sizeof(hexByte); hexNibbleIdx++) - { - if (hexNibbleIdx > 0) - { - binChar = binChar << 4; - } - - if (hexByte[hexNibbleIdx] <= '9') - { - binChar += hexByte[hexNibbleIdx] - '0'; - } - else if (hexByte[hexNibbleIdx] <= 'F') - { - binChar += hexByte[hexNibbleIdx] - ('A' - 10); - } - else if (hexByte[hexNibbleIdx] <= 'f') - { - binChar += hexByte[hexNibbleIdx] - ('a' - 10); - } - } - - binStr[binStrIdx++] = binChar; - hexNibbleIdx = 0; - } - } + DT__AddProperty(efiNode, "device-properties", fileSize, (EFI_CHAR8*) staticEFIData); } - *outLength = binStrIdx; - return binStr; - } - else - { - *outLength = 0; - return NULL; - } -} -//============================================================================== - - -static EFI_UINT32* getUUIDFromString(const char * givenUUID) // Patch by: rekursor (rewrite by Master Chief). -{ - if (givenUUID) // Sanity check. - { - static char errStr[] = "getUUIDFromString: Invalid SystemID - "; - - if (strlen(givenUUID) == 36) // Real UUID's only please. + else // No model specific data found. Use static EFI data from RevoBoot/i386/config/EFI { - int size = 0; - char szUUID[37]; // 0-35 (36) + 1 - char *p = szUUID; - - while (*givenUUID) { - if (*givenUUID != '-') - *p++ = *givenUUID++; - else - givenUUID++; - } - *p = '\0'; - void* binaryString = convertHexStr2Binary(szUUID, &size); + // useStaticEFIProperties(efiNode); + // The STRING (macro) is defined in RevoBoot/i386/config/settings.h + #include STRING(EFI_DATA_FILE) - if (binaryString && size == 16) - return (EFI_UINT32*) binaryString; + static EFI_UINT8 const EFI_DEVICE_PROPERTIES[] = + { + // Replaced with data from: RevoBoot/i386/config/EFI/[data-template/MacModelNN].h + STATIC_EFI_DEVICE_PROPERTIES + }; - verbose("%swrong format maybe?\n", errStr); + DT__AddProperty(efiNode, "device-properties", sizeof(EFI_DEVICE_PROPERTIES), (EFI_CHAR8*) &EFI_DEVICE_PROPERTIES); } - else - verbose("%slength should be 36.\n", errStr); - } - return (EFI_UINT32*) 0; -} + #else + // The STRING (macro) is defined in RevoBoot/i386/config/settings.h + #include STRING(EFI_DATA_FILE) + + static EFI_UINT8 const EFI_DEVICE_PROPERTIES[] = + { + // Replaced with data from: RevoBoot/i386/config/EFI/[data-template/MacModelNN].h + STATIC_EFI_DEVICE_PROPERTIES + }; + + DT__AddProperty(efiNode, "device-properties", sizeof(EFI_DEVICE_PROPERTIES), (EFI_CHAR8*) &EFI_DEVICE_PROPERTIES); + #endif #endif + _EFI_DEBUG_DUMP("Exiting initEFITree()\n"); + _EFI_DEBUG_SLEEP(5); +} + + //============================================================================== // Stage two EFI initialization (after getting data from com.apple.Boot.plist). @@ -306,37 +368,14 @@ void updateEFITree(char *rootUUID) { _EFI_DEBUG_DUMP("In updateEFITree(%s)\n", rootUUID); - static EFI_CHAR8 const SYSTEM_ID[] = STATIC_SYSTEM_ID; - - // This is your hardcoded SYSTEM_ID (see: config/settings.h). - EFI_UINT32 * targetUUID = (EFI_UINT32 *) &SYSTEM_ID; - -#if UNUSED_EFI_CODE - // Feature to set your own, uuidgen generated string in com.apple.Boot.plist - // Note: Unsupported feature in Revolution (you need to compile it anyway). - - const char* userDefinedUUID = newStringForKey("SystemID", &bootInfo->bootConfig); - - if (userDefinedUUID) + // Only accept a UUID with the correct length. + if (strlen(rootUUID) == 36) { - targetUUID = getUUIDFromString(userDefinedUUID); - - if (targetUUID) - { - _EFI_DEBUG_DUMP("Customizing SystemID with: %s\n", userDefinedUUID); - } - - free ((void*) userDefinedUUID); + _EFI_DEBUG_DUMP("Initializing property boot-uuid (%s)\n", rootUUID); + + DT__AddProperty(gPlatform.EFI.Nodes.Chosen, "boot-uuid", 37, rootUUID); } -#endif - - DT__AddProperty(gPlatform.EFI.Nodes.Platform, "system-id", 16, targetUUID); - // gPlatform.EFI.Nodes.Platform = NULL; - - setRootUUID(gPlatform.EFI.Nodes.Chosen, rootUUID); - // gPlatform.EFI.Nodes.Chosen = NULL; - /* * Check the architectures' target (boot) mode against the chosen setting of * EFI_64_BIT, which may not fit well and throw the dreadful @@ -354,25 +393,6 @@ void updateEFITree(char *rootUUID) } -//============================================================================== -// Called from initEFITree() and execKernel() in boot.c - -bool setRootUUID(Node *chosenNode, char *rootUUID) -{ - // Only accept a UUID with the correct length. - if (strlen(rootUUID) == 36) - { - _EFI_DEBUG_DUMP("Initializing property boot-uuid (%s)\n", rootUUID); - - DT__AddProperty(chosenNode, "boot-uuid", 37, rootUUID); - - return 0; - } - - return -1; -} - - #if INCLUDE_MPS_TABLE //============================================================================== @@ -417,20 +437,56 @@ bool initMultiProcessorTableAdress(void) //============================================================================== // Called from execKernel() in boot.c -void finalizeEFITree(void) +void finalizeEFITree(EFI_UINT32 kernelAdler32) { - _EFI_DEBUG_DUMP("Calling setupEFITables("); + _EFI_DEBUG_DUMP("Calling setupEFITables()\n"); setupEFITables(); - _EFI_DEBUG_DUMP("done).\nCalling setupSMBIOS("); + _EFI_DEBUG_DUMP("Add property: boot-kernelcache-adler32 = %d\n", kernelAdler32); + DT__AddProperty(gPlatform.EFI.Nodes.Chosen, "boot-kernelcache-adler32", sizeof(EFI_UINT32), (EFI_UINT32*)kernelAdler32); + _EFI_DEBUG_DUMP("Calling setupSMBIOS()\n"); setupSMBIOS(); - _EFI_DEBUG_DUMP("done).\nAdding EFI configuration table for SMBIOS("); + _EFI_DEBUG_DUMP("Adding EFI configuration table for SMBIOS("); addConfigurationTable(&gPlatform.SMBIOS.Guid, &gPlatform.SMBIOS.BaseAddress, NULL); +#ifdef SMB_STATIC_SYSTEM_UUID + // Static UUID from: RevoBoot/i386/config/SETTINGS/MacModelNN.h + static EFI_CHAR8 const SYSTEM_ID[] = SMB_STATIC_SYSTEM_UUID; + + DT__AddProperty(gPlatform.EFI.Nodes.Platform, "system-id", 16, (EFI_CHAR8 *) &SYSTEM_ID); +#else + // gPlatform.UUID is set in: RevoBoot/i386/libsaio/SMBIOS/[dynamic/static]_data.h + DT__AddProperty(gPlatform.EFI.Nodes.Platform, "system-id", 16, (EFI_CHAR8 *)gPlatform.UUID); +#endif + + // + // Start of experimental code + // + Node *revoEFINode = DT__AddChild(gPlatform.DT.RootNode, "RevoEFI"); + +#ifdef STATIC_NVRAM_ROM + static EFI_UINT8 const NVRAM_ROM_DATA[] = STATIC_NVRAM_ROM; +#else + #ifdef SMB_STATIC_SYSTEM_UIID + static EFI_UINT8 const NVRAM_ROM_DATA[] = SMB_STATIC_SYSTEM_UUID; + #else + static EFI_UINT8 const NVRAM_ROM_DATA[] = gPlatform.UUID; + #endif +#endif + + DT__AddProperty(revoEFINode, "NVRAM:ROM", sizeof(NVRAM_ROM_DATA), (EFI_UINT8 *) &NVRAM_ROM_DATA); + + static EFI_UINT8 const NVRAM_MLB_DATA[] = STATIC_NVRAM_MLB; + DT__AddProperty(revoEFINode, "NVRAM:MLB", sizeof(NVRAM_MLB_DATA), (EFI_UINT8 *) &NVRAM_MLB_DATA); + + // + // End of experimental code + // + #if INCLUDE_MPS_TABLE // This BIOS includes a MP table? if (initMultiProcessorTableAdress()) diff --git a/i386/libsaio/efi/EfiError.h b/i386/libsaio/efi/EfiError.h new file mode 100644 index 0000000..5e15e1a --- /dev/null +++ b/i386/libsaio/efi/EfiError.h @@ -0,0 +1,70 @@ +/*++ + +Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiError.h + +Abstract: + + EFI error levels and their associated defines + +--*/ + +#ifndef _EFI_ERROR_H_ +#define _EFI_ERROR_H_ + +// +// Set the upper bit to indicate EFI Error. +// +#define EFIERR(a) (EFI_MAX_BIT | (a)) + +#define EFIWARN(a) (a) +#define EFI_ERROR(a) (((INTN) (a)) < 0) + +#define EFI_SUCCESS 0 +#define EFI_LOAD_ERROR EFIERR (1) +#define EFI_INVALID_PARAMETER EFIERR (2) +#define EFI_UNSUPPORTED EFIERR (3) +#define EFI_BAD_BUFFER_SIZE EFIERR (4) +#define EFI_BUFFER_TOO_SMALL EFIERR (5) +#define EFI_NOT_READY EFIERR (6) +#define EFI_DEVICE_ERROR EFIERR (7) +#define EFI_WRITE_PROTECTED EFIERR (8) +#define EFI_OUT_OF_RESOURCES EFIERR (9) +#define EFI_VOLUME_CORRUPTED EFIERR (10) +#define EFI_VOLUME_FULL EFIERR (11) +#define EFI_NO_MEDIA EFIERR (12) +#define EFI_MEDIA_CHANGED EFIERR (13) +#define EFI_NOT_FOUND EFIERR (14) +#define EFI_ACCESS_DENIED EFIERR (15) +#define EFI_NO_RESPONSE EFIERR (16) +#define EFI_NO_MAPPING EFIERR (17) +#define EFI_TIMEOUT EFIERR (18) +#define EFI_NOT_STARTED EFIERR (19) +#define EFI_ALREADY_STARTED EFIERR (20) +#define EFI_ABORTED EFIERR (21) +#define EFI_ICMP_ERROR EFIERR (22) +#define EFI_TFTP_ERROR EFIERR (23) +#define EFI_PROTOCOL_ERROR EFIERR (24) +#define EFI_INCOMPATIBLE_VERSION EFIERR (25) +#define EFI_SECURITY_VIOLATION EFIERR (26) +#define EFI_CRC_ERROR EFIERR (27) +#define EFI_END_OF_MEDIA EFIERR (28) +#define EFI_END_OF_FILE EFIERR (31) +#define EFI_INVALID_LANGUAGE EFIERR (32) + +#define EFI_WARN_UNKNOWN_GLYPH EFIWARN (1) +#define EFI_WARN_DELETE_FAILURE EFIWARN (2) +#define EFI_WARN_WRITE_FAILURE EFIWARN (3) +#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN (4) + +#endif diff --git a/i386/libsaio/efi/efi.h b/i386/libsaio/efi/efi.h index 01422c4..c19c789 100755 --- a/i386/libsaio/efi/efi.h +++ b/i386/libsaio/efi/efi.h @@ -29,18 +29,33 @@ #ifndef _LIBSAIO_EFI_EFI_H #define _LIBSAIO_EFI_EFI_H +/// +/// 32/64-bit native width with the highest bit set. +/// +#if EFI_64_BIT + #define EFI_MAX_BIT 0x8000000000000000ULL +#else + #define EFI_MAX_BIT 0x80000000 +#endif + +#include "EfiError.h" // Set up space for up to 5 tables but we currently only add two. #define EFI_MAX_CONFIG_TABLES 5 -#define EFI_MAX_BIT 0x80000000 - -// Set the upper bit to indicate EFI Error. -#define EFIERR(a) (EFI_MAX_BIT | (a)) - -#define EFI_SUCCESS 0 -#define EFI_INVALID_PARAMETER EFIERR (2) -#define EFI_UNSUPPORTED EFIERR (3) +#if EFI_64_BIT + // Mountain Lion, Mavericks and Yosemite + // + // movabs $0x8000000000000003,%rax + // ret + static uint8_t const UNSUPPORTEDRET_INSTRUCTIONS[] = { 0x48, 0xb8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc3 }; +#else + // Lion, Snow Leopard and Leopard + // + // movl $0x80000003,%eax + // ret + static uint8_t const UNSUPPORTEDRET_INSTRUCTIONS[] = { 0xb8, 0x03, 0x00, 0x00, 0x80, 0xc3 }; +#endif // EFI Revision info. // diff --git a/i386/libsaio/efi/essentials.h b/i386/libsaio/efi/essentials.h index 001d181..e82986f 100755 --- a/i386/libsaio/efi/essentials.h +++ b/i386/libsaio/efi/essentials.h @@ -24,13 +24,19 @@ * EFI implementation for Revolution Copyright (c) 2010 by DHP. * All rights reserved. * + * Updates: + * - Stand alone support for base64.c added (PikerAlpha, November 2012). + * */ #ifndef __LIBSAIO_EFI_ESSENTIALS_H #define __LIBSAIO_EFI_ESSENTIALS_H -// #include "../config/settings.h" -#include "../boot2/debug.h" + +#ifdef TARGET_MODEL + #include "../boot2/debug.h" +#endif + typedef void VOID; @@ -183,6 +189,89 @@ typedef struct // 0x02 - GUID signature. // EFI_UINT8 SignatureType; -} EFI_BOOT_DEVICE_PATH; // HARDDRIVE_DEVICE_PATH +} HARDDRIVE_DEVICE_PATH; + + +/* + * Stuff from EDK2's EfiDevicePath.h + */ + +// +// Networking Definitions +// + +typedef struct +{ + EFI_UINT8 Addr[4]; +} EFI_IPv4_ADDRESS; + +typedef struct +{ + EFI_UINT8 Addr[16]; +} EFI_IPv6_ADDRESS; + +typedef struct +{ + EFI_UINT8 Addr[32]; +} EFI_MAC_ADDRESS; + +typedef struct +{ + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_UINT16 HBAPortNumber; + EFI_UINT16 PortMultiplierPortNumber; + EFI_UINT16 Lun; +} SATA_DEVICE_PATH; + +typedef struct +{ + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_MAC_ADDRESS MacAddress; + EFI_UINT8 IfType; +} MAC_ADDR_DEVICE_PATH; + +typedef struct +{ + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_IPv4_ADDRESS LocalIpAddress; + EFI_IPv4_ADDRESS RemoteIpAddress; + EFI_UINT16 LocalPort; + EFI_UINT16 RemotePort; + EFI_UINT16 Protocol; + EFI_BOOLEAN StaticIpAddress; +} IPv4_DEVICE_PATH; + +typedef struct +{ + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_IPv6_ADDRESS LocalIpAddress; + EFI_IPv6_ADDRESS RemoteIpAddress; + EFI_UINT16 LocalPort; + EFI_UINT16 RemotePort; + EFI_UINT16 Protocol; + EFI_BOOLEAN StaticIpAddress; +} IPv6_DEVICE_PATH; + + +#define MSG_SATA_DP 0x12 +#define MSG_MAC_ADDR_DP 0x0b +#define MSG_IPv4_DP 0x0c +#define MSG_IPv6_DP 0x0d + +#define MEDIA_HARDDRIVE_DP 0x01 +#define MEDIA_DEVICE_PATH 0x04 + +#define SIGNATURE_TYPE_MBR 0x01 +#define SIGNATURE_TYPE_GUID 0x02 + +#define END_DEVICE_PATH_TYPE 0x7f +#define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff +#define EFI_DP_TYPE_MASK 0x7f + +#define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK ) +#define DevicePathSubType(a) ( (a)->SubType ) +#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE ) +#define DevicePathNodeLength(a) ( ((a)->Length[0]) | ((a)->Length[1] << 8) ) +#define NextDevicePathNode(a) ( (EFI_DEVICE_PATH_PROTOCOL *) ( ((EFI_INT8 *) (a)) + DevicePathNodeLength(a))) #endif /* !__LIBSAIO_EFI_ESSENTIALS_H */ diff --git a/i386/libsaio/efi/fake_efi.h b/i386/libsaio/efi/fake_efi.h index bfa1bff..3a4f6ac 100755 --- a/i386/libsaio/efi/fake_efi.h +++ b/i386/libsaio/efi/fake_efi.h @@ -27,16 +27,17 @@ * EFI implementation for Revolution Copyright (c) 2010 by DHP. * All rights reserved. * + * Updates: + * - Check malloc return (PikerAlpha, November 2012). + * */ -#include "bootstruct.h" // For bootArgs. -#include "efi_tables.h" +#include "bootstruct.h" // For bootArgs. //------------------------------------------------------------------------------ extern void setupACPI(void); extern void setupSMBIOS(void); -extern bool setRootUUID(Node *chosenNode, char * rootUUID); //------------------------------------------------------------------------------ @@ -54,14 +55,19 @@ static EFI_UINT32 const FIRMWARE_REVISION = EFI_SYSTEM_TABLE_REVISION; //============================================================================== // Utility function to make a device tree string from an EFI_GUID -static inline char * mallocStringForGuid(EFI_GUID const *pGuid) +static inline char * mallocStringForGuid(EFI_GUID const *aGuid) { - char *string = malloc(37); - efi_guid_unparse_upper(pGuid, string); + char *string = NULL; - return string; -} + convertEFIGUIDToString(aGuid, &string); + + if (string) + { + return string; + } + return NULL; +} //============================================================================== // Function to map a 32-bit address to a 64-bit address, or it simply returns @@ -113,12 +119,13 @@ extern EFI_STATUS addConfigurationTable(EFI_GUID const *pGuid, void * table, cha { DT__AddProperty(tableNode, "alias", strlen(tableAlias) + 1, (char *)tableAlias); } + + gPlatform.EFI.SystemTable->NumberOfTableEntries++; } return EFI_SUCCESS; } - //============================================================================== // Allocate fake EFI system / runtime services table. @@ -127,9 +134,6 @@ void setupEFITables(void) // return instruction. static uint8_t const VOIDRET_INSTRUCTIONS[] = { 0xc3 }; - // movl $0x80000003,%eax; ret - static uint8_t const UNSUPPORTEDRET_INSTRUCTIONS[] = { 0xb8, 0x03, 0x00, 0x00, 0x80, 0xc3 }; - // Occupying a single 4 KB memory block (wired page) to prevent multiple smaller allocations. struct EFI_Container { @@ -238,7 +242,7 @@ void setupEFITables(void) * things like efiRuntimeServices* and what not. * * In fact, the only code that seems to use that is the hibernate code so it - * knows not to save the pages. It even checks to make sure its nonzero. + * knows not to save the pages. It even checks to make sure that it is non-zero. */ bootArgs->efiSystemTable = (uint32_t)efiSystemTable; diff --git a/i386/libsaio/fdisk.h b/i386/libsaio/fdisk.h index 9c51847..a6634cd 100755 --- a/i386/libsaio/fdisk.h +++ b/i386/libsaio/fdisk.h @@ -28,62 +28,62 @@ * * HISTORY * - * 8 July 1992 David E. Bohman at NeXT - * Created. + * 8 July 1992 David E. Bohman at NeXT Created. + * + * Updates: + * - Spaces replaced with tabs (PikerAlpha, November 2012) + * - Unused 'REAL_disk_blk0' removed (PikerAlpha, November 2012) + * */ - + + #ifndef __LIBSAIO_FDISK_H #define __LIBSAIO_FDISK_H -#define DISK_BLK0 0 /* blkno of boot block */ -#define DISK_BLK0SZ 512 /* size of boot block */ -#define DISK_BOOTSZ 446 /* size of boot code in boot block */ -#define DISK_SIGNATURE 0xAA55 /* signature of the boot record */ -#define FDISK_NPART 4 /* number of entries in fdisk table */ -#define FDISK_ACTIVE 0x80 /* indicator of active partition */ -#define FDISK_NEXTNAME 0xA7 /* indicator of NeXT partition */ -#define FDISK_DOS12 0x01 /* 12-bit fat < 10MB dos partition */ -#define FDISK_DOS16S 0x04 /* 16-bit fat < 32MB dos partition */ -#define FDISK_DOSEXT 0x05 /* extended dos partition */ -#define FDISK_DOS16B 0x06 /* 16-bit fat >= 32MB dos partition */ -#define FDISK_NTFS 0x07 /* NTFS partition */ -#define FDISK_SMALLFAT32 0x0b /* FAT32 partition */ -#define FDISK_FAT32 0x0c /* FAT32 partition */ +#define DISK_BLK0 0 // Block number of boot block +#define DISK_BLK0SZ 512 // Size of boot block +#define DISK_BOOTSZ 446 // Size of boot code in boot block +#define DISK_SIGNATURE 0xAA55 // signature of the boot record +#define FDISK_NPART 4 // Number of entries in fdisk table +#define FDISK_ACTIVE 0x80 // Indicator of active partition +#define FDISK_NEXTNAME 0xA7 // Indicator of NeXT partition +#define FDISK_DOS12 0x01 // 12-bit fat < 10MB dos partition +#define FDISK_DOS16S 0x04 // 16-bit fat < 32MB dos partition +#define FDISK_DOSEXT 0x05 // Extended DOS partition +#define FDISK_DOS16B 0x06 // 16-bit fat >= 32MB dos partition +#define FDISK_NTFS 0x07 // NTFS partition +#define FDISK_SMALLFAT32 0x0b // FAT32 partition +#define FDISK_FAT32 0x0c // FAT32 partition #define FDISK_DOS16SLBA 0x0e #define FDISK_LINUX 0x83 -#define FDISK_UFS 0xa8 /* Apple UFS partition */ -#define FDISK_HFS 0xaf /* Apple HFS partition */ -#define FDISK_BOOTER 0xab /* Apple booter partition */ +#define FDISK_UFS 0xa8 // Apple UFS partition +#define FDISK_HFS 0xaf // Apple HFS partition +#define FDISK_BOOTER 0xab // Apple booter partition -/* - * Format of fdisk partion entry (if present). - */ -struct fdisk_part { - unsigned char bootid; /* bootable or not */ - unsigned char beghead; /* begining head, sector, cylinder */ - unsigned char begsect; /* begcyl is a 10-bit number */ - unsigned char begcyl; /* High 2 bits are in begsect */ - unsigned char systid; /* OS type */ - unsigned char endhead; /* ending head, sector, cylinder */ - unsigned char endsect; /* endcyl is a 10-bit number */ - unsigned char endcyl; /* High 2 bits are in endsect */ - unsigned long relsect; /* partion physical offset on disk */ - unsigned long numsect; /* number of sectors in partition */ +// Format of fdisk partion entry (if present). + +struct fdisk_part +{ + unsigned char bootid; // Bootable or not + unsigned char beghead; // Begining head, sector, cylinder + unsigned char begsect; // Beginning cylinder is a 10-bit number + unsigned char begcyl; // High 2 bits are in begsect + unsigned char systid; // OS type + unsigned char endhead; // Ending head, sector, cylinder + unsigned char endsect; // Endcyl is a 10-bit number + unsigned char endcyl; // High 2 bits are in endsect + unsigned long relsect; // Partion physical offset on disk + unsigned long numsect; // Number of sectors in partition } __attribute__((packed)); -/* - * Format of boot block. - */ -struct disk_blk0 { - unsigned char bootcode[DISK_BOOTSZ]; - unsigned char parts[FDISK_NPART][sizeof (struct fdisk_part)]; - unsigned short signature; -}; -struct REAL_disk_blk0 { - unsigned char bootcode[DISK_BOOTSZ]; - struct fdisk_part parts[FDISK_NPART]; - unsigned short signature; -} __attribute__((packed)); +// Format of boot block. + +struct disk_blk0 +{ + unsigned char bootcode[DISK_BOOTSZ]; + unsigned char parts[FDISK_NPART][sizeof (struct fdisk_part)]; + unsigned short signature; +}; #endif /* !__LIBSAIO_FDISK_H */ diff --git a/i386/libsaio/guid.c b/i386/libsaio/guid.c new file mode 100755 index 0000000..3ac4ed8 --- /dev/null +++ b/i386/libsaio/guid.c @@ -0,0 +1,151 @@ + + +#include "libsaio.h" + +#include "efi/essentials.h" +#include "efi/efi.h" + + +//========================================================================== +// Used in RevoBoot/i386/libsaio/disk.c + +void convertEFIGUIDToString(EFI_GUID const *aGuid, char **aUUIDString) +{ + // Do we need to allocate memory? + if (*aUUIDString == NULL) + { + // 1 2 3 + // 123456789 123456789 123456789 123456 + // 00000000-0000-0000-0000-000000000000 + *aUUIDString = (char *)malloc(36); + } + + if (*aUUIDString) + { + bzero(*aUUIDString, 36); + sprintf(*aUUIDString, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", + aGuid->Data1, /* - */ + aGuid->Data2, /* - */ + aGuid->Data3, /* - */ + aGuid->Data4[0], aGuid->Data4[1], /* - */ + aGuid->Data4[2], aGuid->Data4[3], + aGuid->Data4[4], aGuid->Data4[5], + aGuid->Data4[6], aGuid->Data4[7]); + } +} + + +//========================================================================== +// Used in RevoBoot/i386/libsaio/disk.c + +bool isEFIGUIDNull(EFI_GUID const *aGuid) +{ + if (aGuid->Data1 == 0 && aGuid->Data2 == 0 && aGuid->Data3 == 0) + { + int i = 0; + + for (i = 0; i < 8; ++i) + { + if (aGuid->Data4[i] != 0) + { + return false; + } + } + + return true; + } + + return false; +} + + +//========================================================================= +// Used in RevoBoot/i386/libsaio/disk.c + +int compareEFIGUID(EFI_GUID const *aSourceGuid, EFI_GUID const *aCompareGuid) +{ + if (aSourceGuid->Data1 == aCompareGuid->Data1) // Comparing two EFI_UINT32's + { + if (aSourceGuid->Data2 == aCompareGuid->Data2) // Comparing two EFI_UINT16's + { + if (aSourceGuid->Data3 == aCompareGuid->Data3) // Comparing two EFI_UINT16's + { + // Returns 0 when equal or -1 when not + return memcmp((const void *)aSourceGuid->Data4, (const void *)aSourceGuid->Data4, 8); + } + } + } + + return -1; +} + + +#if STARTUP_DISK_SUPPORT +//========================================================================= +// Helper function for getStartupDiskUUID() + +#if USE_DEVICE_PATH +void *getUUIDFromDevicePath(EFI_DEVICE_PATH_PROTOCOL *devicePath) +#else +void *getUUIDFromDevicePath(EFI_GUID *aGUID) +#endif +{ + char * uuid = NULL; + +#if USE_DEVICE_PATH + if (devicePath != NULL) + { + while (!IsDevicePathEndType(devicePath) && + !(DevicePathType(devicePath) == MEDIA_DEVICE_PATH && DevicePathSubType(devicePath) == MEDIA_HARDDRIVE_DP)) + { + devicePath = NextDevicePathNode(devicePath); + } + + if (DevicePathType(devicePath) == MEDIA_DEVICE_PATH && DevicePathSubType(devicePath) == MEDIA_HARDDRIVE_DP) + { + HARDDRIVE_DEVICE_PATH * HDDevicePath = (HARDDRIVE_DEVICE_PATH *) devicePath; + + if (HDDevicePath->SignatureType == SIGNATURE_TYPE_GUID) // 0x02 + { + EFI_GUID const * aGUID = (EFI_GUID*)HDDevicePath->Signature; + + convertEFIGUIDToString(aGUID, &uuid); + } + } + } +#else + convertEFIGUIDToString(aGUID, &uuid); +#endif + + return uuid; +} + + +//============================================================================== +// Used in RevoBoot/i386/boot2/boot.c + +char * getStartupDiskUUID(char * aDataPtr) +{ + char * startupDiskUUID = NULL; + + unsigned char * decodedData = NULL; + + int rc = base64Decode(aDataPtr, &decodedData); + + if ((rc == 75) && (decodedData != NULL)) + { +#if USE_DEVICE_PATH + EFI_DEVICE_PATH_PROTOCOL * dp = (EFI_DEVICE_PATH_PROTOCOL *) decodedData; + + startupDiskUUID = getUUIDFromDevicePath(dp); +#else + EFI_GUID * uuid = (EFI_GUID *) (decodedData + 52); + + convertEFIGUIDToString(uuid, &startupDiskUUID); +#endif + free(decodedData); + } + + return startupDiskUUID; +} +#endif // #if DISK_TARGET_SUPPORT diff --git a/i386/libsaio/hfs.c b/i386/libsaio/hfs.c index e19206c..48c6ee4 100755 --- a/i386/libsaio/hfs.c +++ b/i386/libsaio/hfs.c @@ -2,13 +2,13 @@ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 2.0 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. - * + * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -16,15 +16,19 @@ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. - * + * * @APPLE_LICENSE_HEADER_END@ - */ -/* - * hfs.c - File System Module for HFS and HFS+. * - * Copyright (c) 1999-2002 Apple Computer, Inc. + * hfs.c - File System Module for HFS and HFS+. + * + * Copyright (c) 1999-2002 Apple Computer, Inc. + * + * DRI: Josh de Cesare + * + * Updates: + * - OSBigEndian removed and white space changes (PikerAlpha, November 2012) + * - Cleanups and spaces -> tabs (PikerAlpha, November 2012) * - * DRI: Josh de Cesare */ #include @@ -39,40 +43,33 @@ #define kBTreeCatalog (0) #define kBTreeExtents (1) +static CICell gCurrentIH; +static long long gAllocationOffset; +static long gIsHFSPlus; +static long gBlockSize; +static long gCaseSensitive; +static long gCacheBlockSize; +static BTHeaderRec *gBTHeaders[2]; +static long long gVolID; + #ifdef __i386__ -static CICell gCurrentIH; -static long long gAllocationOffset; -static long gIsHFSPlus; -static long gCaseSensitive; -static long gBlockSize; -static long gCacheBlockSize; -static char *gBTreeHeaderBuffer; -static BTHeaderRec *gBTHeaders[2]; -static char *gHFSMdbVib; -static HFSMasterDirectoryBlock *gHFSMDB; -static char *gHFSPlusHeader; -static HFSPlusVolumeHeader *gHFSPlus; -static char *gLinkTemp; -static long long gVolID; -static char *gTempStr; +static char *gBTreeHeaderBuffer; +static char *gHFSMdbVib; +static HFSMasterDirectoryBlock *gHFSMDB; +static char *gHFSPlusHeader; +static HFSPlusVolumeHeader *gHFSPlus; +static char *gLinkTemp; +static char *gTempStr; #else /* !__i386__ */ -static CICell gCurrentIH; -static long long gAllocationOffset; -static long gIsHFSPlus; -static long gBlockSize; -static long gCaseSensitive; -static long gCacheBlockSize; -static char gBTreeHeaderBuffer[512]; -static BTHeaderRec *gBTHeaders[2]; -static char gHFSMdbVib[kBlockSize]; -static HFSMasterDirectoryBlock *gHFSMDB =(HFSMasterDirectoryBlock*)gHFSMdbVib; -static char gHFSPlusHeader[kBlockSize]; -static HFSPlusVolumeHeader *gHFSPlus =(HFSPlusVolumeHeader*)gHFSPlusHeader; -static char gLinkTemp[64]; -static long long gVolID; +static char gBTreeHeaderBuffer[512]; +static char gHFSMdbVib[kBlockSize]; +static HFSMasterDirectoryBlock *gHFSMDB =(HFSMasterDirectoryBlock*)gHFSMdbVib; +static char gHFSPlusHeader[kBlockSize]; +static HFSPlusVolumeHeader *gHFSPlus =(HFSPlusVolumeHeader*)gHFSPlusHeader; +static char gLinkTemp[64]; #endif /* !__i386__ */ @@ -105,10 +102,10 @@ extern long BinaryUnicodeCompare(u_int16_t *uniStr1, u_int32_t len1, u_int16_t * static void SwapFinderInfo(FndrFileInfo *dst, FndrFileInfo *src) { - dst->fdType = SWAP_BE32(src->fdType); - dst->fdCreator = SWAP_BE32(src->fdCreator); - dst->fdFlags = SWAP_BE16(src->fdFlags); - // Don't bother with location + dst->fdType = SWAP_BE32(src->fdType); + dst->fdCreator = SWAP_BE32(src->fdCreator); + dst->fdFlags = SWAP_BE16(src->fdFlags); + // Don't bother with location } @@ -116,9 +113,12 @@ static void SwapFinderInfo(FndrFileInfo *dst, FndrFileInfo *src) void HFSFree(CICell ih) { - if(gCurrentIH == ih) - gCurrentIH = 0; - free(ih); + if (gCurrentIH == ih) + { + gCurrentIH = 0; + } + + free(ih); } @@ -126,18 +126,20 @@ void HFSFree(CICell ih) bool HFSProbe (const void *buf) { - const HFSMasterDirectoryBlock *mdb; - const HFSPlusVolumeHeader *header; - mdb = (const HFSMasterDirectoryBlock *)(((const char*)buf)+kMDBBaseOffset); - header = (const HFSPlusVolumeHeader *)(((const char*)buf)+kMDBBaseOffset); + const HFSMasterDirectoryBlock *mdb = (const HFSMasterDirectoryBlock *)(((const char*)buf)+kMDBBaseOffset); + const HFSPlusVolumeHeader *header = (const HFSPlusVolumeHeader *)(((const char*)buf)+kMDBBaseOffset); - if ( SWAP_BE16(mdb->drSigWord) == kHFSSigWord ) - return true; - - if (SWAP_BE16(header->signature) != kHFSPlusSigWord && SWAP_BE16(header->signature) != kHFSXSigWord) - return false; - - return true; + if (SWAP_BE16(mdb->drSigWord) == kHFSSigWord) + { + return true; + } + + if (SWAP_BE16(header->signature) != kHFSPlusSigWord && SWAP_BE16(header->signature) != kHFSXSigWord) + { + return false; + } + + return true; } @@ -145,132 +147,138 @@ bool HFSProbe (const void *buf) long HFSInitPartition(CICell ih) { - long extentSize, extentFile, nodeSize; - void *extent; - - if (ih == gCurrentIH) + long extentSize, extentFile, nodeSize; + void *extent; + + if (ih == gCurrentIH) { #ifdef __i386__ - CacheInit(ih, gCacheBlockSize); + CacheInit(ih, gCacheBlockSize); #endif - return 0; - } - + return 0L; + } + #ifdef __i386__ - if (!gTempStr) + if (!gTempStr) + { gTempStr = (char *)malloc(4096); - - if (!gLinkTemp) + } + + if (!gLinkTemp) + { gLinkTemp = (char *)malloc(64); - - if (!gBTreeHeaderBuffer) + } + + if (!gBTreeHeaderBuffer) + { gBTreeHeaderBuffer = (char *)malloc(512); - - if (!gHFSMdbVib) + } + + if (!gHFSMdbVib) { - gHFSMdbVib = (char *)malloc(kBlockSize); - gHFSMDB = (HFSMasterDirectoryBlock *)gHFSMdbVib; - } - - if (!gHFSPlusHeader) + gHFSMdbVib = (char *)malloc(kBlockSize); + gHFSMDB = (HFSMasterDirectoryBlock *)gHFSMdbVib; + } + + if (!gHFSPlusHeader) { - gHFSPlusHeader = (char *)malloc(kBlockSize); - gHFSPlus = (HFSPlusVolumeHeader *)gHFSPlusHeader; - } - - if (!gTempStr || !gLinkTemp || !gBTreeHeaderBuffer || !gHFSMdbVib || !gHFSPlusHeader) return -1; + gHFSPlusHeader = (char *)malloc(kBlockSize); + gHFSPlus = (HFSPlusVolumeHeader *)gHFSPlusHeader; + } + + if (!gTempStr || !gLinkTemp || !gBTreeHeaderBuffer || !gHFSMdbVib || !gHFSPlusHeader) + { + return -1L; + } #endif /* __i386__ */ - - gAllocationOffset = 0; - gIsHFSPlus = 0; - gCaseSensitive = 0; - gBTHeaders[0] = 0; - gBTHeaders[1] = 0; - - // Look for the HFS MDB - Seek(ih, kMDBBaseOffset); - Read(ih, (long)gHFSMdbVib, kBlockSize); - - if (SWAP_BE16(gHFSMDB->drSigWord) == kHFSSigWord) + + gAllocationOffset = 0; + gIsHFSPlus = 0; + gCaseSensitive = 0; + gBTHeaders[0] = 0; + gBTHeaders[1] = 0; + + // Look for the HFS MDB + Seek(ih, kMDBBaseOffset); + Read(ih, (long)gHFSMdbVib, kBlockSize); + + if (SWAP_BE16(gHFSMDB->drSigWord) == kHFSSigWord) { - gAllocationOffset = SWAP_BE16(gHFSMDB->drAlBlSt) * kBlockSize; - - // See if it is HFSPlus - if (SWAP_BE16(gHFSMDB->drEmbedSigWord) != kHFSPlusSigWord) + gAllocationOffset = SWAP_BE16(gHFSMDB->drAlBlSt) * kBlockSize; + + // See if it is HFSPlus + if (SWAP_BE16(gHFSMDB->drEmbedSigWord) != kHFSPlusSigWord) { - // Normal HFS; - gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSMDB->drAlBlkSiz); - CacheInit(ih, gCacheBlockSize); - gCurrentIH = ih; - - // grab the 64 bit volume ID - bcopy(&gHFSMDB->drFndrInfo[6], &gVolID, 8); - - // Get the Catalog BTree node size. - extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec; - extentSize = SWAP_BE32(gHFSMDB->drCTFlSize); - extentFile = kHFSCatalogFileID; - ReadExtent(extent, extentSize, extentFile, 0, 256, gBTreeHeaderBuffer + kBTreeCatalog * 256, 0); - - nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 + - sizeof(BTNodeDescriptor)))->nodeSize); - - // If the BTree node size is larger than the block size, reset the cache. - if (nodeSize > gBlockSize) + // Normal HFS; + gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSMDB->drAlBlkSiz); + CacheInit(ih, gCacheBlockSize); + gCurrentIH = ih; + + // grab the 64 bit volume ID + bcopy(&gHFSMDB->drFndrInfo[6], &gVolID, 8); + + // Get the Catalog BTree node size. + extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec; + extentSize = SWAP_BE32(gHFSMDB->drCTFlSize); + extentFile = kHFSCatalogFileID; + ReadExtent(extent, extentSize, extentFile, 0, 256, gBTreeHeaderBuffer + kBTreeCatalog * 256, 0); + + nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 + sizeof(BTNodeDescriptor)))->nodeSize); + + // If the BTree node size is larger than the block size, reset the cache. + if (nodeSize > gBlockSize) { - gCacheBlockSize = nodeSize; - CacheInit(ih, gCacheBlockSize); - } - - return 0; - } - - // Calculate the offset to the embeded HFSPlus volume. - gAllocationOffset += (long long)SWAP_BE16(gHFSMDB->drEmbedExtent.startBlock) * - SWAP_BE32(gHFSMDB->drAlBlkSiz); - } - - // Look for the HFSPlus Header - Seek(ih, gAllocationOffset + kMDBBaseOffset); - Read(ih, (long)gHFSPlusHeader, kBlockSize); - - // Not a HFS+ or HFSX volume. - if (SWAP_BE16(gHFSPlus->signature) != kHFSPlusSigWord && SWAP_BE16(gHFSPlus->signature) != kHFSXSigWord) + gCacheBlockSize = nodeSize; + CacheInit(ih, gCacheBlockSize); + } + + return 0L; + } + + // Calculate the offset to the embeded HFSPlus volume. + gAllocationOffset += (long long)SWAP_BE16(gHFSMDB->drEmbedExtent.startBlock) * SWAP_BE32(gHFSMDB->drAlBlkSiz); + } + + // Look for the HFSPlus Header + Seek(ih, gAllocationOffset + kMDBBaseOffset); + Read(ih, (long)gHFSPlusHeader, kBlockSize); + + // Not a HFS+ or HFSX volume. + if (SWAP_BE16(gHFSPlus->signature) != kHFSPlusSigWord && SWAP_BE16(gHFSPlus->signature) != kHFSXSigWord) { verbose("HFS signature was not present.\n"); gCurrentIH = 0; - return -1; - } - - gIsHFSPlus = 1; - gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSPlus->blockSize); - CacheInit(ih, gCacheBlockSize); - gCurrentIH = ih; - + + return -1L; + } + + gIsHFSPlus = 1; + gCacheBlockSize = gBlockSize = SWAP_BE32(gHFSPlus->blockSize); + CacheInit(ih, gCacheBlockSize); + gCurrentIH = ih; + ih->modTime = SWAP_BE32(gHFSPlus->modifyDate) - 2082844800; - // grab the 64 bit volume ID - bcopy(&gHFSPlus->finderInfo[24], &gVolID, 8); - - // Get the Catalog BTree node size. - extent = &gHFSPlus->catalogFile.extents; - extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize); - extentFile = kHFSCatalogFileID; - - ReadExtent(extent, extentSize, extentFile, 0, 256, - gBTreeHeaderBuffer + kBTreeCatalog * 256, 0); - - nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 + - sizeof(BTNodeDescriptor)))->nodeSize); - - // If the BTree node size is larger than the block size, reset the cache. - if (nodeSize > gBlockSize) + // grab the 64 bit volume ID + bcopy(&gHFSPlus->finderInfo[24], &gVolID, 8); + + // Get the Catalog BTree node size. + extent = &gHFSPlus->catalogFile.extents; + extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize); + extentFile = kHFSCatalogFileID; + + ReadExtent(extent, extentSize, extentFile, 0, 256, gBTreeHeaderBuffer + kBTreeCatalog * 256, 0); + + nodeSize = SWAP_BE16(((BTHeaderRec *)(gBTreeHeaderBuffer + kBTreeCatalog * 256 + sizeof(BTNodeDescriptor)))->nodeSize); + + // If the BTree node size is larger than the block size, reset the cache. + if (nodeSize > gBlockSize) { - gCacheBlockSize = nodeSize; - CacheInit(ih, gCacheBlockSize); - } - - return 0; + gCacheBlockSize = nodeSize; + CacheInit(ih, gCacheBlockSize); + } + + return 0L; } @@ -278,7 +286,7 @@ long HFSInitPartition(CICell ih) long HFSLoadFile(CICell ih, char * filePath) { - return HFSReadFile(ih, filePath, (void *)gFSLoadAddress, 0, 0); + return HFSReadFile(ih, filePath, (void *)gFSLoadAddress, 0, 0); } @@ -286,81 +294,67 @@ long HFSLoadFile(CICell ih, char * filePath) long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length) { - char entry[512]; - long dirID, result, flags; - // bool thinFatReadRequest = (length == 4096 && offset == 0); - - if (HFSInitPartition(ih) == -1) + char entry[512]; + long dirID, result, flags; + + if (HFSInitPartition(ih) == -1) { return -1; } - - dirID = kHFSRootFolderID; - // Skip a lead '\'. Start in the system folder if there are two. - if (filePath[0] == '/') + + dirID = kHFSRootFolderID; + + // Skip a lead '\'. Start in the system folder if there are two. + if (filePath[0] == '/') { - if (filePath[1] == '/') + if (filePath[1] == '/') { - if (gIsHFSPlus) + if (gIsHFSPlus) { dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]); } - else + else { dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]); } - - if (dirID == 0) + + if (dirID == 0) { - return -1; + return -1L; } - filePath++; - } - filePath++; - } - - result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0); - - if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) + + filePath++; + } + + filePath++; + } + + result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0); + + if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) { - return -1; - } - + return -1L; + } + #if UNUSED - // Not yet for Intel. System.config/Default.table will fail this check. - // Check file owner and permissions. - if (flags & (kOwnerNotRoot | kPermGroupWrite | kPermOtherWrite)) + // Not yet for Intel. System.config/Default.table will fail this check. + // Check file owner and permissions. + if (flags & (kOwnerNotRoot | kPermGroupWrite | kPermOtherWrite)) { - return -1; + return -1L; } #endif - - /* if (thinFatReadRequest) - { - length = 0; // Zero will make it load the whole file at once. - } */ - - if (ReadFile(entry, &length, base, offset) == -1) - { - return -1; - } - - /* if (thinFatReadRequest) + + if (ReadFile(entry, &length, base, offset) == -1) { - unsigned long length2 = 0; - printf("thinFatReadRequest()\n"); - ReadFile(entry, &length2, base + 4096, 0); - length += length2; - return 0; // Zero prevents ThinFatFile() from calling us again. - } */ - -#if CHAMELEON - verbose("Loaded HFS%s file: [%s] %d bytes from %x.\n", (gIsHFSPlus ? "+" : ""), filePath, (uint32_t)length, ih); -#elif DEBUG + return -1L; + } + +#if DEBUG printf("Loaded [%s] %d bytes.\n", filePath, (uint32_t)length); #endif - return length; + return length; } @@ -369,21 +363,21 @@ long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64 long HFSGetDirEntry(CICell ih, char * dirPath, long * dirIndex, char ** name, long * flags, long * time, FinderInfo * finderInfo, long * infoValid) { char entry[512]; - + long dirID, dirFlags; - + if (HFSInitPartition(ih) == -1) { return -1; } - + if (*dirIndex == -1) { return -1; } - + dirID = kHFSRootFolderID; - + // Skip a lead '\'. Start in the system folder if there are two. if (dirPath[0] == '/') { @@ -393,49 +387,49 @@ long HFSGetDirEntry(CICell ih, char * dirPath, long * dirIndex, char ** name, lo { dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]); } - else + else { dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]); } - + if (dirID == 0) { return -1; } - + dirPath++; } - + dirPath++; } - + if (*dirIndex == 0) { ResolvePathToCatalogEntry(dirPath, &dirFlags, entry, dirID, dirIndex); - + if (*dirIndex == 0) { *dirIndex = -1; } - + if ((dirFlags & kFileTypeMask) != kFileTypeUnknown) { return -1; } } - + GetCatalogEntry(dirIndex, name, flags, time, finderInfo, infoValid); - + if (*dirIndex == 0) { *dirIndex = -1; } - + if ((*flags & kFileTypeMask) == kFileTypeUnknown) { return -1; } - + return 0; } @@ -449,24 +443,24 @@ void HFSGetDescription(CICell ih, char *str, long strMaxLen) long dirIndex; char *name; long flags, time; - + if (HFSInitPartition(ih) == -1) { return; } - + /* Fill some crucial data structures by side effect. */ dirIndex = 0; HFSGetDirEntry(ih, "/", &dirIndex, &name, &flags, &time, 0, 0); - + /* Now we can loook up the volume name node. */ nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize); firstLeafNode = SWAP_BE32(gBTHeaders[kBTreeCatalog]->firstLeafNode); - + dirIndex = firstLeafNode * nodeSize; - + GetCatalogEntry(&dirIndex, &name, &flags, &time, 0, 0); - + strncpy(str, name, strMaxLen); str[strMaxLen] = '\0'; } @@ -476,62 +470,71 @@ void HFSGetDescription(CICell ih, char *str, long strMaxLen) long HFSGetFileBlock(CICell ih, char *filePath, unsigned long long *firstBlock) { - char entry[512]; - long dirID, result, flags; - void *extents; - HFSCatalogFile *hfsFile = (void *)entry; - HFSPlusCatalogFile *hfsPlusFile = (void *)entry; - - if (HFSInitPartition(ih) == -1) return -1; - - dirID = kHFSRootFolderID; - // Skip a lead '\'. Start in the system folder if there are two. - if (filePath[0] == '/') + char entry[512]; + long dirID, result, flags; + void *extents; + + HFSCatalogFile *hfsFile = (void *)entry; + HFSPlusCatalogFile *hfsPlusFile = (void *)entry; + + if (HFSInitPartition(ih) == -1) + { + return -1L; + } + + dirID = kHFSRootFolderID; + + // Skip a lead '\'. Start in the system folder if there are two. + + if (filePath[0] == '/') { - if (filePath[1] == '/') + if (filePath[1] == '/') { - if (gIsHFSPlus) + if (gIsHFSPlus) { dirID = SWAP_BE32(((long *) gHFSPlus->finderInfo)[5]); } - else + else { dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]); } - + if (dirID == 0) { return -1; } - filePath++; - } - filePath++; - } - - result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0); - - if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) + + filePath++; + } + + filePath++; + } + + result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0); + + if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) { - printf("HFS: Resolve path %s failed\n", filePath); - return -1; - } - - if (gIsHFSPlus) + return -1L; + } + + if (gIsHFSPlus) { - extents = &hfsPlusFile->dataFork.extents; - } + extents = &hfsPlusFile->dataFork.extents; + } else { - extents = &hfsFile->dataExtents; - } - + extents = &hfsFile->dataExtents; + } + #if DEBUG - printf("extent start 0x%x\n", (unsigned long)GetExtentStart(extents, 0)); - printf("block size 0x%x\n", (unsigned long)gBlockSize); - printf("Allocation offset 0x%x\n", (unsigned long)gAllocationOffset); + printf("extent start 0x%x\n", (unsigned long)GetExtentStart(extents, 0)); + printf("block size 0x%x\n", (unsigned long)gBlockSize); + printf("Allocation offset 0x%x\n", (unsigned long)gAllocationOffset); #endif - *firstBlock = ((unsigned long long)GetExtentStart(extents, 0) * (unsigned long long) gBlockSize + gAllocationOffset) / 512ULL; - return 0; + + *firstBlock = ((unsigned long long)GetExtentStart(extents, 0) * (unsigned long long) gBlockSize + gAllocationOffset) / 512ULL; + + return 0L; } @@ -539,13 +542,17 @@ long HFSGetFileBlock(CICell ih, char *filePath, unsigned long long *firstBlock) long HFSGetUUID(CICell ih, char *uuidStr) { - if (HFSInitPartition(ih) == -1) + if (HFSInitPartition(ih) == -1) + { return -1; - - if (gVolID == 0LL) + } + + if (gVolID == 0LL) + { return -1; - - return CreateUUIDString((uint8_t*)(&gVolID), sizeof(gVolID), uuidStr); + } + + return CreateUUIDString((uint8_t*)(&gVolID), sizeof(gVolID), uuidStr); } @@ -554,44 +561,40 @@ long HFSGetUUID(CICell ih, char *uuidStr) static long ReadFile(void * file, uint64_t * length, void * base, uint64_t offset) { - void *extents; - long fileID; - uint64_t fileLength; - HFSCatalogFile *hfsFile = file; - HFSPlusCatalogFile *hfsPlusFile = file; - - if (gIsHFSPlus) - { - fileID = SWAP_BE32(hfsPlusFile->fileID); - fileLength = (uint64_t)SWAP_BE64(hfsPlusFile->dataFork.logicalSize); - extents = &hfsPlusFile->dataFork.extents; - } + void *extents; + long fileID; + + uint64_t fileLength; + + HFSCatalogFile *hfsFile = file; + HFSPlusCatalogFile *hfsPlusFile = file; + + if (gIsHFSPlus) + { + fileID = SWAP_BE32(hfsPlusFile->fileID); + fileLength = (uint64_t)SWAP_BE64(hfsPlusFile->dataFork.logicalSize); + extents = &hfsPlusFile->dataFork.extents; + } else { - fileID = SWAP_BE32(hfsFile->fileID); - fileLength = SWAP_BE32(hfsFile->dataLogicalSize); - extents = &hfsFile->dataExtents; - } - - if (offset > fileLength) + fileID = SWAP_BE32(hfsFile->fileID); + fileLength = SWAP_BE32(hfsFile->dataLogicalSize); + extents = &hfsFile->dataExtents; + } + + if (offset > fileLength) { - printf("Offset is too large.\n"); - return -1; - } - - if ((*length == 0) || ((offset + *length) > fileLength)) + return -1L; + } + + if ((*length == 0) || ((offset + *length) > fileLength)) { - *length = fileLength - offset; - } - -/* if (*length > kLoadSize) { - printf("File is too large.\n"); - return -1; - }*/ - - *length = ReadExtent((char *)extents, fileLength, fileID, offset, *length, (char *)base, 0); - - return 0; + *length = fileLength - offset; + } + + *length = ReadExtent((char *)extents, fileLength, fileID, offset, *length, (char *)base, 0); + + return 0L; } @@ -599,68 +602,83 @@ static long ReadFile(void * file, uint64_t * length, void * base, uint64_t offse static long GetCatalogEntryInfo(void * entry, long * flags, long * time, FinderInfo * finderInfo, long * infoValid) { - long tmpTime = 0; - long valid = 0; - - // Get information about the file. - - switch (SWAP_BE16(*(short *)entry)) - { - case kHFSFolderRecord : - *flags = kFileTypeDirectory; - tmpTime = SWAP_BE32(((HFSCatalogFolder *)entry)->modifyDate); - break; - - case kHFSPlusFolderRecord : - *flags = kFileTypeDirectory | - (SWAP_BE16(((HFSPlusCatalogFolder *)entry)->bsdInfo.fileMode) & kPermMask); - if (SWAP_BE32(((HFSPlusCatalogFolder *)entry)->bsdInfo.ownerID) != 0) - *flags |= kOwnerNotRoot; - tmpTime = SWAP_BE32(((HFSPlusCatalogFolder *)entry)->contentModDate); - break; - - case kHFSFileRecord : - *flags = kFileTypeFlat; - tmpTime = SWAP_BE32(((HFSCatalogFile *)entry)->modifyDate); - if (finderInfo) { - SwapFinderInfo((FndrFileInfo *)finderInfo, &((HFSCatalogFile *)entry)->userInfo); - valid = 1; - } - break; - - case kHFSPlusFileRecord : - *flags = kFileTypeFlat | - (SWAP_BE16(((HFSPlusCatalogFile *)entry)->bsdInfo.fileMode) & kPermMask); - if (SWAP_BE32(((HFSPlusCatalogFile *)entry)->bsdInfo.ownerID) != 0) - *flags |= kOwnerNotRoot; - tmpTime = SWAP_BE32(((HFSPlusCatalogFile *)entry)->contentModDate); - if (finderInfo) { - SwapFinderInfo((FndrFileInfo *)finderInfo, &((HFSPlusCatalogFile *)entry)->userInfo); - valid = 1; - } - break; - - case kHFSFileThreadRecord : - case kHFSPlusFileThreadRecord : - case kHFSFolderThreadRecord : - case kHFSPlusFolderThreadRecord : - *flags = kFileTypeUnknown; - tmpTime = 0; - break; + long tmpTime = 0L; + long valid = 0L; + + // Get information about the file. + + switch (SWAP_BE16(*(short *)entry)) + { + case kHFSFolderRecord: + *flags = kFileTypeDirectory; + tmpTime = SWAP_BE32(((HFSCatalogFolder *)entry)->modifyDate); + + break; + + case kHFSPlusFolderRecord: + *flags = kFileTypeDirectory | (SWAP_BE16(((HFSPlusCatalogFolder *)entry)->bsdInfo.fileMode) & kPermMask); + + if (SWAP_BE32(((HFSPlusCatalogFolder *)entry)->bsdInfo.ownerID) != 0) + { + *flags |= kOwnerNotRoot; + } + + tmpTime = SWAP_BE32(((HFSPlusCatalogFolder *)entry)->contentModDate); + + break; + + case kHFSFileRecord: + *flags = kFileTypeFlat; + tmpTime = SWAP_BE32(((HFSCatalogFile *)entry)->modifyDate); + + if (finderInfo) + { + SwapFinderInfo((FndrFileInfo *)finderInfo, &((HFSCatalogFile *)entry)->userInfo); + valid = 1; + } + + break; + + case kHFSPlusFileRecord: + *flags = kFileTypeFlat | (SWAP_BE16(((HFSPlusCatalogFile *)entry)->bsdInfo.fileMode) & kPermMask); + + if (SWAP_BE32(((HFSPlusCatalogFile *)entry)->bsdInfo.ownerID) != 0) + { + *flags |= kOwnerNotRoot; + } + + tmpTime = SWAP_BE32(((HFSPlusCatalogFile *)entry)->contentModDate); + + if (finderInfo) + { + SwapFinderInfo((FndrFileInfo *)finderInfo, &((HFSPlusCatalogFile *)entry)->userInfo); + valid = 1; + } + + break; + + case kHFSFileThreadRecord: + case kHFSPlusFileThreadRecord: + case kHFSFolderThreadRecord: + case kHFSPlusFolderThreadRecord: + *flags = kFileTypeUnknown; + tmpTime = 0; + + break; } - + if (time != 0) { // Convert base time from 1904 to 1970. *time = tmpTime - 2082844800; } - + if (infoValid) { *infoValid = valid; } - - return 0; + + return 0L; } @@ -671,37 +689,37 @@ static long ResolvePathToCatalogEntry(char * filePath, long * flags, void * entr char *restPath; long result, subFolderID = 0, tmpDirIndex; HFSPlusCatalogFile *hfsPlusFile; - + // Copy the file name to gTempStr long cnt = 0; - + while ((filePath[cnt] != '/') && (filePath[cnt] != '\0')) { cnt++; } - + strlcpy(gTempStr, filePath, cnt+1); - + // Move restPath to the right place. if (filePath[cnt] != '\0') { cnt++; } - + restPath = filePath + cnt; - + // gTempStr is a name in the current Dir. // restPath is the rest of the path if any. - + result = ReadCatalogEntry(gTempStr, dirID, entry, dirIndex); - + if (result == -1) { return -1; } - + GetCatalogEntryInfo(entry, flags, 0, 0, 0); - + if ((*flags & kFileTypeMask) == kFileTypeDirectory) { if (gIsHFSPlus) @@ -713,16 +731,16 @@ static long ResolvePathToCatalogEntry(char * filePath, long * flags, void * entr subFolderID = SWAP_BE32(((HFSCatalogFolder *)entry)->folderID); } } - + if ((*flags & kFileTypeMask) == kFileTypeDirectory) { result = ResolvePathToCatalogEntry(restPath, flags, entry, subFolderID, dirIndex); } - + if (gIsHFSPlus && ((*flags & kFileTypeMask) == kFileTypeFlat)) { hfsPlusFile = (HFSPlusCatalogFile *)entry; - + if ((SWAP_BE32(hfsPlusFile->userInfo.fdType) == kHardLinkFileType) && (SWAP_BE32(hfsPlusFile->userInfo.fdCreator) == kHFSPlusCreator)) { @@ -730,7 +748,7 @@ static long ResolvePathToCatalogEntry(char * filePath, long * flags, void * entr result = ResolvePathToCatalogEntry(gLinkTemp, flags, entry, kHFSRootFolderID, &tmpDirIndex); } } - + return result; } @@ -739,63 +757,66 @@ static long ResolvePathToCatalogEntry(char * filePath, long * flags, void * entr static long GetCatalogEntry(long * dirIndex, char ** name, long * flags, long * time, FinderInfo * finderInfo, long * infoValid) { - long extentSize, nodeSize, curNode, index; - void *extent; - char *nodeBuf, *testKey, *entry; - BTNodeDescriptor *node; - + long extentSize, nodeSize, curNode, index; + void *extent; + char *nodeBuf, *testKey, *entry; + + BTNodeDescriptor *node = NULL; + if (gIsHFSPlus) { - extent = &gHFSPlus->catalogFile.extents; - extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize); + extent = &gHFSPlus->catalogFile.extents; + extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize); } else { - extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec; - extentSize = SWAP_BE32(gHFSMDB->drCTFlSize); + extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec; + extentSize = SWAP_BE32(gHFSMDB->drCTFlSize); } - - nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize); - nodeBuf = (char *)malloc(nodeSize); - node = (BTNodeDescriptor *)nodeBuf; - + + nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize); + nodeBuf = (char *)malloc(nodeSize); + + if (nodeBuf) + { + node = (BTNodeDescriptor *)nodeBuf; + } + index = *dirIndex % nodeSize; curNode = *dirIndex / nodeSize; - + // Read the BTree node and get the record for index. ReadExtent(extent, extentSize, kHFSCatalogFileID, curNode * nodeSize, nodeSize, nodeBuf, 1); GetBTreeRecord(index, nodeBuf, nodeSize, &testKey, &entry); GetCatalogEntryInfo(entry, flags, time, finderInfo, infoValid); - + // Get the file name. if (gIsHFSPlus) { - utf_encodestr(((HFSPlusCatalogKey *)testKey)->nodeName.unicode, - SWAP_BE16(((HFSPlusCatalogKey *)testKey)->nodeName.length), - (u_int8_t *)gTempStr, 256, OSBigEndian); + utf_encodestr(((HFSPlusCatalogKey *)testKey)->nodeName.unicode, SWAP_BE16(((HFSPlusCatalogKey *)testKey)->nodeName.length), (u_int8_t *)gTempStr, 256); } else { - strncpy(gTempStr, (const char *)&((HFSCatalogKey *)testKey)->nodeName[1], - ((HFSCatalogKey *)testKey)->nodeName[0]); - + strncpy(gTempStr, (const char *)&((HFSCatalogKey *)testKey)->nodeName[1], ((HFSCatalogKey *)testKey)->nodeName[0]); + gTempStr[((HFSCatalogKey *)testKey)->nodeName[0]] = '\0'; } - *name = gTempStr; - - // Update dirIndex. - index++; - - if (index == SWAP_BE16(node->numRecords)) + + *name = gTempStr; + + // Update dirIndex. + index++; + + if (node && (index == SWAP_BE16(node->numRecords))) { index = 0; curNode = SWAP_BE32(node->fLink); - } - + } + *dirIndex = curNode * nodeSize + index; - + free(nodeBuf); - + return 0; } @@ -804,38 +825,32 @@ static long GetCatalogEntry(long * dirIndex, char ** name, long * flags, long * static long ReadCatalogEntry(char * fileName, long dirID, void * entry, long * dirIndex) { - long length; - char key[sizeof(HFSPlusCatalogKey)]; - HFSCatalogKey *hfsKey = (HFSCatalogKey *)key; - HFSPlusCatalogKey *hfsPlusKey = (HFSPlusCatalogKey *)key; - + long length = 0L; + char key[sizeof(HFSPlusCatalogKey)]; + + HFSCatalogKey *hfsKey = (HFSCatalogKey *)key; + HFSPlusCatalogKey *hfsPlusKey = (HFSPlusCatalogKey *)key; + // Make the catalog key. if (gIsHFSPlus) { hfsPlusKey->parentID = SWAP_BE32(dirID); - length = strlen(fileName); - - if (length > 255) - { - length = 255; - } - - utf_decodestr((u_int8_t *)fileName, hfsPlusKey->nodeName.unicode, &(hfsPlusKey->nodeName.length), 512, OSBigEndian); + utf_decodestr((u_int8_t *)fileName, hfsPlusKey->nodeName.unicode, &(hfsPlusKey->nodeName.length), 512); } else { hfsKey->parentID = SWAP_BE32(dirID); length = strlen(fileName); - + if (length > 31) { length = 31; } - + hfsKey->nodeName[0] = length; strncpy((char *)(hfsKey->nodeName + 1), fileName, length); } - + return ReadBTreeEntry(kBTreeCatalog, &key, entry, dirIndex); } @@ -844,25 +859,26 @@ static long ReadCatalogEntry(char * fileName, long dirID, void * entry, long * d static long ReadExtentsEntry(long fileID, long startBlock, void * entry) { - char key[sizeof(HFSPlusExtentKey)]; - HFSExtentKey *hfsKey = (HFSExtentKey *)key; - HFSPlusExtentKey *hfsPlusKey = (HFSPlusExtentKey *)key; - - // Make the extents key. - if (gIsHFSPlus) + char key[sizeof(HFSPlusExtentKey)]; + + HFSExtentKey *hfsKey = (HFSExtentKey *)key; + HFSPlusExtentKey *hfsPlusKey = (HFSPlusExtentKey *)key; + + // Make the extents key. + if (gIsHFSPlus) { - hfsPlusKey->forkType = 0; - hfsPlusKey->fileID = SWAP_BE32(fileID); - hfsPlusKey->startBlock = SWAP_BE32(startBlock); - } + hfsPlusKey->forkType = 0; + hfsPlusKey->fileID = SWAP_BE32(fileID); + hfsPlusKey->startBlock = SWAP_BE32(startBlock); + } else { - hfsKey->forkType = 0; - hfsKey->fileID = SWAP_BE32(fileID); - hfsKey->startBlock = SWAP_BE16(startBlock); - } - - return ReadBTreeEntry(kBTreeExtents, &key, entry, 0); + hfsKey->forkType = 0; + hfsKey->fileID = SWAP_BE32(fileID); + hfsKey->startBlock = SWAP_BE16(startBlock); + } + + return ReadBTreeEntry(kBTreeExtents, &key, entry, 0); } @@ -870,123 +886,126 @@ static long ReadExtentsEntry(long fileID, long startBlock, void * entry) static long ReadBTreeEntry(long btree, void * key, char * entry, long * dirIndex) { - long extentSize; - void *extent; - short extentFile; - char *nodeBuf; - BTNodeDescriptor *node; - long nodeSize, result = 0, entrySize = 0; - long curNode, index = 0, lowerBound, upperBound; - char *testKey, *recordData; - - // Figure out which tree is being looked at. - if (btree == kBTreeCatalog) - { - if (gIsHFSPlus) + + void *extent; + short extentFile; + long nodeSize, result = 0, entrySize = 0; + long curNode, index = 0, lowerBound, upperBound; + long extentSize; + char *testKey, *recordData = NULL; + char *nodeBuf; + + BTNodeDescriptor *node; + + // Figure out which tree is being looked at. + if (btree == kBTreeCatalog) + { + if (gIsHFSPlus) { - extent = &gHFSPlus->catalogFile.extents; - extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize); - } + extent = &gHFSPlus->catalogFile.extents; + extentSize = SWAP_BE64(gHFSPlus->catalogFile.logicalSize); + } else { - extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec; - extentSize = SWAP_BE32(gHFSMDB->drCTFlSize); - } - extentFile = kHFSCatalogFileID; - } + extent = (HFSExtentDescriptor *)&gHFSMDB->drCTExtRec; + extentSize = SWAP_BE32(gHFSMDB->drCTFlSize); + } + + extentFile = kHFSCatalogFileID; + } else { - if (gIsHFSPlus) + if (gIsHFSPlus) { - extent = &gHFSPlus->extentsFile.extents; - extentSize = SWAP_BE64(gHFSPlus->extentsFile.logicalSize); - } + extent = &gHFSPlus->extentsFile.extents; + extentSize = SWAP_BE64(gHFSPlus->extentsFile.logicalSize); + } else { - extent = (HFSExtentDescriptor *)&gHFSMDB->drXTExtRec; - extentSize = SWAP_BE32(gHFSMDB->drXTFlSize); - } - extentFile = kHFSExtentsFileID; - } - - // Read the BTree Header if needed. - if (gBTHeaders[btree] == 0) + extent = (HFSExtentDescriptor *)&gHFSMDB->drXTExtRec; + extentSize = SWAP_BE32(gHFSMDB->drXTFlSize); + } + + extentFile = kHFSExtentsFileID; + } + + // Read the BTree Header if needed. + if (gBTHeaders[btree] == 0) { - ReadExtent(extent, extentSize, extentFile, 0, 256, gBTreeHeaderBuffer + btree * 256, 0); - gBTHeaders[btree] = (BTHeaderRec *)(gBTreeHeaderBuffer + btree * 256 + sizeof(BTNodeDescriptor)); - - if ((gIsHFSPlus && btree == kBTreeCatalog) && (gBTHeaders[btree]->keyCompareType == kHFSBinaryCompare)) + ReadExtent(extent, extentSize, extentFile, 0, 256, gBTreeHeaderBuffer + btree * 256, 0); + gBTHeaders[btree] = (BTHeaderRec *)(gBTreeHeaderBuffer + btree * 256 + sizeof(BTNodeDescriptor)); + + if ((gIsHFSPlus && btree == kBTreeCatalog) && (gBTHeaders[btree]->keyCompareType == kHFSBinaryCompare)) { gCaseSensitive = 1; - } - } - - curNode = SWAP_BE32(gBTHeaders[btree]->rootNode); - nodeSize = SWAP_BE16(gBTHeaders[btree]->nodeSize); - nodeBuf = (char *)malloc(nodeSize); - node = (BTNodeDescriptor *)nodeBuf; - - while (1) - { - // Read the current node. - ReadExtent(extent, extentSize, extentFile, - curNode * nodeSize, nodeSize, nodeBuf, 1); - - // Find the matching key. - lowerBound = 0; - upperBound = SWAP_BE16(node->numRecords) - 1; - - while (lowerBound <= upperBound) + } + } + + curNode = SWAP_BE32(gBTHeaders[btree]->rootNode); + nodeSize = SWAP_BE16(gBTHeaders[btree]->nodeSize); + nodeBuf = (char *)malloc(nodeSize); + node = (BTNodeDescriptor *)nodeBuf; + + while (1) + { + // Read the current node. + ReadExtent(extent, extentSize, extentFile, curNode * nodeSize, nodeSize, nodeBuf, 1); + + // Find the matching key. + lowerBound = 0; + upperBound = SWAP_BE16(node->numRecords) - 1; + + while (lowerBound <= upperBound) { - index = (lowerBound + upperBound) / 2; - - GetBTreeRecord(index, nodeBuf, nodeSize, &testKey, &recordData); - - if (gIsHFSPlus) + index = (lowerBound + upperBound) / 2; + + GetBTreeRecord(index, nodeBuf, nodeSize, &testKey, &recordData); + + if (gIsHFSPlus) { - if (btree == kBTreeCatalog) + if (btree == kBTreeCatalog) { - result = CompareHFSPlusCatalogKeys(key, testKey); - } + result = CompareHFSPlusCatalogKeys(key, testKey); + } else { - result = CompareHFSPlusExtentsKeys(key, testKey); - } - } + result = CompareHFSPlusExtentsKeys(key, testKey); + } + } else { - if (btree == kBTreeCatalog) + if (btree == kBTreeCatalog) { - result = CompareHFSCatalogKeys(key, testKey); - } + result = CompareHFSCatalogKeys(key, testKey); + } else { - result = CompareHFSExtentsKeys(key, testKey); - } - } - - if (result < 0) + result = CompareHFSExtentsKeys(key, testKey); + } + } + + if (result < 0) { upperBound = index - 1; // search < trial } - else if (result > 0) + else if (result > 0) { lowerBound = index + 1; // search > trial } - else + else { break; // search = trial } } - + if (result < 0) { index = upperBound; GetBTreeRecord(index, nodeBuf, nodeSize, &testKey, &recordData); } - + // Found the closest key... Recurse on it if this is an index node. - if (node->kind == kBTIndexNode) + if (recordData && node->kind == kBTIndexNode) { curNode = SWAP_BE32( *((long *)recordData) ); } @@ -995,33 +1014,34 @@ static long ReadBTreeEntry(long btree, void * key, char * entry, long * dirIndex break; } } - + // Return error if the file was not found. if (result != 0) { free(nodeBuf); + return -1; } - + if (btree == kBTreeCatalog) { switch (SWAP_BE16(*(short *)recordData)) { - case kHFSFolderRecord : entrySize = 70; + case kHFSFolderRecord : entrySize = 70; break; - case kHFSFileRecord : entrySize = 102; + case kHFSFileRecord : entrySize = 102; break; - case kHFSFolderThreadRecord : entrySize = 46; + case kHFSFolderThreadRecord : entrySize = 46; break; - case kHFSFileThreadRecord : entrySize = 46; + case kHFSFileThreadRecord : entrySize = 46; break; - case kHFSPlusFolderRecord : entrySize = 88; + case kHFSPlusFolderRecord : entrySize = 88; break; - case kHFSPlusFileRecord : entrySize = 248; + case kHFSPlusFileRecord : entrySize = 248; break; - case kHFSPlusFolderThreadRecord : entrySize = 264; + case kHFSPlusFolderThreadRecord : entrySize = 264; break; - case kHFSPlusFileThreadRecord : entrySize = 264; + case kHFSPlusFileThreadRecord : entrySize = 264; break; } } @@ -1037,24 +1057,27 @@ static long ReadBTreeEntry(long btree, void * key, char * entry, long * dirIndex } } - bcopy(recordData, entry, entrySize); + if (recordData) + { + bcopy(recordData, entry, entrySize); + } // Update dirIndex. if (dirIndex != 0) { index++; - + if (index == SWAP_BE16(node->numRecords)) { index = 0; curNode = SWAP_BE32(node->fLink); } - + *dirIndex = curNode * nodeSize + index; } free(nodeBuf); - + return 0; } @@ -1065,9 +1088,9 @@ static void GetBTreeRecord(long index, char * nodeBuffer, long nodeSize, char ** { long keySize; long recordOffset = SWAP_BE16(*((short *)(nodeBuffer + (nodeSize - 2 * index - 2)))); - + *key = nodeBuffer + recordOffset; - + if (gIsHFSPlus) { keySize = SWAP_BE16(*(short *)*key); @@ -1091,30 +1114,30 @@ static long ReadExtent(char * extent, uint64_t extentSize, long extentFile, uint long long nextExtentBlock, currentExtentBlock = 0; long long readOffset; long long extentDensity, sizeofExtent, currentExtentSize; - char *currentExtent, *extentBuffer = 0, *bufferPos = buffer; - + char *currentExtent, *extentBuffer = 0, *bufferPos = buffer; + if (offset >= extentSize) { return 0; } - + if (gIsHFSPlus) { extentDensity = kHFSPlusExtentDensity; sizeofExtent = sizeof(HFSPlusExtentDescriptor); - } + } else { extentDensity = kHFSExtentDensity; sizeofExtent = sizeof(HFSExtentDescriptor); } - + lastOffset = offset + size; - + while (offset < lastOffset) { blockNumber = offset / gBlockSize; - + // Find the extent for the offset. for (; ; nextExtent++) { @@ -1125,63 +1148,63 @@ static long ReadExtent(char * extent, uint64_t extentSize, long extentFile, uint countedBlocks += GetExtentSize(extent, nextExtent); continue; } - + currentExtent = extent + nextExtent * sizeofExtent; break; } - + if (extentBuffer == 0) { extentBuffer = malloc(sizeofExtent * extentDensity); - + if (extentBuffer == 0) { return -1; } } - + nextExtentBlock = nextExtent / extentDensity; - + if (currentExtentBlock != nextExtentBlock) { ReadExtentsEntry(extentFile, countedBlocks, extentBuffer); currentExtentBlock = nextExtentBlock; } - + currentExtentSize = GetExtentSize(extentBuffer, nextExtent % extentDensity); - + if ((countedBlocks + currentExtentSize - 1) >= blockNumber) { currentExtent = extentBuffer + sizeofExtent * (nextExtent % extentDensity); break; } - + countedBlocks += currentExtentSize; } - + readOffset = ((blockNumber - countedBlocks) * gBlockSize) + (offset % gBlockSize); - + readSize = GetExtentSize(currentExtent, 0) * gBlockSize - readOffset; - + if (readSize > (size - sizeRead)) { readSize = size - sizeRead; } - + readOffset += (long long)GetExtentStart(currentExtent, 0) * gBlockSize; - + CacheRead(gCurrentIH, bufferPos, gAllocationOffset + readOffset, readSize, cache); - + sizeRead += readSize; offset += readSize; bufferPos += readSize; } - + if (extentBuffer) { free(extentBuffer); } - + return sizeRead; } @@ -1191,19 +1214,19 @@ static long ReadExtent(char * extent, uint64_t extentSize, long extentFile, uint static long GetExtentStart(void * extents, long index) { long start; - + HFSExtentDescriptor *hfsExtents = extents; HFSPlusExtentDescriptor *hfsPlusExtents = extents; - + if (gIsHFSPlus) { start = SWAP_BE32(hfsPlusExtents[index].startBlock); } - else + else { start = SWAP_BE16(hfsExtents[index].startBlock); } - + return start; } @@ -1212,20 +1235,21 @@ static long GetExtentStart(void * extents, long index) static long GetExtentSize(void * extents, long index) { - long size; - HFSExtentDescriptor *hfsExtents = extents; - HFSPlusExtentDescriptor *hfsPlusExtents = extents; - - if (gIsHFSPlus) + long size = 0L; + + HFSExtentDescriptor *hfsExtents = extents; + HFSPlusExtentDescriptor *hfsPlusExtents = extents; + + if (gIsHFSPlus) { size = SWAP_BE32(hfsPlusExtents[index].blockCount); } - else + else { size = SWAP_BE16(hfsExtents[index].blockCount); } - - return size; + + return size; } @@ -1233,30 +1257,31 @@ static long GetExtentSize(void * extents, long index) static long CompareHFSCatalogKeys(void * key, void * testKey) { - HFSCatalogKey *searchKey, *trialKey; - long result, searchParentID, trialParentID; - - searchKey = key; - trialKey = testKey; - - searchParentID = SWAP_BE32(searchKey->parentID); - trialParentID = SWAP_BE32(trialKey->parentID); - - // parent dirID is unsigned - if (searchParentID > trialParentID) + HFSCatalogKey *searchKey, *trialKey; + long result, searchParentID, trialParentID; + + searchKey = key; + trialKey = testKey; + + searchParentID = SWAP_BE32(searchKey->parentID); + trialParentID = SWAP_BE32(trialKey->parentID); + + // parent dirID is unsigned + if (searchParentID > trialParentID) { result = 1; } - else if (searchParentID < trialParentID) + else if (searchParentID < trialParentID) { result = -1; } - else { - // parent dirID's are equal, compare names - result = FastRelString(searchKey->nodeName, trialKey->nodeName); - } - - return result; + else + { + // parent dirID's are equal, compare names + result = FastRelString(searchKey->nodeName, trialKey->nodeName); + } + + return result; } @@ -1264,48 +1289,44 @@ static long CompareHFSCatalogKeys(void * key, void * testKey) static long CompareHFSPlusCatalogKeys(void * key, void * testKey) { - HFSPlusCatalogKey *searchKey, *trialKey; - long result, searchParentID, trialParentID; - - searchKey = key; - trialKey = testKey; - - searchParentID = SWAP_BE32(searchKey->parentID); - trialParentID = SWAP_BE32(trialKey->parentID); - - // parent dirID is unsigned - if (searchParentID > trialParentID) + HFSPlusCatalogKey *searchKey, *trialKey; + long result, searchParentID, trialParentID; + + searchKey = key; + trialKey = testKey; + + searchParentID = SWAP_BE32(searchKey->parentID); + trialParentID = SWAP_BE32(trialKey->parentID); + + // parent dirID is unsigned + if (searchParentID > trialParentID) { result = 1; } - else if (searchParentID < trialParentID) + else if (searchParentID < trialParentID) { result = -1; } - else + else { - // parent dirID's are equal, compare names - if ((searchKey->nodeName.length == 0) || (trialKey->nodeName.length == 0)) + // parent dirID's are equal, compare names + if ((searchKey->nodeName.length == 0) || (trialKey->nodeName.length == 0)) { - result = searchKey->nodeName.length - trialKey->nodeName.length; + result = searchKey->nodeName.length - trialKey->nodeName.length; } - else if (gCaseSensitive) + else if (gCaseSensitive) { - result = BinaryUnicodeCompare(&searchKey->nodeName.unicode[0], - SWAP_BE16(searchKey->nodeName.length), - &trialKey->nodeName.unicode[0], - SWAP_BE16(trialKey->nodeName.length)); - } + result = BinaryUnicodeCompare(&searchKey->nodeName.unicode[0],SWAP_BE16(searchKey->nodeName.length), + &trialKey->nodeName.unicode[0], SWAP_BE16(trialKey->nodeName.length)); + } else { - result = FastUnicodeCompare(&searchKey->nodeName.unicode[0], - SWAP_BE16(searchKey->nodeName.length), - &trialKey->nodeName.unicode[0], - SWAP_BE16(trialKey->nodeName.length), OSBigEndian); - } - } - - return result; + result = FastUnicodeCompare(&searchKey->nodeName.unicode[0], SWAP_BE16(searchKey->nodeName.length), + &trialKey->nodeName.unicode[0], SWAP_BE16(trialKey->nodeName.length)); + } + } + + return result; } @@ -1313,26 +1334,26 @@ static long CompareHFSPlusCatalogKeys(void * key, void * testKey) static long CompareHFSExtentsKeys(void * key, void * testKey) { - HFSExtentKey *searchKey, *trialKey; - long result; - - searchKey = key; - trialKey = testKey; - - // assume searchKey < trialKey - result = -1; - - if (searchKey->fileID == trialKey->fileID) - { - // FileNum's are equal; compare fork types - if (searchKey->forkType == trialKey->forkType) + HFSExtentKey *searchKey, *trialKey; + long result; + + searchKey = key; + trialKey = testKey; + + // assume searchKey < trialKey + result = -1; + + if (searchKey->fileID == trialKey->fileID) + { + // FileNum's are equal; compare fork types + if (searchKey->forkType == trialKey->forkType) { - // Fork types are equal; compare allocation block number - if (searchKey->startBlock == trialKey->startBlock) + // Fork types are equal; compare allocation block number + if (searchKey->startBlock == trialKey->startBlock) { - // Everything is equal - result = 0; - } + // Everything is equal + result = 0; + } else { // Allocation block numbers differ; determine sign @@ -1341,26 +1362,26 @@ static long CompareHFSExtentsKeys(void * key, void * testKey) result = 1; } } - } + } else { // Fork types differ; determine sign - if (searchKey->forkType > trialKey->forkType) + if (searchKey->forkType > trialKey->forkType) { result = 1; } - } - } + } + } else { - // FileNums differ; determine sign - if (SWAP_BE32(searchKey->fileID) > SWAP_BE32(trialKey->fileID)) + // FileNums differ; determine sign + if (SWAP_BE32(searchKey->fileID) > SWAP_BE32(trialKey->fileID)) { - result = 1; + result = 1; } - } - - return result; + } + + return result; } @@ -1369,12 +1390,12 @@ static long CompareHFSExtentsKeys(void * key, void * testKey) static long CompareHFSPlusExtentsKeys(void * key, void * testKey) { HFSPlusExtentKey *searchKey, *trialKey; - + long result = -1; // assume searchKey < trialKey - - searchKey = key; - trialKey = testKey; - + + searchKey = key; + trialKey = testKey; + if (searchKey->fileID == trialKey->fileID) { // FileNum's are equal; compare fork types @@ -1385,7 +1406,7 @@ static long CompareHFSPlusExtentsKeys(void * key, void * testKey) { // Everything is equal result = 0; - } + } else { // Allocation block numbers differ; determine sign @@ -1393,8 +1414,8 @@ static long CompareHFSPlusExtentsKeys(void * key, void * testKey) { result = 1; } - } - } + } + } else { // Fork types differ; determine sign @@ -1403,16 +1424,15 @@ static long CompareHFSPlusExtentsKeys(void * key, void * testKey) result = 1; } } - } + } else { - // FileNums differ; determine sign - if (SWAP_BE32(searchKey->fileID) > SWAP_BE32(trialKey->fileID)) + // FileNums differ; determine sign + if (SWAP_BE32(searchKey->fileID) > SWAP_BE32(trialKey->fileID)) { result = 1; } } - - return result; + + return result; } - diff --git a/i386/libsaio/hfs_CaseTables.h b/i386/libsaio/hfs_CaseTables.h index 105007c..ac12604 100755 --- a/i386/libsaio/hfs_CaseTables.h +++ b/i386/libsaio/hfs_CaseTables.h @@ -18,41 +18,43 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ + * + * Updates: + * - Table data updated to match the XNU 2050.18.24 source code (PikerAlpha, November 2012) + * - Latin is now a seperate table, done to make it faster (PikerAlpha, November 2012) + * - Compressed and uncompressed table data is now 100% the same (PikerAlpha, November 2012) + * - UNCOMPRESSED renamed to USE_UNCOMPRESSED_TABLES (PikerAlpha, November 2012) + * - Cleanups and other reformatting to pull it out of the 90's (PikerAlpha, November 2012) + * - Table length errors fixed. Don't use 512/5632 instead of 256/2816 (PikerAlpha, November 2012) + * - Table data verified against HFSPlusX64.efi (PikerAlpha, November 2012) + * */ -/* - File: CaseTables.h -*/ -/* The lower case table consists of a 256-entry high-byte table followed by some number of - 256-entry subtables. The high-byte table contains either an offset to the subtable for - characters with that high byte or zero, which means that there are no case mappings or - ignored characters in that block. Ignored characters are mapped to zero. +/* + * The default setting is 1, but you can change it to 0 to use uncompressed + * table data. Making the booter 5152 bytes (data/extra code) bigger. */ -#if UNCOMPRESSED -u_int16_t gLowerCaseTable[] = { +#define USE_COMPRESSED_TABLES 1 - // High-byte indices ( == 0 iff no case mapping and no ignorables ) +/* Do NOT change this one! */ - /* 0 */ 0x0100, 0x0200, 0x0000, 0x0300, 0x0400, 0x0500, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* 1 */ 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* 2 */ 0x0700, 0x0800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* 3 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* 4 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* 5 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* 6 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* 7 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* 8 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* 9 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* A */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* B */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* C */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* D */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* E */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - /* F */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0900, 0x0A00, +#define USE_UNCOMPRESSED_TABLES ! USE_COMPRESSED_TABLES + + +#if USE_UNCOMPRESSED_TABLES +/*============================================================================== + * For better performance, the case folding table for basic latin + * is seperate from the others. This eliminates the extra lookup + * to get the offset to this table. + * + * Note: 0x0000 now maps to 0 so that it will be ignored + */ - // Table 1 (for high byte 0x00) +u_int16_t gLatinCaseFoldTable[] = +{ + // gLatinCaseFold in XNU/bsd/hfs/hfscommon/Unicode/UCStringCompareData.h) 512 bytes starting @ 0x4240 in HFSPlusX64.efi /* 0 */ 0xFFFF, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, /* 1 */ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, @@ -70,8 +72,38 @@ u_int16_t gLowerCaseTable[] = { /* D */ 0x00F0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00F8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00FE, 0x00DF, /* E */ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, /* F */ 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, +}; + + +/*============================================================================== + * The lower case table consists of a 256-entry high-byte table followed by some number of + * 256-entry subtables. The high-byte table contains either an offset to the subtable for + * characters with that high byte or zero, which means that there are no case mappings or + * ignored characters in that block. Ignored characters are mapped to zero. + */ + +u_int16_t gLowerCaseTable[] = +{ + /* Table 0 high-byte indices ( == 0 iff no case mapping and no ignorables ) 512 bytes starting @ 0x4440 in HFSPlusX64.efi */ + + /* 0 */ 0x0000, 0x0100, 0x0000, 0x0200, 0x0300, 0x0400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* 1 */ 0x0500, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* 2 */ 0x0600, 0x0700, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* 3 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* 4 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* 5 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* 6 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* 7 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* 8 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* 9 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* A */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* B */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* C */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* D */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* E */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + /* F */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0800, 0x0900, - // Table 2 (for high byte 0x01) + // Table 1 (for high byte 0x01) 512 bytes starting @ 0x4640 in HFSPlusX64.efi /* 0 */ 0x0100, 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, 0x0109, 0x010A, 0x010B, 0x010C, 0x010D, 0x010E, 0x010F, /* 1 */ 0x0111, 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118, 0x0119, 0x011A, 0x011B, 0x011C, 0x011D, 0x011E, 0x011F, @@ -90,7 +122,7 @@ u_int16_t gLowerCaseTable[] = { /* E */ 0x01E0, 0x01E1, 0x01E2, 0x01E3, 0x01E5, 0x01E5, 0x01E6, 0x01E7, 0x01E8, 0x01E9, 0x01EA, 0x01EB, 0x01EC, 0x01ED, 0x01EE, 0x01EF, /* F */ 0x01F0, 0x01F3, 0x01F3, 0x01F3, 0x01F4, 0x01F5, 0x01F6, 0x01F7, 0x01F8, 0x01F9, 0x01FA, 0x01FB, 0x01FC, 0x01FD, 0x01FE, 0x01FF, - // Table 3 (for high byte 0x03) + // Table 2 (for high byte 0x03) 512 bytes starting @ 0x4840 in HFSPlusX64.efi /* 0 */ 0x0300, 0x0301, 0x0302, 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308, 0x0309, 0x030A, 0x030B, 0x030C, 0x030D, 0x030E, 0x030F, /* 1 */ 0x0310, 0x0311, 0x0312, 0x0313, 0x0314, 0x0315, 0x0316, 0x0317, 0x0318, 0x0319, 0x031A, 0x031B, 0x031C, 0x031D, 0x031E, 0x031F, @@ -109,7 +141,7 @@ u_int16_t gLowerCaseTable[] = { /* E */ 0x03E0, 0x03E1, 0x03E3, 0x03E3, 0x03E5, 0x03E5, 0x03E7, 0x03E7, 0x03E9, 0x03E9, 0x03EB, 0x03EB, 0x03ED, 0x03ED, 0x03EF, 0x03EF, /* F */ 0x03F0, 0x03F1, 0x03F2, 0x03F3, 0x03F4, 0x03F5, 0x03F6, 0x03F7, 0x03F8, 0x03F9, 0x03FA, 0x03FB, 0x03FC, 0x03FD, 0x03FE, 0x03FF, - // Table 4 (for high byte 0x04) + // Table 3 (for high byte 0x04) 512 bytes starting @ 0x4A40 in HFSPlusX64.efi /* 0 */ 0x0400, 0x0401, 0x0452, 0x0403, 0x0454, 0x0455, 0x0456, 0x0407, 0x0458, 0x0459, 0x045A, 0x045B, 0x040C, 0x040D, 0x040E, 0x045F, /* 1 */ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0419, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, @@ -128,7 +160,7 @@ u_int16_t gLowerCaseTable[] = { /* E */ 0x04E0, 0x04E1, 0x04E2, 0x04E3, 0x04E4, 0x04E5, 0x04E6, 0x04E7, 0x04E8, 0x04E9, 0x04EA, 0x04EB, 0x04EC, 0x04ED, 0x04EE, 0x04EF, /* F */ 0x04F0, 0x04F1, 0x04F2, 0x04F3, 0x04F4, 0x04F5, 0x04F6, 0x04F7, 0x04F8, 0x04F9, 0x04FA, 0x04FB, 0x04FC, 0x04FD, 0x04FE, 0x04FF, - // Table 5 (for high byte 0x05) + // Table 4 (for high byte 0x05) 512 bytes starting @ 0x4C40 in HFSPlusX64.efi /* 0 */ 0x0500, 0x0501, 0x0502, 0x0503, 0x0504, 0x0505, 0x0506, 0x0507, 0x0508, 0x0509, 0x050A, 0x050B, 0x050C, 0x050D, 0x050E, 0x050F, /* 1 */ 0x0510, 0x0511, 0x0512, 0x0513, 0x0514, 0x0515, 0x0516, 0x0517, 0x0518, 0x0519, 0x051A, 0x051B, 0x051C, 0x051D, 0x051E, 0x051F, @@ -147,7 +179,7 @@ u_int16_t gLowerCaseTable[] = { /* E */ 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x05EB, 0x05EC, 0x05ED, 0x05EE, 0x05EF, /* F */ 0x05F0, 0x05F1, 0x05F2, 0x05F3, 0x05F4, 0x05F5, 0x05F6, 0x05F7, 0x05F8, 0x05F9, 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF, - // Table 6 (for high byte 0x10) + // Table 5 (for high byte 0x10) 512 bytes starting @ 0x4E40 in HFSPlusX64.efi /* 0 */ 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006, 0x1007, 0x1008, 0x1009, 0x100A, 0x100B, 0x100C, 0x100D, 0x100E, 0x100F, /* 1 */ 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016, 0x1017, 0x1018, 0x1019, 0x101A, 0x101B, 0x101C, 0x101D, 0x101E, 0x101F, @@ -166,7 +198,7 @@ u_int16_t gLowerCaseTable[] = { /* E */ 0x10E0, 0x10E1, 0x10E2, 0x10E3, 0x10E4, 0x10E5, 0x10E6, 0x10E7, 0x10E8, 0x10E9, 0x10EA, 0x10EB, 0x10EC, 0x10ED, 0x10EE, 0x10EF, /* F */ 0x10F0, 0x10F1, 0x10F2, 0x10F3, 0x10F4, 0x10F5, 0x10F6, 0x10F7, 0x10F8, 0x10F9, 0x10FA, 0x10FB, 0x10FC, 0x10FD, 0x10FE, 0x10FF, - // Table 7 (for high byte 0x20) + // Table 6 (for high byte 0x20) 512 bytes starting @ 0x5040 in HFSPlusX64.efi /* 0 */ 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x200B, 0x0000, 0x0000, 0x0000, 0x0000, /* 1 */ 0x2010, 0x2011, 0x2012, 0x2013, 0x2014, 0x2015, 0x2016, 0x2017, 0x2018, 0x2019, 0x201A, 0x201B, 0x201C, 0x201D, 0x201E, 0x201F, @@ -185,7 +217,7 @@ u_int16_t gLowerCaseTable[] = { /* E */ 0x20E0, 0x20E1, 0x20E2, 0x20E3, 0x20E4, 0x20E5, 0x20E6, 0x20E7, 0x20E8, 0x20E9, 0x20EA, 0x20EB, 0x20EC, 0x20ED, 0x20EE, 0x20EF, /* F */ 0x20F0, 0x20F1, 0x20F2, 0x20F3, 0x20F4, 0x20F5, 0x20F6, 0x20F7, 0x20F8, 0x20F9, 0x20FA, 0x20FB, 0x20FC, 0x20FD, 0x20FE, 0x20FF, - // Table 8 (for high byte 0x21) + // Table 7 (for high byte 0x21) 512 bytes starting @ 0x5240 in HFSPlusX64.efi /* 0 */ 0x2100, 0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107, 0x2108, 0x2109, 0x210A, 0x210B, 0x210C, 0x210D, 0x210E, 0x210F, /* 1 */ 0x2110, 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117, 0x2118, 0x2119, 0x211A, 0x211B, 0x211C, 0x211D, 0x211E, 0x211F, @@ -204,7 +236,7 @@ u_int16_t gLowerCaseTable[] = { /* E */ 0x21E0, 0x21E1, 0x21E2, 0x21E3, 0x21E4, 0x21E5, 0x21E6, 0x21E7, 0x21E8, 0x21E9, 0x21EA, 0x21EB, 0x21EC, 0x21ED, 0x21EE, 0x21EF, /* F */ 0x21F0, 0x21F1, 0x21F2, 0x21F3, 0x21F4, 0x21F5, 0x21F6, 0x21F7, 0x21F8, 0x21F9, 0x21FA, 0x21FB, 0x21FC, 0x21FD, 0x21FE, 0x21FF, - // Table 9 (for high byte 0xFE) + // Table 8 (for high byte 0xFE) 512 bytes starting @ 0x5440 in HFSPlusX64.efi /* 0 */ 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, /* 1 */ 0xFE10, 0xFE11, 0xFE12, 0xFE13, 0xFE14, 0xFE15, 0xFE16, 0xFE17, 0xFE18, 0xFE19, 0xFE1A, 0xFE1B, 0xFE1C, 0xFE1D, 0xFE1E, 0xFE1F, @@ -223,7 +255,7 @@ u_int16_t gLowerCaseTable[] = { /* E */ 0xFEE0, 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4, 0xFEE5, 0xFEE6, 0xFEE7, 0xFEE8, 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC, 0xFEED, 0xFEEE, 0xFEEF, /* F */ 0xFEF0, 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7, 0xFEF8, 0xFEF9, 0xFEFA, 0xFEFB, 0xFEFC, 0xFEFD, 0xFEFE, 0x0000, - // Table 10 (for high byte 0xFF) + // Table 9 (for high byte 0xFF) 512 bytes starting @ 0x5640 in HFSPlusX64.efi /* 0 */ 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05, 0xFF06, 0xFF07, 0xFF08, 0xFF09, 0xFF0A, 0xFF0B, 0xFF0C, 0xFF0D, 0xFF0E, 0xFF0F, /* 1 */ 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17, 0xFF18, 0xFF19, 0xFF1A, 0xFF1B, 0xFF1C, 0xFF1D, 0xFF1E, 0xFF1F, @@ -245,8 +277,8 @@ u_int16_t gLowerCaseTable[] = { /* RelString case folding table */ -unsigned short gCompareTable[] = { - +unsigned short gCompareTable[] = +{ /* 0 */ 0x0000, 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700, 0x0800, 0x0900, 0x0A00, 0x0B00, 0x0C00, 0x0D00, 0x0E00, 0x0F00, /* 1 */ 0x1000, 0x1100, 0x1200, 0x1300, 0x1400, 0x1500, 0x1600, 0x1700, 0x1800, 0x1900, 0x1A00, 0x1B00, 0x1C00, 0x1D00, 0x1E00, 0x1F00, /* 2 */ 0x2000, 0x2100, 0x2200, 0x2300, 0x2400, 0x2500, 0x2600, 0x2700, 0x2800, 0x2900, 0x2A00, 0x2B00, 0x2C00, 0x2D00, 0x2E00, 0x2F00, @@ -261,7 +293,7 @@ unsigned short gCompareTable[] = { /* 7 */ 0x5000, 0x5100, 0x5200, 0x5300, 0x5400, 0x5500, 0x5600, 0x5700, 0x5800, 0x5900, 0x5A00, 0x7B00, 0x7C00, 0x7D00, 0x7E00, 0x7F00, // range 0x80 to 0xd8 gets mapped... - + /* 8 */ 0x4108, 0x410C, 0x4310, 0x4502, 0x4E0A, 0x4F08, 0x5508, 0x4182, 0x4104, 0x4186, 0x4108, 0x410A, 0x410C, 0x4310, 0x4502, 0x4584, /* 9 */ 0x4586, 0x4588, 0x4982, 0x4984, 0x4986, 0x4988, 0x4E0A, 0x4F82, 0x4F84, 0x4F86, 0x4F08, 0x4F0A, 0x5582, 0x5584, 0x5586, 0x5508, /* A */ 0xA000, 0xA100, 0xA200, 0xA300, 0xA400, 0xA500, 0xA600, 0x5382, 0xA800, 0xA900, 0xAA00, 0xAB00, 0xAC00, 0xAD00, 0x4114, 0x4F0E, @@ -271,290 +303,317 @@ unsigned short gCompareTable[] = { /* E */ 0xE000, 0xE100, 0xE200, 0xE300, 0xE400, 0xE500, 0xE600, 0xE700, 0xE800, 0xE900, 0xEA00, 0xEB00, 0xEC00, 0xED00, 0xEE00, 0xEF00, /* F */ 0xF000, 0xF100, 0xF200, 0xF300, 0xF400, 0xF500, 0xF600, 0xF700, 0xF800, 0xF900, 0xFA00, 0xFB00, 0xFC00, 0xFD00, 0xFE00, 0xFF00, - }; -#else /* ! UNCOMPRESSED */ +#else -enum { - kTypeLiteral = 0, - kTypeAscending = 1, - kTypeAscending256 = 2 +enum +{ + kTypeLiteral = 0, + kTypeAscending = 1, + kTypeAscending256 = 2 }; -struct compressed_block { - unsigned char type; - unsigned char count; - unsigned short data; +struct CompressedBlock +{ + unsigned char type; + unsigned char count; + unsigned short data; }; +unsigned short *gLatinCaseFoldTable; unsigned short *gLowerCaseTable; +unsigned short *gCompareTable; -struct compressed_block gLowerCaseTableCompressed[] = { - {0x0, 0x1, 0x100}, - {0x0, 0x1, 0x200}, - {0x0, 0x1, 0x0}, - {0x0, 0x1, 0x300}, - {0x0, 0x1, 0x400}, - {0x0, 0x1, 0x500}, - {0x0, 0xa, 0x0}, - {0x0, 0x1, 0x600}, - {0x0, 0xf, 0x0}, - {0x0, 0x1, 0x700}, - {0x0, 0x1, 0x800}, - {0x0, 0xdc, 0x0}, - {0x0, 0x1, 0x900}, - {0x0, 0x1, 0xa00}, - {0x0, 0x1, 0xffff}, - {0x1, 0x40, 0x1}, - {0x1, 0x1a, 0x61}, - {0x1, 0x6b, 0x5b}, - {0x0, 0x1, 0xe6}, - {0x1, 0x9, 0xc7}, - {0x0, 0x1, 0xf0}, - {0x1, 0x7, 0xd1}, - {0x0, 0x1, 0xf8}, - {0x1, 0x5, 0xd9}, - {0x0, 0x1, 0xfe}, - {0x1, 0x31, 0xdf}, - {0x0, 0x2, 0x111}, - {0x1, 0x14, 0x112}, - {0x0, 0x2, 0x127}, - {0x1, 0xa, 0x128}, - {0x0, 0x2, 0x133}, - {0x1, 0xb, 0x134}, - {0x0, 0x2, 0x140}, - {0x0, 0x2, 0x142}, - {0x1, 0x7, 0x143}, - {0x0, 0x2, 0x14b}, - {0x1, 0x6, 0x14c}, - {0x0, 0x2, 0x153}, - {0x1, 0x12, 0x154}, - {0x0, 0x2, 0x167}, - {0x1, 0x19, 0x168}, - {0x0, 0x1, 0x253}, - {0x0, 0x2, 0x183}, - {0x0, 0x2, 0x185}, - {0x0, 0x1, 0x254}, - {0x0, 0x2, 0x188}, - {0x1, 0x2, 0x256}, - {0x0, 0x2, 0x18c}, - {0x0, 0x1, 0x18d}, - {0x0, 0x1, 0x1dd}, - {0x0, 0x1, 0x259}, - {0x0, 0x1, 0x25b}, - {0x0, 0x2, 0x192}, - {0x0, 0x1, 0x260}, - {0x0, 0x1, 0x263}, - {0x0, 0x1, 0x195}, - {0x0, 0x1, 0x269}, - {0x0, 0x1, 0x268}, - {0x0, 0x2, 0x199}, - {0x1, 0x2, 0x19a}, - {0x0, 0x1, 0x26f}, - {0x0, 0x1, 0x272}, - {0x0, 0x1, 0x19e}, - {0x0, 0x1, 0x275}, - {0x1, 0x2, 0x1a0}, - {0x0, 0x2, 0x1a3}, - {0x0, 0x2, 0x1a5}, - {0x0, 0x1, 0x1a6}, - {0x0, 0x2, 0x1a8}, - {0x0, 0x1, 0x283}, - {0x1, 0x2, 0x1aa}, - {0x0, 0x2, 0x1ad}, - {0x0, 0x1, 0x288}, - {0x1, 0x2, 0x1af}, - {0x1, 0x2, 0x28a}, - {0x0, 0x2, 0x1b4}, - {0x0, 0x2, 0x1b6}, - {0x0, 0x1, 0x292}, - {0x0, 0x2, 0x1b9}, - {0x1, 0x2, 0x1ba}, - {0x0, 0x2, 0x1bd}, - {0x1, 0x6, 0x1be}, - {0x0, 0x3, 0x1c6}, - {0x0, 0x3, 0x1c9}, - {0x0, 0x3, 0x1cc}, - {0x1, 0x17, 0x1cd}, - {0x0, 0x2, 0x1e5}, - {0x1, 0xb, 0x1e6}, - {0x0, 0x3, 0x1f3}, - {0x1, 0xc, 0x1f4}, - {0x1, 0x91, 0x300}, - {0x1, 0x11, 0x3b1}, - {0x0, 0x1, 0x3a2}, - {0x1, 0x7, 0x3c3}, - {0x1, 0x38, 0x3aa}, - {0x0, 0x2, 0x3e3}, - {0x0, 0x2, 0x3e5}, - {0x0, 0x2, 0x3e7}, - {0x0, 0x2, 0x3e9}, - {0x0, 0x2, 0x3eb}, - {0x0, 0x2, 0x3ed}, - {0x0, 0x2, 0x3ef}, - {0x1, 0x12, 0x3f0}, - {0x0, 0x1, 0x452}, - {0x0, 0x1, 0x403}, - {0x1, 0x3, 0x454}, - {0x0, 0x1, 0x407}, - {0x1, 0x4, 0x458}, - {0x1, 0x3, 0x40c}, - {0x0, 0x1, 0x45f}, - {0x1, 0x9, 0x430}, - {0x0, 0x1, 0x419}, - {0x1, 0x16, 0x43a}, - {0x1, 0x30, 0x430}, - {0x0, 0x2, 0x461}, - {0x0, 0x2, 0x463}, - {0x0, 0x2, 0x465}, - {0x0, 0x2, 0x467}, - {0x0, 0x2, 0x469}, - {0x0, 0x2, 0x46b}, - {0x0, 0x2, 0x46d}, - {0x0, 0x2, 0x46f}, - {0x0, 0x2, 0x471}, - {0x0, 0x2, 0x473}, - {0x0, 0x2, 0x475}, - {0x1, 0x2, 0x476}, - {0x0, 0x2, 0x479}, - {0x0, 0x2, 0x47b}, - {0x0, 0x2, 0x47d}, - {0x0, 0x2, 0x47f}, - {0x0, 0x2, 0x481}, - {0x1, 0xe, 0x482}, - {0x0, 0x2, 0x491}, - {0x0, 0x2, 0x493}, - {0x0, 0x2, 0x495}, - {0x0, 0x2, 0x497}, - {0x0, 0x2, 0x499}, - {0x0, 0x2, 0x49b}, - {0x0, 0x2, 0x49d}, - {0x0, 0x2, 0x49f}, - {0x0, 0x2, 0x4a1}, - {0x0, 0x2, 0x4a3}, - {0x0, 0x2, 0x4a5}, - {0x0, 0x2, 0x4a7}, - {0x0, 0x2, 0x4a9}, - {0x0, 0x2, 0x4ab}, - {0x0, 0x2, 0x4ad}, - {0x0, 0x2, 0x4af}, - {0x0, 0x2, 0x4b1}, - {0x0, 0x2, 0x4b3}, - {0x0, 0x2, 0x4b5}, - {0x0, 0x2, 0x4b7}, - {0x0, 0x2, 0x4b9}, - {0x0, 0x2, 0x4bb}, - {0x0, 0x2, 0x4bd}, - {0x0, 0x2, 0x4bf}, - {0x1, 0x3, 0x4c0}, - {0x0, 0x2, 0x4c4}, - {0x1, 0x2, 0x4c5}, - {0x0, 0x2, 0x4c8}, - {0x1, 0x2, 0x4c9}, - {0x0, 0x2, 0x4cc}, - {0x1, 0x64, 0x4cd}, - {0x1, 0x26, 0x561}, - {0x1, 0xa9, 0x557}, - {0x1, 0xa0, 0x1000}, - {0x1, 0x26, 0x10d0}, - {0x1, 0x3a, 0x10c6}, - {0x1, 0xc, 0x2000}, - {0x0, 0x4, 0x0}, - {0x1, 0x1a, 0x2010}, - {0x0, 0x5, 0x0}, - {0x1, 0x3b, 0x202f}, - {0x0, 0x6, 0x0}, - {0x1, 0xf0, 0x2070}, - {0x1, 0x10, 0x2170}, - {0x1, 0x90, 0x2170}, - {0x1, 0xff, 0xfe00}, - {0x0, 0x1, 0x0}, - {0x1, 0x21, 0xff00}, - {0x1, 0x1a, 0xff41}, - {0x1, 0xc5, 0xff3b}, +struct CompressedBlock gLatinCaseFoldTableCompressed[] = +{ + { kTypeLiteral, 0x01, 0xffff }, + { kTypeAscending, 0x40, 0x0001 }, + { kTypeAscending, 0x1a, 0x0061 }, + { kTypeAscending, 0x6b, 0x005b }, + { kTypeLiteral, 0x01, 0x00e6 }, + { kTypeAscending, 0x09, 0x00c7 }, + { kTypeLiteral, 0x01, 0x00f0 }, + { kTypeAscending, 0x07, 0x00d1 }, + { kTypeLiteral, 0x01, 0x00f8 }, + { kTypeAscending, 0x05, 0x00d9 }, + { kTypeLiteral, 0x01, 0x00fe }, + { kTypeAscending, 0x21, 0x00df } +}; + +struct CompressedBlock gLowerCaseTableCompressed[] = +{ + /* Table 0 */ + { kTypeLiteral, 0x01, 0x0000 }, + { kTypeLiteral, 0x01, 0x0100 }, + { kTypeLiteral, 0x01, 0x0000 }, + { kTypeLiteral, 0x01, 0x0200 }, + { kTypeLiteral, 0x01, 0x0300 }, + { kTypeLiteral, 0x01, 0x0400 }, + { kTypeLiteral, 0x0a, 0x0000 }, + { kTypeLiteral, 0x01, 0x0500 }, + { kTypeLiteral, 0x0f, 0x0000 }, + { kTypeLiteral, 0x01, 0x0600 }, + { kTypeLiteral, 0x01, 0x0700 }, + { kTypeLiteral, 0xdc, 0x0000 }, + { kTypeLiteral, 0x01, 0x0800 }, + { kTypeLiteral, 0x01, 0x0900 }, + + /* Table 1 */ + { kTypeAscending, 0x10, 0x0100 }, + { kTypeLiteral, 0x01, 0x0111 }, + { kTypeAscending, 0x15, 0x0111 }, + { kTypeLiteral, 0x01, 0x0127 }, + { kTypeAscending, 0x0b, 0x0127 }, + { kTypeLiteral, 0x01, 0x0133 }, + { kTypeAscending, 0x0c, 0x0133 }, + { kTypeLiteral, 0x02, 0x0140 }, + { kTypeLiteral, 0x01, 0x0142 }, + { kTypeAscending, 0x08, 0x0142 }, + { kTypeLiteral, 0x01, 0x014b }, + { kTypeAscending, 0x07, 0x014b }, + { kTypeLiteral, 0x01, 0x0153 }, + { kTypeAscending, 0x13, 0x0153 }, + { kTypeLiteral, 0x01, 0x0167 }, + { kTypeAscending, 0x1a, 0x0167 }, + { kTypeLiteral, 0x01, 0x0253 }, + { kTypeLiteral, 0x02, 0x0183 }, + { kTypeLiteral, 0x02, 0x0185 }, + { kTypeLiteral, 0x01, 0x0254 }, + { kTypeLiteral, 0x02, 0x0188 }, + { kTypeAscending, 0x02, 0x0256 }, + { kTypeLiteral, 0x01, 0x018c }, + { kTypeAscending, 0x02, 0x018c }, + { kTypeLiteral, 0x01, 0x01dd }, + { kTypeLiteral, 0x01, 0x0259 }, + { kTypeLiteral, 0x01, 0x025b }, + { kTypeLiteral, 0x02, 0x0192 }, + { kTypeLiteral, 0x01, 0x0260 }, + { kTypeLiteral, 0x01, 0x0263 }, + { kTypeLiteral, 0x01, 0x0195 }, + { kTypeLiteral, 0x01, 0x0269 }, + { kTypeLiteral, 0x01, 0x0268 }, + { kTypeLiteral, 0x01, 0x0199 }, + { kTypeAscending, 0x03, 0x0199 }, + { kTypeLiteral, 0x01, 0x026f }, + { kTypeLiteral, 0x01, 0x0272 }, + { kTypeLiteral, 0x01, 0x019e }, + { kTypeLiteral, 0x01, 0x0275 }, + { kTypeAscending, 0x02, 0x01a0 }, + { kTypeLiteral, 0x02, 0x01a3 }, + { kTypeLiteral, 0x02, 0x01a5 }, + { kTypeLiteral, 0x01, 0x01a6 }, + { kTypeLiteral, 0x02, 0x01a8 }, + { kTypeLiteral, 0x01, 0x0283 }, + { kTypeAscending, 0x02, 0x01aa }, + { kTypeLiteral, 0x02, 0x01ad }, + { kTypeLiteral, 0x01, 0x0288 }, + { kTypeAscending, 0x02, 0x01af }, + { kTypeAscending, 0x02, 0x028a }, + { kTypeLiteral, 0x02, 0x01b4 }, + { kTypeLiteral, 0x02, 0x01b6 }, + { kTypeLiteral, 0x01, 0x0292 }, + { kTypeLiteral, 0x02, 0x01b9 }, + { kTypeAscending, 0x02, 0x01ba }, + { kTypeLiteral, 0x01, 0x01bd }, + { kTypeAscending, 0x07, 0x01bd }, + { kTypeLiteral, 0x03, 0x01c6 }, + { kTypeLiteral, 0x03, 0x01c9 }, + { kTypeLiteral, 0x02, 0x01cc }, + { kTypeAscending, 0x18, 0x01cc }, + { kTypeLiteral, 0x01, 0x01e5 }, + { kTypeAscending, 0x0c, 0x01e5 }, + { kTypeLiteral, 0x02, 0x01f3 }, + { kTypeAscending, 0x0d, 0x01f3 }, + + /* Table 2 */ + { kTypeAscending, 0x91, 0x0300 }, + { kTypeAscending, 0x11, 0x03b1 }, + { kTypeLiteral, 0x01, 0x03a2 }, + { kTypeAscending, 0x07, 0x03c3 }, + { kTypeAscending, 0x38, 0x03aa }, + { kTypeLiteral, 0x02, 0x03e3 }, + { kTypeLiteral, 0x02, 0x03e5 }, + { kTypeLiteral, 0x02, 0x03e7 }, + { kTypeLiteral, 0x02, 0x03e9 }, + { kTypeLiteral, 0x02, 0x03eb }, + { kTypeLiteral, 0x02, 0x03ed }, + { kTypeLiteral, 0x02, 0x03ef }, + { kTypeAscending, 0x10, 0x03f0 }, + + /* Table 3 */ + { kTypeAscending, 0x02, 0x0400 }, + { kTypeLiteral, 0x01, 0x0452 }, + { kTypeLiteral, 0x01, 0x0403 }, + { kTypeAscending, 0x03, 0x0454 }, + { kTypeLiteral, 0x01, 0x0407 }, + { kTypeAscending, 0x04, 0x0458 }, + { kTypeAscending, 0x03, 0x040c }, + { kTypeLiteral, 0x01, 0x045f }, + { kTypeAscending, 0x09, 0x0430 }, + { kTypeLiteral, 0x01, 0x0419 }, + { kTypeAscending, 0x16, 0x043a }, + { kTypeAscending, 0x30, 0x0430 }, + { kTypeLiteral, 0x02, 0x0461 }, + { kTypeLiteral, 0x02, 0x0463 }, + { kTypeLiteral, 0x02, 0x0465 }, + { kTypeLiteral, 0x02, 0x0467 }, + { kTypeLiteral, 0x02, 0x0469 }, + { kTypeLiteral, 0x02, 0x046b }, + { kTypeLiteral, 0x02, 0x046d }, + { kTypeLiteral, 0x02, 0x046f }, + { kTypeLiteral, 0x02, 0x0471 }, + { kTypeLiteral, 0x02, 0x0473 }, + { kTypeLiteral, 0x02, 0x0475 }, + { kTypeAscending, 0x02, 0x0476 }, + { kTypeLiteral, 0x02, 0x0479 }, + { kTypeLiteral, 0x02, 0x047b }, + { kTypeLiteral, 0x02, 0x047d }, + { kTypeLiteral, 0x02, 0x047f }, + { kTypeLiteral, 0x02, 0x0481 }, + { kTypeAscending, 0x0e, 0x0482 }, + { kTypeLiteral, 0x02, 0x0491 }, + { kTypeLiteral, 0x02, 0x0493 }, + { kTypeLiteral, 0x02, 0x0495 }, + { kTypeLiteral, 0x02, 0x0497 }, + { kTypeLiteral, 0x02, 0x0499 }, + { kTypeLiteral, 0x02, 0x049b }, + { kTypeLiteral, 0x02, 0x049d }, + { kTypeLiteral, 0x02, 0x049f }, + { kTypeLiteral, 0x02, 0x04a1 }, + { kTypeLiteral, 0x02, 0x04a3 }, + { kTypeLiteral, 0x02, 0x04a5 }, + { kTypeLiteral, 0x02, 0x04a7 }, + { kTypeLiteral, 0x02, 0x04a9 }, + { kTypeLiteral, 0x02, 0x04ab }, + { kTypeLiteral, 0x02, 0x04ad }, + { kTypeLiteral, 0x02, 0x04af }, + { kTypeLiteral, 0x02, 0x04b1 }, + { kTypeLiteral, 0x02, 0x04b3 }, + { kTypeLiteral, 0x02, 0x04b5 }, + { kTypeLiteral, 0x02, 0x04b7 }, + { kTypeLiteral, 0x02, 0x04b9 }, + { kTypeLiteral, 0x02, 0x04bb }, + { kTypeLiteral, 0x02, 0x04bd }, + { kTypeLiteral, 0x02, 0x04bf }, + { kTypeAscending, 0x03, 0x04c0 }, + { kTypeLiteral, 0x02, 0x04c4 }, + { kTypeAscending, 0x02, 0x04c5 }, + { kTypeLiteral, 0x02, 0x04c8 }, + { kTypeAscending, 0x02, 0x04c9 }, + { kTypeLiteral, 0x01, 0x04cc }, + { kTypeAscending, 0x34, 0x04cc }, + + /* Table 4 */ + { kTypeAscending, 0x31, 0x0500 }, + { kTypeAscending, 0x26, 0x0561 }, + { kTypeAscending, 0xa9, 0x0557 }, + + /* Table 5 */ + { kTypeAscending, 0xa0, 0x1000 }, + { kTypeAscending, 0x26, 0x10d0 }, + { kTypeAscending, 0x3a, 0x10c6 }, + + /* Table 6 */ + { kTypeAscending, 0x0c, 0x2000 }, + { kTypeLiteral, 0x04, 0x0000 }, + { kTypeAscending, 0x1a, 0x2010 }, + { kTypeLiteral, 0x05, 0x0000 }, + { kTypeAscending, 0x3b, 0x202f }, + { kTypeLiteral, 0x06, 0x0000 }, + { kTypeAscending, 0x90, 0x2070 }, + + /* Table 7 */ + { kTypeLiteral, 0x01, 0x2100 }, + { kTypeAscending, 0x5f, 0x2101 }, + { kTypeAscending, 0x10, 0x2170 }, + { kTypeAscending, 0x90, 0x2170 }, + + /* Table 8 */ + { kTypeAscending, 0xff, 0xfe00 }, + { kTypeLiteral, 0x01, 0x0000 }, + + /* Table 9 */ + { kTypeAscending, 0x21, 0xff00 }, + { kTypeAscending, 0x1a, 0xff41 }, + { kTypeAscending, 0xc5, 0xff3b } }; -// Please update count if you add/remove entries but also please just let -// the compiler calculate it so you don't get it wrong. -//#define kLowerCaseTableNBlocks 182 -#define kLowerCaseTableNBlocks (sizeof(gLowerCaseTableCompressed)/sizeof(*gLowerCaseTableCompressed)) -// WARNING: The expanded size MUST be updated if you change the table and -// cannot be calculated at compile time. -#define kLowerCaseTableDataSize 5632 /* size of uncompressed structure in bytes */ -unsigned short *gCompareTable; -struct compressed_block gCompareTableCompressed[] = { - {0x2, 0x60, 0x0}, - {0x0, 0x1, 0x4180}, - {0x2, 0x1a, 0x4100}, - {0x2, 0x5, 0x7b00}, - {0x0, 0x1, 0x4108}, - {0x0, 0x1, 0x410c}, - {0x0, 0x1, 0x4310}, - {0x0, 0x1, 0x4502}, - {0x0, 0x1, 0x4e0a}, - {0x0, 0x1, 0x4f08}, - {0x0, 0x1, 0x5508}, - {0x0, 0x1, 0x4182}, - {0x0, 0x1, 0x4104}, - {0x0, 0x1, 0x4186}, - {0x0, 0x1, 0x4108}, - {0x0, 0x1, 0x410a}, - {0x0, 0x1, 0x410c}, - {0x0, 0x1, 0x4310}, - {0x0, 0x1, 0x4502}, - {0x0, 0x1, 0x4584}, - {0x0, 0x1, 0x4586}, - {0x0, 0x1, 0x4588}, - {0x0, 0x1, 0x4982}, - {0x0, 0x1, 0x4984}, - {0x0, 0x1, 0x4986}, - {0x0, 0x1, 0x4988}, - {0x0, 0x1, 0x4e0a}, - {0x0, 0x1, 0x4f82}, - {0x0, 0x1, 0x4f84}, - {0x0, 0x1, 0x4f86}, - {0x0, 0x1, 0x4f08}, - {0x0, 0x1, 0x4f0a}, - {0x0, 0x1, 0x5582}, - {0x0, 0x1, 0x5584}, - {0x0, 0x1, 0x5586}, - {0x0, 0x1, 0x5508}, - {0x2, 0x7, 0xa000}, - {0x0, 0x1, 0x5382}, - {0x2, 0x6, 0xa800}, - {0x0, 0x1, 0x4114}, - {0x0, 0x1, 0x4f0e}, - {0x2, 0xb, 0xb000}, - {0x0, 0x1, 0x4192}, - {0x0, 0x1, 0x4f92}, - {0x0, 0x1, 0xbd00}, - {0x0, 0x1, 0x4114}, - {0x0, 0x1, 0x4f0e}, - {0x2, 0x7, 0xc000}, - {0x0, 0x1, 0x2206}, - {0x0, 0x1, 0x2208}, - {0x0, 0x1, 0xc900}, - {0x0, 0x1, 0x2000}, - {0x0, 0x1, 0x4104}, - {0x0, 0x1, 0x410a}, - {0x0, 0x1, 0x4f0a}, - {0x0, 0x2, 0x4f14}, - {0x2, 0x2, 0xd000}, - {0x0, 0x1, 0x2202}, - {0x0, 0x1, 0x2204}, - {0x0, 0x1, 0x2702}, - {0x0, 0x1, 0x2704}, - {0x2, 0x2, 0xd600}, - {0x0, 0x1, 0x5988}, - {0x2, 0x27, 0xd900}, +struct CompressedBlock gCompareTableCompressed[] = +{ + { kTypeAscending256, 0x60, 0x0000 }, + { kTypeLiteral, 0x01, 0x4180 }, + { kTypeAscending256, 0x1a, 0x4100 }, + { kTypeAscending256, 0x05, 0x7b00 }, + { kTypeLiteral, 0x01, 0x4108 }, + { kTypeLiteral, 0x01, 0x410c }, + { kTypeLiteral, 0x01, 0x4310 }, + { kTypeLiteral, 0x01, 0x4502 }, + { kTypeLiteral, 0x01, 0x4e0a }, + { kTypeLiteral, 0x01, 0x4f08 }, + { kTypeLiteral, 0x01, 0x5508 }, + { kTypeLiteral, 0x01, 0x4182 }, + { kTypeLiteral, 0x01, 0x4104 }, + { kTypeLiteral, 0x01, 0x4186 }, + { kTypeLiteral, 0x01, 0x4108 }, + { kTypeLiteral, 0x01, 0x410a }, + { kTypeLiteral, 0x01, 0x410c }, + { kTypeLiteral, 0x01, 0x4310 }, + { kTypeLiteral, 0x01, 0x4502 }, + { kTypeLiteral, 0x01, 0x4584 }, + { kTypeLiteral, 0x01, 0x4586 }, + { kTypeLiteral, 0x01, 0x4588 }, + { kTypeLiteral, 0x01, 0x4982 }, + { kTypeLiteral, 0x01, 0x4984 }, + { kTypeLiteral, 0x01, 0x4986 }, + { kTypeLiteral, 0x01, 0x4988 }, + { kTypeLiteral, 0x01, 0x4e0a }, + { kTypeLiteral, 0x01, 0x4f82 }, + { kTypeLiteral, 0x01, 0x4f84 }, + { kTypeLiteral, 0x01, 0x4f86 }, + { kTypeLiteral, 0x01, 0x4f08 }, + { kTypeLiteral, 0x01, 0x4f0a }, + { kTypeLiteral, 0x01, 0x5582 }, + { kTypeLiteral, 0x01, 0x5584 }, + { kTypeLiteral, 0x01, 0x5586 }, + { kTypeLiteral, 0x01, 0x5508 }, + { kTypeAscending256, 0x07, 0xa000 }, + { kTypeLiteral, 0x01, 0x5382 }, + { kTypeAscending256, 0x06, 0xa800 }, + { kTypeLiteral, 0x01, 0x4114 }, + { kTypeLiteral, 0x01, 0x4f0e }, + { kTypeAscending256, 0x0b, 0xb000 }, + { kTypeLiteral, 0x01, 0x4192 }, + { kTypeLiteral, 0x01, 0x4f92 }, + { kTypeLiteral, 0x01, 0xbd00 }, + { kTypeLiteral, 0x01, 0x4114 }, + { kTypeLiteral, 0x01, 0x4f0e }, + { kTypeAscending256, 0x07, 0xc000 }, + { kTypeLiteral, 0x01, 0x2206 }, + { kTypeLiteral, 0x01, 0x2208 }, + { kTypeLiteral, 0x01, 0xc900 }, + { kTypeLiteral, 0x01, 0x2000 }, + { kTypeLiteral, 0x01, 0x4104 }, + { kTypeLiteral, 0x01, 0x410a }, + { kTypeLiteral, 0x01, 0x4f0a }, + { kTypeLiteral, 0x02, 0x4f14 }, + { kTypeAscending256, 0x02, 0xd000 }, + { kTypeLiteral, 0x01, 0x2202 }, + { kTypeLiteral, 0x01, 0x2204 }, + { kTypeLiteral, 0x01, 0x2702 }, + { kTypeLiteral, 0x01, 0x2704 }, + { kTypeAscending256, 0x02, 0xd600 }, + { kTypeLiteral, 0x01, 0x5988 }, + { kTypeAscending256, 0x27, 0xd900 }, }; -// Please update count if you add/remove entries but also please just let -// the compiler calculate it so you don't get it wrong. -//#define kCompareTableNBlocks 64 -#define kCompareTableNBlocks (sizeof(gCompareTableCompressed)/sizeof(*gCompareTableCompressed)) -// WARNING: The expanded size MUST be updated if you change the table and -// cannot be calculated at compile time. -#define kCompareTableDataSize 512 /* size of uncompressed structure in bytes */ - -#endif /* UNCOMPRESSED */ + + +#define kLatinCaseFoldTableNBlocks (sizeof(gLatinCaseFoldTableCompressed) / sizeof(*gLatinCaseFoldTableCompressed)) +#define kLowerCaseTableNBlocks (sizeof(gLowerCaseTableCompressed) / sizeof(*gLowerCaseTableCompressed)) +#define kCompareTableNBlocks (sizeof(gCompareTableCompressed) / sizeof(*gCompareTableCompressed)) + +#define kLatinCaseFoldTableDataSize 256 +#define kLowerCaseTableDataSize 2816 +#define kCompareTableDataSize 256 + +#endif /* USE_UNCOMPRESSED_TABLES */ diff --git a/i386/libsaio/hfs_compare.c b/i386/libsaio/hfs_compare.c index 405a571..6b61cd6 100755 --- a/i386/libsaio/hfs_compare.c +++ b/i386/libsaio/hfs_compare.c @@ -7,7 +7,7 @@ * are subject to the Apple Public Source License Version 2.0 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * http: *www.apple.com/publicsource and read it before using this file. * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER @@ -18,89 +18,127 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ - */ -/* - * HFSCompare.c - Functions for working with and comparing HFS nams. * - * Copyright (c) 1999-2000 Apple Computer, Inc. + * HFSCompare.c - Functions for working with and comparing HFS nams. + * + * Copyright (c) 1999-2000 Apple Computer, Inc. + * + * DRI: Josh de Cesare + * + * Updates: + * - Latin is now a seperate table, done to make it faster (PikerAlpha, November 2012) + * - UNCOMPRESSED renamed to USE_UNCOMPRESSED_TABLES (PikerAlpha, November 2012) + * - Cleanups and other reformatting to pull it out of the 90's (PikerAlpha, November 2012) * - * DRI: Josh de Cesare */ #include #include "hfs_CaseTables.h" -#if ! UNCOMPRESSED -static unsigned short * UncompressStructure(struct compressed_block *bp, int count, int size) +#if USE_COMPRESSED_TABLES +//============================================================================== + +static unsigned short * deCompressStructure(struct CompressedBlock *cb, int count, int size) { - unsigned short *out = malloc(size); - unsigned short *op = out; - unsigned short data; - int i, j; - - for (i=0; icount) - { - stop("HFS+ Unicode tables are malformed\n"); - } - data = bp->data; - for (j=0; jcount; j++) { - *op++ = data; - if (bp->type == kTypeAscending) data++; - else if (bp->type == kTypeAscending256) data += 256; - } - } - return out; + int i, j; + + unsigned short *out = malloc(size); + + if (out) + { + unsigned short *op = out; + unsigned short data; + + for (i = 0; i < count; i++, cb++) + { + /* If this happens (it shouldn't) please fix size and/or double check that count really is + * the number of elements in the array. + * This was a very hard bug to find, so please leave this code here. + */ +#if DEBUG + if ((out + size) <= (op + cb->count)) + { + stop("HFS+ Unicode tables are malformed\n"); + } +#endif + data = cb->data; + + for (j = 0; j < cb->count; j++) + { + *op++ = data; + + if (cb->type == kTypeAscending) // 1 + { + data++; + } + else if (cb->type == kTypeAscending256) // 2 + { + data += 256; + } + } + } + + return out; + } + + return NULL; } -static void InitCompareTables(void) + +//============================================================================== + +static void deCompressHFSUnicodeTables(void) { - if (gCompareTable == 0) { - gCompareTable = UncompressStructure(gCompareTableCompressed, - kCompareTableNBlocks, kCompareTableDataSize); - gLowerCaseTable = UncompressStructure(gLowerCaseTableCompressed, - kLowerCaseTableNBlocks, kLowerCaseTableDataSize); - } + if (gCompareTable == 0) + { + gLatinCaseFoldTable = deCompressStructure(gLatinCaseFoldTableCompressed, kLatinCaseFoldTableNBlocks, kLatinCaseFoldTableDataSize); + gLowerCaseTable = deCompressStructure(gLowerCaseTableCompressed, kLowerCaseTableNBlocks, kLowerCaseTableDataSize); + gCompareTable = deCompressStructure(gCompareTableCompressed, kCompareTableNBlocks, kCompareTableDataSize); + + } } +#endif /* ! USE_COMPRESSED_TABLES */ -#endif /* ! UNCOMPRESSED */ -//_______________________________________________________________________ -// -// Routine: FastRelString -// -// Output: returns -1 if str1 < str2 -// returns 1 if str1 > str2 -// return 0 if equal -// -//_______________________________________________________________________ +/*============================================================================== + * + * Routine: FastRelString + * + * Output: returns -1 if str1 < str2 + * returns 1 if str1 > str2 + * return 0 if equal + * + */ int32_t FastRelString(u_int8_t * str1, u_int8_t * str2) { int32_t bestGuess; u_int8_t length, length2; -#if ! UNCOMPRESED - InitCompareTables(); -#endif - length = *(str1++); length2 = *(str2++); if (length == length2) + { bestGuess = 0; + } else if (length < length2) + { bestGuess = -1; + } else { bestGuess = 1; length = length2; } +#if USE_COMPRESSED_TABLES + deCompressHFSUnicodeTables(); +#endif + + // u_int16_t* compareTable = (u_int16_t*) gCompareTable; + while (length--) { u_int32_t aChar, bChar; @@ -108,7 +146,7 @@ int32_t FastRelString(u_int8_t * str1, u_int8_t * str2) aChar = *(str1++); bChar = *(str2++); - if (aChar != bChar) /* If they don't match exacly, do case conversion */ + if (aChar != bChar) /* If they don't match exacly, do case conversion */ { u_int16_t aSortWord, bSortWord; @@ -116,176 +154,215 @@ int32_t FastRelString(u_int8_t * str1, u_int8_t * str2) bSortWord = gCompareTable[bChar]; if (aSortWord > bSortWord) + { return 1; + } if (aSortWord < bSortWord) + { return -1; + } } - + /* * If characters match exactly, then go on to next character * immediately without doing any extra work. */ } - /* if you got to here, then return bestGuess */ + /* If you got to here, then return bestGuess */ return bestGuess; } -// -// FastUnicodeCompare - Compare two Unicode strings; produce a relative ordering -// -// IF RESULT -// -------------------------- -// str1 < str2 => -1 -// str1 = str2 => 0 -// str1 > str2 => +1 -// -// The lower case table starts with 256 entries (one for each of the upper bytes -// of the original Unicode char). If that entry is zero, then all characters with -// that upper byte are already case folded. If the entry is non-zero, then it is -// the _index_ (not byte offset) of the start of the sub-table for the characters -// with that upper byte. All ignorable characters are folded to the value zero. -// -// In pseudocode: -// -// Let c = source Unicode character -// Let table[] = lower case table -// -// lower = table[highbyte(c)] -// if (lower == 0) -// lower = c -// else -// lower = table[lower+lowbyte(c)] -// -// if (lower == 0) -// ignore this character -// -// To handle ignorable characters, we now need a loop to find the next valid character. -// Also, we can't pre-compute the number of characters to compare; the string length might -// be larger than the number of non-ignorable characters. Further, we must be able to handle -// ignorable characters at any point in the string, including as the first or last characters. -// We use a zero value as a sentinel to detect both end-of-string and ignorable characters. -// Since the File Manager doesn't prevent the NUL character (value zero) as part of a filename, -// the case mapping table is assumed to map u+0000 to some non-zero value (like 0xFFFF, which is -// an invalid Unicode character). -// -// Pseudocode: -// -// while (1) { -// c1 = GetNextValidChar(str1) // returns zero if at end of string -// c2 = GetNextValidChar(str2) -// -// if (c1 != c2) break // found a difference -// -// if (c1 == 0) // reached end of string on both strings at once? -// return 0; // yes, so strings are equal -// } -// -// // When we get here, c1 != c2. So, we just need to determine which one is less. -// if (c1 < c2) -// return -1; -// else -// return 1; -// - -int32_t FastUnicodeCompare( u_int16_t * str1, register u_int32_t length1, - u_int16_t * str2, register u_int32_t length2, int byte_order ) +/*============================================================================== + * + * FastUnicodeCompare - Compare two Unicode strings; produce a relative ordering + * + * IF RESULT + * -------------------------- + * str1 < str2 => -1 + * str1 = str2 => 0 + * str1 > str2 => +1 + * + * The lower case table starts with 256 entries (one for each of the upper bytes + * of the original Unicode char). If that entry is zero, then all characters with + * that upper byte are already case folded. If the entry is non-zero, then it is + * the _index_ (not byte offset) of the start of the sub-table for the characters + * with that upper byte. All ignorable characters are folded to the value zero. + * + * In pseudocode: + * + * Let c = source Unicode character + * Let table[] = lower case table + * + * lower = table[highbyte(c)] + * if (lower == 0) + * lower = c + * else + * lower = table[lower+lowbyte(c)] + * + * if (lower == 0) + * ignore this character + * + * To handle ignorable characters, we now need a loop to find the next valid character. + * Also, we can't pre-compute the number of characters to compare; the string length might + * be larger than the number of non-ignorable characters. Further, we must be able to handle + * ignorable characters at any point in the string, including as the first or last characters. + * We use a zero value as a sentinel to detect both end-of-string and ignorable characters. + * Since the File Manager doesn't prevent the NUL character (value zero) as part of a filename, + * the case mapping table is assumed to map u+0000 to some non-zero value (like 0xFFFF, which is + * an invalid Unicode character). + * + * Pseudocode: + * + * while (1) { + * c1 = GetNextValidChar(str1) * returns zero if at end of string + * c2 = GetNextValidChar(str2) + * + * if (c1 != c2) break * found a difference + * + * if (c1 == 0) * reached end of string on both strings at once? + * return 0; * yes, so strings are equal + * } + * + * // When we get here, c1 != c2. So, we just need to determine which one is less. + * if (c1 < c2) + * return -1; + * else + * return 1; + */ + +int32_t FastUnicodeCompare(u_int16_t * str1, register u_int32_t length1, u_int16_t * str2, register u_int32_t length2) { - register u_int16_t c1,c2; + register u_int16_t c1, c2; register u_int16_t temp; -#if ! UNCOMPRESSED - InitCompareTables(); + register UInt16 * lowerCaseTable = (UInt16*) gLowerCaseTable; + +#if USE_COMPRESSED_TABLES + deCompressHFSUnicodeTables(); #endif - while (1) { + while (1) + { /* Set default values for c1, c2 in case there are no more valid chars */ c1 = 0; c2 = 0; /* Find next non-ignorable char from str1, or zero if no more */ - while (length1 && c1 == 0) { - if (byte_order == OSBigEndian) - c1 = SWAP_BE16(*(str1++)); - else - c1 = SWAP_LE16(*(str1++)); + while (length1 && c1 == 0) + { + c1 = SWAP_BE16(*(str1++)); --length1; - if ((temp = gLowerCaseTable[c1>>8]) != 0) // is there a subtable for this upper byte? - c1 = gLowerCaseTable[temp + (c1 & 0x00FF)]; // yes, so fold the char + + /* Check for basic latin first */ + if (c1 < 0x0100) + { + c1 = SWAP_BE16(gLatinCaseFoldTable[c1]); + break; + } + /* Case fold if neccessary */ + if ((temp = lowerCaseTable[c1 >> 8]) != 0) /* Is there a subtable for this upper byte? */ + { + c1 = lowerCaseTable[temp + (c1 & 0x00FF)]; /* Yes, so fold the char */ + } } /* Find next non-ignorable char from str2, or zero if no more */ - while (length2 && c2 == 0) { - if (byte_order == OSBigEndian) - c2 = SWAP_BE16(*(str2++)); - else - c2 = SWAP_LE16(*(str2++)); + while (length2 && c2 == 0) + { + c2 = SWAP_BE16(*(str2++)); --length2; - if ((temp = gLowerCaseTable[c2>>8]) != 0) // is there a subtable for this upper byte? - c2 = gLowerCaseTable[temp + (c2 & 0x00FF)]; // yes, so fold the char + + /* Check for basic latin first */ + if (c2 < 0x0100) + { + c2 = SWAP_BE16(gLatinCaseFoldTable[c2]); + break; + } + + /* Case fold if neccessary */ + if ((temp = lowerCaseTable[c2 >> 8]) != 0) /* Is there a subtable for this upper byte? */ + { + c2 = lowerCaseTable[temp + (c2 & 0x00FF)]; /* Yes, so fold the char */ + } } - if (c1 != c2) /* found a difference, so stop looping */ + if (c1 != c2) /* Found a difference, so stop looping */ + { break; + } - if (c1 == 0) /* did we reach the end of both strings at the same time? */ - return 0; /* yes, so strings are equal */ + if (c1 == 0) /* Did we reach the end of both strings at the same time? */ + { + return 0; /* Yes, so strings are equal */ + } } if (c1 < c2) + { return -1; - else - return 1; + } + + return 1; } -// -// BinaryUnicodeCompare - Compare two Unicode strings; produce a relative ordering -// Compared using a 16-bit binary comparison (no case folding) -// -int32_t BinaryUnicodeCompare (u_int16_t * str1, u_int32_t length1, - u_int16_t * str2, u_int32_t length2) +/*============================================================================== + * BinaryUnicodeCompare - Compare two Unicode strings; produce a relative ordering + * Compared using a 16-bit binary comparison (no case folding) + */ + +int32_t BinaryUnicodeCompare(u_int16_t * str1, u_int32_t length1, u_int16_t * str2, u_int32_t length2) { - register u_int16_t c1, c2; - int32_t bestGuess; - u_int32_t length; - - bestGuess = 0; - - if (length1 < length2) { - length = length1; - --bestGuess; - } else if (length1 > length2) { - length = length2; - ++bestGuess; - } else { - length = length1; - } - - while (length--) { - c1 = *(str1++); - c2 = *(str2++); - - if (c1 > c2) - return (1); - if (c1 < c2) - return (-1); - } - - return (bestGuess); + register u_int16_t c1, c2; + int32_t bestGuess = 0; + u_int32_t length; + + if (length1 < length2) + { + length = length1; + --bestGuess; + } + else if (length1 > length2) + { + length = length2; + ++bestGuess; + } + else + { + length = length1; + } + + while (length--) + { + c1 = *(str1++); + c2 = *(str2++); + + if (c1 > c2) + { + return (1); + } + + if (c1 < c2) + { + return (-1); + } + } + + return (bestGuess); } -/* +/*============================================================================== * UTF-8 (UCS Transformation Format) * * The following subset of UTF-8 is used to encode UCS-2 filenames. It * requires a maximum of three 3 bytes per UCS-2 character. Only the * shortest encoding required to represent the significant UCS-2 bits * is legal. - * + * * UTF-8 Multibyte Codes * * Bytes Bits UCS-2 Min UCS-2 Max UTF-8 Byte Sequence (binary) @@ -297,46 +374,60 @@ int32_t BinaryUnicodeCompare (u_int16_t * str1, u_int32_t length1, */ -/* +/*============================================================================== * utf_encodestr - Encodes the UCS-2 (Unicode) string at ucsp into a * null terminated UTF-8 string at utf8p. * * ucslen is the number of UCS-2 input characters (not bytes) * bufsize is the size of the output buffer in bytes */ -void utf_encodestr( const u_int16_t * ucsp, int ucslen, - u_int8_t * utf8p, u_int32_t bufsize, int byte_order ) + +void utf_encodestr(const u_int16_t * ucsp, int ucslen, u_int8_t * utf8p, u_int32_t bufsize) { u_int8_t *bufend; u_int16_t ucs_ch; bufend = utf8p + bufsize; - while (ucslen-- > 0) { - if (byte_order == OSBigEndian) - ucs_ch = SWAP_BE16(*ucsp++); - else - ucs_ch = SWAP_LE16(*ucsp++); + while (ucslen-- > 0) + { + ucs_ch = SWAP_BE16(*ucsp++); - if (ucs_ch < 0x0080) { + if (ucs_ch < 0x0080) + { if (utf8p >= bufend) + { break; + } + if (ucs_ch == '\0') - continue; /* skip over embedded NULLs */ + { + continue; /* Skip over embedded NULLs */ + } + *utf8p++ = ucs_ch; - } else if (ucs_ch < 0x800) { + } + else if (ucs_ch < 0x800) + { if ((utf8p + 1) >= bufend) + { break; - *utf8p++ = (ucs_ch >> 6) | 0xc0; - *utf8p++ = (ucs_ch & 0x3f) | 0x80; + } - } else { + *utf8p++ = ((ucs_ch >> 6) | 0xc0); + *utf8p++ = ((ucs_ch & 0x3f) | 0x80); + } + else + { if ((utf8p + 2) >= bufend) + { break; - *utf8p++ = (ucs_ch >> 12) | 0xe0; - *utf8p++ = ((ucs_ch >> 6) & 0x3f) | 0x80; - *utf8p++ = ((ucs_ch) & 0x3f) | 0x80; + } + + *utf8p++ = ((ucs_ch >> 12) | 0xe0); + *utf8p++ = (((ucs_ch >> 6) & 0x3f) | 0x80); + *utf8p++ = ((ucs_ch & 0x3f) | 0x80); } } @@ -344,14 +435,15 @@ void utf_encodestr( const u_int16_t * ucsp, int ucslen, } -/* +/*============================================================================== * utf_decodestr - Decodes the null terminated UTF-8 string at * utf8p into a UCS-2 (Unicode) string at ucsp. * * ucslen is the number of UCS-2 output characters (not bytes) * bufsize is the size of the output buffer in bytes */ -void utf_decodestr(const u_int8_t * utf8p, u_int16_t * ucsp, u_int16_t * ucslen, u_int32_t bufsize, int byte_order) + +void utf_decodestr(const u_int8_t * utf8p, u_int16_t * ucsp, u_int16_t * ucslen, u_int32_t bufsize) { u_int16_t *bufstart; u_int16_t *bufend; @@ -361,58 +453,56 @@ void utf_decodestr(const u_int8_t * utf8p, u_int16_t * ucsp, u_int16_t * ucslen, bufstart = ucsp; bufend = (u_int16_t *)((u_int8_t *)ucsp + bufsize); - while ((byte = *utf8p++) != '\0') { + while ((byte = *utf8p++) != '\0') + { if (ucsp >= bufend) + { break; + } - /* check for ascii */ - if (byte < 0x80) { + /* Check for ASCII */ + if (byte < 0x80) + { ucs_ch = byte; - - if (byte_order == OSBigEndian) - *ucsp++ = SWAP_BE16(ucs_ch); - else - *ucsp++ = SWAP_LE16(ucs_ch); - + *ucsp++ = SWAP_BE16(ucs_ch); continue; } - switch (byte & 0xf0) { - /* 2 byte sequence*/ - case 0xc0: - case 0xd0: - /* extract bits 6 - 10 from first byte */ - ucs_ch = (byte & 0x1F) << 6; - break; - /* 3 byte sequence*/ - case 0xe0: - /* extract bits 12 - 15 from first byte */ - ucs_ch = (byte & 0x0F) << 6; - - /* extract bits 6 - 11 from second byte */ - if (((byte = *utf8p++) & 0xc0) != 0x80) - goto stop; - - ucs_ch += (byte & 0x3F); - ucs_ch <<= 6; - break; - default: - goto stop; + switch (byte & 0xf0) + { + /* 2 byte sequence */ + case 0xc0: + case 0xd0: /* Extract bits 6 - 10 from first byte */ + ucs_ch = ((byte & 0x1F) << 6); + break; + /* 3 byte sequence */ + case 0xe0: + /* Extract bits 12 - 15 from first byte */ + ucs_ch = ((byte & 0x0F) << 6); + + /* Extract bits 6 - 11 from second byte */ + if (((byte = *utf8p++) & 0xc0) != 0x80) + { + goto stop; + } + + ucs_ch += (byte & 0x3F); + ucs_ch <<= 6; + break; + default: + goto stop; } - /* extract bits 0 - 5 from final byte */ + /* Extract bits 0 - 5 from final byte */ if (((byte = *utf8p++) & 0xc0) != 0x80) + { goto stop; - ucs_ch += (byte & 0x3F); + } - if (byte_order == OSBigEndian) - *ucsp++ = SWAP_BE16(ucs_ch); - else - *ucsp++ = SWAP_LE16(ucs_ch); + ucs_ch += (byte & 0x3F); + *ucsp++ = SWAP_BE16(ucs_ch); } + stop: - if (byte_order == OSBigEndian) - *ucslen = SWAP_BE16(ucsp - bufstart); - else - *ucslen = SWAP_LE16(ucsp - bufstart); + *ucslen = SWAP_BE16(ucsp - bufstart); } diff --git a/i386/libsaio/libsaio.h b/i386/libsaio/libsaio.h index 6eee4d1..f669a27 100755 --- a/i386/libsaio/libsaio.h +++ b/i386/libsaio/libsaio.h @@ -20,8 +20,11 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ + * + * Updates: + * - STATE_SUCCESS moved from boot.h (PikerAlpha, November 2012) + * */ -/* libsaio.h */ #ifndef __LIBSAIO_LIBSAIO_H #define __LIBSAIO_LIBSAIO_H diff --git a/i386/libsaio/load.c b/i386/libsaio/load.c index dad895a..4c0f76e 100755 --- a/i386/libsaio/load.c +++ b/i386/libsaio/load.c @@ -18,19 +18,34 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ - */ -/* - * load.c - Functions for decoding a Mach-o Kernel. * - * Copyright (c) 1998-2003 Apple Computer, Inc. + * load.c - Functions for decoding a Mach-o Kernel. + * + * Copyright (c) 1998-2003 Apple Computer, Inc. + * + * Updates: + * - White space changes (Pike R. Alpha, November 2012) + * - Mountain Lion kernel patch for iMessage implemented (Pike R. Alpha, January 2013) + * - Patch for __ZN6OSKext14loadExecutableEv added (Pike R. Alpha, 2015) + * - Patch for __ZN12KLDBootstrap21readStartupExtensionsEv added. + * - Use Lower Camel Case for function names (Pike R. Alpha, July 2016) + * - Add _cpuid_set_info/_xcpm_bootstrap/_xcpm_idle to patches. + * - Dump global gBinaryAddress and use loadAddress argument. + * - New and improved patching routines (getting ready for smarter patching). + * - Renamed patchLoadExecutable to patchKernel (Pike R. Alpha, August 2016) + * - New and improved debug output (see also boot2/debug.h) + * - Made some preparations to move patchKernel() to patcher.c + * - Moved function patchKernel to patcher.c * */ #include #include +#include #include #include +#include "platform.h" /*** * Backward compatibility fix for the SDK 10.7 version of loader.h @@ -43,20 +58,21 @@ // Load MKext(s) or separate kexts (default behaviour / behavior). bool gLoadKernelDrivers = true; -// Private functions. -static long DecodeSegment(long cmdBase, unsigned int*load_addr, unsigned int *load_size); -static long DecodeUnixThread(long cmdBase, unsigned int *entry); -static long DecodeSymbolTable(long cmdBase); +static long initKernelVersionInfo(unsigned long loadAddress, unsigned long cmdbase, long listSize, unsigned int textSegmentAddress); +static long decodeSegment(unsigned long loadAddress, long cmdBase, unsigned int*load_addr, unsigned int *load_size); +static long decodeUnixThread(long cmdBase, unsigned int *entry); -static unsigned long gBinaryAddress; +#define ADD_SYMTAB 1 -cpu_type_t gArchCPUType = 0; // CPU_TYPE_I386; +#if ADD_SYMTAB + static long decodeSymbolTable(unsigned long loadAddress, long cmdBase); +#endif //============================================================================== // Public function. -long ThinFatFile(void **binary, unsigned long *length) +long thinFatFile(void **binary, unsigned long *length) { unsigned long nfat, swapped, size = 0; struct fat_header *fhp = (struct fat_header *)*binary; @@ -64,7 +80,7 @@ long ThinFatFile(void **binary, unsigned long *length) cpu_type_t fapcputype; uint32_t fapoffset; uint32_t fapsize; - + if (fhp->magic == FAT_MAGIC) { nfat = fhp->nfat_arch; @@ -94,15 +110,15 @@ long ThinFatFile(void **binary, unsigned long *length) fapoffset = fap->offset; fapsize = fap->size; } - - if (fapcputype == gArchCPUType) + + if (fapcputype == gPlatform.ArchCPUType) { *binary = (void *) ((unsigned long)*binary + fapoffset); size = fapsize; break; } } - + if (length != 0) { *length = size; @@ -113,193 +129,334 @@ long ThinFatFile(void **binary, unsigned long *length) //============================================================================== -// Called from DecodeKernel() in drivers.c +// Called from decodeKernel() in drivers.c -long DecodeMachO(void *binary, entry_t *rentry, char **raddr, int *rsize) +long decodeMachO(void *fileLoadBuffer, entry_t *rentry, char **raddr, int *rsize) { - struct mach_header *mH; - unsigned long ncmds, cmdBase, cmd, cmdsize, cmdstart; - unsigned int vmaddr = ~0; - unsigned int vmend = 0; - unsigned long cnt; - long ret = -1; - unsigned int entry = 0; - - gBinaryAddress = (unsigned long)binary; - mH = (struct mach_header *)(gBinaryAddress); + long ret = -1; + long sectionNumber = 0; + + unsigned int vmaddr = ~0; + unsigned int vmend = 0; + unsigned int entry = 0; + unsigned int load_addr = 0; + unsigned int load_size = 0; + unsigned int textSegmentAddress = 0; + unsigned int vldSegmentAddress = 0; + + unsigned long ncmds = 0; + unsigned long cmdBase = 0; + unsigned long cmd = 0; + unsigned long cmdsize = 0; + unsigned long cmdstart = 0; + unsigned long cnt = 0; + unsigned long listSize = 0; + + unsigned long loadAddress = (unsigned long)fileLoadBuffer; + + if (gPlatform.ArchCPUType == CPU_TYPE_X86_64) + { + struct mach_header_64 * machHeader = (struct mach_header_64 *)(loadAddress); + if (machHeader->magic != MH_MAGIC_64) + { + error("Mach-O file(X86_64) has a bad magic number!\n"); + return -1; + } + + listSize = sizeof(struct nlist_64); + cmdstart = loadAddress + sizeof(struct mach_header_64); #if DEBUG - printf("magic: %x\n", (unsigned)mH->magic); - printf("cputype: %x\n", (unsigned)mH->cputype); - printf("cpusubtype: %x\n", (unsigned)mH->cpusubtype); - printf("filetype: %x\n", (unsigned)mH->filetype); - printf("ncmds: %x\n", (unsigned)mH->ncmds); - printf("sizeofcmds: %x\n", (unsigned)mH->sizeofcmds); - printf("flags: %x\n", (unsigned)mH->flags); - sleep(5); + printf("In decodeMachO()\n"); + printf("magic: %x\n", (unsigned)machHeader->magic); + printf("cputype: %x\n", (unsigned)machHeader->cputype); + printf("cpusubtype: %x\n", (unsigned)machHeader->cpusubtype); + printf("filetype: %x\n", (unsigned)machHeader->filetype); + printf("ncmds: %x\n", (unsigned)machHeader->ncmds); + printf("sizeofcmds: %x\n", (unsigned)machHeader->sizeofcmds); + printf("flags: %x\n", (unsigned)machHeader->flags); + sleep(5); #endif - - /* if ((gArchCPUType == CPU_TYPE_I386 && mH->magic != MH_MAGIC) || - (gArchCPUType == CPU_TYPE_X86_64 && mH->magic != MH_MAGIC_64)) - { - error("Mach-O file has bad magic number\n"); - return -1; - } */ - - switch (gArchCPUType) + ncmds = machHeader->ncmds; + } +#if ((MAKE_TARGET_OS & SNOW_LEOPARD) == SNOW_LEOPARD) + else // if (gPlatform.ArchCPUType == CPU_TYPE_I386) { - case CPU_TYPE_I386: + struct mach_header * machHeader = (struct mach_header *)(loadAddress); - if (mH->magic != MH_MAGIC) - { - error("Mach-O file has bad magic number\n"); - return -1; - } + if (machHeader->magic != MH_MAGIC) + { + error("Mach-O file(i386) has a bad magic number!\n"); + return -1; + } - cmdstart = (unsigned long)gBinaryAddress + sizeof(struct mach_header); - break; + listSize = sizeof(struct nlist); + cmdstart = loadAddress + sizeof(struct mach_header); +#if DEBUG + printf("In decodeMachO()\n"); + printf("magic: %x\n", (unsigned)machHeader->magic); + printf("cputype: %x\n", (unsigned)machHeader->cputype); + printf("cpusubtype: %x\n", (unsigned)machHeader->cpusubtype); + printf("filetype: %x\n", (unsigned)machHeader->filetype); + printf("ncmds: %x\n", (unsigned)machHeader->ncmds); + printf("sizeofcmds: %x\n", (unsigned)machHeader->sizeofcmds); + printf("flags: %x\n", (unsigned)machHeader->flags); + sleep(5); +#endif + ncmds = machHeader->ncmds; + } +#endif - case CPU_TYPE_X86_64: + cmdBase = cmdstart; - if (mH->magic != MH_MAGIC_64 && mH->magic == MH_MAGIC) - { - return -1; - } + for (cnt = 0; cnt < ncmds; cnt++) + { + cmd = ((long *)cmdBase)[0]; + cmdsize = ((long *)cmdBase)[1]; - if (mH->magic != MH_MAGIC_64) - { - error("Mach-O file has bad magic number\n"); - return -1; - } + switch (cmd) + { + case LC_SEGMENT: + case LC_SEGMENT_64: + sectionNumber = decodeSegment(loadAddress, cmdBase, &load_addr, &load_size); + + if (sectionNumber == 1) // __TEXT,__text + { + textSegmentAddress = cmdBase; + ret = 0; + } + else if (sectionNumber == 25) // __KLD,__text + { + vldSegmentAddress = cmdBase; + ret = 0; + } + + if (load_size != 0 && load_addr >= KERNEL_ADDR) + { + vmaddr = min(vmaddr, load_addr); + vmend = max(vmend, load_addr + load_size); + } + + break; + + case LC_SYMTAB: + initKernelVersionInfo(loadAddress, cmdBase, listSize, textSegmentAddress); +#if (PATCH_KERNEL && ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN)) + patchKernel(loadAddress, cmdBase, listSize, textSegmentAddress, vldSegmentAddress); +#endif + break; - cmdstart = (unsigned long)gBinaryAddress + sizeof(struct mach_header_64); - break; + case LC_MAIN: /* Mountain Lion's replacement for LC_UNIXTHREAD */ + case LC_UNIXTHREAD: + ret = decodeUnixThread(cmdBase, &entry); + break; - default: + default: +#if NOTDEF + printf("Ignoring cmd type %d.\n", (unsigned)cmd); +#endif + break; + } - error("Unknown CPU type\n"); + if (ret != 0) + { return -1; + } + + cmdBase += cmdsize; } - /* cmdstart = (unsigned long)gBinaryAddress + (gArchCPUType == CPU_TYPE_I386) ? sizeof(struct mach_header) : - sizeof(struct mach_header_64); */ - cmdBase = cmdstart; - ncmds = mH->ncmds; - - for (cnt = 0; cnt < ncmds; cnt++) - { - cmd = ((long *)cmdBase)[0]; - cmdsize = ((long *)cmdBase)[1]; - unsigned int load_addr; - unsigned int load_size; - - switch (cmd) - { - case LC_SEGMENT_64: - case LC_SEGMENT: - - ret = DecodeSegment(cmdBase, &load_addr, &load_size); - - if (ret == 0 && load_size != 0 && load_addr >= KERNEL_ADDR) - { - vmaddr = min(vmaddr, load_addr); - vmend = max(vmend, load_addr + load_size); - } - break; - - case LC_MAIN: /* Mountain Lion's replacement for LC_UNIXTHREAD */ - case LC_UNIXTHREAD: - ret = DecodeUnixThread(cmdBase, &entry); - break; - - case LC_SYMTAB: - break; - - default: -#if NOTDEF - printf("Ignoring cmd type %d.\n", (unsigned)cmd); -#endif - break; - } - - if (ret != 0) - return -1; - - cmdBase += cmdsize; - } - - *rentry = (entry_t)( (unsigned long) entry & 0x3fffffff ); - *rsize = vmend - vmaddr; - *raddr = (char *)vmaddr; - - cmdBase = cmdstart; - - for (cnt = 0; cnt < ncmds; cnt++) - { - cmd = ((long *)cmdBase)[0]; - cmdsize = ((long *)cmdBase)[1]; + *rentry = (entry_t)( (unsigned long) entry & 0x3fffffff ); + *rsize = vmend - vmaddr; + *raddr = (char *)vmaddr; + +#if ADD_SYMTAB + cmdBase = cmdstart; + + for (cnt = 0; cnt < ncmds; cnt++) + { + cmd = ((long *)cmdBase)[0]; + cmdsize = ((long *)cmdBase)[1]; - if (cmd == LC_SYMTAB) - { - if (DecodeSymbolTable(cmdBase) != 0) + if (cmd == LC_SYMTAB) + { + if (decodeSymbolTable(loadAddress, cmdBase) != 0) { return -1; } - } - + } + cmdBase += cmdsize; - } - + } +#endif return ret; } //============================================================================== -// Private function. Called from DecodeMachO() +// Private function. Called from decodeMachO() + +static long initKernelVersionInfo(unsigned long loadAddress, unsigned long cmdBase, long listSize, unsigned int textSegmentVMAddress) +{ + struct symtab_command * symtab = (struct symtab_command *)cmdBase; + + /* + * Reverse search is quicker for symbols at the end of the symbol table (example with 20496 symbols): + * + * _version_revision is symbol 18865 – first target symbol, iterated symbols: 1631 + * _version_minor is symbol 18863 – second target symbol, iterated symbols: 1633 + * _version_major is symbol 18862 – last target symbol, iterated symbols: 1634 + * + * versus: + * + * _version_major is symbol 18862 – first target symbol, iterated symbols: 18862 + * _version_minor is symbol 18863 – ssecond target symbol, iterated symbols: 18863 + * _version_revision is symbol 18865 – last target symbol, iterated symbols: 18865 + */ + + const char * targetSymbols[] = { "_version_revision", "_version_minor", "_version_major" }; + + char * symbolName = NULL; + char * loadBuffer = (char *)loadAddress; + + void * stringTable = (void *)(loadAddress + symtab->stroff); + + short index = 0; + + long symbolOffset = 0; + long symbolLength = 0; + long symbolNumber = symtab->nsyms; + + uint32_t pointer = loadAddress + symtab->symoff + ((symtab->nsyms - 1) * listSize); + +#if ((MAKE_TARGET_OS & SNOW_LEOPARD) == SNOW_LEOPARD) + if (gPlatform.ArchCPUType == CPU_TYPE_X86_64) + { +#endif + while (symbolNumber > 0) + { + struct nlist_64 * nl = (struct nlist_64 *)pointer; + + if ((nl->n_sect == 2 /* __TEXT,__const */) && nl->n_value) + { + symbolName = (char *)stringTable + nl->n_un.n_strx; + symbolLength = strlen(symbolName); + symbolOffset = (nl->n_value - textSegmentVMAddress); + + if (symbolLength && (strcmp(symbolName, targetSymbols[index]) == 0)) + { + switch(index) + { + case 0: + gPlatform.KERNEL.versionRevision = (uint8_t)loadBuffer[symbolOffset]; + index++; + break; + + case 1: + gPlatform.KERNEL.versionMinor = (uint8_t)loadBuffer[symbolOffset]; + index++; + break; + + case 2: + gPlatform.KERNEL.versionMajor = (uint8_t)loadBuffer[symbolOffset]; + symbolNumber = 0; + break; + } + } + } + + symbolNumber--; + pointer -= listSize; + } +#if ((MAKE_TARGET_OS & SNOW_LEOPARD) == SNOW_LEOPARD) + } + else // 32-bit compatibility code. + { + struct nlist * nl = (struct nlist *)pointer; + + while (symbolNumber > 0) + { + nl = (struct nlist *)pointer; + + if ((nl->n_sect == 2 /* __TEXT,__const */) && nl->n_value) + { + symbolName = (char *)stringTable + nl->n_un.n_strx; + symbolLength = strlen(symbolName); + symbolOffset = (nl->n_value - textSegmentVMAddress); + + if (symbolLength && (strcmp(symbolName, targetSymbols[index]) == 0)) + { + switch(index) + { + case 0: + gPlatform.KERNEL.versionRevision = (uint8_t)loadBuffer[symbolOffset]; + index++; + break; + + case 1: + gPlatform.KERNEL.versionMinor = (uint8_t)loadBuffer[symbolOffset]; + index++; + break; + + case 2: + gPlatform.KERNEL.versionMajor = (uint8_t)loadBuffer[symbolOffset]; + symbolNumber = 0; + break; + } + } + } + + symbolNumber--; + pointer -= listSize; + } + } +#endif + +#if DEBUG + printf("gPlatform.KERNEL.versionMmR: %d.%d.%d\n", gPlatform.KERNEL.versionMajor, gPlatform.KERNEL.versionMinor, gPlatform.KERNEL.versionRevision); + sleep(5); +#endif + + return 0; +} + +//============================================================================== +// Private function. Called from decodeMachO() // Refactoring and segment name fix for OS X 10.6+ by DHP in 2010. -static long DecodeSegment(long cmdBase, unsigned int *load_addr, unsigned int *load_size) +static long decodeSegment(unsigned long loadAddress, long cmdBase, unsigned int *load_addr, unsigned int *load_size) { - char *segname; - long vmsize, filesize; - unsigned long vmaddr, fileaddr; - + char *segmentName = NULL; + + long retValue = 0; + long vmsize = 0; + long filesize = 0; + + unsigned long vmaddr = 0; + unsigned long fileAddress = 0; + if (((long *)cmdBase)[0] == LC_SEGMENT_64) { struct segment_command_64 *segCmd = (struct segment_command_64 *)cmdBase; - - vmaddr = (segCmd->vmaddr & 0x3fffffff); - vmsize = segCmd->vmsize; - fileaddr = (gBinaryAddress + segCmd->fileoff); - filesize = segCmd->filesize; - segname = segCmd->segname; + vmaddr = (segCmd->vmaddr & 0x3fffffff); + vmsize = segCmd->vmsize; + fileAddress = (loadAddress + segCmd->fileoff); + filesize = segCmd->filesize; + segmentName = segCmd->segname; } else { struct segment_command *segCmd = (struct segment_command *)cmdBase; - - vmaddr = (segCmd->vmaddr & 0x3fffffff); - vmsize = segCmd->vmsize; - fileaddr = (gBinaryAddress + segCmd->fileoff); - filesize = segCmd->filesize; - segname = segCmd->segname; + vmaddr = (segCmd->vmaddr & 0x3fffffff); + vmsize = segCmd->vmsize; + fileAddress = (loadAddress + segCmd->fileoff); + filesize = segCmd->filesize; + segmentName = segCmd->segname; } - + // Pre-flight checks. if (vmsize && filesize) { -#if DEBUG - printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x\n", - segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize); - - if (gArchCPUType == CPU_TYPE_X86_64) - { - printf("nsects: %d, flags: %x.\n", (unsigned) segCmd->nsects, (unsigned)segCmd->flags); - } - - getchar(); -#endif - if (! ((vmaddr >= KERNEL_ADDR && (vmaddr + vmsize) <= (KERNEL_ADDR + KERNEL_LEN)) || (vmaddr >= HIB_ADDR && (vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN)))) { @@ -312,23 +469,30 @@ static long DecodeSegment(long cmdBase, unsigned int *load_addr, unsigned int *l * __PRELINK_TEXT, __PRELINK_STATE, __PRELINK_INFO versus __PRELINK in 10.5 */ - if (gLoadKernelDrivers && strncmp(segname, "__PRELINK", 9) == 0) + if (gLoadKernelDrivers && strncmp(segmentName, "__PRELINK", 9) == 0) { #if DEBUG printf("Setting: gLoadKernelDrivers to false.\n"); printf("Sleeping for 5 seconds...\n"); sleep(5); #endif - // Make boot() skip kernel / MKext(s) loading. gLoadKernelDrivers = false; } - + else if (strncmp(segmentName, "__TEXT", 6) == 0) + { + retValue = 1; + } + else if (strncmp(segmentName, "__KLD", 5) == 0) + { + retValue = 25; + } + // Copy from file load area. if (filesize > 0) { - bcopy((char *)fileaddr, (char *)vmaddr, vmsize > filesize ? filesize : vmsize); + bcopy((char *)fileAddress, (char *)vmaddr, vmsize > filesize ? filesize : vmsize); } - + // Zero space at the end of the segment. if (vmsize > filesize) { @@ -343,23 +507,23 @@ static long DecodeSegment(long cmdBase, unsigned int *load_addr, unsigned int *l *load_addr = ~0; *load_size = 0; } - - return 0; + + return retValue; } //============================================================================== -// Private function. Called from DecodeMachO() +// Private function. Called from decodeMachO() -static long DecodeUnixThread(long cmdBase, unsigned int *entry) +static long decodeUnixThread(long cmdBase, unsigned int *entry) { - switch (gArchCPUType) + switch (gPlatform.ArchCPUType) { case CPU_TYPE_I386: { i386_thread_state_t *i386ThreadState; i386ThreadState = (i386_thread_state_t *) (cmdBase + sizeof(struct thread_command) + 8); - + #if defined(__DARWIN_UNIX03) && __DARWIN_UNIX03 *entry = i386ThreadState->__eip; #else @@ -387,43 +551,68 @@ static long DecodeUnixThread(long cmdBase, unsigned int *entry) } } - +#if ADD_SYMTAB //============================================================================== -// Private function. Called from DecodeMachO() +// Private function. Called from decodeMachO() -static long DecodeSymbolTable(long cmdBase) +static long decodeSymbolTable(unsigned long loadAddress, long cmdBase) { long tmpAddr, symsSize, totalSize; long gSymbolTableAddr; long gSymbolTableSize; struct symtab_command *symTab, *symTableSave; - + symTab = (struct symtab_command *)cmdBase; - + #if DEBUG - printf("symoff: %x, nsyms: %x, stroff: %x, strsize: %x\n", - symTab->symoff, symTab->nsyms, symTab->stroff, symTab->strsize); + printf("symoff: %x, nsyms: %x, stroff: %x, strsize: %x\n", symTab->symoff, symTab->nsyms, symTab->stroff, symTab->strsize); getchar(); #endif - + symsSize = symTab->stroff - symTab->symoff; totalSize = symsSize + symTab->strsize; - + gSymbolTableSize = totalSize + sizeof(struct symtab_command); gSymbolTableAddr = AllocateKernelMemory(gSymbolTableSize); // Add the SymTab to the memory-map. - AllocateMemoryRange("Kernel-__SYMTAB", gSymbolTableAddr, gSymbolTableSize, -1); - + AllocateMemoryRange("Kernel-__SYMTAB", gSymbolTableAddr, gSymbolTableSize); + symTableSave = (struct symtab_command *)gSymbolTableAddr; tmpAddr = gSymbolTableAddr + sizeof(struct symtab_command); - + symTableSave->symoff = tmpAddr; symTableSave->nsyms = symTab->nsyms; symTableSave->stroff = tmpAddr + symsSize; symTableSave->strsize = symTab->strsize; - bcopy((char *)(gBinaryAddress + symTab->symoff), (char *)tmpAddr, totalSize); - + bcopy((char *)(loadAddress + symTab->symoff), (char *)tmpAddr, totalSize); + + return 0; +} +#endif + +//============================================================================== +// Public function (RevoBoot v1.5.30 and greater). Called from our ACPI patcher +// which looks in /Extra/ACPI/ for [TableName].aml but it is also used in two +// other places, being libsaio/efi.c and libsaio/SMBIOS/static_data.h This to +// get static (binary) data from /Extra/[EFI/SMBIOS]/[FileName].bin + +long loadBinaryData(char *aFilePath, void **aMemoryAddress) +{ + long fileSize = LoadFile(aFilePath); + + if (fileSize > 0) + { + *aMemoryAddress = (void *)malloc(fileSize); + + if (aMemoryAddress) + { + memcpy(*aMemoryAddress, (void *)kLoadAddr, fileSize); + + return fileSize; + } + } + return 0; } diff --git a/i386/libsaio/patcher.c b/i386/libsaio/patcher.c new file mode 100755 index 0000000..acbb919 --- /dev/null +++ b/i386/libsaio/patcher.c @@ -0,0 +1,443 @@ +/* + * Copyright (c) 2016 Pike R. Alpha. All rights reserved. + * + * Updates: + * - Moved function patchKernel from load.c to patcher.c (Pike R. Alpha, August 2016) + * - Cleanups/removed some of the old style patches (more to follow). + * - Function disableMSRs added. + * - Patch bit mask added to speedup the main while loop. + * - Reducing the number of compiler derectives (make it much easier to handle). + * - Latest source code from Vector implemented. + * - Checks added to catch errors in config.h (think MacPro61.h etc). + * - Moving targetMSRs to configuration file. + * + */ + +// +// TODO: Add and verify patch data for El Capitan and make diableMSRs smarter. +// + +#include +#include +#include + +#include "platform.h" + +#ifndef PATCH_CPUID_SET_INFO + #define PATCH_CPUID_SET_INFO -1 +#endif + +#ifndef PATCH_XCPM_BOOTSTRAP + #define PATCH_XCPM_BOOTSTRAP -1 +#endif + + +#if (PATCH_KERNEL_XCPM && ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN)) +//============================================================================== +// Called from patchKernel() + +void disableMSRs(unsigned char * aPointer, uint8_t aNumberOfTargetMSRs) +{ + // + // Array from configuration file with target MSRs that need to be disable. + // + const uint16_t targetMSRs[] = TARGET_XCPM_SCOPE_MSRS; + // + // Main for-loop. + // + for (char x = 0; x < aNumberOfTargetMSRs; x++) + { + // + // Secondary for-loop to find MSRs that we need to disable. + // + for (uint8_t y = 0; y < (sizeof(targetMSRs) / sizeof(short)); y++) + { + // + // Target MSR? + // + if (*(uint16_t *)aPointer == targetMSRs[y]) + { + // + // Yes. + // + DEBUG_DISABLED_MSR(targetMSRs[y], 1) + // + // Zero out the 32-bit CPU-bits field. + // + *(uint32_t *)(aPointer + 4) = 0x00000000UL; + // + // Done (MSR is disabled). + // + break; + } + } + + aPointer += 0x30; + } +} +#endif + + +//============================================================================== +// Called from decodeMachO() + +long patchKernel(unsigned long loadAddress, unsigned long cmdBase, long listSize, unsigned long textSegmentAddress, unsigned long vldSegmentAddress) +{ + #if DEBUG_KERNEL_PATCHER + printf("patchKernel(%d/%d/%d) called\n", PRELINKED_KERNEL_SUPPORT, PATCH_CPUID_SET_INFO, PATCH_XCPM_BOOTSTRAP); + sleep(1); + #endif + + char * symbolName = NULL; + unsigned char * p = NULL; + // + // Option to skip first nth symbols (speeds up the search process). + // + int skippedSymbolCount = 0; // (3000 * listSize); + + long symbolNumber = 0; + + uint32_t targetSections = 9; + uint32_t targetPatches = 1; + + struct symtab_command * symtab = (struct symtab_command *)cmdBase; + struct segment_command_64 * textSegment = (struct segment_command_64 *)textSegmentAddress; +#if PRELINKED_KERNEL_SUPPORT + // struct segment_command_64 * vldSegment = (struct segment_command_64 *)vldSegmentAddress; + + // targetSections |= 25; // El Capitan + // targetSections |= 26; // Sierra + targetSections |= 27; // High Sierra +#endif + + void * stringTable = (void *)(loadAddress + symtab->stroff); + + uint32_t pointer = (loadAddress + symtab->symoff + skippedSymbolCount); + + int64_t offset = 0; + + uint64_t startAddress = 0; + uint64_t endAddress = 0; + +#if (PATCH_KERNEL_XCPM && ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN)) + uint8_t cpuid_set_info_ModelCorrection = 0; + uint8_t xcpm_bootstrap_ModelCorrection = 0; + +#if (PATCH_CPUID_SET_INFO == 0) + switch (gPlatform.CPU.Model) + { + case CPU_MODEL_BROADWELL_E: + targetPatches += 2; + cpuid_set_info_ModelCorrection = -8; + break; + } +#else + targetPatches += 2; + cpuid_set_info_ModelCorrection = PATCH_CPUID_SET_INFO; +#endif + +#if (PATCH_XCPM_BOOTSTRAP == 0) + switch (gPlatform.CPU.Model) + { + case CPU_MODEL_IB_CORE: // Verification required! + targetPatches += 4; + xcpm_bootstrap_ModelCorrection = -1; + break; + + case CPU_MODEL_IB_CORE_EX: // Verification required! + targetPatches += 4; + xcpm_bootstrap_ModelCorrection = -2; + break; + + case CPU_MODEL_HASWELL_E: // Confirmed working in El Capitan and Sierra. + targetPatches += 4; + xcpm_bootstrap_ModelCorrection = -3; + break; + + case CPU_MODEL_BROADWELL_E: // Confirmed working in El Capitan and Sierra. + targetPatches += 4; + xcpm_bootstrap_ModelCorrection = -8; + break; + + default: + return 0; + } +#else + targetPatches += 4; + xcpm_bootstrap_ModelCorrection = PATCH_XCPM_BOOTSTRAP; +#endif + + // + // Is MSR(0xE2) locked (bit-15 set)? + // + if (gPlatform.CPU.CstConfigMsrLocked) + { + // + // Yes. Enable patches: _xcpm_idle(8), _xcpm_SMT_scope_msrs(16), _xcpm_core_scope_msrs(32), _xcpm_pkg_scope_msrs(64) + // + targetPatches += 120; + } + else + { +#if PRELINKED_KERNEL_SUPPORT + // + // Yes. Enable patche: _xcpm_SMT_scope_msrs(16), _xcpm_pkg_scope_msrs(64), __ZN12KLDBootstrap21readStartupExtensionsEv(128) + // + targetPatches += 208; +#else + // + // No. Enabling a limited patch set: _xcpm_SMT_scope_msrs(16), _xcpm_pkg_scope_msrs(64) + // + targetPatches += 80; +#endif + } +#endif // #if (PATCH_KERNEL_XCPM && ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN)) + + // + // Main while loop. + // + while ((symbolNumber < symtab->nsyms) && targetSections) + { + struct nlist_64 * nl = (struct nlist_64 *)pointer; + + if (nl->n_sect == 1 && nl->n_value && (targetSections & nl->n_sect)) // __TEXT,__text + { + symbolName = (char *)stringTable + nl->n_un.n_strx; + + if ((targetPatches & 1) && strcmp(symbolName, "__ZN6OSKext14loadExecutableEv") == 0) + { + offset = (nl->n_value - textSegment->vmaddr); + startAddress = (uint64_t)(textSegment->vmaddr + offset); + endAddress = (startAddress + 0x300); + + DEBUG_SYMBOL_FOUND(symbolName, offset, textSegment->vmaddr, textSegment->fileoff, startAddress, endAddress) + + for (p = (unsigned char *)startAddress; p <= (unsigned char *)endAddress; p++) + { + // + // Search pattern: 89 C3 48 85 DB 74 71 48 (in HexEdit) + // Search pattern: 89 C3 48 85 DB 74 69 48 8b 03 48 89 df ff 50 28 (in HexEdit for High Sierra DP1) + // + // if ((*(uint32_t *)p == 0x8548c389) && (*(uint16_t *)(p + 4) == 0x74db) && (*(uint8_t *)(p + 7) == 0x48) && (*(uint64_t *)(p + 8) == 0x2850ffdf8948038b)) + if ((*(uint32_t *)p == 0x8548c389) && (*(uint16_t *)(p + 4) == 0x74db) && (*(uint8_t *)(p + 7) == 0x48)) + { + DEBUG_PATCH_STATUS(symbolName, ((uint64_t)p - startAddress), 1) + + *(uint64_t *)p = 0x4812ebdb8548c389; + // ^^^^ + // + // Done. Disable this patch. + // + p = (unsigned char *)endAddress; + targetPatches -= 1; + } + } + } +#if (PATCH_KERNEL_XCPM && ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN)) + else if ((targetPatches & 2) && strcmp(symbolName, "_cpuid_set_info") == 0) + { + offset = (nl->n_value - textSegment->vmaddr); + startAddress = (uint64_t)(textSegment->vmaddr + offset); + endAddress = (startAddress + 0x2100); + + DEBUG_SYMBOL_FOUND(symbolName, offset, textSegment->vmaddr, textSegment->fileoff, startAddress, endAddress) + + for (p = (unsigned char *)startAddress; p <= (unsigned char *)endAddress; p++) + { + // + // Search pattern: 0F B6 C4 83 C0 E9 83 F8 (in HexEdit). + // + if ((*(uint32_t *)p == 0x83c4b60f) && (*(uint8_t *)(p + 4) == 0xc0) && (*(uint16_t *)(p + 6) == 0xf883)) + { + DEBUG_PATCH_STATUS(symbolName, ((uint64_t)p - startAddress), 1) + + // *(uint8_t *)(p + 5) = (*(uint8_t *)(p + 5) + PATCH_CPUID_SET_INFO); + *(uint8_t *)(p + 5) = (*(uint8_t *)(p + 5) + cpuid_set_info_ModelCorrection); + // + // Done. Disable this patch. + // + p = (unsigned char *)endAddress; + targetPatches -= 2; + } + } + } + else if ((targetPatches & 4) && strcmp(symbolName, "_xcpm_bootstrap") == 0) + { + offset = (nl->n_value - textSegment->vmaddr); + startAddress = (uint64_t)(textSegment->vmaddr + offset); + endAddress = (startAddress + 0x100); + + DEBUG_SYMBOL_FOUND(symbolName, offset, textSegment->vmaddr, textSegment->fileoff, startAddress, endAddress) + + for (p = (unsigned char *)startAddress; p <= (unsigned char *)endAddress; p++) + { + // + // Search pattern: 83 C3 xx 83 FB 22 77 1C (in HexEdit). + // + if ((*(uint16_t *)p == 0xc383) && (*(uint32_t *)(p + 3) == 0x7722fb83) && (*(uint8_t *)(p + 7) == 0x1C)) + { + DEBUG_PATCH_STATUS(symbolName, ((uint64_t)p - startAddress), 1) + + // *(uint8_t *)(p + 2) = (*(uint8_t *)(p + 2) + PATCH_XCPM_BOOTSTRAP); + *(uint8_t *)(p + 2) = (*(uint8_t *)(p + 2) + xcpm_bootstrap_ModelCorrection); + // + // Done. Disable this patch. + // + p = (unsigned char *)endAddress; + targetPatches -= 4; + } + } + } + else if ((targetPatches & 8) && strcmp(symbolName, "_xcpm_idle") == 0) // 2 MSRs (0xE2, 0xE2) + { + uint8_t patch_count = 0; + offset = (nl->n_value - textSegment->vmaddr); + startAddress = (uint64_t)(textSegment->vmaddr + offset); + endAddress = (startAddress + 0x200); + + DEBUG_SYMBOL_FOUND(symbolName, offset, textSegment->vmaddr, textSegment->fileoff, startAddress, endAddress) + + for (p = (unsigned char *)startAddress; p <= (unsigned char *)endAddress; p++) + { + if (*(uint64_t *)p == 0x300f000000e2b920)// (48 C1 EA) 20 B9 E2 00 00 00 0F 30 reversed + { + patch_count++; + + DEBUG_PATCH_STATUS(symbolName, ((uint64_t)p - startAddress), 1) + + *(uint32_t *)(p + 4) = 0x90900000; // Reversed 00 00 90 90 (4 bytes). + + if (patch_count == 2) + { + // + // Done. Disable this patch. + // + p = (unsigned char *)endAddress; + targetPatches -= 8; + } + } + } + } +#endif // #if (PATCH_KERNEL_XCPM && ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN)) + // + // Are we done patching for this section? + // + if (targetPatches == 0) + { + // + // Yes. Disable this section. + // + targetSections -= nl->n_sect; + } + } + else if (nl->n_sect == 8 && nl->n_value && (targetSections & nl->n_sect)) // __DATA,__data + { + symbolName = (char *)stringTable + nl->n_un.n_strx; + +#if (PATCH_KERNEL_XCPM && ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN)) + if ((targetPatches & 16) && strcmp(symbolName, "_xcpm_SMT_scope_msrs") == 0) + { + // + // 11 MSRs (0xE2, 0x01A0, 0x01B0, 0x01B0, 0x01B0, 0x0609, 0x038D, 0x038F, 0x0187, 0x0188, 0x0189) + // + int64_t offset = (nl->n_value - textSegment->vmaddr); + uint64_t startAddress = (uint64_t)(textSegment->vmaddr + offset); + + DEBUG_SYMBOL_FOUND(symbolName, offset, textSegment->vmaddr, textSegment->fileoff, startAddress, startAddress) + // + // Disable MSR's from config.h + // + disableMSRs((unsigned char *)startAddress, 11); + // + // Done. Disable this patch. + // + targetPatches -= 16; + } + else if ((targetPatches & 32) && strcmp(symbolName, "_xcpm_core_scope_msrs") == 0) + { + // + // 2 MSRs (0xE2, 0xE2) + // + int64_t offset = (nl->n_value - textSegment->vmaddr); + uint64_t startAddress = (uint64_t)(textSegment->vmaddr + offset); + + DEBUG_SYMBOL_FOUND(symbolName, offset, textSegment->vmaddr, textSegment->fileoff, startAddress, startAddress) + // + // Disable MSR's from config.h + // + disableMSRs((unsigned char *)startAddress, 2); + // + // Done. Disable this patch. + // + targetPatches -= 32; + } + else if ((targetPatches & 64) && strcmp(symbolName, "_xcpm_pkg_scope_msrs") == 0) + { + // + // 7 MSRs (0x01A0, 0x01FC, 0x01AA, 0x0620, 0x064C, 0x063A, 0x0642) + // + int64_t offset = (nl->n_value - textSegment->vmaddr); + uint64_t startAddress = (uint64_t)(textSegment->vmaddr + offset); + + DEBUG_SYMBOL_FOUND(symbolName, offset, textSegment->vmaddr, textSegment->fileoff, startAddress, startAddress) + // + // Disable MSR's from config.h + // + disableMSRs((unsigned char *)startAddress, 7); + // + // Done. Disable this patch. + // + targetPatches -= 64; + + } +#endif // #if (PATCH_KERNEL_XCPM && ((MAKE_TARGET_OS & EL_CAPITAN) == EL_CAPITAN)) + // + // Are we done patching for this section? + // + if (targetPatches == 0) + { + // + // Yes. Disable this section. + // + targetSections -= nl->n_sect; + } + } +#if PRELINKED_KERNEL_SUPPORT + else if (/* nl->n_sect == 27 && */ nl->n_value /* && (targetSections & nl->n_sect) */) // __KLD,__text + { + symbolName = (char *)stringTable + nl->n_un.n_strx; + + if (/* (targetPatches & 128) && */ strcmp(symbolName, "__ZN12KLDBootstrap21readStartupExtensionsEv") == 0) + { + int64_t offset = (nl->n_value - textSegment->vmaddr); + uint64_t startAddress = (uint64_t)(textSegment->vmaddr + offset); + uint64_t endAddress = (startAddress + 0x3f); + + DEBUG_SYMBOL_FOUND(symbolName, offset, textSegment->vmaddr, textSegment->fileoff, startAddress, endAddress) + + for (p = (unsigned char *)startAddress; p <= (unsigned char *)endAddress; p++) + { + if (*(uint64_t *)p == 0xe805eb00000025e8) // E8 25 00 00 00 EB 05 E8 (in HexEdit) + { // ^^^^ + DEBUG_PATCH_STATUS(symbolName, ((uint64_t)p - startAddress), 1) + + *(uint64_t *)p = 0xe8909000000025e8; // E8 25 00 00 00 90 90 E8 (in HexEdit) + // ^^^^ + // + // Disable this section. + // + p = (unsigned char *)endAddress; + // targetPatches -= 128; + targetSections -= nl->n_sect; + } + } + } + } +#endif // #if PRELINKED_KERNEL_SUPPORT + + symbolNumber++; + pointer += listSize; // Point to next symbol. + } + + return 0; +} diff --git a/i386/libsaio/pci.h b/i386/libsaio/pci.h index e48456a..f472f38 100755 --- a/i386/libsaio/pci.h +++ b/i386/libsaio/pci.h @@ -20,12 +20,20 @@ uint32_t pciConfigRead( uint8_t readType, uint32_t pciAddress, uint8_t pciRegist //============================================================================== // Note: Currently only called from: i386/libsaio/cpu/dynamic_data.h +static inline uint8_t pciConfigRead8(uint32_t pciAddress, uint8_t pciRegister) +{ + return (uint8_t)pciConfigRead(READ_BYTE, pciAddress, pciRegister); +} + +//============================================================================== +// Note: Currently only called from: i386/libsaio/cpu/dynamic_data.h + + static inline uint16_t pciConfigRead16(uint32_t pciAddress, uint8_t pciRegister) { return (uint16_t)pciConfigRead(READ_WORD, pciAddress, pciRegister); } - //============================================================================== // Note: Currently only called from: i386/libsaio/cpu/dynamic_data.h @@ -33,4 +41,3 @@ static inline uint32_t pciConfigRead32(uint32_t pciAddress, uint8_t pciRegister) { return (uint32_t)pciConfigRead(READ_LONG, pciAddress, pciRegister); } - diff --git a/i386/libsaio/platform.c b/i386/libsaio/platform.c index 11af0fa..c6b4f42 100644 --- a/i386/libsaio/platform.c +++ b/i386/libsaio/platform.c @@ -4,7 +4,9 @@ * * Updates: * - * - STATIC_SMBIOS_MODEL_ID renamed to SMB_PRODUCT_NAME (PikerAlpha, October 2012). + * - STATIC_SMBIOS_MODEL_ID renamed to SMB_PRODUCT_NAME (Pike R. Alpha, October 2012). + * - Yosemite support added (Pike R. Alpha, June 2014). + * - Replaced hard-coded OS version control with a flexible one (Pike R. Alpha, June 2014). * */ @@ -127,10 +129,12 @@ void initPlatform(int biosDevice) { memset(&gPlatform, 0, sizeof(gPlatform)); + gPlatform.BootMode = kBootModeQuiet; // no longer defaults to 0 aka kBootModeNormal + // Copied from cpu/dynamic_data.h to make printf work this early on. -#if DEBUG_CPU || DEBUG_PLATFORM +#if DEBUG_STATE_ENABLED extern void setVideoMode(int mode); - setVideoMode(0); // Switch to VGA_TEXT_MODE + setVideoMode(VGA_TEXT_MODE); #endif #if ENABLE_HPET @@ -161,11 +165,9 @@ void initPlatform(int biosDevice) * DHP: Booting with arch=i386 and setting this to CPU_TYPE_I386 * and setting the EFI_64_BIT directive in private_data to 0 allowed me * to boot in EFI32 mode. Even with my 64 bit configuration. Pretty sweet. - * - * Note to self: Get rid of gArchCPUType (global alarm) fast. */ - gPlatform.ArchCPUType = gArchCPUType = getArchCPUType(); + gPlatform.ArchCPUType = getArchCPUType(); gPlatform.AddressWidth = (gPlatform.ArchCPUType == CPU_TYPE_X86_64) ? 8 : 4; @@ -177,12 +179,18 @@ void initPlatform(int biosDevice) gPlatform.MPS.Guid = (EFI_GUID) EFI_MPS_TABLE_GUID; #endif // INCLUDE_MP_TABLE - // Used in boot.c to verify the checksum (adler32) of a pre-linked kernel. - gPlatform.ModelID = SMB_PRODUCT_NAME; + // Used in boot.c to verify the checksum (adler32) of pre-linked kernels. + gPlatform.ModelID = strdup(SMB_PRODUCT_NAME); + +#if LOAD_MODEL_SPECIFIC_STATIC_DATA + // Used in RevoBoot/i386/libsaio/ACPI/patcher.h, RevoBoot/i386/libsaio/efi.c + // and RevoBoot/i386/libsaio/SMBIOS/static_data.h + gPlatform.CommaLessModelID = removeChar(strdup(gPlatform.ModelID), ','); +#endif // Determine system type based on product name. Used in // acpi/patcher.h to update FADT->Preferred_PM_Profile - gPlatform.Type = (strncmp(gPlatform.ModelID, "MacBook", 7) == 0) ? 2 : 1; + gPlatform.Type = (strncmp(gPlatform.ModelID, "MacBook", 7) == 0) ? 2 : PM_PROFILE_OVERRIDE; // Are we supposted to have a Mobile CPU? if (gPlatform.Type == 2 && gPlatform.CPU.Mobile == false) @@ -192,14 +200,10 @@ void initPlatform(int biosDevice) gPlatform.CPU.Mobile = true; // Will be initialized in cpu/cpu_dynamic.h (used in smbios/dynamic_data.h) } -#if (MAKE_TARGET_OS == LION) - gPlatform.OSVersion = strdup("10.7"); -#elif (MAKE_TARGET_OS == MOUNTAIN_LION) - gPlatform.OSVersion = strdup("10.8"); -#else // Snow Leopard - gPlatform.OSVersion = strdup("10.6"); -#endif - + // MAKE_TARGET_OS_VER is defined in RevoBoot/i386/libsaio/Makefile + // and exported from the main RevoBoot/Makefile + gPlatform.OSVersion = MAKE_TARGET_OS_VER; + // _PLATFORM_DEBUG_DUMP("REVOBOOT_OS_TARGET: %d\n", REVOBOOT_OS_TARGET); gPlatform.OSType = (int) MAKE_TARGET_OS; @@ -211,16 +215,20 @@ void initPlatform(int biosDevice) _PLATFORM_DEBUG_DUMP("gPlatform.OSVersion: %s\n", gPlatform.OSVersion); + gPlatform.HelperPath = NULL; // Will be initialized in stringTable.c + + gPlatform.KernelCachePath = strdup(kKernelCachePath); // Used in boot.c and driver.c + _PLATFORM_DEBUG_DUMP("Kernel cache path: %s\n", gPlatform.KernelCachePath); + gPlatform.BIOSDevice = (biosDevice & kBIOSDevMask); // Device number masked with 0xFF. gPlatform.BootVolume = NULL; // Will be initialized in disk.c gPlatform.BootPartitionChain = NULL; // Will be initialized in sys.c gPlatform.RootVolume = NULL; // Will be initialized in disk.c (used in sys.c) - gPlatform.RAM.SlotCount = 0; // Will be initialized further down (used in smbios/dynamic_data.h) - - gPlatform.KernelCachePath = strdup(kKernelCachePath); // Used in boot.c and driver.c + gPlatform.UUID = NULL; // Will be initialized in RevoBoot/i386/libsaio/smbios/[dynamic/static]_data.h - _PLATFORM_DEBUG_DUMP("Kernel cache path: %s\n", gPlatform.KernelCachePath); + gPlatform.RAM.SlotCount = 0; // Will be initialized further down (used in smbios/dynamic_data.h) + gPlatform.RAM.MemorySize = 0; // Will be initialized in setupSMBIOS() #if USE_STATIC_SMBIOS_DATA // We don't have to do anything when static SMBIOS data is used. @@ -230,25 +238,26 @@ void initPlatform(int biosDevice) const char * ramPartNumber[] = STATIC_RAM_PART_NUMBERS; const char * ramSerialNumber[] = STATIC_RAM_SERIAL_NUMBERS; -#if DYNAMIC_RAM_OVERRIDE_SIZE - int ramSize[] = DYNAMIC_RAM_OVERRIDE_SIZES; +#if STATIC_RAM_OVERRIDE_SIZE + int ramSize[] = STATIC_RAM_OVERRIDE_SIZES; #endif - int i = 0; + int populatedSlotCount = 0; // Loop through the static RAM vendors (might be different). - for (; i < STATIC_RAM_SLOTS; i++) + for (int i = 0; i < STATIC_RAM_SLOTS; i++) { gPlatform.RAM.SlotCount++; - // We check for "N/A" so make sure you use that in config/settings.h + // We check for "N/A" so make sure you use that in config/settings.h for unused RAM banks. if (strcmp(ramVendor[i], "N/A") != 0) { _PLATFORM_DEBUG_DUMP("Slot:%d, ", i); + populatedSlotCount++; gPlatform.RAM.MODULE[i].InUse = true; - gPlatform.RAM.MODULE[i].Type = DYNAMIC_RAM_OVERRIDE_TYPE; -#if DYNAMIC_RAM_OVERRIDE_SIZE + gPlatform.RAM.MODULE[i].Type = STATIC_RAM_OVERRIDE_TYPE; +#if STATIC_RAM_OVERRIDE_SIZE gPlatform.RAM.MODULE[i].Size = ramSize[i]; _PLATFORM_DEBUG_DUMP("Size:%d, ", gPlatform.RAM.MODULE[i].Size); @@ -261,20 +270,59 @@ void initPlatform(int biosDevice) gPlatform.RAM.MODULE[i].Vendor, gPlatform.RAM.MODULE[i].PartNumber, gPlatform.RAM.MODULE[i].SerialNumber); + _PLATFORM_DEBUG_SLEEP(2); } else { // Properly initialized for: smbios/dynamic_data.h which relies on it. gPlatform.RAM.MODULE[i].InUse = false; } + + _PLATFORM_DEBUG_SLEEP(1); + } + + if (populatedSlotCount < 2) + { + stop("At least 2 RAM banks required, check vendors in configuration file)!\n"); } _PLATFORM_DEBUG_DUMP("Static data for %d RAM BANKS used.\n", gPlatform.RAM.SlotCount); + _PLATFORM_DEBUG_SLEEP(10); +#else + _PLATFORM_DEBUG_SLEEP(5); #endif - _PLATFORM_DEBUG_SLEEP(15); - initKernelBootConfig(); +#if RECOVERY_HD_SUPPORT + int version = 1; + + printf("\nRecovery HD boot support enabled\n"); + printf("Recovery HD boot support is: enabled in version %d!\n", version); + + int key = (bgetc() & 0xff); + printf("key: %d\n", key); + + if ( ((key |= 0x20) == 0x33) || ((key |= 0x20) == 114) ) + { + gPlatform.BootRecoveryHD = true; + gPlatform.BootMode = kBootModeNormal; + } + + printf("gPlatform.BootRecoveryHD: %s\n", gPlatform.BootRecoveryHD ? "True" : "False"); + sleep(1); +#else + gPlatform.BootMode = kBootModeNormal; + gPlatform.BootRecoveryHD = false; +#endif + +#if (LOAD_MODEL_SPECIFIC_EFI_DATA || BLACKMODE) + /* + * We need to call this much earlier in the boot process when static EFI data + * is read from: /Extra/EFI[MacModelNN.bin]. Otherwise LoadFile (load.c) fails. + */ + initPartitionChain(); +#endif + initEFITree(); } diff --git a/i386/libsaio/platform.h b/i386/libsaio/platform.h index 9205b14..b66030f 100644 --- a/i386/libsaio/platform.h +++ b/i386/libsaio/platform.h @@ -3,31 +3,44 @@ * * Updates: * - * - SMBIOS data logic moved to preprocessor code (PikerAlpha, October 2012). - * - Now includes: RevoBoot/libsaoi/i386/SMBIOS/model_data.h (PikerAlpha, October 2012). + * - SMBIOS data logic moved to preprocessor code (Pike R. Alpha, October 2012). + * - Now includes: RevoBoot/libsaoi/i386/SMBIOS/model_data.h (Pike R. Alpha, October 2012). + * - DDR4 support added (Pike R. Alpha, June 2014). + * - Yosemite support added (Pike R. Alpha, June 2014). + * - El Capitan support added (Pike R. Alpha, June 2015). * */ #ifndef __LIBSAIO_PLATFORM_H #define __LIBSAIO_PLATFORM_H +#define __LP64__ 1 + #include "libsaio.h" #include "cpu/essentials.h" #include "efi/essentials.h" #include "efi/efi.h" #include "device_tree.h" + + //------------------------------------------------------------------------------ #define SNOW_LEOPARD 1 // Snow Leopard. #define LION 2 // Lion (the default). #define MOUNTAIN_LION 6 // Mountain Lion (includes Lion changes). +#define MAVERICKS 10 // Mavericks (includes Lion changes). +#define YOSEMITE 26 // Yosemite (includes Lion and Mavericks changes). +#define EL_CAPITAN 62 // El Capitan (includes Lion/Mavericks and Yosemite changes). +#define SIERRA 126 // Sierra (includes Lion/Mavericks/Yosemite and El Capitan changes). +#define HIGH_SIERRA 254 // High Sierra (includes Lion/Mavericks/Yosemite/El Capitan and Sierra changes). //------------------------------------------------------------------------------ #define SMB_MEM_TYPE_DDR2 19 #define SMB_MEM_TYPE_FBDIMM 20 #define SMB_MEM_TYPE_DDR3 24 +#define SMB_MEM_TYPE_DDR4 26 //------------------------------------------------------------------------------ @@ -38,6 +51,7 @@ #define SMB_MEM_SIZE_8GB (SMB_MEM_SIZE_1GB * 8) #define SMB_MEM_SIZE_16GB (SMB_MEM_SIZE_1GB * 16) #define SMB_MEM_SIZE_32GB (SMB_MEM_SIZE_1GB * 32) // May not be supported! +#define SMB_MEM_SIZE_64GB (SMB_MEM_SIZE_1GB * 64) // May not be supported! //------------------------------------------------------------------------------ // All currently supported models are defined below. @@ -54,37 +68,98 @@ // Additional model selectors to select a specific target model. //------------------------------------------------------------------------------ -#define IMAC_131 IMAC | (3 << 15) -#define IMAC_111 IMAC | (2 << 15) -#define IMAC_122 IMAC | (1 << 15) -#define IMAC_121 IMAC // Defaults to iMac12,1 - -#define MACBOOK_41 MACBOOK // Defaults to MacBook,1 - -#define MACBOOK_AIR_42 MACBOOK_AIR | (1 << 15) -#define MACBOOK_AIR_41 MACBOOK_AIR // Defaults to MacBookAir4,1 - -#define MACBOOK_PRO_101 MACBOOK_PRO | (5 << 15) -#define MACBOOK_PRO_91 MACBOOK_PRO | (4 << 15) -#define MACBOOK_PRO_83 MACBOOK_PRO | (3 << 15) -#define MACBOOK_PRO_82 MACBOOK_PRO | (2 << 15) -#define MACBOOK_PRO_81 MACBOOK_PRO | (1 << 15) -#define MACBOOK_PRO_61 MACBOOK_PRO // Defaults to MacBookPro8,1 +#define IMAC_111 (IMAC | ( 1 << 15)) +#define IMAC_121 (IMAC | ( 2 << 15)) +#define IMAC_122 (IMAC | ( 3 << 15)) +#define IMAC_131 (IMAC | ( 4 << 15)) +#define IMAC_132 (IMAC | ( 5 << 15)) +#define IMAC_133 (IMAC | ( 6 << 15)) +#define IMAC_141 (IMAC | ( 7 << 15)) +#define IMAC_142 (IMAC | ( 8 << 15)) +#define IMAC_143 (IMAC | ( 9 << 15)) +#define IMAC_144 (IMAC | (10 << 15)) +#define IMAC_151 (IMAC | (11 << 15)) +#define IMAC_152 (IMAC | (12 << 15)) +#define IMAC_161 (IMAC | (13 << 15)) +#define IMAC_162 (IMAC | (14 << 15)) +#define IMAC_171 (IMAC | (15 << 15)) +#define IMAC_181 (IMAC | (16 << 15)) +#define IMAC_182 (IMAC | (17 << 15)) +#define IMAC_183 (IMAC | (18 << 15)) +#define IMAC_191 IMAC // Defaults to iMac19,1 + +#define MACBOOK_41 (MACBOOK | ( 1 << 15)) +#define MACBOOK_81 (MACBOOK | ( 2 << 15)) +#define MACBOOK_82 (MACBOOK | ( 3 << 15)) +#define MACBOOK_91 MACBOOK // Defaults to MacBook9,1 + +#define MACBOOK_AIR_41 (MACBOOK_AIR | (1 << 15)) +#define MACBOOK_AIR_42 (MACBOOK_AIR | (2 << 15)) +#define MACBOOK_AIR_51 (MACBOOK_AIR | (3 << 15)) +#define MACBOOK_AIR_52 (MACBOOK_AIR | (4 << 15)) +#define MACBOOK_AIR_61 (MACBOOK_AIR | (5 << 15)) +#define MACBOOK_AIR_62 (MACBOOK_AIR | (6 << 15)) +#define MACBOOK_AIR_71 (MACBOOK_AIR | (7 << 15)) +#define MACBOOK_AIR_72 MACBOOK_AIR // Defaults to MacBookAir7,2 + +#define MACBOOK_PRO_61 (MACBOOK_PRO | ( 1 << 15)) +#define MACBOOK_PRO_81 (MACBOOK_PRO | ( 2 << 15)) +#define MACBOOK_PRO_82 (MACBOOK_PRO | ( 3 << 15)) +#define MACBOOK_PRO_83 (MACBOOK_PRO | ( 4 << 15)) +#define MACBOOK_PRO_91 (MACBOOK_PRO | ( 5 << 15)) +#define MACBOOK_PRO_92 (MACBOOK_PRO | ( 6 << 15)) +#define MACBOOK_PRO_101 (MACBOOK_PRO | ( 7 << 15)) +#define MACBOOK_PRO_102 (MACBOOK_PRO | ( 8 << 15)) +#define MACBOOK_PRO_111 (MACBOOK_PRO | ( 9 << 15)) +#define MACBOOK_PRO_112 (MACBOOK_PRO | (10 << 15)) +#define MACBOOK_PRO_113 (MACBOOK_PRO | (11 << 15)) +#define MACBOOK_PRO_114 (MACBOOK_PRO | (12 << 15)) +#define MACBOOK_PRO_115 (MACBOOK_PRO | (13 << 15)) +#define MACBOOK_PRO_121 (MACBOOK_PRO | (14 << 15)) +#define MACBOOK_PRO_131 (MACBOOK_PRO | (15 << 15)) +#define MACBOOK_PRO_132 (MACBOOK_PRO | (16 << 15)) +#define MACBOOK_PRO_133 (MACBOOK_PRO | (17 << 15)) +#define MACBOOK_PRO_141 (MACBOOK_PRO | (18 << 15)) +#define MACBOOK_PRO_142 (MACBOOK_PRO | (19 << 15)) +#define MACBOOK_PRO_143 MACBOOK_PRO // Defaults to MacBookPro14,3 + +#define MACMINI_41 (MACMINI | (1 << 15)) +#define MACMINI_51 (MACMINI | (2 << 15)) +#define MACMINI_52 (MACMINI | (3 << 15)) +#define MACMINI_53 (MACMINI | (4 << 15)) +#define MACMINI_61 (MACMINI | (5 << 15)) +#define MACMINI_62 (MACMINI | (6 << 15)) +#define MACMINI_81 (MACMINI | (7 << 15)) +#define MACMINI_71 MACMINI // Defaults to Macmini7,1 + +#define MACPRO_31 (MACPRO | (1 << 15)) +#define MACPRO_41 (MACPRO | (2 << 15)) +#define MACPRO_51 (MACPRO | (3 << 15)) +#define MACPRO_71 (MACPRO | (4 << 15)) +#define MACPRO_61 MACPRO // Defaults to MacPro6,1 + + +#if ((TARGET_MODEL & MACPRO) == MACPRO) + #define PM_PROFILE_OVERRIDE 3 +#else + #define PM_PROFILE_OVERRIDE 1 +#endif -#define MACMINI_53 (MACMINI | (2 << 15)) -#define MACMINI_52 (MACMINI | (1 << 15)) -#define MACMINI_51 MACMINI // Defaults to Macmini5,1 +//------------------------------------------------------------------------------ -#define MACPRO_51 MACPRO | (2 << 15) -#define MACPRO_41 MACPRO | (1 << 15) -#define MACPRO_31 MACPRO // Defaults to MacPro3,1 +// #define LOAD_MODEL_SPECIFIC_STATIC_DATA (LOAD_MODEL_SPECIFIC_ACPI_DATA || LOAD_MODEL_SPECIFIC_EFI_DATA || LOAD_MODEL_SPECIFIC_SMBIOS_DATA) #include "smbios/model_data.h" //------------------------------------------------------------------------------ -#define kKernelCachePath "/System/Library/Caches/com.apple.kext.caches/Startup" -#define kKernelCache "kernelcache" +#if ((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) // Yosemite and El Capitan. + #define kKernelCachePath "/System/Library/PrelinkedKernels" + #define kKernelCache "prelinkedkernel" +#else + #define kKernelCachePath "/System/Library/Caches/com.apple.kext.caches/Startup" + #define kKernelCache "kernelcache" +#endif //------------------------------------------------------------------------------ @@ -105,6 +180,17 @@ #define MAX_SLOTS STATIC_RAM_SLOTS // Defined in config/settings.h #endif +//============================================================================== +// Kernel boot modes (moved from boot.h) + +enum +{ + kBootModeNormal = 0, + kBootModeSafe = 1, + kBootModeSecure = 2, + kBootModeQuiet = 4 +}; + //============================================================================== typedef struct _RamSlotInfo_t @@ -141,21 +227,31 @@ typedef struct _PlatformInfo_t char * OSVersion; // OS version initialized with "10.6" in platform.c and // later updated in boot.c with the actual version info. - + + struct KERNEL // Initialised in initKernelVersionInfo() + { + uint8_t versionMajor; + + uint8_t versionMinor; + + uint8_t versionRevision; + } KERNEL; + char * ModelID; // Initialized in platform.c and used in boot.c - + char * CommaLessModelID; // Initialized in platform.c and used in i386/libsaio/ACPI/patcher.h, char * KextFileName; // Initialized and used in drivers.c char * KextFileSpec; // Initialized and used in drivers.c char * KextPlistSpec; // Initialized and used in drivers.c - char * KernelCachePath; // Initialized in platform.c and used in boot.c, driver.c - -#if PRE_LINKED_KERNEL_SUPPORT + char * HelperPath; // Initialized in stringTable.c and used in boot.c +#if PRELINKED_KERNEL_SUPPORT bool KernelCacheSpecified; // Set to indicate that a full path is specified. #endif int BIOSDevice; // Initialized in platform.c (formely know as gBIOSDev). - + + long BootMode; // Initialized in platform.c + BVRef BootVolume; // Initialized in disk.c BVRef BootPartitionChain; // Initialized in sys.c BVRef RootVolume; // Initialized in disk.c (used in sys.c). @@ -163,7 +259,9 @@ typedef struct _PlatformInfo_t bool BootRecoveryHD; // uint32_t allocatedVRAM; // Amount of allocated graphics memory (UEFI-BIOS settings). - + + uint8_t * UUID; // Allocated/set in RevoBoot/i386/libsaio/smbios/[dynamic/static]_data.h + struct ACPI // Used in acpi_patcher.h { uint8_t Type; // System type. Referring to FACP->PM_Profile. @@ -177,6 +275,8 @@ typedef struct _PlatformInfo_t struct CPU { bool Mobile; // Set to true (in cpu/dynamic_data.h) for Mobile CPU's. + bool CstConfigMsrLocked; // Initialised in cpu/dynamic_data.h and used in load.c + uint16_t Type; // CPU type ('cpu-type') used in the SMBIOS patcher. uint32_t Features; // CPU Features like MMX, SSE2, VT, MobileCPU uint32_t Vendor; // Vendor @@ -198,7 +298,8 @@ typedef struct _PlatformInfo_t uint64_t TSCFrequency; // TSC Frequency Hz uint64_t FSBFrequency; // FSB Frequency Hz uint64_t CPUFrequency; // CPU Frequency Hz - + uint64_t ARTFrequency; // ART Frequency Hz + uint32_t QPISpeed; // QuickPath Interconnect Bus Speed uint8_t NumberOfTurboRatios; // Jeroen: initialized in cpu.c and used in ACPI/ssdt_pr_generator.h @@ -243,6 +344,7 @@ typedef struct _PlatformInfo_t uint8_t Channels; // Channel Configuration Single, Dual or Triple uint8_t SlotCount; // Previously NoSlots; - Maximum no of slots available uint8_t Type; // Standard SMBIOS v2.5 Memory Type + uint64_t MemorySize; // Initialised in setupSMBIOS() and used in initKernelBootConfig() /* Remove me */ char * BrandString; // Branding String Memory Controller RamSlotInfo_t MODULE[MAX_SLOTS]; // Information about each slot @@ -252,7 +354,7 @@ typedef struct _PlatformInfo_t { Node * RootNode; // Path: / } DT; - + struct EFI { EFI_SYSTEM_TABLE * SystemTable; // Used to re-calculate the checksum at the end of the run. @@ -264,6 +366,7 @@ typedef struct _PlatformInfo_t // EFI specific stuff. Node * ConfigurationTable; // Path: /efi/configuration-table + // Node * ACPI_Tables; // Path: /efi/configuration-table/ACPI Tables Node * RuntimeServices; // Path: /efi/runtime-services Node * Platform; // Path: /efi/platform } Nodes; @@ -294,7 +397,7 @@ typedef struct _PlatformInfo_t UInt8 CcdRevision; } DMI; */ } SMBIOS; - + } PlatformInfo_t; @@ -304,8 +407,6 @@ typedef struct _PlatformInfo_t extern void initCPUStruct(void); /* platform.c */ -extern cpu_type_t gArchCPUType; // DHP: Fix / remove me! - extern PlatformInfo_t gPlatform; extern void initPlatform(int biosDevice); diff --git a/i386/libsaio/saio_internal.h b/i386/libsaio/saio_internal.h index d4da384..7d3789b 100755 --- a/i386/libsaio/saio_internal.h +++ b/i386/libsaio/saio_internal.h @@ -20,79 +20,93 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ + * + * Updates: + * + * - loadBinaryData(load.c) and toLowerCase(string.c) added (Pike R. Alpha, October 2012). + * - Tidied up (spaces -> tabs) (Pike R. Alpha, October 2012). + * - Stripped (unnecessary) argument from loadSystemConfig (Pike R. Alpha, April 2013). + * - Use Lower Camel Case for function names (Pike R. Alpha, July 2016) + * */ #ifndef __LIBSAIO_SAIO_INTERNAL_H #define __LIBSAIO_SAIO_INTERNAL_H #include "saio_types.h" +#include "efi/essentials.h" + /* asm.s */ -extern void real_to_prot(void); -extern void prot_to_real(void); -extern void halt(void); -extern void startMachKernel(unsigned int address, void *arg); +extern void real_to_prot(void); +extern void prot_to_real(void); +extern void halt(void); +extern void startMachKernel(unsigned int address, void *arg); +extern uint64_t computeRand(void); -// extern void loader(UInt32 code, UInt32 cmdptr); /* bios.s */ -extern void bios(biosBuf_t *bb); +extern void bios(biosBuf_t *bb); -extern int bgetc(void); -extern int biosread(int dev, int cyl, int head, int sec, int num); -extern int ebiosread(int dev, unsigned long long sec, int count); -extern int get_drive_info(int drive, struct driveInfo *dp); -extern void putc(int ch); -extern void putca(int ch, int attr, int repeat); -extern int getc(void); -extern int readKeyboardStatus(void); +extern int bgetc(void); +extern int biosread(int dev, int cyl, int head, int sec, int num); +extern int ebiosread(int dev, unsigned long long sec, int count); +extern int get_drive_info(int drive, struct driveInfo *dp); +extern void putc(int ch); +extern void putca(int ch, int attr, int repeat); +extern int getc(void); +extern int readKeyboardStatus(void); extern unsigned int time18(void); -extern void delay(int ms); +extern void delay(int ms); extern unsigned int get_diskinfo(int dev); -extern int memsize(int i); -extern void video_mode(int mode); -extern void setCursorPosition(int x, int y, int page); -extern void setCursorType(int type); -extern void getCursorPositionAndType(int *x, int *y, int *type); -extern void scollPage(int x1, int y1, int x2, int y2, int attr, int rows, int dir); -extern void clearScreenRows(int y1, int y2); -extern void setActiveDisplayPage( int page ); +extern int memsize(int i); +extern void video_mode(int mode); +extern void setCursorPosition(int x, int y, int page); +extern void setCursorType(int type); +extern void getCursorPositionAndType(int *x, int *y, int *type); +extern void scollPage(int x1, int y1, int x2, int y2, int attr, int rows, int dir); +extern void clearScreenRows(int y1, int y2); +extern void setActiveDisplayPage(int page); extern unsigned long getMemoryMap(struct MemoryRange * rangeArray, unsigned long maxRangeCount, unsigned long * conMemSizePtr, unsigned long * extMemSizePtr); extern unsigned long getExtendedMemorySize(); extern unsigned long getConventionalMemorySize(); -extern void sleep(int n); +extern void sleep(int n); + /* efi.c */ -extern void initEFITree(void); -extern void updateEFITree(char *rootUUID); -extern void finalizeEFITree(void); +extern void initEFITree(void); +extern void updateEFITree(char *rootUUID); +extern void finalizeEFITree(uint32_t kernelAdler32); + /* bootstruct.c */ -extern void initKernelBootConfig(void); -extern void finalizeKernelBootConfig(void); -extern void moveKernelBootArgs(void); +extern void initKernelBootConfig(void); +extern void finalizeKernelBootConfig(void); +extern void moveKernelBootArgs(void); + /* cache.c */ -extern void CacheReset(); -extern void CacheInit(CICell ih, long blockSize); -extern long CacheRead(CICell ih, char *buffer, long long offset, long length, long cache); +extern void CacheReset(); +extern void CacheInit(CICell ih, long blockSize); +extern long CacheRead(CICell ih, char *buffer, long long offset, long length, long cache); + /* console.c */ -extern bool gVerboseMode; -extern bool gErrors; -extern void putchar(int ch); -extern int getchar(void); -extern int printf(const char *format, ...); -extern int error(const char *format, ...); -extern int verbose(const char *format, ...); -extern void stop(const char *format, ...); +extern bool gVerboseMode; +extern bool gErrors; +extern void putchar(int ch); +extern int getchar(void); +extern int printf(const char *format, ...); +extern int error(const char *format, ...); +extern int verbose(const char *format, ...); +extern void stop(const char *format, ...); /* disk.c */ -extern int testBiosread( int biosdev, unsigned long long secno); +extern int testBiosread(int biosdev, unsigned long long secno); extern BVRef diskScanBootVolumes(int biosdev, int *count); extern BVRef diskScanGPTBootVolumes(int biosdev, int *count); extern void diskSeek(BVRef bvr, long long position); @@ -100,94 +114,111 @@ extern int diskRead(BVRef bvr, long addr, long length); extern bool hasBootEFI(BVRef bvr); extern void initPartitionChain(void); -extern BVRef getBVChainForBIOSDev(int biosdev); -extern BVRef newFilteredBVChain(int minBIOSDev, int maxBIOSDev, unsigned int allowFlags, unsigned int denyFlags, int *count); -extern int freeFilteredBVChain(const BVRef chain); -extern int rawDiskRead(BVRef bvr, unsigned int secno, void *buffer, unsigned int len); -extern int rawDiskWrite(BVRef bvr, unsigned int secno, void *buffer, unsigned int len); -extern int readBootSector(int biosdev, unsigned int secno, void *buffer); -extern void turnOffFloppy(void); -extern int testFAT32EFIBootSector( int biosdev, unsigned int secno, void * buffer ); +extern BVRef getBVChainForBIOSDev(int biosdev); +extern BVRef newFilteredBVChain(int minBIOSDev, int maxBIOSDev, unsigned int allowFlags, unsigned int denyFlags, int *count); +extern int freeFilteredBVChain(const BVRef chain); +extern int rawDiskRead(BVRef bvr, unsigned int secno, void *buffer, unsigned int len); +extern int rawDiskWrite(BVRef bvr, unsigned int secno, void *buffer, unsigned int len); +extern int readBootSector(int biosdev, unsigned int secno, void *buffer); +extern void turnOffFloppy(void); +extern int testFAT32EFIBootSector(int biosdev, unsigned int secno, void * buffer); + + +/* guid.c */ +extern void convertEFIGUIDToString(EFI_GUID const *aGuid, char **aUUIDString); +extern bool isEFIGUIDNull(EFI_GUID const *aGuid); +extern int compareEFIGUID(EFI_GUID const *pG1, EFI_GUID const *pG2); + +#if USE_DEVICE_PATH +void *getUUIDFromDevicePath(EFI_DEVICE_PATH_PROTOCOL *devicePath); +#else +void *getUUIDFromDevicePath(EFI_GUID *aGUID); +#endif + +extern char * getStartupDiskUUID(char * aDataPtr); /* hfs_compare.c */ -extern int32_t FastUnicodeCompare(u_int16_t *uniStr1, u_int32_t len1, u_int16_t *uniStr2, u_int32_t len2, int byte_order); -extern void utf_encodestr( const u_int16_t * ucsp, int ucslen, u_int8_t * utf8p, u_int32_t bufsize, int byte_order ); -extern void utf_decodestr(const u_int8_t *utf8p, u_int16_t *ucsp, u_int16_t *ucslen, u_int32_t bufsize, int byte_order ); +extern int32_t FastUnicodeCompare(u_int16_t *uniStr1, u_int32_t len1, u_int16_t *uniStr2, u_int32_t len2); +extern void utf_encodestr(const u_int16_t * ucsp, int ucslen, u_int8_t * utf8p, u_int32_t bufsize); +extern void utf_decodestr(const u_int8_t *utf8p, u_int16_t *ucsp, u_int16_t *ucslen, u_int32_t bufsize); /* load.c */ -extern bool gLoadKernelDrivers; -extern long ThinFatFile(void **binary, unsigned long *length); -extern long DecodeMachO(void *binary, entry_t *rentry, char **raddr, int *rsize); +extern bool gLoadKernelDrivers; +extern long thinFatFile(void **binary, unsigned long *length); +extern long decodeMachO(void *binary, entry_t *rentry, char **raddr, int *rsize); +extern long loadBinaryData(char *aFilePath, void **aMemoryAddress); + + +/* patcher.c */ +extern long patchKernel(unsigned long loadAddress, unsigned long cmdBase, long listSize, unsigned long textSegmentAddress, unsigned long vldSegmentAddress); /* memory.c */ -long AllocateKernelMemory( long inSize ); -long AllocateMemoryRange(char * rangeName, long start, long length, long type); +long AllocateKernelMemory(long inSize); +long AllocateMemoryRange(char * rangeName, long start, long length); /* platform.c */ -extern void enableA20(void); +extern void enableA20(void); /* stringTable.c */ -extern bool getValueForConfigTableKey(config_file_t *config, const char *key, const char **val, int *size); -extern char * newStringForKey(char *key, config_file_t *configBuff); -extern bool getValueForBootKey(const char *line, const char *match, const char **matchval, int *len); -extern bool getValueForKey(const char *key, const char **val, int *size, config_file_t *configBuff); -extern bool getBoolForKey(const char *key, bool *val, config_file_t *configBuff); -extern bool getIntForKey(const char *key, int *val, config_file_t *configBuff); - -extern int loadConfigFile(const char *configFile, config_file_t *configBuff); +extern int base64Decode(char *input, unsigned char **decodedData); -extern int loadSystemConfig(config_file_t *configBuff); - - -extern int loadHelperConfig(config_file_t *configBuff); -extern int loadOverrideConfig(config_file_t *configBuff); - -extern char * newString(const char *oldString); -extern char * getNextArg(char ** ptr, char * val); -extern long ParseXMLFile( char * buffer, TagPtr * dict ); +extern bool getValueForConfigTableKey(config_file_t *config, const char *key, const char **val, int *size); +extern char * newStringForKey(char *key, config_file_t *configBuff); +extern bool getValueForBootKey(const char *line, const char *match, const char **matchval, int *len); +extern bool getValueForKey(const char *key, const char **val, int *size, config_file_t *configBuff); +extern bool getBoolForKey(const char *key, bool *val, config_file_t *configBuff); +extern bool getIntForKey(const char *key, int *val, config_file_t *configBuff); +extern long loadConfigFile(const char *configFile, config_file_t *configBuff); +extern long loadCABootPlist(void); +extern char * getNextArg(char ** ptr, char * val); +extern long ParseXMLFile(char * buffer, TagPtr * dict); /* sys.c */ -extern BVRef getBootVolumeRef( const char * path, const char ** outPath ); -extern long LoadVolumeFile(BVRef bvr, const char *fileSpec); -extern long LoadFile(const char *fileSpec); -extern long ReadFileAtOffset(const char * fileSpec, void *buffer, uint64_t offset, uint64_t length); -extern long LoadThinFatFile(const char *fileSpec, void **binary); -extern long GetDirEntry(const char *dirSpec, long *dirIndex, const char **name, long *flags, long *time); -extern long GetFileInfo(const char *dirSpec, const char *name,long *flags, long *time); -extern long GetFileBlock(const char *fileSpec, unsigned long long *firstBlock); -extern long GetFSUUID(char *spec, char *uuidStr); -extern long CreateUUIDString(uint8_t uubytes[], int nbytes, char *uuidStr); -extern int openmem(char *buf, int len); -extern int open(const char *str, int how); -extern int close(int fdesc); -extern int file_size(int fdesc); -extern int read(int fdesc, char *buf, int count); -extern int b_lseek(int fdesc, int addr, int ptr); -extern int tell(int fdesc); +extern BVRef getBootVolumeRef(const char * path, const char ** outPath); +extern long LoadVolumeFile(BVRef bvr, const char *fileSpec); +extern long LoadFile(const char *fileSpec); +extern long ReadFileAtOffset(const char * fileSpec, void *buffer, uint64_t offset, uint64_t length); +extern long LoadThinFatFile(const char *fileSpec, void **binary); +extern long GetDirEntry(const char *dirSpec, long *dirIndex, const char **name, long *flags, long *time); +extern long GetFileInfo(const char *dirSpec, const char *name,long *flags, long *time); +extern long GetFileBlock(const char *fileSpec, unsigned long long *firstBlock); +extern long GetFSUUID(char *spec, char *uuidStr); +extern long CreateUUIDString(uint8_t uubytes[], int nbytes, char *uuidStr); +extern int openmem(char *buf, int len); +extern int open(const char *str, int flags); +extern int close(int fdesc); +extern int file_size(int fdesc); +extern int read(int fdesc, char *buf, int count); +extern int b_lseek(int fdesc, int addr, int ptr); +extern int tell(int fdesc); extern const char * systemConfigDir(void); -extern struct dirstuff * opendir(const char *path); -extern struct dirstuff * vol_opendir(BVRef bvr, const char *path); -extern int closedir(struct dirstuff *dirp); -extern int readdir(struct dirstuff *dirp, const char **name, long *flags, long *time); -extern int readdir_ext(struct dirstuff * dirp, const char ** name, long * flags, long * time, FinderInfo *finderInfo, long *infoValid); -extern void flushdev(void); -extern void scanBootVolumes(int biosdev, int *count); +extern struct dirstuff * opendir(const char *path); +extern struct dirstuff * vol_opendir(BVRef bvr, const char *path); +extern int closedir(struct dirstuff *dirp); +extern int readdir(struct dirstuff *dirp, const char **name, long *flags, long *time); +extern int readdir_ext(struct dirstuff * dirp, const char ** name, long * flags, long * time, FinderInfo *finderInfo, long *infoValid); +extern void flushdev(void); +extern void scanBootVolumes(int biosdev, int *count); -extern BVRef getBootVolume(BVRef chain, int targetDevice); -extern BVRef getTargetRootVolume(char *rootUUID); -extern BVRef selectBootVolume(BVRef chain); +extern BVRef getBootVolume(BVRef chain, int targetDevice); +extern BVRef getTargetRootVolume(char *rootUUID); +extern BVRef selectBootVolume(BVRef chain); -extern void getBootVolumeDescription(BVRef bvr, char *str, long strMaxLen, bool verbose); +extern void getBootVolumeDescription(BVRef bvr, char *str, long strMaxLen, bool verbose); // Function pointer to be filled in if ramdisks are available -extern int (*p_get_ramdisk_info)(int biosdev, struct driveInfo *dip); -extern int (*p_ramdiskReadBytes)( int biosdev, unsigned int blkno, unsigned int byteoff, unsigned int byteCount, void * buffer ); +extern int (*p_get_ramdisk_info)(int biosdev, struct driveInfo *dip); +extern int (*p_ramdiskReadBytes)(int biosdev, unsigned int blkno, unsigned int byteoff, unsigned int byteCount, void * buffer); + + +/* string.h */ +extern char * toLowerCase(char *aSourceString); #endif /* !__LIBSAIO_SAIO_INTERNAL_H */ diff --git a/i386/libsaio/saio_types.h b/i386/libsaio/saio_types.h index 0d2ba5b..7b4942c 100755 --- a/i386/libsaio/saio_types.h +++ b/i386/libsaio/saio_types.h @@ -65,7 +65,7 @@ typedef struct Tag typedef struct { char plist[4096]; // buffer for plist - TagPtr dictionary; // buffer for xml dictionary + TagPtr dictionary; // buffer for XML dictionary bool canOverride; // flag to mark a dictionary can be overriden } config_file_t; @@ -211,7 +211,8 @@ enum kBVFlagBootable = 0x08, kBVFlagEFISystem = 0x10, kBVFlagBooter = 0x20, - kBVFlagSystemVolume = 0x40 + kBVFlagSystemVolume = 0x40, + kBVFlagInstallVolume = 0x80 }; enum diff --git a/i386/libsaio/sl.h b/i386/libsaio/sl.h index ac5e7d1..79715e0 100755 --- a/i386/libsaio/sl.h +++ b/i386/libsaio/sl.h @@ -20,6 +20,11 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ + * + * Updates: + * - White space changes (PikerAlpha, November 2012) + * - Unused Little Endian macro's removed (PikerAlpha, November 2012) + * */ #ifndef __LIBSAIO_SL_H @@ -31,39 +36,33 @@ #include "libsaio.h" #define SWAP_BE16(x) OSSwapBigToHostInt16(x) -#define SWAP_LE16(x) OSSwapLittleToHostInt16(x) #define SWAP_BE32(x) OSSwapBigToHostInt32(x) -#define SWAP_LE32(x) OSSwapLittleToHostInt32(x) #define SWAP_BE64(x) OSSwapBigToHostInt64(x) -#define SWAP_LE64(x) OSSwapLittleToHostInt64(x) // File Permissions and Types enum { - kPermOtherExecute = 1 << 0, - kPermOtherWrite = 1 << 1, - kPermOtherRead = 1 << 2, - kPermGroupExecute = 1 << 3, - kPermGroupWrite = 1 << 4, - kPermGroupRead = 1 << 5, - kPermOwnerExecute = 1 << 6, - kPermOwnerWrite = 1 << 7, - kPermOwnerRead = 1 << 8, - kPermMask = 0x1FF, - kOwnerNotRoot = 1 << 9, - kFileTypeUnknown = 0x0 << 16, - kFileTypeFlat = 0x1 << 16, - kFileTypeDirectory = 0x2 << 16, - kFileTypeLink = 0x3 << 16, - kFileTypeMask = 0x3 << 16 + kPermOtherExecute = 1 << 0, + kPermOtherWrite = 1 << 1, + kPermOtherRead = 1 << 2, + kPermGroupExecute = 1 << 3, + kPermGroupWrite = 1 << 4, + kPermGroupRead = 1 << 5, + kPermOwnerExecute = 1 << 6, + kPermOwnerWrite = 1 << 7, + kPermOwnerRead = 1 << 8, + kPermMask = 0x1FF, + kOwnerNotRoot = 1 << 9, + kFileTypeUnknown = 0x0 << 16, + kFileTypeFlat = 0x1 << 16, + kFileTypeDirectory = 0x2 << 16, + kFileTypeLink = 0x3 << 16, + kFileTypeMask = 0x3 << 16 }; -#define Seek(c, p) diskSeek(c, p); -#define Read(c, a, l) diskRead(c, a, l); +#define Seek(c, p) diskSeek(c, p); +#define Read(c, a, l) diskRead(c, a, l); extern void * gFSLoadAddress; -// Used in: boot/drivers/load.c -extern cpu_type_t gArchCPUType; // Formerly known as archCpuType. - #endif /* !__LIBSAIO_SL_H */ diff --git a/i386/libsaio/smbios.c b/i386/libsaio/smbios.c index 4b9b051..d4bf1b0 100755 --- a/i386/libsaio/smbios.c +++ b/i386/libsaio/smbios.c @@ -1,16 +1,21 @@ /* * Copyright (c) 2009 by Master Chief. - * Dynamic and static SMBIOS data gathering added by DHP in 2010. - * Refactorized by DHP in 2011. + * + * Updates: + * + * - Dynamic and static SMBIOS data gathering added by DHP in 2010. + * - Refactorized by DHP in 2011. + * - Get static EFI data (optional) from /Extra/EFI/[MacModelNN].bin (PikerAlpha, October 2012). + * - Set newEPS->dmi.tableLength to fileSize when model specific data is loaded (PikerAlpha, November 2012). + * - Get number of table structures from loaded model specific SMBIOS data (PikerAlpha, November 2012). + * - Set newEPS->maxStructureSize when SET_MAX_STRUCTURE_LENGTH is set (PikerAlpha, November 2012). + * - Check/correct errors in RevoBoot/i386/config/SMBIOS/[data-template/MacModelNN].h (PikerAlpha, November 2012). */ #include "platform.h" +#include "smbios/smbios.h" #if USE_STATIC_SMBIOS_DATA - -#include "smbios/static_data.h" - - //============================================================================== void setupSMBIOS(void) @@ -19,15 +24,13 @@ void setupSMBIOS(void) // Allocate 1 page of kernel memory (sufficient for a stripped SMBIOS table). void * kernelMemory = (void *)AllocateKernelMemory(4096); - + // Setup a new Entry Point Structure at the beginning of the newly allocated memory page. struct SMBEntryPoint * newEPS = (struct SMBEntryPoint *) kernelMemory; - int tableLength = sizeof(SMBIOS_Table); + // Include additional/conditional code snippet. + #include "smbios/static_data.h" - // Copy the static SMBIOS data into the newly allocated memory page. Right after the new EPS. - memcpy((kernelMemory + sizeof(* newEPS)), SMBIOS_Table, tableLength); - newEPS->anchor[0] = 0x5f; // _ newEPS->anchor[1] = 0x53; // S newEPS->anchor[2] = 0x4d; // M @@ -35,8 +38,8 @@ void setupSMBIOS(void) newEPS->checksum = 0; newEPS->entryPointLength = 0x1f; // sizeof(* newEPS) newEPS->majorVersion = 2; - newEPS->minorVersion = 4; - newEPS->maxStructureSize = STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE; // Defined in: config/smbios/data.h + newEPS->minorVersion = 6; + newEPS->maxStructureSize = STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE; // Defined in RevoBoot/i386/config/SMBIOS/data-template.h newEPS->entryPointRevision = 0; newEPS->formattedArea[0] = 0; @@ -51,27 +54,101 @@ void setupSMBIOS(void) newEPS->dmi.anchor[3] = 0x49; // I newEPS->dmi.anchor[4] = 0x5f; // _ newEPS->dmi.checksum = 0; - newEPS->dmi.tableLength = tableLength; + newEPS->dmi.tableLength = tableLength; newEPS->dmi.tableAddress = (uint32_t) (kernelMemory + sizeof(struct SMBEntryPoint)); - newEPS->dmi.structureCount = STATIC_SMBIOS_DMI_STRUCTURE_COUNT; // Defined in: config/smbios/data.h newEPS->dmi.bcdRevision = 0x24; - - // Take care of possible checksum errors - newEPS->dmi.checksum = 256 - checksum8(&newEPS->dmi, sizeof(newEPS->dmi)); - newEPS->checksum = 256 - checksum8(newEPS, sizeof(* newEPS)); - - _SMBIOS_DEBUG_DUMP("newEPS->dmi.structureCount: %d - tableLength: %d\n", newEPS->dmi.structureCount, newEPS->dmi.tableLength); - - // Used to update the EFI Configuration Table (in efi.c) which is + newEPS->dmi.structureCount = STATIC_SMBIOS_DMI_STRUCTURE_COUNT; // Defined in RevoBoot/i386/config/SMBIOS/[data-template/MacModelNN].h + + // Safety measure to protect people from doing something that breaks the boot process. + // #define FORCED_CHECK ((STATIC_SMBIOS_DMI_STRUCTURE_COUNT == 0) || (SET_MAX_STRUCTURE_LENGTH && (STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE == 0))) + #define FORCED_CHECK ((STATIC_SMBIOS_DMI_STRUCTURE_COUNT == 0) || SET_MAX_STRUCTURE_LENGTH) + +#if (LOAD_MODEL_SPECIFIC_SMBIOS_DATA || FORCED_CHECK) + /* + * Get number of SMBIOS table structures from the loaded model specific SMBIOS data, or + * when we have 0 values in: RevoBoot/i386/config/SMBIOS/[data-template/MacModelNN].bin + */ + if ((fileSize > 0) || FORCED_CHECK) + { + UInt16 structureCount = 0; + + char * structurePtr = (char *)newEPS->dmi.tableAddress; + char * structureEnd = (structurePtr + newEPS->dmi.tableLength); + + while (structureEnd > (structurePtr + sizeof(SMBStructHeader))) + { + struct SMBStructHeader * header = (struct SMBStructHeader *) structurePtr; + SMBByte currentStructureType = header->type; + + if (currentStructureType == kSMBTypeMemoryDevice) + { + UInt64 memorySize = 0; +#if STATIC_RAM_OVERRIDE_SIZE + memorySize = getRAMSize(); +#else + memorySize = ((SMBMemoryDevice *)header)->memorySize; +#endif + if (memorySize > 0 && memorySize < 0xffff) + { + gPlatform.RAM.MemorySize += (memorySize << ((memorySize & 0x8000) ? 10 : 20)); + } + } + +#if SET_MAX_STRUCTURE_LENGTH + char * stringsPtr = structurePtr; +#endif + // Skip the formatted area of the structure. + structurePtr += header->length; + + /* + * Skip the unformatted structure area at the end (strings). + * Using word comparison instead of checking two bytes (thanks to Kabyl). + */ + for (; ((uint16_t *)structurePtr)[0] != 0; structurePtr++); + + // Adjust pointer after locating the double 0 terminator. + structurePtr += 2; + + // Update structure counter. + structureCount++; + + _SMBIOS_DEBUG_DUMP("structureCount: %d\n", structureCount); + +#if SET_MAX_STRUCTURE_LENGTH + UInt16 maxStructureSize = (structurePtr - stringsPtr); + + if (newEPS->maxStructureSize < maxStructureSize) + { + newEPS->maxStructureSize = maxStructureSize; + } + + _SMBIOS_DEBUG_DUMP("Structure (%d) length: %3d bytes.\n", currentStructureType, maxStructureSize); + _SMBIOS_DEBUG_SLEEP(1); +#endif // #if SET_MAX_STRUCTURE_LENGTH + } + // Uodate number of structures (boot hang without the correct value). + newEPS->dmi.structureCount = structureCount; + } +#endif // #if (LOAD_MODEL_SPECIFIC_SMBIOS_DATA || FORCED_CHECK) + /* + * newEPS->dmi.tableLength represents the length of the static data, or the size + * of the model specific SMBIOS data file from: /Extra/SMBIOS/MacModelNN.bin + */ + _SMBIOS_DEBUG_DUMP("newEPS->dmi.structureCount: %d\nnewEPS.dmi.tableLength: %d\n", newEPS->dmi.structureCount, newEPS->dmi.tableLength); + + // Calculate checksums + newEPS->dmi.checksum = checksum8(&newEPS->dmi, sizeof(newEPS->dmi)); + newEPS->checksum = checksum8(newEPS, sizeof(* newEPS)); + + // Used to update the EFI Configuration Table (in efi.c) which is // what AppleSMBIOS.kext reads to setup the SMBIOS table for OS X. gPlatform.SMBIOS.BaseAddress = (uint32_t) newEPS; _SMBIOS_DEBUG_DUMP("New SMBIOS replacement setup.\n"); _SMBIOS_DEBUG_SLEEP(5); } - -#else +#else // #if USE_STATIC_SMBIOS_DATA #include "smbios/dynamic_data.h" -#endif \ No newline at end of file +#endif // #if USE_STATIC_SMBIOS_DATA diff --git a/i386/libsaio/smbios/dynamic_data.h b/i386/libsaio/smbios/dynamic_data.h index 99f62fe..f607040 100755 --- a/i386/libsaio/smbios/dynamic_data.h +++ b/i386/libsaio/smbios/dynamic_data.h @@ -8,9 +8,18 @@ * - Complete rewrite / overhaul by DHP in Februari 2011. * - More work, including bug fixes by DHP in Februari 2011. * - Do more with cleaner and faster code in less bytes (DHP in March 2012). - * - SMBIOS data logic moved to preprocessor code (PikerAlpha, October 2012). - * - SMBProperties changed for speed and simplicity (PikerAlpha, October 2012). - * - Calls with SMBProperties.keyString cleaned up (PikerAlpha, October 2012). + * - SMBIOS data logic moved to preprocessor code (Pike R. Alpha, October 2012). + * - SMBProperties changed for speed and simplicity (Pike R. Alpha, October 2012). + * - Calls with SMBProperties.keyString cleaned up (Pike R. Alpha, October 2012). + * - Fixed requiredStructures.start/stop values (Pike R. Alpha, October 2012). + * - STATIC_SMSERIALNUMBER renamed to SMB_SYSTEM_SERIAL_NUMBER (Pike R. Alpha, October 2012). + * - Removed some unused experimental code snippets (Pike R. Alpha, November 2012). + * - Option SET_MAX_STRUCTURE_LENGTH to verify/fix newEPS->maxStructureSize (Pike R. Alpha, November 2012). + * - Allow DEBUG_SMBIOS = 2 to filter out some of the output (Pike R. Alpha, November 2012). + * - Pre-compiler directive PROBOARD removed, which is required for iMessage (Pike R. Alpha, January 2013). + * - SMBStructure.start[2] was 13 but should have been 11 (Pike R. Alpha, January 2013). + * - Override factory SystemID when (Pike R. Alpha, January 2013). + * - Add table type 128 for High Sierra (Pike R. Alpha, June 2017). * * Credits: * - Kabyl (see notes in source code) @@ -19,7 +28,7 @@ * Tip: The idea is to use dynamic SMBIOS generation in RevoBoot only to * let it strip your factory table, after which you should do this: * - * 1.) Extract the new OS X compatible SMBIOS table with: tools/smbios2struct + * 1.) Extract the new OS X compatible SMBIOS table with: tools/smbios2struct3 * 2.) Add the data structure to: RevoBoot/i386/config/SMBIOS/data.h * 3.) Recompile RevoBoot, and be happy with your quicker boot time. * @@ -33,9 +42,10 @@ #include "libsaio.h" -#include "smbios.h" #include "model_data.h" +#define IOSERVICE_PLATFORM_FEATURE 0x0000000000000001 + //------------------------------------------------------------------------------ struct SMBStructure @@ -52,24 +62,26 @@ struct SMBStructure struct SMBStructure requiredStructures[] = { - { kSMBTypeBIOSInformation /* 0 */ , 0, 5, false, 0 }, - { kSMBTypeSystemInformation /* 1 */ , 6, 10, false, 0 }, - { kSMBTypeBaseBoard /* 2 */ , 11, 12, false, 0 }, - { kSMBUnused /* 3 */ , 0, 0, false, 0 }, - { kSMBTypeProcessorInformation /* 4 */ , 13, 14, true, 0 }, - { kSMBUnused /* 5 */ , 0, 0, false, 0 }, - { kSMBUnused /* 6 */ , 0, 0, false, 0 }, - { kSMBUnused /* 7 */ , 0, 0, false, 0 }, - { kSMBUnused /* 8 */ , 0, 0, false, 0 }, - { kSMBUnused /* 9 */ , 0, 0, false, 0 }, - { kSMBUnused /* 10 */ , 0, 0, false, 0 }, - { kSMBUnused /* 11 */ , 0, 0, false, 0 }, - { kSMBUnused /* 12 */ , 0, 0, false, 0 }, - { kSMBUnused /* 13 */ , 0, 0, false, 0 }, - { kSMBUnused /* 14 */ , 0, 0, false, 0 }, - { kSMBUnused /* 15 */ , 0, 0, false, 0 }, - { kSMBUnused /* 16 */ , 0, 0, false, 0 }, - { kSMBTypeMemoryDevice /* 17 */ , 15, 19, true, 0 } + { kSMBTypeBIOSInformation /* 0 */ , 0, 5, false, 0 }, + { kSMBTypeSystemInformation /* 1 */ , 6, 11, false, 0 }, + { kSMBTypeBaseBoard /* 2 */ , 12, 18, false, 0 }, + { kSMBUnused /* 3 */ , 0, 0, false, 0 }, + { kSMBTypeProcessorInformation /* 4 */ , 19, 20, true, 0 }, + { kSMBUnused /* 5 */ , 0, 0, false, 0 }, + { kSMBUnused /* 6 */ , 0, 0, false, 0 }, + { kSMBUnused /* 7 */ , 0, 0, false, 0 }, + { kSMBUnused /* 8 */ , 0, 0, false, 0 }, + { kSMBUnused /* 9 */ , 0, 0, false, 0 }, + { kSMBUnused /* 10 */ , 0, 0, false, 0 }, + { kSMBUnused /* 11 */ , 0, 0, false, 0 }, + { kSMBUnused /* 12 */ , 0, 0, false, 0 }, + { kSMBUnused /* 13 */ , 0, 0, false, 0 }, + { kSMBUnused /* 14 */ , 0, 0, false, 0 }, + { kSMBUnused /* 15 */ , 0, 0, false, 0 }, + { kSMBUnused /* 16 */ , 0, 0, false, 0 }, + { kSMBTypeMemoryDevice /* 17 */ , 21, 25, true, 0 }, + { kSMBUnused /* 18 */ , 0, 0, false, 0 }, + { kSMBTypeMemoryArrayMappedAddress /* 19 */ , -1, -1, false, 0 } }; @@ -102,60 +114,79 @@ struct SMBProperty const char *plainData; }; -#define APPLE_INC "Apple Inc." -#define SMB_SYSTEM_VERSION "1.0" +#define APPLE_INC "Apple Inc." +#define SMB_SYSTEM_SKU "System SKU#" +#define SMB_BOARD_ASSET_TAG "Base Board Asset Tag#" +#define SMB_BOARD_LOCATION "Part Component" //------------------------------------------------------------------------------ struct SMBProperty SMBProperties[] = { - //------------------------------------------------------------------------------------------------ - - { kSMBTypeBIOSInformation, 0x04, kSMBString, .plainData = APPLE_INC }, - { kSMBTypeBIOSInformation, 0x05, kSMBString, .plainData = SMB_BIOS_VERSION }, - { kSMBTypeBIOSInformation, 0x06, kSMBWord, .getSMBWord = getBIOSLocation }, - { kSMBTypeBIOSInformation, 0x08, kSMBString, .getSMBString = getBIOSDate }, - { kSMBTypeBIOSInformation, 0x0a, kSMBQWord, .getSMBQWord = getBIOSFeatures }, - { kSMBTypeBIOSInformation, 0x12, kSMBDWord, .getSMBDWord = getBIOSFeaturesEX }, - - //------------------------------------------------------------------------------------------------ + //---------------------------------------------------------------------------------------------------- - { kSMBTypeSystemInformation, 0x04, kSMBString, .plainData = APPLE_INC }, - { kSMBTypeSystemInformation, 0x05, kSMBString, .plainData = SMB_PRODUCT_NAME }, - { kSMBTypeSystemInformation, 0x06, kSMBString, .plainData = SMB_SYSTEM_VERSION }, - { kSMBTypeSystemInformation, 0x07, kSMBString, .plainData = STATIC_SMSERIALNUMBER }, - { kSMBTypeSystemInformation, 0x1a, kSMBString, .plainData = SMB_FAMILY }, + { kSMBTypeBIOSInformation, 0x04, kSMBString, .plainData = APPLE_INC }, + { kSMBTypeBIOSInformation, 0x05, kSMBString, .plainData = SMB_BIOS_VERSION }, + { kSMBTypeBIOSInformation, 0x06, kSMBWord, .getSMBWord = getBIOSLocation }, + { kSMBTypeBIOSInformation, 0x08, kSMBString, .getSMBString = getBIOSDate }, + { kSMBTypeBIOSInformation, 0x0a, kSMBQWord, .getSMBQWord = getBIOSFeatures }, + { kSMBTypeBIOSInformation, 0x12, kSMBDWord, .getSMBDWord = getBIOSFeaturesEX }, + + //---------------------------------------------------------------------------------------------------- - //------------------------------------------------------------------------------------------------ - - { kSMBTypeBaseBoard, 0x04, kSMBString, .plainData = APPLE_INC }, - { kSMBTypeBaseBoard, 0x05, kSMBString, .plainData = SMB_BOARD_PRODUCT }, + { kSMBTypeSystemInformation, 0x04, kSMBString, .plainData = APPLE_INC }, + { kSMBTypeSystemInformation, 0x05, kSMBString, .plainData = SMB_PRODUCT_NAME }, + { kSMBTypeSystemInformation, 0x06, kSMBString, .plainData = "1.0" }, + { kSMBTypeSystemInformation, 0x07, kSMBString, .plainData = SMB_SYSTEM_SERIAL_NUMBER }, + + { kSMBTypeSystemInformation, 0x19, kSMBString, .plainData = SMB_SYSTEM_SKU }, + { kSMBTypeSystemInformation, 0x1a, kSMBString, .plainData = SMB_FAMILY }, - //------------------------------------------------------------------------------------------------ + //---------------------------------------------------------------------------------------------------- - { kSMBTypeProcessorInformation, 0x12, kSMBWord, .getSMBWord = getFSBFrequency }, - { kSMBTypeProcessorInformation, 0x14, kSMBWord, .getSMBWord = getCPUFrequency }, + { kSMBTypeBaseBoard, 0x04, kSMBString, .plainData = APPLE_INC }, + { kSMBTypeBaseBoard, 0x05, kSMBString, .plainData = SMB_BOARD_PRODUCT }, + { kSMBTypeBaseBoard, 0x06, kSMBString, .plainData = SMB_FAMILY }, + { kSMBTypeBaseBoard, 0x07, kSMBString, .plainData = SMB_BOARD_SERIAL_NUMBER }, + { kSMBTypeBaseBoard, 0x08, kSMBString, .plainData = SMB_BOARD_ASSET_TAG }, + + { kSMBTypeBaseBoard, 0x0a, kSMBString, .plainData = SMB_BOARD_LOCATION }, + + { kSMBTypeBaseBoard, 0x0d, kSMBByte, .getSMBByte = getBoardType }, + + //---------------------------------------------------------------------------------------------------- - //------------------------------------------------------------------------------------------------ + { kSMBTypeProcessorInformation, 0x12, kSMBWord, .getSMBWord = getFSBFrequency }, + { kSMBTypeProcessorInformation, 0x14, kSMBWord, .getSMBWord = getCPUFrequency }, -#if DYNAMIC_RAM_OVERRIDE_SIZE - { kSMBTypeMemoryDevice, 0x0c, kSMBWord, .getSMBWord = getRAMSize }, + //---------------------------------------------------------------------------------------------------- + +#if STATIC_RAM_OVERRIDE_ERROR_HANDLE + // Handle or instance number associated with any error that was previously detected for the device. + // If the system does not provide the error information structure, then this field contains FFFEh; + // otherwise this field contains either FFFFh (if no error was detected) or the handle (number) of + // the error information structure. See 7.18.4 and 7.34 of the SMBIOS specification. + { kSMBTypeMemoryDevice, 0x06, kSMBWord, .plainData = 0xFFFE }, +#endif + +#if STATIC_RAM_OVERRIDE_SIZE + { kSMBTypeMemoryDevice, 0x0c, kSMBWord, .getSMBWord = getRAMSize }, #endif - { kSMBTypeMemoryDevice, 0x10, kSMBString, .getSMBString = NULL }, - { kSMBTypeMemoryDevice, 0x11, kSMBString, .getSMBString = NULL }, + { kSMBTypeMemoryDevice, 0x10, kSMBString, .getSMBString = NULL }, + { kSMBTypeMemoryDevice, 0x11, kSMBString, .getSMBString = NULL }, -#if DYNAMIC_RAM_OVERRIDE_TYPE - { kSMBTypeMemoryDevice, 0x12, kSMBByte, .getSMBByte = getRAMType }, +#if STATIC_RAM_OVERRIDE_TYPE + { kSMBTypeMemoryDevice, 0x12, kSMBByte, .getSMBByte = getRAMType }, #endif -#if DYNAMIC_RAM_OVERRIDE_FREQUENCY - { kSMBTypeMemoryDevice, 0x15, kSMBWord, .getSMBWord = getRAMFrequency }, +#if STATIC_RAM_OVERRIDE_FREQUENCY + { kSMBTypeMemoryDevice, 0x15, kSMBWord, .getSMBWord = getRAMFrequency }, #endif - { kSMBTypeMemoryDevice, 0x17, kSMBString, .getSMBString = getRAMVendor }, - { kSMBTypeMemoryDevice, 0x18, kSMBString, .getSMBString = getRAMSerialNumber }, - { kSMBTypeMemoryDevice, 0x1a, kSMBString, .getSMBString = getRAMPartNumber }, + { kSMBTypeMemoryDevice, 0x17, kSMBString, .getSMBString = getRAMVendor }, + { kSMBTypeMemoryDevice, 0x18, kSMBString, .getSMBString = getRAMSerialNumber }, + { kSMBTypeMemoryDevice, 0x1a, kSMBString, .getSMBString = getRAMPartNumber }, }; @@ -176,24 +207,23 @@ void setupSMBIOS(void) // return; //-------------------------------------------------------------------------- - // Allocate 1 page of kernel memory (sufficient for a stripped SMBIOS table). - void * kernelMemory = (void *)AllocateKernelMemory(4096); + // Allocate 4 pages of kernel memory (enough for a stripped SMBIOS table). + void * kernelMemory = (void *)AllocateKernelMemory(8192); // 4096 // Setup a new Entry Point Structure at the beginning of the newly allocated memory page. struct SMBEntryPoint * newEPS = (struct SMBEntryPoint *) kernelMemory; - // Clear the first K bytes (new table will be even shorter). - bzero(kernelMemory, 1024); - - newEPS->anchor[0] = 0x5f; // _ - newEPS->anchor[1] = 0x53; // S - newEPS->anchor[2] = 0x4d; // M - newEPS->anchor[3] = 0x5f; // _ - newEPS->checksum = 0; // Updated at the end of this run. - newEPS->entryPointLength = 0x1f; // sizeof(* newEPS) - newEPS->majorVersion = 2; // SMBIOS version 2.4 - newEPS->minorVersion = 4; - newEPS->maxStructureSize = 0; // Updated during this run. + bzero(kernelMemory, 8192); + + newEPS->anchor[0] = 0x5f; // _ + newEPS->anchor[1] = 0x53; // S + newEPS->anchor[2] = 0x4d; // M + newEPS->anchor[3] = 0x5f; // _ + newEPS->checksum = 0; // Updated at the end of this run. + newEPS->entryPointLength = 0x1f; // sizeof(* newEPS) + newEPS->majorVersion = 2; // SMBIOS version 2.7 + newEPS->minorVersion = 7; + newEPS->maxStructureSize = factoryEPS->maxStructureSize; // Optionally checked and updated later on. newEPS->entryPointRevision = 0; newEPS->formattedArea[0] = 0; @@ -202,30 +232,28 @@ void setupSMBIOS(void) newEPS->formattedArea[3] = 0; newEPS->formattedArea[4] = 0; - newEPS->dmi.anchor[0] = 0x5f; // _ - newEPS->dmi.anchor[1] = 0x44; // D - newEPS->dmi.anchor[2] = 0x4d; // M - newEPS->dmi.anchor[3] = 0x49; // I - newEPS->dmi.anchor[4] = 0x5f; // _ - newEPS->dmi.checksum = 0; // Updated at the end of this run. - newEPS->dmi.tableLength = 0; // Updated at the end of this run. + newEPS->dmi.anchor[0] = 0x5f; // _ + newEPS->dmi.anchor[1] = 0x44; // D + newEPS->dmi.anchor[2] = 0x4d; // M + newEPS->dmi.anchor[3] = 0x49; // I + newEPS->dmi.anchor[4] = 0x5f; // _ + newEPS->dmi.checksum = 0; // Updated at the end of this run. + newEPS->dmi.tableLength = 0; // Updated at the end of this run. newEPS->dmi.tableAddress = (uint32_t) (kernelMemory + sizeof(struct SMBEntryPoint)); - newEPS->dmi.structureCount = 0; // Updated during this run. - newEPS->dmi.bcdRevision = 0x24; // SMBIOS version 2.4 + newEPS->dmi.structureCount = 0; // Updated during this run. + newEPS->dmi.bcdRevision = 0x27; // SMBIOS version 2.7 char * stringsPtr = NULL; char * newtablesPtr = (char *)newEPS->dmi.tableAddress; char * structurePtr = (char *)factoryEPS->dmi.tableAddress; - char * structureStartPtr = NULL; - int i, j; - int numberOfStrings = 0; - int structureCount = factoryEPS->dmi.structureCount; + int i, j, numberOfStrings = 0; + int structureCount = factoryEPS->dmi.structureCount; SMBWord handle = 1; //------------------------------------------------------------------------------ - // Add SMBOemProcessorType structure. + // Add SMBOemProcessorType structure (131) struct SMBStructHeader * newHeader = (struct SMBStructHeader *) newtablesPtr; @@ -242,7 +270,39 @@ void setupSMBIOS(void) newtablesPtr += 8; //------------------------------------------------------------------------------ - // Add SMBOemProcessorBusSpeed structure (when we have something to inject). + // Add SMBFirmwareVolume structure (128). + + struct SMBFirmwareVolume * firmwareVolume = (struct SMBFirmwareVolume *) newtablesPtr; + + bzero(firmwareVolume, sizeof(struct SMBFirmwareVolume)); + + firmwareVolume->header.type = kSMBTypeFirmwareVolume; + firmwareVolume->header.length = sizeof(struct SMBFirmwareVolume); + firmwareVolume->header.handle = ++handle; + + firmwareVolume->RegionCount = (SMBByte) 1; + firmwareVolume->Reserved[0] = (SMBByte) 0; + firmwareVolume->Reserved[1] = (SMBByte) 0; + firmwareVolume->Reserved[2] = (SMBByte) 0; + firmwareVolume->FirmwareFeatures = getFirmwareFeatures(); + firmwareVolume->FirmwareFeaturesMask = getFirmwareFeaturesEx(); + /* firmwareVolume->RegionType[0] = FW_REGION_MAIN; + firmwareVolume->RegionType[1] = FW_REGION_RESERVED; + firmwareVolume->RegionType[2] = FW_REGION_RESERVED; + firmwareVolume->RegionType[3] = FW_REGION_RESERVED; + firmwareVolume->RegionType[4] = FW_REGION_RESERVED; + firmwareVolume->RegionType[5] = FW_REGION_RESERVED; + firmwareVolume->RegionType[6] = FW_REGION_RESERVED; + firmwareVolume->RegionType[7] = FW_REGION_RESERVED; */ + + // Update EPS + newEPS->dmi.tableLength += sizeof(struct SMBFirmwareVolume) + 2; + newEPS->dmi.structureCount++; + + newtablesPtr += sizeof(struct SMBFirmwareVolume) + 2; + + //------------------------------------------------------------------------------ + // Add SMBOemProcessorBusSpeed structure (132/when we have something to inject). if (gPlatform.CPU.QPISpeed) { @@ -260,8 +320,8 @@ void setupSMBIOS(void) newtablesPtr += 8; } - -#if DYNAMIC_RAM_OVERRIDE_SIZE || DYNAMIC_RAM_OVERRIDE_TYPE || DYNAMIC_RAM_OVERRIDE_FREQUENCY + +#if (STATIC_RAM_OVERRIDE_ERROR_HANDLE || STATIC_RAM_OVERRIDE_SIZE || STATIC_RAM_OVERRIDE_TYPE || STATIC_RAM_OVERRIDE_FREQUENCY) requiredStructures[17].stop = (sizeof(SMBProperties) / sizeof(SMBProperties[0])) -1; #endif @@ -273,7 +333,7 @@ void setupSMBIOS(void) struct SMBStructHeader * factoryHeader = (struct SMBStructHeader *) structurePtr; SMBByte currentStructureType = factoryHeader->type; - if ((currentStructureType > 17) || (requiredStructures[currentStructureType].type == kSMBUnused)) + if ((currentStructureType > 19) || (requiredStructures[currentStructureType].type == kSMBUnused)) { // _SMBIOS_DEBUG_DUMP("Dropping SMBIOS structure: %d\n", currentStructureType); @@ -287,26 +347,55 @@ void setupSMBIOS(void) // Adjust pointer after locating the double 0 terminator. structurePtr += 2; -#if DEBUG_SMBIOS - // printf("currentStructureType: %d (length: %d)\n", currentStructureType, factoryHeader->length); - // sleep(1); // Silent sleep (for debug only). +#if (DEBUG_SMBIOS & 2) + _SMBIOS_DEBUG_DUMP("currentStructureType: %d (length: %d)\n", currentStructureType, factoryHeader->length); + _SMBIOS_DEBUG_SLEEP(1); #endif continue; } - + newHeader = (struct SMBStructHeader *) newtablesPtr; // Copy structure data from factory table to new table (not the strings). memcpy(newHeader, factoryHeader, factoryHeader->length); + if (currentStructureType == kSMBTypeSystemInformation) + { + // gPlatform.UUID is set to NULL in platform.c so that we can check for NULL to see if we + // located the (per spec) required SMBIOS type 1 structure (allocating memory signals OK). + gPlatform.UUID = malloc(16); + +#ifdef SMB_STATIC_SYSTEM_UUID + static unsigned char SMB_SYSTEM_UUID[] = SMB_STATIC_SYSTEM_UUID; + + // Replace factory UUID with the one specified in: RevoBoot/i386/config/SETTINGS/MacModelNN.h + memcpy(((SMBSystemInformation *)newHeader)->uuid, SMB_SYSTEM_UUID, 16); + memcpy(gPlatform.UUID, SMB_SYSTEM_UUID, 16); +#else + // Get factory UUID from SMBIOS. + memcpy(gPlatform.UUID, ((SMBSystemInformation *)factoryHeader)->uuid, 16); +#endif + } + else if (currentStructureType == kSMBTypeMemoryDevice) + { + UInt64 memorySize = 0; +#if STATIC_RAM_OVERRIDE_SIZE + memorySize = getRAMSize(); +#else + memorySize = ((SMBMemoryDevice *)factoryHeader)->memorySize; +#endif + if (memorySize > 0 && memorySize < 0xffff) + { + gPlatform.RAM.MemorySize += (memorySize << ((memorySize & 0x8000) ? 10 : 20)); + } + } + // Init handle in the new header. newHeader->handle = ++handle; // Update structure counter. newEPS->dmi.structureCount++; - structureStartPtr = newtablesPtr; - // Update pointers (pointing to the end of the formatted area). structurePtr += factoryHeader->length; stringsPtr = structurePtr; @@ -334,7 +423,30 @@ void setupSMBIOS(void) } structurePtr += 2; - + +#if SET_MAX_STRUCTURE_LENGTH + /* + * Size of the longest factory SMBIOS structure, in bytes, encompasses the structure’s formatted area + * and text strings. In our case a kSMBTypeProcessorInformation structure, because we strip out all + * unwanted data. And safe to check it at this point, because we don't add anything this long ourself. + * + * Note: The maximum structure length is only checked when SET_MAX_STRUCTURE_LENGTH is set to 1 but + * is not required, because it is only available since RevoBoot v1.5.35. Never checked before. + */ + + UInt16 maxStructureSize = (structurePtr - (stringsPtr - factoryHeader->length)); + + if (newEPS->maxStructureSize < maxStructureSize) + { + newEPS->maxStructureSize = maxStructureSize; + } + + #if (DEBUG_SMBIOS & 2) + _SMBIOS_DEBUG_DUMP("Structure (%d) length: %3d bytes.\n", currentStructureType, maxStructureSize); + _SMBIOS_DEBUG_SLEEP(1); + #endif +#endif // if SET_MAX_STRUCTURE_LENGTH + // Do we need to copy the string data? if (requiredStructures[currentStructureType].copyStrings) { @@ -346,23 +458,6 @@ void setupSMBIOS(void) // Point to the next possible position for a string (deducting the second 0 char at the end). newtablesPtr += stringDataLength; - - /* ---------------------------------------------------------------------- - // Start of experimental code. - - if (currentStructureType == kSMBTypeProcessorInformation) - { - int c = 0; - - for (; c < 3; c++) - { - memcpy(newtablesPtr + 1, structureStartPtr, factoryHeader->length + stringDataLength + 2); - newtablesPtr += factoryHeader->length + stringDataLength + 2; - } - } - - //---------------------------------------------------------------------- - // End of experimental code. */ } else { @@ -385,13 +480,21 @@ void setupSMBIOS(void) { const char * str = ""; -#if DEBUG_SMBIOS if (SMBProperties[j].type != currentStructureType) { - printf("SMBIOS Patcher Error: Turbo Index [%d != %d] Mismatch!\n", SMBProperties[j].type, currentStructureType); +#if (DEBUG_SMBIOS & 2) + /* + * When SMBProperties[j].start and SMBProperties[j].stop are set to -1 + * then there isn't anything to add/replace, but that is not an error. + */ + if ((SMBProperties[j].start > -1) && (SMBProperties[j].stop > -1)) + { + printf("SMBIOS Patcher Error: Turbo Index [%d != %d] Mismatch!\n", SMBProperties[j].type, currentStructureType); + } +#endif continue; } -#endif + switch (SMBProperties[j].valueType) { case kSMBByte: @@ -427,7 +530,7 @@ void setupSMBIOS(void) { memcpy(newtablesPtr, str, size); newtablesPtr[size] = 0; - newtablesPtr += size + 1; + newtablesPtr += (size + 1); *((uint8_t *)(((char *)newHeader) + SMBProperties[j].offset)) = ++numberOfStrings; } break; @@ -445,6 +548,40 @@ void setupSMBIOS(void) requiredStructures[currentStructureType].hits++; } + //------------------------------------------------------------------------------ + // Add Platform Feature structure (Apple Specific Type 0x85/133). + // + // Note: AppleSMBIOS.kext will use this data for: IOService:/platform-feature + + newHeader = (struct SMBStructHeader *) newtablesPtr; + + newHeader->type = kSMBTypeOemPlatformFeature; + newHeader->length = 0x0C; + newHeader->handle = ++handle; + + *((uint64_t *)(((char *)newHeader) + 4)) = IOSERVICE_PLATFORM_FEATURE; + + // Update EPS + newEPS->dmi.tableLength += 0x0E; // 0x0C + two (00 00) + newEPS->dmi.structureCount++; + + newtablesPtr += 0x0E; + + /*------------------------------------------------------------------------------ + // Add SMBOemSMCVersion structure (134). + + newHeader = (struct SMBStructHeader *) newtablesPtr; + + newHeader->type = kSMBTypeOemSMCVersion; + newHeader->length = 6; + newHeader->handle = ++handle; + + // Update EPS + newEPS->dmi.tableLength += 8; + newEPS->dmi.structureCount++; + + newtablesPtr += 8; */ + //------------------------------------------------------------------------------ // Add EndOfTable structure. @@ -452,7 +589,7 @@ void setupSMBIOS(void) newHeader->type = kSMBTypeEndOfTable; newHeader->length = 4; - newHeader->handle = ++handle; + newHeader->handle = 0xFFFD; // ++handle; newtablesPtr += 6; @@ -465,8 +602,8 @@ void setupSMBIOS(void) newEPS->dmi.tableLength = (newtablesPtr - (char *)newEPS->dmi.tableAddress); // Calculate new checksums. - newEPS->dmi.checksum = 256 - checksum8(&newEPS->dmi, sizeof(newEPS->dmi)); - newEPS->checksum = 256 - checksum8(newEPS, sizeof(* newEPS)); + newEPS->dmi.checksum = checksum8(&newEPS->dmi, sizeof(newEPS->dmi)); + newEPS->checksum = checksum8(newEPS, sizeof(* newEPS)); _SMBIOS_DEBUG_DUMP("newEPS->dmi.structureCount: %d - tableLength: %d\n", newEPS->dmi.structureCount, newEPS->dmi.tableLength); @@ -480,4 +617,3 @@ void setupSMBIOS(void) #endif /* !__LIBSAIO_SMBIOS_PATCHER_H */ - diff --git a/i386/libsaio/smbios/essentials.h b/i386/libsaio/smbios/essentials.h index dc2ad54..9b4a970 100755 --- a/i386/libsaio/smbios/essentials.h +++ b/i386/libsaio/smbios/essentials.h @@ -58,4 +58,11 @@ struct SMBEntryPoint struct DMIEntryPoint dmi; } __attribute__((packed)); -#endif /* !__LIBSAIO_SMBIOS_ESSENTIALS_H */ \ No newline at end of file +typedef struct SMBStructHeader +{ + SMBByte type; + SMBByte length; + SMBWord handle; +} __attribute__((packed)) SMBStructHeader; + +#endif /* !__LIBSAIO_SMBIOS_ESSENTIALS_H */ diff --git a/i386/libsaio/smbios/getters.h b/i386/libsaio/smbios/getters.h index 9c9b100..17ae79e 100755 --- a/i386/libsaio/smbios/getters.h +++ b/i386/libsaio/smbios/getters.h @@ -11,6 +11,7 @@ * - Function getOverrideString removed (PikerAlpha, October 2012). * - Function getBIOSDate added (PikerAlpha, October 2012). * - Unused arguments removed (PikerAlpha, October 2012). + * - Pre-compiler directive PROBOARD removed, which is required for iMessage (PikerAlpha, January 2013). * * Credits: * - macerintel (see note in source code) @@ -26,12 +27,12 @@ #define NOT_AVAILABLE "N/A" #define RAM_SLOT_EMPTY "" -#ifndef DYNAMIC_RAM_OVERRIDE_TYPE - #define DYNAMIC_RAM_OVERRIDE_TYPE SMB_MEM_TYPE_DDR3 +#ifndef STATIC_RAM_OVERRIDE_TYPE + #define STATIC_RAM_OVERRIDE_TYPE SMB_MEM_TYPE_DDR3 #endif -#ifndef DYNAMIC_RAM_OVERRIDE_FREQUENCY - #define DYNAMIC_RAM_OVERRIDE_FREQUENCY 1066 +#ifndef STATIC_RAM_OVERRIDE_FREQUENCY + #define STATIC_RAM_OVERRIDE_FREQUENCY 1066 #endif /*============================================================================== @@ -92,11 +93,17 @@ static inline struct SMBEntryPoint * getEPSAddress(void) static SMBWord getFSBFrequency(void) { - _SMBIOS_DEBUG_DUMP("In getFSBFrequency() = %d Hz\n", (gPlatform.CPU.FSBFrequency < 100500000) ? 0 : (gPlatform.CPU.FSBFrequency / 1000000)); + // _SMBIOS_DEBUG_DUMP("In getFSBFrequency() = %d Hz\n", (gPlatform.CPU.FSBFrequency < 100500000) ? 0 : (gPlatform.CPU.FSBFrequency / 1000000)); + _SMBIOS_DEBUG_DUMP("In getFSBFrequency() = %d Hz\n", (gPlatform.CPU.FSBFrequency == 0) ? 0 : (gPlatform.CPU.FSBFrequency / 1000000)); + + if (gPlatform.CPU.QPISpeed == 0) + { + return ((gPlatform.CPU.FSBFrequency / 1000000) / 4); + } /* * Returning zero (0) here is invalid, but we can get away with it because - * of XNU's check in tsc.init() which effectively catches the invalid value + * of XNU's check in tsc_init() which effectively catches the invalid value * and set it to 100 MHz for Sandy Bridge CPU's (133 MHz when quad pumped). * * Note: We don't want to lose the OC feedback in GeekBench et all and that @@ -106,7 +113,7 @@ static SMBWord getFSBFrequency(void) * (for example) report 412 MHz instead of 103 MHz. */ - return (gPlatform.CPU.FSBFrequency < 100500000) ? 0 : (gPlatform.CPU.FSBFrequency / 1000000); + return 100; // (gPlatform.CPU.FSBFrequency < 100500000) ? 0 : (gPlatform.CPU.FSBFrequency / 1000000); } @@ -130,8 +137,8 @@ static SMBWord getCPUType(void) } -//============================================================================== #if OVERRIDE_DYNAMIC_MEMORY_DETECTION +//============================================================================== int getSlotNumber(int slotNumber) { @@ -150,7 +157,7 @@ int getSlotNumber(int slotNumber) } #if DEBUG_SMBIOS - // sleep(1); // Silent sleep (for debug only / slows down the process). + sleep(1); // Silent sleep (for debug only / slows down the process). #endif return slotNumber; @@ -158,8 +165,8 @@ int getSlotNumber(int slotNumber) #endif +#if STATIC_RAM_OVERRIDE_SIZE //============================================================================== -#if DYNAMIC_RAM_OVERRIDE_SIZE static SMBWord getRAMSize(void) { @@ -177,26 +184,28 @@ static SMBWord getRAMSize(void) #endif +#if STATIC_RAM_OVERRIDE_TYPE //============================================================================== -#if DYNAMIC_RAM_OVERRIDE_TYPE static SMBByte getRAMType(void) { - _SMBIOS_DEBUG_DUMP("In getRAMType() = %s\n", SMBMemoryDeviceTypes[DYNAMIC_RAM_OVERRIDE_TYPE]); +#if (DEBUG_SMBIOS == 2) + _SMBIOS_DEBUG_DUMP("In getRAMType() = %s\n", SMBMemoryDeviceTypes[STATIC_RAM_OVERRIDE_TYPE]); +#endif - return DYNAMIC_RAM_OVERRIDE_TYPE; + return STATIC_RAM_OVERRIDE_TYPE; } #endif +#if STATIC_RAM_OVERRIDE_FREQUENCY //============================================================================== -#if DYNAMIC_RAM_OVERRIDE_FREQUENCY static SMBWord getRAMFrequency(void) { - _SMBIOS_DEBUG_DUMP("In getRAMFrequency() = %d\n", DYNAMIC_RAM_OVERRIDE_FREQUENCY); + _SMBIOS_DEBUG_DUMP("In getRAMFrequency() = %d\n", STATIC_RAM_OVERRIDE_FREQUENCY); - return DYNAMIC_RAM_OVERRIDE_FREQUENCY; + return STATIC_RAM_OVERRIDE_FREQUENCY; } #endif @@ -309,6 +318,7 @@ static const char * getBIOSDate(void) size_t len = strlen(smbBIOSVersion); char biosDate[len]; + bzero(biosDate, len); strncpy(biosDate, smbBIOSVersion + (len - 8), 2); strncpy(biosDate + 2, "/", 1); @@ -316,9 +326,9 @@ static const char * getBIOSDate(void) strncpy(biosDate + 5, "/20", 3); strncpy(biosDate + 8, smbBIOSVersion + (len - 10), 2); - biosDate[10] = 0; + // biosDate[10] = 0; - _SMBIOS_DEBUG_DUMP("biosData = %s\n", biosDate); + _SMBIOS_DEBUG_DUMP("biosDate = %s\n", biosDate); _SMBIOS_DEBUG_SLEEP(5); const char * retValue = biosDate; @@ -346,3 +356,43 @@ static SMBDWord getBIOSFeaturesEX(void) { return (0x010002c1); } + +//============================================================================== + +static SMBByte getBoardType(void) +{ +#if TARGET_MODEL & MACPRO + return 0x0b; +#else + return 0x0a; +#endif +} + +//============================================================================== + +static SMBDWord getFirmwareFeatures(void) +{ + return 0xE80FE137; + /* + * With 0xE907F537 you'll get: + * + * OSInstaller[574]: ROM Features returned: 3909612855 + * OSInstaller[574]: ROM does not support APFS + * + * Note: It is bit-19 (0x80000) that adds support for APFS. + */ +} + +//============================================================================== + +static SMBDWord getFirmwareFeaturesEx(void) +{ + return 0xFFFFFFFF; +} + +//============================================================================== + +static SMBDWord getROMFeatures(void) +{ + return 0xFFFFFFFF; +} diff --git a/i386/libsaio/smbios/model_data.h b/i386/libsaio/smbios/model_data.h index bf1ce85..50f2040 100644 --- a/i386/libsaio/smbios/model_data.h +++ b/i386/libsaio/smbios/model_data.h @@ -16,41 +16,166 @@ * - Dynamic and static SMBIOS data gathering added by DHP in 2010. * - Complete rewrite / overhaul by DHP in Februari 2011. * - Coding style changes by DHP in Februari 2011. - * - Model data stripped and simplified (PikerAlpha, October 2012). - * - EFI/SMBIOS data logic moved to preprocessor code (PikerAlpha, October 2012). - * - SMB_PRODUCT_NAME renamed/moved over from settings.h (PikerAlpha, October 2012). - * - EFI_MODEL_NAME renamed/moved over from settings.h (PikerAlpha, October 2012). + * - Model data stripped and simplified (Pike R. Alpha, October 2012). + * - EFI/SMBIOS data logic moved to preprocessor code (Pike R. Alpha, October 2012). + * - SMB_PRODUCT_NAME renamed/moved over from settings.h (Pike R. Alpha, October 2012). + * - EFI_MODEL_NAME renamed/moved over from settings.h (Pike R. Alpha, October 2012). + * - Data for new MacBookPro and Macmini added (Pike R. Alpha, October 2012). + * - Data for iMac13,2 and MacBookPro9,2 added (Pike R. Alpha, October 2013). + * - Typo in SMB_BOARD_PRODUCT for iMac12,n fixed (Pike R. Alpha, April 2013). + * - Data for new iMac18,x and MacBookPro14,x added (Pike R. Alpha, June 2017). * * Credits: * - blackosx, DB1, dgsga, FKA, humph, scrax and STLVNUB (testers). + * - 4D3K for iMac12,n SMB_BOARD_PRODUCT typos. */ #if TARGET_MODEL & IMAC // 1 // ------------------------------------------------------------------------------------- - #define SMB_FAMILY "Mac" + #define SMB_FAMILY "iMac" - #if (TARGET_MODEL == IMAC_131) - // Intel Core i7-3770 @ 3.40 GHz - 4 Cores / 8 Threads. - #define SMB_BIOS_VERSION "IM131.88Z.00CE.B00.1203281326" - #define SMB_PRODUCT_NAME "iMac13,1" - #define SMB_BOARD_PRODUCT "Mac-FC02E91DDD3FA6A4" - #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '3', ',', '1' } - #elif (TARGET_MODEL == IMAC_122) - #define SMB_BIOS_VERSION "IM121.88Z.0047.B1D.1110171110" - #define SMB_PRODUCT_NAME "iMac12,2" - #define SMB_BOARD_PRODUCT "Mac-942B5BF58194151B" - #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '2', ',', '2' } - #elif (TARGET_MODEL == IMAC_111) - #define SMB_BIOS_VERSION "IM111.88Z.0034.B00.0910301727" + #if (TARGET_MODEL == IMAC_111) // 27-inch, Late 2009 + // Intel Core i5-750 @ 2.66 GHz - 4 cores / 4 threads + // Intel Core i7-860 @ 2.80 GHz - 4 cores / 8 threads + // ATI Radeon HD 4850 + #define SMB_BIOS_VERSION "IM111.88Z.0034.B12.1705021416" #define SMB_PRODUCT_NAME "iMac11,1" #define SMB_BOARD_PRODUCT "Mac-F2268DAE" #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '1', ',', '1' } - #else // Defaults to iMac12,1 - #define SMB_BIOS_VERSION "IM121.88Z.0047.B1D.1110171110" + #elif (TARGET_MODEL == IMAC_121) // 21.5-inch, Mid 2011 + // Intel Core i3-2100 @ 3.10 GHz - 2 cores / 4 threads + // Intel Core i5-2400S @ 2.50 GHz - 4 cores / 4 threads + // Intel Core i5-2500S @ 2.70 GHz - 4 cores / 4 threads + // Intel Core i7-2600S @ 2.80 GHz - 4 cores / 8 threads + // AMD Radeon HD 6750M & AMD Radeon HD 6770M + #define SMB_BIOS_VERSION "IM121.88Z.0047.B33.1705101231" #define SMB_PRODUCT_NAME "iMac12,1" - #define SMB_BOARD_PRODUCT "Mac-942B59F58194171B" + #define SMB_BOARD_PRODUCT "Mac-942B5BF58194151B" #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '2', ',', '1' } + #elif (TARGET_MODEL == IMAC_122) // 27-inch, Mid 2011 + // Intel Core i5-2400 @ 3.10 GHz - 4 cores / 4 threads + // Intel Core i5-2500S @ 2.70 GHz - 4 cores / 4 threads + // Intel Core i7-2600 @ 3.40 GHz - 4 cores / 8 threads + // AMD Radeon HD 6770M & AMD Radeon HD 6970M + #define SMB_BIOS_VERSION "IM121.88Z.0047.B33.1705101231" + #define SMB_PRODUCT_NAME "iMac12,2" + #define SMB_BOARD_PRODUCT "Mac-942B59F58194171B" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '2', ',', '2' } + #elif (TARGET_MODEL == IMAC_131) // 21.5-inch, Late 2012 + // Intel Core i5-3335S @ 2.70 GHz - 4 cores / 4 threads + // Intel Core i5-3470S @ 2.90 GHz - 4 cores / 4 threads + // Intel Core i7-3770S @ 3.10 GHz - 4 cores / 8 threads + // NVIDIA GeForce GT 640M & NVIDIA GeForce GT 650M + #define SMB_BIOS_VERSION "IM131.88Z.010A.B1C.1705011311" + #define SMB_PRODUCT_NAME "iMac13,1" + #define SMB_BOARD_PRODUCT "Mac-00BE6ED71E35EB86" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '3', ',', '1' } + #elif (TARGET_MODEL == IMAC_132) // 27-inch, Late 2012 + // Intel Core i5-3470S @ 2.9 GHz - 4 cores / 4 threads + // Intel Core i5-3470 @ 3.2 GHz - 4 cores / 4 threads + // Intel Core i7-3770 @ 3.4 GHz - 4 cores / 8 threads + // NVIDIA GeForce GTX 660M, NVIDIA GeForce GTX 675MX & NVIDIA GeForce GTX 680MX + #define SMB_BIOS_VERSION "IM131.88Z.010A.B1C.1705011311" + #define SMB_PRODUCT_NAME "iMac13,2" + #define SMB_BOARD_PRODUCT "Mac-FC02E91DDD3FA6A4" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '3', ',', '2' } + #elif (TARGET_MODEL == IMAC_133) // 21.5-inch, Early 2013 (Education) + // Intel Core i3-3225 @ 3.30 GHz - 2 cores / 4 threads + // Intel HD Graphics 4000 + #define SMB_BIOS_VERSION "IM131.88Z.010A.B1C.1705011311" + #define SMB_PRODUCT_NAME "iMac13,3" + #define SMB_BOARD_PRODUCT "Mac-7DF2A3B5E5D671ED" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '3', ',', '3' } + #elif (TARGET_MODEL == IMAC_141) // 21.5-inch, Late 2013 + // Intel Core i5-4570R @ 2.70 GHz - 4 cores / 4 threads + // Intel Iris Pro Graphics 5200 + #define SMB_BIOS_VERSION "IM141.88Z.0118.B46.1705011412" + #define SMB_PRODUCT_NAME "iMac14,1" + #define SMB_BOARD_PRODUCT "Mac-031B6874CF7F642A" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '4', ',', '1' } + #elif (TARGET_MODEL == IMAC_142) // 27-inch, Late 2013 + // Intel Core i5-4570 @ 3.20 GHz - 4 cores / 4 threads + // Intel Core i5-4670 @ 3.40 GHz - 4 cores / 4 threads + // Intel Core i7-4771 @ 3.50 GHz - 4 cores / 8 threads + // NVIDIA GeForce GT 755M, NVIDIA GeForce GTX 775M & NVIDIA GeForce GTX 780M + #define SMB_BIOS_VERSION "IM142.88Z.0118.B46.1705011513" + #define SMB_PRODUCT_NAME "iMac14,2" + #define SMB_BOARD_PRODUCT "Mac-27ADBB7B4CEE8E61" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '4', ',', '2' } + #elif (TARGET_MODEL == IMAC_143) // 21.5-inch, Late 2013 + // Intel Core i5-4570S @ 2.80 GHz - 4 cores / 4 threads + // Intel Core i7-4770S @ 3.10 GHz - 4 cores / 8 threads + // NVIDIA GeForce GT 750M + #define SMB_BIOS_VERSION "IM143.88Z.0118.B13.1602221716" + #define SMB_PRODUCT_NAME "iMac14,3" + #define SMB_BOARD_PRODUCT "Mac-77EB7D7DAF985301" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '4', ',', '3' } + #elif (TARGET_MODEL == IMAC_144) // 21.5-inch, Mid 2014 + // Intel Core i5-4260U @ 1.40 GHz - 2 cores / 4 threads + // Intel HD Graphics 5000 + #define SMB_BIOS_VERSION "IM144.88Z.0179.B30.1705011718" + #define SMB_PRODUCT_NAME "iMac14,4" + #define SMB_BOARD_PRODUCT "Mac-81E3E92DD6088272" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '4', ',', '4' } + #elif (TARGET_MODEL == IMAC_151) // Retina 5K, 27-inch, Late 2014 + // Intel Core i5-4690 @ 3.50 GHz - 4 cores / 4 threads + // Intel Core i7-4790K @ 4.00 GHz - 4 cores / 8 threads + // AMD Radeon R9 M290X, AMD Radeon R9 M295X + #define SMB_BIOS_VERSION "IM151.88Z.0207.B26.1705011718" + #define SMB_PRODUCT_NAME "iMac15,1" + #define SMB_BOARD_PRODUCT "Mac-42FD25EABCABB274" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '5', ',', '1' } + #elif (TARGET_MODEL == IMAC_152) // Retina 5K, 27-inch, Mid 2015 + // Intel Core i5-4590 @ 3.30 GHz - 4 cores / 4 threads + // AMD Radeon R9 M290 + #define SMB_BIOS_VERSION "IM151.88Z.0207.B26.1705011718" + #define SMB_PRODUCT_NAME "iMac15,2" + #define SMB_BOARD_PRODUCT "Mac-FA842E06C61E91C5" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '5', ',', '2' } + #elif (TARGET_MODEL == IMAC_161) // 21.5-inch, Late 2015 + // Intel Core i5-5250U @ 1.60 GHz - 2 cores / 4 threads + // Intel HD Graphics 6000 + #define SMB_BIOS_VERSION "IM161.88Z.0207.B19.1705011046" + #define SMB_PRODUCT_NAME "iMac16,1" + #define SMB_BOARD_PRODUCT "Mac-A369DDC4E67F1C45" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '6', ',', '1' } + #elif (TARGET_MODEL == IMAC_162) // Retina 5K, 21.5-inch, Late 2015 + // Intel Core i5-5575R @ 2.80 GHz - 4 cores / 4 threads + // Intel Core i5-5675R @ 3.10 GHz - 4 cores / 4 threads + // Intel Core i7-5775R @ 3.30 GHz - 4 cores / 8 threads + // Intel Iris Pro Graphics 6200 + #define SMB_BIOS_VERSION "IM162.88Z.0206.B19.1705011413" + #define SMB_PRODUCT_NAME "iMac16,2" + #define SMB_BOARD_PRODUCT "Mac-FFE5EF870D7BA81A" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '6', ',', '2' } + #elif (TARGET_MODEL == IMAC_171) // (Retina 5K, 27-inch, Late 2015) + // Intel Core i5-6500 @ 3.20 GHz - 4 cores / 4 threads + // AMD Radeon R9 M380 + #define SMB_BIOS_VERSION "IM171.88Z.0105.B25.1704292104" + #define SMB_PRODUCT_NAME "iMac17,1" + #define SMB_BOARD_PRODUCT "Mac-65CE76090165799A" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '7', ',', '1' } + #elif (TARGET_MODEL == IMAC_181) // Retina 5K, 27-inch, 2017 + #define SMB_BIOS_VERSION "IM181.88Z.0145.B07.1705082121" + #define SMB_PRODUCT_NAME "iMac18,1" + #define SMB_BOARD_PRODUCT "Mac-4B682C642B45593E" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '8', ',', '1' } + #elif (TARGET_MODEL == IMAC_182) // Retina 5K, 27-inch, 2017 + #define SMB_BIOS_VERSION "IM182.88Z.0145.B07.1705082121" + #define SMB_PRODUCT_NAME "iMac18,2" + #define SMB_BOARD_PRODUCT "Mac-77F17D7DA9285301" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '8', ',', '2' } + #elif (TARGET_MODEL == IMAC_183) // Defaults to iMac18,3 Retina 5K, 27-inch, 2017 + #define SMB_BIOS_VERSION "IM183.88Z.0145.B07.1705082121" + #define SMB_PRODUCT_NAME "iMac18,3" + #define SMB_BOARD_PRODUCT "Mac-BE088AF8C5EB4FA2" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '8', ',', '3' } + #else // Defaults to iMac19,1 Retina 5K, 27-inch, 2017 + #define SMB_BIOS_VERSION "IM191.88Z.0058.B00.1708081711" + #define SMB_PRODUCT_NAME "iMac19,1" + #define SMB_BOARD_PRODUCT "Mac-CF21D135A7D34AA6" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', '1', '9', ',', '1' } #endif // ------------------------------------------------------------------------------------- #endif @@ -60,10 +185,28 @@ // ------------------------------------------------------------------------------------- #define SMB_FAMILY "MacBook" - #define SMB_BIOS_VERSION "MB41.88Z.0073.B00.0809221748" - #define SMB_PRODUCT_NAME "MacBook4,1" - #define SMB_BOARD_PRODUCT "Mac-F42D89C8" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', '4', ',', '1' } + #if (TARGET_MODEL == MACBOOK_41) + #define SMB_BIOS_VERSION "MB41.88Z.0073.B00.0809221748" + #define SMB_PRODUCT_NAME "MacBook4,1" + #define SMB_BOARD_PRODUCT "Mac-F42D89C8" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', '4', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_81) + // Intel Core M-5Y31 @ 1.10 GHz (2 cores, 4 threads) + // Intel Core M-5Y51 @ 1.20 GHz (2 cores, 4 threads) + // Intel Core M-5Y71 @ 1.30 GHz (2 cores, 4 threads) + #define SMB_BIOS_VERSION "MB81.88Z.0164.B18.1608121416" + #define SMB_PRODUCT_NAME "MacBook8,1" + #define SMB_BOARD_PRODUCT "Mac-BE0E8AC46FE800CC" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', '8', ',', '1' } + #else // Defaults to MacBook9,1 + // Intel Core m3-6Y30 @ 1.10 GHz (2 cores, 4 threads) + // Intel Core m5-6Y54 @ 1.20 GHz (2 cores, 4 threads) + // Intel Core m7-6Y75 @ 1.30 GHz (2 cores, 4 threads) + #define SMB_BIOS_VERSION "MB91.88Z.0154.B04.1604191425" + #define SMB_PRODUCT_NAME "MacBook9,1" + #define SMB_BOARD_PRODUCT "Mac-9AE82516C7C6B903" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', '9', ',', '1' } + #endif // ------------------------------------------------------------------------------------- #endif @@ -72,20 +215,61 @@ // ------------------------------------------------------------------------------------- #define SMB_FAMILY "MacBookAir" - #if (TARGET_MODEL == MACBOOK_AIR_42) - // Intel Core i5-2557M @ 1.7GHz (2 cores - 4 threads) - // Intel Core i7-2677M @ 1.8GHz (2 cores - 4 threads) - #define SMB_BIOS_VERSION "MBA41.88Z.0077.B08.1109011050" - #define SMB_PRODUCT_NAME "MacBookAir4,2" - #define SMB_BOARD_PRODUCT "Mac-742912EFDBEE19B3" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'A', 'i', 'r', '4', ',', '2' } - #else // Defaults to MacBookAir4,1 + #if (TARGET_MODEL == MACBOOK_AIR_41) // Intel Core i5-2467M @ 1.6GHz (2 cores - 4 threads) // Intel Core i7-2677M @ 1.8GHz (2 cores - 4 threads) - #define SMB_BIOS_VERSION "MBA41.88Z.0077.B08.1109011050" + #define SMB_BIOS_VERSION "MBA41.88Z.0077.B14.1510261805" #define SMB_PRODUCT_NAME "MacBookAir4,1" #define SMB_BOARD_PRODUCT "Mac-C08A6BB70A942AC2" #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'A', 'i', 'r', '4', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_AIR_42) + // Intel Core i5-2557M @ 1.7GHz (2 cores - 4 threads) + // Intel Core i7-2677M @ 1.8GHz (2 cores - 4 threads) + #define SMB_BIOS_VERSION "MBA41.88Z.0077.B14.1510261805" + #define SMB_PRODUCT_NAME "MacBookAir4,2" + #define SMB_BOARD_PRODUCT "Mac-742912EFDBEE19B3" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'A', 'i', 'r', '4', ',', '2' } + #elif (TARGET_MODEL == MACBOOK_AIR_51) + // Intel Core i5-3317U @ 1.7GHz (2 cores - 4 threads) + // Intel Core i7-3667U @ 2.0GHz (2 cores - 4 threads) + #define SMB_BIOS_VERSION "MBA51.88Z.00EF.B04.1509111654" + #define SMB_PRODUCT_NAME "MacBookAir5,1" + #define SMB_BOARD_PRODUCT "Mac-66F35F19FE2A0D05" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'A', 'i', 'r', '5', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_AIR_52) + // Intel Core i5-3317U @ 1.7GHz (2 cores - 4 threads) + // Intel Core i7-3667U @ 2.0GHz (2 cores - 4 threads) + #define SMB_BIOS_VERSION "MBA51.88Z.00EF.B04.1509111654" + #define SMB_PRODUCT_NAME "MacBookAir5,2" + #define SMB_BOARD_PRODUCT "Mac-2E6FAB96566FE58C" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'A', 'i', 'r', '5', ',', '2' } + #elif (TARGET_MODEL == MACBOOK_AIR_61) + // Intel Core i5-3427U @ 1.8GHz (2 cores - 4 threads) + // Intel Core i7-4650U @ 1.7GHz (2 cores - 4 threads) + #define SMB_BIOS_VERSION "MBA61.88Z.0099.B22.1602221559" + #define SMB_PRODUCT_NAME "MacBookAir6,1" + #define SMB_BOARD_PRODUCT "Mac-35C1E88140C3E6CF" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'A', 'i', 'r', '6', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_AIR_62) + // Intel Core i5-4250U @ 1.30 GHz (2 cores - 4 threads) + // Intel Core i7-4650U @ 1.70 GHz (2 cores - 4 threads) + #define SMB_BIOS_VERSION "MBA61.88Z.0099.B22.1602221559" + #define SMB_PRODUCT_NAME "MacBookAir6,2" + #define SMB_BOARD_PRODUCT "Mac-7DF21CB3ED6977E5" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'A', 'i', 'r', '6', ',', '2' } + #elif (TARGET_MODEL == MACBOOK_AIR_71) + // Intel Core i5-5250U @ 1.60 GHz (2 cores - 4 threads) + #define SMB_BIOS_VERSION "MBA71.88Z.0166.B12.1602221953" + #define SMB_PRODUCT_NAME "MacBookAir7,1" + #define SMB_BOARD_PRODUCT "Mac-9F18E312C5C2BF0B" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'A', 'i', 'r', '7', ',', '1' } + #else // Defaults to MacBookAir7,2 + // Intel Core i5-5250U @ 1.60 GHz (2 cores - 4 threads) + // Intel Core i7-5650U @ 2.20 GHz (2 cores - 4 threads) + #define SMB_BIOS_VERSION "MBA71.88Z.0166.B12.1602221953" + #define SMB_PRODUCT_NAME "MacBookAir7,2" + #define SMB_BOARD_PRODUCT "Mac-937CB26E2E02BB01" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'A', 'i', 'r', '7', ',', '2' } #endif // ------------------------------------------------------------------------------------- #endif @@ -95,38 +279,148 @@ // ------------------------------------------------------------------------------------- #define SMB_FAMILY "MacBookPro" - #if (TARGET_MODEL == MACBOOK_PRO_101) - // Intel Core i7-3720QM @ 2.60 GHz - 4 cores / 8 threads. - #define SMB_BIOS_VERSION "MBP101.88Z.00EE.B00.1205101839" - #define SMB_PRODUCT_NAME "MacBookPro10,1" - #define SMB_BOARD_PRODUCT "Mac-C3EC7CD22292981F" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '0', ',', '1' } - #elif (TARGET_MODEL == MACBOOK_PRO_91) - // Intel Core i7-3820QM @ 2.70 GHz - 4 cores / 8 threads. - #define SMB_BIOS_VERSION "MBP91.88Z.00D3.B00.1203211536" - #define SMB_PRODUCT_NAME "MacBookPro9,1" - #define SMB_BOARD_PRODUCT "Mac-4B7AC7E43945597E" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '9', ',', '1' } - #elif (TARGET_MODEL == MACBOOK_PRO_83) - #define SMB_BIOS_VERSION "MBP81.88Z.0047.B24.1110141131" - #define SMB_PRODUCT_NAME "MacBookPro8,3" - #define SMB_BOARD_PRODUCT "Mac-942459F5819B171B" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '8', ',', '3' } - #elif (TARGET_MODEL == MACBOOK_PRO_82) - #define SMB_BIOS_VERSION "MBP81.88Z.0047.B24.1110141131" - #define SMB_PRODUCT_NAME "MacBookPro8,2" - #define SMB_BOARD_PRODUCT "Mac-94245A3940C91C80" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '8', ',', '2' } + #if(TARGET_MODEL == MACBOOK_PRO_61) + #define SMB_BIOS_VERSION "MBP61.88Z.0057.B11.1509232013" + #define SMB_PRODUCT_NAME "MacBookPro6,1" + #define SMB_BOARD_PRODUCT "Mac-F22589C8" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '6', ',', '1' } #elif (TARGET_MODEL == MACBOOK_PRO_81) - #define SMB_BIOS_VERSION "MBP81.88Z.0047.B24.1110141131" + #define SMB_BIOS_VERSION "MBP81.88Z.0047.B2C.1510261540" #define SMB_PRODUCT_NAME "MacBookPro8,1" #define SMB_BOARD_PRODUCT "Mac-94245B3640C91C81" #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '8', ',', '1' } - #else (TARGET_MODEL == MACBOOK_PRO_61) - #define SMB_BIOS_VERSION "MBP61.88Z.0057.B0C.1007261552" - #define SMB_PRODUCT_NAME "MacBookPro6,1" - #define SMB_BOARD_PRODUCT "Mac-F22589C8" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '6', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_PRO_82) + #define SMB_BIOS_VERSION "MBP81.88Z.0047.B2C.1510261540" + #define SMB_PRODUCT_NAME "MacBookPro8,2" + #define SMB_BOARD_PRODUCT "Mac-94245A3940C91C80" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '8', ',', '2' } + #elif (TARGET_MODEL == MACBOOK_PRO_83) + #define SMB_BIOS_VERSION "MBP81.88Z.0047.B2C.1510261540" + #define SMB_PRODUCT_NAME "MacBookPro8,3" + #define SMB_BOARD_PRODUCT "Mac-942459F5819B171B" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '8', ',', '3' } + #elif (TARGET_MODEL == MACBOOK_PRO_91) + // Intel Core i7-3820QM @ 2.70 GHz - 4 cores / 8 threads. + #define SMB_BIOS_VERSION "MBP91.88Z.00D3.B0D.1602221713" + #define SMB_PRODUCT_NAME "MacBookPro9,1" + #define SMB_BOARD_PRODUCT "Mac-4B7AC7E43945597E" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '9', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_PRO_92) + // Intel Core i7-3820QM @ 2.70 GHz - 4 cores / 8 threads. + #define SMB_BIOS_VERSION "MBP91.88Z.00D3.B0D.1602221713" + #define SMB_PRODUCT_NAME "MacBookPro9,2" + #define SMB_BOARD_PRODUCT "Mac-6F01561E16C75D06" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '9', ',', '2' } + #elif (TARGET_MODEL == MACBOOK_PRO_101) + // Intel Core i7-3635QM @ 2.40 GHz - 4 cores / 8 threads. + // Intel Core i7-3740QM @ 2.70 GHz - 4 cores / 8 threads. + // Intel Core i7-3840QM @ 2.80 GHz - 4 cores / 8 threads. + #define SMB_BIOS_VERSION "MBP101.88Z.00EE.B0A.1509111559" + #define SMB_PRODUCT_NAME "MacBookPro10,1" + #define SMB_BOARD_PRODUCT "Mac-C3EC7CD22292981F" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '0', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_PRO_102) + // Intel Core i5-3230QM @ 2.60 GHz - 2 cores / 4 threads. + // Intel Core i7-3540QM @ 3.00 GHz - 2 cores / 4 threads. + #define SMB_BIOS_VERSION "MBP102.88Z.0106.B0A.1509130955" + #define SMB_PRODUCT_NAME "MacBookPro10,2" + #define SMB_BOARD_PRODUCT "Mac-AFD8A9D944EA4843" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '0', ',', '2' } + #elif (TARGET_MODEL == MACBOOK_PRO_111) + // Intel Core i5-4258U @ 2.40 GHz - 2 cores / 4 threads. + // Intel Core i5-4288U @ 2.60 GHz - 2 cores / 4 threads. + // Intel Core i7-4558U @ 2.80 GHz - 2 cores / 4 threads. + #define SMB_BIOS_VERSION "MBP111.88Z.0138.B17.1602221718" + #define SMB_PRODUCT_NAME "MacBookPro11,1" + #define SMB_BOARD_PRODUCT "Mac-189A3D4F975D5FFC" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '1', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_PRO_112) + // Intel Core i7-4750HQ @ 2.00 GHz - 4 cores / 8 threads. + // Intel Core i7-4950HQ @ 2.40 GHz - 4 cores / 8 threads. + #define SMB_BIOS_VERSION "MBP112.88Z.0138.B17.1602221600" + #define SMB_PRODUCT_NAME "MacBookPro11,2" + #define SMB_BOARD_PRODUCT "Mac-3CBD00234E554E41" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '1', ',', '2' } + #elif (TARGET_MODEL == MACBOOK_PRO_113) + // Intel Core i7-4850HQ @ 2.30 GHz - 4 cores / 8 threads. + // Intel Core i7-4960HQ @ 2.60 GHz - 4 cores / 8 threads. + #define SMB_BIOS_VERSION "MBP112.88Z.0138.B17.1602221600" + #define SMB_PRODUCT_NAME "MacBookPro11,3" + #define SMB_BOARD_PRODUCT "Mac-2BD1B31983FE1663" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '1', ',', '3' } + #elif (TARGET_MODEL == MACBOOK_PRO_114) + // Intel Core i7-4770HQ @ 2.20 GHz - 4 cores / 8 threads. + // Intel Core i7-4870HQ @ 2.50 GHz - 4 cores / 8 threads. + // Intel Core i7-4980HQ @ 2.80 GHz - 4 cores / 8 threads. + #define SMB_BIOS_VERSION "MBP114.88Z.0172.B09.1602151732" + #define SMB_PRODUCT_NAME "MacBookPro11,3" + #define SMB_BOARD_PRODUCT "Mac-06F11FD93F0323C5" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '1', ',', '4' } + #elif (TARGET_MODEL == MACBOOK_PRO_115) + // Intel Core i7-4870HQ @ 2.50 GHz - 4 cores / 8 threads. + // Intel Core i7-4980HQ @ 2.80 GHz - 4 cores / 8 threads. + #define SMB_BIOS_VERSION "MBP114.88Z.0172.B09.1602151732" + #define SMB_PRODUCT_NAME "MacBookPro11,5" + #define SMB_BOARD_PRODUCT "Mac-06F11F11946D27C5" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '1', ',', '5' } + #elif (TARGET_MODEL == MACBOOK_PRO_121) + // Intel Core i5-5257U @ 2.70 GHz - 2 cores / 4 threads. + #define SMB_BIOS_VERSION "MBP121.88Z.0167.B16.1602111810" + #define SMB_PRODUCT_NAME "MacBookPro12,1" + #define SMB_BOARD_PRODUCT "Mac-E43C1C25D4880AD6" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '2', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_PRO_131) + // 13-inch without Touch Bar / Touch ID + // Intel Core i5-6360U 2.0 GHz (max Turbo Boost 3.1 GHz) + // Intel Core i7-6660U 2.4 GHz (max Turbo Boost 3.4 GHz) + #define SMB_BIOS_VERSION "MBP131.88Z.0205.B02.1610121536" + #define SMB_PRODUCT_NAME "MacBookPro13,1" + #define SMB_BOARD_PRODUCT "Mac-473D31EABEB93F9B" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '3', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_PRO_132) + // 13-inch with Touch Bar / Touch ID + // Intel Core i5-6267U 2.9 GHz (max Turbo Boost 3.3 GHz) + // Intel Core i5-6287U 3.1 GHz (max Turbo Boost 3.5 GHz) + // Intel Core i7-6567U 3.3 GHz (max Turbo Boost 3.6 GHz) + #define SMB_BIOS_VERSION "MBP132.88Z.0223.B00.1610201042" + #define SMB_PRODUCT_NAME "MacBookPro13,2" + #define SMB_BOARD_PRODUCT "Mac-66E35819EE2D0D05" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '3', ',', '2' } + #elif (TARGET_MODEL == MACBOOK_PRO_133) + // 15-inch with Touch Bar / Touch ID + // Intel Core i7-6700HQ 2.6 GHz (max Turbo Boost 3.5 GHz) + // Intel Core i7-6820HQ 2.7 GHz (max Turbo Boost 3.6 GHz) + // Intel Core i7-6920HQ 2.9 GHz (max Turbo Boost 3.8 GHz) + #define SMB_BIOS_VERSION "MBP133.88Z.0223.B00.1610201042" + #define SMB_PRODUCT_NAME "MacBookPro13,3" + #define SMB_BOARD_PRODUCT "Mac-A5C67F76ED83108C" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '3', ',', '3' } + #elif (TARGET_MODEL == MACBOOK_PRO_141) + // 13-inch without Touch Bar / Touch ID + // Intel Core i5-7360U 2.3 GHz (max Turbo Boost 3.6 GHz) + // Intel Core i7-7660U 2.5 GHz (max Turbo Boost 4.0 GHz) + #define SMB_BIOS_VERSION "MBP141.88Z.0160.B00.1705082121" + #define SMB_PRODUCT_NAME "MacBookPro14,1" + #define SMB_BOARD_PRODUCT "Mac-B4831CEBD52A0C4C" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '4', ',', '1' } + #elif (TARGET_MODEL == MACBOOK_PRO_142) + // 13-inch with Touch Bar / Touch ID + // Intel Core i5-7267U 3.1 GHz (max Turbo Boost 3.5 GHz) + // Intel Core i5-7287U 3.3 GHz (max Turbo Boost 3.7 GHz) + // Intel Core i7-7567U 3.5 GHz (max Turbo Boost 4.0 GHz) + #define SMB_BIOS_VERSION "MBP142.88Z.0160.B00.1705082121" + #define SMB_PRODUCT_NAME "MacBookPro14,2" + #define SMB_BOARD_PRODUCT "Mac-CAD6701F7CEA0921 " + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '4', ',', '2' } + #else // Defaults to MacBookPro14,3 + // 15-inch with Touch Bar / Touch ID + // Intel Core i7-7700HQ 2.8 GHz (max Turbo Boost 3.8 GHz) + // Intel Core i7-7820HQ 2.9 GHz (max Turbo Boost 3.9 GHz) + // Intel Core i7-7920HQ 3.1 GHz (max Turbo Boost 4.1 GHz) + #define SMB_BIOS_VERSION "MBP143.88Z.0160.B00.1705090111" + #define SMB_PRODUCT_NAME "MacBookPro14,3" + #define SMB_BOARD_PRODUCT "Mac-551B86E5744E2388" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'B', 'o', 'o', 'k', 'P', 'r', 'o', '1', '4', ',', '3' } #endif // ------------------------------------------------------------------------------------- #endif @@ -136,24 +430,47 @@ // ------------------------------------------------------------------------------------- #define SMB_FAMILY "Macmini" - #if (TARGET_MODEL == MACMINI_53) - // Intel Core i7-2635QM @ 2.0GHz (4 cores - 8 threads) - #define SMB_BIOS_VERSION "MM51.88Z.0077.B10.1201241549" - #define SMB_PRODUCT_NAME "Macmini5,3" - #define SMB_BOARD_PRODUCT "Mac-7BA5B2794B2CDB12" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'm', 'i', 'n', 'i', '5', ',', '3' } + #if (TARGET_MODEL == MACMINI_41) + // Intel Core P8800 @ 2.4/2.66 GHz (2 cores - 2 threads) + #define SMB_BIOS_VERSION "MM41.88Z.0042.B03.1111072100" + #define SMB_PRODUCT_NAME "Macmini4,1" + #define SMB_BOARD_PRODUCT "Mac-F2208EC8" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'm', 'i', 'n', 'i', '4', ',', '1' } + #elif (TARGET_MODEL == MACMINI_51) + // Intel Core i5-2415M @ 2.3 GHz (2 cores - 4 threads) + #define SMB_BIOS_VERSION "MM51.88Z.0077.B14.1510261805" + #define SMB_PRODUCT_NAME "Macmini5,1" + #define SMB_BOARD_PRODUCT "Mac-8ED6AF5B48C039E1" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'm', 'i', 'n', 'i', '5', ',', '1' } #elif (TARGET_MODEL == MACMINI_52) // Intel Core i5-2520M @ 2.5GHz (2 cores - 4 threads) - #define SMB_BIOS_VERSION "MM51.88Z.0077.B10.1201241549" + #define SMB_BIOS_VERSION "MM51.88Z.0077.B14.1510261805" #define SMB_PRODUCT_NAME "Macmini5,2" #define SMB_BOARD_PRODUCT "Mac-4BC72D62AD45599E" #define EFI_MODEL_NAME { 'M', 'a', 'c', 'm', 'i', 'n', 'i', '5', ',', '2' } - #else // Defaults to Macmini5,1 - // Intel Core i5-2415M @ 2.3 GHz (2 cores - 4 theeads) - #define SMB_BIOS_VERSION "MM51.88Z.0077.B10.1201241549" - #define SMB_PRODUCT_NAME "Macmini5,1" - #define SMB_BOARD_PRODUCT "Mac-8ED6AF5B48C039E1" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'm', 'i', 'n', 'i', '5', ',', '1' } + #elif (TARGET_MODEL == MACMINI_53) + // Intel Core i7-2635QM @ 2.0GHz (4 cores - 8 threads) + #define SMB_BIOS_VERSION "MM51.88Z.0077.B14.1510261805" + #define SMB_PRODUCT_NAME "Macmini5,3" + #define SMB_BOARD_PRODUCT "Mac-7BA5B2794B2CDB12" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'm', 'i', 'n', 'i', '5', ',', '3' } + #elif (TARGET_MODEL == MACMINI_61) + // Intel Core i5-3210M @ 2.50 GH (2 cores - 4 theeads) + #define SMB_BIOS_VERSION "MM61.88Z.0106.B0A.1509111654" + #define SMB_PRODUCT_NAME "Macmini6,1" + #define SMB_BOARD_PRODUCT "Mac-031AEE4D24BFF0B1" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'm', 'i', 'n', 'i', '6', ',', '1' } + #elif (TARGET_MODEL == MACMINI_62) + // Intel Core i7-3615QM @ 2.30 GHz (4 cores - 8 threads) + #define SMB_BIOS_VERSION "MM61.88Z.0106.B0A.1509111654" + #define SMB_PRODUCT_NAME "Macmini6,2" + #define SMB_BOARD_PRODUCT "Mac-F65AE981FFA204ED" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'm', 'i', 'n', 'i', '6', ',', '2' } + #else // Defaults to Macmini7,1 + #define SMB_BIOS_VERSION "MM71.88Z.0220.B07.1602221546" + #define SMB_PRODUCT_NAME "Macmini7,1" + #define SMB_BOARD_PRODUCT "Mac-35C5E08120C7EEAF" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'm', 'i', 'n', 'i', '7', ',', '1' } #endif // ------------------------------------------------------------------------------------- #endif @@ -163,21 +480,39 @@ // ------------------------------------------------------------------------------------- #define SMB_FAMILY "MacPro" - #if (TARGET_MODEL == MACPRO_51) - #define SMB_BIOS_VERSION "MP51.88Z.007F.B03.1010071432" - #define SMB_PRODUCT_NAME "MacPro5,1" - #define SMB_BOARD_PRODUCT "Mac-F221BEC8" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'P', 'r', 'o', '5', ',', '1' } - #elif (TARGET_MODEL == MACPRO_41) - #define SMB_BIOS_VERSION "MP41.88Z.0081.B04.0903051113" - #define SMB_PRODUCT_NAME "MacPro4,1" - #define SMB_BOARD_PRODUCT "Mac-F221BEC8" - #define EFI_MODEL_NAME { 'M', 'a', 'c', 'P', 'r', 'o', '4', ',', '1' } - #else // Defaults to MacPro3,1 + #if (TARGET_MODEL == MACPRO_31) #define SMB_BIOS_VERSION "MP31.88Z.006C.B05.0802291410" #define SMB_PRODUCT_NAME "MacPro3,1" #define SMB_BOARD_PRODUCT "Mac-F4208DC8" #define EFI_MODEL_NAME { 'M', 'a', 'c', 'P', 'r', 'o', '3', ',', '1' } + #elif (TARGET_MODEL == MACPRO_41) + #define SMB_BIOS_VERSION "MP41.88Z.0081.B08.1001221313" + #define SMB_PRODUCT_NAME "MacPro4,1" + #define SMB_BOARD_PRODUCT "Mac-F221BEC8" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'P', 'r', 'o', '4', ',', '1' } + #elif (TARGET_MODEL == MACPRO_51) + #define SMB_BIOS_VERSION "MP51.88Z.007F.B03.1010071432" + #define SMB_PRODUCT_NAME "MacPro5,1" + #define SMB_BOARD_PRODUCT "Mac-F221BEC8" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'P', 'r', 'o', '5', ',', '1' } + #else // Defaults to MacPro6,1 + #define SMB_BIOS_VERSION "MP61.88Z.0116.B20.1610051057" + #define SMB_PRODUCT_NAME "MacPro6,1" + #define SMB_BOARD_PRODUCT "Mac-F60DEB81FF30ACF6" + #define EFI_MODEL_NAME { 'M', 'a', 'c', 'P', 'r', 'o', '6', ',', '1' } + #endif +// ------------------------------------------------------------------------------------- +#endif + +#if TARGET_MODEL & IMACPRO // 64 +// ------------------------------------------------------------------------------------- + #define SMB_FAMILY "iMacPro" + + #if (TARGET_MODEL == IMACPRO_10) + #define SMB_BIOS_VERSION "IMP10.88Z.0058.B00.1705091711" + #define SMB_PRODUCT_NAME "iMacPro1,1" + #define SMB_BOARD_PRODUCT "Mac-CF21D135A7D34AA6" + #define EFI_MODEL_NAME { 'i', 'M', 'a', 'c', 'P', 'r', 'o', '1', ',', '0' } #endif // ------------------------------------------------------------------------------------- #endif diff --git a/i386/libsaio/smbios/smbios.h b/i386/libsaio/smbios/smbios.h index 121f433..c28c1b0 100755 --- a/i386/libsaio/smbios/smbios.h +++ b/i386/libsaio/smbios/smbios.h @@ -95,9 +95,11 @@ enum { kSMBTypeMemoryModule = 6, kSMBTypeCacheInformation = 7, kSMBTypeSystemSlot = 9, + kSMBTypeOemStrings = 11, kSMBTypePhysicalMemoryArray = 16, kSMBTypeMemoryDevice = 17, kSMBType32BitMemoryErrorInfo = 18, + kSMBTypeMemoryArrayMappedAddress = 19, kSMBType64BitMemoryErrorInfo = 33, kSMBTypeEndOfTable = 127, @@ -107,8 +109,10 @@ enum { kSMBTypeMemorySPD = 130, kSMBTypeOemProcessorType = 131, kSMBTypeOemProcessorBusSpeed = 132, + kSMBTypeOemPlatformFeature = 133, + kSMBTypeOemSMCVersion = 134, - // Structures dropped by Revolution. + // Structures dropped by RevoBoot. kSMBUnused = 255 }; @@ -134,13 +138,16 @@ typedef struct SMBSystemInformation { // 2.0+ spec (8 bytes) SMB_STRUCT_HEADER // Type 1 - SMBString manufacturer; - SMBString productName; - SMBString version; - SMBString serialNumber; + SMBString manufacturer; + SMBString productName; + SMBString version; + SMBString serialNumber; // 2.1+ spec (25 bytes) - SMBByte uuid[16]; // can be all 0 or all 1's - SMBByte wakeupReason; // reason for system wakeup + SMBByte uuid[16]; // can be all 0 or all 1's + SMBByte wakeupReason; // reason for system wakeup + // 2.4+ spec (27 bytes) + SMBString SKUNumber; // System SKU# + SMBString family; // Mac, Macmini etc } __attribute__((packed)) SMBSystemInformation; // @@ -306,13 +313,12 @@ typedef struct SMBSystemSlot // // OEM Strings - Type 11 (AppleSMBIOS-43) // +// Note: Used to add IODeviceTree:/rom@0/apple-rom-version (Data) +// typedef struct SMBOemStrings { - SMB_STRUCT_HEADER - SMBByte type; - SMBByte length; - SMBWord handle; + SMB_STRUCT_HEADER // Length is a fixed value (5) SMBByte count; } __attribute__((packed)) SMBOemStrings; @@ -385,6 +391,26 @@ typedef struct SMBMemoryDevice SMBByte attributes; } __attribute__((packed)) SMBMemoryDevice; +/// +/// Memory Array Mapped Address (Type 19). +/// +/// This structure provides the address mapping for a Physical Memory Array. +/// One structure is present for each contiguous address range described. +/// +typedef struct SMBMemoryArrayMappedAddress +{ + SMB_STRUCT_HEADER // Type 19 + SMBDWord StartingAddress; + SMBDWord EndingAddress; + SMBWord MemoryArrayHandle; + SMBByte PartitionWidth; + // + // Added for SMBIOS v2.7 + // + // SMBQWord ExtendedStartingAddress; + // SMBQWord ExtendedEndingAddress; +} __attribute__((packed)) SMBMemoryArrayMappedAddress; + // // Firmware Volume Description (Apple Specific - Type 128) // @@ -409,7 +435,7 @@ typedef struct FW_REGION_INFO typedef struct SMBFirmwareVolume { - SMB_STRUCT_HEADER // Type 128 + SMB_STRUCT_HEADER // Type 0x80/128 SMBByte RegionCount; SMBByte Reserved[3]; SMBDWord FirmwareFeatures; @@ -424,7 +450,7 @@ typedef struct SMBFirmwareVolume typedef struct SMBMemorySPD { - SMB_STRUCT_HEADER // Type 130 + SMB_STRUCT_HEADER // Type 0x82/130 SMBWord Type17Handle; SMBWord Offset; SMBWord Size; @@ -432,7 +458,7 @@ typedef struct SMBMemorySPD } __attribute__((packed)) SMBMemorySPD; -#if DEBUG_SMBIOS +#if (DEBUG_SMBIOS == 4) static const char * SMBMemoryDeviceTypes[] = { "RAM", /* 00h Undefined */ @@ -456,10 +482,16 @@ static const char * SMBMemoryDeviceTypes[] = "DDR SDRAM", /* 12h DDR */ "DDR2 SDRAM", /* 13h DDR2 */ "DDR2 FB-DIMM", /* 14h DDR2 FB-DIMM */ - "RAM", /* 15h unused */ - "RAM", /* 16h unused */ - "RAM", /* 17h unused */ + "RESERVED", /* 15h Reserved */ + "RESERVED", /* 16h Reserved */ + "RESERVED", /* 17h Reserved */ "DDR3", /* 18h DDR3, chosen in [5776134] */ + "FBD2", /* 19h FBD2 */ + "DDR4", /* 1Ah DDR4 */ + "LPDDR", /* 1Bh LPDDR */ + "LPDDR2", /* 1Ch LPDDR2 */ + "LPDDR3", /* 1Dh LPDDR3 */ + "LPDDR3", /* 1Eh LPDDR5 */ }; static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) / sizeof(SMBMemoryDeviceTypes[0]); @@ -467,31 +499,40 @@ static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) / size // -// OEM Processor Type (Apple Specific - Type 131) +// OEM – Apple Processor Type (type 0x83/131) // struct SMBOemProcessorType { SMB_STRUCT_HEADER - SMBWord ProcessorType; + SMBWord ProcessorType; } __attribute__((packed)) SMBOemProcessorType; // -// OEM Processor Bus Speed (Apple Specific - Type 132) +// OEM – Apple Processor Bus Speed (type 0x84/132) // struct SMBOemProcessorBusSpeed { SMB_STRUCT_HEADER - SMBWord ProcessorBusSpeed; // MT/s unit + SMBWord ProcessorBusSpeed; // MT/s unit } __attribute__((packed)) SMBOemProcessorBusSpeed; // -// OEM Platform Feature (Apple Specific - Type 133 / AppleSMBIOS-43) +// OEM – Apple Platform Features (type 0x85/133 / AppleSMBIOS-43) // struct SMBOemPlatformFeature { SMB_STRUCT_HEADER - SMBWord PlatformFeature; + SMBWord PlatformFeature; } __attribute__((packed)) SMBOemPlatformFeature; + +// +// OEM – Apple SMC Version (type 0x86/134) +// +struct SMBOemSMCVersion +{ + SMB_STRUCT_HEADER + SMBString SMCVersion; +} __attribute__((packed)) SMBOemSMCVersion; diff --git a/i386/libsaio/smbios/static_data.h b/i386/libsaio/smbios/static_data.h index 5cf2938..4f39f51 100755 --- a/i386/libsaio/smbios/static_data.h +++ b/i386/libsaio/smbios/static_data.h @@ -3,6 +3,11 @@ * * Updates: * - Dynamic and static SMBIOS data gathering added by DHP in 2010. + * - New path for static EFI data (PikerAlpha, October 2012). + * - Optionally check /Extra/SMBIOS/[MacModelNN.bin] for static SMBIOS data (PikerAlpha, October 2012). + * - Get maxStructureSize/structureCount from factory EPS (PikerAlpha, October 2012). + * - Cleanups/simplification of code (Pike, April 2013). + * - iMessage fix for static SMBIOS data / init gPlatform.UUID from static data (Pike, April 2013). * * Credits: * - blackosx, DB1, dgsga, FKA, humph, scrax and STLVNUB (testers). @@ -13,12 +18,67 @@ #include "essentials.h" -#define INCLUDE_SMBIOS_DATA 1 -#include "../../config/data.h" +int offset = 0; +int tableLength = 0; -static uint32_t SMBIOS_Table[] = -{ - STATIC_SMBIOS_DATA // Will get replaced with the data from: config/smbios/data.h -}; +long fileSize = 0L; + +void * staticSMBIOSData = (void *)kLoadAddr; + +#if LOAD_MODEL_SPECIFIC_SMBIOS_DATA + char dirSpec[32] = ""; + + sprintf(dirSpec, "/Extra/SMBIOS/%s.bin", COMMA_STRIPPED_MODEL_ID); + _SMBIOS_DEBUG_DUMP("Loading: %s", dirSpec); + fileSize = loadBinaryData(dirSpec, &staticSMBIOSData); + + if (fileSize > 0) + { + tableLength = fileSize; + _SMBIOS_DEBUG_DUMP("\n"); + } + else // File not found. Use static data defined in: RevoBoot/i386/config/SMBIOS/MacModelNN.h + { + _SMBIOS_DEBUG_DUMP("Error: File not found!\n"); + } +#endif /* LOAD_MODEL_SPECIFIC_SMBIOS_DATA */ + + if (fileSize == 0) + { + // The STRING (macro) is defined in RevoBoot/i386/config/settings.h + #include STRING(SMBIOS_DATA_FILE) + + static uint32_t SMBIOS_Table[] = + { + // Replaced with data from: RevoBoot/i386/config/SMBIOS/MacModelNN.h + STATIC_SMBIOS_DATA + }; + + tableLength = sizeof(SMBIOS_Table); + staticSMBIOSData = SMBIOS_Table; + _SMBIOS_DEBUG_DUMP("Using statically linked SMBIOS data: %d bytes\n", tableLength); + } + + if (*(uint32_t *) staticSMBIOSData == 0x44495555) // "UUID" in little endian. + { + offset = 20; // "UUID" + 16 bytes data + } + + // Copy the static SMBIOS data into the newly allocated memory page. Right after the new EPS. + memcpy((kernelMemory + sizeof(* newEPS)), staticSMBIOSData + offset, (tableLength - offset)); + +#ifdef SMB_STATIC_SYSTEM_UUID + // This enables you to override the factory UUID from the settings file. + static unsigned char SMB_SYSTEM_UUID[] = SMB_STATIC_SYSTEM_UUID; + + // Replace factory UUID with the one specified in: RevoBoot/i386/config/SETTINGS/MacModelNN.h + memcpy(gPlatform.UUID, SMB_SYSTEM_UUID, 16); +#else + if (offset) + { + // Get UUID from (dynamically loaded) SMBIOS data (/Extra/SMBIOS/MacModelNN.bin) + memcpy(gPlatform.UUID, staticSMBIOSData + 4, 16); + } +#endif #endif /* !__LIBSAIO_SMBIOS_STATIC_DATA_H */ diff --git a/i386/libsaio/smbios/tools/smbios.h b/i386/libsaio/smbios/tools/smbios.h deleted file mode 100644 index 2982e02..0000000 --- a/i386/libsaio/smbios/tools/smbios.h +++ /dev/null @@ -1,472 +0,0 @@ -/* - * Copyright (c) 1998-2009 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -// #include - -// -// Based on System Management BIOS Reference Specification v2.5 -// - -typedef bool SMBBool; -typedef UInt8 SMBString; -typedef UInt8 SMBByte; -typedef UInt16 SMBWord; -typedef UInt32 SMBDWord; -typedef UInt64 SMBQWord; - -typedef struct DMIEntryPoint -{ - SMBByte anchor[5]; - SMBByte checksum; - SMBWord tableLength; - SMBDWord tableAddress; - SMBWord structureCount; - SMBByte bcdRevision; -} __attribute__((packed)) DMIEntryPoint; - -typedef struct SMBEntryPoint -{ - SMBByte anchor[4]; - SMBByte checksum; - SMBByte entryPointLength; - SMBByte majorVersion; - SMBByte minorVersion; - SMBWord maxStructureSize; - SMBByte entryPointRevision; - SMBByte formattedArea[5]; - struct DMIEntryPoint dmi; -} __attribute__((packed)) SMBEntryPoint; - -// -// Header common to all SMBIOS structures -// - -typedef struct SMBStructHeader -{ - SMBByte type; - SMBByte length; - SMBWord handle; -} __attribute__((packed)) SMBStructHeader; - -#define SMB_STRUCT_HEADER SMBStructHeader header; - -typedef struct SMBAnchor -{ - const SMBStructHeader * header; - const UInt8 * next; - const UInt8 * end; -} SMBAnchor; - -#define SMB_ANCHOR_IS_VALID(x) \ - ((x) && ((x)->header) && ((x)->next) && ((x)->end)) - -#define SMB_ANCHOR_RESET(x) \ - bzero(x, sizeof(struct SMBAnchor)); - -// -// SMBIOS structure types. -// - -enum { - kSMBTypeBIOSInformation = 0, - kSMBTypeSystemInformation = 1, - kSMBTypeBaseBoard = 2, - kSMBTypeSystemEnclosure = 3, - kSMBTypeProcessorInformation = 4, - kSMBTypeMemoryModule = 6, - kSMBTypeCacheInformation = 7, - kSMBTypeSystemSlot = 9, - kSMBTypePhysicalMemoryArray = 16, - kSMBTypeMemoryDevice = 17, - kSMBType32BitMemoryErrorInfo = 18, - kSMBType64BitMemoryErrorInfo = 33, - - kSMBTypeEndOfTable = 127, - - // Apple Specific Structures. - kSMBTypeFirmwareVolume = 128, - kSMBTypeMemorySPD = 130, - kSMBTypeOemProcessorType = 131, - kSMBTypeOemProcessorBusSpeed = 132, - - // Structures dropped by Revolution. - kSMBUnused = 255 -}; - -// -// BIOS Information (Type 0) -// -typedef struct SMBBIOSInformation -{ - SMB_STRUCT_HEADER // Type 0 - SMBString vendor; // BIOS vendor name - SMBString version; // BIOS version - SMBWord startSegment; // BIOS segment start - SMBString releaseDate; // BIOS release date - SMBByte romSize; // (n); 64K * (n+1) bytes - SMBQWord characteristics; // supported BIOS functions -} __attribute__((packed)) SMBBIOSInformation; - -// -// System Information (Type 1) -// - -typedef struct SMBSystemInformation -{ - // 2.0+ spec (8 bytes) - SMB_STRUCT_HEADER // Type 1 - SMBString manufacturer; - SMBString productName; - SMBString version; - SMBString serialNumber; - // 2.1+ spec (25 bytes) - SMBByte uuid[16]; // can be all 0 or all 1's - SMBByte wakeupReason; // reason for system wakeup -} __attribute__((packed)) SMBSystemInformation; - -// -// Base Board (Type 2) -// - -typedef struct SMBBaseBoard -{ - SMB_STRUCT_HEADER // Type 2 - SMBString manufacturer; - SMBString product; - SMBString version; - SMBString serialNumber; - SMBString assetTagNumber; - SMBByte featureFlags; - SMBString locationInChassis; - SMBWord chassisHandle; - SMBByte boardType; - SMBByte numberOfContainedHandles; - // 0 - 255 contained handles go here but we do not include - // them in our structure. Be careful to use numberOfContainedHandles - // times sizeof(SMBWord) when computing the actual record size, - // if you need it. -} __attribute__((packed)) SMBBaseBoard; - -// Values for boardType in Type 2 records -enum -{ - kSMBBaseBoardUnknown = 0x01, - kSMBBaseBoardOther = 0x02, - kSMBBaseBoardServerBlade = 0x03, - kSMBBaseBoardConnectivitySwitch = 0x04, - kSMBBaseBoardSystemMgmtModule = 0x05, - kSMBBaseBoardProcessorModule = 0x06, - kSMBBaseBoardIOModule = 0x07, - kSMBBaseBoardMemoryModule = 0x08, - kSMBBaseBoardDaughter = 0x09, - kSMBBaseBoardMotherboard = 0x0A, - kSMBBaseBoardProcessorMemoryModule = 0x0B, - kSMBBaseBoardProcessorIOModule = 0x0C, - kSMBBaseBoardInterconnect = 0x0D, -}; - - -// -// System Enclosure (Type 3) -// - -typedef struct SMBSystemEnclosure -{ - SMB_STRUCT_HEADER // Type 3 - SMBString manufacturer; - SMBByte type; - SMBString version; - SMBString serialNumber; - SMBString assetTagNumber; - SMBByte bootupState; - SMBByte powerSupplyState; - SMBByte thermalState; - SMBByte securityStatus; - SMBDWord oemDefined; -} __attribute__((packed)) SMBSystemEnclosure; - -// -// Processor Information (Type 4) -// - -typedef struct SMBProcessorInformation -{ - // 2.0+ spec (26 bytes) - SMB_STRUCT_HEADER // Type 4 - SMBString socketDesignation; - SMBByte processorType; // CPU = 3 - SMBByte processorFamily; // processor family enum - SMBString manufacturer; - SMBQWord processorID; // based on CPUID - SMBString processorVersion; - SMBByte voltage; // bit7 cleared indicate legacy mode - SMBWord externalClock; // external clock in MHz - SMBWord maximumClock; // max internal clock in MHz - SMBWord currentClock; // current internal clock in MHz - SMBByte status; - SMBByte processorUpgrade; // processor upgrade enum - // 2.1+ spec (32 bytes) - SMBWord L1CacheHandle; - SMBWord L2CacheHandle; - SMBWord L3CacheHandle; - // 2.3+ spec (35 bytes) - SMBString serialNumber; - SMBString assetTag; - SMBString partNumber; - // 2.5+ spec (40 bytes) - SMBByte coreCount; // Number of cores detected by the BIOS. - SMBByte coreEnabled; // Number of cores that are enabled by the BIOS. - SMBByte threadCount; // Number of threads that are supported by this CPU (not per core). - SMBWord processorFuncSupport; // Defines which functions the processor supports. - /* 2.6+ spec (42 bytes) - SMBWord processorFamily; */ -} __attribute__((packed)) SMBProcessorInformation; - -#define kSMBProcessorInformationMinSize 26 - -// -// Memory Module Information (Type 6) -// Obsoleted since SMBIOS version 2.1 -// - -typedef struct SMBMemoryModule -{ - SMB_STRUCT_HEADER // Type 6 - SMBString socketDesignation; - SMBByte bankConnections; - SMBByte currentSpeed; - SMBWord currentMemoryType; - SMBByte installedSize; - SMBByte enabledSize; - SMBByte errorStatus; -} __attribute__((packed)) SMBMemoryModule; - -#define kSMBMemoryModuleSizeNotDeterminable 0x7D -#define kSMBMemoryModuleSizeNotEnabled 0x7E -#define kSMBMemoryModuleSizeNotInstalled 0x7F - -// -// Cache Information (Type 7) -// - -typedef struct SMBCacheInformation -{ - SMB_STRUCT_HEADER // Type 7 - SMBString socketDesignation; - SMBWord cacheConfiguration; - SMBWord maximumCacheSize; - SMBWord installedSize; - SMBWord supportedSRAMType; - SMBWord currentSRAMType; - // 2.1+ spec (12 ??? bytes) - SMBByte cacheSpeed; - SMBByte errorCorrectionType; - SMBByte systemCacheType; - SMBByte associativity; -} __attribute__((packed)) SMBCacheInformation; - -typedef struct SMBSystemSlot -{ - // 2.0+ spec (12 bytes) - SMB_STRUCT_HEADER // Type 9 - SMBString slotDesignation; - SMBByte slotType; - SMBByte slotDataBusWidth; - SMBByte currentUsage; - SMBByte slotLength; - SMBWord slotID; - SMBByte slotCharacteristics1; - // 2.1+ spec (13 bytes) - SMBByte slotCharacteristics2; - // 2.6+ spec (17 bytes) - SMBWord segmentGroupNumber; - SMBByte busNumber; - SMBByte deviceFunctionNumber; -} __attribute__((packed)) SMBSystemSlot; - -// -// Physical Memory Array (Type 16) -// - -typedef struct SMBPhysicalMemoryArray -{ - // 2.1+ spec (15 bytes) - SMB_STRUCT_HEADER // Type 16 - SMBByte physicalLocation; // physical location - SMBByte arrayUse; // the use for the memory array - SMBByte errorCorrection; // error correction/detection method - SMBDWord maximumCapacity; // maximum memory capacity in kilobytes - SMBWord errorHandle; // handle of a previously detected error - SMBWord numMemoryDevices; // number of memory slots or sockets -} __attribute__((packed)) SMBPhysicalMemoryArray; - -// Memory Array - Use -enum -{ - kSMBMemoryArrayUseOther = 0x01, - kSMBMemoryArrayUseUnknown = 0x02, - kSMBMemoryArrayUseSystemMemory = 0x03, - kSMBMemoryArrayUseVideoMemory = 0x04, - kSMBMemoryArrayUseFlashMemory = 0x05, - kSMBMemoryArrayUseNonVolatileMemory = 0x06, - kSMBMemoryArrayUseCacheMemory = 0x07 -}; - -// Memory Array - Error Correction Types -enum -{ - kSMBMemoryArrayErrorCorrectionTypeOther = 0x01, - kSMBMemoryArrayErrorCorrectionTypeUnknown = 0x02, - kSMBMemoryArrayErrorCorrectionTypeNone = 0x03, - kSMBMemoryArrayErrorCorrectionTypeParity = 0x04, - kSMBMemoryArrayErrorCorrectionTypeSingleBitECC = 0x05, - kSMBMemoryArrayErrorCorrectionTypeMultiBitECC = 0x06, - kSMBMemoryArrayErrorCorrectionTypeCRC = 0x07 -}; - -// -// Memory Device (Type 17) -// - -typedef struct SMBMemoryDevice -{ - // 2.1+ spec (21 bytes) - SMB_STRUCT_HEADER // Type 17 - SMBWord arrayHandle; // handle of the parent memory array - SMBWord errorHandle; // handle of a previously detected error - SMBWord totalWidth; // total width in bits; including ECC bits - SMBWord dataWidth; // data width in bits - SMBWord memorySize; // bit15 is scale, 0 = MB, 1 = KB - SMBByte formFactor; // memory device form factor - SMBByte deviceSet; // parent set of identical memory devices - SMBString deviceLocator; // labeled socket; e.g. "SIMM 3" - SMBString bankLocator; // labeled bank; e.g. "Bank 0" or "A" - SMBByte memoryType; // type of memory - SMBWord memoryTypeDetail; // additional detail on memory type - // 2.3+ spec (27 bytes) - SMBWord memorySpeed; // speed of device in MHz (0 for unknown) - SMBString manufacturer; - SMBString serialNumber; - SMBString assetTag; - SMBString partNumber; - // 2.6+ spec (28 bytes) - SMBByte attributes; -} __attribute__((packed)) SMBMemoryDevice; - -// -// Firmware Volume Description (Apple Specific - Type 128) -// - -enum -{ - FW_REGION_RESERVED = 0, - FW_REGION_RECOVERY = 1, - FW_REGION_MAIN = 2, - FW_REGION_NVRAM = 3, - FW_REGION_CONFIG = 4, - FW_REGION_DIAGVAULT = 5, - - NUM_FLASHMAP_ENTRIES = 8 -}; - -typedef struct FW_REGION_INFO -{ - SMBDWord StartAddress; - SMBDWord EndAddress; -} __attribute__((packed)) FW_REGION_INFO; - -typedef struct SMBFirmwareVolume -{ - SMB_STRUCT_HEADER // Type 128 - SMBByte RegionCount; - SMBByte Reserved[3]; - SMBDWord FirmwareFeatures; - SMBDWord FirmwareFeaturesMask; - SMBByte RegionType[ NUM_FLASHMAP_ENTRIES ]; - FW_REGION_INFO FlashMap[ NUM_FLASHMAP_ENTRIES ]; -} __attribute__((packed)) SMBFirmwareVolume; - -// -// Memory SPD Data (Apple Specific - Type 130) -// - -typedef struct SMBMemorySPD -{ - SMB_STRUCT_HEADER // Type 130 - SMBWord Type17Handle; - SMBWord Offset; - SMBWord Size; - SMBWord Data[]; -} __attribute__((packed)) SMBMemorySPD; - -static const char * SMBMemoryDeviceTypes[] = -{ - "RAM", /* 00h Undefined */ - "RAM", /* 01h Other */ - "RAM", /* 02h Unknown */ - "DRAM", /* 03h DRAM */ - "EDRAM", /* 04h EDRAM */ - "VRAM", /* 05h VRAM */ - "SRAM", /* 06h SRAM */ - "RAM", /* 07h RAM */ - "ROM", /* 08h ROM */ - "FLASH", /* 09h FLASH */ - "EEPROM", /* 0Ah EEPROM */ - "FEPROM", /* 0Bh FEPROM */ - "EPROM", /* 0Ch EPROM */ - "CDRAM", /* 0Dh CDRAM */ - "3DRAM", /* 0Eh 3DRAM */ - "SDRAM", /* 0Fh SDRAM */ - "SGRAM", /* 10h SGRAM */ - "RDRAM", /* 11h RDRAM */ - "DDR SDRAM", /* 12h DDR */ - "DDR2 SDRAM", /* 13h DDR2 */ - "DDR2 FB-DIMM", /* 14h DDR2 FB-DIMM */ - "RAM", /* 15h unused */ - "RAM", /* 16h unused */ - "RAM", /* 17h unused */ - "DDR3", /* 18h DDR3, chosen in [5776134] */ -}; - -static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) / sizeof(SMBMemoryDeviceTypes[0]); - -// -// OEM Processor Type (Apple Specific - Type 131) -// - -struct SMBOemProcessorType -{ - SMB_STRUCT_HEADER - SMBWord ProcessorType; -} __attribute__((packed)) SMBOemProcessorType; - -// -// OEM Processor Bus Speed (Apple Specific - Type 132) -// -struct SMBOemProcessorBusSpeed -{ - SMB_STRUCT_HEADER - SMBWord ProcessorBusSpeed; // MT/s unit -} __attribute__((packed)) SMBOemProcessorBusSpeed; - - - diff --git a/i386/libsaio/smbios/tools/smbios2struct3.c b/i386/libsaio/smbios/tools/smbios2struct3.c index 85fc38c..659bcc9 100755 --- a/i386/libsaio/smbios/tools/smbios2struct3.c +++ b/i386/libsaio/smbios/tools/smbios2struct3.c @@ -1,23 +1,33 @@ -/*** - * - * Name : smbios2struct3 (pipe output to file) - * Version : 1.0.5 - * Type : Command line tool - * Description : SMBIOS extractor / converter (resulting in a smaller and more Apple like table). - * - * Copyright : DutchHockeyPro (c) 2011 - * - * Compile with: cc -I . smbios2struct3.c -o smbios2struct3 -Wall -framework IOKit -framework CoreFoundation - * - */ +/* + * + * Name : smbios2struct4 + * Version : 1.1.2 + * Type : Command line tool + * Copyright : Sam aka RevoGirl (c) 2011 / Pike R. Alpha (c) 2012, 2013 + * Description : SMBIOS extractor / converter (resulting in a smaller and more Apple like table). + * + * Usage : sudo ./smbios2struct4 (output to terminal window) + * : sudo ./smbios2struct4 > ../../../config/SMBIOS/MacModelNN.h (writes to [path]MacModelNN.h) + * : sudo ./smbios2struct4 MacModelNN (writes to: /Extra/SMBIOS/MacModel.bin) + * + * Compile with : cc smbios2struct4.c -o smbios2struct4 -Wall -framework IOKit -framework CoreFoundation + * + * Updates : Interim solution for writing stripped SMBIOS table data to MacModelNN.bin (PikerAlpha, November 2012) + * : Check root priveledges for writing to: /Extra/SMBIOS/MacModelNN.bin (PikerAlpha, November 2012) + * : Now also saves /EFI-device-properties (PikerAlpha, November 2012) + * : Cleanups and iMessage fix for static SMBIOS data (Pike, April 2013) + * + */ #include #include +#include +#include #include #include -#include "SMBIOS.h" +#include "../smbios.h" #define DEBUG 0 // Set to 1 for additional (debug) output #define VERBOSE 1 @@ -33,7 +43,7 @@ //============================================================================== -char tableDescriptions[133][36] = +char tableDescriptions[134][36] = { /* 0 */ "BIOS Information", /* 1 */ "System Information", @@ -92,7 +102,8 @@ char tableDescriptions[133][36] = /* 129 */ "", /* 130 */ "Memory SPD Data", /* 131 */ "OEM Processor Type", - /* 132 */ "OEM Processor Bus Speed" + /* 132 */ "OEM Processor Bus Speed", + /* 133 */ "OEM Platform Feature" }; @@ -102,12 +113,12 @@ void dumpStaticTableData(const UInt8 * tableBuffer, int maxStructureSize, int st { int index = 0; - printf("\n\t#define STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE\t%d\n", maxStructureSize); - printf("\n\t#define STATIC_SMBIOS_DMI_STRUCTURE_COUNT\t%d\n", structureCount); + printf("\n#define STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE\t%d\n", maxStructureSize); + printf("\n#define STATIC_SMBIOS_DMI_STRUCTURE_COUNT\t%d\n", structureCount); printf("\n"); - printf("\t#define STATIC_SMBIOS_DATA \\\n"); - printf("\t/* SMBIOS data (0x%04x / %d bytes) converted with smbios2struct2 into little endian format. */ \\\n", tableLength, tableLength); - printf("\t/* 0x0000 */\t"); + printf("#define STATIC_SMBIOS_DATA \\\n"); + printf("/* SMBIOS data (0x%04x / %d bytes) converted with smbios2struct2 into little endian format. */ \\\n", tableLength, tableLength); + printf("/* 0x0000 */\t"); UInt16 length = round2(tableLength, 4); UInt32 * newTableData = malloc(tableLength); @@ -123,7 +134,7 @@ void dumpStaticTableData(const UInt8 * tableBuffer, int maxStructureSize, int st if ((index % 8) == 0) { - printf("\\\n\t/* 0x%04x */\t", (index * 4)); + printf("\\\n/* 0x%04x */\t", (index * 4)); } } } while((index * 4) <= length); @@ -138,6 +149,27 @@ void dumpStaticTableData(const UInt8 * tableBuffer, int maxStructureSize, int st int main(int argc, char * argv[]) { + char dirspec[128]; + int filedesc = 0; + struct stat my_sb; + + if (argc == 2) + { + uid_t real_uid = getuid(); + uid_t euid = geteuid(); + +#if DEBUG + printf("UID: %u EUID: %u\n", real_uid, euid); +#endif + // Under sudo, getuid and geteuid returns 0. + if (real_uid != 0 || euid != 0) + { + printf("Error: Not root. Use sudo ./smbios2struct4 [filename without extension]\n"); + + exit (-1); + } + } + mach_port_t masterPort; io_service_t service = MACH_PORT_NULL; CFDataRef dataRef; @@ -146,20 +178,88 @@ int main(int argc, char * argv[]) UInt16 tableLength = 0, droppedTables = 0; UInt16 newTableLength = 0; - // UInt32 * shadowTableData = NULL; - IOMasterPort(MACH_PORT_NULL, &masterPort); + + //================================================================================== + + io_registry_entry_t efi = IORegistryEntryFromPath(kIOMasterPortDefault, kIODeviceTreePlane ":/efi"); + + if (efi == IO_OBJECT_NULL) + { +#if DEBUG + printf("FAILURE: Unable to locate EFI registry entry.\n"); +#endif + exit(-1); + } + else + { +#if DEBUG + printf("OK\n"); +#endif + dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(efi, CFSTR("device-properties"), kCFAllocatorDefault, kNilOptions); + + if (dataRef) + { + UInt32 * deviceProperties = (UInt32 *) CFDataGetBytePtr(dataRef); + UInt16 devicePropertiesBytes = (int) CFDataGetLength(dataRef); +#if DEBUG + printf("Property 'device-properties' %d bytes found.", numBytes); +#endif + if ((argc == 2) && (devicePropertiesBytes)) // Write to file? + { + // Sanity check for required directory. + if (stat("/Extra", &my_sb) != 0) + { + mkdir("/Extra", (S_IRWXU | S_IRWXG | S_IRWXO)); + } + // Sanity check for required directory. + if (stat("/Extra/EFI", &my_sb) != 0) + { + mkdir("/Extra/EFI", (S_IRWXU | S_IRWXG | S_IRWXO)); + } + + sprintf (dirspec, "/Extra/EFI/%s.bin", argv[1]); + filedesc = open(dirspec, O_WRONLY|O_CREAT|O_TRUNC, 0644); + + if (filedesc == -1) + { + printf("Error: Unable to open file!\n"); + } + else + { + int status = write(filedesc, deviceProperties, devicePropertiesBytes); + + if (status != devicePropertiesBytes) + { + printf("status %d, saved %d bytes\n", status, devicePropertiesBytes); + } + else + { + printf("%d bytes written to: %s\n", devicePropertiesBytes, dirspec); + } + } + + close (filedesc); + } + } +#if DEBUG + else + { + printf("FAILURE: Unable to locate ':/efi/device-properties'\n"); + } +#endif + } + + //================================================================================== + service = IOServiceGetMatchingService(masterPort, IOServiceMatching("AppleSMBIOS")); if (service) { #if DEBUG - printf("\nHave AppleSMBIOS\n"); + printf("\nAppleSMBIOS found\n"); #endif - dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service, - CFSTR("SMBIOS-EPS"), - kCFAllocatorDefault, - kNilOptions); + dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service, CFSTR("SMBIOS-EPS"), kCFAllocatorDefault, kNilOptions); if (dataRef) { @@ -208,10 +308,7 @@ int main(int argc, char * argv[]) printf("\n"); #endif - dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service, - CFSTR("SMBIOS"), - kCFAllocatorDefault, - kNilOptions); + dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service, CFSTR("SMBIOS"), kCFAllocatorDefault, kNilOptions); if (dataRef) { @@ -226,21 +323,20 @@ int main(int argc, char * argv[]) UInt16 numBytes = (int) CFDataGetLength(dataRef); printf("\nNumber of bytes: %d (Original SMBIOS table)\n", numBytes); #endif - + SMBWord newHandle = 0; SMBStructHeader * header; + SMBSystemInformation * systemInfo; + const UInt8 * tablePtr = (const UInt8 *) tableData; const UInt8 * tableEndPtr = tablePtr + tableLength; const UInt8 * tableStructureStart = 0; const UInt8 * droppedTableStructureStart = 0; - const UInt8 * tableBuffer = malloc(tableLength); + const UInt8 * tableBuffer = malloc(tableLength + 20); - // int index = 0; int maxStructureSize = 0; int newStructureCount = 0; int structureLength = 0; - SMBWord newHandle = 0; - bzero((void *)tableBuffer, sizeof(tableBuffer)); while (structureCount-- && (tableEndPtr > tablePtr + sizeof(SMBStructHeader))) @@ -253,22 +349,40 @@ int main(int argc, char * argv[]) { break; } - + switch (header->type) { - case kSMBTypeBIOSInformation: // Type 0 - case kSMBTypeSystemInformation: // Type 1 - case kSMBTypeBaseBoard: // Type 2 - case kSMBTypeProcessorInformation: // Type 4 - // case kSMBTypeMemoryModule: // Type 6 - // case kSMBTypeSystemSlot: // Type 9 - case kSMBTypePhysicalMemoryArray: // Type 16 - case kSMBTypeMemoryDevice: // Type 17 - case kSMBTypeEndOfTable: // Type 127 - case kSMBTypeFirmwareVolume: // Type 128 - case kSMBTypeMemorySPD: // Type 130 - case kSMBTypeOemProcessorType: // Type 131 - case kSMBTypeOemProcessorBusSpeed: // Type 132 + case kSMBTypeSystemInformation: // Type 1 + + bcopy((void *)tableBuffer, (void *)tableBuffer + 20, (tableLength - 20)); + + static SMBByte const data[] = { + 0x55, 0x55, 0x49, 0x44, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + + bcopy(data, (void *)tableBuffer, 20); + + systemInfo = (SMBSystemInformation *) tablePtr; + bcopy((SMBByte *)systemInfo->uuid, (void *)tableBuffer + 4, 16); + newTableLength += 20; + + case kSMBTypeBIOSInformation: // Type 0 + case kSMBTypeBaseBoard: // Type 2 + case kSMBTypeProcessorInformation: // Type 4 + // case kSMBTypeMemoryModule: // Type 6 + // case kSMBTypeSystemSlot: // Type 9 + case kSMBTypeOemStrings: // Type 11 + case kSMBTypePhysicalMemoryArray: // Type 16 + case kSMBTypeMemoryDevice: // Type 17 + case kSMBTypeMemoryArrayMappedAddress: // Type 19 + case kSMBTypeEndOfTable: // Type 127 + case kSMBTypeFirmwareVolume: // Type 128 + case kSMBTypeMemorySPD: // Type 130 + case kSMBTypeOemProcessorType: // Type 131 + case kSMBTypeOemProcessorBusSpeed: // Type 132 + case kSMBTypeOemPlatformFeature: // Type 133 newStructureCount++; tableStructureStart = tablePtr; @@ -280,14 +394,23 @@ int main(int argc, char * argv[]) droppedTables++; droppedTableStructureStart = tablePtr; } - + + if (header->type == kSMBTypeProcessorInformation) + { + SMBProcessorInformation * cpuInfo = (SMBProcessorInformation *) tablePtr; + VERBOSE_DUMP("cpu.externalClock: %d\n", cpuInfo->externalClock); + VERBOSE_DUMP("cpu.maximumClock : %d\n", cpuInfo->maximumClock); + VERBOSE_DUMP("cpu.currentClock :%d\n", cpuInfo->currentClock); + } + VERBOSE_DUMP("Table: %3d %37s @%p Formatted area: %2d bytes ", header->type, tableDescriptions[header->type], tablePtr, header->length); // Skip the formatted area of the structure. tablePtr += header->length; // Skip the unformatted structure area at the end (strings). - for (; tableEndPtr > tablePtr + sizeof(SMBStructHeader); tablePtr++) + // for (; tableEndPtr > tablePtr + sizeof(SMBStructHeader); tablePtr++) + for (; tableEndPtr > tablePtr; tablePtr++) { // Look for a terminating double NULL. if (tablePtr[0] == 0 && tablePtr[1] == 0) @@ -321,7 +444,45 @@ int main(int argc, char * argv[]) VERBOSE_DUMP("\nDropped tables: %2d.\n", droppedTables); - dumpStaticTableData(tableBuffer, maxStructureSize, newStructureCount, newTableLength); + if (argc == 2) // Write to file? + { + // Sanity check for required directory. + if (stat("/Extra/SMBIOS", &my_sb) != 0) + { + mkdir("/Extra/SMBIOS", (S_IRWXU | S_IRWXG | S_IRWXO)); + } + + sprintf (dirspec, "/Extra/SMBIOS/%s.bin", argv[1]); + filedesc = open(dirspec, O_WRONLY|O_CREAT|O_TRUNC, 0644); + + if (filedesc == -1) + { + printf("Error: Unable to open file!\n"); + } + else + { + newTableLength = round2((newTableLength + 2), 4); + + VERBOSE_DUMP("newTableLength: %d\n", newTableLength); + + int status = write(filedesc, tableBuffer, newTableLength); + + if (status != newTableLength) + { + printf("status %d, saved %d bytes\n", status, newTableLength); + } + else + { + printf("%d bytes written to: %s\n", newTableLength, dirspec); + } + } + + close (filedesc); + } + else + { + dumpStaticTableData(tableBuffer, maxStructureSize, newStructureCount, newTableLength); + } free((void *)tableBuffer); diff --git a/i386/libsaio/smbios/tools/smbiosXtract.c b/i386/libsaio/smbios/tools/smbiosXtract.c new file mode 100755 index 0000000..dbdec80 --- /dev/null +++ b/i386/libsaio/smbios/tools/smbiosXtract.c @@ -0,0 +1,115 @@ +/* + * + * Name : smbiosXtract + * Version : 0.0.1 + * Type : Command line tool + * Copyright : Pike R. Alpha (c) 2016 + * Description : SMBIOS extractor for use with: dmidecode --from-file SMBIOS.bin + * + * Usage : sudo ./smbiosXtract + * + * Compile with : cc smbiosXtract.c -o smbiosXtract -Wall -framework IOKit -framework CoreFoundation + * + * Updates : None so far. + * + */ + +#include +#include +#include +#include + +#include +#include + +#include "../smbios.h" + +//============================================================================== + +uint8_t checksum8(const uint8_t *cp, uint8_t length) +{ + uint8_t sum = 0; + uint8_t i = 0; + + for (; i < length; i++) + { + sum += *cp++; + } + + return sum; +} + +//============================================================================== + +int main(void) +{ + char dirspec[128]; + int filedesc = 0; + + mach_port_t masterPort; + io_service_t service = MACH_PORT_NULL; + CFDataRef dataRef; + + UInt8 entryPointLength = 0; + UInt16 tableLength = 0; + UInt32 bytesWritten = 0; + + IOMasterPort(MACH_PORT_NULL, &masterPort); + + //================================================================================== + + service = IOServiceGetMatchingService(masterPort, IOServiceMatching("AppleSMBIOS")); + + if (service) + { + dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service, CFSTR("SMBIOS-EPS"), kCFAllocatorDefault, kNilOptions); + + if (dataRef) + { + struct SMBEntryPoint * eps = (struct SMBEntryPoint *) CFDataGetBytePtr(dataRef); + entryPointLength = eps->entryPointLength; + tableLength = eps->dmi.tableLength; + + // Point table address to data. + eps->dmi.tableAddress = 0x20; + + // Zero out checksums. + eps->checksum = 0; + eps->dmi.checksum = 0; + + // Recalculate checksums. + eps->dmi.checksum = (256 - checksum8(CFDataGetBytePtr(dataRef) + 0x10, 0x0f)); + eps->checksum = (256 - checksum8(CFDataGetBytePtr(dataRef), 0x1f)); + + sprintf (dirspec, "SMBIOS.bin"); + filedesc = open(dirspec, O_WRONLY|O_CREAT|O_TRUNC, 0644); + + if (filedesc == -1) + { + printf("Error: Unable to open SMBIOS.bin!\n"); + close (filedesc); + CFRelease(dataRef); + } + else + { + bytesWritten = write(filedesc, (char *)CFDataGetBytePtr(dataRef), (entryPointLength + 1)); + close (filedesc); + CFRelease(dataRef); + dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service, CFSTR("SMBIOS"), kCFAllocatorDefault, kNilOptions); + + if (dataRef) + { + filedesc = open(dirspec, O_WRONLY|O_APPEND, 0644); + bytesWritten += write(filedesc, (char *)CFDataGetBytePtr(dataRef), tableLength); + printf("%d bytes written to SMBIOS.bin for use with: dmidecode --from-dump SMBIOS.bin\n", bytesWritten); + close (filedesc); + CFRelease(dataRef); + } + } + } + + IOObjectRelease(service); + } + + exit(0); +} diff --git a/i386/libsaio/stringTable.c b/i386/libsaio/stringTable.c index fe725ad..1d9ca20 100755 --- a/i386/libsaio/stringTable.c +++ b/i386/libsaio/stringTable.c @@ -22,24 +22,30 @@ * @APPLE_LICENSE_HEADER_END@ * * Copyright 1993 NeXT, Inc. All rights reserved. + * + * Updates: + * - White space changes (PikerAlpha, November 2012). + * - Now checking malloc returns (PikerAlpha, November 2012). + * - Cleanups, kTagTypeData support and NVRAMstorage reading changes (PikerAlpha, November 2012). + * - Renamed LION_INSTALL_SUPPORT to INSTALL_ESD_SUPPORT (PikerAlpha, April 2013). + * - Stripped (unnecessary) argument from loadSystemConfig (PikerAlpha, April 2013). + * */ + #include "bootstruct.h" #include "libsaio.h" #include "xml.h" #include "stdbool.h" -extern char *Language; -extern char *LoadableFamilies; - -int sysConfigValid; +#define DEBUG_XML_PARSER 0 //============================================================================== static inline int isspace(char c) { - return (c == ' ' || c == '\t'); + return (c == ' ' || c == '\t'); } @@ -47,25 +53,28 @@ static inline int isspace(char c) bool getValueForConfigTableKey(config_file_t *config, const char *key, const char **val, int *size) { - if (config->dictionary != 0) - { - // Look up key in XML dictionary - TagPtr value; - value = XMLGetProperty(config->dictionary, key); - - if (value != 0) - { - if (value->type != kTagTypeString) - { - error("Non-string tag '%s' found in config file\n", key); - return false; - } - *val = value->string; - *size = strlen(value->string); - return true; - } - } - // else {} for legacy plist-style table, which is not implemented! + if (config->dictionary != 0) + { + // Look up key in XML dictionary + TagPtr value = XMLGetProperty(config->dictionary, key); + + if (value != 0) + { + if ((value->type != kTagTypeString) && (value->type != kTagTypeData)) + { +#if DEBUG_XML_PARSER + error("Unsupported tag '%s' found in config file\n", key); +#endif + return false; + } + + *val = value->string; + *size = strlen(value->string); + + return true; + } + } + // else {} for legacy plist-style table, which is not implemented! return false; } @@ -75,26 +84,22 @@ bool getValueForConfigTableKey(config_file_t *config, const char *key, const cha char * newStringForKey(char *key, config_file_t *config) { - const char *val; - char *newstr; - int size; - - if (getValueForKey(key, &val, &size, config) && size) - { - newstr = (char *)malloc(size + 1); - strlcpy(newstr, val, size + 1); - return newstr; - } - - return 0; + int size; + const char *val; + + if (getValueForKey(key, &val, &size, config) && size) + { + return strdup(val); // string.c + } + + return 0; } //============================================================================== -/* parse a command line - * in the form: [ ...] [