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