]>
Commit | Line | Data |
---|---|---|
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 | |
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 |
7e284acb | 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 |
7e284acb | 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 | |
36 | RETURN_STATUS\r | |
37 | EFIAPI\r | |
38 | SerialPortInitialize (\r | |
39 | VOID\r | |
40 | )\r | |
41 | {\r | |
42 | return RETURN_SUCCESS;\r | |
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 | |
7e284acb | 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 |
7e284acb | 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 |
7e284acb | 59 | If this value is less than NumberOfBytes, then the read operation failed.\r |
60 | \r | |
61 | **/\r | |
62 | UINTN\r | |
63 | EFIAPI\r | |
64 | SerialPortWrite (\r | |
65 | IN UINT8 *Buffer,\r | |
66 | IN UINTN NumberOfBytes\r | |
67 | )\r | |
68 | {\r | |
9184d5da | 69 | if (gEmuThunk == NULL) {\r |
70 | return NumberOfBytes;\r | |
71 | }\r | |
72 | \r | |
7e284acb | 73 | return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);\r |
74 | }\r | |
75 | \r | |
76 | \r | |
77 | /**\r | |
78 | Read data from serial device and save the datas in buffer.\r | |
d18d8a1d | 79 | \r |
7e284acb | 80 | Reads NumberOfBytes data bytes from a serial device into the buffer\r |
d18d8a1d | 81 | specified by Buffer. The number of bytes actually read is returned.\r |
7e284acb | 82 | If the return value is less than NumberOfBytes, then the rest operation failed.\r |
d18d8a1d | 83 | If Buffer is NULL, then ASSERT().\r |
7e284acb | 84 | If NumberOfBytes is zero, then return 0.\r |
85 | \r | |
86 | @param Buffer The pointer to the data buffer to store the data read from the serial device.\r | |
87 | @param NumberOfBytes The number of bytes which will be read.\r | |
88 | \r | |
89 | @retval 0 Read data failed; No data is to be read.\r | |
90 | @retval >0 The actual number of bytes read from serial device.\r | |
91 | \r | |
92 | **/\r | |
93 | UINTN\r | |
94 | EFIAPI\r | |
95 | SerialPortRead (\r | |
96 | OUT UINT8 *Buffer,\r | |
97 | IN UINTN NumberOfBytes\r | |
98 | )\r | |
99 | {\r | |
100 | return 0;\r | |
101 | }\r | |
102 | \r | |
103 | /**\r | |
104 | Polls a serial device to see if there is any data waiting to be read.\r | |
105 | \r | |
106 | Polls a serial device to see if there is any data waiting to be read.\r | |
107 | If there is data waiting to be read from the serial device, then TRUE is returned.\r | |
108 | If there is no data waiting to be read from the serial device, then FALSE is returned.\r | |
109 | \r | |
110 | @retval TRUE Data is waiting to be read from the serial device.\r | |
111 | @retval FALSE There is no data waiting to be read from the serial device.\r | |
112 | \r | |
113 | **/\r | |
114 | BOOLEAN\r | |
115 | EFIAPI\r | |
116 | SerialPortPoll (\r | |
117 | VOID\r | |
118 | )\r | |
119 | {\r | |
120 | return FALSE;\r | |
121 | }\r | |
122 | \r | |
123 | \r |