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