TianoCore EDK2 master
Loading...
Searching...
No Matches
PlatformHookLib.c
Go to the documentation of this file.
1
9#include <Base.h>
10#include <PiDxe.h>
13#include <Library/PcdLib.h>
14#include <Library/HobLib.h>
15
21EFIAPI
23 VOID
24 )
25{
26 // Nothing to do here. This constructor is added to
27 // enable the chain of constructor invocation for
28 // dependent libraries.
29 return RETURN_SUCCESS;
30}
31
43RETURN_STATUS
44EFIAPI
46 VOID
47 )
48{
49 RETURN_STATUS Status;
51 UINT8 *GuidHob;
53
54 if (GetHobList () == NULL) {
55 return RETURN_SUCCESS;
56 }
57
58 GuidHob = GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid);
59 if (GuidHob == NULL) {
60 return EFI_NOT_FOUND;
61 }
62
63 GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)GET_GUID_HOB_DATA (GuidHob);
64 if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) {
65 return EFI_NOT_FOUND;
66 }
67
68 if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION) {
69 SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)GET_GUID_HOB_DATA (GuidHob);
70 if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) {
71 //
72 // Return if can't find the Serial Port Info Hob with enough length
73 //
74 return EFI_NOT_FOUND;
75 }
76
77 Status = PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio);
78 if (RETURN_ERROR (Status)) {
79 return Status;
80 }
81
82 Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase);
83 if (RETURN_ERROR (Status)) {
84 return Status;
85 }
86
87 Status = PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->RegisterStride);
88 if (RETURN_ERROR (Status)) {
89 return Status;
90 }
91
92 Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
93 if (RETURN_ERROR (Status)) {
94 return Status;
95 }
96
97 return RETURN_SUCCESS;
98 }
99
100 return EFI_NOT_FOUND;
101}
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
VOID *EFIAPI GetHobList(VOID)
Definition: HobLib.c:76
#define NULL
Definition: Base.h:319
#define RETURN_ERROR(StatusCode)
Definition: Base.h:1061
#define RETURN_SUCCESS
Definition: Base.h:1066
#define PcdSetBoolS(TokenName, Value)
Definition: PcdLib.h:549
#define PcdSet64S(TokenName, Value)
Definition: PcdLib.h:511
#define PcdSet32S(TokenName, Value)
Definition: PcdLib.h:497
RETURN_STATUS EFIAPI PlatformHookSerialPortInitialize(VOID)
EFI_STATUS EFIAPI PlatformHookSerialPortConstructor(VOID)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD(TYPE, Field)