TianoCore EDK2 master
Loading...
Searching...
No Matches
SerialPortLib.c File Reference
#include <Uefi.h>
#include <Library/DebugLib.h>
#include <Library/SemihostLib.h>
#include <Library/SerialPortLib.h>

Go to the source code of this file.

Macros

#define PRINT_BUFFER_SIZE   512
 
#define PRINT_BUFFER_THRESHOLD   (PRINT_BUFFER_SIZE - 4)
 

Functions

RETURN_STATUS EFIAPI SerialPortInitialize (VOID)
 
UINTN EFIAPI SerialPortWrite (IN UINT8 *Buffer, IN UINTN NumberOfBytes)
 
UINTN EFIAPI SerialPortRead (OUT UINT8 *Buffer, IN UINTN NumberOfBytes)
 
BOOLEAN EFIAPI SerialPortPoll (VOID)
 

Detailed Description

Serial I/O Port library functions with no library constructor/destructor

Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
Copyright (c) 2021, Arm Limited. All rights reserved.

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

Definition in file SerialPortLib.c.

Macro Definition Documentation

◆ PRINT_BUFFER_SIZE

#define PRINT_BUFFER_SIZE   512

Write data to serial device.

Parameters
BufferPoint of data buffer which need to be written.
NumberOfBytesNumber of output bytes which are cached in Buffer.
Return values
0Write data failed.
!0Actual number of bytes written to serial device.

Definition at line 47 of file SerialPortLib.c.

◆ PRINT_BUFFER_THRESHOLD

#define PRINT_BUFFER_THRESHOLD   (PRINT_BUFFER_SIZE - 4)

Definition at line 48 of file SerialPortLib.c.

Function Documentation

◆ SerialPortInitialize()

RETURN_STATUS EFIAPI SerialPortInitialize ( VOID  )

Initialize the serial device hardware.

If no initialization is required, then return RETURN_SUCCESS. If the serial device was successfully initialized, then return RETURN_SUCCESS. If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.

Return values
RETURN_SUCCESSThe serial device was initialized.
RETURN_DEVICE_ERRORThe serial device could not be initialized.

Definition at line 25 of file SerialPortLib.c.

◆ SerialPortPoll()

BOOLEAN EFIAPI SerialPortPoll ( VOID  )

Check to see if any data is available to be read from the debug device.

Return values
TRUEAt least one byte of data is available to be read
FALSENo data is available to be read

Definition at line 127 of file SerialPortLib.c.

◆ SerialPortRead()

UINTN EFIAPI SerialPortRead ( OUT UINT8 *  Buffer,
IN UINTN  NumberOfBytes 
)

Read data from serial device and save the datas in buffer.

Parameters
BufferPoint of data buffer which need to be written.
NumberOfBytesNumber of output bytes which are cached in Buffer.
Return values
0Read data failed.
!0Actual number of bytes read from serial device.

Definition at line 109 of file SerialPortLib.c.

◆ SerialPortWrite()

UINTN EFIAPI SerialPortWrite ( IN UINT8 *  Buffer,
IN UINTN  NumberOfBytes 
)

Write data from buffer to serial device.

Writes NumberOfBytes data bytes from Buffer to the serial device. The number of bytes actually written to the serial device is returned. If the return value is less than NumberOfBytes, then the write operation failed. If Buffer is NULL, then ASSERT(). If NumberOfBytes is zero, then return 0.

Parameters
BufferPointer to the data buffer to be written.
NumberOfBytesNumber of bytes to written to the serial device.
Return values
0NumberOfBytes is 0.
>0The number of bytes written to the serial device. If this value is less than NumberOfBytes, then the write operation failed.

Definition at line 52 of file SerialPortLib.c.