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