2 Platform Hook Library instance for 16550 Uart.
4 Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <Pi/PiBootMode.h>
15 #include <Guid/Early16550UartBaseAddress.h>
17 #include <Guid/FdtHob.h>
19 #include <Library/BaseLib.h>
20 #include <Library/HobLib.h>
21 #include <Library/PcdLib.h>
22 #include <Library/PlatformHookLib.h>
24 /** Platform hook to retrieve the 16550 UART base address from the GUID Hob
25 that caches the UART base address from early boot stage and store it in
26 PcdSerialRegisterBase.
28 @retval RETURN_SUCCESS Success.
29 @retval RETURN_NOT_FOUND Serial Port information not found.
34 PlatformHookSerialPortInitialize (
41 if (PcdGet64 (PcdSerialRegisterBase
) != 0) {
42 return RETURN_SUCCESS
;
45 Hob
= GetFirstGuidHob (&gEarly16550UartBaseAddressGuid
);
46 if ((Hob
== NULL
) || (GET_GUID_HOB_DATA_SIZE (Hob
) != sizeof (*UartBase
))) {
47 return RETURN_NOT_FOUND
;
50 UartBase
= GET_GUID_HOB_DATA (Hob
);
51 if ((UINTN
)*UartBase
== 0) {
52 return RETURN_NOT_FOUND
;
55 return (RETURN_STATUS
)PcdSet64S (PcdSerialRegisterBase
, (UINTN
)*UartBase
);