2 Serial Port Lib that thunks back to Emulator services to write to StdErr.
3 All read functions are stubed out.
5 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Library/SerialPortLib.h>
20 #include <Library/EmuThunkLib.h>
26 Initialize the serial device hardware.
28 If no initialization is required, then return RETURN_SUCCESS.
29 If the serial device was successfully initialized, then return RETURN_SUCCESS.
30 If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
32 @retval RETURN_SUCCESS The serial device was initialized.
33 @retval RETURN_DEVICE_ERROR The serial device could not be initialized.
38 SerialPortInitialize (
42 return gEmuThunk
->ConfigStdIn ();
46 Write data from buffer to serial device.
48 Writes NumberOfBytes data bytes from Buffer to the serial device.
49 The number of bytes actually written to the serial device is returned.
50 If the return value is less than NumberOfBytes, then the write operation failed.
51 If Buffer is NULL, then ASSERT().
52 If NumberOfBytes is zero, then return 0.
54 @param Buffer The pointer to the data buffer to be written.
55 @param NumberOfBytes The number of bytes to written to the serial device.
57 @retval 0 NumberOfBytes is 0.
58 @retval >0 The number of bytes written to the serial device.
59 If this value is less than NumberOfBytes, then the read operation failed.
66 IN UINTN NumberOfBytes
69 return gEmuThunk
->WriteStdOut (Buffer
, NumberOfBytes
);
74 Read data from serial device and save the datas in buffer.
76 Reads NumberOfBytes data bytes from a serial device into the buffer
77 specified by Buffer. The number of bytes actually read is returned.
78 If the return value is less than NumberOfBytes, then the rest operation failed.
79 If Buffer is NULL, then ASSERT().
80 If NumberOfBytes is zero, then return 0.
82 @param Buffer The pointer to the data buffer to store the data read from the serial device.
83 @param NumberOfBytes The number of bytes which will be read.
85 @retval 0 Read data failed; No data is to be read.
86 @retval >0 The actual number of bytes read from serial device.
93 IN UINTN NumberOfBytes
96 return gEmuThunk
->ReadStdIn (Buffer
, NumberOfBytes
);
100 Polls a serial device to see if there is any data waiting to be read.
102 Polls a serial device to see if there is any data waiting to be read.
103 If there is data waiting to be read from the serial device, then TRUE is returned.
104 If there is no data waiting to be read from the serial device, then FALSE is returned.
106 @retval TRUE Data is waiting to be read from the serial device.
107 @retval FALSE There is no data waiting to be read from the serial device.
116 return gEmuThunk
->PollStdIn ();
120 Sets the control bits on a serial device.
122 @param Control Sets the bits of Control that are settable.
124 @retval RETURN_SUCCESS The new control bits were set on the serial device.
125 @retval RETURN_UNSUPPORTED The serial device does not support this operation.
126 @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
131 SerialPortSetControl (
135 return RETURN_UNSUPPORTED
;
139 Retrieve the status of the control bits on a serial device.
141 @param Control A pointer to return the current control signals from the serial device.
143 @retval RETURN_SUCCESS The control bits were read from the serial device.
144 @retval RETURN_UNSUPPORTED The serial device does not support this operation.
145 @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
150 SerialPortGetControl (
155 if (!SerialPortPoll ()) {
156 *Control
= EFI_SERIAL_INPUT_BUFFER_EMPTY
;
158 return RETURN_SUCCESS
;
162 Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
163 data bits, and stop bits on a serial device.
165 @param BaudRate The requested baud rate. A BaudRate value of 0 will use the
166 device's default interface speed.
167 On output, the value actually set.
168 @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the
169 serial interface. A ReceiveFifoDepth value of 0 will use
170 the device's default FIFO depth.
171 On output, the value actually set.
172 @param Timeout The requested time out for a single character in microseconds.
173 This timeout applies to both the transmit and receive side of the
174 interface. A Timeout value of 0 will use the device's default time
176 On output, the value actually set.
177 @param Parity The type of parity to use on this serial device. A Parity value of
178 DefaultParity will use the device's default parity value.
179 On output, the value actually set.
180 @param DataBits The number of data bits to use on the serial device. A DataBits
181 vaule of 0 will use the device's default data bit setting.
182 On output, the value actually set.
183 @param StopBits The number of stop bits to use on this serial device. A StopBits
184 value of DefaultStopBits will use the device's default number of
186 On output, the value actually set.
188 @retval RETURN_SUCCESS The new attributes were set on the serial device.
189 @retval RETURN_UNSUPPORTED The serial device does not support this operation.
190 @retval RETURN_INVALID_PARAMETER One or more of the attributes has an unsupported value.
191 @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
196 SerialPortSetAttributes (
197 IN OUT UINT64
*BaudRate
,
198 IN OUT UINT32
*ReceiveFifoDepth
,
199 IN OUT UINT32
*Timeout
,
200 IN OUT EFI_PARITY_TYPE
*Parity
,
201 IN OUT UINT8
*DataBits
,
202 IN OUT EFI_STOP_BITS_TYPE
*StopBits
205 return RETURN_UNSUPPORTED
;