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