2 Serial Port Lib that thunks back to Emulator services to write to StdErr.
3 All read functions are stubed out. There is no constructor so this lib can
4 be linked with PEI Core.
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
7 Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php.
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include <Library/SerialPortLib.h>
21 #include <Library/SerialPortExtLib.h>
22 #include <Library/PeiServicesLib.h>
24 #include <Ppi/EmuThunk.h>
25 #include <Protocol/EmuThunk.h>
30 Initialize the serial device hardware.
32 If no initialization is required, then return RETURN_SUCCESS.
33 If the serial device was successfully initialized, then return RETURN_SUCCESS.
34 If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
36 @retval RETURN_SUCCESS The serial device was initialized.
37 @retval RETURN_DEVICE_ERROR The serial device could not be initialized.
42 SerialPortInitialize (
46 return RETURN_SUCCESS
;
50 Write data from buffer to serial device.
52 Writes NumberOfBytes data bytes from Buffer to the serial device.
53 The number of bytes actually written to the serial device is returned.
54 If the return value is less than NumberOfBytes, then the write operation failed.
55 If Buffer is NULL, then ASSERT().
56 If NumberOfBytes is zero, then return 0.
58 @param Buffer The pointer to the data buffer to be written.
59 @param NumberOfBytes The number of bytes to written to the serial device.
61 @retval 0 NumberOfBytes is 0.
62 @retval >0 The number of bytes written to the serial device.
63 If this value is less than NumberOfBytes, then the read operation failed.
70 IN UINTN NumberOfBytes
73 EMU_THUNK_PPI
*ThunkPpi
;
75 EMU_THUNK_PROTOCOL
*Thunk
;
78 // Locate EmuThunkPpi for retrieving standard output handle
80 Status
= PeiServicesLocatePpi (
86 if (!EFI_ERROR (Status
)) {
87 Thunk
= (EMU_THUNK_PROTOCOL
*)ThunkPpi
->Thunk ();
88 return Thunk
->WriteStdErr (Buffer
, NumberOfBytes
);
96 Read data from serial device and save the datas in buffer.
98 Reads NumberOfBytes data bytes from a serial device into the buffer
99 specified by Buffer. The number of bytes actually read is returned.
100 If the return value is less than NumberOfBytes, then the rest operation failed.
101 If Buffer is NULL, then ASSERT().
102 If NumberOfBytes is zero, then return 0.
104 @param Buffer The pointer to the data buffer to store the data read from the serial device.
105 @param NumberOfBytes The number of bytes which will be read.
107 @retval 0 Read data failed; No data is to be read.
108 @retval >0 The actual number of bytes read from serial device.
115 IN UINTN NumberOfBytes
122 Polls a serial device to see if there is any data waiting to be read.
124 Polls a serial device to see if there is any data waiting to be read.
125 If there is data waiting to be read from the serial device, then TRUE is returned.
126 If there is no data waiting to be read from the serial device, then FALSE is returned.
128 @retval TRUE Data is waiting to be read from the serial device.
129 @retval FALSE There is no data waiting to be read from the serial device.
142 Set the serial device control bits.
144 @return Always return EFI_UNSUPPORTED.
149 SerialPortSetControl (
153 return RETURN_SUCCESS
;
157 Get the serial device control bits.
159 @param Control Control signals read from the serial device.
161 @retval EFI_SUCCESS The control bits were read from the serial device.
162 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
167 SerialPortGetControl (
171 return RETURN_SUCCESS
;
176 Set the serial device attributes.
178 @return Always return EFI_UNSUPPORTED.
183 SerialPortSetAttributes (
185 IN UINT32 ReceiveFifoDepth
,
187 IN EFI_PARITY_TYPE Parity
,
189 IN EFI_STOP_BITS_TYPE StopBits
192 return RETURN_SUCCESS
;