]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | IoFifo read/write routines.\r | |
3 | \r | |
4 | Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #include "BaseIoLibIntrinsicInternal.h"\r | |
10 | #include "IoLibSev.h"\r | |
11 | #include "IoLibTdx.h"\r | |
12 | #include <Uefi/UefiBaseType.h>\r | |
13 | #include <Library/TdxLib.h>\r | |
14 | \r | |
15 | /**\r | |
16 | Reads an 8-bit I/O port fifo into a block of memory.\r | |
17 | \r | |
18 | Reads the 8-bit I/O fifo port specified by Port.\r | |
19 | The port is read Count times, and the read data is\r | |
20 | stored in the provided Buffer.\r | |
21 | \r | |
22 | This function must guarantee that all I/O read and write operations are\r | |
23 | serialized.\r | |
24 | \r | |
25 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
26 | \r | |
27 | In TDX a serial of TdIoRead8 is invoked to read the I/O port fifo.\r | |
28 | \r | |
29 | @param Port The I/O port to read.\r | |
30 | @param Count The number of times to read I/O port.\r | |
31 | @param Buffer The buffer to store the read data into.\r | |
32 | \r | |
33 | **/\r | |
34 | VOID\r | |
35 | EFIAPI\r | |
36 | IoReadFifo8 (\r | |
37 | IN UINTN Port,\r | |
38 | IN UINTN Count,\r | |
39 | OUT VOID *Buffer\r | |
40 | )\r | |
41 | {\r | |
42 | if (IsTdxGuest ()) {\r | |
43 | TdIoReadFifo8 (Port, Count, Buffer);\r | |
44 | } else {\r | |
45 | SevIoReadFifo8 (Port, Count, Buffer);\r | |
46 | }\r | |
47 | }\r | |
48 | \r | |
49 | /**\r | |
50 | Writes a block of memory into an 8-bit I/O port fifo.\r | |
51 | \r | |
52 | Writes the 8-bit I/O fifo port specified by Port.\r | |
53 | The port is written Count times, and the write data is\r | |
54 | retrieved from the provided Buffer.\r | |
55 | \r | |
56 | This function must guarantee that all I/O write and write operations are\r | |
57 | serialized.\r | |
58 | \r | |
59 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
60 | \r | |
61 | In TDX a serial of TdIoWrite8 is invoked to write data to the I/O port.\r | |
62 | \r | |
63 | @param Port The I/O port to write.\r | |
64 | @param Count The number of times to write I/O port.\r | |
65 | @param Buffer The buffer to retrieve the write data from.\r | |
66 | \r | |
67 | **/\r | |
68 | VOID\r | |
69 | EFIAPI\r | |
70 | IoWriteFifo8 (\r | |
71 | IN UINTN Port,\r | |
72 | IN UINTN Count,\r | |
73 | IN VOID *Buffer\r | |
74 | )\r | |
75 | {\r | |
76 | if (IsTdxGuest ()) {\r | |
77 | TdIoWriteFifo8 (Port, Count, Buffer);\r | |
78 | } else {\r | |
79 | SevIoWriteFifo8 (Port, Count, Buffer);\r | |
80 | }\r | |
81 | }\r | |
82 | \r | |
83 | /**\r | |
84 | Reads a 16-bit I/O port fifo into a block of memory.\r | |
85 | \r | |
86 | Reads the 16-bit I/O fifo port specified by Port.\r | |
87 | The port is read Count times, and the read data is\r | |
88 | stored in the provided Buffer.\r | |
89 | \r | |
90 | This function must guarantee that all I/O read and write operations are\r | |
91 | serialized.\r | |
92 | \r | |
93 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
94 | \r | |
95 | In TDX a serial of TdIoRead16 is invoked to read data from the I/O port.\r | |
96 | \r | |
97 | @param Port The I/O port to read.\r | |
98 | @param Count The number of times to read I/O port.\r | |
99 | @param Buffer The buffer to store the read data into.\r | |
100 | \r | |
101 | **/\r | |
102 | VOID\r | |
103 | EFIAPI\r | |
104 | IoReadFifo16 (\r | |
105 | IN UINTN Port,\r | |
106 | IN UINTN Count,\r | |
107 | OUT VOID *Buffer\r | |
108 | )\r | |
109 | {\r | |
110 | if (IsTdxGuest ()) {\r | |
111 | TdIoReadFifo16 (Port, Count, Buffer);\r | |
112 | } else {\r | |
113 | SevIoReadFifo16 (Port, Count, Buffer);\r | |
114 | }\r | |
115 | }\r | |
116 | \r | |
117 | /**\r | |
118 | Writes a block of memory into a 16-bit I/O port fifo.\r | |
119 | \r | |
120 | Writes the 16-bit I/O fifo port specified by Port.\r | |
121 | The port is written Count times, and the write data is\r | |
122 | retrieved from the provided Buffer.\r | |
123 | \r | |
124 | This function must guarantee that all I/O write and write operations are\r | |
125 | serialized.\r | |
126 | \r | |
127 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
128 | \r | |
129 | In TDX a serial of TdIoWrite16 is invoked to write data to the I/O port.\r | |
130 | \r | |
131 | @param Port The I/O port to write.\r | |
132 | @param Count The number of times to write I/O port.\r | |
133 | @param Buffer The buffer to retrieve the write data from.\r | |
134 | \r | |
135 | **/\r | |
136 | VOID\r | |
137 | EFIAPI\r | |
138 | IoWriteFifo16 (\r | |
139 | IN UINTN Port,\r | |
140 | IN UINTN Count,\r | |
141 | IN VOID *Buffer\r | |
142 | )\r | |
143 | {\r | |
144 | if (IsTdxGuest ()) {\r | |
145 | TdIoWriteFifo16 (Port, Count, Buffer);\r | |
146 | } else {\r | |
147 | SevIoWriteFifo16 (Port, Count, Buffer);\r | |
148 | }\r | |
149 | }\r | |
150 | \r | |
151 | /**\r | |
152 | Reads a 32-bit I/O port fifo into a block of memory.\r | |
153 | \r | |
154 | Reads the 32-bit I/O fifo port specified by Port.\r | |
155 | The port is read Count times, and the read data is\r | |
156 | stored in the provided Buffer.\r | |
157 | \r | |
158 | This function must guarantee that all I/O read and write operations are\r | |
159 | serialized.\r | |
160 | \r | |
161 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
162 | \r | |
163 | In TDX a serial of TdIoRead32 is invoked to read data from the I/O port.\r | |
164 | \r | |
165 | @param Port The I/O port to read.\r | |
166 | @param Count The number of times to read I/O port.\r | |
167 | @param Buffer The buffer to store the read data into.\r | |
168 | \r | |
169 | **/\r | |
170 | VOID\r | |
171 | EFIAPI\r | |
172 | IoReadFifo32 (\r | |
173 | IN UINTN Port,\r | |
174 | IN UINTN Count,\r | |
175 | OUT VOID *Buffer\r | |
176 | )\r | |
177 | {\r | |
178 | if (IsTdxGuest ()) {\r | |
179 | TdIoReadFifo32 (Port, Count, Buffer);\r | |
180 | } else {\r | |
181 | SevIoReadFifo32 (Port, Count, Buffer);\r | |
182 | }\r | |
183 | }\r | |
184 | \r | |
185 | /**\r | |
186 | Writes a block of memory into a 32-bit I/O port fifo.\r | |
187 | \r | |
188 | Writes the 32-bit I/O fifo port specified by Port.\r | |
189 | The port is written Count times, and the write data is\r | |
190 | retrieved from the provided Buffer.\r | |
191 | \r | |
192 | This function must guarantee that all I/O write and write operations are\r | |
193 | serialized.\r | |
194 | \r | |
195 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
196 | \r | |
197 | In TDX a serial of TdIoWrite32 is invoked to write data to the I/O port.\r | |
198 | \r | |
199 | @param Port The I/O port to write.\r | |
200 | @param Count The number of times to write I/O port.\r | |
201 | @param Buffer The buffer to retrieve the write data from.\r | |
202 | \r | |
203 | **/\r | |
204 | VOID\r | |
205 | EFIAPI\r | |
206 | IoWriteFifo32 (\r | |
207 | IN UINTN Port,\r | |
208 | IN UINTN Count,\r | |
209 | IN VOID *Buffer\r | |
210 | )\r | |
211 | {\r | |
212 | if (IsTdxGuest ()) {\r | |
213 | TdIoWriteFifo32 (Port, Count, Buffer);\r | |
214 | } else {\r | |
215 | SevIoWriteFifo32 (Port, Count, Buffer);\r | |
216 | }\r | |
217 | }\r |