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