]>
Commit | Line | Data |
---|---|---|
4134f2bd AB |
1 | /** @file\r |
2 | I/O Library for ARM.\r | |
3 | \r | |
38c8be12 | 4 | Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r |
4134f2bd AB |
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 | |
27 | UINT8\r | |
28 | EFIAPI\r | |
29 | MmioRead8Internal (\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 | |
44 | VOID\r | |
45 | EFIAPI\r | |
46 | MmioWrite8Internal (\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 | |
63 | UINT16\r | |
64 | EFIAPI\r | |
65 | MmioRead16Internal (\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 | |
80 | VOID\r | |
81 | EFIAPI\r | |
82 | MmioWrite16Internal (\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 | |
99 | UINT32\r | |
100 | EFIAPI\r | |
101 | MmioRead32Internal (\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 | |
116 | VOID\r | |
117 | EFIAPI\r | |
118 | MmioWrite32Internal (\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 | |
135 | UINT64\r | |
136 | EFIAPI\r | |
137 | MmioRead64Internal (\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 | |
152 | VOID\r | |
153 | EFIAPI\r | |
154 | MmioWrite64Internal (\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 | |
173 | UINT8\r | |
174 | EFIAPI\r | |
175 | IoRead8 (\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 | |
198 | UINT8\r | |
199 | EFIAPI\r | |
200 | IoWrite8 (\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 | |
223 | UINT16\r | |
224 | EFIAPI\r | |
225 | IoRead16 (\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 | |
248 | UINT16\r | |
249 | EFIAPI\r | |
250 | IoWrite16 (\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 | |
273 | UINT32\r | |
274 | EFIAPI\r | |
275 | IoRead32 (\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 | |
298 | UINT32\r | |
299 | EFIAPI\r | |
300 | IoWrite32 (\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 | |
324 | UINT64\r | |
325 | EFIAPI\r | |
326 | IoRead64 (\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 | |
350 | UINT64\r | |
351 | EFIAPI\r | |
352 | IoWrite64 (\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 | |
378 | VOID\r | |
379 | EFIAPI\r | |
380 | IoReadFifo8 (\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 | |
406 | VOID\r | |
407 | EFIAPI\r | |
408 | IoWriteFifo8 (\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 | |
434 | VOID\r | |
435 | EFIAPI\r | |
436 | IoReadFifo16 (\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 | |
462 | VOID\r | |
463 | EFIAPI\r | |
464 | IoWriteFifo16 (\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 | |
490 | VOID\r | |
491 | EFIAPI\r | |
492 | IoReadFifo32 (\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 | |
518 | VOID\r | |
519 | EFIAPI\r | |
520 | IoWriteFifo32 (\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 | |
543 | UINT8\r | |
544 | EFIAPI\r | |
545 | MmioRead8 (\r | |
546 | IN UINTN Address\r | |
547 | )\r | |
548 | {\r | |
38c8be12 DB |
549 | UINT8 Value;\r |
550 | BOOLEAN Flag;\r | |
551 | \r | |
552 | Flag = FilterBeforeMmIoRead (FilterWidth8, Address, &Value);\r | |
553 | if (Flag) {\r | |
554 | Value = MmioRead8Internal (Address);\r | |
555 | }\r | |
556 | FilterAfterMmIoRead (FilterWidth8, Address, &Value);\r | |
557 | \r | |
558 | return Value;\r | |
4134f2bd AB |
559 | }\r |
560 | \r | |
561 | /**\r | |
562 | Writes an 8-bit MMIO register.\r | |
563 | \r | |
564 | Writes the 8-bit MMIO register specified by Address with the value specified\r | |
565 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
566 | and write operations are serialized.\r | |
567 | \r | |
568 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
569 | \r | |
570 | @param Address The MMIO register to write.\r | |
571 | @param Value The value to write to the MMIO register.\r | |
572 | \r | |
573 | **/\r | |
574 | UINT8\r | |
575 | EFIAPI\r | |
576 | MmioWrite8 (\r | |
577 | IN UINTN Address,\r | |
578 | IN UINT8 Value\r | |
579 | )\r | |
580 | {\r | |
38c8be12 DB |
581 | BOOLEAN Flag;\r |
582 | \r | |
583 | Flag = FilterBeforeMmIoWrite (FilterWidth8, Address, &Value);\r | |
584 | if (Flag) {\r | |
585 | MmioWrite8Internal (Address, Value);\r | |
586 | }\r | |
587 | FilterAfterMmIoWrite (FilterWidth8, Address, &Value);\r | |
588 | \r | |
4134f2bd AB |
589 | return Value;\r |
590 | }\r | |
591 | \r | |
592 | /**\r | |
593 | Reads a 16-bit MMIO register.\r | |
594 | \r | |
595 | Reads the 16-bit MMIO register specified by Address. The 16-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 16-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 | |
606 | UINT16\r | |
607 | EFIAPI\r | |
608 | MmioRead16 (\r | |
609 | IN UINTN Address\r | |
610 | )\r | |
611 | {\r | |
38c8be12 DB |
612 | BOOLEAN Flag;\r |
613 | UINT16 Value;\r | |
614 | \r | |
4134f2bd AB |
615 | ASSERT ((Address & 1) == 0);\r |
616 | \r | |
38c8be12 DB |
617 | Flag = FilterBeforeMmIoRead (FilterWidth16, Address, &Value);\r |
618 | if (Flag) {\r | |
619 | Value = MmioRead16Internal (Address);\r | |
620 | }\r | |
621 | FilterAfterMmIoRead (FilterWidth16, Address, &Value);\r | |
622 | \r | |
623 | return Value;\r | |
4134f2bd AB |
624 | }\r |
625 | \r | |
626 | /**\r | |
627 | Writes a 16-bit MMIO register.\r | |
628 | \r | |
629 | Writes the 16-bit MMIO register specified by Address with the value specified\r | |
630 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
631 | and write operations are serialized.\r | |
632 | \r | |
633 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
634 | \r | |
635 | @param Address The MMIO register to write.\r | |
636 | @param Value The value to write to the MMIO register.\r | |
637 | \r | |
638 | **/\r | |
639 | UINT16\r | |
640 | EFIAPI\r | |
641 | MmioWrite16 (\r | |
642 | IN UINTN Address,\r | |
643 | IN UINT16 Value\r | |
644 | )\r | |
645 | {\r | |
38c8be12 DB |
646 | BOOLEAN Flag;\r |
647 | \r | |
4134f2bd AB |
648 | ASSERT ((Address & 1) == 0);\r |
649 | \r | |
38c8be12 DB |
650 | Flag = FilterBeforeMmIoWrite (FilterWidth16, Address, &Value);\r |
651 | if (Flag) {\r | |
652 | MmioWrite16Internal (Address, Value);\r | |
653 | }\r | |
654 | FilterAfterMmIoWrite (FilterWidth16, Address, &Value);\r | |
655 | \r | |
4134f2bd AB |
656 | return Value;\r |
657 | }\r | |
658 | \r | |
659 | /**\r | |
660 | Reads a 32-bit MMIO register.\r | |
661 | \r | |
662 | Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r | |
663 | returned. This function must guarantee that all MMIO read and write\r | |
664 | operations are serialized.\r | |
665 | \r | |
666 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
667 | \r | |
668 | @param Address The MMIO register to read.\r | |
669 | \r | |
670 | @return The value read.\r | |
671 | \r | |
672 | **/\r | |
673 | UINT32\r | |
674 | EFIAPI\r | |
675 | MmioRead32 (\r | |
676 | IN UINTN Address\r | |
677 | )\r | |
678 | {\r | |
38c8be12 DB |
679 | BOOLEAN Flag;\r |
680 | UINT32 Value;\r | |
681 | \r | |
4134f2bd AB |
682 | ASSERT ((Address & 3) == 0);\r |
683 | \r | |
38c8be12 DB |
684 | Flag = FilterBeforeMmIoRead (FilterWidth32, Address, &Value);\r |
685 | if (Flag) {\r | |
686 | Value = MmioRead32Internal (Address);\r | |
687 | }\r | |
688 | FilterAfterMmIoRead (FilterWidth32, Address, &Value);\r | |
689 | \r | |
690 | return Value;\r | |
4134f2bd AB |
691 | }\r |
692 | \r | |
693 | /**\r | |
694 | Writes a 32-bit MMIO register.\r | |
695 | \r | |
696 | Writes the 32-bit MMIO register specified by Address with the value specified\r | |
697 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
698 | and write operations are serialized.\r | |
699 | \r | |
700 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
701 | \r | |
702 | @param Address The MMIO register to write.\r | |
703 | @param Value The value to write to the MMIO register.\r | |
704 | \r | |
705 | **/\r | |
706 | UINT32\r | |
707 | EFIAPI\r | |
708 | MmioWrite32 (\r | |
709 | IN UINTN Address,\r | |
710 | IN UINT32 Value\r | |
711 | )\r | |
712 | {\r | |
38c8be12 DB |
713 | BOOLEAN Flag;\r |
714 | \r | |
4134f2bd AB |
715 | ASSERT ((Address & 3) == 0);\r |
716 | \r | |
38c8be12 DB |
717 | Flag = FilterBeforeMmIoWrite (FilterWidth32, Address, &Value);\r |
718 | if (Flag) {\r | |
719 | MmioWrite32Internal (Address, Value);\r | |
720 | }\r | |
721 | FilterAfterMmIoWrite (FilterWidth32, Address, &Value);\r | |
722 | \r | |
4134f2bd AB |
723 | return Value;\r |
724 | }\r | |
725 | \r | |
726 | /**\r | |
727 | Reads a 64-bit MMIO register.\r | |
728 | \r | |
729 | Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r | |
730 | returned. This function must guarantee that all MMIO read and write\r | |
731 | operations are serialized.\r | |
732 | \r | |
733 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
734 | \r | |
735 | @param Address The MMIO register to read.\r | |
736 | \r | |
737 | @return The value read.\r | |
738 | \r | |
739 | **/\r | |
740 | UINT64\r | |
741 | EFIAPI\r | |
742 | MmioRead64 (\r | |
743 | IN UINTN Address\r | |
744 | )\r | |
745 | {\r | |
38c8be12 DB |
746 | BOOLEAN Flag;\r |
747 | UINT64 Value;\r | |
748 | \r | |
4134f2bd AB |
749 | ASSERT ((Address & 7) == 0);\r |
750 | \r | |
38c8be12 DB |
751 | Flag = FilterBeforeMmIoRead (FilterWidth64, Address, &Value);\r |
752 | if (Flag) {\r | |
753 | Value = MmioRead64Internal (Address);\r | |
754 | }\r | |
755 | FilterAfterMmIoRead (FilterWidth64, Address, &Value);\r | |
756 | \r | |
757 | return Value;\r | |
4134f2bd AB |
758 | }\r |
759 | \r | |
760 | /**\r | |
761 | Writes a 64-bit MMIO register.\r | |
762 | \r | |
763 | Writes the 64-bit MMIO register specified by Address with the value specified\r | |
764 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
765 | and write operations are serialized.\r | |
766 | \r | |
767 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
768 | \r | |
769 | @param Address The MMIO register to write.\r | |
770 | @param Value The value to write to the MMIO register.\r | |
771 | \r | |
772 | **/\r | |
773 | UINT64\r | |
774 | EFIAPI\r | |
775 | MmioWrite64 (\r | |
776 | IN UINTN Address,\r | |
777 | IN UINT64 Value\r | |
778 | )\r | |
779 | {\r | |
38c8be12 DB |
780 | BOOLEAN Flag;\r |
781 | \r | |
4134f2bd AB |
782 | ASSERT ((Address & 7) == 0);\r |
783 | \r | |
38c8be12 DB |
784 | Flag = FilterBeforeMmIoWrite (FilterWidth64, Address, &Value);\r |
785 | if (Flag) {\r | |
786 | MmioWrite64Internal (Address, Value);\r | |
787 | }\r | |
788 | FilterAfterMmIoWrite (FilterWidth64, Address, &Value);\r | |
789 | \r | |
4134f2bd AB |
790 | return Value;\r |
791 | }\r |