]>
Commit | Line | Data |
---|---|---|
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.\r | |
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 | |
27 | \r | |
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 | |
31 | \r | |
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 gEmuThunk->ConfigStdIn ();\r | |
43 | }\r | |
44 | \r | |
45 | /**\r | |
46 | Write data from buffer to serial device.\r | |
47 | \r | |
48 | Writes NumberOfBytes data bytes from Buffer to the serial device.\r | |
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 | |
51 | If Buffer is NULL, then ASSERT().\r | |
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 | |
58 | @retval >0 The number of bytes written to the serial device.\r | |
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 | |
69 | return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);\r | |
70 | }\r | |
71 | \r | |
72 | \r | |
73 | /**\r | |
74 | Read data from serial device and save the datas in buffer.\r | |
75 | \r | |
76 | Reads NumberOfBytes data bytes from a serial device into the buffer\r | |
77 | specified by Buffer. The number of bytes actually read is returned.\r | |
78 | If the return value is less than NumberOfBytes, then the rest operation failed.\r | |
79 | If Buffer is NULL, then ASSERT().\r | |
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 | |
89 | UINTN\r | |
90 | EFIAPI\r | |
91 | SerialPortRead (\r | |
92 | OUT UINT8 *Buffer,\r | |
93 | IN UINTN NumberOfBytes\r | |
94 | )\r | |
95 | {\r | |
96 | return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);\r | |
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 | |
110 | BOOLEAN\r | |
111 | EFIAPI\r | |
112 | SerialPortPoll (\r | |
113 | VOID\r | |
114 | )\r | |
115 | {\r | |
116 | return gEmuThunk->PollStdIn ();\r | |
117 | }\r | |
118 | \r |