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