Skip to content

CustomPciSerialDevice quirk doesn't work with default RegisterStride #2003

@joevt

Description

@joevt

I have updated my iMac14,2 to OpenCore 0.8.0 (config converted from OCLP 0.4.4 to OpenCore 0.8.0). I am attempting to do macOS xnu serial kprintf for the first time from this computer using a PCIe serial port card in a Thunderbolt enclosure.

Issue 1

The first issue is that FindSerialPort.command is not outputting the result. The following change should fix that.
Find:

fi

Replace:

else
  echo "$serial_dev"
fi

FYI, The output for a PCIe Serial Port in a Thunderbolt enclosure looks like this:

/Volumes/EFINVME/OpenCore-0/Utilities/FindSerialPort/FindSerialPort.command
/PCI0@0/RP05@1C,4/UPSB@0/DSB1@3/UPS0@0/pci-bridge@1/pci-bridge@0/pci-bridge@1/pci125b,9100@0
PciRoot(0x0)/Pci(0x1c,0x4)/Pci(0x0,0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)
xxd -p -r <<< "1c 04 00 00 00 00 00 00 03 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 FF" | base64

/PCI0@0/RP05@1C,4/UPSB@0/DSB1@3/UPS0@0/pci-bridge@1/pci-bridge@0/pci-bridge@1/pci125b,9100@0,2
PciRoot(0x0)/Pci(0x1c,0x4)/Pci(0x0,0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)/Pci(0x1,0x0)/Pci(0x0,0x2)
xxd -p -r <<< "1c 04 00 00 00 00 00 00 03 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 00 02 00 00 FF" | base64

The PCIe card has two serial ports, so there's two device paths in the result. I am using the first device path. It has 33 bytes which fits in the 40 byte limit. There's an extra pci-bridge since I'm using a Sonnet Echo Express III-D which has 3 slots.

Main Issue

The main issue is that the OpenCore CustomPciSerialDevice quirk doesn't do anything if the RegisterStride is 1. To fix this, make the following changes:

Find in CommonPatches.c:

  if ((mPmioRegisterBase != 0 && mPmioRegisterStride > 1)

Replace with:

  if ((mPmioRegisterBase != 0 && mPmioRegisterStride != 0)

Find in OcConfigurationLib.c:

      if ((RegisterBase != 0 && RegisterStride > 1)
        && RegisterBase != 0x3F8U) {

Replace with:

      if ((RegisterBase != 0 && RegisterStride != 0)
        && (RegisterBase != 0x3F8U || RegisterStride != 1)) {

Other Thunderbolt PCIe serial port notes

Apple's serial port driver Apple16X50Serial.kext doesn't have IOPCITunnelCompatible set to true except for a pair of PCIe cards:
https://pci-ids.ucw.cz/read/PC/1415/c101
https://pci-ids.ucw.cz/read/PC/1d0f 8250
so my PCIe card https://pci-ids.ucw.cz/read/PC/125b/9100 is not automatically enabled while in a Thunderbolt enclosure.

For Thunderbolt, I suppose a code-less kext can be made to enable any PCIe serial port card by defining an IOKit personality that matches the PCIe card using IONameMatch or IOPCIMatch (or any PCIe serial port with IOPCIClassMatch) and sets IOPCITunnelCompatible to true and points to the Apple16X50Serial binary. Add additional matching criteria so that the serial port that is used for xnu serial kprintf is not matched. Or add an IOKit personality that matches the serial port that is used by xnu and make that personality point to IOService instead of Apple16X50Serial binary and make it have a higher probe score (like the PCIeSerialDisable.kext example mentioned in the OpenCore Reference Manual).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions