Contribute
Register

[Guide] Dell XPS 13 9360 on MacOS Sierra 10.12.x - LTS (Long-Term Support) Guide

Status
Not open for further replies.
Uh, interesting.
Now nothing happens, even while pressing Ctrl.
Before hotpatches, a light tap made the window appear, longer tap made laptop sleep without prompt.

Compare patched DSDT with hotpatched DSDT to determine what is different.
 
Compare patched DSDT with hotpatched DSDT to determine what is different.

Found. Hotpatches do not remove IRQNoFlags() {2} from IPIC device.
Old DSDT patches removed it.
Tried applying FixIPIC_0040 Clover hotpatch, but the IRQ is still there in the hot-patched DSDT I extracted from running system with MacIasl (see screenshots below).
Does this old patch work with Clover 4000+? It seems not...

1.png


2.png


3.png
 
Found. Hotpatches do not remove IRQNoFlags() {2} from IPIC device.
Old DSDT patches removed it.
Tried applying FixIPIC_0040 Clover hotpatch, but the IRQ is still there in the hot-patched DSDT I extracted from running system with MacIasl (see screenshots below).
Does this old patch work with Clover 4000+? It seems not...

View attachment 257648

View attachment 257649

View attachment 257650

Check your Clover bootlog...
This is the FixIPIC_0040 code:
Code:
UINT32 FixPIC (UINT8 *dsdt, UINT32 len)
{
    UINT32 i, j, k;
    UINT32 IOADR  = 0;
    UINT32 RESADR = 0;
  UINT32 adr = 0;
  INT32  offset = 0, sizeoffset = 0;
  UINT32 PICADR, picsize = 0;

  DBG("Start PIC Fix\n");
  for (j=20; j<len; j++) {
    // Find Device PIC or IPIC  PNP0000
    if (CmpPNP(dsdt, j, 0x0000)) {
      PICADR = devFind(dsdt, j);
      adr = PICADR;
      if (!adr) {
        continue;
      }
      picsize = get_size(dsdt, adr);
      DBG("PIC size=%x at %x\n", picsize, adr);
      if (picsize) {
        break;
      }
    } // End PIC
  }
  if (!picsize) {
    DBG("IPIC not found\n");
    return len;
  }

    for (i=adr; i<adr+picsize; i++)
    {
    if (dsdt[i] == 0x11 && dsdt[i+2] == 0x0A) {
      RESADR = i+1;  //Format 11, size, 0A, size-3,... 79, 00
      IOADR = i+3;  //IO (Decode16 ==> 47, 01
      continue;
        } else {
      // or 11 41 09 0A 8D 47 01 20 00 -> size=0x91 size-4=0x89
      if ((dsdt[i] == 0x11) &&
          (dsdt[i+3] == 0x0A) &&
          ((dsdt[i+1] & 0xF0) == 0x40)) {
        RESADR = i+1;  //Format 11, size1, size2, 0A, size-4,... 79, 00
        IOADR = i+4;  //IO (Decode16 ==> 47, 01
        DBG("found CRS at %x size %x\n", RESADR, dsdt[IOADR]);
        continue;
      }
    }

    if (dsdt[i] == 0x22) { // Had IRQNoFlag
      for (k = i; k < RESADR + dsdt[IOADR] + 4; k++) {
        if ((dsdt[k] == 0x79) ||
            ((dsdt[k] == 0x47) && (dsdt[k+1] == 0x01)) ||
            ((dsdt[k] == 0x86) && (dsdt[k+1] == 0x09))) {
          sizeoffset = i - k;
          DBG("found PIC had IRQNoFlag will move %d bytes\n", sizeoffset);
          // First move offset byte remove IRQNoFlag
          len = move_data(i, dsdt, len, sizeoffset);
          // Fix IO (Decode16, size and _CRS size
      //   dsdt[RESADR] += (UINT8)sizeoffset;
          dsdt[IOADR] += (UINT8)sizeoffset;
          offset = write_size(RESADR, dsdt, len, sizeoffset);
          sizeoffset += offset;
          len += offset;
          break;
        }
      }
    }

    // if offset > 0 Fix Device PIC size
        if (sizeoffset != 0 ) {
      offset = write_size(adr, dsdt, len, sizeoffset);
      sizeoffset += offset;
      DBG("Fix Device PIC size %d\n", sizeoffset);
      len += offset;
      len = CorrectOuters(dsdt, len, adr-3, sizeoffset);
      sizeoffset = 0;
    } // sizeoffset if
    if ((dsdt[i+1] == 0x5B) && (dsdt[i+2] == 0x82)) {
      break; //end of PIC device and begin of new Device()
    }
    } // i loop

    return len;
}

It is from FixBiosDsdt.c
 
Check your Clover bootlog...
This is the FixIPIC_0040 code:
Code:
UINT32 FixPIC (UINT8 *dsdt, UINT32 len)
{
    UINT32 i, j, k;
    UINT32 IOADR  = 0;
    UINT32 RESADR = 0;
  UINT32 adr = 0;
  INT32  offset = 0, sizeoffset = 0;
  UINT32 PICADR, picsize = 0;

  DBG("Start PIC Fix\n");
  for (j=20; j<len; j++) {
    // Find Device PIC or IPIC  PNP0000
    if (CmpPNP(dsdt, j, 0x0000)) {
      PICADR = devFind(dsdt, j);
      adr = PICADR;
      if (!adr) {
        continue;
      }
      picsize = get_size(dsdt, adr);
      DBG("PIC size=%x at %x\n", picsize, adr);
      if (picsize) {
        break;
      }
    } // End PIC
  }
  if (!picsize) {
    DBG("IPIC not found\n");
    return len;
  }

    for (i=adr; i<adr+picsize; i++)
    {
    if (dsdt[i] == 0x11 && dsdt[i+2] == 0x0A) {
      RESADR = i+1;  //Format 11, size, 0A, size-3,... 79, 00
      IOADR = i+3;  //IO (Decode16 ==> 47, 01
      continue;
        } else {
      // or 11 41 09 0A 8D 47 01 20 00 -> size=0x91 size-4=0x89
      if ((dsdt[i] == 0x11) &&
          (dsdt[i+3] == 0x0A) &&
          ((dsdt[i+1] & 0xF0) == 0x40)) {
        RESADR = i+1;  //Format 11, size1, size2, 0A, size-4,... 79, 00
        IOADR = i+4;  //IO (Decode16 ==> 47, 01
        DBG("found CRS at %x size %x\n", RESADR, dsdt[IOADR]);
        continue;
      }
    }

    if (dsdt[i] == 0x22) { // Had IRQNoFlag
      for (k = i; k < RESADR + dsdt[IOADR] + 4; k++) {
        if ((dsdt[k] == 0x79) ||
            ((dsdt[k] == 0x47) && (dsdt[k+1] == 0x01)) ||
            ((dsdt[k] == 0x86) && (dsdt[k+1] == 0x09))) {
          sizeoffset = i - k;
          DBG("found PIC had IRQNoFlag will move %d bytes\n", sizeoffset);
          // First move offset byte remove IRQNoFlag
          len = move_data(i, dsdt, len, sizeoffset);
          // Fix IO (Decode16, size and _CRS size
      //   dsdt[RESADR] += (UINT8)sizeoffset;
          dsdt[IOADR] += (UINT8)sizeoffset;
          offset = write_size(RESADR, dsdt, len, sizeoffset);
          sizeoffset += offset;
          len += offset;
          break;
        }
      }
    }

    // if offset > 0 Fix Device PIC size
        if (sizeoffset != 0 ) {
      offset = write_size(adr, dsdt, len, sizeoffset);
      sizeoffset += offset;
      DBG("Fix Device PIC size %d\n", sizeoffset);
      len += offset;
      len = CorrectOuters(dsdt, len, adr-3, sizeoffset);
      sizeoffset = 0;
    } // sizeoffset if
    if ((dsdt[i+1] == 0x5B) && (dsdt[i+2] == 0x82)) {
      break; //end of PIC device and begin of new Device()
    }
    } // i loop

    return len;
}

It is from FixBiosDsdt.c

My Clover Bootlog says

Code:
<...>
5:572  0:004  FADT from XSDT: 0x766599B8
5:577  0:004  Xsdt reallocation done
5:582  0:004  old FADT length=10C
5:586  0:004  Apply DsdtFixMask=0x00260044
5:591  0:004     drop _DSM mask=0xFFFF
5:595  0:004  === [ FixBiosDsdt ] =======================================
5:784  0:188  VideoCard devID=0x59168086
5:789  0:004  DisplayADR1[0] = 0x20000, DisplayADR2[0] = 0xFFFE
5:793  0:004  USBADR[0] = 0x140000 and PCIe = 0xFFFE
<...>

Being the mask 0x00260044, it should be patched. How to read/log Clover DBG messages? Do I need a special, debug-flagged Clover binary?
 
My Clover Bootlog says

Code:
<...>
5:572  0:004  FADT from XSDT: 0x766599B8
5:577  0:004  Xsdt reallocation done
5:582  0:004  old FADT length=10C
5:586  0:004  Apply DsdtFixMask=0x00260044
5:591  0:004     drop _DSM mask=0xFFFF
5:595  0:004  === [ FixBiosDsdt ] =======================================
5:784  0:188  VideoCard devID=0x59168086
5:789  0:004  DisplayADR1[0] = 0x20000, DisplayADR2[0] = 0xFFFE
5:793  0:004  USBADR[0] = 0x140000 and PCIe = 0xFFFE
<...>

Being the mask 0x00260044, it should be patched. How to read/log Clover DBG messages? Do I need a special, debug-flagged Clover binary?

DBG macro is a compile time thing...
This is from FixBiosDsdt.c
Code:
#if DEBUG_FIX==0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_FIX, __VA_ARGS__)
#endif
 
@bozma88
Power-window opens with ctrl+insert, not sure what caused it to map to that
 
@bozma88
Power-window opens with ctrl+insert, not sure what caused it to map to that

Insert is probably mapped to the power button in the PS2 keyboard kext...
Check PS2 logs from debug kext.
Check ApplePS2ToADBMap.h.
Note:
Code:
    0x7f,   // e0 5e  System Power / Keyboard Power
 
Ok.

USB has been patched. CPU PM implemented.

Sleep just got even more efficient, 0% drain on 12hour sleep. Bluetooth unfortunately did not survive. Also of note that reboot does not fix it, has to be a cold boot, any idea why this is? Something interesting I noticed is that although the Bluetooth menu via Settings is unresponsive, it does still send the correct commands. So clicking "Turn Bluetooth Off" doesn't give a response, but blueutil correctly reports Bluetooth as off after the event. This makes me think that its possibly not the Bluetooth driver that crashed but the interface, which might be easier to solve. Will do more testing.

X86PlatformPlugin: I managed to inject modified plist for our board-id, and if you don't need to throttle the cpu this actually works really well, snappy, nice and low idle of .55W. Native HWP. AppleIntelInfo reports IA32_HWP_REQUEST at 0x80162304 and for the life of me I cannot figure out how to inject my own value. I tried modifying the frequency vectors string myself but either couldn't find the bits for anything other than LFM, or changing them elicits no response. @goodwin_c had a binary (released with HWPEnable) that could inject the value, but it no longer works, might have to try rewrite it myself.

Initiating sleep via Fn+insert leads to a very upsetting situation where upon wake the system crashes, screen goes blank, charge-indicator (by trackpad) flashes amber/white and fans go on full blast before the system resets. It was a very stressful 10 seconds and not something I'm going to experiment with again. Sleep via menu or lid works perfectly.

Code:
@MacBook:~$ kextstat|grep -y acpiplat
   13    2 0xffffff7f8334b000 0x60000    0x60000    com.apple.driver.AppleACPIPlatform (5.0) 65E05472-6AE7-3308-8CC8-FA6CB0DB2AEE <12 11 7 6 5 4 3 1>
@MacBook:~$ kextstat|grep -y appleintelcpu
@MacBook:~$ kextstat|grep -y applelpc
@MacBook:~$ kextstat|grep -y applehda
   90    1 0xffffff7f82f67000 0x1d000    0x1d000    com.apple.driver.AppleHDAController (279.48) ED51F180-19C8-3DE1-AF81-0E389D98ADDE <89 88 76 12 7 6 5 4 3 1>
  119    0 0xffffff7f830e9000 0xb5000    0xb5000    com.apple.driver.AppleHDA (279.48) 806B8C17-50CA-3C6B-90B3-195F38D8FB89 <118 96 90 89 88 76 6 5 4 3 1>

@MacBook:~$ sudo touch /System/Library/Extensions && sudo kextcache -u /
kext-dev-mode allowing invalid signature -67030 0xFFFFFFFFFFFEFA2A for kext X86PlatformPluginInjector.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext VoodooPS2Trackpad.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext VoodooPS2Mouse.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext VoodooPS2Keyboard.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext VoodooPS2Controller.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext USBInjectAll.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext Lilu.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakeSMC.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Intel_HD_Graphics.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID_Broadcom_WiFi.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext FakePCIID.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext BrcmPatchRAM2.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext BrcmFirmwareRepo.kext
kext-dev-mode allowing invalid signature -67013 0xFFFFFFFFFFFEFA3B for kext AppleMobileDevice.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext AppleBacklightInjector.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext PinConfigs.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext AppleALC.kext
kext-dev-mode allowing invalid signature -67062 0xFFFFFFFFFFFEFA0A for kext ACPIBatteryManager.kext
KernelCache ID: 64B558A613FA6B8401D81BD5C4D60CFD
 

Attachments

  • Problem_Reporting_3.zip
    2.9 MB · Views: 80
Ok.

USB has been patched. CPU PM implemented.

Sleep just got even more efficient, 0% drain on 12hour sleep. Bluetooth unfortunately did not survive.

Check kernel logs from BrcmPatchRAM.
The way BrcmPatchRAM works may need some modifications. It would be better if it hooked IOUSB vtable (if possible), such that all work was done upon open being called. But it might be tricky...
With the way it is now, a race condition is all too easy to cause. Possibility exists of race condition between native bluetooth drivers and the firmware uploader code.

Try also with normal XCPM (eg. SMBIOS that is not HWP enabled).

Note: SSDT-SMBUS.aml probably not needed.

Also of note that reboot does not fix it, has to be a cold boot, any idea why this is?

Bluetooth controller is probably in a bad state after the race condition occuring.

X86PlatformPlugin: I managed to inject modified plist for our board-id, and if you don't need to throttle the cpu this actually works really well, snappy, nice and low idle of .55W. Native HWP. AppleIntelInfo reports IA32_HWP_REQUEST at 0x80162304 and for the life of me I cannot figure out how to inject my own value.

Try setting with Clover. See if it survives boot and sleep/wake cycle.

Initiating sleep via Fn+insert leads to a very upsetting situation where upon wake the system crashes, screen goes blank, charge-indicator (by trackpad) flashes amber/white and fans go on full blast before the system resets. It was a very stressful 10 seconds and not something I'm going to experiment with again. Sleep via menu or lid works perfectly.

Fn+Insert should probably be trapped and handled natively (it is likely native ACPI code taking over...)
 
Status
Not open for further replies.
Back
Top