TianoCore EDK2 master
Loading...
Searching...
No Matches
DebugPort.c File Reference
#include "DebugPort.h"

Go to the source code of this file.

Functions

EFI_DEVICE_PATH_PROTOCOLGetDebugPortVariable (VOID)
 
EFI_STATUS EFIAPI InitializeDebugPortDriver (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI DebugPortSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI DebugPortStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI DebugPortStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI DebugPortReset (IN EFI_DEBUGPORT_PROTOCOL *This)
 
EFI_STATUS EFIAPI DebugPortRead (IN EFI_DEBUGPORT_PROTOCOL *This, IN UINT32 Timeout, IN OUT UINTN *BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI DebugPortWrite (IN EFI_DEBUGPORT_PROTOCOL *This, IN UINT32 Timeout, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI DebugPortPoll (IN EFI_DEBUGPORT_PROTOCOL *This)
 
EFI_STATUS EFIAPI ImageUnloadHandler (EFI_HANDLE ImageHandle)
 

Variables

EFI_DRIVER_BINDING_PROTOCOL gDebugPortDriverBinding
 
DEBUGPORT_DEVICE mDebugPortDevice
 

Detailed Description

Top level C file for debugport driver. Contains initialization function. This driver layers on top of SerialIo. ALL CODE IN THE SERIALIO STACK MUST BE RE-ENTRANT AND CALLABLE FROM INTERRUPT CONTEXT

Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file DebugPort.c.

Function Documentation

◆ DebugPortPoll()

EFI_STATUS EFIAPI DebugPortPoll ( IN EFI_DEBUGPORT_PROTOCOL This)

DebugPort protocol member function. Calls SerialIo:Write() after setting if it's different than the last SerialIo access.

Parameters
ThisPointer to DebugPort protocol.
Return values
EFI_SUCCESSAt least 1 character is ready to be read from the DebugPort interface.
EFI_NOT_READYThere are no characters ready to read from the DebugPort interface
EFI_DEVICE_ERRORA hardware failure occurred... (from SerialIo)

Definition at line 644 of file DebugPort.c.

◆ DebugPortRead()

EFI_STATUS EFIAPI DebugPortRead ( IN EFI_DEBUGPORT_PROTOCOL This,
IN UINT32  Timeout,
IN OUT UINTN BufferSize,
IN VOID *  Buffer 
)

DebugPort protocol member function. Calls SerialIo:Read() after setting if it's different than the last SerialIo access.

Parameters
ThisPointer to DebugPort protocol.
TimeoutTimeout value.
BufferSizeOn input, the size of Buffer. On output, the amount of data actually written.
BufferPointer to buffer to read.
Return values
EFI_SUCCESS
others

Definition at line 534 of file DebugPort.c.

◆ DebugPortReset()

EFI_STATUS EFIAPI DebugPortReset ( IN EFI_DEBUGPORT_PROTOCOL This)

DebugPort protocol member function. Calls SerialIo:GetControl to flush buffer. We cannot call SerialIo:SetAttributes because it uses pool services, which use locks, which affect TPL, so it's not interrupt context safe or re-entrant. SerialIo:Reset() calls SetAttributes, so it can't be used either.

The port itself should be fine since it was set up during initialization.

Parameters
ThisProtocol instance pointer.
Returns
EFI_SUCCESS Always.

Definition at line 503 of file DebugPort.c.

◆ DebugPortStart()

EFI_STATUS EFIAPI DebugPortStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Binds exclusively to serial io on the controller handle, Produces DebugPort protocol and DevicePath on new handle.

Parameters
ThisProtocol instance pointer.
ControllerHandleHandle of device to bind driver to.
RemainingDevicePathOptional parameter use to pick a specific child device to start.
Return values
EFI_SUCCESSThis driver is added to ControllerHandle.
EFI_OUT_OF_RESOURCESFails to allocate memory for device.
othersSome error occurs.

Definition at line 265 of file DebugPort.c.

◆ DebugPortStop()

EFI_STATUS EFIAPI DebugPortStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Stop this driver on ControllerHandle by removing Serial IO protocol on the ControllerHandle.

Parameters
ThisProtocol instance pointer.
ControllerHandleHandle of device to stop driver on
NumberOfChildrenNumber of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver.
ChildHandleBufferList of Child Handles to Stop.
Return values
EFI_SUCCESSThis driver is removed ControllerHandle.
otherThis driver was not removed from this device.

Definition at line 412 of file DebugPort.c.

◆ DebugPortSupported()

EFI_STATUS EFIAPI DebugPortSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Checks to see if there's not already a DebugPort interface somewhere.

If there's a DEBUGPORT variable, the device path must match exactly. If there's no DEBUGPORT variable, then device path is not checked and does not matter. Checks to see that there's a serial io interface on the controller handle that can be bound BY_DRIVER | EXCLUSIVE. If all these tests succeed, then we return EFI_SUCCESS, else, EFI_UNSUPPORTED or other error returned by OpenProtocol.

Parameters
ThisProtocol instance pointer.
ControllerHandleHandle of device to test.
RemainingDevicePathOptional parameter use to pick a specific child device to start.
Return values
EFI_SUCCESSThis driver supports this device.
EFI_UNSUPPORTEDDebug Port device is not supported.
EFI_OUT_OF_RESOURCESFails to allocate memory for device.
othersSome error occurs.

Definition at line 165 of file DebugPort.c.

◆ DebugPortWrite()

EFI_STATUS EFIAPI DebugPortWrite ( IN EFI_DEBUGPORT_PROTOCOL This,
IN UINT32  Timeout,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

DebugPort protocol member function. Calls SerialIo:Write() Writes 8 bytes at a time and does a GetControl between 8 byte writes to help insure reads are interspersed This is poor-man's flow control.

Parameters
ThisPointer to DebugPort protocol.
TimeoutTimeout value.
BufferSizeOn input, the size of Buffer. On output, the amount of data actually written.
BufferPointer to buffer to read.
Return values
EFI_SUCCESSThe data was written.
othersFails when writting datas to debug port device.

Definition at line 592 of file DebugPort.c.

◆ GetDebugPortVariable()

EFI_DEVICE_PATH_PROTOCOL * GetDebugPortVariable ( VOID  )

Local worker function to obtain device path information from DebugPort variable.

Records requested settings in DebugPort device structure.

Definition at line 54 of file DebugPort.c.

◆ ImageUnloadHandler()

EFI_STATUS EFIAPI ImageUnloadHandler ( EFI_HANDLE  ImageHandle)

Unload function that is registered in the LoadImage protocol. It un-installs protocols produced and deallocates pool used by the driver. Called by the core when unloading the driver.

Parameters
ImageHandle
Return values
EFI_SUCCESSUnload Debug Port driver successfully.
EFI_ABORTEDSerial IO is still binding.

Definition at line 683 of file DebugPort.c.

◆ InitializeDebugPortDriver()

EFI_STATUS EFIAPI InitializeDebugPortDriver ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Debug Port Driver entry point.

Reads DebugPort variable to determine what device and settings to use as the debug port. Binds exclusively to SerialIo. Reverts to defaults if no variable is found.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
EFI_OUT_OF_RESOURCESFails to allocate memory for device.
otherSome error occurs when executing this entry point.

Definition at line 119 of file DebugPort.c.

Variable Documentation

◆ gDebugPortDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gDebugPortDriverBinding
Initial value:
= {
DEBUGPORT_DRIVER_VERSION,
}
EFI_STATUS EFIAPI DebugPortStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: DebugPort.c:265
EFI_STATUS EFIAPI DebugPortStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: DebugPort.c:412
EFI_STATUS EFIAPI DebugPortSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: DebugPort.c:165
#define NULL
Definition: Base.h:319

Definition at line 17 of file DebugPort.c.

◆ mDebugPortDevice

DEBUGPORT_DEVICE mDebugPortDevice
Initial value:
= {
DEBUGPORT_DEVICE_SIGNATURE,
{
},
DEBUGPORT_UART_DEFAULT_BAUDRATE,
DEBUGPORT_UART_DEFAULT_FIFO_DEPTH,
(EFI_PARITY_TYPE)DEBUGPORT_UART_DEFAULT_PARITY,
DEBUGPORT_UART_DEFAULT_DATA_BITS,
(EFI_STOP_BITS_TYPE)DEBUGPORT_UART_DEFAULT_STOP_BITS
}
EFI_STATUS EFIAPI DebugPortReset(IN EFI_DEBUGPORT_PROTOCOL *This)
Definition: DebugPort.c:503
EFI_STATUS EFIAPI DebugPortPoll(IN EFI_DEBUGPORT_PROTOCOL *This)
Definition: DebugPort.c:644
EFI_STATUS EFIAPI DebugPortRead(IN EFI_DEBUGPORT_PROTOCOL *This, IN UINT32 Timeout, IN OUT UINTN *BufferSize, IN VOID *Buffer)
Definition: DebugPort.c:534
EFI_STATUS EFIAPI DebugPortWrite(IN EFI_DEBUGPORT_PROTOCOL *This, IN UINT32 Timeout, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
Definition: DebugPort.c:592
#define DEBUGPORT_UART_DEFAULT_TIMEOUT
5 ms
Definition: DebugPort.h:70
EFI_STOP_BITS_TYPE
Definition: SerialIo.h:53
EFI_PARITY_TYPE
Definition: SerialIo.h:41
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33

Definition at line 26 of file DebugPort.c.