TianoCore EDK2 master
Loading...
Searching...
No Matches
FdtSerialPortAddressLib.c File Reference
#include <Library/BaseLib.h>
#include <Library/FdtSerialPortAddressLib.h>
#include <libfdt.h>

Go to the source code of this file.

Functions

STATIC RETURN_STATUS GetBaseAddress (IN CONST VOID *DeviceTree, IN INT32 Node, OUT UINT64 *BaseAddress)
 
RETURN_STATUS EFIAPI FdtSerialGetPorts (IN CONST VOID *DeviceTree, IN CONST CHAR8 *Compatible, OUT FDT_SERIAL_PORTS *Ports)
 
RETURN_STATUS EFIAPI FdtSerialGetConsolePort (IN CONST VOID *DeviceTree, OUT UINT64 *BaseAddress)
 

Detailed Description

Determine the base addresses of serial ports from the Device Tree.

Copyright (C) Red Hat Copyright (c) 2011 - 2023, Arm Ltd. All rights reserved.
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
Copyright (c) 2014 - 2020, Linaro Ltd. All rights reserved.
Copyright (c) 2015, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file FdtSerialPortAddressLib.c.

Function Documentation

◆ FdtSerialGetConsolePort()

RETURN_STATUS EFIAPI FdtSerialGetConsolePort ( IN CONST VOID *  DeviceTree,
OUT UINT64 *  BaseAddress 
)

Fetch the base address of the serial port identified in the "stdout-path" property of the "/chosen" node in DeviceTree.

Parameters
[in]DeviceTreeThe flat device tree (FDT) to scan.
[out]BaseAddressOn success, the base address of the preferred serial port (to be used as console). On error, BaseAddress is not modified.
Return values
RETURN_INVALID_PARAMETERDeviceTree does not point to a valid FDT header.
RETURN_NOT_FOUNDNo enabled console port has been found.
RETURN_PROTOCOL_ERRORThe first (or only) node path in the "stdout-path" property is an empty string.
RETURN_PROTOCOL_ERRORThe console port has been found in the FDT, but its base address is not correctly represented.
RETURN_SUCCESSBaseAddress has been populated.

Definition at line 168 of file FdtSerialPortAddressLib.c.

◆ FdtSerialGetPorts()

RETURN_STATUS EFIAPI FdtSerialGetPorts ( IN CONST VOID *  DeviceTree,
IN CONST CHAR8 *  Compatible,
OUT FDT_SERIAL_PORTS Ports 
)

Collect the first ARRAY_SIZE (Ports->BaseAddress) serial ports into Ports from DeviceTree.

Parameters
[in]DeviceTreeThe flat device tree (FDT) to scan.
[in]CompatibleLook for Compatible in the "compatible" property of the scanned nodes.
[out]PortsOn successful return, Ports->NumberOfPorts contains the number of serial ports found; it is (a) positive and (b) at most ARRAY_SIZE (Ports->BaseAddress). If the FDT had more serial ports, those are not reported. On error, the contents of Ports are indeterminate.
Return values
RETURN_INVALID_PARAMETERDeviceTree does not point to a valid FDT header.
RETURN_NOT_FOUNDNo compatible and enabled serial port has been found.
RETURN_SUCCESSAt least one compatible and enabled serial port has been found; Ports has been filled in.

Definition at line 94 of file FdtSerialPortAddressLib.c.

◆ GetBaseAddress()

STATIC RETURN_STATUS GetBaseAddress ( IN CONST VOID *  DeviceTree,
IN INT32  Node,
OUT UINT64 *  BaseAddress 
)

Read the "reg" property of Node in DeviceTree as a UINT64 base address.

Parameters
[in]DeviceTreeThe flat device tree (FDT) to scan.
[in]NodeThe node to read the "reg" property of.
[out]BaseAddressOn success, the base address read out of Node's "reg" property. On error, not modified.
Return values
RETURN_DEVICE_ERRORNode has a "status" property with value different from "okay".
RETURN_NOT_FOUNDNode does not have a "reg" property.
RETURN_BAD_BUFFER_SIZEThe size of Node's "reg" property is not 16 bytes.
RETURN_SUCCESSBaseAddress has been populated.

Definition at line 39 of file FdtSerialPortAddressLib.c.