When running on machines with a hw_vendor of "Apple Inc." or "Apple
Computer, Inc.", only return 1 for an OSI check of "Darwin" and not
the other Windows variants.
Code in the AML of the MacBookAir7,1 (most likely all Macs) does
much different things when running on Darwin systems, but the AML
that checks for Darwin does this:
OSYS = 0x07DC
If (CondRefOf (\_OSI, Local0))
{
If (_OSI ("Darwin"))
{
OSYS = 0x2710
}
If (\_OSI ("Linux"))
{
OSYS = 0x03E8
}
If (\_OSI ("Windows 2009"))
{
OSYS = 0x07D9
}
[...]
So we can't just add Darwin to aml_valid_osi.
Without this, my MacBook Air won't suspend properly (hangs calling
_PTS) and a similar change in Linux from 2014 (commit
7bc5a2bad0b8d9d1ac9f7b8b33150e4ddf197334) notes that upon resume,
the Thunderbolt ports won't be powered up without pretending to be
Darwin.
I tested this with a Thunderbolt ethernet device and it works
properly before and after suspend. Hot-plugging the Thunderbolt
ethernet device after boot no longer prints these messages:
ppb5 at pci4 dev 0 function 0 vendor "Intel", unknown product 0x156b rev
0x00
pci6 at ppb5 bus 6
ppb6 at pci6 dev 0 function 0 vendor "Intel", unknown product 0x156b rev
0x00: not configured by system firmware
ppb7 at pci6 dev 3 function 0 vendor "Intel", unknown product 0x156b rev
0x00: not configured by system firmware
ppb8 at pci6 dev 4 function 0 vendor "Intel", unknown product 0x156b rev
0x00: not configured by system firmware
ppb9 at pci6 dev 5 function 0 vendor "Intel", unknown product 0x156b rev
0x00: not configured by system firmware
ppb10 at pci6 dev 6 function 0 vendor "Intel", unknown product 0x156b rev
0x00: not configured by system firmware
Index: sys/dev/acpi/dsdt.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
retrieving revision 1.230
diff -u -p -u -p -r1.230 dsdt.c
--- sys/dev/acpi/dsdt.c 14 Jan 2017 11:32:00 -0000 1.230
+++ sys/dev/acpi/dsdt.c 10 Feb 2017 00:31:02 -0000
@@ -106,6 +106,8 @@ void _aml_die(const char *fn, int
line
void aml_notify_task(void *, int);
void acpi_poll_notify_task(void *, int);
+extern char *hw_vendor;
+
/*
* @@@: Global variables
*/
@@ -1505,6 +1507,21 @@ aml_callosi(struct aml_scope *scope, str
struct aml_value *fa;
fa = aml_getstack(scope, AMLOP_ARG0);
+
+ if (hw_vendor != NULL &&
+ (strcmp(hw_vendor, "Apple Inc.") == 0 ||
+ strcmp(hw_vendor, "Apple Computer, Inc.") == 0)) {
+ if (strcmp(fa->v_string, "Darwin") == 0) {
+ dnprintf(10,"osi: returning 1 for %s on %s hardware\n",
+ fa->v_string, hw_vendor);
+ result = 1;
+ } else
+ dnprintf(10,"osi: on %s hardware, but ignoring %s\n",
+ hw_vendor, fa->v_string);
+
+ return aml_allocvalue(AML_OBJTYPE_INTEGER, result, NULL);
+ }
+
for (idx=0; !result && aml_valid_osi[idx] != NULL; idx++) {
dnprintf(10,"osi: %s,%s\n", fa->v_string, aml_valid_osi[idx]);
result = !strcmp(fa->v_string, aml_valid_osi[idx]);