2007-06-19 12:12:02 +02:00
|
|
|
/** @file
|
2007-11-22 07:00:39 +01:00
|
|
|
Serial IO protocol as defined in the UEFI 2.0 specification.
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
Abstraction of a basic serial device. Targeted at 16550 UART, but
|
|
|
|
could be much more generic.
|
|
|
|
|
2008-07-25 12:37:15 +02:00
|
|
|
Copyright (c) 2006 - 2008, Intel Corporation
|
2007-06-19 12:12:02 +02:00
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef __SERIAL_IO_PROTOCOL_H__
|
|
|
|
#define __SERIAL_IO_PROTOCOL_H__
|
|
|
|
|
|
|
|
#define EFI_SERIAL_IO_PROTOCOL_GUID \
|
|
|
|
{ \
|
|
|
|
0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD } \
|
|
|
|
}
|
|
|
|
|
2008-08-14 06:29:48 +02:00
|
|
|
///
|
|
|
|
/// Protocol GUID defined in EFI1.1.
|
|
|
|
///
|
2007-06-21 09:16:27 +02:00
|
|
|
#define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID
|
|
|
|
|
2007-06-19 12:12:02 +02:00
|
|
|
typedef struct _EFI_SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL;
|
|
|
|
|
2007-06-21 09:16:27 +02:00
|
|
|
|
2008-08-14 06:29:48 +02:00
|
|
|
///
|
|
|
|
/// Backward-compatible with EFI1.1.
|
|
|
|
///
|
2007-06-21 09:16:27 +02:00
|
|
|
typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE;
|
|
|
|
|
2008-08-14 06:29:48 +02:00
|
|
|
///
|
2008-12-08 15:48:27 +01:00
|
|
|
/// Parity type that is computed or checked as each character is transmitted or received. If the
|
|
|
|
/// device does not support parity, the value is the default parity value.
|
2008-08-14 06:29:48 +02:00
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
typedef enum {
|
|
|
|
DefaultParity,
|
|
|
|
NoParity,
|
|
|
|
EvenParity,
|
|
|
|
OddParity,
|
|
|
|
MarkParity,
|
|
|
|
SpaceParity
|
|
|
|
} EFI_PARITY_TYPE;
|
|
|
|
|
2008-12-08 15:48:27 +01:00
|
|
|
///
|
|
|
|
/// Stop bits type
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
typedef enum {
|
|
|
|
DefaultStopBits,
|
|
|
|
OneStopBit,
|
|
|
|
OneFiveStopBits,
|
|
|
|
TwoStopBits
|
|
|
|
} EFI_STOP_BITS_TYPE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// define for Control bits, grouped by read only, write only, and read write
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Read Only
|
|
|
|
//
|
|
|
|
#define EFI_SERIAL_CLEAR_TO_SEND 0x00000010
|
|
|
|
#define EFI_SERIAL_DATA_SET_READY 0x00000020
|
|
|
|
#define EFI_SERIAL_RING_INDICATE 0x00000040
|
|
|
|
#define EFI_SERIAL_CARRIER_DETECT 0x00000080
|
|
|
|
#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x00000100
|
|
|
|
#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x00000200
|
|
|
|
|
|
|
|
//
|
|
|
|
// Write Only
|
|
|
|
//
|
|
|
|
#define EFI_SERIAL_REQUEST_TO_SEND 0x00000002
|
|
|
|
#define EFI_SERIAL_DATA_TERMINAL_READY 0x00000001
|
|
|
|
|
|
|
|
//
|
|
|
|
// Read Write
|
|
|
|
//
|
|
|
|
#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x00001000
|
|
|
|
#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x00002000
|
|
|
|
#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x00004000
|
|
|
|
|
|
|
|
//
|
|
|
|
// Serial IO Member Functions
|
|
|
|
//
|
|
|
|
/**
|
|
|
|
Reset the serial device.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The device was reset.
|
|
|
|
@retval EFI_DEVICE_ERROR The serial device could not be reset.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_SERIAL_RESET)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_SERIAL_IO_PROTOCOL *This
|
2008-09-04 11:37:28 +02:00
|
|
|
);
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
/**
|
2009-06-04 07:49:29 +02:00
|
|
|
Sets the following attributes for a serial device:
|
|
|
|
* baud rate
|
|
|
|
* receive FIFO depth
|
|
|
|
* transmit/receive time out
|
|
|
|
* parity
|
|
|
|
* data bits
|
|
|
|
* stop bits
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
2009-06-04 07:49:29 +02:00
|
|
|
@param BaudRate The requested baud rate. A BaudRate value of 0 will use the
|
2007-06-19 12:12:02 +02:00
|
|
|
device's default interface speed.
|
|
|
|
@param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the
|
|
|
|
serial interface. A ReceiveFifoDepth value of 0 will use
|
2009-06-04 07:49:29 +02:00
|
|
|
the device's default FIFO depth.
|
2007-06-19 12:12:02 +02:00
|
|
|
@param Timeout The 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.
|
|
|
|
@param Parity The type of parity to use on this serial device. A Parity value of
|
|
|
|
DefaultParity will use the device's default parity value.
|
|
|
|
@param DataBits The number of data bits to use on the serial device. A DataBits
|
|
|
|
vaule of 0 will use the device's default data bit setting.
|
|
|
|
@param StopBits The 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.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The device was reset.
|
|
|
|
@retval EFI_DEVICE_ERROR The serial device could not be reset.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_SERIAL_SET_ATTRIBUTES)(
|
2007-06-19 12:12:02 +02:00
|
|
|
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
|
2008-09-04 11:37:28 +02:00
|
|
|
);
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the control bits on a serial device
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param Control Set the bits of Control that are settable.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The new control bits were set on the serial device.
|
|
|
|
@retval EFI_UNSUPPORTED The serial device does not support this operation.
|
|
|
|
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_SERIAL_SET_CONTROL_BITS)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_SERIAL_IO_PROTOCOL *This,
|
|
|
|
IN UINT32 Control
|
2008-09-04 11:37:28 +02:00
|
|
|
);
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Retrieves the status of thecontrol bits on a serial device
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param Control A pointer to return the current Control signals from the serial device.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The control bits were read from the serial device.
|
|
|
|
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_SERIAL_GET_CONTROL_BITS)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_SERIAL_IO_PROTOCOL *This,
|
|
|
|
OUT UINT32 *Control
|
2008-09-04 11:37:28 +02:00
|
|
|
);
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Writes data to a serial device.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param BufferSize On input, the size of the Buffer. On output, the amount of
|
|
|
|
data actually written.
|
|
|
|
@param Buffer The buffer of data to write
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The data was written.
|
|
|
|
@retval EFI_DEVICE_ERROR The device reported an error.
|
|
|
|
@retval EFI_TIMEOUT The data write was stopped due to a timeout.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_SERIAL_WRITE)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_SERIAL_IO_PROTOCOL *This,
|
|
|
|
IN OUT UINTN *BufferSize,
|
|
|
|
IN VOID *Buffer
|
2008-09-04 11:37:28 +02:00
|
|
|
);
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Writes data to a serial device.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param BufferSize On input, the size of the Buffer. On output, the amount of
|
|
|
|
data returned in Buffer.
|
2009-06-04 07:49:29 +02:00
|
|
|
@param Buffer The buffer to which to return the data.
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS The data was read.
|
|
|
|
@retval EFI_DEVICE_ERROR The device reported an error.
|
|
|
|
@retval EFI_TIMEOUT The data write was stopped due to a timeout.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_SERIAL_READ)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_SERIAL_IO_PROTOCOL *This,
|
|
|
|
IN OUT UINTN *BufferSize,
|
|
|
|
OUT VOID *Buffer
|
2008-09-04 11:37:28 +02:00
|
|
|
);
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
/**
|
2008-07-25 12:37:15 +02:00
|
|
|
@par Data Structure Description:
|
2007-06-19 12:12:02 +02:00
|
|
|
The data values in SERIAL_IO_MODE are read-only and are updated by the code
|
|
|
|
that produces the SERIAL_IO_PROTOCOL member functions.
|
|
|
|
|
2008-07-25 12:37:15 +02:00
|
|
|
@param ControlMask
|
2009-06-04 07:49:29 +02:00
|
|
|
A mask for the Control bits that the device supports. The device
|
2007-06-19 12:12:02 +02:00
|
|
|
must always support the Input Buffer Empty control bit.
|
2008-07-25 12:37:15 +02:00
|
|
|
|
|
|
|
@param TimeOut
|
|
|
|
If applicable, the number of microseconds to wait before timing out
|
2007-06-19 12:12:02 +02:00
|
|
|
a Read or Write operation.
|
2008-07-25 12:37:15 +02:00
|
|
|
|
|
|
|
@param BaudRate
|
|
|
|
If applicable, the current baud rate setting of the device; otherwise,
|
2007-06-19 12:12:02 +02:00
|
|
|
baud rate has the value of zero to indicate that device runs at the
|
|
|
|
device's designed speed.
|
2008-07-25 12:37:15 +02:00
|
|
|
|
|
|
|
@param ReceiveFifoDepth
|
|
|
|
The number of characters the device will buffer on input
|
|
|
|
|
|
|
|
@param DataBits
|
|
|
|
The number of characters the device will buffer on input
|
|
|
|
|
|
|
|
@param Parity
|
|
|
|
If applicable, this is the EFI_PARITY_TYPE that is computed or
|
2007-06-19 12:12:02 +02:00
|
|
|
checked as each character is transmitted or reveived. If the device
|
|
|
|
does not support parity the value is the default parity value.
|
2008-07-25 12:37:15 +02:00
|
|
|
|
|
|
|
@param StopBits
|
|
|
|
If applicable, the EFI_STOP_BITS_TYPE number of stop bits per
|
2007-06-19 12:12:02 +02:00
|
|
|
character. If the device does not support stop bits the value is
|
|
|
|
the default stop bit values.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef struct {
|
|
|
|
UINT32 ControlMask;
|
|
|
|
|
|
|
|
//
|
|
|
|
// current Attributes
|
|
|
|
//
|
|
|
|
UINT32 Timeout;
|
|
|
|
UINT64 BaudRate;
|
|
|
|
UINT32 ReceiveFifoDepth;
|
|
|
|
UINT32 DataBits;
|
|
|
|
UINT32 Parity;
|
|
|
|
UINT32 StopBits;
|
|
|
|
} EFI_SERIAL_IO_MODE;
|
|
|
|
|
2007-06-21 09:16:27 +02:00
|
|
|
#define EFI_SERIAL_IO_PROTOCOL_REVISION 0x00010000
|
|
|
|
#define SERIAL_IO_INTERFACE_REVISION EFI_SERIAL_IO_PROTOCOL_REVISION
|
2007-06-19 12:12:02 +02:00
|
|
|
|
2008-10-13 04:54:29 +02:00
|
|
|
///
|
|
|
|
/// The Serial I/O protocol is used to communicate with UART-style serial devices.
|
2009-06-04 07:49:29 +02:00
|
|
|
/// These can be standard UART serial ports in PC-AT systems, or serial ports attached
|
|
|
|
/// to a USB interface or any character-based I/O device.
|
2008-10-13 04:54:29 +02:00
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
struct _EFI_SERIAL_IO_PROTOCOL {
|
2008-10-09 21:17:35 +02:00
|
|
|
///
|
|
|
|
/// The revision to which the EFI_SERIAL_IO_PROTOCOL adheres. All future revisions
|
2009-06-04 07:49:29 +02:00
|
|
|
/// must be backwards compatible. If a future version is not backwards compatible,
|
2008-10-09 21:17:35 +02:00
|
|
|
/// it is not the same GUID.
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
UINT32 Revision;
|
|
|
|
EFI_SERIAL_RESET Reset;
|
|
|
|
EFI_SERIAL_SET_ATTRIBUTES SetAttributes;
|
|
|
|
EFI_SERIAL_SET_CONTROL_BITS SetControl;
|
|
|
|
EFI_SERIAL_GET_CONTROL_BITS GetControl;
|
|
|
|
EFI_SERIAL_WRITE Write;
|
|
|
|
EFI_SERIAL_READ Read;
|
2008-10-13 04:54:29 +02:00
|
|
|
///
|
|
|
|
/// Pointer to SERIAL_IO_MODE data.
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
EFI_SERIAL_IO_MODE *Mode;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern EFI_GUID gEfiSerialIoProtocolGuid;
|
|
|
|
|
|
|
|
#endif
|