Closed joevt closed 2 years ago
I suspect on Macmini it might use mmio. As for jumping to new code, there is no such support right now, and I am afraid it will be too much effort to add it.
I don't think the PCIe serial port card that I have connected with Thunderbolt uses mmio. And the source code for serial_init seems to indicate that mmio can be bypassed using boot-arg mmio_uart=0
I will do some testing to see if legacy_uart_probe
can detect my PCIe serial port card.
I did a test where I call serial_init
directly from Lilu. This causes serial output from macOS to work but there's an eventual hang booting Ventura. The hang might be due to IOPCIConfigurator stuff happening while logging to the PCIe serial card. I eliminated the hang by reducing serial port output (I was logging all calls to PE_parse_boot_argn
which is called for boot-arg ioimageloader.logging
many times so I made it not log that boot-arg).
It may be that IOPCIConfigurator or something might disable PMIO to the serial port even when PCIeSerialDisable.kext is injected (this is in Ventura on Mac mini 2018; I need to check other OS's to see if this is new behaviour). In that case, the following command will reenable I/O:
sudo lspci -s $pciaddress COMMAND=1:1
where $pciaddress
is the bus:device.function in hex (IOReg property pcidebug has this info in decimal). I suppose it might be useful for PCIeSerialDisable.kext to have code to reenable I/O (the kext was meant to stop only macOS user processes from accessing the serial port).
The mystery remains why serial_init
isn't working properly before Lilu. I can try to see how the pe_serial.c globals are setup before Lilu calls serial_init
but the variables are static so I have to access them by offset instead of name (the offsets are in the kernel dSYM file in the KDK).
My changes to fix this issue are at https://github.com/joevt/PCIeSerialDisable
@PMheart, please update the docs :)
Done.
I have connected a Sonnet Echo Express III-D with PCIe serial card and have setup serial debug output from OpenCore. I am trying to determine why my patches to displaypolicyd (using my fork of Lilu/WhateverGreen) sometimes cause macOS Monterey 12.4 boot to hang. I am unable to get xnu to do kprintf to the PCIe serial card with the Mac mini 2018 like I could with my iMac 27 inch 2013. The OpenCore log says it patched xnu successfully:
I verified that the PMIO address of 0x4008 is unchanged in macOS (using
lspci
) I verified that the serial card is usable in macOS using Serial.app (requires PCIeSerialThunderboltEnable.kext; requires that PCIeSerialDisable.kext is not enabled for the port to be tested)The last line I usually see in the serial output is this:
If I have
Send early prints to serial port
and/orEnable early serial output on RELEASE kernel
patches enabled, then I can see these lines appear after the above line:I believe my boot-args are set correctly for serial kprintf (same as my iMac 2013)
I guess I need to figure out if
PE_init_kprintf
is being called and if it is setting or clearingdisable_serial_output
.Is it possible to make a patch to xnu that jumps to some new code, rather than just changing a few bytes? Perhaps xnu can jump into OpenCoreRuntime or some other block of code that is loaded at EFI time? Is there an example of such a patch?