]> git.proxmox.com Git - mirror_edk2.git/blame - InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
Clarify the requirements for the Destination parameter of UnicodeStrToAsciiStr.
[mirror_edk2.git] / InOsEmuPkg / Library / PeiEmuSerialPortLib / PeiEmuSerialPortLib.c
CommitLineData
949f388f 1/** @file\r
2 Serial Port Lib that thunks back to Emulator services to write to StdErr. \r
3 All read functions are stubed out. There is no constructor so this lib can \r
4 be linked with PEI Core.\r
5\r
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
7 Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
8 This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php.\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18\r
19#include <PiPei.h>\r
20#include <Library/SerialPortLib.h>\r
21#include <Library/PeiServicesLib.h>\r
22\r
23#include <Ppi/EmuThunk.h>\r
24#include <Protocol/EmuThunk.h>\r
25\r
26\r
27\r
28/**\r
29 Initialize the serial device hardware.\r
30 \r
31 If no initialization is required, then return RETURN_SUCCESS.\r
32 If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
33 If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
34 \r
35 @retval RETURN_SUCCESS The serial device was initialized.\r
36 @retval RETURN_DEVICE_ERROR The serial device could not be initialized.\r
37\r
38**/\r
39RETURN_STATUS\r
40EFIAPI\r
41SerialPortInitialize (\r
42 VOID\r
43 )\r
44{\r
45 return RETURN_SUCCESS;\r
46}\r
47\r
48/**\r
49 Write data from buffer to serial device. \r
50 \r
51 Writes NumberOfBytes data bytes from Buffer to the serial device. \r
52 The number of bytes actually written to the serial device is returned.\r
53 If the return value is less than NumberOfBytes, then the write operation failed.\r
54 If Buffer is NULL, then ASSERT(). \r
55 If NumberOfBytes is zero, then return 0.\r
56\r
57 @param Buffer The pointer to the data buffer to be written.\r
58 @param NumberOfBytes The number of bytes to written to the serial device.\r
59\r
60 @retval 0 NumberOfBytes is 0.\r
61 @retval >0 The number of bytes written to the serial device. \r
62 If this value is less than NumberOfBytes, then the read operation failed.\r
63\r
64**/\r
65UINTN\r
66EFIAPI\r
67SerialPortWrite (\r
68 IN UINT8 *Buffer,\r
69 IN UINTN NumberOfBytes\r
70 )\r
71{\r
72 EMU_THUNK_PPI *ThunkPpi;\r
73 EFI_STATUS Status;\r
74 EMU_THUNK_PROTOCOL *Thunk;\r
75\r
76 //\r
77 // Locate EmuThunkPpi for retrieving standard output handle\r
78 //\r
79 Status = PeiServicesLocatePpi (\r
80 &gEmuThunkPpiGuid,\r
81 0,\r
82 NULL,\r
83 (VOID **) &ThunkPpi\r
84 );\r
85 if (!EFI_ERROR (Status)) {\r
86 Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
87 return Thunk->WriteStdErr (Buffer, NumberOfBytes);\r
88 }\r
89 \r
90 return 0;\r
91}\r
92\r
93\r
94/**\r
95 Read data from serial device and save the datas in buffer.\r
96 \r
97 Reads NumberOfBytes data bytes from a serial device into the buffer\r
98 specified by Buffer. The number of bytes actually read is returned. \r
99 If the return value is less than NumberOfBytes, then the rest operation failed.\r
100 If Buffer is NULL, then ASSERT(). \r
101 If NumberOfBytes is zero, then return 0.\r
102\r
103 @param Buffer The pointer to the data buffer to store the data read from the serial device.\r
104 @param NumberOfBytes The number of bytes which will be read.\r
105\r
106 @retval 0 Read data failed; No data is to be read.\r
107 @retval >0 The actual number of bytes read from serial device.\r
108\r
109**/\r
110UINTN\r
111EFIAPI\r
112SerialPortRead (\r
113 OUT UINT8 *Buffer,\r
114 IN UINTN NumberOfBytes\r
115 )\r
116{\r
117 return 0;\r
118}\r
119\r
120/**\r
121 Polls a serial device to see if there is any data waiting to be read.\r
122\r
123 Polls a serial device to see if there is any data waiting to be read.\r
124 If there is data waiting to be read from the serial device, then TRUE is returned.\r
125 If there is no data waiting to be read from the serial device, then FALSE is returned.\r
126\r
127 @retval TRUE Data is waiting to be read from the serial device.\r
128 @retval FALSE There is no data waiting to be read from the serial device.\r
129\r
130**/\r
131BOOLEAN\r
132EFIAPI\r
133SerialPortPoll (\r
134 VOID\r
135 )\r
136{\r
137 return FALSE;\r
138}\r
139\r
140\r