]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
EmulatorPkg: Replace BSD License with BSD+Patent License
[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
11\r
12#include <PiDxe.h>\r
13#include <Library/SerialPortLib.h>\r
14#include <Library/EmuThunkLib.h>\r
15\r
16\r
17\r
18\r
19/**\r
20 Initialize the serial device hardware.\r
d18d8a1d 21\r
7e284acb 22 If no initialization is required, then return RETURN_SUCCESS.\r
23 If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
24 If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
d18d8a1d 25\r
7e284acb 26 @retval RETURN_SUCCESS The serial device was initialized.\r
27 @retval RETURN_DEVICE_ERROR The serial device could not be initialized.\r
28\r
29**/\r
30RETURN_STATUS\r
31EFIAPI\r
32SerialPortInitialize (\r
33 VOID\r
34 )\r
35{\r
36 return RETURN_SUCCESS;\r
37}\r
38\r
39/**\r
d18d8a1d 40 Write data from buffer to serial device.\r
41\r
42 Writes NumberOfBytes data bytes from Buffer to the serial device.\r
7e284acb 43 The number of bytes actually written to the serial device is returned.\r
44 If the return value is less than NumberOfBytes, then the write operation failed.\r
d18d8a1d 45 If Buffer is NULL, then ASSERT().\r
7e284acb 46 If NumberOfBytes is zero, then return 0.\r
47\r
48 @param Buffer The pointer to the data buffer to be written.\r
49 @param NumberOfBytes The number of bytes to written to the serial device.\r
50\r
51 @retval 0 NumberOfBytes is 0.\r
d18d8a1d 52 @retval >0 The number of bytes written to the serial device.\r
7e284acb 53 If this value is less than NumberOfBytes, then the read operation failed.\r
54\r
55**/\r
56UINTN\r
57EFIAPI\r
58SerialPortWrite (\r
59 IN UINT8 *Buffer,\r
60 IN UINTN NumberOfBytes\r
61 )\r
62{\r
9184d5da 63 if (gEmuThunk == NULL) {\r
64 return NumberOfBytes;\r
65 }\r
79e4f2a5 66\r
7e284acb 67 return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);\r
68}\r
69\r
70\r
71/**\r
72 Read data from serial device and save the datas in buffer.\r
d18d8a1d 73\r
7e284acb 74 Reads NumberOfBytes data bytes from a serial device into the buffer\r
d18d8a1d 75 specified by Buffer. The number of bytes actually read is returned.\r
7e284acb 76 If the return value is less than NumberOfBytes, then the rest operation failed.\r
d18d8a1d 77 If Buffer is NULL, then ASSERT().\r
7e284acb 78 If NumberOfBytes is zero, then return 0.\r
79\r
80 @param Buffer The pointer to the data buffer to store the data read from the serial device.\r
81 @param NumberOfBytes The number of bytes which will be read.\r
82\r
83 @retval 0 Read data failed; No data is to be read.\r
84 @retval >0 The actual number of bytes read from serial device.\r
85\r
86**/\r
87UINTN\r
88EFIAPI\r
89SerialPortRead (\r
90 OUT UINT8 *Buffer,\r
91 IN UINTN NumberOfBytes\r
92 )\r
93{\r
94 return 0;\r
95}\r
96\r
97/**\r
98 Polls a serial device to see if there is any data waiting to be read.\r
99\r
100 Polls a serial device to see if there is any data waiting to be read.\r
101 If there is data waiting to be read from the serial device, then TRUE is returned.\r
102 If there is no data waiting to be read from the serial device, then FALSE is returned.\r
103\r
104 @retval TRUE Data is waiting to be read from the serial device.\r
105 @retval FALSE There is no data waiting to be read from the serial device.\r
106\r
107**/\r
108BOOLEAN\r
109EFIAPI\r
110SerialPortPoll (\r
111 VOID\r
112 )\r
113{\r
114 return FALSE;\r
115}\r
116\r
117\r