]>
git.proxmox.com Git - mirror_edk2.git/blob - InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
aa4e80cf01baf892aee9093b2b5aaca67791adbb
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/PeiServicesLib.h>
23 #include <Ppi/EmuThunk.h>
24 #include <Protocol/EmuThunk.h>
29 Initialize the serial device hardware.
31 If no initialization is required, then return RETURN_SUCCESS.
32 If the serial device was successfully initialized, then return RETURN_SUCCESS.
33 If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
35 @retval RETURN_SUCCESS The serial device was initialized.
36 @retval RETURN_DEVICE_ERROR The serial device could not be initialized.
41 SerialPortInitialize (
45 return RETURN_SUCCESS
;
49 Write data from buffer to serial device.
51 Writes NumberOfBytes data bytes from Buffer to the serial device.
52 The number of bytes actually written to the serial device is returned.
53 If the return value is less than NumberOfBytes, then the write operation failed.
54 If Buffer is NULL, then ASSERT().
55 If NumberOfBytes is zero, then return 0.
57 @param Buffer The pointer to the data buffer to be written.
58 @param NumberOfBytes The number of bytes to written to the serial device.
60 @retval 0 NumberOfBytes is 0.
61 @retval >0 The number of bytes written to the serial device.
62 If this value is less than NumberOfBytes, then the read operation failed.
69 IN UINTN NumberOfBytes
72 EMU_THUNK_PPI
*ThunkPpi
;
74 EMU_THUNK_PROTOCOL
*Thunk
;
77 // Locate EmuThunkPpi for retrieving standard output handle
79 Status
= PeiServicesLocatePpi (
85 if (!EFI_ERROR (Status
)) {
86 Thunk
= (EMU_THUNK_PROTOCOL
*)ThunkPpi
->Thunk ();
87 return Thunk
->WriteStdErr (Buffer
, NumberOfBytes
);
95 Read data from serial device and save the datas in buffer.
97 Reads NumberOfBytes data bytes from a serial device into the buffer
98 specified by Buffer. The number of bytes actually read is returned.
99 If the return value is less than NumberOfBytes, then the rest operation failed.
100 If Buffer is NULL, then ASSERT().
101 If NumberOfBytes is zero, then return 0.
103 @param Buffer The pointer to the data buffer to store the data read from the serial device.
104 @param NumberOfBytes The number of bytes which will be read.
106 @retval 0 Read data failed; No data is to be read.
107 @retval >0 The actual number of bytes read from serial device.
114 IN UINTN NumberOfBytes
121 Polls a serial device to see if there is any data waiting to be read.
123 Polls a serial device to see if there is any data waiting to be read.
124 If there is data waiting to be read from the serial device, then TRUE is returned.
125 If there is no data waiting to be read from the serial device, then FALSE is returned.
127 @retval TRUE Data is waiting to be read from the serial device.
128 @retval FALSE There is no data waiting to be read from the serial device.