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