TianoCore EDK2 master
Loading...
Searching...
No Matches
SerialPortParser.c File Reference

Go to the source code of this file.

Functions

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)
 
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 EFI_STATUS EFIAPI SerialPortInfoParser (IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch, IN EARCH_COMMON_OBJECT_ID SerialObjectId)
 
EFI_STATUS EFIAPI SerialPortDispatcher (IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
 

Variables

STATIC CONST COMPATIBILITY_STR SerialCompatibleStr []
 
CONST COMPATIBILITY_INFO SerialCompatibleInfo
 
STATIC CONST COMPATIBILITY_STR Serial16550CompatibleStr []
 
CONST COMPATIBILITY_INFO Serial16550CompatibleInfo
 
STATIC CONST COMPATIBILITY_STR SerialSbsaCompatibleStr []
 
CONST COMPATIBILITY_INFO SerialSbsaCompatibleInfo
 

Detailed Description

Serial Port Parser.

Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Reference(s):
  • linux/Documentation/devicetree/bindings/serial/serial.yaml
  • linux/Documentation/devicetree/bindings/serial/8250.txt
  • linux/Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
  • linux/Documentation/devicetree/bindings/serial/pl011.yaml

Definition in file SerialPortParser.c.

Function Documentation

◆ GetSerialConsoleNode()

STATIC EFI_STATUS EFIAPI GetSerialConsoleNode ( IN CONST VOID *  Fdt,
OUT INT32 *  SerialConsoleNode 
)

Find the console serial-port node in the DT.

This function fetches the node referenced in the "stdout-path" property of the "chosen" node.

Parameters
[in]FdtPointer to a Flattened Device Tree (Fdt).
[out]SerialConsoleNodeIf success, contains the node offset of the console serial-port node.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_NOT_FOUNDNot found.

Definition at line 265 of file SerialPortParser.c.

◆ SerialPortDispatcher()

EFI_STATUS EFIAPI SerialPortDispatcher ( IN CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
IN INT32  FdtBranch 
)

SerialPort dispatcher.

This disptacher populates the CM_ARCH_COMMON_SERIAL_PORT_INFO structure for the following CM_OBJ_ID:

  • EArchCommonObjConsolePortInfo
  • EArchCommonObjSerialDebugPortInfo
  • EArchCommonObjSerialPortInfo

A parser parses a Device Tree to populate a specific CmObj type. None, one or many CmObj can be created by the parser. The created CmObj are then handed to the parser's caller through the HW_INFO_ADD_OBJECT interface. This can also be a dispatcher. I.e. a function that not parsing a Device Tree but calling other parsers.

Parameters
[in]FdtParserHandleA handle to the parser instance.
[in]FdtBranchWhen searching for DT node name, restrict the search to this Device Tree branch.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_NOT_FOUNDNot found.
EFI_UNSUPPORTEDUnsupported.

Definition at line 478 of file SerialPortParser.c.

◆ SerialPortInfoDispatch()

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 
)

CM_ARCH_COMMON_SERIAL_PORT_INFO dispatcher function (for a generic serial-port).

Parameters
[in]FdtParserHandleA handle to the parser instance.
[in]GenericSerialInfoPointer to a serial port info list.
[in]NodeCountCount of serial ports to dispatch.
[in]SerialObjectIdSerial port object ID.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_NOT_FOUNDNot found.
EFI_UNSUPPORTEDUnsupported.

Definition at line 334 of file SerialPortParser.c.

◆ SerialPortInfoParser()

STATIC EFI_STATUS EFIAPI SerialPortInfoParser ( IN CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
IN INT32  FdtBranch,
IN EARCH_COMMON_OBJECT_ID  SerialObjectId 
)

CM_ARCH_COMMON_SERIAL_PORT_INFO parser function (for debug/console serial-port).

This parser expects FdtBranch to be the debug serial-port node. At most one CmObj is created. The following structure is populated: typedef struct EArchCommonSerialPortInfo { UINT64 BaseAddress; // {Populated} UINT32 Interrupt; // {Populated} UINT64 BaudRate; // {default} UINT32 Clock; // {Populated} UINT16 PortSubtype; // {Populated} UINT64 BaseAddressLength // {Populated} } CM_ARCH_COMMON_SERIAL_PORT_INFO;

A parser parses a Device Tree to populate a specific CmObj type. None, one or many CmObj can be created by the parser. The created CmObj are then handed to the parser's caller through the HW_INFO_ADD_OBJECT interface. This can also be a dispatcher. I.e. a function that not parsing a Device Tree but calling other parsers.

Parameters
[in]FdtParserHandleA handle to the parser instance.
[in]FdtBranchWhen searching for DT node name, restrict the search to this Device Tree branch.
[in]SerialObjectIdArchCommon Namespace Object ID for the serial port.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_NOT_FOUNDNot found.
EFI_UNSUPPORTEDUnsupported.

Definition at line 413 of file SerialPortParser.c.

◆ SerialPortNodeParser()

STATIC EFI_STATUS EFIAPI SerialPortNodeParser ( IN CONST VOID *  Fdt,
IN INT32  SerialPortNode,
IN CM_ARCH_COMMON_SERIAL_PORT_INFO SerialPortInfo 
)

Parse a serial port node.

Parameters
[in]FdtPointer to a Flattened Device Tree (Fdt).
[in]SerialPortNodeOffset of a serial-port node.
[in]SerialPortInfoThe CM_ARCH_COMMON_SERIAL_PORT_INFO to populate.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_UNSUPPORTEDUnsupported.

Definition at line 86 of file SerialPortParser.c.

Variable Documentation

◆ Serial16550CompatibleInfo

CONST COMPATIBILITY_INFO Serial16550CompatibleInfo
Initial value:
= {
}
#define ARRAY_SIZE(Array)
Definition: Base.h:1393
STATIC CONST COMPATIBILITY_STR Serial16550CompatibleStr[]

COMPATIBILITY_INFO structure for the Serial16550Compatible.

Definition at line 49 of file SerialPortParser.c.

◆ Serial16550CompatibleStr

STATIC CONST COMPATIBILITY_STR Serial16550CompatibleStr[]
Initial value:
= {
{ "ns16550a" }
}

16550 UART compatible strings.

Any string of this list must be part of SerialCompatible.

Definition at line 43 of file SerialPortParser.c.

◆ SerialCompatibleInfo

CONST COMPATIBILITY_INFO SerialCompatibleInfo
Initial value:
= {
}
STATIC CONST COMPATIBILITY_STR SerialCompatibleStr[]

COMPATIBILITY_INFO structure for the SerialCompatible.

Definition at line 34 of file SerialPortParser.c.

◆ SerialCompatibleStr

STATIC CONST COMPATIBILITY_STR SerialCompatibleStr[]
Initial value:
= {
{ "ns16550a" },
{ "arm,sbsa-uart" },
{ "arm,pl011" }
}

List of "compatible" property values for serial port nodes.

Any other "compatible" value is not supported by this module.

Definition at line 26 of file SerialPortParser.c.

◆ SerialSbsaCompatibleInfo

CONST COMPATIBILITY_INFO SerialSbsaCompatibleInfo
Initial value:
= {
}
STATIC CONST COMPATIBILITY_STR SerialSbsaCompatibleStr[]

COMPATIBILITY_INFO structure for the SerialSbsaCompatible.

Definition at line 67 of file SerialPortParser.c.

◆ SerialSbsaCompatibleStr

STATIC CONST COMPATIBILITY_STR SerialSbsaCompatibleStr[]
Initial value:
= {
{ "arm,sbsa-uart" },
{ "arm,pl011" }
}

SBSA UART compatible strings.

Include PL011 as SBSA uart is a subset of PL011.

Any string of this list must be part of SerialCompatible.

Definition at line 60 of file SerialPortParser.c.