TianoCore EDK2 master
Loading...
Searching...
No Matches
SerialIo.c File Reference
#include <GdbStubInternal.h>

Go to the source code of this file.

Functions

VOID GdbCtrlCBreakMessage (IN UINTN ErrNo)
 
INTN GdbParseFReplyPacket (IN CHAR8 *Packet, OUT UINTN *ErrNo)
 
INTN GdbRead (IN INTN FileDescriptor, OUT VOID *Buffer, IN UINTN Count)
 
INTN GdbWrite (IN INTN FileDescriptor, OUT CONST VOID *Buffer, IN UINTN Count)
 
EFI_STATUS EFIAPI GdbSerialReset (IN EFI_SERIAL_IO_PROTOCOL *This)
 
EFI_STATUS EFIAPI GdbSerialSetAttributes (IN EFI_SERIAL_IO_PROTOCOL *This, IN UINT64 BaudRate, IN UINT32 ReceiveFifoDepth, IN UINT32 Timeout, IN EFI_PARITY_TYPE Parity, IN UINT8 DataBits, IN EFI_STOP_BITS_TYPE StopBits)
 
EFI_STATUS EFIAPI GdbSerialSetControl (IN EFI_SERIAL_IO_PROTOCOL *This, IN UINT32 Control)
 
EFI_STATUS EFIAPI GdbSerialGetControl (IN EFI_SERIAL_IO_PROTOCOL *This, OUT UINT32 *Control)
 
EFI_STATUS EFIAPI GdbSerialWrite (IN EFI_SERIAL_IO_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI GdbSerialRead (IN EFI_SERIAL_IO_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
VOID GdbInitializeSerialConsole (VOID)
 

Variables

BOOLEAN gCtrlCBreakFlag = FALSE
 
BOOLEAN gProcessingFPacket = FALSE
 
GDB_SERIAL_DEV gdbSerialDevTemplate
 

Detailed Description

Serial IO Abstraction for GDB stub. This allows an EFI consoles that shows up on the system running GDB. One console for error information and another console for user input/output.

Basic packet format is $packet-data::checksum. So every command has 4 bytes of overhead: $, #, 0, 0. The 0 and 0 are the ascii characters for the checksum.

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

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

Definition in file SerialIo.c.

Function Documentation

◆ GdbCtrlCBreakMessage()

VOID GdbCtrlCBreakMessage ( IN UINTN  ErrNo)

Process a control-C break message.

Currently a place holder, remove the ASSERT when it gets implemented.

Parameters
ErrNoError information from the F reply packet or other source

Definition at line 39 of file SerialIo.c.

◆ GdbInitializeSerialConsole()

VOID GdbInitializeSerialConsole ( VOID  )

Make two serial consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.

These console show up on the remote system running GDB

Definition at line 498 of file SerialIo.c.

◆ GdbParseFReplyPacket()

INTN GdbParseFReplyPacket ( IN CHAR8 *  Packet,
OUT UINTN ErrNo 
)

Parse the F reply packet and extract the return value and an ErrNo if it exists.

Parameters
PacketPacket to parse like an F reply packet
ErrNoBuffer to hold Count bytes that were read
Return values
-1Error, not a valid F reply packet
otherReturn the return code from the F reply packet

Definition at line 62 of file SerialIo.c.

◆ GdbRead()

INTN GdbRead ( IN INTN  FileDescriptor,
OUT VOID *  Buffer,
IN UINTN  Count 
)

Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.

Parameters
FileDescriptorDevice to talk to.
BufferBuffer to hold Count bytes that were read
CountNumber of bytes to transfer.
Return values
-1Error
{other}Number of bytes read.

Definition at line 115 of file SerialIo.c.

◆ GdbSerialGetControl()

EFI_STATUS EFIAPI GdbSerialGetControl ( IN EFI_SERIAL_IO_PROTOCOL This,
OUT UINT32 *  Control 
)

Retrieves the status of the control bits on a serial device

Parameters
ThisProtocol instance pointer.
ControlA pointer to return the current Control signals from the serial device.
Return values
EFI_SUCCESSThe control bits were read from the serial device.
EFI_DEVICE_ERRORThe serial device is not functioning correctly.

Definition at line 355 of file SerialIo.c.

◆ GdbSerialRead()

EFI_STATUS EFIAPI GdbSerialRead ( IN EFI_SERIAL_IO_PROTOCOL This,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

Writes data to a serial device.

Parameters
ThisProtocol instance pointer.
BufferSizeOn input, the size of the Buffer. On output, the amount of data returned in Buffer.
BufferThe buffer to return the data into.
Return values
EFI_SUCCESSThe data was read.
EFI_DEVICE_ERRORThe device reported an error.
EFI_TIMEOUTThe data write was stopped due to a timeout.

Definition at line 416 of file SerialIo.c.

◆ GdbSerialReset()

EFI_STATUS EFIAPI GdbSerialReset ( IN EFI_SERIAL_IO_PROTOCOL This)

Reset the serial device.

Parameters
ThisProtocol instance pointer.
Return values
EFI_SUCCESSThe device was reset.
EFI_DEVICE_ERRORThe serial device could not be reset.

Definition at line 274 of file SerialIo.c.

◆ GdbSerialSetAttributes()

EFI_STATUS EFIAPI GdbSerialSetAttributes ( IN EFI_SERIAL_IO_PROTOCOL This,
IN UINT64  BaudRate,
IN UINT32  ReceiveFifoDepth,
IN UINT32  Timeout,
IN EFI_PARITY_TYPE  Parity,
IN UINT8  DataBits,
IN EFI_STOP_BITS_TYPE  StopBits 
)

Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, data buts, and stop bits on a serial device.

Parameters
ThisProtocol instance pointer.
BaudRateThe requested baud rate. A BaudRate value of 0 will use the device's default interface speed.
ReceiveFifoDepthThe requested depth of the FIFO on the receive side of the serial interface. A ReceiveFifoDepth value of 0 will use the device's default FIFO depth.
TimeoutThe requested time out for a single character in microseconds. This timeout applies to both the transmit and receive side of the interface. A Timeout value of 0 will use the device's default time out value.
ParityThe type of parity to use on this serial device. A Parity value of DefaultParity will use the device's default parity value.
DataBitsThe number of data bits to use on the serial device. A DataBits value of 0 will use the device's default data bit setting.
StopBitsThe number of stop bits to use on this serial device. A StopBits value of DefaultStopBits will use the device's default number of stop bits.
Return values
EFI_SUCCESSThe device was reset.
EFI_DEVICE_ERRORThe serial device could not be reset.

Definition at line 309 of file SerialIo.c.

◆ GdbSerialSetControl()

EFI_STATUS EFIAPI GdbSerialSetControl ( IN EFI_SERIAL_IO_PROTOCOL This,
IN UINT32  Control 
)

Set the control bits on a serial device

Parameters
ThisProtocol instance pointer.
ControlSet the bits of Control that are settable.
Return values
EFI_SUCCESSThe new control bits were set on the serial device.
EFI_UNSUPPORTEDThe serial device does not support this operation.
EFI_DEVICE_ERRORThe serial device is not functioning correctly.

Definition at line 335 of file SerialIo.c.

◆ GdbSerialWrite()

EFI_STATUS EFIAPI GdbSerialWrite ( IN EFI_SERIAL_IO_PROTOCOL This,
IN OUT UINTN BufferSize,
IN VOID *  Buffer 
)

Writes data to a serial device.

Parameters
ThisProtocol instance pointer.
BufferSizeOn input, the size of the Buffer. On output, the amount of data actually written.
BufferThe buffer of data to write
Return values
EFI_SUCCESSThe data was written.
EFI_DEVICE_ERRORThe device reported an error.
EFI_TIMEOUTThe data write was stopped due to a timeout.

Definition at line 378 of file SerialIo.c.

◆ GdbWrite()

INTN GdbWrite ( IN INTN  FileDescriptor,
OUT CONST VOID *  Buffer,
IN UINTN  Count 
)

Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates nothing was written. On error -1 is returned.

Parameters
FileDescriptorDevice to talk to.
BufferBuffer to hold Count bytes that are to be written
CountNumber of bytes to transfer.
Return values
-1Error
{other}Number of bytes written.

Definition at line 197 of file SerialIo.c.

Variable Documentation

◆ gCtrlCBreakFlag

BOOLEAN gCtrlCBreakFlag = FALSE

Definition at line 21 of file SerialIo.c.

◆ gdbSerialDevTemplate

GDB_SERIAL_DEV gdbSerialDevTemplate

Definition at line 442 of file SerialIo.c.

◆ gProcessingFPacket

BOOLEAN gProcessingFPacket = FALSE

Definition at line 28 of file SerialIo.c.