]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
EmulatorPkg: Remove all trailing whitespace
[mirror_edk2.git] / EmulatorPkg / Library / DxeEmuSerialPortLib / DxeEmuSerialPortLib.c
CommitLineData
949f388f 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
949f388f 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
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php.\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17\r
18#include <PiDxe.h>\r
19#include <Library/SerialPortLib.h>\r
20#include <Library/EmuThunkLib.h>\r
21\r
22\r
23\r
24\r
25/**\r
26 Initialize the serial device hardware.\r
d18d8a1d 27\r
949f388f 28 If no initialization is required, then return RETURN_SUCCESS.\r
29 If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
30 If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
d18d8a1d 31\r
949f388f 32 @retval RETURN_SUCCESS The serial device was initialized.\r
33 @retval RETURN_DEVICE_ERROR The serial device could not be initialized.\r
34\r
35**/\r
36RETURN_STATUS\r
37EFIAPI\r
38SerialPortInitialize (\r
39 VOID\r
40 )\r
41{\r
7e284acb 42 return gEmuThunk->ConfigStdIn ();\r
949f388f 43}\r
44\r
45/**\r
d18d8a1d 46 Write data from buffer to serial device.\r
47\r
48 Writes NumberOfBytes data bytes from Buffer to the serial device.\r
949f388f 49 The number of bytes actually written to the serial device is returned.\r
50 If the return value is less than NumberOfBytes, then the write operation failed.\r
d18d8a1d 51 If Buffer is NULL, then ASSERT().\r
949f388f 52 If NumberOfBytes is zero, then return 0.\r
53\r
54 @param Buffer The pointer to the data buffer to be written.\r
55 @param NumberOfBytes The number of bytes to written to the serial device.\r
56\r
57 @retval 0 NumberOfBytes is 0.\r
d18d8a1d 58 @retval >0 The number of bytes written to the serial device.\r
949f388f 59 If this value is less than NumberOfBytes, then the read operation failed.\r
60\r
61**/\r
62UINTN\r
63EFIAPI\r
64SerialPortWrite (\r
65 IN UINT8 *Buffer,\r
66 IN UINTN NumberOfBytes\r
67 )\r
68{\r
7e284acb 69 return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);\r
949f388f 70}\r
71\r
72\r
73/**\r
74 Read data from serial device and save the datas in buffer.\r
d18d8a1d 75\r
949f388f 76 Reads NumberOfBytes data bytes from a serial device into the buffer\r
d18d8a1d 77 specified by Buffer. The number of bytes actually read is returned.\r
949f388f 78 If the return value is less than NumberOfBytes, then the rest operation failed.\r
d18d8a1d 79 If Buffer is NULL, then ASSERT().\r
949f388f 80 If NumberOfBytes is zero, then return 0.\r
81\r
82 @param Buffer The pointer to the data buffer to store the data read from the serial device.\r
83 @param NumberOfBytes The number of bytes which will be read.\r
84\r
85 @retval 0 Read data failed; No data is to be read.\r
86 @retval >0 The actual number of bytes read from serial device.\r
87\r
88**/\r
89UINTN\r
90EFIAPI\r
91SerialPortRead (\r
92 OUT UINT8 *Buffer,\r
93 IN UINTN NumberOfBytes\r
94 )\r
95{\r
7e284acb 96 return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);\r
949f388f 97}\r
98\r
99/**\r
100 Polls a serial device to see if there is any data waiting to be read.\r
101\r
102 Polls a serial device to see if there is any data waiting to be read.\r
103 If there is data waiting to be read from the serial device, then TRUE is returned.\r
104 If there is no data waiting to be read from the serial device, then FALSE is returned.\r
105\r
106 @retval TRUE Data is waiting to be read from the serial device.\r
107 @retval FALSE There is no data waiting to be read from the serial device.\r
108\r
109**/\r
110BOOLEAN\r
111EFIAPI\r
112SerialPortPoll (\r
113 VOID\r
114 )\r
115{\r
7e284acb 116 return gEmuThunk->PollStdIn ();\r
949f388f 117}\r
118\r
119\r