]>
Commit | Line | Data |
---|---|---|
b7c5912a | 1 | /** @file\r |
2 | I/O Library.\r | |
9095d37b | 3 | The implementation of I/O operation for this library instance\r |
b7c5912a | 4 | are based on EFI_CPU_IO_PROTOCOL.\r |
9095d37b LG |
5 | \r |
6 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
44564668 LD |
7 | Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r |
8 | \r | |
9344f092 | 9 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
b7c5912a | 10 | \r |
b7c5912a | 11 | **/\r |
12 | \r | |
b7c5912a | 13 | #include "SmmCpuIoLibInternal.h"\r |
14 | \r | |
b7c5912a | 15 | /**\r |
16 | Reads registers in the EFI CPU I/O space.\r | |
17 | \r | |
18 | Reads the I/O port specified by Port with registers width specified by Width.\r | |
19 | The read value is returned. If such operations are not supported, then ASSERT().\r | |
20 | This function must guarantee that all I/O read and write operations are serialized.\r | |
21 | \r | |
22 | @param Port The base address of the I/O operation.\r | |
23 | The caller is responsible for aligning the Address if required.\r | |
24 | @param Width The width of the I/O operation.\r | |
25 | \r | |
26 | @return Data read from registers in the EFI CPU I/O space.\r | |
27 | \r | |
28 | **/\r | |
29 | UINT64\r | |
30 | EFIAPI\r | |
31 | IoReadWorker (\r | |
32 | IN UINTN Port,\r | |
33 | IN EFI_SMM_IO_WIDTH Width\r | |
34 | )\r | |
35 | {\r | |
36 | EFI_STATUS Status;\r | |
37 | UINT64 Data;\r | |
38 | \r | |
112af426 | 39 | Status = gSmst->SmmIo.Io.Read (&gSmst->SmmIo, Width, Port, 1, &Data);\r |
b7c5912a | 40 | ASSERT_EFI_ERROR (Status);\r |
41 | \r | |
42 | return Data;\r | |
43 | }\r | |
44 | \r | |
45 | /**\r | |
46 | Writes registers in the EFI CPU I/O space.\r | |
47 | \r | |
48 | Writes the I/O port specified by Port with registers width and value specified by Width\r | |
49 | and Data respectively. Data is returned. If such operations are not supported, then ASSERT().\r | |
50 | This function must guarantee that all I/O read and write operations are serialized.\r | |
51 | \r | |
52 | @param Port The base address of the I/O operation.\r | |
53 | The caller is responsible for aligning the Address if required.\r | |
54 | @param Width The width of the I/O operation.\r | |
55 | @param Data The value to write to the I/O port.\r | |
56 | \r | |
a750b4ae | 57 | @return The parameter of Data.\r |
b7c5912a | 58 | \r |
59 | **/\r | |
60 | UINT64\r | |
61 | EFIAPI\r | |
62 | IoWriteWorker (\r | |
63 | IN UINTN Port,\r | |
64 | IN EFI_SMM_IO_WIDTH Width,\r | |
65 | IN UINT64 Data\r | |
66 | )\r | |
67 | {\r | |
68 | EFI_STATUS Status;\r | |
69 | \r | |
112af426 | 70 | Status = gSmst->SmmIo.Io.Write (&gSmst->SmmIo, Width, Port, 1, &Data);\r |
b7c5912a | 71 | ASSERT_EFI_ERROR (Status);\r |
72 | \r | |
73 | return Data;\r | |
74 | }\r | |
75 | \r | |
76 | /**\r | |
77 | Reads memory-mapped registers in the EFI system memory space.\r | |
78 | \r | |
79 | Reads the MMIO registers specified by Address with registers width specified by Width.\r | |
80 | The read value is returned. If such operations are not supported, then ASSERT().\r | |
81 | This function must guarantee that all MMIO read and write operations are serialized.\r | |
82 | \r | |
83 | @param Address The MMIO register to read.\r | |
84 | The caller is responsible for aligning the Address if required.\r | |
85 | @param Width The width of the I/O operation.\r | |
86 | \r | |
87 | @return Data read from registers in the EFI system memory space.\r | |
88 | \r | |
89 | **/\r | |
90 | UINT64\r | |
91 | EFIAPI\r | |
92 | MmioReadWorker (\r | |
93 | IN UINTN Address,\r | |
94 | IN EFI_SMM_IO_WIDTH Width\r | |
95 | )\r | |
96 | {\r | |
97 | EFI_STATUS Status;\r | |
98 | UINT64 Data;\r | |
99 | \r | |
112af426 | 100 | Status = gSmst->SmmIo.Mem.Read (&gSmst->SmmIo, Width, Address, 1, &Data);\r |
b7c5912a | 101 | ASSERT_EFI_ERROR (Status);\r |
102 | \r | |
103 | return Data;\r | |
104 | }\r | |
105 | \r | |
106 | /**\r | |
107 | Writes memory-mapped registers in the EFI system memory space.\r | |
108 | \r | |
109 | Writes the MMIO registers specified by Address with registers width and value specified by Width\r | |
110 | and Data respectively. Data is returned. If such operations are not supported, then ASSERT().\r | |
111 | This function must guarantee that all MMIO read and write operations are serialized.\r | |
112 | \r | |
113 | @param Address The MMIO register to read.\r | |
114 | The caller is responsible for aligning the Address if required.\r | |
115 | @param Width The width of the I/O operation.\r | |
116 | @param Data The value to write to the I/O port.\r | |
9095d37b | 117 | \r |
b7c5912a | 118 | @return Data read from registers in the EFI system memory space.\r |
119 | \r | |
120 | **/\r | |
121 | UINT64\r | |
122 | EFIAPI\r | |
123 | MmioWriteWorker (\r | |
124 | IN UINTN Address,\r | |
125 | IN EFI_SMM_IO_WIDTH Width,\r | |
126 | IN UINT64 Data\r | |
127 | )\r | |
128 | {\r | |
129 | EFI_STATUS Status;\r | |
130 | \r | |
112af426 | 131 | Status = gSmst->SmmIo.Mem.Write (&gSmst->SmmIo, Width, Address, 1, &Data);\r |
b7c5912a | 132 | ASSERT_EFI_ERROR (Status);\r |
133 | \r | |
134 | return Data;\r | |
135 | }\r | |
136 | \r | |
137 | /**\r | |
138 | Reads an 8-bit I/O port.\r | |
139 | \r | |
140 | Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.\r | |
141 | This function must guarantee that all I/O read and write operations are\r | |
142 | serialized.\r | |
143 | \r | |
144 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
145 | \r | |
146 | @param Port The I/O port to read.\r | |
147 | \r | |
148 | @return The value read.\r | |
149 | \r | |
150 | **/\r | |
151 | UINT8\r | |
152 | EFIAPI\r | |
153 | IoRead8 (\r | |
154 | IN UINTN Port\r | |
155 | )\r | |
156 | {\r | |
157 | return (UINT8)IoReadWorker (Port, SMM_IO_UINT8);\r | |
158 | }\r | |
159 | \r | |
160 | /**\r | |
161 | Writes an 8-bit I/O port.\r | |
162 | \r | |
163 | Writes the 8-bit I/O port specified by Port with the value specified by Value\r | |
164 | and returns Value. This function must guarantee that all I/O read and write\r | |
165 | operations are serialized.\r | |
166 | \r | |
167 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
168 | \r | |
169 | @param Port The I/O port to write.\r | |
170 | @param Value The value to write to the I/O port.\r | |
171 | \r | |
172 | @return The value written the I/O port.\r | |
173 | \r | |
174 | **/\r | |
175 | UINT8\r | |
176 | EFIAPI\r | |
177 | IoWrite8 (\r | |
178 | IN UINTN Port,\r | |
179 | IN UINT8 Value\r | |
180 | )\r | |
181 | {\r | |
182 | return (UINT8)IoWriteWorker (Port, SMM_IO_UINT8, Value);\r | |
183 | }\r | |
184 | \r | |
185 | /**\r | |
186 | Reads a 16-bit I/O port.\r | |
187 | \r | |
188 | Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.\r | |
189 | This function must guarantee that all I/O read and write operations are\r | |
190 | serialized.\r | |
191 | \r | |
192 | If Port is not aligned on a 16-bit boundary, then ASSERT().\r | |
9095d37b | 193 | \r |
b7c5912a | 194 | If 16-bit I/O port operations are not supported, then ASSERT().\r |
195 | \r | |
196 | @param Port The I/O port to read.\r | |
197 | \r | |
198 | @return The value read.\r | |
199 | \r | |
200 | **/\r | |
201 | UINT16\r | |
202 | EFIAPI\r | |
203 | IoRead16 (\r | |
204 | IN UINTN Port\r | |
205 | )\r | |
206 | {\r | |
207 | //\r | |
208 | // Make sure Port is aligned on a 16-bit boundary.\r | |
209 | //\r | |
210 | ASSERT ((Port & 1) == 0);\r | |
211 | return (UINT16)IoReadWorker (Port, SMM_IO_UINT16);\r | |
212 | }\r | |
213 | \r | |
214 | /**\r | |
215 | Writes a 16-bit I/O port.\r | |
216 | \r | |
217 | Writes the 16-bit I/O port specified by Port with the value specified by Value\r | |
218 | and returns Value. This function must guarantee that all I/O read and write\r | |
219 | operations are serialized.\r | |
220 | \r | |
221 | If Port is not aligned on a 16-bit boundary, then ASSERT().\r | |
222 | \r | |
223 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
224 | \r | |
225 | @param Port The I/O port to write.\r | |
226 | @param Value The value to write to the I/O port.\r | |
227 | \r | |
228 | @return The value written the I/O port.\r | |
229 | \r | |
230 | **/\r | |
231 | UINT16\r | |
232 | EFIAPI\r | |
233 | IoWrite16 (\r | |
234 | IN UINTN Port,\r | |
235 | IN UINT16 Value\r | |
236 | )\r | |
237 | {\r | |
238 | //\r | |
239 | // Make sure Port is aligned on a 16-bit boundary.\r | |
240 | //\r | |
241 | ASSERT ((Port & 1) == 0);\r | |
242 | return (UINT16)IoWriteWorker (Port, SMM_IO_UINT16, Value);\r | |
243 | }\r | |
244 | \r | |
245 | /**\r | |
246 | Reads a 32-bit I/O port.\r | |
247 | \r | |
248 | Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.\r | |
249 | This function must guarantee that all I/O read and write operations are\r | |
250 | serialized.\r | |
9095d37b | 251 | \r |
b7c5912a | 252 | If Port is not aligned on a 32-bit boundary, then ASSERT().\r |
253 | \r | |
254 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
255 | \r | |
256 | @param Port The I/O port to read.\r | |
257 | \r | |
258 | @return The value read.\r | |
259 | \r | |
260 | **/\r | |
261 | UINT32\r | |
262 | EFIAPI\r | |
263 | IoRead32 (\r | |
264 | IN UINTN Port\r | |
265 | )\r | |
266 | {\r | |
267 | //\r | |
268 | // Make sure Port is aligned on a 32-bit boundary.\r | |
269 | //\r | |
270 | ASSERT ((Port & 3) == 0);\r | |
271 | return (UINT32)IoReadWorker (Port, SMM_IO_UINT32);\r | |
272 | }\r | |
273 | \r | |
274 | /**\r | |
275 | Writes a 32-bit I/O port.\r | |
276 | \r | |
277 | Writes the 32-bit I/O port specified by Port with the value specified by Value\r | |
278 | and returns Value. This function must guarantee that all I/O read and write\r | |
279 | operations are serialized.\r | |
280 | \r | |
281 | If Port is not aligned on a 32-bit boundary, then ASSERT().\r | |
282 | \r | |
283 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
284 | \r | |
285 | @param Port The I/O port to write.\r | |
286 | @param Value The value to write to the I/O port.\r | |
287 | \r | |
288 | @return The value written the I/O port.\r | |
289 | \r | |
290 | **/\r | |
291 | UINT32\r | |
292 | EFIAPI\r | |
293 | IoWrite32 (\r | |
294 | IN UINTN Port,\r | |
295 | IN UINT32 Value\r | |
296 | )\r | |
297 | {\r | |
298 | //\r | |
299 | // Make sure Port is aligned on a 32-bit boundary.\r | |
300 | //\r | |
301 | ASSERT ((Port & 3) == 0);\r | |
302 | return (UINT32)IoWriteWorker (Port, SMM_IO_UINT32, Value);\r | |
303 | }\r | |
304 | \r | |
305 | /**\r | |
306 | Reads a 64-bit I/O port.\r | |
307 | \r | |
308 | Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.\r | |
309 | This function must guarantee that all I/O read and write operations are\r | |
310 | serialized.\r | |
311 | \r | |
312 | If Port is not aligned on a 64-bit boundary, then ASSERT().\r | |
313 | \r | |
314 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
315 | \r | |
316 | @param Port The I/O port to read.\r | |
317 | \r | |
318 | @return The value read.\r | |
319 | \r | |
320 | **/\r | |
321 | UINT64\r | |
322 | EFIAPI\r | |
323 | IoRead64 (\r | |
324 | IN UINTN Port\r | |
325 | )\r | |
326 | {\r | |
327 | //\r | |
328 | // Make sure Port is aligned on a 64-bit boundary.\r | |
329 | //\r | |
330 | ASSERT ((Port & 7) == 0);\r | |
331 | return IoReadWorker (Port, SMM_IO_UINT64);\r | |
332 | }\r | |
333 | \r | |
334 | /**\r | |
335 | Writes a 64-bit I/O port.\r | |
336 | \r | |
337 | Writes the 64-bit I/O port specified by Port with the value specified by Value\r | |
338 | and returns Value. This function must guarantee that all I/O read and write\r | |
339 | operations are serialized.\r | |
340 | \r | |
341 | If Port is not aligned on a 64-bit boundary, then ASSERT().\r | |
9095d37b | 342 | \r |
b7c5912a | 343 | If 64-bit I/O port operations are not supported, then ASSERT().\r |
344 | \r | |
345 | @param Port The I/O port to write.\r | |
346 | @param Value The value to write to the I/O port.\r | |
347 | \r | |
348 | @return The value written the I/O port.\r | |
349 | \r | |
350 | **/\r | |
351 | UINT64\r | |
352 | EFIAPI\r | |
353 | IoWrite64 (\r | |
354 | IN UINTN Port,\r | |
355 | IN UINT64 Value\r | |
356 | )\r | |
357 | {\r | |
358 | //\r | |
359 | // Make sure Port is aligned on a 64-bit boundary.\r | |
360 | //\r | |
361 | ASSERT ((Port & 7) == 0);\r | |
362 | return IoWriteWorker (Port, SMM_IO_UINT64, Value);\r | |
363 | }\r | |
364 | \r | |
44564668 LD |
365 | /**\r |
366 | Reads an 8-bit I/O port fifo into a block of memory.\r | |
367 | \r | |
368 | Reads the 8-bit I/O fifo port specified by Port.\r | |
369 | The port is read Count times, and the read data is\r | |
370 | stored in the provided Buffer.\r | |
371 | \r | |
372 | This function must guarantee that all I/O read and write operations are\r | |
373 | serialized.\r | |
374 | \r | |
375 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
376 | \r | |
377 | @param Port The I/O port to read.\r | |
378 | @param Count The number of times to read I/O port.\r | |
379 | @param Buffer The buffer to store the read data into.\r | |
380 | \r | |
381 | **/\r | |
382 | VOID\r | |
383 | EFIAPI\r | |
384 | IoReadFifo8 (\r | |
385 | IN UINTN Port,\r | |
386 | IN UINTN Count,\r | |
387 | OUT VOID *Buffer\r | |
388 | )\r | |
389 | {\r | |
390 | UINT8 *Buffer8;\r | |
391 | \r | |
392 | Buffer8 = (UINT8 *)Buffer;\r | |
058cd03b | 393 | while (Count-- > 0) {\r |
44564668 LD |
394 | *Buffer8++ = IoRead8 (Port);\r |
395 | }\r | |
396 | }\r | |
397 | \r | |
398 | /**\r | |
399 | Writes a block of memory into an 8-bit I/O port fifo.\r | |
400 | \r | |
401 | Writes the 8-bit I/O fifo port specified by Port.\r | |
402 | The port is written Count times, and the write data is\r | |
403 | retrieved from the provided Buffer.\r | |
404 | \r | |
405 | This function must guarantee that all I/O write and write operations are\r | |
406 | serialized.\r | |
407 | \r | |
408 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
409 | \r | |
410 | @param Port The I/O port to write.\r | |
411 | @param Count The number of times to write I/O port.\r | |
412 | @param Buffer The buffer to retrieve the write data from.\r | |
413 | \r | |
414 | **/\r | |
415 | VOID\r | |
416 | EFIAPI\r | |
417 | IoWriteFifo8 (\r | |
418 | IN UINTN Port,\r | |
419 | IN UINTN Count,\r | |
420 | IN VOID *Buffer\r | |
421 | )\r | |
422 | {\r | |
423 | UINT8 *Buffer8;\r | |
424 | \r | |
425 | Buffer8 = (UINT8 *)Buffer;\r | |
058cd03b | 426 | while (Count-- > 0) {\r |
44564668 LD |
427 | IoWrite8 (Port, *Buffer8++);\r |
428 | }\r | |
429 | }\r | |
430 | \r | |
431 | /**\r | |
432 | Reads a 16-bit I/O port fifo into a block of memory.\r | |
433 | \r | |
434 | Reads the 16-bit I/O fifo port specified by Port.\r | |
435 | The port is read Count times, and the read data is\r | |
436 | stored in the provided Buffer.\r | |
437 | \r | |
438 | This function must guarantee that all I/O read and write operations are\r | |
439 | serialized.\r | |
440 | \r | |
441 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
442 | \r | |
443 | @param Port The I/O port to read.\r | |
444 | @param Count The number of times to read I/O port.\r | |
445 | @param Buffer The buffer to store the read data into.\r | |
446 | \r | |
447 | **/\r | |
448 | VOID\r | |
449 | EFIAPI\r | |
450 | IoReadFifo16 (\r | |
451 | IN UINTN Port,\r | |
452 | IN UINTN Count,\r | |
453 | OUT VOID *Buffer\r | |
454 | )\r | |
455 | {\r | |
456 | UINT16 *Buffer16;\r | |
457 | \r | |
458 | //\r | |
459 | // Make sure Port is aligned on a 16-bit boundary.\r | |
460 | //\r | |
461 | ASSERT ((Port & 1) == 0);\r | |
462 | Buffer16 = (UINT16 *)Buffer;\r | |
058cd03b | 463 | while (Count-- > 0) {\r |
44564668 LD |
464 | *Buffer16++ = IoRead16 (Port);\r |
465 | }\r | |
466 | }\r | |
467 | \r | |
468 | /**\r | |
469 | Writes a block of memory into a 16-bit I/O port fifo.\r | |
470 | \r | |
471 | Writes the 16-bit I/O fifo port specified by Port.\r | |
472 | The port is written Count times, and the write data is\r | |
473 | retrieved from the provided Buffer.\r | |
474 | \r | |
475 | This function must guarantee that all I/O write and write operations are\r | |
476 | serialized.\r | |
477 | \r | |
478 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
479 | \r | |
480 | @param Port The I/O port to write.\r | |
481 | @param Count The number of times to write I/O port.\r | |
482 | @param Buffer The buffer to retrieve the write data from.\r | |
483 | \r | |
484 | **/\r | |
485 | VOID\r | |
486 | EFIAPI\r | |
487 | IoWriteFifo16 (\r | |
488 | IN UINTN Port,\r | |
489 | IN UINTN Count,\r | |
490 | IN VOID *Buffer\r | |
491 | )\r | |
492 | {\r | |
493 | UINT16 *Buffer16;\r | |
494 | \r | |
495 | //\r | |
496 | // Make sure Port is aligned on a 16-bit boundary.\r | |
497 | //\r | |
498 | ASSERT ((Port & 1) == 0);\r | |
499 | Buffer16 = (UINT16 *)Buffer;\r | |
058cd03b | 500 | while (Count-- > 0) {\r |
44564668 LD |
501 | IoWrite16 (Port, *Buffer16++);\r |
502 | }\r | |
503 | }\r | |
504 | \r | |
505 | /**\r | |
506 | Reads a 32-bit I/O port fifo into a block of memory.\r | |
507 | \r | |
508 | Reads the 32-bit I/O fifo port specified by Port.\r | |
509 | The port is read Count times, and the read data is\r | |
510 | stored in the provided Buffer.\r | |
511 | \r | |
512 | This function must guarantee that all I/O read and write operations are\r | |
513 | serialized.\r | |
514 | \r | |
515 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
516 | \r | |
517 | @param Port The I/O port to read.\r | |
518 | @param Count The number of times to read I/O port.\r | |
519 | @param Buffer The buffer to store the read data into.\r | |
520 | \r | |
521 | **/\r | |
522 | VOID\r | |
523 | EFIAPI\r | |
524 | IoReadFifo32 (\r | |
525 | IN UINTN Port,\r | |
526 | IN UINTN Count,\r | |
527 | OUT VOID *Buffer\r | |
528 | )\r | |
529 | {\r | |
530 | UINT32 *Buffer32;\r | |
531 | \r | |
532 | //\r | |
533 | // Make sure Port is aligned on a 32-bit boundary.\r | |
534 | //\r | |
535 | ASSERT ((Port & 3) == 0);\r | |
536 | Buffer32 = (UINT32 *)Buffer;\r | |
058cd03b | 537 | while (Count-- > 0) {\r |
44564668 LD |
538 | *Buffer32++ = IoRead32 (Port);\r |
539 | }\r | |
540 | }\r | |
541 | \r | |
542 | /**\r | |
543 | Writes a block of memory into a 32-bit I/O port fifo.\r | |
544 | \r | |
545 | Writes the 32-bit I/O fifo port specified by Port.\r | |
546 | The port is written Count times, and the write data is\r | |
547 | retrieved from the provided Buffer.\r | |
548 | \r | |
549 | This function must guarantee that all I/O write and write operations are\r | |
550 | serialized.\r | |
551 | \r | |
552 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
553 | \r | |
554 | @param Port The I/O port to write.\r | |
555 | @param Count The number of times to write I/O port.\r | |
556 | @param Buffer The buffer to retrieve the write data from.\r | |
557 | \r | |
558 | **/\r | |
559 | VOID\r | |
560 | EFIAPI\r | |
561 | IoWriteFifo32 (\r | |
562 | IN UINTN Port,\r | |
563 | IN UINTN Count,\r | |
564 | IN VOID *Buffer\r | |
565 | )\r | |
566 | {\r | |
567 | UINT32 *Buffer32;\r | |
568 | \r | |
569 | //\r | |
570 | // Make sure Port is aligned on a 32-bit boundary.\r | |
571 | //\r | |
572 | ASSERT ((Port & 3) == 0);\r | |
573 | Buffer32 = (UINT32 *)Buffer;\r | |
058cd03b | 574 | while (Count-- > 0) {\r |
44564668 LD |
575 | IoWrite32 (Port, *Buffer32++);\r |
576 | }\r | |
577 | }\r | |
578 | \r | |
b7c5912a | 579 | /**\r |
580 | Reads an 8-bit MMIO register.\r | |
581 | \r | |
582 | Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r | |
583 | returned. This function must guarantee that all MMIO read and write\r | |
584 | operations are serialized.\r | |
585 | \r | |
586 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
587 | \r | |
588 | @param Address The MMIO register to read.\r | |
589 | \r | |
590 | @return The value read.\r | |
591 | \r | |
592 | **/\r | |
593 | UINT8\r | |
594 | EFIAPI\r | |
595 | MmioRead8 (\r | |
596 | IN UINTN Address\r | |
597 | )\r | |
598 | {\r | |
599 | return (UINT8)MmioReadWorker (Address, SMM_IO_UINT8);\r | |
600 | }\r | |
601 | \r | |
602 | /**\r | |
603 | Writes an 8-bit MMIO register.\r | |
604 | \r | |
605 | Writes the 8-bit MMIO register specified by Address with the value specified\r | |
606 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
607 | and write operations are serialized.\r | |
608 | \r | |
609 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
610 | \r | |
611 | @param Address The MMIO register to write.\r | |
612 | @param Value The value to write to the MMIO register.\r | |
613 | \r | |
614 | **/\r | |
615 | UINT8\r | |
616 | EFIAPI\r | |
617 | MmioWrite8 (\r | |
618 | IN UINTN Address,\r | |
619 | IN UINT8 Value\r | |
620 | )\r | |
621 | {\r | |
622 | return (UINT8)MmioWriteWorker (Address, SMM_IO_UINT8, Value);\r | |
623 | }\r | |
624 | \r | |
625 | /**\r | |
626 | Reads a 16-bit MMIO register.\r | |
627 | \r | |
628 | Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r | |
629 | returned. This function must guarantee that all MMIO read and write\r | |
630 | operations are serialized.\r | |
631 | \r | |
632 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
9095d37b | 633 | \r |
b7c5912a | 634 | If 16-bit MMIO register operations are not supported, then ASSERT().\r |
635 | \r | |
636 | @param Address The MMIO register to read.\r | |
637 | \r | |
638 | @return The value read.\r | |
639 | \r | |
640 | **/\r | |
641 | UINT16\r | |
642 | EFIAPI\r | |
643 | MmioRead16 (\r | |
644 | IN UINTN Address\r | |
645 | )\r | |
646 | {\r | |
647 | //\r | |
648 | // Make sure Address is aligned on a 16-bit boundary.\r | |
649 | //\r | |
650 | ASSERT ((Address & 1) == 0);\r | |
651 | return (UINT16)MmioReadWorker (Address, SMM_IO_UINT16);\r | |
652 | }\r | |
653 | \r | |
654 | /**\r | |
655 | Writes a 16-bit MMIO register.\r | |
656 | \r | |
657 | Writes the 16-bit MMIO register specified by Address with the value specified\r | |
658 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
659 | and write operations are serialized.\r | |
660 | \r | |
661 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
9095d37b | 662 | \r |
b7c5912a | 663 | If 16-bit MMIO register operations are not supported, then ASSERT().\r |
664 | \r | |
665 | @param Address The MMIO register to write.\r | |
666 | @param Value The value to write to the MMIO register.\r | |
667 | \r | |
668 | **/\r | |
669 | UINT16\r | |
670 | EFIAPI\r | |
671 | MmioWrite16 (\r | |
672 | IN UINTN Address,\r | |
673 | IN UINT16 Value\r | |
674 | )\r | |
675 | {\r | |
676 | //\r | |
677 | // Make sure Address is aligned on a 16-bit boundary.\r | |
678 | //\r | |
679 | ASSERT ((Address & 1) == 0);\r | |
680 | return (UINT16)MmioWriteWorker (Address, SMM_IO_UINT16, Value);\r | |
681 | }\r | |
682 | \r | |
683 | /**\r | |
684 | Reads a 32-bit MMIO register.\r | |
685 | \r | |
686 | Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r | |
687 | returned. This function must guarantee that all MMIO read and write\r | |
688 | operations are serialized.\r | |
689 | \r | |
690 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
9095d37b | 691 | \r |
b7c5912a | 692 | If 32-bit MMIO register operations are not supported, then ASSERT().\r |
693 | \r | |
694 | @param Address The MMIO register to read.\r | |
695 | \r | |
696 | @return The value read.\r | |
697 | \r | |
698 | **/\r | |
699 | UINT32\r | |
700 | EFIAPI\r | |
701 | MmioRead32 (\r | |
702 | IN UINTN Address\r | |
703 | )\r | |
704 | {\r | |
705 | //\r | |
706 | // Make sure Address is aligned on a 32-bit boundary.\r | |
707 | //\r | |
708 | ASSERT ((Address & 3) == 0);\r | |
709 | return (UINT32)MmioReadWorker (Address, SMM_IO_UINT32);\r | |
710 | }\r | |
711 | \r | |
712 | /**\r | |
713 | Writes a 32-bit MMIO register.\r | |
714 | \r | |
715 | Writes the 32-bit MMIO register specified by Address with the value specified\r | |
716 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
717 | and write operations are serialized.\r | |
718 | \r | |
719 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
9095d37b | 720 | \r |
b7c5912a | 721 | If 32-bit MMIO register operations are not supported, then ASSERT().\r |
722 | \r | |
723 | @param Address The MMIO register to write.\r | |
724 | @param Value The value to write to the MMIO register.\r | |
725 | \r | |
726 | **/\r | |
727 | UINT32\r | |
728 | EFIAPI\r | |
729 | MmioWrite32 (\r | |
730 | IN UINTN Address,\r | |
731 | IN UINT32 Value\r | |
732 | )\r | |
733 | {\r | |
734 | //\r | |
735 | // Make sure Address is aligned on a 32-bit boundary.\r | |
736 | //\r | |
737 | ASSERT ((Address & 3) == 0);\r | |
738 | return (UINT32)MmioWriteWorker (Address, SMM_IO_UINT32, Value);\r | |
739 | }\r | |
740 | \r | |
741 | /**\r | |
742 | Reads a 64-bit MMIO register.\r | |
743 | \r | |
744 | Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r | |
745 | returned. This function must guarantee that all MMIO read and write\r | |
746 | operations are serialized.\r | |
747 | \r | |
748 | If Address is not aligned on a 64-bit boundary, then ASSERT().\r | |
9095d37b | 749 | \r |
b7c5912a | 750 | If 64-bit MMIO register operations are not supported, then ASSERT().\r |
751 | \r | |
752 | @param Address The MMIO register to read.\r | |
753 | \r | |
754 | @return The value read.\r | |
755 | \r | |
756 | **/\r | |
757 | UINT64\r | |
758 | EFIAPI\r | |
759 | MmioRead64 (\r | |
760 | IN UINTN Address\r | |
761 | )\r | |
762 | {\r | |
763 | //\r | |
764 | // Make sure Address is aligned on a 64-bit boundary.\r | |
765 | //\r | |
766 | ASSERT ((Address & 7) == 0);\r | |
767 | return (UINT64)MmioReadWorker (Address, SMM_IO_UINT64);\r | |
768 | }\r | |
769 | \r | |
770 | /**\r | |
771 | Writes a 64-bit MMIO register.\r | |
772 | \r | |
773 | Writes the 64-bit MMIO register specified by Address with the value specified\r | |
774 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
775 | and write operations are serialized.\r | |
776 | \r | |
777 | If Address is not aligned on a 64-bit boundary, then ASSERT().\r | |
9095d37b | 778 | \r |
b7c5912a | 779 | If 64-bit MMIO register operations are not supported, then ASSERT().\r |
780 | \r | |
781 | @param Address The MMIO register to write.\r | |
782 | @param Value The value to write to the MMIO register.\r | |
783 | \r | |
784 | **/\r | |
785 | UINT64\r | |
786 | EFIAPI\r | |
787 | MmioWrite64 (\r | |
788 | IN UINTN Address,\r | |
789 | IN UINT64 Value\r | |
790 | )\r | |
791 | {\r | |
792 | //\r | |
793 | // Make sure Address is aligned on a 64-bit boundary.\r | |
794 | //\r | |
795 | ASSERT ((Address & 7) == 0);\r | |
796 | return (UINT64)MmioWriteWorker (Address, SMM_IO_UINT64, Value);\r | |
797 | }\r |