]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/SerialPortLib.h
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Include / Library / SerialPortLib.h
1 /** @file
2 This library class provides common serial I/O port functions.
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2012 - 2014, ARM Ltd. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef __SERIAL_PORT_LIB__
11 #define __SERIAL_PORT_LIB__
12
13 #include <Uefi/UefiBaseType.h>
14 #include <Protocol/SerialIo.h>
15
16 /**
17 Initialize the serial device hardware.
18
19 If no initialization is required, then return RETURN_SUCCESS.
20 If the serial device was successfully initialized, then return RETURN_SUCCESS.
21 If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
22
23 @retval RETURN_SUCCESS The serial device was initialized.
24 @retval RETURN_DEVICE_ERROR The serial device could not be initialized.
25
26 **/
27 RETURN_STATUS
28 EFIAPI
29 SerialPortInitialize (
30 VOID
31 );
32
33 /**
34 Write data from buffer to serial device.
35
36 Writes NumberOfBytes data bytes from Buffer to the serial device.
37 The number of bytes actually written to the serial device is returned.
38 If the return value is less than NumberOfBytes, then the write operation failed.
39 If Buffer is NULL, then ASSERT().
40 If NumberOfBytes is zero, then return 0.
41
42 @param Buffer Pointer to the data buffer to be written.
43 @param NumberOfBytes Number of bytes to written to the serial device.
44
45 @retval 0 NumberOfBytes is 0.
46 @retval >0 The number of bytes written to the serial device.
47 If this value is less than NumberOfBytes, then the write operation failed.
48
49 **/
50 UINTN
51 EFIAPI
52 SerialPortWrite (
53 IN UINT8 *Buffer,
54 IN UINTN NumberOfBytes
55 );
56
57 /**
58 Read data from serial device and save the datas in buffer.
59
60 Reads NumberOfBytes data bytes from a serial device into the buffer
61 specified by Buffer. The number of bytes actually read is returned.
62 If the return value is less than NumberOfBytes, then the rest operation failed.
63 If Buffer is NULL, then ASSERT().
64 If NumberOfBytes is zero, then return 0.
65
66 @param Buffer Pointer to the data buffer to store the data read from the serial device.
67 @param NumberOfBytes Number of bytes which will be read.
68
69 @retval 0 Read data failed, no data is to be read.
70 @retval >0 Actual number of bytes read from serial device.
71
72 **/
73 UINTN
74 EFIAPI
75 SerialPortRead (
76 OUT UINT8 *Buffer,
77 IN UINTN NumberOfBytes
78 );
79
80 /**
81 Polls a serial device to see if there is any data waiting to be read.
82
83 Polls a serial device to see if there is any data waiting to be read.
84 If there is data waiting to be read from the serial device, then TRUE is returned.
85 If there is no data waiting to be read from the serial device, then FALSE is returned.
86
87 @retval TRUE Data is waiting to be read from the serial device.
88 @retval FALSE There is no data waiting to be read from the serial device.
89
90 **/
91 BOOLEAN
92 EFIAPI
93 SerialPortPoll (
94 VOID
95 );
96
97 /**
98 Sets the control bits on a serial device.
99
100 @param Control Sets the bits of Control that are settable.
101
102 @retval RETURN_SUCCESS The new control bits were set on the serial device.
103 @retval RETURN_UNSUPPORTED The serial device does not support this operation.
104 @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
105
106 **/
107 RETURN_STATUS
108 EFIAPI
109 SerialPortSetControl (
110 IN UINT32 Control
111 );
112
113 /**
114 Retrieve the status of the control bits on a serial device.
115
116 @param Control A pointer to return the current control signals from the serial device.
117
118 @retval RETURN_SUCCESS The control bits were read from the serial device.
119 @retval RETURN_UNSUPPORTED The serial device does not support this operation.
120 @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
121
122 **/
123 RETURN_STATUS
124 EFIAPI
125 SerialPortGetControl (
126 OUT UINT32 *Control
127 );
128
129 /**
130 Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
131 data bits, and stop bits on a serial device.
132
133 @param BaudRate The requested baud rate. A BaudRate value of 0 will use the
134 device's default interface speed.
135 On output, the value actually set.
136 @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the
137 serial interface. A ReceiveFifoDepth value of 0 will use
138 the device's default FIFO depth.
139 On output, the value actually set.
140 @param Timeout The requested time out for a single character in microseconds.
141 This timeout applies to both the transmit and receive side of the
142 interface. A Timeout value of 0 will use the device's default time
143 out value.
144 On output, the value actually set.
145 @param Parity The type of parity to use on this serial device. A Parity value of
146 DefaultParity will use the device's default parity value.
147 On output, the value actually set.
148 @param DataBits The number of data bits to use on the serial device. A DataBits
149 vaule of 0 will use the device's default data bit setting.
150 On output, the value actually set.
151 @param StopBits The number of stop bits to use on this serial device. A StopBits
152 value of DefaultStopBits will use the device's default number of
153 stop bits.
154 On output, the value actually set.
155
156 @retval RETURN_SUCCESS The new attributes were set on the serial device.
157 @retval RETURN_UNSUPPORTED The serial device does not support this operation.
158 @retval RETURN_INVALID_PARAMETER One or more of the attributes has an unsupported value.
159 @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
160
161 **/
162 RETURN_STATUS
163 EFIAPI
164 SerialPortSetAttributes (
165 IN OUT UINT64 *BaudRate,
166 IN OUT UINT32 *ReceiveFifoDepth,
167 IN OUT UINT32 *Timeout,
168 IN OUT EFI_PARITY_TYPE *Parity,
169 IN OUT UINT8 *DataBits,
170 IN OUT EFI_STOP_BITS_TYPE *StopBits
171 );
172
173 #endif