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