88 IN INT32 SerialPortNode,
94 CONST UINT8 *SizeValue;
105 (SerialPortInfo ==
NULL))
108 return EFI_INVALID_PARAMETER;
117 if (EFI_ERROR (Status)) {
123 if ((AddressCells < 1) ||
124 (AddressCells > 2) ||
132 Data = fdt_getprop (Fdt, SerialPortNode,
"reg", &DataSize);
133 if ((Data ==
NULL) ||
134 (DataSize < (INT32)(
sizeof (UINT32) *
142 if (AddressCells == 2) {
143 SerialPortInfo->BaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
145 SerialPortInfo->BaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
148 SizeValue = Data + (
sizeof (UINT32) *
150 if (SizeCells == 2) {
151 SerialPortInfo->BaseAddressLength = fdt64_to_cpu (*(UINT64 *)SizeValue);
153 SerialPortInfo->BaseAddressLength = fdt32_to_cpu (*(UINT32 *)SizeValue);
158 if (EFI_ERROR (Status)) {
160 if (Status == EFI_NOT_FOUND) {
162 Status = EFI_ABORTED;
170 if (EFI_ERROR (Status)) {
175 Data = fdt_getprop (Fdt, SerialPortNode,
"interrupts", &DataSize);
176 if ((Data ==
NULL) || (DataSize != (IntCells *
sizeof (UINT32)))) {
185 Data = fdt_getprop (Fdt, SerialPortNode,
"clock-frequency", &DataSize);
187 if (DataSize <
sizeof (UINT32)) {
191 }
else if (fdt_node_offset_by_phandle (Fdt, fdt32_to_cpu (*Data)) >= 0) {
195 return EFI_UNSUPPORTED;
198 SerialPortInfo->Clock = fdt32_to_cpu (*(UINT32 *)Data);
202 SerialPortInfo->PortSubtype =
203 EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_16550_WITH_GAS;
211 Data = fdt_getprop (Fdt, SerialPortNode,
"reg-io-width", &DataSize);
213 if (DataSize <
sizeof (UINT32)) {
219 AccessSize = fdt32_to_cpu (*(UINT32 *)Data);
220 if (AccessSize > EFI_ACPI_6_3_QWORD) {
222 return EFI_INVALID_PARAMETER;
225 SerialPortInfo->AccessSize = AccessSize;
228 SerialPortInfo->AccessSize = EFI_ACPI_6_3_BYTE;
236 SerialPortInfo->PortSubtype =
237 EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART;
240 return EFI_UNSUPPORTED;
244 SerialPortInfo->BaudRate = 115200;
267 OUT INT32 *SerialConsoleNode
277 (SerialConsoleNode ==
NULL))
280 return EFI_INVALID_PARAMETER;
284 ChosenNode = fdt_path_offset (Fdt,
"/chosen");
285 if (ChosenNode < 0) {
286 return EFI_NOT_FOUND;
289 Prop = fdt_getprop (Fdt, ChosenNode,
"stdout-path", &PropSize);
290 if ((Prop ==
NULL) || (PropSize < 0)) {
291 return EFI_NOT_FOUND;
295 Path =
ScanMem8 (Prop, PropSize,
':');
299 PathLen = (INT32)(Path - Prop);
303 if (Prop[0] ==
'/') {
304 *SerialConsoleNode = fdt_path_offset_namelen (Fdt, Prop, PathLen);
309 Path = fdt_get_alias_namelen (Fdt, Prop, PathLen);
311 return EFI_NOT_FOUND;
314 *SerialConsoleNode = fdt_path_offset (Fdt, Path);
344 if ((GenericSerialInfo ==
NULL) || (NodeCount == 0)) {
346 return EFI_INVALID_PARAMETER;
354 return EFI_INVALID_PARAMETER;
365 if (EFI_ERROR (Status)) {
426 return EFI_INVALID_PARAMETER;
429 ZeroMem (&SerialInfo,
sizeof (SerialInfo));
432 FdtParserHandle->Fdt,
436 if (EFI_ERROR (Status)) {
484 INT32 SerialConsoleNode;
485 INT32 SerialDebugNode;
488 UINT32 SerialNodeCount;
489 UINT32 SerialNodesRemaining;
491 UINT32 GenericSerialIndex;
494 if (FdtParserHandle ==
NULL) {
496 return EFI_INVALID_PARAMETER;
499 Fdt = FdtParserHandle->Fdt;
508 if (EFI_ERROR (Status)) {
513 if (SerialNodeCount == 0) {
514 return EFI_NOT_FOUND;
522 SerialNodesRemaining = SerialNodeCount;
526 if (Status == EFI_NOT_FOUND) {
528 SerialConsoleNode = -1;
529 }
else if (EFI_ERROR (Status)) {
539 if (EFI_ERROR (Status)) {
544 SerialNodesRemaining--;
547 GenericSerialInfo =
NULL;
548 if (SerialNodesRemaining > 1) {
553 SerialNodesRemaining--;
555 SerialNodesRemaining *
558 if (GenericSerialInfo ==
NULL) {
560 return EFI_OUT_OF_RESOURCES;
564 SerialNode = FdtBranch;
565 SerialDebugNode = -1;
566 GenericSerialIndex = 0;
567 for (Index = 0; Index < SerialNodeCount; Index++) {
575 if (EFI_ERROR (Status)) {
577 if (Status == EFI_NOT_FOUND) {
579 Status = EFI_ABORTED;
586 if (SerialNode == SerialConsoleNode) {
588 }
else if (SerialDebugNode == -1) {
591 SerialDebugNode = SerialNode;
597 if (EFI_ERROR (Status)) {
602 if (GenericSerialInfo ==
NULL) {
605 Status = EFI_ABORTED;
612 &GenericSerialInfo[GenericSerialIndex++]
614 if (EFI_ERROR (Status)) {
621 if (GenericSerialIndex > 0) {
631 if (GenericSerialInfo !=
NULL) {
enum ArchCommonObjectID EARCH_COMMON_OBJECT_ID
@ EArchCommonObjSerialPortInfo
2 - Generic Serial Port Info
@ EArchCommonObjSerialDebugPortInfo
4 - Serial Debug Port Info
@ EArchCommonObjConsolePortInfo
3 - Serial Console Port Info
UINT32 EFIAPI FdtGetInterruptId(UINT32 CONST *Data)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI ScanMem8(IN CONST VOID *Buffer, IN UINTN Length, IN UINT8 Value)
EFI_STATUS EFIAPI FreeCmObjDesc(IN CM_OBJ_DESCRIPTOR *CmObjDesc)
EFI_STATUS EFIAPI AddMultipleCmObj(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN CONST CM_OBJ_DESCRIPTOR *CmObjDesc, IN UINT32 TokenCount, OPTIONAL OUT CM_OBJECT_TOKEN *TokenTable OPTIONAL)
EFI_STATUS EFIAPI CreateCmObjDesc(IN CM_OBJECT_ID ObjectId, IN UINT32 Count, IN VOID *Data, IN UINT32 Size, OUT CM_OBJ_DESCRIPTOR **NewCmObjDesc)
#define CREATE_CM_ARCH_COMMON_OBJECT_ID(ObjectId)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI FdtGetNextCompatNodeInBranch(IN CONST VOID *Fdt, IN INT32 FdtBranch, IN CONST COMPATIBILITY_INFO *CompatNamesInfo, IN OUT INT32 *Node)
BOOLEAN EFIAPI FdtNodeIsCompatible(IN CONST VOID *Fdt, IN INT32 Node, IN CONST VOID *CompatInfo)
EFI_STATUS EFIAPI FdtGetParentAddressInfo(IN CONST VOID *Fdt, IN INT32 Node, OUT INT32 *AddressCells, OPTIONAL OUT INT32 *SizeCells OPTIONAL)
EFI_STATUS EFIAPI FdtCountCompatNodeInBranch(IN CONST VOID *Fdt, IN INT32 FdtBranch, IN CONST COMPATIBILITY_INFO *CompatNamesInfo, OUT UINT32 *NodeCount)
EFI_STATUS EFIAPI FdtGetIntcParentNode(IN CONST VOID *Fdt, IN INT32 Node, OUT INT32 *IntcNode)
EFI_STATUS EFIAPI FdtGetInterruptCellsInfo(IN CONST VOID *Fdt, IN INT32 IntcNode, OUT INT32 *IntCells)
#define GET_DT_REG_SIZE_OFFSET(Index, AddrCells, SizeCells)
#define GET_DT_REG_ADDRESS_OFFSET(Index, AddrCells, SizeCells)
#define ARRAY_SIZE(Array)
#define ASSERT_EFI_ERROR(StatusParameter)
STATIC CONST COMPATIBILITY_STR SerialSbsaCompatibleStr[]
EFI_STATUS EFIAPI SerialPortDispatcher(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
CONST COMPATIBILITY_INFO Serial16550CompatibleInfo
CONST COMPATIBILITY_INFO SerialCompatibleInfo
STATIC CONST COMPATIBILITY_STR Serial16550CompatibleStr[]
STATIC EFI_STATUS EFIAPI SerialPortInfoDispatch(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN CM_ARCH_COMMON_SERIAL_PORT_INFO *GenericSerialInfo, IN INT32 NodeCount, IN EARCH_COMMON_OBJECT_ID SerialObjectId)
STATIC CONST COMPATIBILITY_STR SerialCompatibleStr[]
STATIC EFI_STATUS EFIAPI SerialPortInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch, IN EARCH_COMMON_OBJECT_ID SerialObjectId)
CONST COMPATIBILITY_INFO SerialSbsaCompatibleInfo
STATIC EFI_STATUS EFIAPI SerialPortNodeParser(IN CONST VOID *Fdt, IN INT32 SerialPortNode, IN CM_ARCH_COMMON_SERIAL_PORT_INFO *SerialPortInfo)
STATIC EFI_STATUS EFIAPI GetSerialConsoleNode(IN CONST VOID *Fdt, OUT INT32 *SerialConsoleNode)