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