]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmulatorPkg / Library / DxeEmuStdErrSerialPortLib / DxeEmuStdErrSerialPortLib.c
CommitLineData
7e284acb 1/** @file\r
d18d8a1d 2 Serial Port Lib that thunks back to Emulator services to write to StdErr.\r
3 All read functions are stubed out.\r
7e284acb 4\r
5 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
6 Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
e3ba31da 7 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7e284acb 8\r
9**/\r
10\r
7e284acb 11#include <PiDxe.h>\r
12#include <Library/SerialPortLib.h>\r
13#include <Library/EmuThunkLib.h>\r
14\r
7e284acb 15/**\r
16 Initialize the serial device hardware.\r
d18d8a1d 17\r
7e284acb 18 If no initialization is required, then return RETURN_SUCCESS.\r
19 If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
20 If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
d18d8a1d 21\r
7e284acb 22 @retval RETURN_SUCCESS The serial device was initialized.\r
23 @retval RETURN_DEVICE_ERROR The serial device could not be initialized.\r
24\r
25**/\r
26RETURN_STATUS\r
27EFIAPI\r
28SerialPortInitialize (\r
29 VOID\r
30 )\r
31{\r
32 return RETURN_SUCCESS;\r
33}\r
34\r
35/**\r
d18d8a1d 36 Write data from buffer to serial device.\r
37\r
38 Writes NumberOfBytes data bytes from Buffer to the serial device.\r
7e284acb 39 The number of bytes actually written to the serial device is returned.\r
40 If the return value is less than NumberOfBytes, then the write operation failed.\r
d18d8a1d 41 If Buffer is NULL, then ASSERT().\r
7e284acb 42 If NumberOfBytes is zero, then return 0.\r
43\r
44 @param Buffer The pointer to the data buffer to be written.\r
45 @param NumberOfBytes The number of bytes to written to the serial device.\r
46\r
47 @retval 0 NumberOfBytes is 0.\r
d18d8a1d 48 @retval >0 The number of bytes written to the serial device.\r
7e284acb 49 If this value is less than NumberOfBytes, then the read operation failed.\r
50\r
51**/\r
52UINTN\r
53EFIAPI\r
54SerialPortWrite (\r
a550d468
MK
55 IN UINT8 *Buffer,\r
56 IN UINTN NumberOfBytes\r
7e284acb 57 )\r
58{\r
9184d5da 59 if (gEmuThunk == NULL) {\r
60 return NumberOfBytes;\r
61 }\r
79e4f2a5 62\r
7e284acb 63 return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);\r
64}\r
65\r
7e284acb 66/**\r
67 Read data from serial device and save the datas in buffer.\r
d18d8a1d 68\r
7e284acb 69 Reads NumberOfBytes data bytes from a serial device into the buffer\r
d18d8a1d 70 specified by Buffer. The number of bytes actually read is returned.\r
7e284acb 71 If the return value is less than NumberOfBytes, then the rest operation failed.\r
d18d8a1d 72 If Buffer is NULL, then ASSERT().\r
7e284acb 73 If NumberOfBytes is zero, then return 0.\r
74\r
75 @param Buffer The pointer to the data buffer to store the data read from the serial device.\r
76 @param NumberOfBytes The number of bytes which will be read.\r
77\r
78 @retval 0 Read data failed; No data is to be read.\r
79 @retval >0 The actual number of bytes read from serial device.\r
80\r
81**/\r
82UINTN\r
83EFIAPI\r
84SerialPortRead (\r
a550d468
MK
85 OUT UINT8 *Buffer,\r
86 IN UINTN NumberOfBytes\r
7e284acb 87 )\r
88{\r
89 return 0;\r
90}\r
91\r
92/**\r
93 Polls a serial device to see if there is any data waiting to be read.\r
94\r
95 Polls a serial device to see if there is any data waiting to be read.\r
96 If there is data waiting to be read from the serial device, then TRUE is returned.\r
97 If there is no data waiting to be read from the serial device, then FALSE is returned.\r
98\r
99 @retval TRUE Data is waiting to be read from the serial device.\r
100 @retval FALSE There is no data waiting to be read from the serial device.\r
101\r
102**/\r
103BOOLEAN\r
104EFIAPI\r
105SerialPortPoll (\r
106 VOID\r
107 )\r
108{\r
109 return FALSE;\r
110}\r