Skip to content

Commit 2a454ba

Browse files
committed
Initial commit
0 parents  commit 2a454ba

File tree

333 files changed

+66169
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

333 files changed

+66169
-0
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
DerivedData
3+
Lilu.kext
4+
xcuserdata
5+
project.xcworkspace
6+
build
7+
VirtualSmcPkg/Binaries
8+
VirtualSmcPkg/UDK

.travis.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
language: cpp
2+
3+
env:
4+
global:
5+
- secure: "Q7+8APe7r5vkUO+77VUoWlRW7ERFZ2WYkYTMo5QCfhqldpm5furgeJsLTivux/RiEWjpJ/Ez64pZWET2rQbVPdKvxIbt9kebQ4klQFZIcbq0z7h9AKMMv2RMGBkl01oU5Mj07CIlJr59dnGnNftPMSoe9Vg9TVQu8gJGkiR/W4q8LTxj7iHl12d8e4A3Wf//9Pu2TZt2IuYToDOhrFgZ7sy5QN/6Uiz/m65fLDR2lSaO5nzAao4eXEB6uQ2BVH5vHqTAXLKPzrIb9PGkrlY1CDyZ4ECng7lCjP4+i3nGTPg+Y5gnH7c0JmAG9NFhEXj+CgxGnMvZcwCwv5GbLnY2LLJgWQSBSo9OMO88bns//6cQmFtMlW8ZZhd2jyIQxG6wOC4CVKvEbzsoLnhEuW9yVCAiY3WoJfqyGg0UVtgimcjEJ7ynB6A7jgCMoEQN7K3MmwXMDKcy9RR6RbaFRPuoCaPg2e4uhWtI2Q0HZZ/i6SGVtmH9OXn0QnxfxHoJkCHyHYcVrzE67bbrq7H1s5aPJn1AJRx1c7RkVOxW+a/m9umOuJWLJkNB/D5gnk2QgDe9o1s+n2em1bG7iC8V396MoIGDlEl6LiOSwsSlzrg4kxHdNnfClkFeiWNYrORZYxeF/2HBcqhh1TekK74C57Sz1IdUYSZnZwy5tJRrQ996SxE="
6+
7+
matrix:
8+
include:
9+
- os: osx
10+
compiler: clang
11+
12+
script:
13+
- xcodebuild -target Package -configuration Debug
14+
- xcodebuild -target Package -configuration Release
15+
- xcodebuild analyze -quiet -target Package -configuration Debug CLANG_ANALYZER_OUTPUT=plist-html CLANG_ANALYZER_OUTPUT_DIR="$(pwd)/clang-analyze" && [ "$(find clang-analyze -name "*.html")" = "" ]
16+
- xcodebuild analyze -quiet -target Package -configuration Release CLANG_ANALYZER_OUTPUT=plist-html CLANG_ANALYZER_OUTPUT_DIR="$(pwd)/clang-analyze" && [ "$(find clang-analyze -name "*.html")" = "" ]
17+
18+
deploy:
19+
provider: releases
20+
skip_cleanup: true
21+
file: "build/*/*.zip"
22+
file_glob: true
23+
api_key:
24+
secure: KVG0KIW/HASu1RMYLkjiCnnrxgmJ6l4g+jNU9WLmwCreIF6QRi/oFpsj6wSCq/QDUSRGqkyxRfXzBsvmwFsbd8lgjnhiL3XGlTUnG4f7EQHN3c/vikWZS65zwI4KjmyAv0/tup2SwBoALIqS+blZT8BfGfBqxkFGvakmXfsm98MFHSBn7Jkrz7gEmXkh0Zs5FIlA5fw7ljQOx1NyVTaC+aaZtP2+lxeVWL8CU0KKVONpnsx5YtSZGtCXvrj9dhr4Ti0U6NQhl9m/gYrymLqy4N9ubgJ8setxZgG/sz3CdFZFKx750SSUCbRbh5R9BeFsU3p7M0p69Oka9Jo+tOLA42xYCrBW7dqK89DfZo/MV6zONmuXhvCIQkO3QtkzaJJBBuZzu01LALz9gn5udvBMC9OU4p07xtIPgeIFb2anjkg0gKcdZfCcUeUVimwwSzMrW5STJB/psBvVs/4oLwIna52mEzS0brR6EU0f2ZrYMpF4UIDjSsXBN605ORl2G1dGK5+gpVw2/GPb7w3h35ZVroO56Mked6oo6P3qSZAEsyJv/LHbUFJWigNXRvTlNUZf52OQmKi9TuVipzFgs/GA1maHhXVHjS7DREs5oOSWdolvXQSXqhZr0a1CC3fS58S3K9x0eltammQVyoIw5vEzNlBo5jXA/rnydgoGy8rZM9s=
25+
on:
26+
tags: true
27+
28+
- os: osx
29+
osx_image: xcode6.4
30+
compiler: clang
31+
32+
script:
33+
- echo "This script runs coverity..."
34+
35+
addons:
36+
coverity_scan:
37+
project:
38+
name: "acidanthera/VirtualSMC"
39+
description: "VirtualSMC"
40+
notification_email: $NOTIFICATION_EMAIL
41+
build_command: "xcodebuild -configuration Release"
42+
branch_pattern: master

Changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VirtualSMC Changelog
2+
====================
3+
4+
#### v1.0.0
5+
- Initial release

Docs/FAQ.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#### What is the benefit?
2+
Depending on the circumstances VirtualSMC can bring better compatibility with present and future macOS releases providing broader SMC feature support and allowing more flexible SMC key emulation like MMIO, events (like in SMCLightSensor), permission support, etc. On older Macs it can be used to upgrade SMC generation with more features.
3+
4+
#### What are the requirements?
5+
macOS 10.8.5 or newer. macOS releases prior to 10.13 have issues in XNU kernel and may require `dart=0` boot-arg in case of boot freezes. Compatible Lilu is required for full functionality, basic functionality will be available even on beta macOS versions or with `-liluoff` boot-arg. VirtualSMC.efi module is recommended for boot.efi compatibility when FileVault 2 is enabled. SMCHelper-64.efi is not compatible with VirtualSMC.efi and must be removed.
6+
7+
#### How can I debug issues?
8+
Using DEBUG kexts and the usual boot-args to enable debug information in relevant kexts. Other than `-vsmcdbg` and generic boot-args like `keepsyms=1`, `-v`, `debug=0x100`, `io=0xff` you may be interested in AppleSMC debug support (`smc=0xff`) or AppleSmartBatteryManager debug support (`batman=0xff`). On 10.13 or newer you may have to [patch the kernel](https://applelife.ru/posts/686953) to be able to view the panic trace without the subsequent kext list. Good luck.
9+
10+
#### What is special about sensors?
11+
Sensor kexts provide extra monitoring functionality like temperature, voltage, or extra functionality in dedicated SMC keys. The list of known SMC keys and sensors could be found in Docs directory. You are welcome to implement your own sensor kexts using a dedicated API, but check the basic manual first.
12+
13+
#### Why does sensor X not show the information in Y?
14+
Make sure, that the information you are looking for is actually implemented in sensor X by checking the SMC key values (run `smcread -s`). If it is not, then make sure that this information is present on Apple hardware and consider making a pull-request. If it is not, then make sure that the software you check the information with does try to read the relevant key. Be aware, that some software like iStat Menus implement special sensor profiles based on Mac platform, and may not read all the sensors available.
15+
16+
#### Is authenticated restart supported?
17+
Authenticated restart, normally invoked by `sudo fdesetup authrestart`, see `man fdesetup`, is supported when VirtualSMC.efi is present. However, it is insecure just as any software implementation is. If you care about privacy and security, you should disable it by passing `vsmchbkp=0` boot-arg.
18+
19+
The VirtualSMC implementation stores the encryption key in nvram and may encrypt it with a temporary key if higher RTC memory bank is available. Other than that, AptioMemoryFix will try to prevent reads of the encryption key after EXIT_BOOT_SERVICES, if installed.
20+
21+
#### What are the files in Docs?
22+
- `SMCBasics.txt` contains generic information about SMC
23+
- `SMCKeys.txt` contains documentation about SMC keys
24+
- `SMCLegacyKeys.html` contains old documentation about SMC keys
25+
- `SMCSensorKeys.txt` contains `libSMC.dylib` SMC sensor keys
26+
- `SMCDumps` contains SMC key dumps created by running `smcread -s`, please add more!
27+
- `SMCDatabase` contains SMC firmware dumps created with `smcread` from Apple updates
28+
- `SMCTypes` contains summarised SMC key lists across SMC generations based on `SMCDatabase`
29+
- `iStat.txt` contains iStat Menus key profiles (FauxMac is a profile when FakeSMC service is detected)
30+
- `MacModels.txt` contains board-id <--> mac-model summary with SMC firmware dump statuses
31+
- `SensorInfo.md` contains basic sensor how-to
32+
33+
#### What are the tools all about?
34+
- `rtcread` allows to access RTC/CMOS memory and contains relevant AppleRTC information
35+
- `smcread` allows to access SMC keys, dump SMC firmwares and `libSMC.dylib`
36+
- `smc-fuzzer` is a fork of an old `smc` tool with some features missing in `smcread`
37+
- `libaistat` allows to dump SMC key profiles from iStat Menus when used with `DYLD_INSERT_LIBRARIES`
38+
39+
#### What are the sensors for?
40+
- `SMCLightSensor` implements an example of illumination sensor handling with a new SMC event API (requires `ACPI0008`/`_ALI`)
41+
- `SMCBatteryManager` implements a complete emulation layer of AppleSmartBattery of SMC and SMBus protocols
42+
- `SMCProcessor` implements temperature monitoring for Nehalem CPUs or newer

Docs/MacModels.txt

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
Mac-F42386C8 iMac7,1 <= 10.8 10.11
2+
Mac-F4238CC8 iMac7,1 <= 10.8 10.11
3+
Mac-F226BEC8 iMac8,1 <= 10.8 10.11
4+
Mac-F227BEC8 iMac8,1 <= 10.8 10.11
5+
Mac-F2218EA9 iMac9,1 <= 10.8 10.11
6+
Mac-F2218EC8 iMac9,1 <= 10.8 10.11
7+
Mac-F2218FA9 iMac9,1 <= 10.8 10.11
8+
Mac-F2218FC8 iMac9,1 <= 10.8 10.11
9+
Mac-F221DCC8 iMac10,1 <= 10.8 >= 10.12 [BASE]
10+
Mac-F2268CC8 iMac10,1 <= 10.8 >= 10.12 [BASE]
11+
Mac-F2268DC8 iMac10,1 <= 10.8 >= 10.12 [BASE]
12+
Mac-F2268DAE iMac11,1 <= 10.8 >= 10.12 [BASE]
13+
Mac-F2238AC8 iMac11,2 <= 10.8 >= 10.12
14+
Mac-F2238BAE iMac11,3 <= 10.8 >= 10.12
15+
Mac-942B5BF58194151B iMac12,1 <= 10.8 >= 10.12
16+
Mac-942B59F58194171B iMac12,2 <= 10.8 >= 10.12
17+
Mac-00BE6ED71E35EB86 iMac13,1 <= 10.8 >= 10.12
18+
Mac-FC02E91DDD3FA6A4 iMac13,2 <= 10.8 >= 10.12
19+
Mac-7DF2A3B5E5D671ED iMac13,3 <= 10.8 >= 10.12
20+
Mac-031B6874CF7F642A iMac14,1 <= 10.8 >= 10.12 [OK]
21+
Mac-27ADBB7B4CEE8E61 iMac14,2 <= 10.8 >= 10.12 [OK]
22+
Mac-77EB7D7DAF985301 iMac14,3 10.9 >= 10.12 [OK]
23+
Mac-81E3E92DD6088272 iMac14,4 10.9 >= 10.12 [OK]
24+
Mac-42FD25EABCABB274 iMac15,1 10.10 >= 10.12 [OK]
25+
Mac-FA842E06C61E91C5 iMac15,2 10.10 >= 10.12 [OK] +b
26+
Mac-A369DDC4E67F1C45 iMac16,1 10.11 >= 10.12 [OK]
27+
Mac-FFE5EF870D7BA81A iMac16,2 10.11 >= 10.12 [OK]
28+
Mac-65CE76090165799A iMac17,1 10.11 >= 10.12 [OK]
29+
Mac-B809C3757DA9BB8D iMac17,1 10.11 >= 10.12 [OK]
30+
Mac-DB15BD556843C820 iMac17,1 10.11 >= 10.12 [OK]
31+
Mac-4B682C642B45593E iMac18,1 10.12 >= 10.12
32+
Mac-77F17D7DA9285301 iMac18,2 10.12 >= 10.12
33+
Mac-BE088AF8C5EB4FA2 iMac18,3 10.12 >= 10.12
34+
Mac-CF21D135A7D34AA6 Unknown 10.13 >= 10.13
35+
Mac-112B0A653D3AAB9C Unknown 10.13 >= 10.13
36+
Mac-90BE64C3CB5A9AEB Unknown 10.13 >= 10.13
37+
Mac-F42D89A9 MacBook5,1 <= 10.8 10.11 [BASE]
38+
Mac-F42D89C8 MacBook5,1 <= 10.8 10.11 [BASE]
39+
Mac-F22788AA MacBook5,2 <= 10.8 10.11 [BASE]
40+
Mac-F22C8AC8 MacBook6,1 <= 10.8 >= 10.12
41+
Mac-F22C89C8 MacBook7,1 <= 10.8 >= 10.12 [BASE]
42+
Mac-BE0E8AC46FE800CC MacBook8,1 10.10 >= 10.12 [OK]
43+
Mac-F305150B0C7DEEEF MacBook8,2 10.10 >= 10.12
44+
Mac-9AE82516C7C6B903 MacBook9,1 10.11 >= 10.12 [OK]
45+
Mac-EE2EBD4B90B839A8 MacBook10,1 10.12 >= 10.12
46+
Mac-F42D88C8 MacBookAir2,1 <= 10.8 10.11 [BASE]
47+
Mac-942452F5819B1C1B MacBookAir3,1 <= 10.8 >= 10.12 [BASE]
48+
Mac-942C5DF58193131B MacBookAir3,2 <= 10.8 >= 10.12 [BASE]
49+
Mac-C08A6BB70A942AC2 MacBookAir4,1 <= 10.8 >= 10.12 [BASE]
50+
Mac-742912EFDBEE19B3 MacBookAir4,2 <= 10.8 >= 10.12 [BASE]
51+
Mac-66F35F19FE2A0D05 MacBookAir5,1 <= 10.8 >= 10.12 [BASE]
52+
Mac-2E6FAB96566FE58C MacBookAir5,2 <= 10.8 >= 10.12 [BASE]
53+
Mac-35C1E88140C3E6CF MacBookAir6,1 <= 10.8 >= 10.12 [OK]
54+
Mac-7DF21CB3ED6977E5 MacBookAir6,2 <= 10.8 >= 10.12 [OK]
55+
Mac-9F18E312C5C2BF0B MacBookAir7,1 10.10 >= 10.12 [OK]
56+
Mac-937CB26E2E02BB01 MacBookAir7,2 10.10 >= 10.12 [OK]
57+
Mac-F42388C8 MacBookPro3,1 <= 10.8 10.11 http://support.apple.com/kb/dl832
58+
Mac-F4238BC8 MacBookPro3,1 <= 10.8 10.11 http://support.apple.com/kb/dl832
59+
Mac-F42C86C8 MacBookPro4,1 <= 10.8 10.11 http://support.apple.com/kb/DL1311
60+
Mac-F42C89C8 MacBookPro4,1 <= 10.8 10.11 http://support.apple.com/kb/DL1311
61+
Mac-F42D86A9 MacBookPro5,1 <= 10.8 10.11 http://support.apple.com/kb/DL741
62+
Mac-F42D86C8 MacBookPro5,1 <= 10.8 10.11 http://support.apple.com/kb/DL741
63+
Mac-F2268EC8 MacBookPro5,2 <= 10.8 10.11
64+
Mac-F22587C8 MacBookPro5,3 <= 10.8 10.11
65+
Mac-F22587A1 MacBookPro5,4 <= 10.8 10.11
66+
Mac-F2268AC8 MacBookPro5,5 <= 10.8 10.11
67+
Mac-F22589C8 MacBookPro6,1 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1731
68+
Mac-F22586C8 MacBookPro6,2 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1731
69+
Mac-F222BEC8 MacBookPro7,1 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1626
70+
Mac-50619A408DB004DA MacBookPro8,1 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1731
71+
Mac-94245B3640C91C81 MacBookPro8,1 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1474
72+
Mac-94245A3940C91C80 MacBookPro8,2 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1474
73+
Mac-942459F5819B171B MacBookPro8,3 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1474
74+
Mac-4B7AC7E43945597E MacBookPro9,1 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1633
75+
Mac-6F01561E16C75D06 MacBookPro9,2 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1633
76+
Mac-C3EC7CD22292981F MacBookPro10,1 <= 10.8 >= 10.12
77+
Mac-AFD8A9D944EA4843 MacBookPro10,2 <= 10.8 >= 10.12 http://support.apple.com/kb/DL1559
78+
Mac-189A3D4F975D5FFC MacBookPro11,1 10.9 >= 10.12 [OK]
79+
Mac-3CBD00234E554E41 MacBookPro11,2 10.9 >= 10.12 [OK]
80+
Mac-2BD1B31983FE1663 MacBookPro11,3 10.9 >= 10.12 [OK]
81+
Mac-06F11FD93F0323C5 MacBookPro11,4 10.10 >= 10.12 [OK]
82+
Mac-06F11F11946D27C5 MacBookPro11,5 10.10 >= 10.12 [OK]
83+
Mac-E43C1C25D4880AD6 MacBookPro12,1 10.10 >= 10.12 [OK]
84+
Mac-473D31EABEB93F9B MacBookPro13,1 10.12 >= 10.12 [OK]
85+
Mac-66E35819EE2D0D05 MacBookPro13,2 10.12 >= 10.12 [OK]
86+
Mac-A5C67F76ED83108C MacBookPro13,3 10.12 >= 10.12 [OK]
87+
Mac-B4831CEBD52A0C4C MacBookPro14,1 10.12 >= 10.12
88+
Mac-CAD6701F7CEA0921 MacBookPro14,2 10.12 >= 10.12
89+
Mac-551B86E5744E2388 MacBookPro14,3 10.12 >= 10.12
90+
Mac-937A206F2EE63C01 MacBookPro15,1 >= 10.13 >= 10.13
91+
Mac-827FB448E656EC26 MacBookPro15,2 >= 10.13 >= 10.13
92+
Mac-F22C86C8 Macmini3,1 <= 10.8 10.11
93+
Mac-F2208EC8 Macmini4,1 <= 10.8 >= 10.12
94+
Mac-8ED6AF5B48C039E1 Macmini5,1 <= 10.8 >= 10.12
95+
Mac-4BC72D62AD45599E Macmini5,2 <= 10.8 >= 10.12
96+
Mac-7BA5B2794B2CDB12 Macmini5,3 <= 10.8 >= 10.12
97+
Mac-031AEE4D24BFF0B1 Macmini6,1 <= 10.8 >= 10.12
98+
Mac-F65AE981FFA204ED Macmini6,2 <= 10.8 >= 10.12
99+
Mac-35C5E08120C7EEAF Macmini7,1 10.10 >= 10.12 [OK] +a
100+
Mac-F4208DC8 MacPro1,1 <= 10.7 10.7
101+
Mac-F4208DA9 MacPro2,1 <= 10.7 10.7
102+
Mac-F42C88C8 MacPro3,1 <= 10.8 10.11
103+
Mac-F221BEC8 MacPro4,1 <= 10.8 10.11
104+
Mac-F221BEC8 MacPro5,1 <= 10.8 >= 10.12 [BASE]
105+
Mac-F60DEB81FF30ACF6 MacPro6,1 10.9 >= 10.12 [OK]
106+
Mac-7BA5B2D9E42DDD94 iMacPro1,1 10.13 >= 10.13
107+
Mac-F223BEC8 Xserve3,1 <= 10.8 10.11
108+
Mac-F088A60696011ACB Unknown 10.8 >= 10.13
109+
Mac-C9CF552659EA9913 Unknown 10.9 >= 10.13
110+
Mac-4BFAC7A2B9455938 Unknown 10.9 >= 10.13
111+
Mac-ACE8A17C0DE83137 Unknown 10.9 >= 10.13
112+
Mac-6F01109E16C71B86 Unknown 10.9 >= 10.13
113+
Mac-4BFBC784B845591E Unknown 10.12 >= 10.12

Docs/SMCBasics.txt

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
OLD SMC (Renesas/Hitachi H8S/2117)
2+
0x000000-0x000FFF: Exception Vectors
3+
0x001000-0x005FFF: Unknown/Unused
4+
0x006000-0x006FFF: EPM UV Area
5+
0x007000-0x007FFF: EPM CV Area
6+
0x008000-0x022FFF: ROM Code + Data Variables
7+
0x027FE0-0x027FFF: Code Markers (TBD)
8+
0xFF2000-0xFF2FFF: Reserved (but used!)
9+
0xFFF800-0xFFFEFF: I/O Registers
10+
0xFFD080-0xFFEFFF: RAM (Data Variables)
11+
0xFFFF00-0xFFFF7F: RAM (Used as Stack)
12+
0xFFFF80-0xFFFFFF: I/O Registers
13+
14+
NEW SMC (EP: 0x250)
15+
0x00000000-0x0003FFFF: Flash ROM
16+
0x00040000-0x00FFFFFF: Reserved
17+
0x01000000-0x1FFFFFFF: TI ROM
18+
0x20000000-0x20007FFF: RAM
19+
0x20080000-0x21FFFFFF: Reserved
20+
0x22000000-0x220FFFFF: RAM Alias
21+
0x22100000-0x3FFFFFFF: Reserved
22+
0x40000000-0x400FFFFF: Peripheral Registers
23+
0x400FFFFF-0xDFFFFFFF: Reserved
24+
0xE0000000-0xE0041FFF: Peripheral Registers
25+
0xE0042000-0xFFFFFFFF: Reserved
26+
27+
0x00000-0x007FC: Reset Vectors (2KB)
28+
0x007FC-0x08000: Reset Vector Magic
29+
0x00800-0x057F8: Base Flasher (20KB)
30+
0x057F8-0x05800: Base Flasher Magics
31+
0x05800-0x0A7F8: Update Flasher (20KB)
32+
0x0A7F8-0x0A800: Update Flasher Magics
33+
0x0A800-0x0B000: EPM UV Area (2KB)
34+
0x0B000-0x0B7F8: EPM CV Area (2KB)
35+
0x0B7F8-0x0B800: EPM UV + CV Area Magics
36+
0x0B800-0x3FFF8: User Application (210KB)
37+
0x3FFF8-0x40000: User Application Magic
38+
39+
40+
Regarding IDA:
41+
- ARM LE (ARMv7-m without VFP and with Thumb-2)
42+
- load in manual mode (ROM 0x00000 of 0x40000, RAM 0x20000000 of 0x8000)
43+
- compiler GNU c++, cross reference depth 128 or so
44+
- start with #KEY struct (do not forget to set key/type to string and handler to offset)
45+
- use gKEY and procKEY conventions
46+
- Mark ROM as DATA type with RWX access, otherwise certain code (e.g. getKeyInfo) will be missing in Hex-Rays
47+
48+
49+
Regarding SMC generations:
50+
- 1st generation is the old Hitachi controller
51+
- 2nd generation is the new ARM controller
52+
- 3rd generation is T2-based emulation (outside of bridgeOS, supposedly within sep-firmware.jXXX.RELEASE.im4p)
53+
54+
55+
Regarding SMC connections:
56+
- Normally part of LPCB (supposedly emulated on Kabylake+ Macs)
57+
- Can be a PCI-extension card with pci106b,1185 ID (supposedly for running ESXi on non-Apple servers)
58+
59+
Apple works straight with MMIO when using a PCI-based SMC. To build an emulator one needs to create an IOPCIDevice-based class,
60+
and override virtual IOMemoryMap * mapDeviceMemoryWithRegister(UInt8 reg, IOOptionBits options);
61+
AppleSMC will call it with reg = 16, options = 0, which should be translated to VirtualSMCProvider::getMapping(AppleSMCBufferMMIO, 0).
62+
Otherwise the emulation is exactly the same.
63+
64+
65+
Regarding attributes:
66+
Please be aware that SMC hides certain attributes when reading!
67+
uint8_t getKeyInfo(uint32_t key, uint8_t *out) {
68+
KeyDescr *descr = lookupKey(key);
69+
if (!descr)
70+
return SmcNotFound;
71+
out[0] = descr->len;
72+
out[1] = descr->type[0];
73+
out[2] = descr->type[1];
74+
out[3] = descr->type[2];
75+
out[4] = descr->type[3];
76+
out[5] = descr->attr & ~SMC_KEY_ATTRIBUTE_CONST;
77+
uint16_t epciHigh = gEPCI & 0xFF00;
78+
if (descr->attr & SMC_KEY_ATTRIBUTE_PRIVATE_READ && gKPST == 0 && epciHigh == 0xF000)
79+
out[5] &= ~SMC_KEY_ATTRIBUTE_READ;
80+
if (descr->attr & SMC_KEY_ATTRIBUTE_PRIVATE_WRITE && gKPST == 0 && epciHigh == 0xF000)
81+
out[5] &= ~SMC_KEY_ATTRIBUTE_WRITE;
82+
return SmcSuccess;
83+
}
84+
85+
86+
SMC Notifications
87+
- SMC can also be notified with IoRegistryEntrySetCFProperty
88+
- “TheTimesAreAChangin”
89+
- Sets SMC ‘CLKT’ and ‘CLKH’
90+
- Also supports Mach Message Notification (0xE0078000)
91+
- Sets SMC ‘RAID’ value to 1
92+
- Power State Change Callback (0xE000031)
93+
- Sets SMC ‘MSDW’ key to zero
94+
95+
https://app.assembla.com/wiki/show/fakesmc
96+
https://github.com/gcsgithub/smc_util/tree/master
97+
https://github.com/xythobuz/JSystemInfoKit/blob/master/SystemInfoKit/JSKSMC.m
98+
http://forum.osxlatitude.com/index.php?/topic/7283-apple-mac-smc-keys/
99+
https://web.archive.org/web/20151103144947/http://www.parhelia.ch/blog/statics/k3_keys.html
Binary file not shown.

0 commit comments

Comments
 (0)