├── VERSION
├── i386
├── config
│ ├── ACPI
│ │ ├── data.h
│ │ ├── clean.h
│ │ └── data-template.h
│ ├── data-template.h
│ ├── settings.h
│ ├── EFI
│ │ ├── clean.h
│ │ └── data-template.h
│ ├── data.h
│ ├── SMBIOS
│ │ ├── clean.h
│ │ └── data-template.h
│ └── README
├── libsaio
│ ├── acpi
│ │ ├── Tools
│ │ │ ├── ssdtPRGen.app
│ │ │ │ ├── Icon
│ │ │ │ └── Contents
│ │ │ │ │ └── MacOS
│ │ │ │ │ └── ssdtPRGen
│ │ │ ├── iasl
│ │ │ ├── extractACPITables
│ │ │ ├── install.sh
│ │ │ └── extractACPITables.c
│ │ ├── static_data.h
│ │ ├── debug.h
│ │ └── examples
│ │ │ └── P8Z68-V PRO
│ │ │ └── ssdt.dsl
│ ├── cpu
│ │ ├── tools
│ │ │ └── PMinfo
│ │ │ │ ├── AppleIntelCPUPowerManagementInfo
│ │ │ │ ├── InfoPlist.strings
│ │ │ │ ├── Info-AppleIntelCPUPowerManagementInfo.plist
│ │ │ │ └── AppleIntelCPUPowerManagementInfo.h
│ │ │ │ └── DerivedData
│ │ │ │ └── AppleIntelCPUPowerManagementInfo
│ │ │ │ ├── Logs
│ │ │ │ ├── Build
│ │ │ │ │ ├── Cache.db
│ │ │ │ │ └── AC062B99-9E9E-41C9-966B-1B327D5EC5DC.xcactivitylog
│ │ │ │ └── Issues
│ │ │ │ │ ├── Cache.db
│ │ │ │ │ └── 8BE2DAD6-DF4F-4F8E-9FCF-211E10D22EAE.xcactivitylog
│ │ │ │ ├── info.plist
│ │ │ │ └── Build
│ │ │ │ └── Intermediates
│ │ │ │ └── AppleIntelCPUPowerManagementInfo.build
│ │ │ │ └── Debug
│ │ │ │ └── AppleIntelCPUPowerManagementInfo.build
│ │ │ │ ├── AppleIntelCPUPowerManagementInfo.hmap
│ │ │ │ ├── Objects-normal
│ │ │ │ └── x86_64
│ │ │ │ │ ├── AppleIntelCPUPowerManagementInfo.LinkFileList
│ │ │ │ │ ├── AppleIntelCPUPowerManagementInfo.o
│ │ │ │ │ ├── AppleIntelCPUPowerManagementInfo.dia
│ │ │ │ │ ├── AppleIntelCPUPowerManagementInfo_info.o
│ │ │ │ │ └── AppleIntelCPUPowerManagementInfo_info.dia
│ │ │ │ ├── AppleIntelCPUPowerManagementInfo-generated-files.hmap
│ │ │ │ ├── AppleIntelCPUPowerManagementInfo-all-target-headers.hmap
│ │ │ │ ├── AppleIntelCPUPowerManagementInfo-own-target-headers.hmap
│ │ │ │ ├── DerivedSources
│ │ │ │ └── AppleIntelCPUPowerManagementInfo_info.c
│ │ │ │ ├── AppleIntelCPUPowerManagementInfo-project-headers.hmap
│ │ │ │ └── AppleIntelCPUPowerManagementInfo.dep
│ │ ├── Intel
│ │ │ └── static_data.h
│ │ ├── cpuid.h
│ │ └── proc_reg.h
│ ├── pci.c
│ ├── libsaio.h
│ ├── pci.h
│ ├── hfs.h
│ ├── smbios
│ │ ├── essentials.h
│ │ ├── static_data.h
│ │ └── tools
│ │ │ ├── smbiosXtract.c
│ │ │ └── smbios2struct.c
│ ├── sl.h
│ ├── device_tree.h
│ ├── Makefile
│ ├── xml.h
│ ├── io_inline.h
│ ├── efi
│ │ ├── EfiError.h
│ │ └── efi.h
│ ├── allocate.c
│ ├── bios.h
│ ├── fdisk.h
│ ├── table.c
│ ├── guid.c
│ ├── console.c
│ ├── vbe.c
│ ├── acpi.c
│ └── cache.c
├── boot0
│ └── boot0.s
├── boot1
│ └── boot1h.s
├── MakePaths.dir
├── util
│ ├── Makefile
│ ├── segaddr
│ └── machOconv.c
├── Makefile
├── libsa
│ ├── Makefile
│ ├── setjmp.s
│ ├── printf.c
│ ├── libsa.h
│ ├── prf.c
│ ├── memory.h
│ └── crc32.c
├── MakeInc.dir
└── boot2
│ ├── Makefile
│ ├── lzss.c
│ ├── boot2.s
│ ├── debug.h
│ ├── bootlogo.c
│ ├── options.c
│ └── boot.h
├── fdisk440
├── r
├── .gitignore
├── i
├── README
└── c
/VERSION:
--------------------------------------------------------------------------------
1 | 2.0.00
2 |
--------------------------------------------------------------------------------
/i386/config/ACPI/data.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/i386/config/data-template.h:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/i386/libsaio/acpi/Tools/ssdtPRGen.app/Icon
:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/fdisk440:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/fdisk440
--------------------------------------------------------------------------------
/i386/boot0/boot0.s:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/boot0/boot0.s
--------------------------------------------------------------------------------
/i386/boot1/boot1h.s:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/boot1/boot1h.s
--------------------------------------------------------------------------------
/i386/libsaio/acpi/Tools/iasl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/acpi/Tools/iasl
--------------------------------------------------------------------------------
/i386/libsaio/acpi/Tools/extractACPITables:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/acpi/Tools/extractACPITables
--------------------------------------------------------------------------------
/i386/libsaio/acpi/Tools/ssdtPRGen.app/Contents/MacOS/ssdtPRGen:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/acpi/Tools/ssdtPRGen.app/Contents/MacOS/ssdtPRGen
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 | NSHumanReadableCopyright = "Copyright © 2012-2014 Pike R. Alpha. All rights reserved";
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/Cache.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/Cache.db
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/Cache.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/Cache.db
--------------------------------------------------------------------------------
/i386/MakePaths.dir:
--------------------------------------------------------------------------------
1 | #
2 | # File: RevoBoot/i386/MakePaths.dir
3 | #
4 | # Updates:
5 | #
6 | # - Major cleanup (Pike R. Alpha, October 2012).
7 | #
8 |
9 |
10 | #
11 | # Default paths for subdirectories.
12 | #
13 |
14 | OBJROOT=../../obj/i386/$(DIR)
15 | SYMROOT=../../sym/i386
16 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/AC062B99-9E9E-41C9-966B-1B327D5EC5DC.xcactivitylog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Build/AC062B99-9E9E-41C9-966B-1B327D5EC5DC.xcactivitylog
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/8BE2DAD6-DF4F-4F8E-9FCF-211E10D22EAE.xcactivitylog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Logs/Issues/8BE2DAD6-DF4F-4F8E-9FCF-211E10D22EAE.xcactivitylog
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | WorkspacePath
6 | /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo.xcodeproj
7 |
8 |
9 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo.hmap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo.hmap
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.LinkFileList:
--------------------------------------------------------------------------------
1 | /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o
2 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-generated-files.hmap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-generated-files.hmap
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-all-target-headers.hmap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-all-target-headers.hmap
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-own-target-headers.hmap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-own-target-headers.hmap
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.o
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo.dia
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.o
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piker-Alpha/RevoBoot/HEAD/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/Objects-normal/x86_64/AppleIntelCPUPowerManagementInfo_info.dia
--------------------------------------------------------------------------------
/i386/config/settings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Master Chief.
3 | *
4 | * Updates:
5 | *
6 | * - Read settings file based on given model identifier (PikerAlpha, October 2012).
7 | * - COMMA_STRIPPED_MODEL_ID added (PikerAlpha, November 2012).
8 | */
9 |
10 | #define TO_STRING_DO(a) #a
11 | #define STRING(a) TO_STRING_DO(a)
12 |
13 | #include STRING(SETTINGS_FILE)
14 |
15 | /*
16 | * gPlatform.ModelID is a char * initialized by a call to strdup(SMB_PRODUCT_NAME) in
17 | * platform.c and we use strdup once more here so that gPlatform.ModelID is untouched.
18 | */
19 | #define COMMA_STRIPPED_MODEL_ID removeChar(strdup(gPlatform.ModelID), ',')
20 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/DerivedSources/AppleIntelCPUPowerManagementInfo_info.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | extern kern_return_t _start(kmod_info_t *ki, void *data);
4 | extern kern_return_t _stop(kmod_info_t *ki, void *data);
5 |
6 | __attribute__((visibility("default"))) KMOD_EXPLICIT_DECL(com.apple.kext.AppleIntelCPUPowerManagementInfo, "1.0.0d1", _start, _stop)
7 | __private_extern__ kmod_start_func_t *_realmain = 0;
8 | __private_extern__ kmod_stop_func_t *_antimain = 0;
9 | __private_extern__ int _kext_apple_cc = __APPLE_CC__ ;
10 |
--------------------------------------------------------------------------------
/i386/config/EFI/clean.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Master Chief. All rights reserved.
3 | *
4 | * Note: This is an essential part of the build process for Revolution v0.6.43 and greater.
5 | *
6 | *
7 | * Latest cleanups and additional directives added by DHP in 2011
8 | */
9 |
10 |
11 | //----------------------------------------------------------------- EFI --------------------------------------------------------------------
12 |
13 | #define STATIC_EFI_DEVICE_PROPERTIES \
14 | /* 0x0000 */ // Insert your EFI device-property data here (optional).
15 |
16 | //================================================================= END ====================================================================
17 |
--------------------------------------------------------------------------------
/i386/config/EFI/data-template.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Master Chief. All rights reserved.
3 | *
4 | * Note: This is an essential part of the build process for Revolution v0.6.43 and greater.
5 | *
6 | *
7 | * Latest cleanups and additional directives added by DHP in 2011
8 | */
9 |
10 |
11 | //----------------------------------------------------------------- EFI --------------------------------------------------------------------
12 |
13 | #define STATIC_EFI_DEVICE_PROPERTIES \
14 | /* 0x0000 */ // Insert your EFI device-property data here (optional).
15 |
16 | //================================================================= END ====================================================================
17 |
--------------------------------------------------------------------------------
/r:
--------------------------------------------------------------------------------
1 | clear
2 | #
3 | # Check argument for Mac model.
4 | #
5 | if [[ "$1" =~ [iMac|Mac] ]];
6 | then
7 | #
8 | # Use specified MacModelNN from argument.
9 | #
10 | make MODEL=$1
11 | else
12 | #
13 | # Check RevoBoot/MODEL for default model.
14 | #
15 | if [ -f MODEL ];
16 | then
17 | #
18 | # Get MacModelNN from MODEL (assuming it to be correct).
19 | #
20 | make MODEL=`cat MODEL`
21 | else
22 | #
23 | # No default model found. Create MODEL file for future use.
24 | #
25 | echo "Macmini62" > MODEL
26 | #
27 | # Use Macmini62 as our default (matches settings-template.h)
28 | #
29 | make MODEL=Macmini62
30 | fi;
31 | fi
32 |
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .git
3 |
4 | out.log
5 | obj/*
6 | sym/*
7 |
8 | i386/boot0/boot0
9 | i386/boot1/boot1h
10 |
11 | i386/config/SETTINGS/*.h
12 |
13 | i386/config/ACPI/*.h
14 | i386/config/EFI/*.h
15 | i386/config/SMBIOS/*.h
16 |
17 | i386/util/libcc_kext.a
18 |
19 | MODEL
20 |
21 | xcuserdata
22 | project.xcworkspace
23 |
24 | i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/secretCode.h
25 | i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo.xcodeproj/xcuserdata
26 | i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo.xcodeproj/project.xcworkspace
27 |
28 | i386/libsaio/cpu/tools/PMinfoBackup
29 |
30 | i386/libsaio/smbios/tools/smbios2struct3
31 | i386/libsaio/smbios/tools/smbios2struct4
32 |
33 | *OLD*
34 | *BAK*
35 | *test*
36 | BACKUP
37 |
38 |
--------------------------------------------------------------------------------
/i386/libsaio/pci.c:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2008 by Islam M. Ahmed Zaid. All rights reserved.
4 | *
5 | * Refactoring done by DHP for Revolution in 2011.
6 | *
7 | */
8 |
9 | #include "libsaio.h"
10 | #include "pci.h"
11 |
12 | //==============================================================================
13 |
14 | uint32_t pciConfigRead(uint8_t readType, uint32_t pciAddress, uint8_t pciRegister)
15 | {
16 | uint32_t data = -1;
17 |
18 | pciAddress |= (pciRegister & ~3);
19 | outl(PCI_ADDR_REG, pciAddress);
20 |
21 | switch (readType)
22 | {
23 | case READ_BYTE:
24 | data = inb(PCI_DATA_REG + (pciRegister & 3));
25 | break;
26 |
27 | case READ_WORD:
28 | data = inw(PCI_DATA_REG + (pciRegister & 2));
29 | break;
30 |
31 | case READ_LONG:
32 | data = inl(PCI_DATA_REG);
33 | break;
34 | }
35 |
36 | return data;
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/i386/util/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | #File: RevoBoot/i386/util/Makefile
3 | #
4 | # Updates:
5 | #
6 | # - Major cleanup (PikerAlpha, October 2012).
7 | # - Fixed clang compilation (dgsga, November 2012. Credits to Evan Lojewski for original work).
8 | # - Output improved (PikerAlpha, October 2012).
9 | # - Now using my bash script instead of segsize.c (PikerAlpha, November 2012).
10 | #
11 |
12 | include ../MakePaths.dir
13 |
14 | VPATH = $(OBJROOT):$(SYMROOT)
15 |
16 | OPTIM = -Os -Oz
17 | CFLAGS = $(RC_CFLAGS) $(OPTIM) -Wmost -Werror -g
18 |
19 | LDFLAGS =
20 | DEFINES=
21 |
22 | PROGRAMS = machOconv
23 | OBJS = machOconv.o
24 |
25 | DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
26 |
27 | $(MAKEGOAL): $(DIRS_NEEDED) $(PROGRAMS)
28 |
29 | $(PROGRAMS): $(OBJS)
30 | @echo "\t[CC] $(@F)"
31 | @$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -o $(SYMROOT)/$(@F) $(OBJROOT)/$(@F).o
32 |
33 | include ../MakeInc.dir
34 |
--------------------------------------------------------------------------------
/i386/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # File: RevoBoot/i386/Makefile
3 | #
4 | # Updates:
5 | #
6 | # - Major cleanup (PikerAlpha, October 2012).
7 | # - Output improvements (PikerAlpha, October 2012).
8 | # - PRODUCT_MODEL_TARGET renamed to MAKE_TARGET_MODEL (PikerAlpha, November 2012).
9 | # - Cleanup and output changed (PikerAlpha, October 2012).
10 | #
11 |
12 | #
13 | # These paths are only valid in subdirectories of this directory.
14 | #
15 |
16 | OBJROOT=../i386/obj/i386
17 | SYMROOT=../i386/sym/i386
18 |
19 | # VPATH = $(OBJROOT):$(SYMROOT)
20 |
21 | #
22 | # The build order here is important.
23 | #
24 |
25 | SUBDIRS = util libsa libsaio boot2
26 |
27 |
28 | $(MAKEGOAL):
29 | @for i in $(SUBDIRS); \
30 | do \
31 | echo ================= RevoBoot/i386/$$i =================; \
32 | ( cd $$i; ${MAKE} \
33 | "OBJROOT=$(OBJROOT)/$$i" \
34 | "SYMROOT=$(SYMROOT)" \
35 | "RC_ARCHS=$(RC_ARCHS)" \
36 | "RC_CFLAGS=$(RC_CFLAGS)" $@ \
37 | ) || exit $$?; \
38 | done
39 |
--------------------------------------------------------------------------------
/i386/libsaio/acpi/Tools/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Installation script for ssdtPRGen.command
4 | #
5 | # Version 0.1 - Copyright (c) 2013 by Pike
6 | #
7 | # Updates:
8 | # -
9 | #
10 | # Contributors:
11 | #
12 |
13 | #--------------------------------------------------------------------------------
14 |
15 | if [ -f ~/ssdtPRGen.command ];
16 | then
17 | open ~/ssdtPRGen.command
18 | else
19 | #
20 | # Download script
21 | #
22 | curl -o ~/ssdtPRGen.command https://raw.github.com/Piker-Alpha/RevoBoot/clang/i386/libsaio/acpi/Tools/ssdtPRGen.sh
23 |
24 | #
25 | # Add execute rights
26 | #
27 | chmod +x ~/ssdtPRGen.command
28 |
29 | #
30 | # Maintain backward compatibility with older versions
31 | #
32 | ln -sf ~/ssdtPRGen.command ~/ssdtPRGen.sh
33 |
34 | #
35 | # Put a symbolic link to the script on the Desktop
36 | #
37 | ln -sf ~/ssdtPRGen.command ~/Desktop/ssdtPRGen.command
38 | fi
39 |
40 | exit 0
41 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo-project-headers.hmap:
--------------------------------------------------------------------------------
1 | pamh @ v $ AppleIntelCPUPowerManagementInfo.h /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/
--------------------------------------------------------------------------------
/i386/config/data.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Master Chief.
3 | *
4 | * This file, included by acpi.c, efi.c and smbios.c includes data files
5 | * for the target build model (based on MODEL=MacModelNN) or default.h
6 | *
7 | * Updates:
8 | *
9 | * - Refactored by DHP in 2010-2011.
10 | * - Automatic model data selection (PikerAlpha, October 2012).
11 | * - Static ACPI data selector moved to RevoBoot/i386/libsaio/ACPI/static_data.h (PikerAlpha, October 2012).
12 | * - Static EFI data selector moved to RevoBoot/i386/libsaio/efi.c (PikerAlpha, October 2012).
13 | * - Static SMBIOS data selector moved to RevoBoot/i386/libsaio/SMBIOS/dynamic_data.h (PikerAlpha, October 2012).
14 | * - This file is no longer included with RevoBoot v1.5.25 (PikerAlpha, October 2012).
15 | */
16 |
17 |
18 | !!__WHEN_YOU_SEE_THIS_STUPID_ERROR_THAN_SOMETHING_IS_WRONG__!!
19 |
20 | #if (PATCH_ACPI_TABLE_DATA && INCLUDE_ACPI_DATA)
21 | #undef INCLUDE_ACPI_DATA
22 | // The STRING (macro) is defined in RevoBoot/i386/config/settings.h
23 | #include STRING(ACPI_DATA_FILE)
24 | #endif
25 |
26 | #if (INJECT_EFI_DEVICE_PROPERTIES && INCLUDE_EFI_DATA)
27 | #undef INCLUDE_EFI_DATA
28 |
29 | #include STRING(EFI_DATA_FILE)
30 | #endif
31 |
32 | #if (USE_STATIC_SMBIOS_DATA && INCLUDE_SMBIOS_DATA)
33 | #undef INCLUDE_SMBIOS_DATA
34 |
35 | #include STRING(SMBIOS_DATA_FILE)
36 | #endif
37 |
--------------------------------------------------------------------------------
/i386/libsa/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # File: RevoBoot/i386/libsa/Makefile
3 | #
4 | # Updates:
5 | #
6 | # - Major cleanup (PikerAlpha, October 2012).
7 | # - Output added for rm/ar/ranlib actions (PikerAlpha, November 2012).
8 | # - Enabled clang compilation (dgsga, November 2012. Credits to Evan Lojewski for original work).
9 | # - Output change and now using libtool instead of ar/ranlib (PikerAlpha, November 2012).
10 | # - efi_table.c renamed to crc32.c (PikerAlpha, November 2012).
11 | #
12 |
13 | include ../MakePaths.dir
14 |
15 | UTILDIR = ../util
16 | LIBSAIODIR = ../libsaio
17 |
18 | OPTIM = -Os -Oz
19 | CFLAGS = $(RC_CFLAGS) $(OPTIM) -arch i386 -g -Wmost -Werror \
20 | -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \
21 | -DSETTINGS_FILE=SETTINGS/$(MAKE_TARGET_MODEL).h \
22 | -fno-stack-protector \
23 | -march=pentium4 -msse2 -msoft-float
24 |
25 | INC = -I. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSAIODIR)
26 |
27 | VPATH = $(OBJROOT):$(SYMROOT)
28 |
29 | SA_OBJS = prf.o printf.o zalloc.o string.o strtol.o crc32.o
30 |
31 | LIBS = libsa.a
32 |
33 | DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
34 |
35 | $(MAKEGOAL): $(DIRS_NEEDED) $(LIBS)
36 |
37 | $(LIBS): $(SA_OBJS)
38 | @if [ -f $(SYMROOT)/$@ ]; then \
39 | echo "\t[RM] $@"; \
40 | rm -f $(SYMROOT)/$@; \
41 | fi;
42 |
43 | @echo "\t[LIBTOOL] $@"
44 | @libtool -o $(SYMROOT)/$@ $^
45 |
46 | include ../MakeInc.dir
47 |
--------------------------------------------------------------------------------
/i386/config/SMBIOS/clean.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Master Chief. All rights reserved.
3 | *
4 | * Note: This is an essential part of the build process for Revolution v0.6.44 and greater.
5 | *
6 | *
7 | * Update: - Cleanups and additional directives added by DHP in 2011.
8 | * - Tip / Note added by DHP (march 2012).
9 | *
10 | * Tip: The idea is to use dynamic SMBIOS generation in RevoBoot only to
11 | * let it strip your factory table, after which you should do this:
12 | *
13 | * 1.) Extract the new OS X compatible SMBIOS table with: tools/smbios2struct
14 | * 2.) Add the data structure to: RevoBoot/i386/config/SMBIOS/data.h
15 | * 3.) Recompile RevoBoot, and be happy with your quicker boot time.
16 | *
17 | * Note: Repeat this procedure after adding memory or other SMBIOS relevant
18 | * hardware changes, like replacing the motherboard and/or processor.
19 | *
20 | */
21 |
22 | //--------------------------------------------------------------- SMBIOS -------------------------------------------------------------------
23 |
24 | #define STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE 0
25 |
26 | #define STATIC_SMBIOS_DMI_STRUCTURE_COUNT 0
27 |
28 | #define STATIC_SMBIOS_DATA \
29 | /* 0x0000 */ // Insert your SMBIOS data here.
30 |
31 | //================================================================= END ====================================================================
32 |
--------------------------------------------------------------------------------
/i386/config/SMBIOS/data-template.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Master Chief. All rights reserved.
3 | *
4 | * Note: This is an essential part of the build process for Revolution v0.6.44 and greater.
5 | *
6 | *
7 | * Update: - Cleanups and additional directives added by DHP in 2011.
8 | * - Tip / Note added by DHP (march 2012).
9 | *
10 | * Tip: The idea is to use dynamic SMBIOS generation in RevoBoot only to
11 | * let it strip your factory table, after which you should do this:
12 | *
13 | * 1.) Extract the new OS X compatible SMBIOS table with: tools/smbios2struct
14 | * 2.) Add the data structure to: RevoBoot/i386/config/SMBIOS/data.h
15 | * 3.) Recompile RevoBoot, and be happy with your quicker boot time.
16 | *
17 | * Note: Repeat this procedure after adding memory or other SMBIOS relevant
18 | * hardware changes, like replacing the motherboard and/or processor.
19 | *
20 | */
21 |
22 | //--------------------------------------------------------------- SMBIOS -------------------------------------------------------------------
23 |
24 | #define STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE 0
25 |
26 | #define STATIC_SMBIOS_DMI_STRUCTURE_COUNT 0
27 |
28 | #define STATIC_SMBIOS_DATA \
29 | /* 0x0000 */ // Insert your SMBIOS data here.
30 |
31 | //================================================================= END ====================================================================
32 |
--------------------------------------------------------------------------------
/i386/libsaio/libsaio.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | * Updates:
25 | * - STATE_SUCCESS moved from boot.h (PikerAlpha, November 2012)
26 | *
27 | */
28 |
29 | #ifndef __LIBSAIO_LIBSAIO_H
30 | #define __LIBSAIO_LIBSAIO_H
31 |
32 | #include "libsa.h"
33 | #include "memory.h"
34 | #include "io_inline.h"
35 | #include "saio_types.h"
36 | #include "saio_internal.h"
37 |
38 | #endif /* !__LIBSAIO_LIBSAIO_H */
39 |
--------------------------------------------------------------------------------
/i386/libsaio/pci.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2008 by Islam M. Ahmed Zaid. All rights reserved.
4 | *
5 | * Refactoring for Revolution done by DHP in 2011.
6 | *
7 | */
8 |
9 | #define READ_BYTE 1
10 | #define READ_WORD 2
11 | #define READ_LONG 4
12 |
13 | #define PCI_ADDR_REG 0xcf8
14 | #define PCI_DATA_REG 0xcfc
15 |
16 | #define PCIADDR(bus, dev, func) (1 << 31) | (bus << 16) | (dev << 11) | (func << 8)
17 |
18 | uint32_t pciConfigRead( uint8_t readType, uint32_t pciAddress, uint8_t pciRegister);
19 |
20 | //==============================================================================
21 | // Note: Currently only called from: i386/libsaio/cpu/dynamic_data.h
22 |
23 | static inline uint8_t pciConfigRead8(uint32_t pciAddress, uint8_t pciRegister)
24 | {
25 | return (uint8_t)pciConfigRead(READ_BYTE, pciAddress, pciRegister);
26 | }
27 |
28 | //==============================================================================
29 | // Note: Currently only called from: i386/libsaio/cpu/dynamic_data.h
30 |
31 |
32 | static inline uint16_t pciConfigRead16(uint32_t pciAddress, uint8_t pciRegister)
33 | {
34 | return (uint16_t)pciConfigRead(READ_WORD, pciAddress, pciRegister);
35 | }
36 |
37 | //==============================================================================
38 | // Note: Currently only called from: i386/libsaio/cpu/dynamic_data.h
39 |
40 | static inline uint32_t pciConfigRead32(uint32_t pciAddress, uint8_t pciRegister)
41 | {
42 | return (uint32_t)pciConfigRead(READ_LONG, pciAddress, pciRegister);
43 | }
44 |
--------------------------------------------------------------------------------
/i386/MakeInc.dir:
--------------------------------------------------------------------------------
1 | #
2 | # File: RevoBoot/i386/MakeInc.dir
3 | #
4 | # Updates:
5 | #
6 | # - Major cleanup (Pike R. Alpha, October 2012).
7 | # - Fixed clang compilation (dgsga, November 2012).
8 | # - Single pass compilation (Pike R. Alpha, November 2012).
9 | # - Removed unused CPPFLAGS (Pike R. Alpha, November 2012).
10 | #
11 |
12 |
13 | # Toggle this as to whether you want a frame pointer (%ebp) to be used. It is
14 | # invaluable for debugging the booter. For example using GDB attached to VMware.
15 | # In fact, it's so invaluable that it's now the default. Not only that but the
16 | # compiler seems to generate slightly smaller code and the real<->prot code
17 | # clearly handles it appropriately so I have no idea why Apple omitted it.
18 | #OMIT_FRAME_POINTER_CFLAG=-fomit-frame-pointer
19 | OMIT_FRAME_POINTER_CFLAG=
20 |
21 |
22 | .SUFFIXES: .s .i .c .o
23 |
24 | .c.o .m.o:
25 | @echo "\t[CC] $<"
26 | @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$@
27 |
28 | $(OBJROOT)/%.o: %.c
29 | @echo "\t[CC] $<"
30 | @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$@
31 |
32 | $(OBJROOT)/%.o: %.m
33 | @echo "\t[M] $<"
34 | @$(CC) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$@
35 |
36 | .s.o:
37 | @echo "\t[AS] $<"
38 | @$(CC) -c $(INC) -arch i386 $< -o $(OBJROOT)/$@
39 |
40 | $(OBJROOT)/boot2.o:
41 | @echo "\t[AS] boot2.s"
42 | @$(CC) -Wa,-n -c $(INC) -arch i386 boot2.s -o $(OBJROOT)/$@
43 |
44 | $(OBJROOT)/%.o: %.s
45 | @echo "\t[AS] $<"
46 | @$(CC) -c $(INC) -arch i386 $< -o $(OBJROOT)/$@
47 |
48 | $(DIRS_NEEDED):
49 | @/bin/mkdir -p $@
50 |
--------------------------------------------------------------------------------
/i:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Bash script to install boot files.
5 | #
6 | #
7 | # Version 1.2 - Copyright (c) 2013-2017 by Pike R. Alpha
8 | #
9 | # Updates:
10 | # - 1.1 Verbose output added.
11 | # - 1.2 Check files/run nasm for missing boot files.
12 | #
13 |
14 | pwd=$(pwd)
15 |
16 | if [ ! -e i386/boot0/boot0 ];
17 | then
18 | cd i386/boot0
19 | echo "Running nasm for boot0 ..."
20 | nasm boot0.s -o boot0
21 | cd "${pwd}"
22 | fi
23 |
24 | if [ ! -e i386/boot0/boot1h ];
25 | then
26 | cd "i386/boot1"
27 | echo "Running nasm for boot1h ..."
28 | nasm boot1h.s -o boot1h
29 | cd "${pwd}"
30 | fi
31 |
32 | let index=0
33 |
34 | if [[ -e "i386/boot0/boot0" && -e "i386/boot1/boot1h" ]];
35 | then
36 | #
37 | # Collect available volume names.
38 | #
39 | cd /Volumes/
40 | targetVolumes=(*)
41 | cd "${pwd}"
42 |
43 | echo "\nAvailable target volumes:\n"
44 |
45 | for volume in "${targetVolumes[@]}"
46 | do
47 | echo "[$index] $volume"
48 | let index++
49 | done
50 |
51 | echo ""
52 |
53 | #
54 | # Ask to select a target volume.
55 | #
56 | read -p "Select a target volume for the boot files: " volumeNumber
57 |
58 | #
59 | # Path to target volume.
60 | #
61 | targetVolume="/Volumes/${targetVolumes[$volumeNumber]}"
62 |
63 | #
64 | # Get device identifier.
65 | #
66 | disk=$(diskutil info "${targetVolume}" | awk '$1$2$3 == "PartofWhole:" { print $4 }')
67 |
68 | sudo ./fdisk440 -f i386/boot0/boot0 -u -y "/dev/r${disk}"
69 |
70 | sudo dd if=i386/boot1/boot1h of="/dev/r${disk}s2"
71 | fi
72 |
--------------------------------------------------------------------------------
/i386/libsaio/hfs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * The contents of this file constitute Original Code as defined in and
7 | * are subject to the Apple Public Source License Version 2.0 (the
8 | * "License"). You may not use this file except in compliance with the
9 | * License. Please obtain a copy of the License at
10 | * http://www.apple.com/publicsource and read it before using this file.
11 | *
12 | * This Original Code and all software distributed under the License are
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 | * License for the specific language governing rights and limitations
18 | * under the License.
19 | *
20 | * @APPLE_LICENSE_HEADER_END@
21 | */
22 |
23 | extern long HFSInitPartition(CICell ih);
24 | extern long HFSLoadFile(CICell ih, char * filePath);
25 | extern long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length);
26 | extern long HFSGetDirEntry(CICell ih, char * dirPath, long * dirIndex, char ** name, long * flags, long * time, FinderInfo * finderInfo, long * infoValid);
27 | extern void HFSGetDescription(CICell ih, char *str, long strMaxLen);
28 | extern long HFSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock);
29 | extern long HFSGetUUID(CICell ih, char *uuidStr);
30 | extern void HFSFree(CICell ih);
31 | extern bool HFSProbe (const void *buf);
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Intermediates/AppleIntelCPUPowerManagementInfo.build/Debug/AppleIntelCPUPowerManagementInfo.build/AppleIntelCPUPowerManagementInfo.dep:
--------------------------------------------------------------------------------
1 | ffffffffffffffffffffffffffffffff 0a61d4086202b8aa99802dd5a07619a2 ffffffffffffffffffffffffffffffff 0 /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext
2 | ffffffffffffffffffffffffffffffff 4b0a69eb869f94de6761d3cbb0fc8dca ffffffffffffffffffffffffffffffff 0 /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/MacOS/AppleIntelCPUPowerManagementInfo
3 | 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
4 | 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
5 | 00000000000000000000000000000000 9a5b9dc0f3dffe1c13b61e6a2886150c ffffffffffffffffffffffffffffffff 0 /Users/dave/RevoBoot/i386/libsaio/cpu/tools/PMinfo/DerivedData/AppleIntelCPUPowerManagementInfo/Build/Products/Debug/AppleIntelCPUPowerManagementInfo.kext/Contents/Info.plist
6 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | - About this project
2 |
3 | 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.
4 |
5 |
6 | - Server.app
7 |
8 | RevoBoot works with the Server app for Mountain Lion (12C60) and Mavericks.
9 |
10 |
11 | - Fusion Drive Support
12 |
13 |
14 | 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
15 |
16 | 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.
17 |
18 |
19 | - NetBoot/NetInstall
20 |
21 | People who have Mountain Lion Server setup and like to install their hack from it... sorry that won't work. The source
22 | code snippets for it have been stripped out (by Master Chief in 2009).
23 |
24 |
25 | - Xcode Support for Mountain Lion, Mavericks and Yosemite
26 |
27 | 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.
28 |
29 |
30 | - Configuration
31 |
32 | 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.
33 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/Info-AppleIntelCPUPowerManagementInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | com.apple.driver.${PRODUCT_NAME:identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | KEXT
17 | CFBundleShortVersionString
18 | 4.0.0
19 | CFBundleSignature
20 | ????
21 | OSBundleRequired
22 | Root
23 | CFBundleVersion
24 | 1
25 | IOKitPersonalities
26 |
27 | AppleIntelCPUPowerManagementInfo
28 |
29 | CFBundleIdentifier
30 | com.apple.driver.${PRODUCT_NAME:identifier}
31 | IOClass
32 | ${PRODUCT_NAME:identifier}
33 | IOMatchCategory
34 | ${PRODUCT_NAME:identifier}
35 | IOProviderClass
36 | IOResources
37 | IOResourceMatch
38 | IOKit
39 | logMSRs
40 |
41 | logIGPU
42 |
43 | logCStates
44 |
45 | logIPGStyle
46 |
47 |
48 |
49 | OSBundleLibraries
50 |
51 | com.apple.kpi.bsd
52 | 10.4
53 | com.apple.kpi.iokit
54 | 10.4
55 | com.apple.kpi.libkern
56 | 10.4
57 | com.apple.kpi.mach
58 | 10.4
59 | com.apple.kpi.unsupported
60 | 10.4
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/Intel/static_data.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 by Master Chief.
3 | *
4 | * Refactored (static and dynamic CPU data gathering) by DHP in 2010.
5 | * Expanded (requestMaxTurbo added) by DHP in May 2011.
6 | * Simplified by DHP in Juni 2011 (thanks to MC and flAked for the idea).
7 | * Bug fix: gPlatform.CPU.minBusRatio/maxBusRatio added by Jeroen (Juni 2011).
8 | * Call to checkFlexRatioMSR added by DHP (August 2011).
9 | */
10 |
11 | #ifndef __LIBSAIO_CPU_STATIC_CPU_DATA_H
12 | #define __LIBSAIO_CPU_STATIC_CPU_DATA_H
13 |
14 | //==============================================================================
15 |
16 | void initCPUStruct(void)
17 | {
18 | gPlatform.CPU.Vendor = CPU_VENDOR_ID; // Used in ACPI/patcher.h
19 |
20 | gPlatform.CPU.Type = STATIC_CPU_Type; // Used in SMBIOS/dynamic_data.h and ACPI/SSDT_PR
21 | // Affects CPU type in 'About This Mac' and System Profiler.
22 |
23 | gPlatform.CPU.NumCores = STATIC_CPU_NumCores; // machdep.cpu.cores_per_package - used in: ACPI/ssdt_pm_generator.h
24 | gPlatform.CPU.NumThreads = STATIC_CPU_NumThreads; // machdep.cpu.logical_per_package - used in: ACPI/ssdt_pm_generator.h
25 |
26 | gPlatform.CPU.FSBFrequency = STATIC_CPU_FSBFrequency; // hw.busfrequency - very important to get this right!
27 |
28 | gPlatform.CPU.QPISpeed = STATIC_CPU_QPISpeed; // QuickPath Interconnect - used in: libsaio/SMBIOS/dynamic_data.h
29 |
30 | #if INTEL_CORE_TECHNOLOGY
31 | uint64_t msr = rdmsr64(MSR_PLATFORM_INFO); // Jeroen: Copied over from i386/libsaio/cpu/Intel/dynamic_data.h
32 |
33 | gPlatform.CPU.MinBusRatio = ((msr >> 40) & 0xff); // Example: 16 with Intel i7-2600 processor.
34 |
35 | gPlatform.CPU.MaxBusRatio = ((msr >> 8) & 0xff); // Example: 34 with Intel i7-2600 processor and 33 with Intel i7-2500.
36 |
37 | // Is Turbo Mode Enabled?
38 | if (!((rdmsr64(IA32_MISC_ENABLES) >> 32) & 0x40)) // Jeroen: Using the same check here as we do in Intel/dynamic_data.h
39 | {
40 | requestMaxTurbo(gPlatform.CPU.MaxBusRatio);
41 | }
42 |
43 | checkFlexRatioMSR();
44 | #endif
45 | }
46 |
47 | #endif /* !__LIBSAIO_CPU_STATIC_CPU_DATA_H */
--------------------------------------------------------------------------------
/i386/libsa/setjmp.s:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 1.1 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 |
25 | #include
26 |
27 | #define O_EDI 0
28 | #define O_ESI 4
29 | #define O_EBX 8
30 | #define O_EBP 12
31 | #define O_ESP 16
32 | #define O_EIP 20
33 |
34 | LEAF(_setjmp, 0)
35 | X_LEAF(_set_label, _setjmp)
36 | movl 4(%esp), %edx // address of save area
37 | movl %edi, O_EDI(%edx)
38 | movl %esi, O_ESI(%edx)
39 | movl %ebx, O_EBX(%edx)
40 | movl %ebp, O_EBP(%edx)
41 | movl %esp, O_ESP(%edx)
42 | movl (%esp), %ecx // %eip (return address)
43 | movl %ecx, O_EIP(%edx)
44 | subl %eax, %eax // retval <- 0
45 | ret
46 |
47 | LEAF(_longjmp, 0)
48 | X_LEAF(_jump_label, _longjmp)
49 | movl 4(%esp), %edx // address of save area
50 | movl O_EDI(%edx), %edi
51 | movl O_ESI(%edx), %esi
52 | movl O_EBX(%edx), %ebx
53 | movl O_EBP(%edx), %ebp
54 | movl O_ESP(%edx), %esp
55 | movl O_EIP(%edx), %eax // %eip (return address)
56 | movl %eax, 0(%esp)
57 | popl %eax // ret addr != 0
58 | jmp *%eax // indirect
59 |
--------------------------------------------------------------------------------
/i386/util/segaddr:
--------------------------------------------------------------------------------
1 | #
2 | # Name : RevoBoot/i386/util/segaddr
3 | # Type : Command line tool (script to replace segsize.c)
4 | # Author : PikerAlpha@yahoo.com (Copyright (c) 2012)
5 | # Version: 1.0
6 | # Release: Initial release on Monday 12 November 2012
7 | #
8 | # Updates:
9 | #
10 |
11 | # The following value is decimal for 0x20200 Used to simplify
12 | # stripping unwanted data from the output of size -m boot.sys
13 | BOOT2ADDR=131584
14 |
15 | # Run for segment address of __INIT (start of /boot file)
16 | if [[ $1 =~ "__INIT" ]];
17 | then
18 | # Decimal values in, Hexadecimal value out
19 | echo ibase=10\; obase=16\; $BOOT2ADDR | bc
20 | # Check if boot.sys exists
21 | else if [ -f ../../sym/i386/boot.sys ];
22 | then
23 | # Example output of: 'size boot.sys'
24 | #
25 | #__TEXT __DATA __OBJC others dec hex
26 | #49376 4544 0 640 54560 d520
27 |
28 | # Start by stripping all unwanted stuff (creates a list):
29 | SIZE_INFO=`size ../../sym/i386/boot.sys | tr -cs "[:digit:]" " "`
30 |
31 | # Giving us:
32 | # 49376 4544 0 640 54560 520
33 | # ^
34 | # |
35 | # Yes, the missing 'd' here is expected behaviour
36 |
37 | # Now we assign values (49376, 4544 and 640) to our locals
38 | TEXT=`echo $SIZE_INFO | awk '{ print $1 }'`
39 | INIT=`echo $SIZE_INFO | awk '{ print $4 }'`
40 |
41 | # Run for segment address of __TEXT (right after __INIT segment in /boot file)
42 | if [[ $1 =~ "__TEXT" ]];
43 | then
44 | # Returns 20480 (131584/0x20200 + 640/0x280)
45 | # Decimal values in, Hexadecimal value out
46 | echo ibase=10\; obase=16\; $BOOT2ADDR + $INIT | bc
47 | else
48 | # Run for segment address of __DATA (right after __TEXT segment in /boot file)
49 | # Returns 2C560 (131584/0x20200 + 4544/0x11C0 + 640/0x280)
50 | # Decimal values in, Hexadecimal value out
51 | echo ibase=10\; obase=16\; $BOOT2ADDR + $INIT + $TEXT | bc
52 | fi
53 | else
54 | echo "Error: boot.sys not found!\n"
55 | fi
56 | fi
--------------------------------------------------------------------------------
/i386/libsa/printf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /*
25 | * Copyright 1993 NeXT, Inc.
26 | * All rights reserved.
27 | */
28 |
29 | #include "libsa.h"
30 |
31 | struct putc_info {
32 | char * str;
33 | char * last_str;
34 | };
35 |
36 | static void sputc(int c, struct putc_info * pi)
37 | {
38 | if (pi->last_str)
39 | if (pi->str == pi->last_str) {
40 | *(pi->str) = '\0';
41 | return;
42 | }
43 | *(pi->str)++ = c;
44 | }
45 |
46 | /*VARARGS1*/
47 | int sprintf(char * str, const char * fmt, ...)
48 | {
49 | va_list ap;
50 | struct putc_info pi;
51 |
52 | va_start(ap, fmt);
53 | pi.str = str;
54 | pi.last_str = 0;
55 | prf(fmt, ap, sputc, &pi);
56 | *pi.str = '\0';
57 | va_end(ap);
58 | return 0;
59 | }
60 |
61 | /*VARARGS1*/
62 | int slvprintf(char * str, int len, const char * fmt, va_list ap)
63 | {
64 | struct putc_info pi;
65 | pi.str = str;
66 | pi.last_str = str + len - 1;
67 | prf(fmt, ap, sputc, &pi);
68 | *pi.str = '\0';
69 | return (pi.str - str);
70 | }
71 |
--------------------------------------------------------------------------------
/c:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Bash script executed from: RevoBoot/i386/boot2/Makefile
5 | #
6 | #
7 | # Version 1.3 - Copyright (c) 2013-2017 by Pike R. Alpha
8 | #
9 | # Updates:
10 | # - v1.1 Improved output (Pike R. Alpha, June 2017).
11 | # - v1.2 Fix typo (Pike R. Alpha, June 2017).
12 | # - Now also asks if you want to reboot.
13 | # - v1.3 Improved volume name support. Thanks to 'M':
14 | # - https://pikeralpha.wordpress.com/2017/06/22/script-to-upgrade-macos-high-sierra-dp1-to-dp2/#comment-10216
15 |
16 | let index=0
17 |
18 | #
19 | # Get currect working directory.
20 | #
21 | workingDirectory=$(pwd)
22 |
23 | #
24 | # Change additional shell optional behavior (expand unmatched names to a null string).
25 | #
26 | shopt -s nullglob
27 |
28 | #
29 | # Change to Volumes folder.
30 | #
31 | cd /Volumes
32 |
33 | #
34 | # Collect available volume names.
35 | #
36 | targetVolumes=(*)
37 |
38 | echo "\nAvailable target volumes:\n"
39 |
40 | for volume in "${targetVolumes[@]}"
41 | do
42 | echo "[$index] $volume"
43 | let index++
44 | done
45 |
46 | echo ""
47 |
48 | #
49 | # Ask to select a target volume.
50 | #
51 | read -p "Select a target volume for the boot file: " volumeNumber
52 |
53 | #
54 | # Verify selection.
55 | #
56 | if [ $volumeNumber -gt $index ];
57 | then
58 | printf "\nError: Invalid Option ($volumeNumber)!\nAborting ...\n"
59 | exit 0
60 | else
61 | cd "${workingDirectory}"
62 | echo "Copying RevoBoot/sym/i386/boot to: /Volumes/${targetVolumes[$volumeNumber]}/"
63 | sudo cp ../../sym/i386/boot "/Volumes/${targetVolumes[$volumeNumber]}/"
64 | #
65 | # Compare files.
66 | #
67 | cmp -s ../../sym/i386/boot /Volumes/${targetVolumes[$volumeNumber]}/boot
68 | #
69 | # Check status (zero is ok).
70 | #
71 | if [[ $? -ne 0 ]];
72 | then
73 | echo "Error: Copying boot file failed!"
74 | else
75 | echo ""
76 | read -p "Do you want to reboot now (y/n) ?" shouldReboot
77 |
78 | if [ $shouldReboot == "y" ];
79 | then
80 | sudo reboot now
81 | else
82 | echo "Done!"
83 | fi
84 | fi
85 | fi
86 |
--------------------------------------------------------------------------------
/i386/libsaio/smbios/essentials.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1998-2009 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * The contents of this file constitute Original Code as defined in and
7 | * are subject to the Apple Public Source License Version 1.1 (the
8 | * "License"). You may not use this file except in compliance with the
9 | * License. Please obtain a copy of the License at
10 | * http://www.apple.com/publicsource and read it before using this file.
11 | *
12 | * This Original Code and all software distributed under the License are
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 | * License for the specific language governing rights and limitations
18 | * under the License.
19 | *
20 | * @APPLE_LICENSE_HEADER_END@
21 | *
22 | * Stripped and rewritten for Revolution by Master Chief in 2009.
23 | * Refactored (dynamic and static SMBIOS data gathering) by DHP in 2010.
24 | * Copyright header error (false copyright claim) fixed by DHP in 2011.
25 | */
26 |
27 | #ifndef __LIBSAIO_SMBIOS_ESSENTIALS_H
28 | #define __LIBSAIO_SMBIOS_ESSENTIALS_H
29 |
30 | // Copied from SMBIOS.h
31 |
32 | typedef UInt8 SMBString;
33 | typedef UInt8 SMBByte;
34 | typedef UInt16 SMBWord;
35 | typedef UInt32 SMBDWord;
36 | typedef UInt64 SMBQWord;
37 |
38 | struct DMIEntryPoint
39 | {
40 | SMBByte anchor[5];
41 | SMBByte checksum;
42 | SMBWord tableLength;
43 | SMBDWord tableAddress;
44 | SMBWord structureCount;
45 | SMBByte bcdRevision;
46 | } __attribute__((packed));
47 |
48 | struct SMBEntryPoint
49 | {
50 | SMBByte anchor[4];
51 | SMBByte checksum;
52 | SMBByte entryPointLength;
53 | SMBByte majorVersion;
54 | SMBByte minorVersion;
55 | SMBWord maxStructureSize;
56 | SMBByte entryPointRevision;
57 | SMBByte formattedArea[5];
58 | struct DMIEntryPoint dmi;
59 | } __attribute__((packed));
60 |
61 | typedef struct SMBStructHeader
62 | {
63 | SMBByte type;
64 | SMBByte length;
65 | SMBWord handle;
66 | } __attribute__((packed)) SMBStructHeader;
67 |
68 | #endif /* !__LIBSAIO_SMBIOS_ESSENTIALS_H */
69 |
--------------------------------------------------------------------------------
/i386/libsaio/sl.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | * Updates:
25 | * - White space changes (PikerAlpha, November 2012)
26 | * - Unused Little Endian macro's removed (PikerAlpha, November 2012)
27 | *
28 | */
29 |
30 | #ifndef __LIBSAIO_SL_H
31 | #define __LIBSAIO_SL_H
32 |
33 | #include
34 | #include
35 | #include
36 | #include "libsaio.h"
37 |
38 | #define SWAP_BE16(x) OSSwapBigToHostInt16(x)
39 | #define SWAP_BE32(x) OSSwapBigToHostInt32(x)
40 | #define SWAP_BE64(x) OSSwapBigToHostInt64(x)
41 |
42 | // File Permissions and Types
43 | enum
44 | {
45 | kPermOtherExecute = 1 << 0,
46 | kPermOtherWrite = 1 << 1,
47 | kPermOtherRead = 1 << 2,
48 | kPermGroupExecute = 1 << 3,
49 | kPermGroupWrite = 1 << 4,
50 | kPermGroupRead = 1 << 5,
51 | kPermOwnerExecute = 1 << 6,
52 | kPermOwnerWrite = 1 << 7,
53 | kPermOwnerRead = 1 << 8,
54 | kPermMask = 0x1FF,
55 | kOwnerNotRoot = 1 << 9,
56 | kFileTypeUnknown = 0x0 << 16,
57 | kFileTypeFlat = 0x1 << 16,
58 | kFileTypeDirectory = 0x2 << 16,
59 | kFileTypeLink = 0x3 << 16,
60 | kFileTypeMask = 0x3 << 16
61 | };
62 |
63 | #define Seek(c, p) diskSeek(c, p);
64 | #define Read(c, a, l) diskRead(c, a, l);
65 |
66 | extern void * gFSLoadAddress;
67 |
68 | #endif /* !__LIBSAIO_SL_H */
69 |
--------------------------------------------------------------------------------
/i386/libsaio/device_tree.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 |
25 | #ifndef __DEVICE_TREE_H
26 | #define __DEVICE_TREE_H
27 |
28 | #include
29 | #include
30 |
31 |
32 | //==============================================================================
33 |
34 | typedef struct _Property
35 | {
36 | const char * name;
37 | uint32_t length;
38 | void * value;
39 | struct _Property * next;
40 | } Property;
41 |
42 |
43 | //==============================================================================
44 |
45 | typedef struct _Node
46 | {
47 | struct _Property * properties;
48 | struct _Property * last_prop;
49 | struct _Node * children;
50 | struct _Node * next;
51 | } Node;
52 |
53 | extern Property * DT__AddProperty(Node *node, const char *name, uint32_t length, void *value);
54 |
55 | extern Node * DT__AddChild(Node *parent, const char *name);
56 |
57 | Node * DT__FindNode(const char *path, bool createIfMissing);
58 |
59 | extern void DT__FreeProperty(Property *prop);
60 |
61 | extern void DT__FreeNode(Node *node);
62 |
63 | extern char * DT__GetName(Node *node);
64 |
65 | void DT__Initialize(void);
66 |
67 | // Free up memory used by in-memory representation of device tree.
68 | extern void DT__Finalize(void);
69 |
70 | void DT__FlattenDeviceTree(void **result, uint32_t *length);
71 |
72 | #endif /* __DEVICE_TREE_H */
73 |
--------------------------------------------------------------------------------
/i386/libsaio/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # File: RevoBoot/i386/libsaio/Makefile
3 | #
4 | # Updates:
5 | #
6 | # - Major cleanup (Pike R. Alpha, October 2012).
7 | # - DMAKE_TARGET_MODEL added (Pike R. Alpha, October 2012).
8 | # - Static data selectors added (Pike R. Alpha, October 2012).
9 | # - STATIC_DATA_FILENAME added (Pike R> Alpha, October 2012).
10 | # - Output added for rm/ar/ranlib actions (Pike R> Alpha, November 2012).
11 | # - Enabled clang compilation (dgsga, PikerAlpha, November 2012. Credits to Evan Lojewski for original work).
12 | # - Output change and now using libtool instead of ar/ranlib (Pike R. Alpha, November 2012).
13 | # - SAIO_OBJS changed / base64.o added (Pike R. Alpha, November 2012).
14 | # - MAKE_TARGET_OS_VER added (Pike R. Alpha, June 2014).
15 | # - patcher.c added (Pike R. Alpha, August 2016).
16 |
17 | include ../MakePaths.dir
18 |
19 | UTILDIR = ../util
20 | LIBSADIR = ../libsa
21 |
22 | OPTIM = -Os -Oz
23 | DEBUG = -DNOTHING
24 |
25 | CFLAGS = $(RC_CFLAGS) $(OPTIM) -arch i386 -g -Wmost \
26 | -D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \
27 | -DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \
28 | -DREVOBOOT_VERSION_INFO=\"RevoBoot\ v$(PRODUCT_VERSION_NUMBER)\" \
29 | -DMAKE_TARGET_OS=$(PRODUCT_OS_TARGET) \
30 | -DMAKE_TARGET_OS_VER=$(PRODUCT_OS_TARGET_VERSION) \
31 | -DSETTINGS_FILE=SETTINGS/$(MAKE_TARGET_MODEL).h \
32 | -DSTATIC_DATA_FILENAME=$(MAKE_TARGET_MODEL).bin \
33 | -DACPI_DATA_FILE=../../config/$(MAKE_ACPI_DATA_FILE) \
34 | -DEFI_DATA_FILE=../config/$(MAKE_EFI_DATA_FILE) \
35 | -DSMBIOS_DATA_FILE=../config/$(MAKE_SMBIOS_DATA_FILE) \
36 | -fno-builtin -static $(OMIT_FRAME_POINTER_CFLAG) \
37 | -fno-stack-protector \
38 | -march=pentium4 -msse2 -msoft-float
39 |
40 | INC = -I. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSADIR)
41 |
42 | VPATH = $(OBJROOT):$(SYMROOT)
43 |
44 | SAIO_OBJS = table.o asm.o bios.o biosfn.o guid.o disk.o sys.o cache.o \
45 | bootstruct.o base64.o stringTable.o patcher.o load.o pci.o allocate.o \
46 | vbe.o hfs.o hfs_compare.o xml.o md5c.o device_tree.o cpu.o \
47 | platform.o acpi.o smbios.o efi.o console.o
48 |
49 | LIBS = libsaio.a
50 |
51 | DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
52 |
53 | $(MAKEGOAL): $(DIRS_NEEDED) libsaio.h $(LIBS)
54 |
55 | $(LIBS): $(SAIO_OBJS)
56 | @if [ -f $(SYMROOT)/$@ ]; then \
57 | echo "\t[RM] $@"; \
58 | rm -f $(SYMROOT)/$@; \
59 | fi;
60 |
61 | @echo "\t[LIBTOOL] $@"
62 | @libtool -o $(SYMROOT)/$@ $^
63 |
64 | include ../MakeInc.dir
65 |
--------------------------------------------------------------------------------
/i386/libsaio/xml.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 |
25 | #ifndef __LIBSAIO_XML_H
26 | #define __LIBSAIO_XML_H
27 |
28 | enum
29 | {
30 | kTagTypeNone = 0,
31 | kTagTypeDict,
32 | kTagTypeKey,
33 | kTagTypeString,
34 | kTagTypeInteger,
35 | kTagTypeData,
36 | kTagTypeDate,
37 | kTagTypeFalse,
38 | kTagTypeTrue,
39 | kTagTypeArray
40 | };
41 |
42 | #define kXMLTagPList "plist "
43 | #define kXMLTagDict "dict"
44 | #define kXMLTagKey "key"
45 | #define kXMLTagString "string"
46 | #define kXMLTagInteger "integer"
47 | #define kXMLTagData "data"
48 | #define kXMLTagDate "date"
49 | #define kXMLTagFalse "false/"
50 | #define kXMLTagTrue "true/"
51 | #define kXMLTagArray "array"
52 |
53 |
54 | #define kPropCFBundleIdentifier ("CFBundleIdentifier")
55 | #define kPropCFBundleExecutable ("CFBundleExecutable")
56 | #define kPropOSBundleRequired ("OSBundleRequired")
57 | #define kPropOSBundleLibraries ("OSBundleLibraries")
58 | #define kPropIOKitPersonalities ("IOKitPersonalities")
59 | #define kPropIONameMatch ("IONameMatch")
60 |
61 | extern long gImageFirstBootXAddr;
62 | extern long gImageLastKernelAddr;
63 |
64 | TagPtr XMLGetProperty(TagPtr dict, const char * key);
65 |
66 | void XMLFreeTag(TagPtr tag);
67 | long XMLParseFile(char * buffer, TagPtr * dict);
68 | long XMLParseNextTag(char *buffer, TagPtr *tag);
69 |
70 | #endif /* __LIBSAIO_XML_H */
71 |
--------------------------------------------------------------------------------
/i386/libsaio/acpi/static_data.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Static data overrides for ACPI tables. Copyright 2009 by Master Chief.
3 | *
4 | * Updates:
5 | * - Refactored (dynamic and static ACPI patching) by DHP in 2010/2011.
6 | * - Data selector moved over from RevoBoot/i386/config/data.h (PikerAlpha, October 2012).
7 | */
8 |
9 | #ifndef __LIBSAIO_ACPI_STATIC_DATA_H
10 | #define __LIBSAIO_ACPI_STATIC_DATA_H
11 |
12 | // The STRING (macro) is defined in RevoBoot/i386/config/settings.h
13 | #include STRING(ACPI_DATA_FILE)
14 |
15 | // The STATIC_xxx_TABLE_DATA's here will get replaced with the data from RevoBoot/i386/config/ACPI/[default/MacmodelNN].h
16 |
17 | static uint32_t APIC_Table[] =
18 | {
19 | #if STATIC_APIC_TABLE_INJECTION
20 | STATIC_APIC_TABLE_DATA
21 | #endif
22 | };
23 |
24 | static uint32_t DMAR_Table[] =
25 | {
26 | #if STATIC_DMAR_TABLE_INJECTION
27 | STATIC_DMAR_TABLE_DATA
28 | #endif
29 | };
30 |
31 | static uint32_t ECDT_Table[] =
32 | {
33 | #if STATIC_ECDT_TABLE_INJECTION
34 | STATIC_ECDT_TABLE_DATA
35 | #endif
36 | };
37 |
38 |
39 | static uint32_t HPET_Table[] =
40 | {
41 | #if STATIC_HPET_TABLE_INJECTION
42 | STATIC_HPET_TABLE_DATA
43 | #endif
44 | };
45 |
46 |
47 | static uint32_t MCFG_Table[] =
48 | {
49 | #if STATIC_MCFG_TABLE_INJECTION
50 | STATIC_MCFG_TABLE_DATA
51 | #endif
52 | };
53 |
54 |
55 | static uint32_t SBST_Table[] =
56 | {
57 | #if STATIC_SBST_TABLE_INJECTION
58 | STATIC_SBST_TABLE_DATA
59 | #endif
60 | };
61 |
62 |
63 | static uint32_t SSDT_Table[] =
64 | {
65 | #if STATIC_SSDT_TABLE_INJECTION
66 | STATIC_SSDT_TABLE_DATA
67 | #endif
68 | };
69 |
70 |
71 | // Static data overrides for special-essential tables.
72 |
73 | static uint32_t DSDT_Table[] =
74 | {
75 | #if STATIC_DSDT_TABLE_INJECTION
76 | STATIC_DSDT_TABLE_DATA
77 | #endif
78 | };
79 |
80 |
81 | static uint32_t FACS_Table[] =
82 | {
83 | #if STATIC_FACS_TABLE_INJECTION
84 | STATIC_FACS_TABLE_DATA
85 | #endif
86 | };
87 |
88 |
89 | // Static data overrides for optional tables.
90 |
91 | static uint32_t APIC2_Table[] =
92 | {
93 | #if STATIC_APIC2_TABLE_INJECTION
94 | STATIC_APIC2_TABLE_DATA
95 | #endif
96 | };
97 |
98 |
99 |
100 | static uint32_t SSDT_GPU_Table[] =
101 | {
102 | #if STATIC_SSDT_GPU_TABLE_INJECTION
103 | STATIC_SSDT_GPU_TABLE_DATA
104 | #endif
105 | };
106 |
107 |
108 | static uint32_t SSDT_PR_Table[] =
109 | {
110 | #if STATIC_SSDT_PR_TABLE_INJECTION
111 | STATIC_SSDT_PR_TABLE_DATA
112 | #endif
113 | };
114 |
115 |
116 | static uint32_t SSDT_SATA_Table[] =
117 | {
118 | #if STATIC_SSDT_SATA_TABLE_INJECTION
119 | STATIC_SSDT_SATA_TABLE_DATA
120 | #endif
121 | };
122 |
123 |
124 | static uint32_t SSDT_USB_Table[] =
125 | {
126 | #if STATIC_SSDT_USB_TABLE_INJECTION
127 | STATIC_SSDT_USB_TABLE_DATA
128 | #endif
129 | };
130 |
131 |
132 | #endif /* !__LIBSAIO_ACPI_STATIC_DATA_H */
133 |
--------------------------------------------------------------------------------
/i386/libsaio/io_inline.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /*
25 | * Copyright (c) 1992 NeXT Computer, Inc.
26 | *
27 | * Inlines for io space access.
28 | *
29 | * HISTORY
30 | *
31 | * 20 May 1992 ? at NeXT
32 | * Created.
33 | */
34 |
35 | #ifndef __LIBSAIO_IO_INLINE_H
36 | #define __LIBSAIO_IO_INLINE_H
37 |
38 | /*
39 | *############################################################################
40 | *
41 | * x86 IN/OUT I/O inline functions.
42 | *
43 | * IN : inb, inw, inl
44 | * IN(port)
45 | *
46 | * OUT: outb, outw, outl
47 | * OUT(port, data)
48 | *
49 | *############################################################################
50 | */
51 |
52 | #define __IN(s, u) \
53 | static inline unsigned u \
54 | in##s(unsigned short port) \
55 | { \
56 | unsigned u data; \
57 | asm volatile ( \
58 | "in" #s " %1,%0" \
59 | : "=a" (data) \
60 | : "d" (port)); \
61 | return (data); \
62 | }
63 |
64 | #define __OUT(s, u) \
65 | static inline void \
66 | out##s(unsigned short port, unsigned u data) \
67 | { \
68 | asm volatile ( \
69 | "out" #s " %1,%0" \
70 | : \
71 | : "d" (port), "a" (data)); \
72 | }
73 |
74 | __IN(b, char) /* inb() */
75 | __IN(w, short) /* inw() */
76 | __IN(l, long) /* inl() */
77 |
78 | __OUT(b, char) /* outb() */
79 | __OUT(w, short) /* outw() */
80 | __OUT(l, long) /* outl() */
81 |
82 | #endif /* !__LIBSAIO_IO_INLINE_H */
83 |
--------------------------------------------------------------------------------
/i386/config/README:
--------------------------------------------------------------------------------
1 | RevoBoot comes with configuration templates of which some you need to change:
2 |
3 |
4 | ACPI/data-template.h
5 | --------------------
6 |
7 | RevoBoot's build process will copy this file for new configurations to the target modelidentifier
8 | and use it, but only when you didn't already do this yourself. Make all required changes in
9 | the new file only or it won't be used at all.
10 |
11 | Note: We use 'factory tables' for the original ACPI tables in the BIOS and 'modified'
12 | for new/modified ACPI tables.
13 |
14 |
15 | EFI/data-template.h
16 | -------------------
17 |
18 | RevoBoot's build process will copy this file for new configurations to the target modelidentifier
19 | and use it, but only when you didn't already do this yourself. Make all required changes in
20 | the new file only or it won't be used at all.
21 |
22 | Note: A simple HOWTO will (hopefully) soon be added to the EFI directory.
23 |
24 |
25 | SMBIOS/data-template.h
26 | ----------------------
27 |
28 | RevoBoot's build process will copy this file for new configurations to the target modelidentifier
29 | and use it, but only when you didn't already do this yourself. Make all required changes in
30 | the new file only or it won't be used at all.
31 |
32 | Note: You can extract the SMBIOS table data with: /smbios/tools/smbios2struct2
33 | Make instruction are included in the source code.
34 |
35 |
36 | settings.h
37 | ----------
38 |
39 | This file selects the target settings file based on the specified model identifier. Using
40 | make MODEL=Macmini51 or use ./r Macmini51 (examples) makes it select RevoBoot/i386/config/SETTINGS/Macmini51.h
41 | All future changes need to be made in this file, or they won't be picked up.
42 |
43 |
44 | settings-template.h
45 | -------------------
46 |
47 | RevoBoot's build process first checks RevoBoot/i386/config/SETTINGS/*.h per target model identifier
48 | (example: Macmini51,h) and use it, or copies RevoBoot/i386/config/settings-template.h to the target model
49 | identifier (when the file is missing) to prevent build errors.
50 |
51 | People with working RevoBoot configurations can simply copy their settings.h to SETTINGS/[your model].h
52 | This will allow the RevoBoot build process to compile without errors, but make sure to use the latest
53 | preprocessor options.
54 |
55 | Important: Open settings-template.h and search for:
56 |
57 | #define STATIC_NVRAM_ROM { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0xNN, 0xNN, 0xNN, 0xNN, 0xNN, 0xNN } // Example only!
58 | // 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
59 | // Note: Use your MAC address for the last six bytes!
60 |
61 | You must change this, or RevoBoot won't compile!
62 |
63 | ACPI/EFI/SMBIOS/data.h
64 | ----------------------
65 |
66 | These are RevoBoot's main data selector files to support (optional) static data.
67 |
68 | Note: Do not change this file!
69 |
70 |
--------------------------------------------------------------------------------
/i386/libsaio/efi/EfiError.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
4 | This program and the accompanying materials
5 | are licensed and made available under the terms and conditions of the BSD License
6 | which accompanies this distribution. The full text of the license may be found at
7 | http://opensource.org/licenses/bsd-license.php
8 |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 |
12 | Module Name:
13 |
14 | EfiError.h
15 |
16 | Abstract:
17 |
18 | EFI error levels and their associated defines
19 |
20 | --*/
21 |
22 | #ifndef _EFI_ERROR_H_
23 | #define _EFI_ERROR_H_
24 |
25 | //
26 | // Set the upper bit to indicate EFI Error.
27 | //
28 | #define EFIERR(a) (EFI_MAX_BIT | (a))
29 |
30 | #define EFIWARN(a) (a)
31 | #define EFI_ERROR(a) (((INTN) (a)) < 0)
32 |
33 | #define EFI_SUCCESS 0
34 | #define EFI_LOAD_ERROR EFIERR (1)
35 | #define EFI_INVALID_PARAMETER EFIERR (2)
36 | #define EFI_UNSUPPORTED EFIERR (3)
37 | #define EFI_BAD_BUFFER_SIZE EFIERR (4)
38 | #define EFI_BUFFER_TOO_SMALL EFIERR (5)
39 | #define EFI_NOT_READY EFIERR (6)
40 | #define EFI_DEVICE_ERROR EFIERR (7)
41 | #define EFI_WRITE_PROTECTED EFIERR (8)
42 | #define EFI_OUT_OF_RESOURCES EFIERR (9)
43 | #define EFI_VOLUME_CORRUPTED EFIERR (10)
44 | #define EFI_VOLUME_FULL EFIERR (11)
45 | #define EFI_NO_MEDIA EFIERR (12)
46 | #define EFI_MEDIA_CHANGED EFIERR (13)
47 | #define EFI_NOT_FOUND EFIERR (14)
48 | #define EFI_ACCESS_DENIED EFIERR (15)
49 | #define EFI_NO_RESPONSE EFIERR (16)
50 | #define EFI_NO_MAPPING EFIERR (17)
51 | #define EFI_TIMEOUT EFIERR (18)
52 | #define EFI_NOT_STARTED EFIERR (19)
53 | #define EFI_ALREADY_STARTED EFIERR (20)
54 | #define EFI_ABORTED EFIERR (21)
55 | #define EFI_ICMP_ERROR EFIERR (22)
56 | #define EFI_TFTP_ERROR EFIERR (23)
57 | #define EFI_PROTOCOL_ERROR EFIERR (24)
58 | #define EFI_INCOMPATIBLE_VERSION EFIERR (25)
59 | #define EFI_SECURITY_VIOLATION EFIERR (26)
60 | #define EFI_CRC_ERROR EFIERR (27)
61 | #define EFI_END_OF_MEDIA EFIERR (28)
62 | #define EFI_END_OF_FILE EFIERR (31)
63 | #define EFI_INVALID_LANGUAGE EFIERR (32)
64 |
65 | #define EFI_WARN_UNKNOWN_GLYPH EFIWARN (1)
66 | #define EFI_WARN_DELETE_FAILURE EFIWARN (2)
67 | #define EFI_WARN_WRITE_FAILURE EFIWARN (3)
68 | #define EFI_WARN_BUFFER_TOO_SMALL EFIWARN (4)
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/i386/libsaio/smbios/static_data.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 by Master Chief.
3 | *
4 | * Updates:
5 | * - Dynamic and static SMBIOS data gathering added by DHP in 2010.
6 | * - New path for static EFI data (PikerAlpha, October 2012).
7 | * - Optionally check /Extra/SMBIOS/[MacModelNN.bin] for static SMBIOS data (PikerAlpha, October 2012).
8 | * - Get maxStructureSize/structureCount from factory EPS (PikerAlpha, October 2012).
9 | * - Cleanups/simplification of code (Pike, April 2013).
10 | * - iMessage fix for static SMBIOS data / init gPlatform.UUID from static data (Pike, April 2013).
11 | *
12 | * Credits:
13 | * - blackosx, DB1, dgsga, FKA, humph, scrax and STLVNUB (testers).
14 | */
15 |
16 | #ifndef __LIBSAIO_SMBIOS_STATIC_DATA_H
17 | #define __LIBSAIO_SMBIOS_STATIC_DATA_H
18 |
19 | #include "essentials.h"
20 |
21 | int offset = 0;
22 | int tableLength = 0;
23 |
24 | long fileSize = 0L;
25 |
26 | void * staticSMBIOSData = (void *)kLoadAddr;
27 |
28 | #if LOAD_MODEL_SPECIFIC_SMBIOS_DATA
29 | char dirSpec[32] = "";
30 |
31 | sprintf(dirSpec, "/Extra/SMBIOS/%s.bin", COMMA_STRIPPED_MODEL_ID);
32 | _SMBIOS_DEBUG_DUMP("Loading: %s", dirSpec);
33 | fileSize = loadBinaryData(dirSpec, &staticSMBIOSData);
34 |
35 | if (fileSize > 0)
36 | {
37 | tableLength = fileSize;
38 | _SMBIOS_DEBUG_DUMP("\n");
39 | }
40 | else // File not found. Use static data defined in: RevoBoot/i386/config/SMBIOS/MacModelNN.h
41 | {
42 | _SMBIOS_DEBUG_DUMP("Error: File not found!\n");
43 | }
44 | #endif /* LOAD_MODEL_SPECIFIC_SMBIOS_DATA */
45 |
46 | if (fileSize == 0)
47 | {
48 | // The STRING (macro) is defined in RevoBoot/i386/config/settings.h
49 | #include STRING(SMBIOS_DATA_FILE)
50 |
51 | static uint32_t SMBIOS_Table[] =
52 | {
53 | // Replaced with data from: RevoBoot/i386/config/SMBIOS/MacModelNN.h
54 | STATIC_SMBIOS_DATA
55 | };
56 |
57 | tableLength = sizeof(SMBIOS_Table);
58 | staticSMBIOSData = SMBIOS_Table;
59 | _SMBIOS_DEBUG_DUMP("Using statically linked SMBIOS data: %d bytes\n", tableLength);
60 | }
61 |
62 | if (*(uint32_t *) staticSMBIOSData == 0x44495555) // "UUID" in little endian.
63 | {
64 | offset = 20; // "UUID" + 16 bytes data
65 | }
66 |
67 | // Copy the static SMBIOS data into the newly allocated memory page. Right after the new EPS.
68 | memcpy((kernelMemory + sizeof(* newEPS)), staticSMBIOSData + offset, (tableLength - offset));
69 |
70 | #ifdef SMB_STATIC_SYSTEM_UUID
71 | // This enables you to override the factory UUID from the settings file.
72 | static unsigned char SMB_SYSTEM_UUID[] = SMB_STATIC_SYSTEM_UUID;
73 |
74 | // Replace factory UUID with the one specified in: RevoBoot/i386/config/SETTINGS/MacModelNN.h
75 | memcpy(gPlatform.UUID, SMB_SYSTEM_UUID, 16);
76 | #else
77 | if (offset)
78 | {
79 | // Get UUID from (dynamically loaded) SMBIOS data (/Extra/SMBIOS/MacModelNN.bin)
80 | memcpy(gPlatform.UUID, staticSMBIOSData + 4, 16);
81 | }
82 | #endif
83 |
84 | #endif /* !__LIBSAIO_SMBIOS_STATIC_DATA_H */
85 |
--------------------------------------------------------------------------------
/i386/boot2/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # File: RevoBoot/i386/boot2/Makefile
3 | #
4 | # Updates:
5 | #
6 | # - Support for self compiled libcc_kext.a added (PikerAlpha, October 2012).
7 | # - Major cleanup (PikerAlpha, October 2012).
8 | # - Fixed clang compilation (dgsga, November 2012. Credits to Evan Lojewski for original work).
9 | # - BOOT2ADDR moved to RevoBoot/i386/util/segsize.c (PikerAlpha, November 2012).
10 | # - Simplified calls to RevoBoot/i386/util/segsize (PikerAlpha, November 2012).
11 | # - Reformatted output, include directory dependency lifted (PikerAlpha, November 2012).
12 | # - BOOT2ADDR removed, static compilation and some white space changes (PikerAlpha, November 2012).
13 | #
14 |
15 |
16 | include ../MakePaths.dir
17 |
18 | OPTIM = -Os -Oz
19 | CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror \
20 | -fno-builtin -DSAIO_INTERNAL_USER -static $(OMIT_FRAME_POINTER_CFLAG) \
21 | -DMAKE_TARGET_OS=$(PRODUCT_OS_TARGET) \
22 | -DSETTINGS_FILE=SETTINGS/$(MAKE_TARGET_MODEL).h \
23 | -fno-stack-protector \
24 | -march=pentium4 -msse2 -msoft-float
25 |
26 | LIBSADIR = ../libsa
27 | LIBSAIODIR = ../libsaio
28 | UTILDIR = ../util
29 |
30 | INC = -I. -I.. -I$(SYMROOT) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(UTILDIR)
31 | LIBS = -L$(SYMROOT) -lsaio -lsa
32 | LIBDEP = $(SYMROOT)/libsaio.a $(SYMROOT)/libsa.a
33 |
34 | VPATH = $(OBJROOT):$(SYMROOT)
35 |
36 | #
37 | # The order of object filenames below is important;
38 | #
39 | OBJS = boot2.o boot.o bootlogo.o graphics.o drivers.o options.o lzss.o lzvn.o
40 |
41 | DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
42 |
43 | #
44 | # Set maximum size of the booter to 128KB (should be more than sufficient).
45 | #
46 | MAXBOOTSIZE = 131072
47 |
48 | $(MAKEGOAL): $(DIRS_NEEDED) boot
49 |
50 | boot: $(OBJS)
51 |
52 | @echo "\t[LD] boot.sys"
53 | @$(CC) -nostdlib -arch i386 -static \
54 | -Wl,-preload \
55 | -Wl,-pie \
56 | -Wl,-segalign,20 \
57 | -Wl,-read_only_relocs,suppress \
58 | -lcc_kext \
59 | $(filter %.o,$^) $(LIBS) -o ${SYMROOT}/$@.sys
60 |
61 | @echo "\t[LD] boot.sys"
62 | @$(CC) -nostdlib -arch i386 -static -v \
63 | -Wl,-preload \
64 | -Wl,-pie \
65 | -Wl,-segalign,20 \
66 | -Wl,-segaddr,__INIT,`$(UTILDIR)/segaddr __INIT` \
67 | -Wl,-segaddr,__TEXT,`$(UTILDIR)/segaddr __TEXT` \
68 | -Wl,-segaddr,__DATA,`$(UTILDIR)/segaddr __DATA` \
69 | -Wl,-read_only_relocs,suppress \
70 | -lcc_kext \
71 | $(filter %.o,$^) $(LIBS) -o ${SYMROOT}/$@.sys
72 |
73 | @echo "\t[MACHOCONV] boot"
74 | @$(SYMROOT)/machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot
75 |
76 | @echo "============================================"
77 | @size $(SYMROOT)/boot.sys
78 |
79 | @( size=`ls -l $(SYMROOT)/boot | awk '{ print $$5}'` ; \
80 | if expr "$$size" ">" "$(MAXBOOTSIZE)" > /dev/null ;\
81 | then \
82 | echo "Boot ($$size) larger than $(MAXBOOTSIZE) bytes" ;\
83 | rm $(SYMROOT)/boot ;\
84 | exit 1;\
85 | else \
86 | echo "=========== boot is $$size bytes ============"; \
87 | fi) \
88 |
89 | @../../c
90 |
91 | include ../MakeInc.dir
92 |
--------------------------------------------------------------------------------
/i386/libsaio/allocate.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | *
25 | * Updates:
26 | * - Layout only change (PikerAlpha, November 2012)
27 | *
28 | */
29 |
30 | #include "sl.h"
31 | #include "saio_internal.h"
32 | #include "bootstruct.h"
33 | #include "device_tree.h"
34 | #include "platform.h"
35 |
36 | #define kPageSize 4096
37 | #define RoundPage(x) ((((unsigned)(x)) + kPageSize - 1) & ~(kPageSize - 1))
38 |
39 |
40 | //==============================================================================
41 |
42 | long AllocateMemoryRange(char * rangeName, long start, long length)
43 | {
44 | if (rangeName)
45 | {
46 | char *nameBuf = malloc(strlen(rangeName) + 1);
47 |
48 | if (nameBuf)
49 | {
50 | strcpy(nameBuf, rangeName);
51 | uint32_t *buffer = malloc(2 * sizeof(uint32_t));
52 |
53 | if (buffer)
54 | {
55 | buffer[0] = start;
56 | buffer[1] = length;
57 | #if DEBUG
58 | printf("AllocateMemoryRange(%s) @0x%lx, length 0x%lx\n", rangeName, start, length);
59 | #endif
60 | DT__AddProperty(gPlatform.EFI.Nodes.MemoryMap, nameBuf, 2 * sizeof(uint32_t), (char *)buffer);
61 |
62 | return 0;
63 | }
64 |
65 | free(nameBuf);
66 | }
67 | }
68 |
69 | return -1;
70 | }
71 |
72 |
73 | //==============================================================================
74 |
75 | long AllocateKernelMemory(long inSize)
76 | {
77 | if (gPlatform.LastKernelAddr == 0)
78 | {
79 | gPlatform.LastKernelAddr = RoundPage(bootArgs->kaddr + bootArgs->ksize);
80 | }
81 |
82 | long address = gPlatform.LastKernelAddr;
83 | gPlatform.LastKernelAddr += RoundPage(inSize);
84 |
85 | if (gPlatform.LastKernelAddr >= (KERNEL_ADDR + KERNEL_LEN))
86 | {
87 | stop ("AllocateKernelMemory error");
88 | }
89 |
90 | bootArgs->ksize = gPlatform.LastKernelAddr - bootArgs->kaddr;
91 |
92 | #if DEBUG
93 | printf("AllocateKernelMemory: 0x%lx - 0x%lx\n", address, inSize);
94 | sleep(3);
95 | #endif
96 |
97 | return address;
98 | }
99 |
--------------------------------------------------------------------------------
/i386/libsaio/acpi/Tools/extractACPITables.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Name : extractACPITables.c
3 | * Version : 0.3
4 | * Type : Command line tool
5 | * Copyright : Pike R. Alpha (c) September 2014
6 | * Description : ACPI table extractor.
7 | *
8 | * Usage : ./extractACPITables (writes all tables to: /tmp/XXXX.aml)
9 | * : ./extractACPITables DSDT (writes DSDT.aml to: /tmp/DSDT.aml)
10 | * : ./extractACPITables SSDT (writes all SSDT tables to: /tmp/SSDT.aml)
11 | * : ./extractACPITables SSDT-2 (writes SSDT-2.aml to: /tmp/SSDT-2.aml)
12 | *
13 | * Compile with : cc -O2 extractACPITables.c -o extractACPITables -Wall -framework IOKit -framework CoreFoundation
14 | *
15 | * Updates:
16 | * v0.1 initial version.
17 | * v0.2 renamed from acpiTableExtract.c to extractAcpiTables.c
18 | * v0.3 check arguments, use argv[1] as target table.
19 | */
20 |
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | //==============================================================================
27 |
28 | int main(int argc, char * argv[])
29 | {
30 | char dirspec[32];
31 | char tableName[8];
32 | int filedesc, status = 0;
33 | bool allTables = true;
34 |
35 | io_service_t service;
36 | CFDictionaryRef tableDictionary;
37 |
38 | //==================================================================================
39 |
40 | if (argc == 2)
41 | {
42 | allTables = false;
43 | }
44 |
45 | if ((service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("AppleACPIPlatformExpert"))))
46 | {
47 | if ((tableDictionary = (CFDictionaryRef) IORegistryEntryCreateCFProperty(service, CFSTR("ACPI Tables"), kCFAllocatorDefault, kNilOptions)))
48 | {
49 | CFIndex tableCount = CFDictionaryGetCount(tableDictionary);
50 |
51 | CFStringRef tableNames[tableCount];
52 | CFDataRef tableData[tableCount];
53 |
54 | CFDictionaryGetKeysAndValues(tableDictionary, (const void **)&tableNames, (const void **)&tableData);
55 |
56 | for (CFIndex i = 0; i < tableCount; i++)
57 | {
58 | UInt8 * buffer = (UInt8 *) CFDataGetBytePtr(tableData[i]);
59 | UInt32 numBytes = (UInt32) CFDataGetLength(tableData[i]);
60 |
61 | strcpy(tableName, CFStringGetCStringPtr(tableNames[i], kCFStringEncodingMacRoman));
62 |
63 | if (allTables || (strncasecmp(argv[1], (char *)tableName, strlen(argv[1])) == 0))
64 | {
65 | sprintf(dirspec, "/tmp/%s.aml", tableName);
66 |
67 | if ((filedesc = open(dirspec, O_WRONLY|O_CREAT|O_TRUNC, 0644)) != -1)
68 | {
69 | write(filedesc, buffer, numBytes);
70 | close(filedesc);
71 | }
72 | else
73 | {
74 | status = -3;
75 | }
76 | }
77 | }
78 |
79 | CFRelease(tableDictionary);
80 | }
81 | else
82 | {
83 | status = -2;
84 | }
85 |
86 | IOObjectRelease(service);
87 |
88 | // 0 = success.
89 | // -2 = tableDictionary is NULL.
90 | // -3 = one or more writes failed.
91 | exit(status);
92 | }
93 |
94 | exit(-1); // error (service is NULL).
95 | }
96 |
--------------------------------------------------------------------------------
/i386/config/ACPI/clean.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Master Chief. All rights reserved.
3 | *
4 | * Note: This is an essential part of the build process for Revolution v0.6.43 and greater.
5 | *
6 | *
7 | * Latest cleanups and additional directives added by DHP in 2011
8 | */
9 |
10 |
11 | //--------------------------------------------------------- ESSENTIAL ACPI TABLES -------------------------------------------------------------
12 |
13 |
14 | #if STATIC_APIC_TABLE_INJECTION
15 | #define STATIC_APIC_TABLE_DATA \
16 | /* 0x0000 */ // Insert your APIC table replacement here (optional).
17 | #endif
18 |
19 |
20 | #if STATIC_ECDT_TABLE_INJECTION
21 | #define STATIC_ECDT_TABLE_DATA \
22 | /* 0x0000 */ // Insert your ECDT table replacement here (optional).
23 | #endif
24 |
25 |
26 | #if STATIC_HPET_TABLE_INJECTION
27 | #define STATIC_HPET_TABLE_DATA \
28 | /* 0x0000 */ // Insert your HPET table replacement here (optional).
29 | #endif
30 |
31 |
32 | #if STATIC_MCFG_TABLE_INJECTION
33 | #define STATIC_MCFG_TABLE_DATA \
34 | /* 0x0000 */ // Insert your MCFG table replacement here (optional).
35 | #endif
36 |
37 |
38 | #if STATIC_SBST_TABLE_INJECTION
39 | #define STATIC_SBST_TABLE_DATA \
40 | /* 0x0000 */ // Insert your SBST table replacement here (optional).
41 | #endif
42 |
43 |
44 | #if STATIC_SSDT_TABLE_INJECTION
45 | #define STATIC_SSDT_TABLE_DATA \
46 | /* 0x0000 */ // Insert your SSDT table replacement here (optional).
47 | #endif
48 |
49 |
50 | //--------------------------------------------------------- SECONDARY ACPI TABLES -------------------------------------------------------------
51 |
52 |
53 | #if STATIC_DSDT_TABLE_INJECTION
54 | #define STATIC_DSDT_TABLE_DATA \
55 | /* 0x0000 */ // Insert your DSDT table replacement here (optional).
56 | #endif
57 |
58 |
59 | #if STATIC_FACS_TABLE_INJECTION
60 | #define STATIC_FACS_TABLE_DATA \
61 | /* 0x0000 */ // Insert your FACS table replacement here (optional).
62 | #endif
63 |
64 |
65 | //---------------------------------------------------------- OPTIONAL ACPI TABLES -------------------------------------------------------------
66 |
67 |
68 | #if STATIC_APIC2_TABLE_INJECTION
69 | #define STATIC_APIC2_TABLE_DATA \
70 | /* 0x0000 */ // Insert a second APIC table (replacement) here (optional).
71 | #endif
72 |
73 |
74 | #if STATIC_SSDT_GPU_TABLE_INJECTION
75 | #define STATIC_SSDT_GPU_TABLE_DATA \
76 | /* 0x0000 */ // Insert your SSDT_GPU table replacement here (optional).
77 | #endif
78 |
79 |
80 | #if STATIC_SSDT_PR_TABLE_INJECTION
81 | #define STATIC_SSDT_PR_TABLE_DATA \
82 | /* 0x0000 */ // Insert your SSDT_PR table replacement here (optional).
83 | #endif
84 |
85 |
86 | #if STATIC_SSDT_SATA_TABLE_INJECTION
87 | #define STATIC_SSDT_SATA_TABLE_DATA \
88 | /* 0x0000 */ // Insert your SSDT_SATA table replacement here (optional).
89 | #endif
90 |
91 |
92 | #if STATIC_SSDT_USB_TABLE_INJECTION
93 | #define STATIC_SSDT_USB_TABLE_DATA \
94 | /* 0x0000 */ // Insert your SSDT_USB table replacement here (optional).
95 | #endif
96 |
97 | //================================================================= END ====================================================================
98 |
--------------------------------------------------------------------------------
/i386/config/ACPI/data-template.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Master Chief. All rights reserved.
3 | *
4 | * Note: This is an essential part of the build process for Revolution v0.6.43 and greater.
5 | *
6 | *
7 | * Latest cleanups and additional directives added by DHP in 2011
8 | */
9 |
10 |
11 | //--------------------------------------------------------- ESSENTIAL ACPI TABLES -------------------------------------------------------------
12 |
13 |
14 | #if STATIC_APIC_TABLE_INJECTION
15 | #define STATIC_APIC_TABLE_DATA \
16 | /* 0x0000 */ // Insert your APIC table replacement here (optional).
17 | #endif
18 |
19 |
20 | #if STATIC_ECDT_TABLE_INJECTION
21 | #define STATIC_ECDT_TABLE_DATA \
22 | /* 0x0000 */ // Insert your ECDT table replacement here (optional).
23 | #endif
24 |
25 |
26 | #if STATIC_HPET_TABLE_INJECTION
27 | #define STATIC_HPET_TABLE_DATA \
28 | /* 0x0000 */ // Insert your HPET table replacement here (optional).
29 | #endif
30 |
31 |
32 | #if STATIC_MCFG_TABLE_INJECTION
33 | #define STATIC_MCFG_TABLE_DATA \
34 | /* 0x0000 */ // Insert your MCFG table replacement here (optional).
35 | #endif
36 |
37 |
38 | #if STATIC_SBST_TABLE_INJECTION
39 | #define STATIC_SBST_TABLE_DATA \
40 | /* 0x0000 */ // Insert your SBST table replacement here (optional).
41 | #endif
42 |
43 |
44 | #if STATIC_SSDT_TABLE_INJECTION
45 | #define STATIC_SSDT_TABLE_DATA \
46 | /* 0x0000 */ // Insert your SSDT table replacement here (optional).
47 | #endif
48 |
49 |
50 | //--------------------------------------------------------- SECONDARY ACPI TABLES -------------------------------------------------------------
51 |
52 |
53 | #if STATIC_DSDT_TABLE_INJECTION
54 | #define STATIC_DSDT_TABLE_DATA \
55 | /* 0x0000 */ // Insert your DSDT table replacement here (optional).
56 | #endif
57 |
58 |
59 | #if STATIC_FACS_TABLE_INJECTION
60 | #define STATIC_FACS_TABLE_DATA \
61 | /* 0x0000 */ // Insert your FACS table replacement here (optional).
62 | #endif
63 |
64 |
65 | //---------------------------------------------------------- OPTIONAL ACPI TABLES -------------------------------------------------------------
66 |
67 |
68 | #if STATIC_APIC2_TABLE_INJECTION
69 | #define STATIC_APIC2_TABLE_DATA \
70 | /* 0x0000 */ // Insert a second APIC table (replacement) here (optional).
71 | #endif
72 |
73 |
74 | #if STATIC_SSDT_GPU_TABLE_INJECTION
75 | #define STATIC_SSDT_GPU_TABLE_DATA \
76 | /* 0x0000 */ // Insert your SSDT_GPU table replacement here (optional).
77 | #endif
78 |
79 |
80 | #if STATIC_SSDT_PR_TABLE_INJECTION
81 | #define STATIC_SSDT_PR_TABLE_DATA \
82 | /* 0x0000 */ // Insert your SSDT_PR table replacement here (optional).
83 | #endif
84 |
85 |
86 | #if STATIC_SSDT_SATA_TABLE_INJECTION
87 | #define STATIC_SSDT_SATA_TABLE_DATA \
88 | /* 0x0000 */ // Insert your SSDT_SATA table replacement here (optional).
89 | #endif
90 |
91 |
92 | #if STATIC_SSDT_USB_TABLE_INJECTION
93 | #define STATIC_SSDT_USB_TABLE_DATA \
94 | /* 0x0000 */ // Insert your SSDT_USB table replacement here (optional).
95 | #endif
96 |
97 | //================================================================= END ====================================================================
98 |
--------------------------------------------------------------------------------
/i386/libsaio/bios.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /*
25 | * Copyright 1994 NeXT Computer, Inc.
26 | * All rights reserved.
27 | */
28 |
29 | #ifndef __LIBSAIO_BIOS_H
30 | #define __LIBSAIO_BIOS_H
31 |
32 |
33 | typedef union
34 | {
35 | unsigned int rx;
36 | unsigned short rr;
37 |
38 | struct
39 | {
40 | unsigned char l;
41 | unsigned char h;
42 | } r;
43 | } machineRegister_t;
44 |
45 |
46 | typedef struct
47 | {
48 | unsigned short cf : 1;
49 | unsigned short : 1;
50 | unsigned short pf : 1;
51 | unsigned short : 1;
52 | unsigned short af : 1;
53 | unsigned short : 1;
54 | unsigned short zf : 1;
55 | unsigned short sf : 1;
56 | unsigned short tf : 1;
57 | unsigned short _if : 1;
58 | unsigned short df : 1;
59 | unsigned short of : 1;
60 | unsigned short iopl : 2;
61 | unsigned short nt : 1;
62 | } machineFlags_t;
63 |
64 |
65 | typedef struct
66 | {
67 | unsigned int intno;
68 | machineRegister_t eax;
69 | machineRegister_t ebx;
70 | machineRegister_t ecx;
71 | machineRegister_t edx;
72 | machineRegister_t edi;
73 | machineRegister_t esi;
74 | machineRegister_t ebp;
75 | unsigned short cs;
76 | unsigned short ds;
77 | unsigned short es;
78 | machineFlags_t flags;
79 | } biosBuf_t;
80 |
81 |
82 | /*
83 | * Used in biosfn.c and disk.c
84 | */
85 |
86 | #define EBIOS_FIXED_DISK_ACCESS 0x01
87 | #define EBIOS_LOCKING_ACCESS 0x02
88 | #define EBIOS_ENHANCED_DRIVE_INFO 0x04
89 |
90 | #define BASE_HD_DRIVE 0x80
91 |
92 | /*
93 | * Used in saio_types.h and in StringTable.c (function loadCABootPlist).
94 | */
95 |
96 | #define IO_CONFIG_DATA_SIZE 4096
97 |
98 |
99 | /*
100 | * Memory range descriptor.
101 | */
102 | typedef struct MemoryRange
103 | {
104 | unsigned long long base; // 64-bit base address
105 | unsigned long long length; // 64-bit length in bytes
106 | unsigned long type; // type of memory range
107 | unsigned long reserved;
108 | } MemoryRange;
109 |
110 | #endif /* !__LIBSAIO_BIOS_H */
111 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/cpuid.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | *
28 | * Refactoring for Revolution done by DHP in 2010. Original copyright header
29 | * also reinstated.
30 | *
31 | */
32 |
33 | #ifndef __LIBSAIO_CPU_CPUID_H
34 | #define __LIBSAIO_CPU_CPUID_H
35 |
36 |
37 | #define getCachedCPUID(leaf, reg) gPlatform.CPU.ID[leaf][reg]
38 |
39 |
40 | //==============================================================================
41 | // Copied from: xnu/osfmk/cpuid.h
42 |
43 | typedef enum
44 | {
45 | eax,
46 | ebx,
47 | ecx,
48 | edx
49 | } cpuid_register_t;
50 |
51 |
52 | //==============================================================================
53 | // Copied from: xnu/osfmk/i386/cpuid.h
54 |
55 | static inline void cpuid(uint32_t * data)
56 | {
57 | asm volatile("cpuid"
58 | : "=a" (data[eax]),
59 | "=b" (data[ebx]),
60 | "=c" (data[ecx]),
61 | "=d" (data[edx])
62 | : "a" (data[eax]),
63 | "b" (data[ebx]),
64 | "c" (data[ecx]),
65 | "d" (data[edx])
66 | );
67 | }
68 |
69 |
70 | //==============================================================================
71 | // Copied from: xnu/osfmk/i386/cpuid.h
72 |
73 | static inline void do_cpuid(uint32_t selector, uint32_t * data)
74 | {
75 | asm volatile("cpuid"
76 | : "=a" (data[eax]),
77 | "=b" (data[ebx]),
78 | "=c" (data[ecx]),
79 | "=d" (data[edx])
80 | : "a" (selector)
81 | );
82 | }
83 |
84 |
85 | //==============================================================================
86 | // Copied from: chameleon/i386/libsaio/cpu.h
87 | // Copyright 2008 Islam Ahmed Zaid. All rights reserved. ?
88 |
89 | static inline void do_cpuid2(uint32_t selector, uint32_t selector2, uint32_t * data)
90 | {
91 | asm volatile("cpuid"
92 | : "=a" (data[eax]),
93 | "=b" (data[ebx]),
94 | "=c" (data[ecx]),
95 | "=d" (data[edx])
96 | : "a" (selector),
97 | "c" (selector2)
98 | );
99 | }
100 |
101 | #endif /* !__LIBSAIO_CPU_CPUID_H */
102 |
--------------------------------------------------------------------------------
/i386/libsaio/smbios/tools/smbiosXtract.c:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Name : smbiosXtract
4 | * Version : 0.0.1
5 | * Type : Command line tool
6 | * Copyright : Pike R. Alpha (c) 2016
7 | * Description : SMBIOS extractor for use with: dmidecode --from-file SMBIOS.bin
8 | *
9 | * Usage : sudo ./smbiosXtract
10 | *
11 | * Compile with : cc smbiosXtract.c -o smbiosXtract -Wall -framework IOKit -framework CoreFoundation
12 | *
13 | * Updates : None so far.
14 | *
15 | */
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | #include
23 | #include
24 |
25 | #include "../smbios.h"
26 |
27 | //==============================================================================
28 |
29 | uint8_t checksum8(const uint8_t *cp, uint8_t length)
30 | {
31 | uint8_t sum = 0;
32 | uint8_t i = 0;
33 |
34 | for (; i < length; i++)
35 | {
36 | sum += *cp++;
37 | }
38 |
39 | return sum;
40 | }
41 |
42 | //==============================================================================
43 |
44 | int main(void)
45 | {
46 | char dirspec[128];
47 | int filedesc = 0;
48 |
49 | mach_port_t masterPort;
50 | io_service_t service = MACH_PORT_NULL;
51 | CFDataRef dataRef;
52 |
53 | UInt8 entryPointLength = 0;
54 | UInt16 tableLength = 0;
55 | UInt32 bytesWritten = 0;
56 |
57 | IOMasterPort(MACH_PORT_NULL, &masterPort);
58 |
59 | //==================================================================================
60 |
61 | service = IOServiceGetMatchingService(masterPort, IOServiceMatching("AppleSMBIOS"));
62 |
63 | if (service)
64 | {
65 | dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service, CFSTR("SMBIOS-EPS"), kCFAllocatorDefault, kNilOptions);
66 |
67 | if (dataRef)
68 | {
69 | struct SMBEntryPoint * eps = (struct SMBEntryPoint *) CFDataGetBytePtr(dataRef);
70 | entryPointLength = eps->entryPointLength;
71 | tableLength = eps->dmi.tableLength;
72 |
73 | // Point table address to data.
74 | eps->dmi.tableAddress = 0x20;
75 |
76 | // Zero out checksums.
77 | eps->checksum = 0;
78 | eps->dmi.checksum = 0;
79 |
80 | // Recalculate checksums.
81 | eps->dmi.checksum = (256 - checksum8(CFDataGetBytePtr(dataRef) + 0x10, 0x0f));
82 | eps->checksum = (256 - checksum8(CFDataGetBytePtr(dataRef), 0x1f));
83 |
84 | sprintf (dirspec, "SMBIOS.bin");
85 | filedesc = open(dirspec, O_WRONLY|O_CREAT|O_TRUNC, 0644);
86 |
87 | if (filedesc == -1)
88 | {
89 | printf("Error: Unable to open SMBIOS.bin!\n");
90 | close (filedesc);
91 | CFRelease(dataRef);
92 | }
93 | else
94 | {
95 | bytesWritten = write(filedesc, (char *)CFDataGetBytePtr(dataRef), (entryPointLength + 1));
96 | close (filedesc);
97 | CFRelease(dataRef);
98 | dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service, CFSTR("SMBIOS"), kCFAllocatorDefault, kNilOptions);
99 |
100 | if (dataRef)
101 | {
102 | filedesc = open(dirspec, O_WRONLY|O_APPEND, 0644);
103 | bytesWritten += write(filedesc, (char *)CFDataGetBytePtr(dataRef), tableLength);
104 | printf("%d bytes written to SMBIOS.bin for use with: dmidecode --from-dump SMBIOS.bin\n", bytesWritten);
105 | close (filedesc);
106 | CFRelease(dataRef);
107 | }
108 | }
109 | }
110 |
111 | IOObjectRelease(service);
112 | }
113 |
114 | exit(0);
115 | }
116 |
--------------------------------------------------------------------------------
/i386/boot2/lzss.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /**************************************************************
25 | LZSS.C -- A Data Compression Program
26 | ***************************************************************
27 | 4/6/1989 Haruhiko Okumura
28 | Use, distribute, and modify this program freely.
29 | Please send me your improved versions.
30 | PC-VAN SCIENCE
31 | NIFTY-Serve PAF01022
32 | CompuServe 74050,1022
33 |
34 | **************************************************************/
35 | /*
36 | * lzss.c - Package for decompressing lzss compressed objects
37 | *
38 | * Copyright (c) 2003 Apple Computer, Inc.
39 | *
40 | * DRI: Josh de Cesare
41 | */
42 |
43 | #include
44 |
45 | #define N 4096 // Size of ring buffer - must be power of 2.
46 | #define N_MIN_1 4095
47 | #define F 18 // Upper limit for match_length.
48 | #define R N - F
49 | #define THRESHOLD 2 // Encode string into position and length,
50 | // if match_length is greater than this.
51 | #define NIL N // Index for root of binary search trees.
52 |
53 |
54 | //==============================================================================
55 | // Refactoring and bug fix Copyright (c) 2010 by DHP.
56 |
57 | int decompressLZSS(u_int8_t * dst, u_int8_t * src, u_int32_t srclen)
58 | {
59 | // Four KB ring buffer with 17 extra bytes added to aid string comparisons.
60 | u_int8_t text_buf[N_MIN_1 + F];
61 | u_int8_t * dststart = dst;
62 | const u_int8_t * srcend = (src + srclen);
63 |
64 | int r = R;
65 | int i, j, k, c;
66 | unsigned int flags = 0;
67 |
68 | for (i = 0; i < R; i++)
69 | {
70 | text_buf[i] = ' ';
71 | }
72 |
73 | while (src < srcend)
74 | {
75 | if (((flags >>= 1) & 0x100) == 0)
76 | {
77 | c = *src++;
78 | flags = c | 0xFF00; // Clever use of the high byte.
79 | }
80 |
81 | if ((src < srcend) && (flags & 1))
82 | {
83 | c = *src++;
84 | *dst++ = c;
85 | text_buf[r++] = c;
86 | r &= N_MIN_1;
87 | }
88 | else if ((src + 2) <= srcend)
89 | {
90 | i = *src++;
91 | j = *src++;
92 |
93 | i |= ((j & 0xF0) << 4);
94 | j = (j & 0x0F) + THRESHOLD;
95 |
96 | for (k = 0; k <= j; k++)
97 | {
98 | c = text_buf[(i + k) & N_MIN_1];
99 | *dst++ = c;
100 | text_buf[r++] = c;
101 | r &= N_MIN_1;
102 | }
103 | }
104 | }
105 |
106 | return dst - dststart;
107 | }
108 |
--------------------------------------------------------------------------------
/i386/libsaio/fdisk.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /*
25 | * Copyright (c) 1992 NeXT Computer, Inc.
26 | *
27 | * IBM PC disk partitioning data structures.
28 | *
29 | * HISTORY
30 | *
31 | * 8 July 1992 David E. Bohman at NeXT Created.
32 | *
33 | * Updates:
34 | * - Spaces replaced with tabs (PikerAlpha, November 2012)
35 | * - Unused 'REAL_disk_blk0' removed (PikerAlpha, November 2012)
36 | *
37 | */
38 |
39 |
40 | #ifndef __LIBSAIO_FDISK_H
41 | #define __LIBSAIO_FDISK_H
42 |
43 | #define DISK_BLK0 0 // Block number of boot block
44 | #define DISK_BLK0SZ 512 // Size of boot block
45 | #define DISK_BOOTSZ 446 // Size of boot code in boot block
46 | #define DISK_SIGNATURE 0xAA55 // signature of the boot record
47 | #define FDISK_NPART 4 // Number of entries in fdisk table
48 | #define FDISK_ACTIVE 0x80 // Indicator of active partition
49 | #define FDISK_NEXTNAME 0xA7 // Indicator of NeXT partition
50 | #define FDISK_DOS12 0x01 // 12-bit fat < 10MB dos partition
51 | #define FDISK_DOS16S 0x04 // 16-bit fat < 32MB dos partition
52 | #define FDISK_DOSEXT 0x05 // Extended DOS partition
53 | #define FDISK_DOS16B 0x06 // 16-bit fat >= 32MB dos partition
54 | #define FDISK_NTFS 0x07 // NTFS partition
55 | #define FDISK_SMALLFAT32 0x0b // FAT32 partition
56 | #define FDISK_FAT32 0x0c // FAT32 partition
57 | #define FDISK_DOS16SLBA 0x0e
58 | #define FDISK_LINUX 0x83
59 | #define FDISK_UFS 0xa8 // Apple UFS partition
60 | #define FDISK_HFS 0xaf // Apple HFS partition
61 | #define FDISK_BOOTER 0xab // Apple booter partition
62 |
63 | // Format of fdisk partion entry (if present).
64 |
65 | struct fdisk_part
66 | {
67 | unsigned char bootid; // Bootable or not
68 | unsigned char beghead; // Begining head, sector, cylinder
69 | unsigned char begsect; // Beginning cylinder is a 10-bit number
70 | unsigned char begcyl; // High 2 bits are in begsect
71 | unsigned char systid; // OS type
72 | unsigned char endhead; // Ending head, sector, cylinder
73 | unsigned char endsect; // Endcyl is a 10-bit number
74 | unsigned char endcyl; // High 2 bits are in endsect
75 | unsigned long relsect; // Partion physical offset on disk
76 | unsigned long numsect; // Number of sectors in partition
77 | } __attribute__((packed));
78 |
79 |
80 | // Format of boot block.
81 |
82 | struct disk_blk0
83 | {
84 | unsigned char bootcode[DISK_BOOTSZ];
85 | unsigned char parts[FDISK_NPART][sizeof (struct fdisk_part)];
86 | unsigned short signature;
87 | };
88 |
89 | #endif /* !__LIBSAIO_FDISK_H */
90 |
--------------------------------------------------------------------------------
/i386/libsaio/acpi/debug.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 by Master Chief.
3 | *
4 | * Refactored (dynamic and static ACPI patching) by DHP in 2010/2011
5 | */
6 |
7 | #ifndef __LIBSAIO_ACPI_DEBUG_H
8 | #define __LIBSAIO_ACPI_DEBUG_H
9 |
10 | #if DEBUG_ACPI
11 |
12 | //------------------------- Used in acpi/patcher.h -------------------------
13 |
14 | #define _ACPI_GET(xtr, x, y) strncpy(str, x, y); str[y] = '\0'
15 |
16 | // #define _ACPI_DEBUG_DUMP(x...) printf(x)
17 | // #define _ACPI_DEBUG_SLEEP(seconds) printf("Sleeping for %d seconds...\n", seconds); sleep(seconds)
18 | #define _ACPI_DEBUG_DUMP_TABLENAME(table, tableName, index) dumpTableName((void *)table, (char *)tableName, (int)index)
19 |
20 | #define _ACPI_DUMP_RSDP_TABLE(table, header) tableDumpRSDP((struct acpi_2_rsdp *)table, (char *)header)
21 | #define _ACPI_DUMP_XSDT_TABLE(table, header) tableDumpXSDT((struct acpi_2_xsdt *)table, (char *)header)
22 |
23 | //--------------------------------------------------------------------------
24 |
25 | char str[9] = "";
26 | char * tableName[] = { 0, 0, 0, 0, 0 };
27 |
28 |
29 | //==========================================================================
30 |
31 | void dumpTableName(void *table, char * tableName, int index)
32 | {
33 | strncpy((char *)tableName, (char *)table, 4);
34 | tableName[4] = '\0';
35 |
36 | printf("Found tableSignature(%d): %s ", (index + 1), tableName);
37 | sleep(1);
38 | }
39 |
40 |
41 | //==========================================================================
42 |
43 | void tableDumpRSDP(struct acpi_2_rsdp * rsdp, char * header)
44 | {
45 | printf("\n%s RSDP:\n", header);
46 | printf("=======================\n");
47 | _ACPI_GET(str, rsdp->Signature, 8);
48 | printf("rdsp->Signature : %s\n", str);
49 | printf("rdsp->Checksum : 0x%x\n", rsdp->Checksum);
50 | _ACPI_GET(str, rsdp->OEMID, 6);
51 | printf("rdsp->OEMID : %s\n", str);
52 | printf("rsdp->Revision : %d\n", rsdp->Revision);
53 | printf("rsdp->RsdtAddress : 0x%x\n", rsdp->RsdtAddress);
54 |
55 | if (rsdp->Revision)
56 | {
57 | printf("rsdp->Length : 0x%x\n", rsdp->Length);
58 | printf("rsdp->XsdtAddress : 0x%x\n", rsdp->XsdtAddress);
59 | printf("rdsp->ExtendedChecksum: 0x%x\n", rsdp->ExtendedChecksum);
60 | _ACPI_GET(str, rsdp->Reserved, 3);
61 | printf("rdsp->Reserved : %s\n", str);
62 | }
63 |
64 | _ACPI_DEBUG_SLEEP(5);
65 | }
66 |
67 |
68 | //==========================================================================
69 |
70 | void tableDumpXSDT(struct acpi_2_xsdt * table, char * header)
71 | {
72 | _ACPI_GET(str, table->Signature, 4);
73 | printf("\n%s %s:\n", header, str);
74 | printf("=======================\n");
75 | printf("xsdt->Signature : %s\n", str);
76 | printf("xsdt->Length : 0x%x\n", table->Length);
77 | printf("xsdt->Revision : %d\n", table->Revision);
78 | printf("xsdt->Checksum : 0x%x\n", table->Checksum);
79 | _ACPI_GET(str, table->OEMID, 6);
80 | printf("xsdt->OEMID : %s\n", str);
81 | _ACPI_GET(str, table->OEMTableID, 8);
82 | printf("xsdt->OEMTableId : %s\n", str);
83 | printf("xsdt->OEMRevision : 0x%x\n", table->OEMRevision);
84 | printf("xsdt->CreatorId : 0x%x\n", table->CreatorID);
85 | printf("xsdt->CreatorRevision : 0x%x\n", table->CreatorRevision);
86 |
87 | _ACPI_DEBUG_SLEEP(5);
88 | }
89 |
90 | #else
91 |
92 | //--------------------------- Void replacements ----------------------------
93 |
94 | #define _ACPI_GET(xtr, x, y)
95 |
96 | // define _ACPI_DEBUG_DUMP(x...)
97 | // #define _ACPI_DEBUG_SLEEP(seconds)
98 | #define _ACPI_DEBUG_DUMP_TABLENAME(table, tableName, index)
99 |
100 | #define _ACPI_DUMP_RSDP_TABLE(table, header)
101 | #define _ACPI_DUMP_XSDT_TABLE(table, header)
102 |
103 | //--------------------------------------------------------------------------
104 |
105 | #endif
106 |
107 |
108 | #endif /* !__LIBSAIO_ACPI_DEBUG_H */
109 |
--------------------------------------------------------------------------------
/i386/libsaio/table.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /*
25 | * Mach Operating System
26 | * Copyright (c) 1990 Carnegie-Mellon University
27 | * Copyright (c) 1989 Carnegie-Mellon University
28 | * All rights reserved. The CMU software License Agreement specifies
29 | * the terms and conditions for use and redistribution.
30 | */
31 |
32 | /*
33 | * INTEL CORPORATION PROPRIETARY INFORMATION
34 | *
35 | * This software is supplied under the terms of a license agreement or
36 | * nondisclosure agreement with Intel Corporation and may not be copied
37 | * nor disclosed except in accordance with the terms of that agreement.
38 | *
39 | * Copyright 1988, 1989 Intel Corporation
40 | */
41 |
42 | /*
43 | * Copyright 1993 NeXT, Inc.
44 | * All rights reserved.
45 | */
46 |
47 | #include "memory.h"
48 |
49 | /* Segment Descriptor
50 | *
51 | * 31 24 19 16 7 0
52 | * ------------------------------------------------------------
53 | * | | |B| |A| | | |1|0|E|W|A| |
54 | * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 |
55 | * | | |D| |L| 19..16| | |1|1|C|R|A| |
56 | * ------------------------------------------------------------
57 | * | | |
58 | * | BASE 15..0 | LIMIT 15..0 |
59 | * | | |
60 | * ------------------------------------------------------------
61 | */
62 |
63 | struct seg_desc {
64 | unsigned short limit_15_0;
65 | unsigned short base_15_0;
66 | unsigned char base_23_16;
67 | unsigned char bit_15_8;
68 | unsigned char bit_23_16;
69 | unsigned char base_31_24;
70 | };
71 |
72 | // turbo - GDT must be in first 64k segment
73 | struct seg_desc __attribute__ ((section("__INIT,__data"))) Gdt[ NGDTENT ] = {
74 | /* 0x0 : null */
75 | {0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00},
76 |
77 | /* 0x8 : boot protected mode 32-bit code segment
78 | byte granularity, 1MB limit, MEMBASE offset */
79 | {0xFFFF, MEMBASE, 0x00, 0x9E, 0x4F, 0x00},
80 |
81 | /* 0x10 : boot protected mode data segment
82 | page granularity, 4GB limit, MEMBASE offset */
83 | {0xFFFF, MEMBASE, 0x00, 0x92, 0xCF, 0x00},
84 |
85 | /* 0x18 : boot protected mode 16-bit code segment
86 | byte granularity, 1MB limit, MEMBASE offset */
87 | {0xFFFF, MEMBASE, 0x00, 0x9E, 0x0F, 0x00},
88 |
89 | /* 0x20 : kernel init 32-bit data segment
90 | page granularity, 4GB limit, zero offset */
91 | {0xFFFF, 0x0000, 0x00, 0x92, 0xCF, 0x00},
92 |
93 | /* 0x28 : kernel init 32-bit code segment
94 | page granularity, 4GB limit, zero offset */
95 | {0xFFFF, 0x0000, 0x00, 0x9E, 0xCF, 0x00},
96 |
97 | /* 0x30 : boot real mode data/stack segment
98 | byte granularity, 64K limit, MEMBASE offset, expand-up */
99 | {0xFFFF, MEMBASE, 0x00, 0x92, 0x00, 0x00},
100 | };
101 |
--------------------------------------------------------------------------------
/i386/boot2/boot2.s:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 1.1 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /*
25 | * Mach Operating System
26 | * Copyright (c) 1990 Carnegie-Mellon University
27 | * Copyright (c) 1989 Carnegie-Mellon University
28 | * All rights reserved. The CMU software License Agreement specifies
29 | * the terms and conditions for use and redistribution.
30 | */
31 |
32 | /*
33 | * boot2() -- second stage boot.
34 | *
35 | * This function must be located at 0:BOOTER_ADDR and will be called by boot1.
36 | */
37 |
38 | #include
39 | #include "memory.h"
40 |
41 | #define DEBUG 0 // Set to 0 by default. Use 1 for testing only!
42 |
43 | #define data32 .byte 0x66
44 | #define retf .byte 0xcb
45 |
46 | .file "boot2.s"
47 | .section __INIT,__text // turbo - This initialization code must reside within the first segment
48 |
49 | //.data
50 | .section __INIT,__data // turbo - Data that must be in the first segment
51 |
52 | //.text
53 | .section __INIT,__text // turbo
54 |
55 | #-------------------------------------------------------------------------------
56 | # Booter entry point. Called by boot1.
57 | # This routine must be the first in the TEXT segment.
58 | #
59 | # Arguments:
60 | # DX = Boot device
61 | #
62 | # Returns:
63 | #
64 | LABEL(start) # Entry point at 0:BOOTER_ADDR (will be called by boot1)
65 | pushl %ecx # Save general purpose registers
66 | pushl %ebx
67 | pushl %ebp
68 | pushl %esi
69 | pushl %edi
70 | push %ds # Save DS, ES
71 | push %es
72 |
73 | #if DEBUG
74 | #-------------------------------------------------------------------------------
75 | # Writes ":boot2" to the console and waits for key press.
76 | #
77 | # Note: The text "boot1: /boot:boot2" means that boot2 is loaded and started.
78 | #
79 | push %ax
80 | push %bx
81 |
82 | mov $0x0e3a, %ax
83 | mov $0x0001, %bx
84 | int $0x10
85 | mov $0x0e62, %ax
86 | mov $0x0001, %bx
87 | int $0x10
88 | mov $0x0e6f, %ax
89 | mov $0x0001, %bx
90 | int $0x10
91 | mov $0x0e6f, %ax
92 | mov $0x0001, %bx
93 | int $0x10
94 | mov $0x0e74, %ax
95 | mov $0x0001, %bx
96 | int $0x10
97 | mov $0x0e32, %ax
98 | mov $0x0001, %bx
99 | int $0x10
100 |
101 | mov $0x0000, %ax # Wait for a key press.
102 | mov $0x0001, %bx
103 | int $0x16
104 |
105 | pop %bx
106 | pop %ax
107 |
108 | #-------------------------------------------------------------------------------
109 | #endif
110 |
111 | mov %cs, %ax # Update segment registers.
112 | mov %ax, %ds # Set DS and ES to match CS
113 | mov %ax, %es
114 |
115 | data32
116 | call __switch_stack # Switch to new stack
117 |
118 | data32
119 | call __real_to_prot # Enter protected mode.
120 |
121 | # We are now in 32-bit protected mode.
122 | # Transfer execution to C by calling boot().
123 |
124 | pushl %edx # bootdev
125 | call _boot
126 |
--------------------------------------------------------------------------------
/i386/libsaio/guid.c:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "libsaio.h"
4 |
5 | #include "efi/essentials.h"
6 | #include "efi/efi.h"
7 |
8 |
9 | //==========================================================================
10 | // Used in RevoBoot/i386/libsaio/disk.c
11 |
12 | void convertEFIGUIDToString(EFI_GUID const *aGuid, char **aUUIDString)
13 | {
14 | // Do we need to allocate memory?
15 | if (*aUUIDString == NULL)
16 | {
17 | // 1 2 3
18 | // 123456789 123456789 123456789 123456
19 | // 00000000-0000-0000-0000-000000000000
20 | *aUUIDString = (char *)malloc(36);
21 | }
22 |
23 | if (*aUUIDString)
24 | {
25 | bzero(*aUUIDString, 36);
26 | sprintf(*aUUIDString, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
27 | aGuid->Data1, /* - */
28 | aGuid->Data2, /* - */
29 | aGuid->Data3, /* - */
30 | aGuid->Data4[0], aGuid->Data4[1], /* - */
31 | aGuid->Data4[2], aGuid->Data4[3],
32 | aGuid->Data4[4], aGuid->Data4[5],
33 | aGuid->Data4[6], aGuid->Data4[7]);
34 | }
35 | }
36 |
37 |
38 | //==========================================================================
39 | // Used in RevoBoot/i386/libsaio/disk.c
40 |
41 | bool isEFIGUIDNull(EFI_GUID const *aGuid)
42 | {
43 | if (aGuid->Data1 == 0 && aGuid->Data2 == 0 && aGuid->Data3 == 0)
44 | {
45 | int i = 0;
46 |
47 | for (i = 0; i < 8; ++i)
48 | {
49 | if (aGuid->Data4[i] != 0)
50 | {
51 | return false;
52 | }
53 | }
54 |
55 | return true;
56 | }
57 |
58 | return false;
59 | }
60 |
61 |
62 | //=========================================================================
63 | // Used in RevoBoot/i386/libsaio/disk.c
64 |
65 | int compareEFIGUID(EFI_GUID const *aSourceGuid, EFI_GUID const *aCompareGuid)
66 | {
67 | if (aSourceGuid->Data1 == aCompareGuid->Data1) // Comparing two EFI_UINT32's
68 | {
69 | if (aSourceGuid->Data2 == aCompareGuid->Data2) // Comparing two EFI_UINT16's
70 | {
71 | if (aSourceGuid->Data3 == aCompareGuid->Data3) // Comparing two EFI_UINT16's
72 | {
73 | // Returns 0 when equal or -1 when not
74 | return memcmp((const void *)aSourceGuid->Data4, (const void *)aSourceGuid->Data4, 8);
75 | }
76 | }
77 | }
78 |
79 | return -1;
80 | }
81 |
82 |
83 | #if STARTUP_DISK_SUPPORT
84 | //=========================================================================
85 | // Helper function for getStartupDiskUUID()
86 |
87 | #if USE_DEVICE_PATH
88 | void *getUUIDFromDevicePath(EFI_DEVICE_PATH_PROTOCOL *devicePath)
89 | #else
90 | void *getUUIDFromDevicePath(EFI_GUID *aGUID)
91 | #endif
92 | {
93 | char * uuid = NULL;
94 |
95 | #if USE_DEVICE_PATH
96 | if (devicePath != NULL)
97 | {
98 | while (!IsDevicePathEndType(devicePath) &&
99 | !(DevicePathType(devicePath) == MEDIA_DEVICE_PATH && DevicePathSubType(devicePath) == MEDIA_HARDDRIVE_DP))
100 | {
101 | devicePath = NextDevicePathNode(devicePath);
102 | }
103 |
104 | if (DevicePathType(devicePath) == MEDIA_DEVICE_PATH && DevicePathSubType(devicePath) == MEDIA_HARDDRIVE_DP)
105 | {
106 | HARDDRIVE_DEVICE_PATH * HDDevicePath = (HARDDRIVE_DEVICE_PATH *) devicePath;
107 |
108 | if (HDDevicePath->SignatureType == SIGNATURE_TYPE_GUID) // 0x02
109 | {
110 | EFI_GUID const * aGUID = (EFI_GUID*)HDDevicePath->Signature;
111 |
112 | convertEFIGUIDToString(aGUID, &uuid);
113 | }
114 | }
115 | }
116 | #else
117 | convertEFIGUIDToString(aGUID, &uuid);
118 | #endif
119 |
120 | return uuid;
121 | }
122 |
123 |
124 | //==============================================================================
125 | // Used in RevoBoot/i386/boot2/boot.c
126 |
127 | char * getStartupDiskUUID(char * aDataPtr)
128 | {
129 | char * startupDiskUUID = NULL;
130 |
131 | unsigned char * decodedData = NULL;
132 |
133 | int rc = base64Decode(aDataPtr, &decodedData);
134 |
135 | if ((rc == 75) && (decodedData != NULL))
136 | {
137 | #if USE_DEVICE_PATH
138 | EFI_DEVICE_PATH_PROTOCOL * dp = (EFI_DEVICE_PATH_PROTOCOL *) decodedData;
139 |
140 | startupDiskUUID = getUUIDFromDevicePath(dp);
141 | #else
142 | EFI_GUID * uuid = (EFI_GUID *) (decodedData + 52);
143 |
144 | convertEFIGUIDToString(uuid, &startupDiskUUID);
145 | #endif
146 | free(decodedData);
147 | }
148 |
149 | return startupDiskUUID;
150 | }
151 | #endif // #if DISK_TARGET_SUPPORT
152 |
--------------------------------------------------------------------------------
/i386/libsa/libsa.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | * Updates:
25 | * - Use size_t instead of int when required (PikerAlpha, November 2012)
26 | *
27 | */
28 |
29 | #ifndef __BOOT_LIBSA_H
30 | #define __BOOT_LIBSA_H
31 |
32 | /* Exported API for standalone library */
33 |
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | #include "../config/settings.h"
40 |
41 |
42 | /*
43 | * boot.c
44 | */
45 | extern int fastEnableA20(void);
46 |
47 |
48 | /*
49 | * crc32.c
50 | */
51 | uint32_t crc32(uint32_t crc, const void *buf, size_t size);
52 |
53 |
54 | /*
55 | * getsegbyname.c
56 | */
57 | extern struct segment_command * getsegbynamefromheader(struct mach_header * mhp, char * segname);
58 |
59 |
60 | /*
61 | * prf.c
62 | */
63 | extern void prf(const char * fmt, va_list ap, void (*putfn_p)(), void * putfn_arg);
64 |
65 |
66 | /*
67 | * printf.c
68 | */
69 | extern int sprintf(char *s, const char * format, ...);
70 | extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);
71 |
72 |
73 | /*
74 | * string.c
75 | */
76 | #ifndef bcopy
77 | extern void bcopy(const void * src, void * dst, size_t len);
78 | #endif
79 |
80 | #ifndef bzero
81 | extern void bzero(void * dst, size_t len);
82 | #endif
83 |
84 | extern char * strcpy(char * s1, const char * s2);
85 | extern char * strncpy(char * s1, const char * s2, size_t n);
86 |
87 | extern char * strstr(const char *in, const char *str);
88 | extern char * strcat(char * s1, const char * s2);
89 | extern char * strncat(char * s1, const char * s2, size_t n);
90 | extern char * strdup(const char *s1);
91 |
92 | extern void * memset(void * dst, int c, size_t n);
93 | extern void * memcpy(void * dst, const void * src, size_t len);
94 |
95 | extern int strcmp(const char * s1, const char * s2);
96 | extern int strncmp(const char * s1, const char * s2, size_t n);
97 | extern int atoi(const char * str);
98 | extern int ptol(const char * str);
99 |
100 | extern int memcmp(const void * p1, const void * p2, size_t len);
101 |
102 | extern size_t strlcpy(char * s1, const char * s2, size_t n);
103 | extern size_t strlen(const char * str);
104 |
105 | #if STRNCASECMP
106 | extern int strncasecmp(const char * s1, const char * s2, size_t n);
107 | #endif
108 |
109 | extern uint8_t checksum8( void * start, unsigned int length);
110 | char * removeChar(char *aSourceString, char aTargetChar);
111 |
112 |
113 | /*
114 | * strtol.c
115 | */
116 | extern long strtol(const char * nptr, char ** endptr, int base);
117 | extern unsigned long strtoul(const char * nptr, char ** endptr, int base);
118 | extern unsigned long long strtouq(const char *nptr, char ** endptr, int base);
119 |
120 |
121 | /*
122 | * zalloc.c
123 | */
124 |
125 | #if SAFE_MALLOC
126 | #define malloc(size) safeMalloc(size, __FILE__, __LINE__)
127 |
128 | extern void mallocInit(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
129 | extern void * safeMalloc(size_t size, const char *file, int line);
130 | #else
131 | extern void mallocInit(char * start, int size, int nodes, void (*malloc_error)(char *, size_t));
132 | extern void * malloc(size_t size);
133 | #endif
134 |
135 | extern void free(void * start);
136 | extern void * realloc(void * ptr, size_t size);
137 |
138 | #endif /* !__BOOT_LIBSA_H */
139 |
--------------------------------------------------------------------------------
/i386/libsa/prf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /*
25 | * Mach Operating System
26 | * Copyright (c) 1990 Carnegie-Mellon University
27 | * Copyright (c) 1989 Carnegie-Mellon University
28 | * Copyright (c) 1988 Carnegie-Mellon University
29 | * Copyright (c) 1987 Carnegie-Mellon University
30 | * All rights reserved. The CMU software License Agreement specifies
31 | * the terms and conditions for use and redistribution.
32 | */
33 | /*
34 | * Copyright (c) 1982, 1986 Regents of the University of California.
35 | * All rights reserved. The Berkeley software License Agreement
36 | * specifies the terms and conditions for redistribution.
37 | *
38 | * @(#)prf.c 7.1 (Berkeley) 6/5/86
39 | */
40 |
41 | #include
42 |
43 | #define SPACE 1
44 | #define ZERO 2
45 | #define UCASE 16
46 |
47 | /*
48 | * Scaled down version of C Library printf.
49 | * Used to print diagnostic information directly on console tty.
50 | * Since it is not interrupt driven, all system activities are
51 | * suspended.
52 | *
53 | */
54 |
55 | /*
56 | * Printn prints a number n in base b.
57 | * We don't use recursion to avoid deep kernel stacks.
58 | */
59 | static void printn(n, b, flag, minwidth, putfn_p, putfn_arg)
60 | u_long n;
61 | int b, flag, minwidth;
62 | void (*putfn_p)();
63 | void *putfn_arg;
64 | {
65 | char prbuf[11];
66 | register char *cp;
67 | int width = 0, neg = 0;
68 |
69 | if (b == 10 && (int)n < 0) {
70 | neg = 1;
71 | n = (unsigned)(-(int)n);
72 | }
73 | cp = prbuf;
74 | do {
75 | *cp++ = "0123456789abcdef0123456789ABCDEF"[(flag & UCASE) + n%b];
76 | n /= b;
77 | width++;
78 | } while (n);
79 |
80 | if (neg) {
81 | (*putfn_p)('-', putfn_arg);
82 | width++;
83 | }
84 | while (width++ < minwidth)
85 | (*putfn_p)( (flag & ZERO) ? '0' : ' ', putfn_arg);
86 |
87 | do
88 | (*putfn_p)(*--cp, putfn_arg);
89 | while (cp > prbuf);
90 | }
91 |
92 | void prf(char *fmt, unsigned int *adx, void (*putfn_p)(), void *putfn_arg)
93 | {
94 | int b, c;
95 | char *s;
96 | int flag = 0, width = 0;
97 | int minwidth;
98 |
99 | loop:
100 | while ((c = *fmt++) != '%') {
101 | if(c == '\0')
102 | return;
103 | (*putfn_p)(c, putfn_arg);
104 | }
105 | minwidth = 0;
106 | again:
107 | c = *fmt++;
108 | switch (c) {
109 | case 'l':
110 | goto again;
111 | case ' ':
112 | flag |= SPACE;
113 | goto again;
114 | case '0':
115 | if (minwidth == 0) {
116 | /* this is a flag */
117 | flag |= ZERO;
118 | goto again;
119 | } /* fall through */
120 | case '1':
121 | case '2':
122 | case '3':
123 | case '4':
124 | case '5':
125 | case '6':
126 | case '7':
127 | case '8':
128 | case '9':
129 | minwidth *= 10;
130 | minwidth += c - '0';
131 | goto again;
132 | case 'X':
133 | flag |= UCASE;
134 | /* fall through */
135 | case 'x':
136 | b = 16;
137 | goto number;
138 | case 'd':
139 | b = 10;
140 | goto number;
141 | case 'o': case 'O':
142 | b = 8;
143 | number:
144 | printn((u_long)*adx, b, flag, minwidth, putfn_p, putfn_arg);
145 | break;
146 | case 's':
147 | s = (char *)*adx;
148 | while ((c = *s++)) {
149 | (*putfn_p)(c, putfn_arg);
150 | width++;
151 | }
152 | while (width++ < minwidth)
153 | (*putfn_p)(' ', putfn_arg);
154 | break;
155 | case 'c':
156 | (*putfn_p)((char)*adx, putfn_arg);
157 | break;
158 | }
159 | adx++;
160 | goto loop;
161 | }
162 |
--------------------------------------------------------------------------------
/i386/boot2/debug.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 by DHP.
3 | */
4 |
5 |
6 | //------------------------------------------------------------------------------
7 |
8 | #ifndef __REVO_CONFIG_SETTINGS
9 | #define __REVO_CONFIG_SETTINGS
10 |
11 | #include "../config/settings.h"
12 | #define DEBUG_STATE_ENABLED (DEBUG_ACPI || DEBUG_BOOT || DEBUG_CPU || DEBUG_DISK || \
13 | DEBUG_DRIVERS|| DEBUG_EFI || DEBUG_BOOT_GRAPHICS || \
14 | DEBUG_PLATFORM || DEBUG_SMBIOS)
15 |
16 | #endif // __REVO_CONFIG_SETTINGS
17 |
18 |
19 | //------------------------------------------------------------------------------
20 |
21 | #ifndef __REVO_DEBUG_H
22 | #define __REVO_DEBUG_H
23 |
24 |
25 | #if DEBUG_STATE_ENABLED
26 | #define _DEBUG_DUMP(x...) printf(x)
27 | #define _DEBUG_ELSE_DUMP(x...) else { printf(x); }
28 | #define _DEBUG_SLEEP(seconds) printf("Sleeping for %d second%s...\n", seconds, (seconds > 1) ? "s" : ""); sleep(seconds)
29 | #else
30 | #define _DEBUG_DUMP(x...)
31 | #define _DEBUG_ELSE_DUMP(x...)
32 | #define _DEBUG_SLEEP(seconds)
33 | #endif
34 |
35 |
36 | #if DEBUG_ACPI
37 | #define _ACPI_DEBUG_DUMP(x...) _DEBUG_DUMP(x)
38 | #define _ACPI_DEBUG_SLEEP(seconds) _DEBUG_SLEEP(seconds)
39 | #else
40 | #define _ACPI_DEBUG_DUMP(x...)
41 | #define _ACPI_DEBUG_SLEEP(seconds)
42 | #endif
43 |
44 |
45 | #if DEBUG_BOOT
46 | #define _BOOT_DEBUG_DUMP(x...) _DEBUG_DUMP(x)
47 | #define _BOOT_DEBUG_ELSE_DUMP(x...) _DEBUG_ELSE_DUMP(x)
48 | #define _BOOT_DEBUG_SLEEP(seconds) _DEBUG_SLEEP(seconds)
49 | #else
50 | #define _BOOT_DEBUG_DUMP(x...)
51 | #define _BOOT_DEBUG_ELSE_DUMP(x...)
52 | #define _BOOT_DEBUG_SLEEP(seconds)
53 | #endif
54 |
55 |
56 | #if DEBUG_CPU
57 | #define _CPU_DEBUG_DUMP(x...) _DEBUG_DUMP(x)
58 | #define _CPU_DEBUG_SLEEP(seconds) _DEBUG_SLEEP(seconds)
59 | #else
60 | #define _CPU_DEBUG_DUMP(x...)
61 | #define _CPU_DEBUG_SLEEP(seconds)
62 | #endif
63 |
64 |
65 | #if DEBUG_DISK
66 | #define _DISK_DEBUG_DUMP(x...) _DEBUG_DUMP(x)
67 | #define _DISK_DEBUG_SLEEP(seconds) _DEBUG_SLEEP(seconds)
68 | #define _DISK_DEBUG_ELSE_DUMP(x...) _DEBUG_ELSE_DUMP(x)
69 | #else
70 | #define _DISK_DEBUG_DUMP(x...)
71 | #define _DISK_DEBUG_SLEEP(seconds)
72 | #define _DISK_DEBUG_ELSE_DUMP(x...)
73 | #endif
74 |
75 |
76 | #if DEBUG_DRIVERS
77 | #define _DRIVERS_DEBUG_DUMP(x...) _DEBUG_DUMP(x)
78 | #define _DRIVERS_DEBUG_SLEEP(seconds) _DEBUG_SLEEP(seconds)
79 | #else
80 | #define _DRIVERS_DEBUG_DUMP(x...)
81 | #define _DRIVERS_DEBUG_SLEEP(seconds)
82 | #endif
83 |
84 |
85 | #if DEBUG_EFI
86 | #define _EFI_DEBUG_DUMP(x...) _DEBUG_DUMP(x)
87 | #define _EFI_DEBUG_SLEEP(seconds) _DEBUG_SLEEP(seconds)
88 | #else
89 | #define _EFI_DEBUG_DUMP(x...)
90 | #define _EFI_DEBUG_SLEEP(seconds)
91 | #endif
92 |
93 |
94 | #if DEBUG_PLATFORM
95 | #define _PLATFORM_DEBUG_DUMP(x...) _DEBUG_DUMP(x)
96 | #define _PLATFORM_DEBUG_SLEEP(seconds) _DEBUG_SLEEP(seconds)
97 | #else
98 | #define _PLATFORM_DEBUG_DUMP(x...)
99 | #define _PLATFORM_DEBUG_SLEEP(seconds)
100 | #endif
101 |
102 |
103 | #if DEBUG_SMBIOS
104 | #define _SMBIOS_DEBUG_DUMP(x...) _DEBUG_DUMP(x)
105 | #define _SMBIOS_DEBUG_SLEEP(seconds) _DEBUG_SLEEP(seconds)
106 | #else
107 | #define _SMBIOS_DEBUG_DUMP(x...)
108 | #define _SMBIOS_DEBUG_SLEEP(seconds)
109 | #endif
110 |
111 |
112 | #if (DEBUG_KERNEL_PATCHER & 1)
113 | #define DEBUG_SYMBOL_FOUND(symbol, offset, vmaddr, fileoff, start, end) \
114 | printf("Symbol %s found!\n", symbol); \
115 | printf("offset..............: 0x%llx\n", offset); \
116 | printf("textSegment->vmaddr.: 0x%llx\n", vmaddr); \
117 | printf("textSegment->fileoff: 0x%llx\n", fileoff); \
118 | printf("startAddress........: 0x%llx\n", start); \
119 | printf("endAddress..........: 0x%llx\n", end); \
120 | sleep(1);
121 | #else
122 | #define DEBUG_SYMBOL_FOUND(symbol, offset, vmaddr, fileoff, start, end)
123 | #endif
124 |
125 | #if (DEBUG_KERNEL_PATCHER & 2)
126 | #define DEBUG_PATCH_STATUS(symbol, address, seconds) \
127 | printf("Patched %s(@ 0x%x)\n", symbol, address); \
128 | \
129 | if (seconds) \
130 | { \
131 | sleep(seconds); \
132 | }
133 | #else
134 | #define DEBUG_PATCH_STATUS(symbol, address, seconds)
135 | #endif
136 |
137 | #if (DEBUG_KERNEL_PATCHER & 4)
138 | #define DEBUG_DISABLED_MSR(msr, seconds) \
139 | printf("Disabling MSR: 0x%x\n", msr); \
140 | \
141 | if (seconds) \
142 | { \
143 | sleep(seconds); \
144 | }
145 | #else
146 | #define DEBUG_DISABLED_MSR(msr, seconds)
147 | #endif
148 |
149 | #endif // __REVO_DEBUG_H
150 |
--------------------------------------------------------------------------------
/i386/libsaio/console.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /*
25 | * Mach Operating System
26 | * Copyright (c) 1990 Carnegie-Mellon University
27 | * Copyright (c) 1989 Carnegie-Mellon University
28 | * All rights reserved. The CMU software License Agreement specifies
29 | * the terms and conditions for use and redistribution.
30 | */
31 |
32 | /*
33 | * INTEL CORPORATION PROPRIETARY INFORMATION
34 | *
35 | * This software is supplied under the terms of a license agreement or
36 | * nondisclosure agreement with Intel Corporation and may not be copied
37 | * nor disclosed except in accordance with the terms of that agreement.
38 | *
39 | * Copyright 1988, 1989 Intel Corporation
40 | */
41 |
42 | /*
43 | * Copyright 1993 NeXT, Inc.
44 | * All rights reserved.
45 | */
46 |
47 | #include "libsaio.h"
48 | #include "bootstruct.h"
49 |
50 | extern int vprf(const char * fmt, va_list ap);
51 |
52 | bool gVerboseMode = false;
53 | bool gErrors = false;
54 |
55 |
56 | //==============================================================================
57 |
58 | void putchar(int c)
59 | {
60 | if ( c == '\t' )
61 | {
62 | for (c = 0; c < 8; c++)
63 | {
64 | putc(' ');
65 | }
66 | }
67 |
68 | if ( c == '\n' )
69 | {
70 | putc('\r');
71 | }
72 |
73 | putc(c);
74 | }
75 |
76 |
77 | //==============================================================================
78 |
79 | int getc()
80 | {
81 | int c = bgetc();
82 |
83 | if ((c & 0xff) == 0)
84 | {
85 | return c;
86 | }
87 |
88 | return (c & 0xff);
89 | }
90 |
91 |
92 | //==============================================================================
93 | // Read and echo a character from console. This doesn't echo backspace
94 | // since that screws up higher level handling
95 |
96 | int getchar()
97 | {
98 | register int c = getc();
99 |
100 | if ( c == '\r' )
101 | {
102 | c = '\n';
103 | }
104 |
105 | if ( c >= ' ' && c < 0x7f)
106 | {
107 | putchar(c);
108 | }
109 |
110 | return (c);
111 | }
112 |
113 |
114 | //==============================================================================
115 |
116 | int printf(const char * fmt, ...)
117 | {
118 | va_list ap;
119 | va_start(ap, fmt);
120 |
121 | if (bootArgs->Video_V1.v_display == VGA_TEXT_MODE)
122 | {
123 | prf(fmt, ap, putchar, 0);
124 | }
125 |
126 | va_end(ap);
127 |
128 | return 0;
129 | }
130 |
131 |
132 | //==============================================================================
133 |
134 | int verbose(const char * fmt, ...)
135 | {
136 | va_list ap;
137 |
138 | if (gVerboseMode)
139 | {
140 | va_start(ap, fmt);
141 |
142 | if (bootArgs->Video_V1.v_display == VGA_TEXT_MODE)
143 | {
144 | prf(fmt, ap, putchar, 0);
145 | }
146 |
147 | va_end(ap);
148 | }
149 |
150 | return(0);
151 | }
152 |
153 |
154 | //==============================================================================
155 |
156 | int error(const char * fmt, ...)
157 | {
158 | va_list ap;
159 | gErrors = true;
160 | va_start(ap, fmt);
161 |
162 | if (bootArgs->Video_V1.v_display == VGA_TEXT_MODE)
163 | {
164 | prf(fmt, ap, putchar, 0);
165 | }
166 |
167 | va_end(ap);
168 |
169 | return(0);
170 | }
171 |
172 |
173 | //==============================================================================
174 |
175 | void stop(const char * fmt, ...)
176 | {
177 | va_list ap;
178 |
179 | printf("\n");
180 | va_start(ap, fmt);
181 |
182 | if (bootArgs->Video_V1.v_display == VGA_TEXT_MODE)
183 | {
184 | prf(fmt, ap, putchar, 0);
185 | }
186 |
187 | va_end(ap);
188 | printf("\n");
189 |
190 | halt();
191 | }
192 |
--------------------------------------------------------------------------------
/i386/libsaio/vbe.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 | /*
25 | * Copyright 1993 NeXT, Inc.
26 | * All rights reserved.
27 | */
28 |
29 | #include "libsaio.h"
30 | #include "vbe.h"
31 |
32 | // Various inline routines for video I/O
33 |
34 | static biosBuf_t bb;
35 |
36 |
37 | //==============================================================================
38 |
39 | int getVBEInfo(void * infoBlock)
40 | {
41 | bb.intno = 0x10;
42 | bb.eax.rr = funcGetControllerInfo;
43 | bb.es = SEG( infoBlock );
44 | bb.edi.rr = OFF( infoBlock );
45 | bios(&bb);
46 |
47 | return(bb.eax.r.h);
48 | }
49 |
50 |
51 | //==============================================================================
52 |
53 | int getVBEModeInfo(int mode, void * minfo_p)
54 | {
55 | bb.intno = 0x10;
56 | bb.eax.rr = funcGetModeInfo;
57 | bb.ecx.rr = mode;
58 | bb.es = SEG(minfo_p);
59 | bb.edi.rr = OFF(minfo_p);
60 | bios(&bb);
61 |
62 | return(bb.eax.r.h);
63 | }
64 |
65 |
66 | //==============================================================================
67 |
68 | int setVBEMode(unsigned short mode, const VBECRTCInfoBlock * timing)
69 | {
70 | bb.intno = 0x10;
71 | bb.eax.rr = funcSetMode;
72 | bb.ebx.rr = mode;
73 |
74 | if (timing) {
75 | bb.es = SEG(timing);
76 | bb.edi.rr = OFF(timing);
77 | }
78 |
79 | bios(&bb);
80 |
81 | return(bb.eax.r.h);
82 | }
83 |
84 |
85 | //==============================================================================
86 |
87 | int setVBEPalette(void *palette)
88 | {
89 | bb.intno = 0x10;
90 | bb.eax.rr = funcGetSetPaletteData;
91 | bb.ebx.r.l = subfuncSet;
92 | bb.ecx.rr = 256;
93 | bb.edx.rr = 0;
94 | bb.es = SEG(palette);
95 | bb.edi.rr = OFF(palette);
96 | bios(&bb);
97 |
98 | return(bb.eax.r.h);
99 | }
100 |
101 |
102 | #if (USE_STATIC_DISPLAY_RESOLUTION == 0)
103 | //==============================================================================
104 | // Called from initGraphicsMode() in graphics.c
105 |
106 | unsigned long getResolutionFromEDID(void)
107 | {
108 | UInt8 data[128];
109 | UInt8 targetBlock = 0;
110 | const UInt8 header[] = { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 };
111 |
112 | bzero(data, 128);
113 |
114 | do
115 | {
116 | bb.intno = 0x10;
117 | bb.eax.rr = 0x4F15;
118 | bb.ebx.r.l = 0x01;
119 | bb.edx.rr = targetBlock++;
120 | bb.es = SEG((void *)data);
121 | bb.edi.rr = OFF((void *)data);
122 | bios(&bb);
123 |
124 | // BIOS / display supports Display Data Channel (EDID) reading?
125 | if ( ((bb.eax.rr & 0xff00) == 0) && ((bb.eax.rr & 0xff) == 0x4f) )
126 | {
127 | // Yes, supported. Check EDID header against known headers.
128 | if (memcmp(data, header, sizeof(header)) != 0)
129 | {
130 | #if DEBUG_BOOT_GRAPHICS
131 | printf("targetBlock: %d\n", targetBlock);
132 | #endif
133 | continue;
134 | }
135 |
136 | #if DEBUG_BOOT_GRAPHICS
137 | short r = 0;
138 |
139 | for (short i = 0; i < 128; i++)
140 | {
141 | printf(" %02x", data[i]);
142 |
143 | r++;
144 |
145 | if (r == 16)
146 | {
147 | r = 0;
148 | printf("\n");
149 | sleep(1);
150 | }
151 |
152 | if (data[126] == 0)
153 | {
154 | targetBlock = 0;
155 | }
156 | }
157 | #endif
158 | return (((data[56] | ((data[58] & 0xF0) << 4)) << 16) | (data[59] | ((data[61] & 0xF0) << 4)));
159 | }
160 | else
161 | {
162 | #if DEBUG_BOOT_GRAPHICS
163 | printf("Error: Unable to get EDID (unsupported in BIOS/display)!\n");
164 | #endif
165 | targetBlock = 0;
166 | }
167 | } while (targetBlock);
168 |
169 | return 0;
170 | }
171 | #endif
172 |
--------------------------------------------------------------------------------
/i386/libsaio/acpi.c:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * This file contains Original Code and/or Modifications of Original Code
4 | * as defined in and that are subject to the Apple Public Source License
5 | * Version 2.0 (the 'License'). You may not use this file except in
6 | * compliance with the License. The rights granted to you under the License
7 | * may not be used to create, or enable the creation or redistribution of,
8 | * unlawful or unlicensed copies of an Apple operating system, or to
9 | * circumvent, violate, or enable the circumvention or violation of, any
10 | * terms of an Apple operating system software license agreement.
11 | *
12 | * Please obtain a copy of the License at
13 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
14 | *
15 | * The Original Code and all software distributed under the License are
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 | * Please see the License for the specific language governing rights and
21 | * limitations under the License.
22 | *
23 | * Portions of source code Copyright (c) 2008 by Macerintel, additional
24 | * changes by: Master Chief (2009) and Rekursor in 2009. All rights reserved.
25 | *
26 | * EFI implementation for Revolution Copyright (c) 2010 by DHP.
27 | * All rights reserved.
28 | *
29 | * Updates:
30 | *
31 | * - Moved #include to end of file, eliminating need of extern in patcher.h (PikerAlpha, October 2012).
32 | */
33 |
34 |
35 | #include "platform.h"
36 |
37 | #include "acpi/essentials.h" // Depends on ACPI_10_SUPPORT.
38 | #include "acpi/debug.h" // Depends on the DEBUG directive.
39 |
40 |
41 | //==========================================================================
42 |
43 | void updateACPITableData(struct acpi_2_rsdp * rsdp, struct acpi_2_xsdt * xsdt, int entryCount)
44 | {
45 | #if ACPI_10_SUPPORT
46 |
47 | _ACPI_DEBUG_DUMP("\nPatching RSDP and XSDT tables... ");
48 |
49 | // Update revision info (fake ACPI 2.0).
50 | rsdp->Revision = 1;
51 |
52 | // Update pointers.
53 | rsdp->RsdtAddress = (uint32_t) xsdt;
54 | rsdp->XsdtAddress = rsdp->RsdtAddress;
55 |
56 | // Expand length (32-bit -> 64-bit addresses).
57 | rsdp->Length = sizeof(struct acpi_2_xsdt) + (entryCount * 8);
58 |
59 | // Set initial checksum (will be corrected at the end of this run).
60 | rsdp->Checksum = 0;
61 | rsdp->ExtendedChecksum = 0;
62 |
63 | // Change RSDT signature into XSDT.
64 | xsdt->Signature[0] = 'X';
65 |
66 | #else
67 | _ACPI_DEBUG_DUMP("\nUpdating XSDT address... ");
68 |
69 | rsdp->XsdtAddress = (uint32_t) xsdt;
70 |
71 | #endif // ACPI_10_SUPPORT
72 |
73 | _ACPI_DEBUG_DUMP("(done).\n");
74 | }
75 |
76 |
77 | #if APPLE_STYLE_ACPI
78 | //------------------------- Used in acpi/patcher.h -------------------------
79 | #define _ACPI_SET(target, str, len) strncpy(target, str, len)
80 | #define _ACPI_SET_APPLE_OEMID(target) _ACPI_SET((target)->OEMID, "Apple ", 6)
81 | #define _ACPI_SET_APPLE_OEMTargetID(target) _ACPI_SET((target)->OEMTableID, gPlatform.CommaLessModelID, 8)
82 | //--------------------------------------------------------------------------
83 | #else
84 | //--------------------------- Void replacements ----------------------------
85 | #define _ACPI_SET(target, str, len)
86 | #define _ACPI_SET_APPLE_OEMID(target)
87 | #define _ACPI_SET_APPLE_OEMTargetID(target)
88 | //--------------------------------------------------------------------------
89 | #endif
90 |
91 |
92 | //==============================================================================
93 | // Original version written by macerintel (?). Rewrite by Master Chief in 2009.
94 |
95 | struct acpi_2_rsdp * getACPIBaseAddress()
96 | {
97 | _ACPI_DEBUG_DUMP("getACPIBaseAddress(");
98 |
99 | #if USE_STATIC_ACPI_BASE_ADDRESS
100 | _ACPI_DEBUG_DUMP("0x%08x)\n", STATIC_ACPI_BASE_ADDRESS);
101 | _ACPI_DEBUG_SLEEP(5);
102 |
103 | return (void *)STATIC_ACPI_BASE_ADDRESS;
104 | #else
105 | void *baseAddress = (void *)0x000E0000;
106 |
107 | for (; baseAddress <= (void *)0x000FFFFF; baseAddress += 16)
108 | {
109 | if (*(uint64_t *)baseAddress == ACPI_SIGNATURE_UINT64_LE)
110 | {
111 | if (checksum8(baseAddress, 20) == 0)
112 | {
113 | uint8_t revision = ((struct acpi_2_rsdp*)baseAddress)->Revision;
114 |
115 | if (revision == 0 ||
116 | (revision > 0 && checksum8(baseAddress, sizeof(struct acpi_2_rsdp)) == 0))
117 | {
118 | _ACPI_DEBUG_DUMP("0x%08x)\n", baseAddress);
119 |
120 | return baseAddress;
121 | }
122 | }
123 | }
124 | }
125 |
126 | _ACPI_DEBUG_DUMP("NULL)\n");
127 |
128 | return NULL;
129 | #endif
130 | }
131 |
132 | #include "acpi/patcher.h" // Macro's in this include file must be live now.
133 |
--------------------------------------------------------------------------------
/i386/libsaio/efi/efi.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 | *
4 | * This file contains Original Code and/or Modifications of Original Code
5 | * as defined in and that are subject to the Apple Public Source License
6 | * Version 2.0 (the 'License'). You may not use this file except in
7 | * compliance with the License. The rights granted to you under the License
8 | * may not be used to create, or enable the creation or redistribution of,
9 | * unlawful or unlicensed copies of an Apple operating system, or to
10 | * circumvent, violate, or enable the circumvention or violation of, any
11 | * terms of an Apple operating system software license agreement.
12 | *
13 | * Please obtain a copy of the License at
14 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
15 | *
16 | * The Original Code and all software distributed under the License are
17 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
18 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
19 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
21 | * Please see the License for the specific language governing rights and
22 | * limitations under the License.
23 | *
24 | * EFI implementation for Revolution Copyright (c) 2010 by DHP.
25 | * All rights reserved.
26 | *
27 | */
28 |
29 | #ifndef _LIBSAIO_EFI_EFI_H
30 | #define _LIBSAIO_EFI_EFI_H
31 |
32 | ///
33 | /// 32/64-bit native width with the highest bit set.
34 | ///
35 | #if EFI_64_BIT
36 | #define EFI_MAX_BIT 0x8000000000000000ULL
37 | #else
38 | #define EFI_MAX_BIT 0x80000000
39 | #endif
40 |
41 | #include "EfiError.h"
42 |
43 | // Set up space for up to 5 tables but we currently only add two.
44 | #define EFI_MAX_CONFIG_TABLES 5
45 |
46 | #if EFI_64_BIT
47 | // Mountain Lion, Mavericks and Yosemite
48 | //
49 | // movabs $0x8000000000000003,%rax
50 | // ret
51 | static uint8_t const UNSUPPORTEDRET_INSTRUCTIONS[] = { 0x48, 0xb8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc3 };
52 | #else
53 | // Lion, Snow Leopard and Leopard
54 | //
55 | // movl $0x80000003,%eax
56 | // ret
57 | static uint8_t const UNSUPPORTEDRET_INSTRUCTIONS[] = { 0xb8, 0x03, 0x00, 0x00, 0x80, 0xc3 };
58 | #endif
59 |
60 | // EFI Revision info.
61 | //
62 | #if EFI_64_BIT
63 | #define EFI_SPEC_MAJOR_REVISION 2
64 | #define EFI_SPEC_MINOR_REVISION 31
65 | #else
66 | #define EFI_SPEC_MAJOR_REVISION 1
67 | #define EFI_SPEC_MINOR_REVISION 10
68 | #endif
69 |
70 | // EFI System Table.
71 | //
72 | #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249ULL
73 | #define EFI_SYSTEM_TABLE_REVISION ((EFI_SPEC_MAJOR_REVISION << 16) | (EFI_SPEC_MINOR_REVISION))
74 |
75 | // EFI Runtime Services Table.
76 | //
77 | #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552ULL
78 | #define EFI_RUNTIME_SERVICES_REVISION ((EFI_SPEC_MAJOR_REVISION << 16) | (EFI_SPEC_MINOR_REVISION))
79 |
80 |
81 | typedef struct
82 | {
83 | EFI_UINT64 Signature;
84 | EFI_UINT32 Revision;
85 | EFI_UINT32 HeaderSize;
86 | EFI_UINT32 CRC32;
87 | EFI_UINT32 Reserved;
88 | } __attribute__((aligned(8))) EFI_TABLE_HEADER;
89 |
90 |
91 | typedef struct
92 | {
93 | EFI_TABLE_HEADER Hdr;
94 |
95 | // Time Services
96 | EFI_PTR GetTime;
97 | EFI_PTR SetTime;
98 | EFI_PTR GetWakeupTime;
99 | EFI_PTR SetWakeupTime;
100 |
101 | // Virtual Memory Services
102 | EFI_PTR SetVirtualAddressMap;
103 | EFI_PTR ConvertPointer;
104 |
105 | // Variable Services
106 | EFI_PTR GetVariable;
107 | EFI_PTR GetNextVariableName;
108 | EFI_PTR SetVariable;
109 |
110 | // Miscellaneous Services
111 | EFI_PTR GetNextHighMonotonicCount;
112 | EFI_PTR ResetSystem;
113 |
114 | // UEFI 2.0 Capsule Services
115 | EFI_PTR UpdateCapsule;
116 | EFI_PTR QueryCapsuleCapabilities;
117 |
118 | // Miscellaneous UEFI 2.0 Service
119 | EFI_PTR QueryVariableInfo;
120 | } __attribute__((aligned(8))) EFI_RUNTIME_SERVICES;
121 |
122 |
123 | typedef struct EFI_CONFIGURATION_TABLE
124 | {
125 | EFI_GUID VendorGuid;
126 | EFI_PTR VendorTable;
127 | #if EFI_64_BIT
128 | } __attribute__((aligned(8))) EFI_CONFIGURATION_TABLE;
129 | #else
130 | } EFI_CONFIGURATION_TABLE;
131 | #endif
132 |
133 |
134 | typedef struct EFI_SYSTEM_TABLE
135 | {
136 | EFI_TABLE_HEADER Hdr;
137 |
138 | EFI_PTR FirmwareVendor;
139 | EFI_UINT32 FirmwareRevision;
140 |
141 | #if EFI_64_BIT
142 | EFI_UINT32 __pad;
143 | #endif
144 |
145 | EFI_HANDLE ConsoleInHandle;
146 | EFI_PTR ConIn;
147 |
148 | EFI_HANDLE ConsoleOutHandle;
149 | EFI_PTR ConOut;
150 |
151 | EFI_HANDLE StandardErrorHandle;
152 | EFI_PTR StdErr;
153 |
154 | EFI_PTR RuntimeServices;
155 | EFI_PTR BootServices;
156 |
157 | EFI_UINT NumberOfTableEntries;
158 | EFI_PTR ConfigurationTable;
159 | } __attribute__((aligned(8))) EFI_SYSTEM_TABLE;
160 |
161 | #endif /* _LIBSAIO_EFI_EFI_H */
162 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/tools/PMinfo/AppleIntelCPUPowerManagementInfo/AppleIntelCPUPowerManagementInfo.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012-2014 Pike R. Alpha. All rights reserved.
3 | *
4 | * Original idea and initial development of MSRDumper.kext (c) 2011 by RevoGirl.
5 | *
6 | * Thanks to George for his help and continuation of Sam's work, but it is
7 | * time for us to push the envelope and add some really interesting stuff.
8 | *
9 | */
10 |
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | #include
18 | #include
19 |
20 | #include "../../../essentials.h"
21 |
22 | #define super IOService
23 |
24 | #define VERSION "3.3"
25 |
26 | #define REPORT_MSRS 1
27 | #define REPORT_IGPU_P_STATES 1
28 | #define REPORT_C_STATES 1
29 | #define REPORT_IPG_STYLE 1
30 |
31 | #define NB_BUS 0x00
32 | #define NB_DEV 0x00
33 | #define NB_FUN 0x00
34 |
35 | #define DEVEN (0x54)
36 | #define DEVEN_D2EN_MASK (0x10)
37 |
38 | #define NB_PCICFG_SPACE_INDEX_REG 0xcf8
39 | #define NB_PCICFG_SPACE_DATA_REG 0xcfc
40 |
41 | #define BIT31 0x80000000
42 |
43 | #define PCIEX_BASE_ADDRESS 0xF8000000
44 | #define NB_MCH_BASE_ADDRESS 0xFED10000 // (G)MCH Memory Mapped Register Range Base Address (D0:F0:Rx48).
45 |
46 | #define READ_PCI8(Bx, Dx, Fx, Rx) ReadPci8(Bx, Dx, Fx, Rx)
47 | #define READ_PCI8_NB(Rx) READ_PCI8(NB_BUS, NB_DEV, NB_FUN, Rx)
48 | #define MMIO_READ8(Address) (*(volatile UInt8 *)(Address))
49 |
50 | #define IGPU_RATIO_TO_FREQUENCY(ratio) ((ratio * 100) / 2)
51 |
52 | #define NB_PCI_CFG_ADDRESS(bus, dev, func, reg) \
53 | (UInt64) ((((UInt8)(bus) << 24) + ((UInt8)(dev) << 16) + \
54 | ((UInt8)(func) << 8) + ((UInt8)(reg))) & 0xffffffff)
55 |
56 | #define NB_PCIE_CFG_ADDRESS(bus, dev, func, reg) \
57 | ((UInt32)(PCIEX_BASE_ADDRESS + ((UInt8)(bus) << 20) + \
58 | ((UInt8)(dev) << 15) + ((UInt8)(func) << 12) + (reg)))
59 |
60 | static __inline__ unsigned char inb(UInt16 port)
61 | {
62 | UInt8 value;
63 | __asm__ volatile("inb %w1, %b0" : "=a" (value) : "Nd" (port));
64 | return (value);
65 | }
66 |
67 | static __inline__ void outl(UInt16 port, UInt32 value)
68 | {
69 | __asm__ volatile("outl %0, %w1" : : "a" (value), "Nd" (port));
70 | }
71 |
72 | UInt8 ReadPci8(UInt8 Bus, UInt8 Dev, UInt8 Fun, UInt16 Reg)
73 | {
74 | if (Reg >= 0x100)
75 | {
76 | return MMIO_READ8((UInt64)NB_PCIE_CFG_ADDRESS(Bus, Dev, Fun, Reg));
77 | }
78 | else
79 | {
80 | outl(NB_PCICFG_SPACE_INDEX_REG, BIT31 | (Bus << 16) | (Dev << 11) | (Fun << 8) | (Reg & 0xfc));
81 | return inb(NB_PCICFG_SPACE_DATA_REG | (UInt8)(Reg & 3));
82 | }
83 | }
84 |
85 | extern "C" void mp_rendezvous_no_intrs(void (*action_func)(void *), void * arg);
86 | extern "C" int cpu_number(void);
87 |
88 | class AppleIntelCPUPowerManagementInfo : public IOService
89 | {
90 | OSDeclareDefaultStructors (AppleIntelCPUPowerManagementInfo);
91 |
92 | private:
93 | IOSimpleLock *simpleLock;
94 | IOWorkLoop *workLoop;
95 | IOTimerEventSource *timerEventSource;
96 |
97 | #if REPORT_IGPU_P_STATES
98 | IOMemoryDescriptor *memDescriptor;
99 | IOMemoryMap *memoryMap;
100 |
101 | bool igpuEnabled = false; // Set logIGPU to in Info.plist to enable this feature.
102 | #endif
103 |
104 | IOReturn result = kIOReturnSuccess;
105 |
106 | virtual IOReturn loopTimerEvent(void);
107 |
108 | #if REPORT_MSRS
109 | void reportMSRs(UInt8 aCPUModel);
110 |
111 | bool logMSRs = true; // Set logIGPU to in Info.plist to disable this feature.
112 | #endif
113 |
114 | bool loopLock = false;
115 |
116 | #if REPORT_C_STATES
117 | bool logCStates = true; // Set logCStates to in Info.plist to disable this feature.
118 | #endif
119 |
120 | #if REPORT_IPG_STYLE
121 | bool logIPGStyle = true; // Set logIPGStyle to in Info.plist to disable this feature.
122 | #endif
123 |
124 | UInt16 Interval = 50;
125 |
126 | UInt64 gCoreMultipliers = 0ULL;
127 | UInt64 gTriggeredPStates = 0ULL;
128 |
129 | UInt64 gIGPUMultipliers = 0ULL;
130 | UInt64 gTriggeredIGPUPStates = 0ULL;
131 |
132 | public:
133 | virtual IOService * probe(IOService * provider, SInt32 * score);
134 | virtual bool start(IOService * provider);
135 | virtual void stop(IOService * provider);
136 | virtual void free(void);
137 |
138 | UInt8 gMinRatio = 0;
139 | UInt8 gClockRatio = 0;
140 | UInt8 gMaxRatio = 0;
141 | };
142 |
143 | OSDefineMetaClassAndStructors(AppleIntelCPUPowerManagementInfo, IOService)
144 |
145 | UInt8 gCoreStates = 0ULL;
146 |
147 | #if REPORT_C_STATES
148 | bool gCheckC3 = true;
149 | bool gCheckC6 = true;
150 | bool gCheckC7 = false;
151 |
152 | UInt32 gC3Cores = 0;
153 | UInt32 gC6Cores = 0;
154 | UInt32 gC7Cores = 0;
155 |
156 | UInt32 gTriggeredC3Cores = 0;
157 | UInt32 gTriggeredC6Cores = 0;
158 | UInt32 gTriggeredC7Cores = 0;
159 | #endif
160 |
161 | UInt64 gCoreMultipliers = 0ULL;
162 |
163 | #if REPORT_IGPU_P_STATES
164 | UInt8 * gMchbar = NULL;
165 | #endif
--------------------------------------------------------------------------------
/i386/libsaio/smbios/tools/smbios2struct.c:
--------------------------------------------------------------------------------
1 | /***
2 | *
3 | * Name : smbios2struct (pipe output to file)
4 | * Version : 1.0.1
5 | * Type : Command line tool
6 | * Description : Tool to extract / convert the SMBIOS data into a structure for Revolution's smbios/data.h
7 | *
8 | * Copyright : DutchHockeyPro (c) 2010
9 | *
10 | * Compile with: cc -I . smbios2struct.c -o smbios2struct -Wall -framework IOKit -framework CoreFoundation
11 | *
12 | */
13 |
14 | #include
15 | #include
16 |
17 | #include
18 | #include
19 |
20 | #include "essentials.h"
21 |
22 | #define DEBUG 1 // Set to 1 for additional (debug) output
23 | #define round2(x, m) (((x) + (m / 2)) & ~(m - 1)) // Taken from saio_types.h
24 |
25 | int main(int argc, char * argv[])
26 | {
27 | int index = 0;
28 | mach_port_t masterPort;
29 | io_service_t service = MACH_PORT_NULL;
30 | CFDataRef dataRef;
31 |
32 | UInt16 maxStructureSize, structureCount = 0;
33 |
34 | IOMasterPort(MACH_PORT_NULL, &masterPort);
35 | service = IOServiceGetMatchingService(masterPort, IOServiceMatching("AppleSMBIOS"));
36 |
37 | if (service)
38 | {
39 | #if DEBUG
40 | printf("\nHave AppleSMBIOS\n");
41 | #endif
42 | dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service,
43 | CFSTR("SMBIOS-EPS"),
44 | kCFAllocatorDefault,
45 | kNilOptions);
46 |
47 | if (dataRef)
48 | {
49 | // We could use isA_CFData(dataRef) {} here, but that would force us to include
50 | // another file, which in my opinion would be overkill (dataRef should always be there).
51 | #if DEBUG
52 | printf("Have SMBIOS-EPS dataRef\n\n");
53 | #endif
54 | struct SMBEntryPoint * smbiosEPSData = (struct SMBEntryPoint *) CFDataGetBytePtr(dataRef);
55 | #if DEBUG
56 | // _SM_
57 | smbiosEPSData->anchor[4] = 0; // Prevent garbage output.
58 | printf("anchor : %s\n", smbiosEPSData->anchor);
59 | printf("checksum : 0x%x\n", smbiosEPSData->checksum);
60 | printf("entryPointLength : 0x%x\n", smbiosEPSData->entryPointLength);
61 | printf("majorVersion : 0x%02x\n", smbiosEPSData->majorVersion);
62 | printf("minorVersion : 0x%02x\n", smbiosEPSData->minorVersion);
63 | #endif
64 | maxStructureSize = smbiosEPSData->maxStructureSize;
65 | #if DEBUG
66 | printf("maxStructureSize : 0x%04x\n", maxStructureSize);
67 | printf("entryPointRevision: 0x%02x\n", smbiosEPSData->entryPointRevision);
68 | printf("formattedArea : %s\n\n", smbiosEPSData->formattedArea);
69 |
70 | // _DMI_
71 | smbiosEPSData->dmi.anchor[5] = 0; // Prevent garbage output.
72 | printf("dmi.anchor : %s\n", smbiosEPSData->dmi.anchor);
73 | printf("dmi.checksum : 0x%02x\n", smbiosEPSData->dmi.checksum);
74 | printf("dmi.tableLength : 0x%04x\n", smbiosEPSData->dmi.tableLength);
75 | printf("dmi.tableAddress : 0x%08x\n", (unsigned int)smbiosEPSData->dmi.tableAddress);
76 | #endif
77 | structureCount = smbiosEPSData->dmi.structureCount;
78 | #if DEBUG
79 | printf("dmi.structureCount: 0x%04x\n", structureCount);
80 | printf("dmi.bcdRevision : 0x%x\n", smbiosEPSData->dmi.bcdRevision);
81 | #endif
82 | // Done with dataRef / release it.
83 | CFRelease(dataRef);
84 | }
85 | #if DEBUG
86 | printf("\n");
87 | #endif
88 |
89 | dataRef = (CFDataRef) IORegistryEntryCreateCFProperty(service,
90 | CFSTR("SMBIOS"),
91 | kCFAllocatorDefault,
92 | kNilOptions);
93 |
94 | if (dataRef)
95 | {
96 | // We could use isA_CFData(dataRef) {} here, but that would force us to include another
97 | // header file, which in my opinion would be overkill as dataRef should always be there.
98 | #if DEBUG
99 | printf("Have SMBIOS dataRef\n");
100 | #endif
101 | UInt32 * smbiosData = (UInt32 *) CFDataGetBytePtr(dataRef);
102 | UInt16 numBytes = (int) CFDataGetLength(dataRef);
103 |
104 | #if DEBUG
105 | printf("Number of bytes : %d\n", numBytes);
106 | #endif
107 | UInt16 length = round2((numBytes / 4), 4); // Is this right?
108 |
109 | printf("\n#define SM_STRUCTURE_SIZE\t%d\n", maxStructureSize);
110 | printf("#define DMI_STRUCTURE_COUNT\t%d\n", structureCount);
111 | printf("\n");
112 | printf("/* SMBIOS data (0x%04x / %d values) converted with smbios2struct into little endian format. */\n", length, length);
113 | printf("static uint32_t SMBIOS_Table[] = \n");
114 | printf("{\n\t/* 0x0000 */\t");
115 |
116 | do {
117 | printf("0x%08x", (unsigned int)smbiosData[index++]);
118 |
119 | if (index < length)
120 | {
121 | printf(", ");
122 | }
123 |
124 | // We want a newline character after every 8th double-word.
125 | if ((index % 8) == 0)
126 | {
127 | printf("\n\t/* 0x%04x */\t", (index * 4));
128 | }
129 |
130 | } while (index < length);
131 |
132 | printf("\n};\n");
133 |
134 | // Done with dataRef / release it.
135 | CFRelease(dataRef);
136 | }
137 |
138 | // Done with the service / release it.
139 | IOObjectRelease(service);
140 | }
141 |
142 | exit(0);
143 | }
144 |
--------------------------------------------------------------------------------
/i386/boot2/bootlogo.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | * Copyright 1993 NeXT, Inc. All rights reserved.
25 | *
26 | * Refactorizing done by DHP in 2011.
27 | */
28 |
29 | #include "boot.h"
30 | #include "bootlogo.h"
31 | #include "bootstruct.h"
32 |
33 | #define DEBUG 0
34 |
35 | //==============================================================================
36 |
37 | unsigned long lookUpCLUTIndex(unsigned char index)
38 | {
39 | long colorIndex = (index * 3);
40 | #if (((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) && (BLACKMODE == 1)) // Yosemite, El Capitan and Sierra.
41 | long red = AppleLogoBlackClut[ colorIndex ];
42 | long green = AppleLogoBlackClut[ colorIndex++ ];
43 | long blue = AppleLogoBlackClut[ colorIndex++ ];
44 | #else
45 | long red = AppleLogoClut[ colorIndex ];
46 | long green = AppleLogoClut[ colorIndex++ ];
47 | long blue = AppleLogoClut[ colorIndex++ ];
48 | #endif
49 |
50 | return (red << 16) | (green << 8) | blue;
51 | }
52 |
53 | //==============================================================================
54 |
55 | void * stosl(void *dst, long val, long len)
56 | {
57 | asm volatile ("rep; stosl"
58 | : "=c" (len), "=D" (dst)
59 | : "0" (len), "1" (dst), "a" (val)
60 | : "memory" );
61 |
62 | return dst;
63 | }
64 |
65 | //==============================================================================
66 |
67 | void setBackgroundColor(uint32_t aBackGroundColor)
68 | {
69 | long pixelBytes = VIDEO(depth) / 8;
70 |
71 | char * vram = (char *) VIDEO(baseAddr) + VIDEO(rowBytes) + pixelBytes;
72 |
73 | int width = VIDEO(width);
74 | int height = VIDEO(height);
75 |
76 | int rem = (pixelBytes * width) % 4;
77 | int length = pixelBytes * width / 4;
78 |
79 | bcopy(&aBackGroundColor, vram, rem);
80 |
81 | while (height--)
82 | {
83 | stosl(vram + rem, aBackGroundColor, length);
84 | vram += VIDEO(rowBytes);
85 | }
86 | }
87 |
88 | //==============================================================================
89 |
90 | void drawDataRectangle(unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char *data)
91 | {
92 | long pixelBytes = VIDEO(depth) / 8;
93 |
94 | char * vram = (char *) VIDEO(baseAddr) + VIDEO(rowBytes) * y + pixelBytes * x;
95 |
96 | height = MIN(height, VIDEO(height) - y);
97 |
98 | if (data)
99 | {
100 | while (height--)
101 | {
102 | bcopy(data, vram, (width * pixelBytes));
103 | vram += VIDEO(rowBytes);
104 | data += (width * pixelBytes);
105 | }
106 | }
107 | }
108 |
109 | //==============================================================================
110 |
111 | int convertImage(unsigned short width, unsigned short height, const unsigned char *imageData, unsigned char **newImageData)
112 | {
113 | int index = 0;
114 | int size = (width * height); // 16384
115 | int depth = VIDEO(depth);
116 |
117 | unsigned char *img = 0;
118 | unsigned long *img32;
119 |
120 | switch (depth)
121 | {
122 | case 32:
123 | img32 = malloc(size * 4);
124 |
125 | if (!img32)
126 | {
127 | break;
128 | }
129 |
130 | for (; index < size; index++)
131 | {
132 | img32[index] = lookUpCLUTIndex(imageData[index]);
133 | }
134 |
135 | img = (unsigned char *)img32;
136 | break;
137 | }
138 |
139 | *newImageData = img;
140 |
141 | return 0;
142 | }
143 |
144 |
145 | //==============================================================================
146 |
147 | void showBootLogo()
148 | {
149 | setVideoMode(GRAPHICS_MODE);
150 |
151 | #if (((MAKE_TARGET_OS & YOSEMITE) == YOSEMITE) && (BLACKMODE == 1)) // Yosemite, El Capitan and Sierra.
152 | setBackgroundColor(0x030000);
153 | uint32_t compressedSize = sizeof(AppleLogoBlackPacked);
154 | void *logoData = (void *)AppleLogoBlackPacked;
155 | #else
156 | setBackgroundColor(0xbfbfbf);
157 | uint32_t compressedSize = sizeof(AppleLogoPacked);
158 | void *logoData = (void *)AppleLogoPacked;
159 | #endif
160 |
161 | int logoSize = (APPLE_LOGO_WIDTH * APPLE_LOGO_HEIGHT);
162 | void * decompressedData = malloc(logoSize);
163 |
164 | if (decompressedData)
165 | {
166 | if (lzvn_decode(decompressedData, logoSize, logoData, compressedSize) == logoSize)
167 | {
168 | uint8_t *bootImageData = NULL;
169 | convertImage(APPLE_LOGO_WIDTH, APPLE_LOGO_HEIGHT, decompressedData, &bootImageData);
170 | drawDataRectangle(APPLE_LOGO_X, APPLE_LOGO_Y, APPLE_LOGO_WIDTH, APPLE_LOGO_HEIGHT, bootImageData);
171 | }
172 |
173 | free(decompressedData);
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/i386/boot2/options.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2004 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2004 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | */
24 |
25 | #include "boot.h"
26 | #include "bootstruct.h"
27 |
28 | extern BVRef bvChain;
29 |
30 | static char gBootArgs[BOOT_STRING_LEN];
31 | static char * gBootArgsPtr = gBootArgs;
32 | static char * gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1;
33 |
34 |
35 | //==============================================================================
36 |
37 | static void skipblanks(const char ** cpp)
38 | {
39 | while (**(cpp) == ' ' || **(cpp) == '\t' ) ++(*cpp);
40 | }
41 |
42 |
43 | //==============================================================================
44 |
45 | bool copyArgument(const char *argName, const char *val, int cnt, char **argP, int *cntRemainingP)
46 | {
47 | int argLen = argName ? strlen(argName) : 0;
48 | int len = argLen + cnt + 1; // + 1 to account for space.
49 |
50 | if (len > *cntRemainingP)
51 | {
52 | // error("Warning: boot arguments too long, truncating\n");
53 | return false;
54 | }
55 |
56 | if (argName)
57 | {
58 | strncpy(*argP, argName, argLen);
59 | *argP += argLen;
60 | *argP[0] = '=';
61 | (*argP)++;
62 | len++; // +1 to account for '='
63 | }
64 |
65 | strncpy(*argP, val, cnt);
66 | *argP += cnt;
67 | *argP[0] = ' ';
68 | (*argP)++;
69 | *cntRemainingP -= len;
70 |
71 | return true;
72 | }
73 |
74 |
75 | //==============================================================================
76 | // Copyright (c) 2010 by DHP. All rights reserved.
77 |
78 | void getAndProcessBootArguments(char * configKernelFlags)
79 | {
80 | bool truncated = false;
81 |
82 | const char * cp = gBootArgs;
83 |
84 | char * argP = bootArgs->CommandLine;
85 |
86 | int key;
87 | int pressedKey = 0;
88 | int cntRemaining = BOOT_STRING_LEN - 2; // (1024 -2)
89 | int kernelFlagsLength = strlen(configKernelFlags);
90 |
91 | int index = 1;
92 | int bootModes[6] = { -1, kBootModeNormal, kBootModeNormal, -1, kBootModeSafe, kBootModeNormal };
93 | const char * bootFlags[6] = { "", kVerboseModeFlag, kSingleUserModeFlag, "", kSafeModeFlag, kIgnoreCachesFlag };
94 |
95 | bzero(gBootArgs, sizeof(gBootArgs));
96 | skipblanks(&cp);
97 |
98 | while (readKeyboardStatus())
99 | {
100 | key = (bgetc() & 0xff);
101 |
102 | switch (key |= 0x20)
103 | {
104 | case 'v': // Verbose booting.
105 | printf("V\n");
106 | pressedKey |= 1;
107 | break;
108 |
109 | case 's': // Single user mode.
110 | printf("S\n");
111 | pressedKey |= 2;
112 | break;
113 |
114 | case 'x': // Safe mode.
115 | printf("X\n");
116 | pressedKey |= 4;
117 | break;
118 |
119 | case 'f': // Skip MKext.
120 | printf("F\n");
121 | pressedKey |= 8;
122 | break;
123 | }
124 | }
125 |
126 | if ((pressedKey & 1) || (pressedKey & 2))
127 | {
128 | // Mandatory mode change before entering single user mode,
129 | // which is optional for normal and safe booting modes.
130 | gVerboseMode = true; // ((pressedKey & 1) || (pressedKey & 2));
131 | }
132 |
133 | for (index = 1; index < 6; index++)
134 | {
135 | int currentMode = bootModes[index];
136 | // printf("currentMode: %d\n", currentMode);
137 | // sleep(2);
138 |
139 | if (currentMode >= 0 && (pressedKey & index) == index)
140 | {
141 | // printf("And action...\n");
142 | if (gBootArgsPtr + 3 < gBootArgsEnd)
143 | {
144 | gPlatform.BootMode = currentMode;
145 | copyArgument(0, bootFlags[index], 3, &argP, &cntRemaining);
146 | }
147 |
148 | pressedKey -= index;
149 | }
150 | }
151 |
152 | // Reworked copy from processBootOptions() which is no more.
153 | if (kernelFlagsLength)
154 | {
155 | if (kernelFlagsLength > cntRemaining)
156 | {
157 | truncated = true;
158 | kernelFlagsLength = cntRemaining;
159 | }
160 |
161 | // Store kernel flags.
162 | strncpy(argP, configKernelFlags, kernelFlagsLength);
163 | argP[kernelFlagsLength++] = ' ';
164 | cntRemaining -= kernelFlagsLength;
165 | }
166 |
167 | int bootArgsLength = strlen(cp);
168 |
169 | if (bootArgsLength > cntRemaining)
170 | {
171 | truncated = true;
172 | bootArgsLength = cntRemaining;
173 | }
174 |
175 | if (truncated)
176 | {
177 | error("Warning: boot arguments too long, truncating\n");
178 | }
179 |
180 | // Store boot args.
181 | strncpy(&argP[kernelFlagsLength], cp, bootArgsLength);
182 | argP[kernelFlagsLength + bootArgsLength] = '\0';
183 |
184 | if (configKernelFlags)
185 | {
186 | // Free the earlier allocated (in boot.c) / passed on Kernel Flags.
187 | free(configKernelFlags);
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/i386/libsaio/cache.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * The contents of this file constitute Original Code as defined in and
7 | * are subject to the Apple Public Source License Version 2.0 (the
8 | * "License"). You may not use this file except in compliance with the
9 | * License. Please obtain a copy of the License at
10 | * http://www.apple.com/publicsource and read it before using this file.
11 | *
12 | * This Original Code and all software distributed under the License are
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 | * License for the specific language governing rights and limitations
18 | * under the License.
19 | *
20 | * @APPLE_LICENSE_HEADER_END@
21 | */
22 | /*
23 | * cache.c - A simple cache for file systems meta-data.
24 | *
25 | * Copyright (c) 2000 Apple Computer, Inc.
26 | *
27 | * DRI: Josh de Cesare
28 | */
29 |
30 | #include
31 | // #include
32 |
33 | typedef struct CacheEntry {
34 | CICell ih;
35 | long time;
36 | long long offset;
37 | } CacheEntry;
38 |
39 | #define kCacheSize (0x100000)
40 | #define kCacheMinBlockSize (0x200)
41 | #define kCacheMaxBlockSize (0x4000)
42 | #define kCacheMaxEntries (kCacheSize / kCacheMinBlockSize)
43 |
44 | static CICell gCacheIH;
45 | static long gCacheBlockSize;
46 | static long gCacheNumEntries;
47 | static long gCacheTime;
48 |
49 | #ifdef __i386__
50 | static CacheEntry *gCacheEntries;
51 | static char *gCacheBuffer;
52 | #else
53 | static CacheEntry gCacheEntries[kCacheMaxEntries];
54 | static char gCacheBuffer[kCacheSize];
55 | #endif
56 |
57 | #if CACHE_STATS
58 | unsigned long gCacheHits;
59 | unsigned long gCacheMisses;
60 | unsigned long gCacheEvicts;
61 | #endif
62 |
63 | void CacheReset()
64 | {
65 | gCacheIH = NULL;
66 | }
67 |
68 | void CacheInit( CICell ih, long blockSize )
69 | {
70 | #ifdef __i386__
71 | if ((ih == gCacheIH) && (blockSize == gCacheBlockSize))
72 | {
73 | return;
74 | }
75 | #endif
76 |
77 | if ((blockSize < kCacheMinBlockSize) || (blockSize >= kCacheMaxBlockSize))
78 | {
79 | return;
80 | }
81 |
82 | gCacheBlockSize = blockSize;
83 | gCacheNumEntries = kCacheSize / gCacheBlockSize;
84 | gCacheTime = 0;
85 |
86 | #if CACHE_STATS
87 | gCacheHits = 0;
88 | gCacheMisses = 0;
89 | gCacheEvicts = 0;
90 | #endif
91 |
92 | gCacheIH = ih;
93 |
94 | #ifdef __i386__
95 | if (!gCacheBuffer)
96 | {
97 | gCacheBuffer = (char *) malloc(kCacheSize);
98 | }
99 |
100 | if (!gCacheEntries)
101 | {
102 | gCacheEntries = (CacheEntry *) malloc(kCacheMaxEntries * sizeof(CacheEntry));
103 | }
104 |
105 | if (!gCacheBuffer || !gCacheEntries)
106 | {
107 | gCacheIH = 0; // invalidate cache
108 | return;
109 | }
110 | #endif
111 |
112 | bzero(gCacheEntries, kCacheMaxEntries * sizeof(CacheEntry));
113 | }
114 |
115 | long CacheRead(CICell ih, char * buffer, long long offset, long length, long cache)
116 | {
117 | long cnt, oldestEntry = 0, oldestTime, loadCache = 0;
118 | CacheEntry *entry;
119 |
120 | // See if the data can be cached.
121 | if (cache && (gCacheIH == ih) && (length == gCacheBlockSize))
122 | {
123 | // Look for the data in the cache.
124 | for (cnt = 0; cnt < gCacheNumEntries; cnt++)
125 | {
126 | entry = &gCacheEntries[cnt];
127 |
128 | if ((entry->ih == ih) && (entry->offset == offset))
129 | {
130 | entry->time = ++gCacheTime;
131 | break;
132 | }
133 | }
134 |
135 | // If the data was found copy it to the caller.
136 | if (cnt != gCacheNumEntries)
137 | {
138 | bcopy(gCacheBuffer + cnt * gCacheBlockSize, buffer, gCacheBlockSize);
139 | #if CACHE_STATS
140 | gCacheHits++;
141 | #endif
142 | return gCacheBlockSize;
143 | }
144 |
145 | // Could not find the data in the cache.
146 | loadCache = 1;
147 | }
148 |
149 | // Read the data from the disk.
150 | Seek(ih, offset);
151 | Read(ih, (long)buffer, length);
152 |
153 | #if CACHE_STATS
154 | if (cache)
155 | {
156 | gCacheMisses++;
157 | }
158 | #endif
159 |
160 | // Put the data from the disk in the cache if needed.
161 | if (loadCache)
162 | {
163 | // Find a free entry.
164 | oldestTime = gCacheTime;
165 |
166 | for (cnt = 0; cnt < gCacheNumEntries; cnt++)
167 | {
168 | entry = &gCacheEntries[cnt];
169 |
170 | // Found a free entry.
171 | if (entry->ih == 0)
172 | {
173 | break;
174 | }
175 |
176 | if (entry->time < oldestTime)
177 | {
178 | oldestTime = entry->time;
179 | oldestEntry = cnt;
180 | }
181 | }
182 |
183 | // If no free entry was found, use the oldest.
184 | if (cnt == gCacheNumEntries)
185 | {
186 | cnt = oldestEntry;
187 | #if CACHE_STATS
188 | gCacheEvicts++;
189 | #endif
190 | }
191 |
192 | // Copy the data from disk to the new entry.
193 | entry = &gCacheEntries[cnt];
194 | entry->ih = ih;
195 | entry->time = ++gCacheTime;
196 | entry->offset = offset;
197 | bcopy(buffer, gCacheBuffer + cnt * gCacheBlockSize, gCacheBlockSize);
198 | }
199 |
200 | return length;
201 | }
202 |
--------------------------------------------------------------------------------
/i386/boot2/boot.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | * Copyright 1994 NeXT Computer, Inc. All rights reserved.
25 | *
26 | * Updates:
27 | * - Unused sysConfigValid removed (PikerAlpha, November 2012).
28 | * - STATE_SUCCESS moved to libsaio.h (PikerAlpha, November 2012).
29 | *
30 | */
31 |
32 | #ifndef __BOOT2_BOOT_H
33 | #define __BOOT2_BOOT_H
34 |
35 | #include "platform.h"
36 |
37 | #if USE_STATIC_DISPLAY_RESOLUTION
38 | #define DEFAULT_SCREEN_WIDTH STATIC_SCREEN_WIDTH
39 | #define DEFAULT_SCREEN_HEIGHT STATIC_SCREEN_HEIGHT
40 | #else
41 | #define DEFAULT_SCREEN_WIDTH 1600
42 | #define DEFAULT_SCREEN_HEIGHT 1200
43 | #endif
44 |
45 | /*
46 | * How long to wait (in seconds) to load the kernel after displaying the "boot:" prompt.
47 | */
48 |
49 | #define kBootErrorTimeout 5
50 |
51 | /*
52 | * Keys used in system Boot.plist
53 | */
54 |
55 | #define kGraphicsModeKey "Graphics Mode"
56 | #define kTextModeKey "Text Mode"
57 | #define kQuietBootKey "Quiet Boot"
58 | #define kKernelFlagsKey "Kernel Flags"
59 | #define kMKextCacheKey "MKext Cache"
60 | #define kKernelNameKey "Kernel"
61 | #define kKernelCacheKey "Kernel Cache"
62 | #define kBootDeviceKey "Boot Device"
63 | #define kTimeoutKey "Timeout"
64 | #define kRootDeviceKey "rd"
65 | #define kBootUUIDKey "boot-uuid"
66 | #define kHelperRootUUIDKey "Root UUID"
67 | #define kPlatformKey "platform"
68 | #define kACPIKey "acpi"
69 | #define kScanSingleDriveKey "Scan Single Drive"
70 | #define kInsantMenuKey "Instant Menu"
71 | #define kWaitForKeypressKey "Wait"
72 |
73 | /*
74 | * Flags to the booter or kernel
75 | *
76 | */
77 |
78 | #define kVerboseModeFlag "-v"
79 | #define kSafeModeFlag "-x"
80 | #define kIgnoreCachesFlag "-f" // Formerly kOldSafeModeFlag
81 | #define kIgnoreBootFileFlag "-F"
82 | #define kSingleUserModeFlag "-s"
83 |
84 | /*
85 | * Booter behavior control
86 | */
87 |
88 | #define kBootTimeout -1
89 |
90 | extern char bootPrompt[];
91 |
92 | /*
93 | * Note well that we take an easier approice, and this should not be
94 | * confused with /chosen/boot-file-path because this is what we want.
95 | */
96 | #define BOOT_DEVICE_PATH "\\System\\Library\\CoreServices\\boot.efi"
97 |
98 | // Taken from kextcache_main.h - kernel cache (Adler32) related.
99 |
100 | #define PLATFORM_NAME_LEN 64
101 | #define ROOT_PATH_LEN 256
102 |
103 | /*
104 | * bootlogo.c
105 | */
106 |
107 | extern void showBootLogo();
108 |
109 | /*
110 | * fake_efi.c
111 | */
112 |
113 | extern void finalizeEFITree();
114 |
115 | /*
116 | * graphics.c
117 | */
118 |
119 | extern void setVideoMode(int mode);
120 | extern bool inGraphicsMode(void);
121 |
122 | /*
123 | * hfs.c
124 | */
125 |
126 | extern long HFSGetUUID(CICell ih, char *uuidStr);
127 |
128 | /*
129 | * drivers.c
130 | */
131 |
132 | #if RAMDISK_SUPPORT
133 | extern void drawPreview(void *src, uint8_t * saveunder);
134 | #endif
135 |
136 | extern long loadDrivers(char * dirSpec);
137 | extern long decodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);
138 |
139 | typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin);
140 |
141 | /*!
142 | Hookable function pointer called during the driver loading phase that
143 | allows other code to cause additional drivers to be loaded.
144 | */
145 |
146 | extern long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p);
147 |
148 | /*
149 | * lzss.c
150 | */
151 |
152 | extern int decompressLZSS(u_int8_t *dst, u_int8_t *src, u_int32_t srclen);
153 |
154 | /*
155 | * lzss.c
156 | */
157 |
158 | extern int lzvn_decode(void * decompressedData, uint32_t decompressedSize, void * compressedData, uint32_t compressedSize);
159 |
160 | /*
161 | * options.c
162 | */
163 |
164 | extern void getAndProcessBootArguments(char *configKernelFlags);
165 |
166 | /*
167 | * resume.c
168 | */
169 |
170 | #if HIBERNATE_SUPPORT
171 | void HibernateBoot(char *boot_device);
172 | #endif
173 |
174 | // Taken from: kextcache_main.h
175 |
176 | struct compressed_kernel_header
177 | {
178 | u_int32_t signature;
179 | u_int32_t compressType; // compress_type;
180 | u_int32_t adler32;
181 | u_int32_t uncompressedSize; // uncompressed_size;
182 | u_int32_t compressedSize; // compressed_size;
183 | u_int32_t reserved[11];
184 | char platformName[PLATFORM_NAME_LEN]; // platform_name[64];
185 | char rootPath[ROOT_PATH_LEN]; // root_path[256];
186 | // char data[0];
187 | u_int8_t data[0];
188 | };
189 |
190 | typedef struct compressed_kernel_header compressed_kernel_header;
191 |
192 | /*
193 | * bmdecompress.c ???
194 | */
195 |
196 | void * DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel);
197 |
198 | #endif /* !__BOOT2_BOOT_H */
199 |
--------------------------------------------------------------------------------
/i386/libsa/memory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | * Reworked for automatic address calculation,
25 | * Copyright (c) 2010 by DHP. All Rights Reserved.
26 | */
27 |
28 | #ifndef __BOOT_MEMORY_H
29 | #define __BOOT_MEMORY_H
30 |
31 | /* Memory addresses used by booter and friends */
32 |
33 | /* DFE 2007-12-21: Changed BASE_SEG to be conditional
34 | This allows boot1u and other planned first-stage booters to avoid
35 | maintaining their own copies of asm.s and bios.s and instead
36 | simply build the files from libsaio with the right preprocessor
37 | definitions.
38 |
39 | This affects BASE_ADDR and OFFSET16() thus obviating the need for
40 | separate BASE1U_ADDR and OFFSET1U16() macros.
41 |
42 | Be careful though as changing these values with preprocessor macros
43 | obviously requires rebuilding the source files. That means in particular
44 | that libsaio.a is only suitable for boot2.
45 | */
46 |
47 | #if defined(BASE_SEG)
48 | // Assuming that the personebuilding the boot loader knows what to do.
49 | #elif defined(BOOT1)
50 | # define BASE_SEG BOOT1U_SEG
51 | #else
52 | # define BASE_SEG BOOT2_SEG
53 | #endif
54 |
55 | #define STACK_SEG 0x8000 // zef: old STACK_SEG 0x5000.
56 | #define STACK_OFS 0xFFF0 // Stack pointer.
57 |
58 | #define BOOT1U_SEG 0x1000
59 | #define BOOT1U_OFS 0x0200
60 |
61 | #define BOOT2_SEG 0x2000 // Disk sector offset.
62 | #define BOOT2_OFS 0x0200 // 512 Bytes.
63 |
64 | #define BIOS_ADDR 0x8000 // BIOS disk I/O buffer.
65 | #define BIOS_LEN 0x8000 // 32 KB (dividable by 512 and 2048).
66 |
67 | #define BOOT0_ADDR 0x7E00 // Load address of boot0.
68 |
69 | #define ADDR32(seg, ofs) (((seg) << 4 ) + (ofs))
70 |
71 | #define BASE_ADDR ADDR32(BASE_SEG, 0)
72 | #define BOOT1U_ADDR ADDR32(BOOT1U_SEG, BOOT1U_OFS)
73 | #define BOOT2_ADDR ADDR32(BOOT2_SEG, BOOT2_OFS)
74 |
75 | #define MEMBASE 0x0
76 |
77 | #define BOOTSTRUCT_ADDR 0x00011000L
78 | #define BOOTSTRUCT_LEN 0x0000F000L // Size: 60 KB (overkill, is even smaller).
79 |
80 | // 0x00020000L
81 | #define VOID_ADDR (BOOTSTRUCT_ADDR + BOOTSTRUCT_LEN)
82 | #define VOID_LEN 0x00020000L // Size: 256 KB.
83 |
84 | // 0x00040000L
85 | #define HIB_ADDR (VOID_ADDR + VOID_LEN) // Special hibernation area.
86 | #define HIB_LEN 0x00060000L // Size: 384 KB.
87 |
88 | // 0x000A0000L
89 | #define VIDEO_ADDR (HIB_ADDR + HIB_LEN) // Unusable space.
90 | #define VIDEO_LEN 0x00060000L // Size: 384 KB.
91 |
92 | // 0x00100000L
93 | #define KERNEL_ADDR (VIDEO_ADDR + VIDEO_LEN) // Kernel and MKexts/drivers.
94 | #define KERNEL_LEN 0x08000000L // Size: 128 MB.
95 | //
96 | // Note: Can cause a stop("Kernel overflows available space")
97 | // Based on KERNEL_LEN 0x04100000L
98 | #define ZALLOC_ADDR (KERNEL_ADDR + KERNEL_LEN) // Zalloc area.
99 | #define ZALLOC_LEN 0x10000000L // Size: 256 MB.
100 |
101 | // Based on ZALLOC_LEN 0x14100000L
102 | #define LOAD_ADDR (ZALLOC_ADDR + ZALLOC_LEN) // File load buffer.
103 | #define LOAD_LEN 0x05F80000L // Size: 95 MB.
104 |
105 | // Location of data fed to boot2 by the prebooter
106 | // Based on LOAD_LEN 0x1A080000L
107 | #define PREBOOT_DATA (LOAD_ADDR + LOAD_LEN) // Room for a 195 MB RAM disk image (with 512 MB System Memory).
108 |
109 |
110 | #define TFTP_ADDR LOAD_ADDR // TFTP download buffer (not used in RevoBoot).
111 | #define TFTP_LEN LOAD_LEN
112 |
113 |
114 | #define kLoadAddr LOAD_ADDR
115 | #define kLoadSize LOAD_LEN
116 |
117 | #define CONVENTIONAL_LEN 0x0A0000 // 640 KB
118 | #define EXTENDED_ADDR 0x100000 // 1024 KB
119 |
120 | #define ptov(paddr) ((paddr) - MEMBASE)
121 | #define vtop(vaddr) ((vaddr) + MEMBASE)
122 |
123 | // Extract segment/offset from a linear address.
124 | #define OFFSET16(addr) ((addr) - BASE_ADDR)
125 | #define OFFSET(addr) ((addr) & 0xFFFF)
126 | #define SEGMENT(addr) (((addr) & 0xF0000) >> 4)
127 |
128 | /*
129 | * Extract segment/offset in normalized form so that the resulting far pointer
130 | * will point to something that is very unlikely to straddle a segment.
131 | * This is sometimes known as a "huge" pointer.
132 | */
133 | #define NORMALIZED_OFFSET(addr) ((addr) & 0x000F)
134 | #define NORMALIZED_SEGMENT(addr) (((addr) & 0xFFFF0) >> 4)
135 |
136 | // We need a minimum of 32MB of system memory.
137 | #define MIN_SYS_MEM_KB (32 * 1024)
138 |
139 | // The number of descriptor entries in the GDT (Global Descriptor Table).
140 | #define NGDTENT 7
141 |
142 | // The total size of the GDT in bytes. Each descriptor entry require 8 bytes.
143 | #define GDTLIMIT (NGDTENT * 8)
144 |
145 | #endif /* !__BOOT_MEMORY_H */
146 |
--------------------------------------------------------------------------------
/i386/libsaio/cpu/proc_reg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | * @OSF_COPYRIGHT@
30 | */
31 | /* CMU_ENDHIST */
32 | /*
33 | * Mach Operating System
34 | * Copyright (c) 1991,1990 Carnegie Mellon University
35 | * All Rights Reserved.
36 | *
37 | * Permission to use, copy, modify and distribute this software and its
38 | * documentation is hereby granted, provided that both the copyright
39 | * notice and this permission notice appear in all copies of the
40 | * software, derivative works or modified versions, and any portions
41 | * thereof, and that both notices appear in supporting documentation.
42 | *
43 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
44 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
45 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46 | *
47 | * Carnegie Mellon requests users of this software to return to
48 | *
49 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
50 | * School of Computer Science
51 | * Carnegie Mellon University
52 | * Pittsburgh PA 15213-3890
53 | *
54 | * any improvements or extensions that they make and grant Carnegie Mellon
55 | * the rights to redistribute these changes.
56 | */
57 |
58 | /*
59 | * DFE: enable_PIT2 and disable_PIT2 come from older XNU.
60 | */
61 |
62 | #ifndef __LIBSAIO_CPU_PROC_REG_H
63 | #define __LIBSAIO_CPU_PROC_REG_H
64 |
65 |
66 | //==============================================================================
67 |
68 | static inline uint64_t rdtsc64(void)
69 | {
70 | uint64_t ret;
71 |
72 | __asm__ volatile("rdtsc" : "=A" (ret));
73 |
74 | return ret;
75 | }
76 |
77 |
78 | //==============================================================================
79 |
80 | static inline uint64_t rdmsr64(uint32_t msr)
81 | {
82 | uint64_t ret;
83 |
84 | __asm__ volatile("rdmsr" : "=A" (ret) : "c" (msr));
85 |
86 | return ret;
87 | }
88 |
89 |
90 | //==============================================================================
91 |
92 | static inline void wrmsr64(uint32_t msr, uint64_t val)
93 | {
94 | __asm__ volatile("wrmsr" : : "c" (msr), "A" (val));
95 | }
96 |
97 |
98 | //==============================================================================
99 | /*
100 | * Enable or disable timer 2.
101 | * Port 0x61 controls timer 2:
102 | * bit 0 gates the clock,
103 | * bit 1 gates output to speaker.
104 | */
105 | static inline void enable_PIT2(void)
106 | {
107 | // Enable gate, disable speaker.
108 | __asm__ volatile(" inb $0x61,%%al \n\t"
109 | " and $0xFC,%%al \n\t" /* & ~0x03 */
110 | " or $1,%%al \n\t"
111 | " outb %%al,$0x61 \n\t"
112 | : : : "%al" );
113 | }
114 |
115 |
116 | //==============================================================================
117 |
118 | static inline void disable_PIT2(void)
119 | {
120 | // Disable gate and output to speaker.
121 | __asm__ volatile(" inb $0x61,%%al \n\t"
122 | " and $0xFC,%%al \n\t" /* & ~0x03 */
123 | " outb %%al,$0x61 \n\t"
124 | : : : "%al" );
125 | }
126 |
127 | //==============================================================================
128 | // DFE: set_PIT2_mode0, poll_PIT2_gate, and measure_tsc_frequency are roughly
129 | // based on Linux code.
130 |
131 | static inline void set_PIT2_mode0(uint16_t value)
132 | {
133 | /* Set the 8254 channel 2 to mode 0 with the specified value.
134 | * In mode 0, the counter will initially set its gate low when the
135 | * timer expires. For this to be useful, you ought to set it high
136 | * before calling this function. The enable_PIT2 function does this.
137 | */
138 |
139 | __asm__ volatile(" movb $0xB0,%%al \n\t"
140 | " outb %%al,$0x43 \n\t"
141 | " movb %%dl,%%al \n\t"
142 | " outb %%al,$0x42 \n\t"
143 | " movb %%dh,%%al \n\t"
144 | " outb %%al,$0x42"
145 | : : "d"(value) /*: no clobber */ );
146 | }
147 |
148 |
149 | //==============================================================================
150 | // Returns the number of times the loop ran before the PIT2 signaled.
151 |
152 | static inline unsigned long poll_PIT2_gate(void)
153 | {
154 | unsigned long count = 0;
155 | unsigned char nmi_sc_val;
156 |
157 | do
158 | {
159 | ++count;
160 | __asm__ volatile("inb $0x61,%0": "=q"(nmi_sc_val) /*:*/ /* no input */ /*:*/ /* no clobber */);
161 | } while( (nmi_sc_val & 0x20) == 0);
162 |
163 | return count;
164 | }
165 |
166 | #endif /* !__LIBSAIO_CPU_PROC_REG_H */
167 |
--------------------------------------------------------------------------------
/i386/util/machOconv.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_LICENSE_HEADER_START@
5 | *
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 | * Reserved. This file contains Original Code and/or Modifications of
8 | * Original Code as defined in and that are subject to the Apple Public
9 | * Source License Version 2.0 (the "License"). You may not use this file
10 | * except in compliance with the License. Please obtain a copy of the
11 | * License at http://www.apple.com/publicsource and read it before using
12 | * this file.
13 | *
14 | * The Original Code and all software distributed under the License are
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 | * License for the specific language governing rights and limitations
20 | * under the License.
21 | *
22 | * @APPLE_LICENSE_HEADER_END@
23 | *
24 | * Updates:
25 | * Reformatted (PikerAlpha, November 2012)
26 | */
27 |
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | int infile, outfile;
39 |
40 | void * cmds;
41 |
42 | struct mach_header mh;
43 |
44 | static bool swap_ends;
45 |
46 | //==============================================================================
47 |
48 | static unsigned long swap(unsigned long x)
49 | {
50 | if (swap_ends)
51 | {
52 | return OSSwapInt32(x);
53 | }
54 | else
55 | {
56 | return x;
57 | }
58 | }
59 |
60 |
61 | //==============================================================================
62 |
63 | int main(int argc, char *argv[])
64 | {
65 | kern_return_t result;
66 | vm_address_t data;
67 | int nc, ncmds;
68 | char * cp;
69 |
70 | if (argc == 2)
71 | {
72 | infile = open(argv[1], O_RDONLY);
73 |
74 | if (infile < 0)
75 | {
76 | goto filenotfound;
77 | }
78 |
79 | outfile = fileno(stdout);
80 | }
81 | else if (argc == 3)
82 | {
83 | infile = open(argv[1], O_RDONLY);
84 |
85 | if (infile < 0)
86 | {
87 | goto filenotfound;
88 | }
89 |
90 | outfile = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
91 |
92 | if (outfile < 0)
93 | {
94 | goto openerror;
95 | }
96 | }
97 | else
98 | {
99 | fprintf(stderr, "Usage: machOconv inputfile [outputfile]\n");
100 | exit(1);
101 |
102 | filenotfound:
103 | fprintf(stderr, "Error: File Not Found\n");
104 | exit(1);
105 |
106 | openerror:
107 | fprintf(stderr, "Error: Open Failed\n");
108 | exit(1);
109 | }
110 |
111 | nc = read(infile, &mh, sizeof (mh));
112 |
113 | if (nc < 0)
114 | {
115 | perror("read mach header");
116 | exit(1);
117 | }
118 |
119 | if (nc < (int)sizeof (mh))
120 | {
121 | fprintf(stderr, "Error: read mach header: premature EOF %d\n", nc);
122 | exit(1);
123 | }
124 |
125 | if (mh.magic == MH_MAGIC)
126 | {
127 | swap_ends = false;
128 | }
129 | else if (mh.magic == MH_CIGAM)
130 | {
131 | swap_ends = true;
132 | }
133 | else
134 | {
135 | fprintf(stderr, "Error: bad magic number %lx\n", (unsigned long)mh.magic);
136 | exit(1);
137 | }
138 |
139 | cmds = calloc(swap(mh.sizeofcmds), sizeof (char));
140 |
141 | if (cmds == 0)
142 | {
143 | fprintf(stderr, "Error: alloc load commands: no memory\n");
144 | exit(1);
145 | }
146 |
147 | nc = read(infile, cmds, swap(mh.sizeofcmds));
148 |
149 | if (nc < 0)
150 | {
151 | perror("read load commands");
152 | exit(1);
153 | }
154 |
155 | if (nc < (int)swap(mh.sizeofcmds))
156 | {
157 | fprintf(stderr, "Error: read load commands: premature EOF %d\n", nc);
158 | exit(1);
159 | }
160 |
161 | unsigned long vmstart = (unsigned long) -1;
162 |
163 | // First pass: determine actual load address
164 | for (ncmds = swap(mh.ncmds), cp = cmds; ncmds > 0; ncmds--)
165 | {
166 | #define lcp ((struct load_command *)cp)
167 | #define scp ((struct segment_command *)cp)
168 |
169 | switch(swap(lcp->cmd))
170 | {
171 | case LC_SEGMENT:
172 | if (vmstart > swap(scp->vmaddr))
173 | {
174 | vmstart = swap(scp->vmaddr);
175 | }
176 | }
177 |
178 | cp += swap(lcp->cmdsize);
179 | }
180 |
181 | // Second pass: output to file.
182 | for (ncmds = swap(mh.ncmds), cp = cmds; ncmds > 0; ncmds--)
183 | {
184 | #define lcp ((struct load_command *)cp)
185 | #define scp ((struct segment_command *)cp)
186 |
187 | bool isDATA;
188 | unsigned vmsize;
189 |
190 | switch(swap(lcp->cmd))
191 | {
192 | case LC_SEGMENT:
193 | isDATA = (strcmp(scp->segname, "__DATA") == 0);
194 |
195 | if (isDATA)
196 | {
197 | vmsize = swap(scp->filesize);
198 | }
199 | else
200 | {
201 | vmsize = swap(scp->vmsize);
202 | }
203 |
204 | result = vm_allocate(mach_task_self(), &data, vmsize, true);
205 |
206 | if (result != KERN_SUCCESS)
207 | {
208 | mach_error("vm_allocate segment data", result);
209 | exit(1);
210 | }
211 |
212 | lseek(infile, swap(scp->fileoff), L_SET);
213 | nc = read(infile, (void *)data, swap(scp->filesize));
214 |
215 | if (nc < 0)
216 | {
217 | perror("read segment data");
218 | exit(1);
219 | }
220 |
221 | if (nc < (int)swap(scp->filesize))
222 | {
223 | fprintf(stderr, "read segment data: premature EOF %d\n", nc);
224 | exit(1);
225 | }
226 |
227 | lseek(outfile, swap(scp->vmaddr) - vmstart, L_SET);
228 | nc = write(outfile, (void *)data, vmsize);
229 |
230 | if (nc < (int)vmsize)
231 | {
232 | perror("write segment data");
233 | exit(1);
234 | }
235 |
236 | vm_deallocate(mach_task_self(), data, vmsize);
237 | break;
238 | }
239 |
240 | cp += swap(lcp->cmdsize);
241 | }
242 |
243 | exit(0);
244 | }
245 |
--------------------------------------------------------------------------------
/i386/libsa/crc32.c:
--------------------------------------------------------------------------------
1 | /*
2 | * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
3 | * code or tables extracted from it, as desired without restriction.
4 | *
5 | * First, the polynomial itself and its table of feedback terms. The
6 | * polynomial is
7 | * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
8 | *
9 | * Note that we take it "backwards" and put the highest-order term in
10 | * the lowest-order bit. The X^32 term is "implied"; the LSB is the
11 | * X^31 term, etc. The X^0 term (usually shown as "+1") results in
12 | * the MSB being 1
13 | *
14 | * Note that the usual hardware shift register implementation, which
15 | * is what we're using (we're merely optimizing it by doing eight-bit
16 | * chunks at a time) shifts bits into the lowest-order term. In our
17 | * implementation, that means shifting towards the right. Why do we
18 | * do it this way? Because the calculated CRC must be transmitted in
19 | * order from highest-order term to lowest-order term. UARTs transmit
20 | * characters in order from LSB to MSB. By storing the CRC this way
21 | * we hand it to the UART in the order low-byte to high-byte; the UART
22 | * sends each low-bit to hight-bit; and the result is transmission bit
23 | * by bit from highest- to lowest-order term without requiring any bit
24 | * shuffling on our part. Reception works similarly
25 | *
26 | * The feedback terms table consists of 256, 32-bit entries. Notes
27 | *
28 | * The table can be generated at runtime if desired; code to do so
29 | * is shown later. It might not be obvious, but the feedback
30 | * terms simply represent the results of eight shift/xor opera
31 | * tions for all combinations of data and CRC register values
32 | *
33 | * The values must be right-shifted by eight bits by the "updcrc
34 | * logic; the shift must be unsigned (bring in zeroes). On some
35 | * hardware you could probably optimize the shift in assembler by
36 | * using byte-swap instructions
37 | * polynomial $edb88320
38 | *
39 | * Updates:
40 | * - All but crc32 code moved to guid.c (PikerAlpha, November 2012)
41 | * - File renamed from efi_tables.c to crc32.c (PikerAlpha, November 2012)
42 | * - Copyright restored to original developer (PikerAlpha, November 2012)
43 | *
44 | */
45 |
46 |
47 | #include "libsa.h"
48 |
49 | //==========================================================================
50 | // This data block can also be found in boot.efi
51 |
52 | static uint32_t crc32Table[] =
53 | {
54 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
55 | 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
56 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
57 | 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
58 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
59 | 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
60 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
61 | 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
62 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
63 | 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
64 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
65 | 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
66 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
67 | 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
68 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
69 | 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
70 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
71 | 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
72 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
73 | 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
74 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
75 | 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
76 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
77 | 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
78 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
79 | 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
80 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
81 | 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
82 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
83 | 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
84 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
85 | 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
86 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
87 | 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
88 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
89 | 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
90 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
91 | 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
92 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
93 | 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
94 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
95 | 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
96 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
97 | };
98 |
99 |
100 | //==========================================================================
101 |
102 | uint32_t crc32(uint32_t aCRC, const void *aBuffer, size_t aSize)
103 | {
104 | const uint8_t *p = aBuffer;
105 |
106 | aCRC = aCRC ^ ~0U;
107 |
108 | while (aSize--)
109 | {
110 | aCRC = crc32Table[(aCRC ^ *p++) & 0xFF] ^ (aCRC >> 8);
111 | }
112 |
113 | return (aCRC ^ ~0U);
114 | }
115 |
--------------------------------------------------------------------------------
/i386/libsaio/acpi/examples/P8Z68-V PRO/ssdt.dsl:
--------------------------------------------------------------------------------
1 | /*
2 | * Intel ACPI Component Architecture
3 | * AML Disassembler version 20130214-64 [Mar 24 2013]
4 | * Copyright (c) 2000 - 2013 Intel Corporation
5 | *
6 | * Disassembly of ssdt.aml, Mon Mar 25 08:07:55 2013
7 | *
8 | * Original Table Header:
9 | * Signature "SSDT"
10 | * Length 0x000004FF (1279)
11 | * Revision 0x01
12 | * Checksum 0x72
13 | * OEM ID "APPLE "
14 | * OEM Table ID "general"
15 | * OEM Revision 0x00001000 (4096)
16 | * Compiler ID "INTL"
17 | * Compiler Version 0x20130214 (538116628)
18 | */
19 | DefinitionBlock ("ssdt.aml", "SSDT", 1, "APPLE ", "general", 0x00001000)
20 | {
21 | External (_SB_.PCI0.EHC1, DeviceObj)
22 | External (_SB_.PCI0.EHC2, DeviceObj)
23 | External (_SB_.PCI0.LPCB.HPET, DeviceObj)
24 | External (_SB_.PCI0.RP02, DeviceObj)
25 | External (_SB_.PCI0.RP04, DeviceObj)
26 | External (_SB_.PCI0.RP05, DeviceObj)
27 | External (_SB_.PCI0.RP07, DeviceObj)
28 | External (HPTC, IntObj)
29 |
30 | Scope (\_SB.PCI0.EHC2)
31 | {
32 | Name (AAPL, Package (0x0B)
33 | {
34 | "AAPL,current-available",
35 | 0x0834,
36 | "AAPL,current-extra",
37 | 0x0898,
38 | "AAPL,current-extra-in-sleep",
39 | 0x0640,
40 | "AAPL,max-port-current-in-sleep",
41 | 0x0834,
42 | "AAPL,device-internal",
43 | 0x02,
44 | Buffer (One) { 0x00 }
45 | })
46 |
47 | Method (_DSM, 4, NotSerialized)
48 | {
49 | If (LEqual (Arg2, Zero))
50 | {
51 | Return (Buffer (One) { 0x03 })
52 | }
53 |
54 | Return (RefOf (AAPL))
55 | }
56 | }
57 |
58 | Scope (\_SB.PCI0.RP02)
59 | {
60 | Device (XHC1)
61 | {
62 | Name (_ADR, Zero)
63 | Name (_PRW, Package(0x02) { 0x0D, 0x04 })
64 | Name (_S4D, 0x03)
65 | Name (_S3D, 0x03)
66 | Name (MBSD, One)
67 | Name (XHCN, One)
68 | }
69 | }
70 |
71 | Scope (\_SB.PCI0.RP04)
72 | {
73 | Device (JMB0)
74 | {
75 | Name (_ADR, Zero)
76 | OperationRegion (CF40, PCI_Config, 0x40, 0x04)
77 | Field (CF40, ByteAcc, NoLock, Preserve)
78 | {
79 | CHE0, 1,
80 | MULT, 1,
81 | , 1,
82 | CAB0, 1,
83 | CHE1, 1,
84 | Offset (0x01),
85 | AHEN, 1,
86 | , 3,
87 | PRT0, 1,
88 | AHM0, 1,
89 | PRT1, 1,
90 | AHM1, 1,
91 | CF42, 6,
92 | SWAP, 1,
93 | PATA, 1,
94 | , 6,
95 | WTEN, 1,
96 | Offset (0x04)
97 | }
98 | }
99 |
100 | Device (JMB1)
101 | {
102 | Name (_ADR, One)
103 | OperationRegion (CF40, PCI_Config, 0x40, 0x04)
104 | Field (CF40, ByteAcc, NoLock, Preserve)
105 | {
106 | CHE0, 1,
107 | MULT, 1,
108 | , 1,
109 | CAB0, 1,
110 | CHE1, 1,
111 | Offset (0x01),
112 | AHEN, 1,
113 | , 3,
114 | PRT0, 1,
115 | AHM0, 1,
116 | PRT1, 1,
117 | AHM1, 1,
118 | CF42, 6,
119 | SWAP, 1,
120 | PATA, 1,
121 | , 6,
122 | WTEN, 1,
123 | Offset (0x04)
124 | }
125 | }
126 | }
127 |
128 | Scope (\_SB.PCI0.RP05)
129 | {
130 | Device (XHC1)
131 | {
132 | Name (_ADR, Zero)
133 | Name (_PRW, Package (0x02) { 0x0D, 0x04 })
134 | Name (_S4D, 0x03)
135 | Name (_S3D, 0x03)
136 | Name (MBSD, One)
137 | Name (XHCN, One)
138 | }
139 | }
140 |
141 | Scope (\_SB.PCI0.RP07)
142 | {
143 | Device (FWBR)
144 | {
145 | Name (_ADR, Zero)
146 | Name (_PRW, Package (0x02) { 0x0B, 0x04 })
147 | Name (_PRT, Package (0x0C)
148 | {
149 | Package (0x04) { 0xFFFF, Zero, Zero, 0x12 },
150 | Package (0x04) { 0xFFFF, One, Zero, 0x13 },
151 | Package (0x04) { 0xFFFF, 0x02, Zero, 0x10 },
152 | Package (0x04) { 0xFFFF, 0x03, Zero, 0x11 },
153 | Package (0x04) { 0x0001FFFF, Zero, Zero, 0x13 },
154 | Package (0x04) { 0x0001FFFF, One, Zero, 0x10 },
155 | Package (0x04) { 0x0001FFFF, 0x02, Zero, 0x11 },
156 | Package (0x04) { 0x0001FFFF, 0x03, Zero, 0x12 },
157 | Package (0x04) { 0x0002FFFF, Zero, Zero, 0x11 },
158 | Package (0x04) { 0x0002FFFF, One, Zero, 0x12 },
159 | Package (0x04) { 0x0002FFFF, 0x02, Zero, 0x13 },
160 | Package (0x04) { 0x0002FFFF, 0x03, Zero, 0x10 }
161 | })
162 |
163 | Device (FRWR)
164 | {
165 | Name (_ADR, 0x00020000)
166 | }
167 | }
168 | }
169 |
170 | Scope (\_SB.PCI0.EHC1)
171 | {
172 | Method (_DSM, 4, NotSerialized)
173 | {
174 | If (LEqual (Arg2, Zero))
175 | {
176 | Return (Buffer (One) { 0x03 })
177 | }
178 |
179 | Return (RefOf (\_SB.PCI0.EHC2.AAPL))
180 | }
181 | }
182 |
183 | /* Optional code to activate the HPET */
184 | Scope (\_SB.PCI0.LPCB.HPET)
185 | {
186 | OperationRegion (RCRB, SystemMemory, HPTC, One)
187 | Field (RCRB, ByteAcc, Lock, Preserve)
188 | {
189 | , 7,
190 | HPAE, 1
191 | }
192 |
193 | Method (_INI, 0, NotSerialized)
194 | {
195 | Store (One, HPAE)
196 | }
197 | }
198 | }
199 |
200 |
--------------------------------------------------------------------------------