There is also one extra caveat about UEFI runtime that I forgot to mention. There is no way to share the hardware between UEFI and the OS, so UEFI really needs dedicated hardware. Thanks, Andrew Fish PS This makes me think of a Windows story from the 1990’s when Windows added Plug-and-Play for serial to detect modems. A factory updated Windows on a PC that controlled a CnC machine and the modem auto detect AT commands got sent to the CnC machine, and this told the CnC machine to start drilling holes in the CnC machine. > On May 31, 2024, at 4:59 AM, Andrew Fish via groups.io wrote: > > I think the generic answer is no DEBUG() is not guaranteed to be MP safe. > > Jeff is pointing out in the edk2 your platform build can control what libraries are used to implement DEBUG(), so you might be able to make it work in your case. > > Base libs are libraries that don’t depend on other things so they have a much better chance of working but they will have at least 2 issue: > 1) The are not MP safe so the output could get intermixed and things could get lost as multiple agents try to to write to the UART in parallel > 2) A Base lib that goes after a x86 IO port has a chance of working at runtime, but an ARM UART driver that uses an MMIO address is not going to work as the that MMIO range would need a virtual mapping and a Base lib is not going to request that. > > You can search for instances of the DebugLib (that implements DEBUG) by grepping the inf files. > > /Volumes/Case/edk2(master)>git grep DebugLib -- \*.inf | grep LIBRARY_CLASS | grep DXE_RUNTIME_DRIVER > ArmPkg/Library/SemiHostingDebugLib/SemiHostingDebugLib.inf:19: LIBRARY_CLASS = DebugLib|BASE SEC DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER > ArmVirtPkg/Library/DebugLibFdtPL011Uart/DxeRuntimeDebugLibFdtPL011Uart.inf:23: LIBRARY_CLASS = DebugLib|DXE_RUNTIME_DRIVER > MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf:19: LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER SMM_CORE PEIM SEC PEI_CORE UEFI_APPLICATION UEFI_DRIVER MM_STANDALONE > MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf:22: LIBRARY_CLASS = DebugLib|DXE_RUNTIME_DRIVER > MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf:22: LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER > MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf:22: LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER > MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf:22: LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER > OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf:19: LIBRARY_CLASS = DebugLib|PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER SMM_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION > > Note: DXE_RUNTIME_DRIVE may not imply the the DEBUG works at running, and it may only support DEBUG print a Boot Services time. But if you look at the list you will see some of the libs are designed to used at runtime. So that should imply they deal with virtual address mapping and locks. > > Thanks, > > Andrew Fish > >> On May 31, 2024, at 1:33 AM, Jeff Fan via groups.io wrote: >> >> AP cannot run any UEFI Service. Please make sure AP code use base-typed DebugLib instance (Such as BaseDebugLibSerialport.inf from MdePkg) >> >> >> fanjianfeng@byosoft.com.cn >> >> 发件人: Yoshinoya >> 发送时间: 2024-05-31 14:22 >> 收件人: devel@edk2.groups.io >> 主题: [edk2-devel] Is DEBUG output function safe for MP case? >> Hello >> I ask for help for debug output in multi-core case. >> >> Is the current DEBUG marco safe for AP Cores to output message? >> If the output message is too long, it takes too much time, will it cause some abnormal exception? >> >> Thanks > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119410): https://edk2.groups.io/g/devel/message/119410 Mute This Topic: https://groups.io/mt/106405152/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-