Hi Benjamin, Due to some platform will disable the MMIO access of UART in ExitBootServices event. So we register an ExitBootServices event to avoid access the invalid MMIO space, it will cause the system hang when boot to windows OS. And the serial port library is also used in SEC and PEI phase, we will need another DXE library to avoid build error or possible system hang while the Boot Service is not available in PEI or SEC phase. From: Benjamin Doron Sent: Friday, April 28, 2023 1:36 AM To: Hsieh, PaytonX ; devel@edk2.groups.io Subject: Re: [edk2-devel] [PATCH] UefiPayloadPkg: Fix issues when MULTIPLE_DEBUG_PORT_SUPPORT is true Hi, Can you deduplicate this code by moving the functions into a common, or "base" file, and DXE's constructor and event into a separate file? As I see it, it should be alright to reuse DXE's functions for other phases, the `mBaseSerialPortLibHobAtRuntime` variable will never be changed in this case. Regards, Benjamin