BaseTools/Capsule: Do not support -o with --dump-info
[mirror_edk2.git] / IntelFrameworkPkg / Library / DxeIoLibCpuIo / IoHighLevel.c
1 /** @file
2 High-level Io/Mmio functions.
3
4 All assertions for bit field operations are handled bit field functions in the
5 Base Library.
6
7 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
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 Module Name: IoHighLevel.c
17
18 The following IoLib instances share the same version of this file:
19
20 BaseIoLibIntrinsic
21 DxeIoLibCpuIo
22 PeiIoLibCpuIo
23
24 **/
25
26
27 #include "DxeCpuIoLibInternal.h"
28
29 /**
30 Reads an 8-bit I/O port, performs a bitwise OR, and writes the
31 result back to the 8-bit I/O port.
32
33 Reads the 8-bit I/O port specified by Port, performs a bitwise OR
34 between the read result and the value specified by OrData, and writes the
35 result to the 8-bit I/O port specified by Port. The value written to the I/O
36 port is returned. This function must guarantee that all I/O read and write
37 operations are serialized.
38
39 If 8-bit I/O port operations are not supported, then ASSERT().
40
41 @param Port The I/O port to write.
42 @param OrData The value to OR with the read value from the I/O port.
43
44 @return The value written back to the I/O port.
45
46 **/
47 UINT8
48 EFIAPI
49 IoOr8 (
50 IN UINTN Port,
51 IN UINT8 OrData
52 )
53 {
54 return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData));
55 }
56
57 /**
58 Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back
59 to the 8-bit I/O port.
60
61 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
62 the read result and the value specified by AndData, and writes the result to
63 the 8-bit I/O port specified by Port. The value written to the I/O port is
64 returned. This function must guarantee that all I/O read and write operations
65 are serialized.
66
67 If 8-bit I/O port operations are not supported, then ASSERT().
68
69 @param Port The I/O port to write.
70 @param AndData The value to AND with the read value from the I/O port.
71
72 @return The value written back to the I/O port.
73
74 **/
75 UINT8
76 EFIAPI
77 IoAnd8 (
78 IN UINTN Port,
79 IN UINT8 AndData
80 )
81 {
82 return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData));
83 }
84
85 /**
86 Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise
87 inclusive OR, and writes the result back to the 8-bit I/O port.
88
89 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
90 the read result and the value specified by AndData, performs a bitwise OR
91 between the result of the AND operation and the value specified by OrData,
92 and writes the result to the 8-bit I/O port specified by Port. The value
93 written to the I/O port is returned. This function must guarantee that all
94 I/O read and write operations are serialized.
95
96 If 8-bit I/O port operations are not supported, then ASSERT().
97
98 @param Port The I/O port to write.
99 @param AndData The value to AND with the read value from the I/O port.
100 @param OrData The value to OR with the result of the AND operation.
101
102 @return The value written back to the I/O port.
103
104 **/
105 UINT8
106 EFIAPI
107 IoAndThenOr8 (
108 IN UINTN Port,
109 IN UINT8 AndData,
110 IN UINT8 OrData
111 )
112 {
113 return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData));
114 }
115
116 /**
117 Reads a bit field of an I/O register.
118
119 Reads the bit field in an 8-bit I/O register. The bit field is specified by
120 the StartBit and the EndBit. The value of the bit field is returned.
121
122 If 8-bit I/O port operations are not supported, then ASSERT().
123 If StartBit is greater than 7, then ASSERT().
124 If EndBit is greater than 7, then ASSERT().
125 If EndBit is less than StartBit, then ASSERT().
126
127 @param Port The I/O port to read.
128 @param StartBit The ordinal of the least significant bit in the bit field.
129 Range 0..7.
130 @param EndBit The ordinal of the most significant bit in the bit field.
131 Range 0..7.
132
133 @return The value read.
134
135 **/
136 UINT8
137 EFIAPI
138 IoBitFieldRead8 (
139 IN UINTN Port,
140 IN UINTN StartBit,
141 IN UINTN EndBit
142 )
143 {
144 return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit);
145 }
146
147 /**
148 Writes a bit field to an I/O register.
149
150 Writes Value to the bit field of the I/O register. The bit field is specified
151 by the StartBit and the EndBit. All other bits in the destination I/O
152 register are preserved. The value written to the I/O port is returned. Extra
153 left bits in Value are stripped.
154
155 If 8-bit I/O port operations are not supported, then ASSERT().
156 If StartBit is greater than 7, then ASSERT().
157 If EndBit is greater than 7, then ASSERT().
158 If EndBit is less than StartBit, then ASSERT().
159 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
160
161 @param Port The I/O port to write.
162 @param StartBit The ordinal of the least significant bit in the bit field.
163 Range 0..7.
164 @param EndBit The ordinal of the most significant bit in the bit field.
165 Range 0..7.
166 @param Value New value of the bit field.
167
168 @return The value written back to the I/O port.
169
170 **/
171 UINT8
172 EFIAPI
173 IoBitFieldWrite8 (
174 IN UINTN Port,
175 IN UINTN StartBit,
176 IN UINTN EndBit,
177 IN UINT8 Value
178 )
179 {
180 return IoWrite8 (
181 Port,
182 BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value)
183 );
184 }
185
186 /**
187 Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the
188 result back to the bit field in the 8-bit port.
189
190 Reads the 8-bit I/O port specified by Port, performs a bitwise OR
191 between the read result and the value specified by OrData, and writes the
192 result to the 8-bit I/O port specified by Port. The value written to the I/O
193 port is returned. This function must guarantee that all I/O read and write
194 operations are serialized. Extra left bits in OrData are stripped.
195
196 If 8-bit I/O port operations are not supported, then ASSERT().
197 If StartBit is greater than 7, then ASSERT().
198 If EndBit is greater than 7, then ASSERT().
199 If EndBit is less than StartBit, then ASSERT().
200 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
201
202 @param Port The I/O port to write.
203 @param StartBit The ordinal of the least significant bit in the bit field.
204 Range 0..7.
205 @param EndBit The ordinal of the most significant bit in the bit field.
206 Range 0..7.
207 @param OrData The value to OR with the read value from the I/O port.
208
209 @return The value written back to the I/O port.
210
211 **/
212 UINT8
213 EFIAPI
214 IoBitFieldOr8 (
215 IN UINTN Port,
216 IN UINTN StartBit,
217 IN UINTN EndBit,
218 IN UINT8 OrData
219 )
220 {
221 return IoWrite8 (
222 Port,
223 BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData)
224 );
225 }
226
227 /**
228 Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the
229 result back to the bit field in the 8-bit port.
230
231 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
232 the read result and the value specified by AndData, and writes the result to
233 the 8-bit I/O port specified by Port. The value written to the I/O port is
234 returned. This function must guarantee that all I/O read and write operations
235 are serialized. Extra left bits in AndData are stripped.
236
237 If 8-bit I/O port operations are not supported, then ASSERT().
238 If StartBit is greater than 7, then ASSERT().
239 If EndBit is greater than 7, then ASSERT().
240 If EndBit is less than StartBit, then ASSERT().
241 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
242
243 @param Port The I/O port to write.
244 @param StartBit The ordinal of the least significant bit in the bit field.
245 Range 0..7.
246 @param EndBit The ordinal of the most significant bit in the bit field.
247 Range 0..7.
248 @param AndData The value to AND with the read value from the I/O port.
249
250 @return The value written back to the I/O port.
251
252 **/
253 UINT8
254 EFIAPI
255 IoBitFieldAnd8 (
256 IN UINTN Port,
257 IN UINTN StartBit,
258 IN UINTN EndBit,
259 IN UINT8 AndData
260 )
261 {
262 return IoWrite8 (
263 Port,
264 BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData)
265 );
266 }
267
268 /**
269 Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
270 bitwise OR, and writes the result back to the bit field in the
271 8-bit port.
272
273 Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed
274 by a bitwise OR between the read result and the value specified by
275 AndData, and writes the result to the 8-bit I/O port specified by Port. The
276 value written to the I/O port is returned. This function must guarantee that
277 all I/O read and write operations are serialized. Extra left bits in both
278 AndData and OrData are stripped.
279
280 If 8-bit I/O port operations are not supported, then ASSERT().
281 If StartBit is greater than 7, then ASSERT().
282 If EndBit is greater than 7, then ASSERT().
283 If EndBit is less than StartBit, then ASSERT().
284 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
285 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
286
287 @param Port The I/O port to write.
288 @param StartBit The ordinal of the least significant bit in the bit field.
289 Range 0..7.
290 @param EndBit The ordinal of the most significant bit in the bit field.
291 Range 0..7.
292 @param AndData The value to AND with the read value from the I/O port.
293 @param OrData The value to OR with the result of the AND operation.
294
295 @return The value written back to the I/O port.
296
297 **/
298 UINT8
299 EFIAPI
300 IoBitFieldAndThenOr8 (
301 IN UINTN Port,
302 IN UINTN StartBit,
303 IN UINTN EndBit,
304 IN UINT8 AndData,
305 IN UINT8 OrData
306 )
307 {
308 return IoWrite8 (
309 Port,
310 BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData)
311 );
312 }
313
314 /**
315 Reads a 16-bit I/O port, performs a bitwise OR, and writes the
316 result back to the 16-bit I/O port.
317
318 Reads the 16-bit I/O port specified by Port, performs a bitwise OR
319 between the read result and the value specified by OrData, and writes the
320 result to the 16-bit I/O port specified by Port. The value written to the I/O
321 port is returned. This function must guarantee that all I/O read and write
322 operations are serialized.
323
324 If 16-bit I/O port operations are not supported, then ASSERT().
325
326 @param Port The I/O port to write.
327 @param OrData The value to OR with the read value from the I/O port.
328
329 @return The value written back to the I/O port.
330
331 **/
332 UINT16
333 EFIAPI
334 IoOr16 (
335 IN UINTN Port,
336 IN UINT16 OrData
337 )
338 {
339 return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData));
340 }
341
342 /**
343 Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back
344 to the 16-bit I/O port.
345
346 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
347 the read result and the value specified by AndData, and writes the result to
348 the 16-bit I/O port specified by Port. The value written to the I/O port is
349 returned. This function must guarantee that all I/O read and write operations
350 are serialized.
351
352 If 16-bit I/O port operations are not supported, then ASSERT().
353
354 @param Port The I/O port to write.
355 @param AndData The value to AND with the read value from the I/O port.
356
357 @return The value written back to the I/O port.
358
359 **/
360 UINT16
361 EFIAPI
362 IoAnd16 (
363 IN UINTN Port,
364 IN UINT16 AndData
365 )
366 {
367 return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData));
368 }
369
370 /**
371 Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise
372 inclusive OR, and writes the result back to the 16-bit I/O port.
373
374 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
375 the read result and the value specified by AndData, performs a bitwise OR
376 between the result of the AND operation and the value specified by OrData,
377 and writes the result to the 16-bit I/O port specified by Port. The value
378 written to the I/O port is returned. This function must guarantee that all
379 I/O read and write operations are serialized.
380
381 If 16-bit I/O port operations are not supported, then ASSERT().
382
383 @param Port The I/O port to write.
384 @param AndData The value to AND with the read value from the I/O port.
385 @param OrData The value to OR with the result of the AND operation.
386
387 @return The value written back to the I/O port.
388
389 **/
390 UINT16
391 EFIAPI
392 IoAndThenOr16 (
393 IN UINTN Port,
394 IN UINT16 AndData,
395 IN UINT16 OrData
396 )
397 {
398 return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData));
399 }
400
401 /**
402 Reads a bit field of an I/O register.
403
404 Reads the bit field in a 16-bit I/O register. The bit field is specified by
405 the StartBit and the EndBit. The value of the bit field is returned.
406
407 If 16-bit I/O port operations are not supported, then ASSERT().
408 If StartBit is greater than 15, then ASSERT().
409 If EndBit is greater than 15, then ASSERT().
410 If EndBit is less than StartBit, then ASSERT().
411
412 @param Port The I/O port to read.
413 @param StartBit The ordinal of the least significant bit in the bit field.
414 Range 0..15.
415 @param EndBit The ordinal of the most significant bit in the bit field.
416 Range 0..15.
417
418 @return The value read.
419
420 **/
421 UINT16
422 EFIAPI
423 IoBitFieldRead16 (
424 IN UINTN Port,
425 IN UINTN StartBit,
426 IN UINTN EndBit
427 )
428 {
429 return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit);
430 }
431
432 /**
433 Writes a bit field to an I/O register.
434
435 Writes Value to the bit field of the I/O register. The bit field is specified
436 by the StartBit and the EndBit. All other bits in the destination I/O
437 register are preserved. The value written to the I/O port is returned. Extra
438 left bits in Value are stripped.
439
440 If 16-bit I/O port operations are not supported, then ASSERT().
441 If StartBit is greater than 15, then ASSERT().
442 If EndBit is greater than 15, then ASSERT().
443 If EndBit is less than StartBit, then ASSERT().
444 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
445
446 @param Port The I/O port to write.
447 @param StartBit The ordinal of the least significant bit in the bit field.
448 Range 0..15.
449 @param EndBit The ordinal of the most significant bit in the bit field.
450 Range 0..15.
451 @param Value New value of the bit field.
452
453 @return The value written back to the I/O port.
454
455 **/
456 UINT16
457 EFIAPI
458 IoBitFieldWrite16 (
459 IN UINTN Port,
460 IN UINTN StartBit,
461 IN UINTN EndBit,
462 IN UINT16 Value
463 )
464 {
465 return IoWrite16 (
466 Port,
467 BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value)
468 );
469 }
470
471 /**
472 Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the
473 result back to the bit field in the 16-bit port.
474
475 Reads the 16-bit I/O port specified by Port, performs a bitwise OR
476 between the read result and the value specified by OrData, and writes the
477 result to the 16-bit I/O port specified by Port. The value written to the I/O
478 port is returned. This function must guarantee that all I/O read and write
479 operations are serialized. Extra left bits in OrData are stripped.
480
481 If 16-bit I/O port operations are not supported, then ASSERT().
482 If StartBit is greater than 15, then ASSERT().
483 If EndBit is greater than 15, then ASSERT().
484 If EndBit is less than StartBit, then ASSERT().
485 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
486
487 @param Port The I/O port to write.
488 @param StartBit The ordinal of the least significant bit in the bit field.
489 Range 0..15.
490 @param EndBit The ordinal of the most significant bit in the bit field.
491 Range 0..15.
492 @param OrData The value to OR with the read value from the I/O port.
493
494 @return The value written back to the I/O port.
495
496 **/
497 UINT16
498 EFIAPI
499 IoBitFieldOr16 (
500 IN UINTN Port,
501 IN UINTN StartBit,
502 IN UINTN EndBit,
503 IN UINT16 OrData
504 )
505 {
506 return IoWrite16 (
507 Port,
508 BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData)
509 );
510 }
511
512 /**
513 Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the
514 result back to the bit field in the 16-bit port.
515
516 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
517 the read result and the value specified by AndData, and writes the result to
518 the 16-bit I/O port specified by Port. The value written to the I/O port is
519 returned. This function must guarantee that all I/O read and write operations
520 are serialized. Extra left bits in AndData are stripped.
521
522 If 16-bit I/O port operations are not supported, then ASSERT().
523 If StartBit is greater than 15, then ASSERT().
524 If EndBit is greater than 15, then ASSERT().
525 If EndBit is less than StartBit, then ASSERT().
526 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
527
528 @param Port The I/O port to write.
529 @param StartBit The ordinal of the least significant bit in the bit field.
530 Range 0..15.
531 @param EndBit The ordinal of the most significant bit in the bit field.
532 Range 0..15.
533 @param AndData The value to AND with the read value from the I/O port.
534
535 @return The value written back to the I/O port.
536
537 **/
538 UINT16
539 EFIAPI
540 IoBitFieldAnd16 (
541 IN UINTN Port,
542 IN UINTN StartBit,
543 IN UINTN EndBit,
544 IN UINT16 AndData
545 )
546 {
547 return IoWrite16 (
548 Port,
549 BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData)
550 );
551 }
552
553 /**
554 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
555 bitwise OR, and writes the result back to the bit field in the
556 16-bit port.
557
558 Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed
559 by a bitwise OR between the read result and the value specified by
560 AndData, and writes the result to the 16-bit I/O port specified by Port. The
561 value written to the I/O port is returned. This function must guarantee that
562 all I/O read and write operations are serialized. Extra left bits in both
563 AndData and OrData are stripped.
564
565 If 16-bit I/O port operations are not supported, then ASSERT().
566 If StartBit is greater than 15, then ASSERT().
567 If EndBit is greater than 15, then ASSERT().
568 If EndBit is less than StartBit, then ASSERT().
569 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
570 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
571
572 @param Port The I/O port to write.
573 @param StartBit The ordinal of the least significant bit in the bit field.
574 Range 0..15.
575 @param EndBit The ordinal of the most significant bit in the bit field.
576 Range 0..15.
577 @param AndData The value to AND with the read value from the I/O port.
578 @param OrData The value to OR with the result of the AND operation.
579
580 @return The value written back to the I/O port.
581
582 **/
583 UINT16
584 EFIAPI
585 IoBitFieldAndThenOr16 (
586 IN UINTN Port,
587 IN UINTN StartBit,
588 IN UINTN EndBit,
589 IN UINT16 AndData,
590 IN UINT16 OrData
591 )
592 {
593 return IoWrite16 (
594 Port,
595 BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData)
596 );
597 }
598
599 /**
600 Reads a 32-bit I/O port, performs a bitwise OR, and writes the
601 result back to the 32-bit I/O port.
602
603 Reads the 32-bit I/O port specified by Port, performs a bitwise OR
604 between the read result and the value specified by OrData, and writes the
605 result to the 32-bit I/O port specified by Port. The value written to the I/O
606 port is returned. This function must guarantee that all I/O read and write
607 operations are serialized.
608
609 If 32-bit I/O port operations are not supported, then ASSERT().
610
611 @param Port The I/O port to write.
612 @param OrData The value to OR with the read value from the I/O port.
613
614 @return The value written back to the I/O port.
615
616 **/
617 UINT32
618 EFIAPI
619 IoOr32 (
620 IN UINTN Port,
621 IN UINT32 OrData
622 )
623 {
624 return IoWrite32 (Port, IoRead32 (Port) | OrData);
625 }
626
627 /**
628 Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back
629 to the 32-bit I/O port.
630
631 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
632 the read result and the value specified by AndData, and writes the result to
633 the 32-bit I/O port specified by Port. The value written to the I/O port is
634 returned. This function must guarantee that all I/O read and write operations
635 are serialized.
636
637 If 32-bit I/O port operations are not supported, then ASSERT().
638
639 @param Port The I/O port to write.
640 @param AndData The value to AND with the read value from the I/O port.
641
642 @return The value written back to the I/O port.
643
644 **/
645 UINT32
646 EFIAPI
647 IoAnd32 (
648 IN UINTN Port,
649 IN UINT32 AndData
650 )
651 {
652 return IoWrite32 (Port, IoRead32 (Port) & AndData);
653 }
654
655 /**
656 Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise
657 inclusive OR, and writes the result back to the 32-bit I/O port.
658
659 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
660 the read result and the value specified by AndData, performs a bitwise OR
661 between the result of the AND operation and the value specified by OrData,
662 and writes the result to the 32-bit I/O port specified by Port. The value
663 written to the I/O port is returned. This function must guarantee that all
664 I/O read and write operations are serialized.
665
666 If 32-bit I/O port operations are not supported, then ASSERT().
667
668 @param Port The I/O port to write.
669 @param AndData The value to AND with the read value from the I/O port.
670 @param OrData The value to OR with the result of the AND operation.
671
672 @return The value written back to the I/O port.
673
674 **/
675 UINT32
676 EFIAPI
677 IoAndThenOr32 (
678 IN UINTN Port,
679 IN UINT32 AndData,
680 IN UINT32 OrData
681 )
682 {
683 return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData);
684 }
685
686 /**
687 Reads a bit field of an I/O register.
688
689 Reads the bit field in a 32-bit I/O register. The bit field is specified by
690 the StartBit and the EndBit. The value of the bit field is returned.
691
692 If 32-bit I/O port operations are not supported, then ASSERT().
693 If StartBit is greater than 31, then ASSERT().
694 If EndBit is greater than 31, then ASSERT().
695 If EndBit is less than StartBit, then ASSERT().
696
697 @param Port The I/O port to read.
698 @param StartBit The ordinal of the least significant bit in the bit field.
699 Range 0..31.
700 @param EndBit The ordinal of the most significant bit in the bit field.
701 Range 0..31.
702
703 @return The value read.
704
705 **/
706 UINT32
707 EFIAPI
708 IoBitFieldRead32 (
709 IN UINTN Port,
710 IN UINTN StartBit,
711 IN UINTN EndBit
712 )
713 {
714 return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit);
715 }
716
717 /**
718 Writes a bit field to an I/O register.
719
720 Writes Value to the bit field of the I/O register. The bit field is specified
721 by the StartBit and the EndBit. All other bits in the destination I/O
722 register are preserved. The value written to the I/O port is returned. Extra
723 left bits in Value are stripped.
724
725 If 32-bit I/O port operations are not supported, then ASSERT().
726 If StartBit is greater than 31, then ASSERT().
727 If EndBit is greater than 31, then ASSERT().
728 If EndBit is less than StartBit, then ASSERT().
729 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
730
731 @param Port The I/O port to write.
732 @param StartBit The ordinal of the least significant bit in the bit field.
733 Range 0..31.
734 @param EndBit The ordinal of the most significant bit in the bit field.
735 Range 0..31.
736 @param Value New value of the bit field.
737
738 @return The value written back to the I/O port.
739
740 **/
741 UINT32
742 EFIAPI
743 IoBitFieldWrite32 (
744 IN UINTN Port,
745 IN UINTN StartBit,
746 IN UINTN EndBit,
747 IN UINT32 Value
748 )
749 {
750 return IoWrite32 (
751 Port,
752 BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value)
753 );
754 }
755
756 /**
757 Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the
758 result back to the bit field in the 32-bit port.
759
760 Reads the 32-bit I/O port specified by Port, performs a bitwise OR
761 between the read result and the value specified by OrData, and writes the
762 result to the 32-bit I/O port specified by Port. The value written to the I/O
763 port is returned. This function must guarantee that all I/O read and write
764 operations are serialized. Extra left bits in OrData are stripped.
765
766 If 32-bit I/O port operations are not supported, then ASSERT().
767 If StartBit is greater than 31, then ASSERT().
768 If EndBit is greater than 31, then ASSERT().
769 If EndBit is less than StartBit, then ASSERT().
770 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
771
772 @param Port The I/O port to write.
773 @param StartBit The ordinal of the least significant bit in the bit field.
774 Range 0..31.
775 @param EndBit The ordinal of the most significant bit in the bit field.
776 Range 0..31.
777 @param OrData The value to OR with the read value from the I/O port.
778
779 @return The value written back to the I/O port.
780
781 **/
782 UINT32
783 EFIAPI
784 IoBitFieldOr32 (
785 IN UINTN Port,
786 IN UINTN StartBit,
787 IN UINTN EndBit,
788 IN UINT32 OrData
789 )
790 {
791 return IoWrite32 (
792 Port,
793 BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData)
794 );
795 }
796
797 /**
798 Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the
799 result back to the bit field in the 32-bit port.
800
801 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
802 the read result and the value specified by AndData, and writes the result to
803 the 32-bit I/O port specified by Port. The value written to the I/O port is
804 returned. This function must guarantee that all I/O read and write operations
805 are serialized. Extra left bits in AndData are stripped.
806
807 If 32-bit I/O port operations are not supported, then ASSERT().
808 If StartBit is greater than 31, then ASSERT().
809 If EndBit is greater than 31, then ASSERT().
810 If EndBit is less than StartBit, then ASSERT().
811 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
812
813 @param Port The I/O port to write.
814 @param StartBit The ordinal of the least significant bit in the bit field.
815 Range 0..31.
816 @param EndBit The ordinal of the most significant bit in the bit field.
817 Range 0..31.
818 @param AndData The value to AND with the read value from the I/O port.
819
820 @return The value written back to the I/O port.
821
822 **/
823 UINT32
824 EFIAPI
825 IoBitFieldAnd32 (
826 IN UINTN Port,
827 IN UINTN StartBit,
828 IN UINTN EndBit,
829 IN UINT32 AndData
830 )
831 {
832 return IoWrite32 (
833 Port,
834 BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData)
835 );
836 }
837
838 /**
839 Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
840 bitwise OR, and writes the result back to the bit field in the
841 32-bit port.
842
843 Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed
844 by a bitwise OR between the read result and the value specified by
845 AndData, and writes the result to the 32-bit I/O port specified by Port. The
846 value written to the I/O port is returned. This function must guarantee that
847 all I/O read and write operations are serialized. Extra left bits in both
848 AndData and OrData are stripped.
849
850 If 32-bit I/O port operations are not supported, then ASSERT().
851 If StartBit is greater than 31, then ASSERT().
852 If EndBit is greater than 31, then ASSERT().
853 If EndBit is less than StartBit, then ASSERT().
854 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
855 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
856
857 @param Port The I/O port to write.
858 @param StartBit The ordinal of the least significant bit in the bit field.
859 Range 0..31.
860 @param EndBit The ordinal of the most significant bit in the bit field.
861 Range 0..31.
862 @param AndData The value to AND with the read value from the I/O port.
863 @param OrData The value to OR with the result of the AND operation.
864
865 @return The value written back to the I/O port.
866
867 **/
868 UINT32
869 EFIAPI
870 IoBitFieldAndThenOr32 (
871 IN UINTN Port,
872 IN UINTN StartBit,
873 IN UINTN EndBit,
874 IN UINT32 AndData,
875 IN UINT32 OrData
876 )
877 {
878 return IoWrite32 (
879 Port,
880 BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData)
881 );
882 }
883
884 /**
885 Reads a 64-bit I/O port, performs a bitwise OR, and writes the
886 result back to the 64-bit I/O port.
887
888 Reads the 64-bit I/O port specified by Port, performs a bitwise OR
889 between the read result and the value specified by OrData, and writes the
890 result to the 64-bit I/O port specified by Port. The value written to the I/O
891 port is returned. This function must guarantee that all I/O read and write
892 operations are serialized.
893
894 If 64-bit I/O port operations are not supported, then ASSERT().
895
896 @param Port The I/O port to write.
897 @param OrData The value to OR with the read value from the I/O port.
898
899 @return The value written back to the I/O port.
900
901 **/
902 UINT64
903 EFIAPI
904 IoOr64 (
905 IN UINTN Port,
906 IN UINT64 OrData
907 )
908 {
909 return IoWrite64 (Port, IoRead64 (Port) | OrData);
910 }
911
912 /**
913 Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back
914 to the 64-bit I/O port.
915
916 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
917 the read result and the value specified by AndData, and writes the result to
918 the 64-bit I/O port specified by Port. The value written to the I/O port is
919 returned. This function must guarantee that all I/O read and write operations
920 are serialized.
921
922 If 64-bit I/O port operations are not supported, then ASSERT().
923
924 @param Port The I/O port to write.
925 @param AndData The value to AND with the read value from the I/O port.
926
927 @return The value written back to the I/O port.
928
929 **/
930 UINT64
931 EFIAPI
932 IoAnd64 (
933 IN UINTN Port,
934 IN UINT64 AndData
935 )
936 {
937 return IoWrite64 (Port, IoRead64 (Port) & AndData);
938 }
939
940 /**
941 Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise
942 inclusive OR, and writes the result back to the 64-bit I/O port.
943
944 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
945 the read result and the value specified by AndData, performs a bitwise OR
946 between the result of the AND operation and the value specified by OrData,
947 and writes the result to the 64-bit I/O port specified by Port. The value
948 written to the I/O port is returned. This function must guarantee that all
949 I/O read and write operations are serialized.
950
951 If 64-bit I/O port operations are not supported, then ASSERT().
952
953 @param Port The I/O port to write.
954 @param AndData The value to AND with the read value from the I/O port.
955 @param OrData The value to OR with the result of the AND operation.
956
957 @return The value written back to the I/O port.
958
959 **/
960 UINT64
961 EFIAPI
962 IoAndThenOr64 (
963 IN UINTN Port,
964 IN UINT64 AndData,
965 IN UINT64 OrData
966 )
967 {
968 return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData);
969 }
970
971 /**
972 Reads a bit field of an I/O register.
973
974 Reads the bit field in a 64-bit I/O register. The bit field is specified by
975 the StartBit and the EndBit. The value of the bit field is returned.
976
977 If 64-bit I/O port operations are not supported, then ASSERT().
978 If StartBit is greater than 63, then ASSERT().
979 If EndBit is greater than 63, then ASSERT().
980 If EndBit is less than StartBit, then ASSERT().
981
982 @param Port The I/O port to read.
983 @param StartBit The ordinal of the least significant bit in the bit field.
984 Range 0..63.
985 @param EndBit The ordinal of the most significant bit in the bit field.
986 Range 0..63.
987
988 @return The value read.
989
990 **/
991 UINT64
992 EFIAPI
993 IoBitFieldRead64 (
994 IN UINTN Port,
995 IN UINTN StartBit,
996 IN UINTN EndBit
997 )
998 {
999 return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit);
1000 }
1001
1002 /**
1003 Writes a bit field to an I/O register.
1004
1005 Writes Value to the bit field of the I/O register. The bit field is specified
1006 by the StartBit and the EndBit. All other bits in the destination I/O
1007 register are preserved. The value written to the I/O port is returned. Extra
1008 left bits in Value are stripped.
1009
1010 If 64-bit I/O port operations are not supported, then ASSERT().
1011 If StartBit is greater than 63, then ASSERT().
1012 If EndBit is greater than 63, then ASSERT().
1013 If EndBit is less than StartBit, then ASSERT().
1014 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1015
1016 @param Port The I/O port to write.
1017 @param StartBit The ordinal of the least significant bit in the bit field.
1018 Range 0..63.
1019 @param EndBit The ordinal of the most significant bit in the bit field.
1020 Range 0..63.
1021 @param Value New value of the bit field.
1022
1023 @return The value written back to the I/O port.
1024
1025 **/
1026 UINT64
1027 EFIAPI
1028 IoBitFieldWrite64 (
1029 IN UINTN Port,
1030 IN UINTN StartBit,
1031 IN UINTN EndBit,
1032 IN UINT64 Value
1033 )
1034 {
1035 return IoWrite64 (
1036 Port,
1037 BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value)
1038 );
1039 }
1040
1041 /**
1042 Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the
1043 result back to the bit field in the 64-bit port.
1044
1045 Reads the 64-bit I/O port specified by Port, performs a bitwise OR
1046 between the read result and the value specified by OrData, and writes the
1047 result to the 64-bit I/O port specified by Port. The value written to the I/O
1048 port is returned. This function must guarantee that all I/O read and write
1049 operations are serialized. Extra left bits in OrData are stripped.
1050
1051 If 64-bit I/O port operations are not supported, then ASSERT().
1052 If StartBit is greater than 63, then ASSERT().
1053 If EndBit is greater than 63, then ASSERT().
1054 If EndBit is less than StartBit, then ASSERT().
1055 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1056
1057 @param Port The I/O port to write.
1058 @param StartBit The ordinal of the least significant bit in the bit field.
1059 Range 0..63.
1060 @param EndBit The ordinal of the most significant bit in the bit field.
1061 Range 0..63.
1062 @param OrData The value to OR with the read value from the I/O port.
1063
1064 @return The value written back to the I/O port.
1065
1066 **/
1067 UINT64
1068 EFIAPI
1069 IoBitFieldOr64 (
1070 IN UINTN Port,
1071 IN UINTN StartBit,
1072 IN UINTN EndBit,
1073 IN UINT64 OrData
1074 )
1075 {
1076 return IoWrite64 (
1077 Port,
1078 BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData)
1079 );
1080 }
1081
1082 /**
1083 Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the
1084 result back to the bit field in the 64-bit port.
1085
1086 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
1087 the read result and the value specified by AndData, and writes the result to
1088 the 64-bit I/O port specified by Port. The value written to the I/O port is
1089 returned. This function must guarantee that all I/O read and write operations
1090 are serialized. Extra left bits in AndData are stripped.
1091
1092 If 64-bit I/O port operations are not supported, then ASSERT().
1093 If StartBit is greater than 63, then ASSERT().
1094 If EndBit is greater than 63, then ASSERT().
1095 If EndBit is less than StartBit, then ASSERT().
1096 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1097
1098 @param Port The I/O port to write.
1099 @param StartBit The ordinal of the least significant bit in the bit field.
1100 Range 0..63.
1101 @param EndBit The ordinal of the most significant bit in the bit field.
1102 Range 0..63.
1103 @param AndData The value to AND with the read value from the I/O port.
1104
1105 @return The value written back to the I/O port.
1106
1107 **/
1108 UINT64
1109 EFIAPI
1110 IoBitFieldAnd64 (
1111 IN UINTN Port,
1112 IN UINTN StartBit,
1113 IN UINTN EndBit,
1114 IN UINT64 AndData
1115 )
1116 {
1117 return IoWrite64 (
1118 Port,
1119 BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData)
1120 );
1121 }
1122
1123 /**
1124 Reads a bit field in a 64-bit port, performs a bitwise AND followed by a
1125 bitwise OR, and writes the result back to the bit field in the
1126 64-bit port.
1127
1128 Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed
1129 by a bitwise OR between the read result and the value specified by
1130 AndData, and writes the result to the 64-bit I/O port specified by Port. The
1131 value written to the I/O port is returned. This function must guarantee that
1132 all I/O read and write operations are serialized. Extra left bits in both
1133 AndData and OrData are stripped.
1134
1135 If 64-bit I/O port operations are not supported, then ASSERT().
1136 If StartBit is greater than 63, then ASSERT().
1137 If EndBit is greater than 63, then ASSERT().
1138 If EndBit is less than StartBit, then ASSERT().
1139 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1140 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1141
1142 @param Port The I/O port to write.
1143 @param StartBit The ordinal of the least significant bit in the bit field.
1144 Range 0..63.
1145 @param EndBit The ordinal of the most significant bit in the bit field.
1146 Range 0..63.
1147 @param AndData The value to AND with the read value from the I/O port.
1148 @param OrData The value to OR with the result of the AND operation.
1149
1150 @return The value written back to the I/O port.
1151
1152 **/
1153 UINT64
1154 EFIAPI
1155 IoBitFieldAndThenOr64 (
1156 IN UINTN Port,
1157 IN UINTN StartBit,
1158 IN UINTN EndBit,
1159 IN UINT64 AndData,
1160 IN UINT64 OrData
1161 )
1162 {
1163 return IoWrite64 (
1164 Port,
1165 BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData)
1166 );
1167 }
1168
1169 /**
1170 Reads an 8-bit MMIO register, performs a bitwise OR, and writes the
1171 result back to the 8-bit MMIO register.
1172
1173 Reads the 8-bit MMIO register specified by Address, performs a bitwise
1174 inclusive OR between the read result and the value specified by OrData, and
1175 writes the result to the 8-bit MMIO register specified by Address. The value
1176 written to the MMIO register is returned. This function must guarantee that
1177 all MMIO read and write operations are serialized.
1178
1179 If 8-bit MMIO register operations are not supported, then ASSERT().
1180
1181 @param Address The MMIO register to write.
1182 @param OrData The value to OR with the read value from the MMIO register.
1183
1184 @return The value written back to the MMIO register.
1185
1186 **/
1187 UINT8
1188 EFIAPI
1189 MmioOr8 (
1190 IN UINTN Address,
1191 IN UINT8 OrData
1192 )
1193 {
1194 return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData));
1195 }
1196
1197 /**
1198 Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result
1199 back to the 8-bit MMIO register.
1200
1201 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1202 between the read result and the value specified by AndData, and writes the
1203 result to the 8-bit MMIO register specified by Address. The value written to
1204 the MMIO register is returned. This function must guarantee that all MMIO
1205 read and write operations are serialized.
1206
1207 If 8-bit MMIO register operations are not supported, then ASSERT().
1208
1209 @param Address The MMIO register to write.
1210 @param AndData The value to AND with the read value from the MMIO register.
1211
1212 @return The value written back to the MMIO register.
1213
1214 **/
1215 UINT8
1216 EFIAPI
1217 MmioAnd8 (
1218 IN UINTN Address,
1219 IN UINT8 AndData
1220 )
1221 {
1222 return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData));
1223 }
1224
1225 /**
1226 Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise
1227 inclusive OR, and writes the result back to the 8-bit MMIO register.
1228
1229 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1230 between the read result and the value specified by AndData, performs a
1231 bitwise OR between the result of the AND operation and the value specified by
1232 OrData, and writes the result to the 8-bit MMIO register specified by
1233 Address. The value written to the MMIO register is returned. This function
1234 must guarantee that all MMIO read and write operations are serialized.
1235
1236 If 8-bit MMIO register operations are not supported, then ASSERT().
1237
1238
1239 @param Address The MMIO register to write.
1240 @param AndData The value to AND with the read value from the MMIO register.
1241 @param OrData The value to OR with the result of the AND operation.
1242
1243 @return The value written back to the MMIO register.
1244
1245 **/
1246 UINT8
1247 EFIAPI
1248 MmioAndThenOr8 (
1249 IN UINTN Address,
1250 IN UINT8 AndData,
1251 IN UINT8 OrData
1252 )
1253 {
1254 return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData));
1255 }
1256
1257 /**
1258 Reads a bit field of a MMIO register.
1259
1260 Reads the bit field in an 8-bit MMIO register. The bit field is specified by
1261 the StartBit and the EndBit. The value of the bit field is returned.
1262
1263 If 8-bit MMIO register operations are not supported, then ASSERT().
1264 If StartBit is greater than 7, then ASSERT().
1265 If EndBit is greater than 7, then ASSERT().
1266 If EndBit is less than StartBit, then ASSERT().
1267
1268 @param Address MMIO register to read.
1269 @param StartBit The ordinal of the least significant bit in the bit field.
1270 Range 0..7.
1271 @param EndBit The ordinal of the most significant bit in the bit field.
1272 Range 0..7.
1273
1274 @return The value read.
1275
1276 **/
1277 UINT8
1278 EFIAPI
1279 MmioBitFieldRead8 (
1280 IN UINTN Address,
1281 IN UINTN StartBit,
1282 IN UINTN EndBit
1283 )
1284 {
1285 return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit);
1286 }
1287
1288 /**
1289 Writes a bit field to a MMIO register.
1290
1291 Writes Value to the bit field of the MMIO register. The bit field is
1292 specified by the StartBit and the EndBit. All other bits in the destination
1293 MMIO register are preserved. The new value of the 8-bit register is returned.
1294
1295 If 8-bit MMIO register operations are not supported, then ASSERT().
1296 If StartBit is greater than 7, then ASSERT().
1297 If EndBit is greater than 7, then ASSERT().
1298 If EndBit is less than StartBit, then ASSERT().
1299 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1300
1301 @param Address MMIO register to write.
1302 @param StartBit The ordinal of the least significant bit in the bit field.
1303 Range 0..7.
1304 @param EndBit The ordinal of the most significant bit in the bit field.
1305 Range 0..7.
1306 @param Value New value of the bit field.
1307
1308 @return The value written back to the MMIO register.
1309
1310 **/
1311 UINT8
1312 EFIAPI
1313 MmioBitFieldWrite8 (
1314 IN UINTN Address,
1315 IN UINTN StartBit,
1316 IN UINTN EndBit,
1317 IN UINT8 Value
1318 )
1319 {
1320 return MmioWrite8 (
1321 Address,
1322 BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value)
1323 );
1324 }
1325
1326 /**
1327 Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and
1328 writes the result back to the bit field in the 8-bit MMIO register.
1329
1330 Reads the 8-bit MMIO register specified by Address, performs a bitwise
1331 inclusive OR between the read result and the value specified by OrData, and
1332 writes the result to the 8-bit MMIO register specified by Address. The value
1333 written to the MMIO register is returned. This function must guarantee that
1334 all MMIO read and write operations are serialized. Extra left bits in OrData
1335 are stripped.
1336
1337 If 8-bit MMIO register operations are not supported, then ASSERT().
1338 If StartBit is greater than 7, then ASSERT().
1339 If EndBit is greater than 7, then ASSERT().
1340 If EndBit is less than StartBit, then ASSERT().
1341 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1342
1343 @param Address MMIO register to write.
1344 @param StartBit The ordinal of the least significant bit in the bit field.
1345 Range 0..7.
1346 @param EndBit The ordinal of the most significant bit in the bit field.
1347 Range 0..7.
1348 @param OrData The value to OR with read value from the MMIO register.
1349
1350 @return The value written back to the MMIO register.
1351
1352 **/
1353 UINT8
1354 EFIAPI
1355 MmioBitFieldOr8 (
1356 IN UINTN Address,
1357 IN UINTN StartBit,
1358 IN UINTN EndBit,
1359 IN UINT8 OrData
1360 )
1361 {
1362 return MmioWrite8 (
1363 Address,
1364 BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData)
1365 );
1366 }
1367
1368 /**
1369 Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and
1370 writes the result back to the bit field in the 8-bit MMIO register.
1371
1372 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1373 between the read result and the value specified by AndData, and writes the
1374 result to the 8-bit MMIO register specified by Address. The value written to
1375 the MMIO register is returned. This function must guarantee that all MMIO
1376 read and write operations are serialized. Extra left bits in AndData are
1377 stripped.
1378
1379 If 8-bit MMIO register operations are not supported, then ASSERT().
1380 If StartBit is greater than 7, then ASSERT().
1381 If EndBit is greater than 7, then ASSERT().
1382 If EndBit is less than StartBit, then ASSERT().
1383 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1384
1385 @param Address MMIO register to write.
1386 @param StartBit The ordinal of the least significant bit in the bit field.
1387 Range 0..7.
1388 @param EndBit The ordinal of the most significant bit in the bit field.
1389 Range 0..7.
1390 @param AndData The value to AND with read value from the MMIO register.
1391
1392 @return The value written back to the MMIO register.
1393
1394 **/
1395 UINT8
1396 EFIAPI
1397 MmioBitFieldAnd8 (
1398 IN UINTN Address,
1399 IN UINTN StartBit,
1400 IN UINTN EndBit,
1401 IN UINT8 AndData
1402 )
1403 {
1404 return MmioWrite8 (
1405 Address,
1406 BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData)
1407 );
1408 }
1409
1410 /**
1411 Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed
1412 by a bitwise OR, and writes the result back to the bit field in the
1413 8-bit MMIO register.
1414
1415 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1416 followed by a bitwise OR between the read result and the value
1417 specified by AndData, and writes the result to the 8-bit MMIO register
1418 specified by Address. The value written to the MMIO register is returned.
1419 This function must guarantee that all MMIO read and write operations are
1420 serialized. Extra left bits in both AndData and OrData are stripped.
1421
1422 If 8-bit MMIO register operations are not supported, then ASSERT().
1423 If StartBit is greater than 7, then ASSERT().
1424 If EndBit is greater than 7, then ASSERT().
1425 If EndBit is less than StartBit, then ASSERT().
1426 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1427 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1428
1429 @param Address MMIO register to write.
1430 @param StartBit The ordinal of the least significant bit in the bit field.
1431 Range 0..7.
1432 @param EndBit The ordinal of the most significant bit in the bit field.
1433 Range 0..7.
1434 @param AndData The value to AND with read value from the MMIO register.
1435 @param OrData The value to OR with the result of the AND operation.
1436
1437 @return The value written back to the MMIO register.
1438
1439 **/
1440 UINT8
1441 EFIAPI
1442 MmioBitFieldAndThenOr8 (
1443 IN UINTN Address,
1444 IN UINTN StartBit,
1445 IN UINTN EndBit,
1446 IN UINT8 AndData,
1447 IN UINT8 OrData
1448 )
1449 {
1450 return MmioWrite8 (
1451 Address,
1452 BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData)
1453 );
1454 }
1455
1456 /**
1457 Reads a 16-bit MMIO register, performs a bitwise OR, and writes the
1458 result back to the 16-bit MMIO register.
1459
1460 Reads the 16-bit MMIO register specified by Address, performs a bitwise
1461 inclusive OR between the read result and the value specified by OrData, and
1462 writes the result to the 16-bit MMIO register specified by Address. The value
1463 written to the MMIO register is returned. This function must guarantee that
1464 all MMIO read and write operations are serialized.
1465
1466 If 16-bit MMIO register operations are not supported, then ASSERT().
1467
1468 @param Address The MMIO register to write.
1469 @param OrData The value to OR with the read value from the MMIO register.
1470
1471 @return The value written back to the MMIO register.
1472
1473 **/
1474 UINT16
1475 EFIAPI
1476 MmioOr16 (
1477 IN UINTN Address,
1478 IN UINT16 OrData
1479 )
1480 {
1481 return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData));
1482 }
1483
1484 /**
1485 Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result
1486 back to the 16-bit MMIO register.
1487
1488 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1489 between the read result and the value specified by AndData, and writes the
1490 result to the 16-bit MMIO register specified by Address. The value written to
1491 the MMIO register is returned. This function must guarantee that all MMIO
1492 read and write operations are serialized.
1493
1494 If 16-bit MMIO register operations are not supported, then ASSERT().
1495
1496 @param Address The MMIO register to write.
1497 @param AndData The value to AND with the read value from the MMIO register.
1498
1499 @return The value written back to the MMIO register.
1500
1501 **/
1502 UINT16
1503 EFIAPI
1504 MmioAnd16 (
1505 IN UINTN Address,
1506 IN UINT16 AndData
1507 )
1508 {
1509 return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData));
1510 }
1511
1512 /**
1513 Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise
1514 inclusive OR, and writes the result back to the 16-bit MMIO register.
1515
1516 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1517 between the read result and the value specified by AndData, performs a
1518 bitwise OR between the result of the AND operation and the value specified by
1519 OrData, and writes the result to the 16-bit MMIO register specified by
1520 Address. The value written to the MMIO register is returned. This function
1521 must guarantee that all MMIO read and write operations are serialized.
1522
1523 If 16-bit MMIO register operations are not supported, then ASSERT().
1524
1525
1526 @param Address The MMIO register to write.
1527 @param AndData The value to AND with the read value from the MMIO register.
1528 @param OrData The value to OR with the result of the AND operation.
1529
1530 @return The value written back to the MMIO register.
1531
1532 **/
1533 UINT16
1534 EFIAPI
1535 MmioAndThenOr16 (
1536 IN UINTN Address,
1537 IN UINT16 AndData,
1538 IN UINT16 OrData
1539 )
1540 {
1541 return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData));
1542 }
1543
1544 /**
1545 Reads a bit field of a MMIO register.
1546
1547 Reads the bit field in a 16-bit MMIO register. The bit field is specified by
1548 the StartBit and the EndBit. The value of the bit field is returned.
1549
1550 If 16-bit MMIO register operations are not supported, then ASSERT().
1551 If StartBit is greater than 15, then ASSERT().
1552 If EndBit is greater than 15, then ASSERT().
1553 If EndBit is less than StartBit, then ASSERT().
1554
1555 @param Address MMIO register to read.
1556 @param StartBit The ordinal of the least significant bit in the bit field.
1557 Range 0..15.
1558 @param EndBit The ordinal of the most significant bit in the bit field.
1559 Range 0..15.
1560
1561 @return The value read.
1562
1563 **/
1564 UINT16
1565 EFIAPI
1566 MmioBitFieldRead16 (
1567 IN UINTN Address,
1568 IN UINTN StartBit,
1569 IN UINTN EndBit
1570 )
1571 {
1572 return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit);
1573 }
1574
1575 /**
1576 Writes a bit field to a MMIO register.
1577
1578 Writes Value to the bit field of the MMIO register. The bit field is
1579 specified by the StartBit and the EndBit. All other bits in the destination
1580 MMIO register are preserved. The new value of the 16-bit register is returned.
1581
1582 If 16-bit MMIO register operations are not supported, then ASSERT().
1583 If StartBit is greater than 15, then ASSERT().
1584 If EndBit is greater than 15, then ASSERT().
1585 If EndBit is less than StartBit, then ASSERT().
1586 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1587
1588 @param Address MMIO register to write.
1589 @param StartBit The ordinal of the least significant bit in the bit field.
1590 Range 0..15.
1591 @param EndBit The ordinal of the most significant bit in the bit field.
1592 Range 0..15.
1593 @param Value New value of the bit field.
1594
1595 @return The value written back to the MMIO register.
1596
1597 **/
1598 UINT16
1599 EFIAPI
1600 MmioBitFieldWrite16 (
1601 IN UINTN Address,
1602 IN UINTN StartBit,
1603 IN UINTN EndBit,
1604 IN UINT16 Value
1605 )
1606 {
1607 return MmioWrite16 (
1608 Address,
1609 BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value)
1610 );
1611 }
1612
1613 /**
1614 Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and
1615 writes the result back to the bit field in the 16-bit MMIO register.
1616
1617 Reads the 16-bit MMIO register specified by Address, performs a bitwise
1618 inclusive OR between the read result and the value specified by OrData, and
1619 writes the result to the 16-bit MMIO register specified by Address. The value
1620 written to the MMIO register is returned. This function must guarantee that
1621 all MMIO read and write operations are serialized. Extra left bits in OrData
1622 are stripped.
1623
1624 If 16-bit MMIO register operations are not supported, then ASSERT().
1625 If StartBit is greater than 15, then ASSERT().
1626 If EndBit is greater than 15, then ASSERT().
1627 If EndBit is less than StartBit, then ASSERT().
1628 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1629
1630 @param Address MMIO register to write.
1631 @param StartBit The ordinal of the least significant bit in the bit field.
1632 Range 0..15.
1633 @param EndBit The ordinal of the most significant bit in the bit field.
1634 Range 0..15.
1635 @param OrData The value to OR with read value from the MMIO register.
1636
1637 @return The value written back to the MMIO register.
1638
1639 **/
1640 UINT16
1641 EFIAPI
1642 MmioBitFieldOr16 (
1643 IN UINTN Address,
1644 IN UINTN StartBit,
1645 IN UINTN EndBit,
1646 IN UINT16 OrData
1647 )
1648 {
1649 return MmioWrite16 (
1650 Address,
1651 BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData)
1652 );
1653 }
1654
1655 /**
1656 Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and
1657 writes the result back to the bit field in the 16-bit MMIO register.
1658
1659 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1660 between the read result and the value specified by AndData, and writes the
1661 result to the 16-bit MMIO register specified by Address. The value written to
1662 the MMIO register is returned. This function must guarantee that all MMIO
1663 read and write operations are serialized. Extra left bits in AndData are
1664 stripped.
1665
1666 If 16-bit MMIO register operations are not supported, then ASSERT().
1667 If StartBit is greater than 15, then ASSERT().
1668 If EndBit is greater than 15, then ASSERT().
1669 If EndBit is less than StartBit, then ASSERT().
1670 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1671
1672 @param Address MMIO register to write.
1673 @param StartBit The ordinal of the least significant bit in the bit field.
1674 Range 0..15.
1675 @param EndBit The ordinal of the most significant bit in the bit field.
1676 Range 0..15.
1677 @param AndData The value to AND with read value from the MMIO register.
1678
1679 @return The value written back to the MMIO register.
1680
1681 **/
1682 UINT16
1683 EFIAPI
1684 MmioBitFieldAnd16 (
1685 IN UINTN Address,
1686 IN UINTN StartBit,
1687 IN UINTN EndBit,
1688 IN UINT16 AndData
1689 )
1690 {
1691 return MmioWrite16 (
1692 Address,
1693 BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData)
1694 );
1695 }
1696
1697 /**
1698 Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed
1699 by a bitwise OR, and writes the result back to the bit field in the
1700 16-bit MMIO register.
1701
1702 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1703 followed by a bitwise OR between the read result and the value
1704 specified by AndData, and writes the result to the 16-bit MMIO register
1705 specified by Address. The value written to the MMIO register is returned.
1706 This function must guarantee that all MMIO read and write operations are
1707 serialized. Extra left bits in both AndData and OrData are stripped.
1708
1709 If 16-bit MMIO register operations are not supported, then ASSERT().
1710 If StartBit is greater than 15, then ASSERT().
1711 If EndBit is greater than 15, then ASSERT().
1712 If EndBit is less than StartBit, then ASSERT().
1713 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1714 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1715
1716 @param Address MMIO register to write.
1717 @param StartBit The ordinal of the least significant bit in the bit field.
1718 Range 0..15.
1719 @param EndBit The ordinal of the most significant bit in the bit field.
1720 Range 0..15.
1721 @param AndData The value to AND with read value from the MMIO register.
1722 @param OrData The value to OR with the result of the AND operation.
1723
1724 @return The value written back to the MMIO register.
1725
1726 **/
1727 UINT16
1728 EFIAPI
1729 MmioBitFieldAndThenOr16 (
1730 IN UINTN Address,
1731 IN UINTN StartBit,
1732 IN UINTN EndBit,
1733 IN UINT16 AndData,
1734 IN UINT16 OrData
1735 )
1736 {
1737 return MmioWrite16 (
1738 Address,
1739 BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData)
1740 );
1741 }
1742
1743 /**
1744 Reads a 32-bit MMIO register, performs a bitwise OR, and writes the
1745 result back to the 32-bit MMIO register.
1746
1747 Reads the 32-bit MMIO register specified by Address, performs a bitwise
1748 inclusive OR between the read result and the value specified by OrData, and
1749 writes the result to the 32-bit MMIO register specified by Address. The value
1750 written to the MMIO register is returned. This function must guarantee that
1751 all MMIO read and write operations are serialized.
1752
1753 If 32-bit MMIO register operations are not supported, then ASSERT().
1754
1755 @param Address The MMIO register to write.
1756 @param OrData The value to OR with the read value from the MMIO register.
1757
1758 @return The value written back to the MMIO register.
1759
1760 **/
1761 UINT32
1762 EFIAPI
1763 MmioOr32 (
1764 IN UINTN Address,
1765 IN UINT32 OrData
1766 )
1767 {
1768 return MmioWrite32 (Address, MmioRead32 (Address) | OrData);
1769 }
1770
1771 /**
1772 Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result
1773 back to the 32-bit MMIO register.
1774
1775 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
1776 between the read result and the value specified by AndData, and writes the
1777 result to the 32-bit MMIO register specified by Address. The value written to
1778 the MMIO register is returned. This function must guarantee that all MMIO
1779 read and write operations are serialized.
1780
1781 If 32-bit MMIO register operations are not supported, then ASSERT().
1782
1783 @param Address The MMIO register to write.
1784 @param AndData The value to AND with the read value from the MMIO register.
1785
1786 @return The value written back to the MMIO register.
1787
1788 **/
1789 UINT32
1790 EFIAPI
1791 MmioAnd32 (
1792 IN UINTN Address,
1793 IN UINT32 AndData
1794 )
1795 {
1796 return MmioWrite32 (Address, MmioRead32 (Address) & AndData);
1797 }
1798
1799 /**
1800 Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise
1801 inclusive OR, and writes the result back to the 32-bit MMIO register.
1802
1803 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
1804 between the read result and the value specified by AndData, performs a
1805 bitwise OR between the result of the AND operation and the value specified by
1806 OrData, and writes the result to the 32-bit MMIO register specified by
1807 Address. The value written to the MMIO register is returned. This function
1808 must guarantee that all MMIO read and write operations are serialized.
1809
1810 If 32-bit MMIO register operations are not supported, then ASSERT().
1811
1812
1813 @param Address The MMIO register to write.
1814 @param AndData The value to AND with the read value from the MMIO register.
1815 @param OrData The value to OR with the result of the AND operation.
1816
1817 @return The value written back to the MMIO register.
1818
1819 **/
1820 UINT32
1821 EFIAPI
1822 MmioAndThenOr32 (
1823 IN UINTN Address,
1824 IN UINT32 AndData,
1825 IN UINT32 OrData
1826 )
1827 {
1828 return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData);
1829 }
1830
1831 /**
1832 Reads a bit field of a MMIO register.
1833
1834 Reads the bit field in a 32-bit MMIO register. The bit field is specified by
1835 the StartBit and the EndBit. The value of the bit field is returned.
1836
1837 If 32-bit MMIO register operations are not supported, then ASSERT().
1838 If StartBit is greater than 31, then ASSERT().
1839 If EndBit is greater than 31, then ASSERT().
1840 If EndBit is less than StartBit, then ASSERT().
1841
1842 @param Address MMIO register to read.
1843 @param StartBit The ordinal of the least significant bit in the bit field.
1844 Range 0..31.
1845 @param EndBit The ordinal of the most significant bit in the bit field.
1846 Range 0..31.
1847
1848 @return The value read.
1849
1850 **/
1851 UINT32
1852 EFIAPI
1853 MmioBitFieldRead32 (
1854 IN UINTN Address,
1855 IN UINTN StartBit,
1856 IN UINTN EndBit
1857 )
1858 {
1859 return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit);
1860 }
1861
1862 /**
1863 Writes a bit field to a MMIO register.
1864
1865 Writes Value to the bit field of the MMIO register. The bit field is
1866 specified by the StartBit and the EndBit. All other bits in the destination
1867 MMIO register are preserved. The new value of the 32-bit register is returned.
1868
1869 If 32-bit MMIO register operations are not supported, then ASSERT().
1870 If StartBit is greater than 31, then ASSERT().
1871 If EndBit is greater than 31, then ASSERT().
1872 If EndBit is less than StartBit, then ASSERT().
1873 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1874
1875 @param Address MMIO register to write.
1876 @param StartBit The ordinal of the least significant bit in the bit field.
1877 Range 0..31.
1878 @param EndBit The ordinal of the most significant bit in the bit field.
1879 Range 0..31.
1880 @param Value New value of the bit field.
1881
1882 @return The value written back to the MMIO register.
1883
1884 **/
1885 UINT32
1886 EFIAPI
1887 MmioBitFieldWrite32 (
1888 IN UINTN Address,
1889 IN UINTN StartBit,
1890 IN UINTN EndBit,
1891 IN UINT32 Value
1892 )
1893 {
1894 return MmioWrite32 (
1895 Address,
1896 BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value)
1897 );
1898 }
1899
1900 /**
1901 Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and
1902 writes the result back to the bit field in the 32-bit MMIO register.
1903
1904 Reads the 32-bit MMIO register specified by Address, performs a bitwise
1905 inclusive OR between the read result and the value specified by OrData, and
1906 writes the result to the 32-bit MMIO register specified by Address. The value
1907 written to the MMIO register is returned. This function must guarantee that
1908 all MMIO read and write operations are serialized. Extra left bits in OrData
1909 are stripped.
1910
1911 If 32-bit MMIO register operations are not supported, then ASSERT().
1912 If StartBit is greater than 31, then ASSERT().
1913 If EndBit is greater than 31, then ASSERT().
1914 If EndBit is less than StartBit, then ASSERT().
1915 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1916
1917 @param Address MMIO register to write.
1918 @param StartBit The ordinal of the least significant bit in the bit field.
1919 Range 0..31.
1920 @param EndBit The ordinal of the most significant bit in the bit field.
1921 Range 0..31.
1922 @param OrData The value to OR with read value from the MMIO register.
1923
1924 @return The value written back to the MMIO register.
1925
1926 **/
1927 UINT32
1928 EFIAPI
1929 MmioBitFieldOr32 (
1930 IN UINTN Address,
1931 IN UINTN StartBit,
1932 IN UINTN EndBit,
1933 IN UINT32 OrData
1934 )
1935 {
1936 return MmioWrite32 (
1937 Address,
1938 BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData)
1939 );
1940 }
1941
1942 /**
1943 Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and
1944 writes the result back to the bit field in the 32-bit MMIO register.
1945
1946 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
1947 between the read result and the value specified by AndData, and writes the
1948 result to the 32-bit MMIO register specified by Address. The value written to
1949 the MMIO register is returned. This function must guarantee that all MMIO
1950 read and write operations are serialized. Extra left bits in AndData are
1951 stripped.
1952
1953 If 32-bit MMIO register operations are not supported, then ASSERT().
1954 If StartBit is greater than 31, then ASSERT().
1955 If EndBit is greater than 31, then ASSERT().
1956 If EndBit is less than StartBit, then ASSERT().
1957 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1958
1959 @param Address MMIO register to write.
1960 @param StartBit The ordinal of the least significant bit in the bit field.
1961 Range 0..31.
1962 @param EndBit The ordinal of the most significant bit in the bit field.
1963 Range 0..31.
1964 @param AndData The value to AND with read value from the MMIO register.
1965
1966 @return The value written back to the MMIO register.
1967
1968 **/
1969 UINT32
1970 EFIAPI
1971 MmioBitFieldAnd32 (
1972 IN UINTN Address,
1973 IN UINTN StartBit,
1974 IN UINTN EndBit,
1975 IN UINT32 AndData
1976 )
1977 {
1978 return MmioWrite32 (
1979 Address,
1980 BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData)
1981 );
1982 }
1983
1984 /**
1985 Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed
1986 by a bitwise OR, and writes the result back to the bit field in the
1987 32-bit MMIO register.
1988
1989 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
1990 followed by a bitwise OR between the read result and the value
1991 specified by AndData, and writes the result to the 32-bit MMIO register
1992 specified by Address. The value written to the MMIO register is returned.
1993 This function must guarantee that all MMIO read and write operations are
1994 serialized. Extra left bits in both AndData and OrData are stripped.
1995
1996 If 32-bit MMIO register operations are not supported, then ASSERT().
1997 If StartBit is greater than 31, then ASSERT().
1998 If EndBit is greater than 31, then ASSERT().
1999 If EndBit is less than StartBit, then ASSERT().
2000 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2001 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2002
2003 @param Address MMIO register to write.
2004 @param StartBit The ordinal of the least significant bit in the bit field.
2005 Range 0..31.
2006 @param EndBit The ordinal of the most significant bit in the bit field.
2007 Range 0..31.
2008 @param AndData The value to AND with read value from the MMIO register.
2009 @param OrData The value to OR with the result of the AND operation.
2010
2011 @return The value written back to the MMIO register.
2012
2013 **/
2014 UINT32
2015 EFIAPI
2016 MmioBitFieldAndThenOr32 (
2017 IN UINTN Address,
2018 IN UINTN StartBit,
2019 IN UINTN EndBit,
2020 IN UINT32 AndData,
2021 IN UINT32 OrData
2022 )
2023 {
2024 return MmioWrite32 (
2025 Address,
2026 BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData)
2027 );
2028 }
2029
2030 /**
2031 Reads a 64-bit MMIO register, performs a bitwise OR, and writes the
2032 result back to the 64-bit MMIO register.
2033
2034 Reads the 64-bit MMIO register specified by Address, performs a bitwise
2035 inclusive OR between the read result and the value specified by OrData, and
2036 writes the result to the 64-bit MMIO register specified by Address. The value
2037 written to the MMIO register is returned. This function must guarantee that
2038 all MMIO read and write operations are serialized.
2039
2040 If 64-bit MMIO register operations are not supported, then ASSERT().
2041
2042 @param Address The MMIO register to write.
2043 @param OrData The value to OR with the read value from the MMIO register.
2044
2045 @return The value written back to the MMIO register.
2046
2047 **/
2048 UINT64
2049 EFIAPI
2050 MmioOr64 (
2051 IN UINTN Address,
2052 IN UINT64 OrData
2053 )
2054 {
2055 return MmioWrite64 (Address, MmioRead64 (Address) | OrData);
2056 }
2057
2058 /**
2059 Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result
2060 back to the 64-bit MMIO register.
2061
2062 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2063 between the read result and the value specified by AndData, and writes the
2064 result to the 64-bit MMIO register specified by Address. The value written to
2065 the MMIO register is returned. This function must guarantee that all MMIO
2066 read and write operations are serialized.
2067
2068 If 64-bit MMIO register operations are not supported, then ASSERT().
2069
2070 @param Address The MMIO register to write.
2071 @param AndData The value to AND with the read value from the MMIO register.
2072
2073 @return The value written back to the MMIO register.
2074
2075 **/
2076 UINT64
2077 EFIAPI
2078 MmioAnd64 (
2079 IN UINTN Address,
2080 IN UINT64 AndData
2081 )
2082 {
2083 return MmioWrite64 (Address, MmioRead64 (Address) & AndData);
2084 }
2085
2086 /**
2087 Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise
2088 inclusive OR, and writes the result back to the 64-bit MMIO register.
2089
2090 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2091 between the read result and the value specified by AndData, performs a
2092 bitwise OR between the result of the AND operation and the value specified by
2093 OrData, and writes the result to the 64-bit MMIO register specified by
2094 Address. The value written to the MMIO register is returned. This function
2095 must guarantee that all MMIO read and write operations are serialized.
2096
2097 If 64-bit MMIO register operations are not supported, then ASSERT().
2098
2099
2100 @param Address The MMIO register to write.
2101 @param AndData The value to AND with the read value from the MMIO register.
2102 @param OrData The value to OR with the result of the AND operation.
2103
2104 @return The value written back to the MMIO register.
2105
2106 **/
2107 UINT64
2108 EFIAPI
2109 MmioAndThenOr64 (
2110 IN UINTN Address,
2111 IN UINT64 AndData,
2112 IN UINT64 OrData
2113 )
2114 {
2115 return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData);
2116 }
2117
2118 /**
2119 Reads a bit field of a MMIO register.
2120
2121 Reads the bit field in a 64-bit MMIO register. The bit field is specified by
2122 the StartBit and the EndBit. The value of the bit field is returned.
2123
2124 If 64-bit MMIO register operations are not supported, then ASSERT().
2125 If StartBit is greater than 63, then ASSERT().
2126 If EndBit is greater than 63, then ASSERT().
2127 If EndBit is less than StartBit, then ASSERT().
2128
2129 @param Address MMIO register to read.
2130 @param StartBit The ordinal of the least significant bit in the bit field.
2131 Range 0..63.
2132 @param EndBit The ordinal of the most significant bit in the bit field.
2133 Range 0..63.
2134
2135 @return The value read.
2136
2137 **/
2138 UINT64
2139 EFIAPI
2140 MmioBitFieldRead64 (
2141 IN UINTN Address,
2142 IN UINTN StartBit,
2143 IN UINTN EndBit
2144 )
2145 {
2146 return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit);
2147 }
2148
2149 /**
2150 Writes a bit field to a MMIO register.
2151
2152 Writes Value to the bit field of the MMIO register. The bit field is
2153 specified by the StartBit and the EndBit. All other bits in the destination
2154 MMIO register are preserved. The new value of the 64-bit register is returned.
2155
2156 If 64-bit MMIO register operations are not supported, then ASSERT().
2157 If StartBit is greater than 63, then ASSERT().
2158 If EndBit is greater than 63, then ASSERT().
2159 If EndBit is less than StartBit, then ASSERT().
2160 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2161
2162 @param Address MMIO register to write.
2163 @param StartBit The ordinal of the least significant bit in the bit field.
2164 Range 0..63.
2165 @param EndBit The ordinal of the most significant bit in the bit field.
2166 Range 0..63.
2167 @param Value New value of the bit field.
2168
2169 @return The value written back to the MMIO register.
2170
2171 **/
2172 UINT64
2173 EFIAPI
2174 MmioBitFieldWrite64 (
2175 IN UINTN Address,
2176 IN UINTN StartBit,
2177 IN UINTN EndBit,
2178 IN UINT64 Value
2179 )
2180 {
2181 return MmioWrite64 (
2182 Address,
2183 BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value)
2184 );
2185 }
2186
2187 /**
2188 Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and
2189 writes the result back to the bit field in the 64-bit MMIO register.
2190
2191 Reads the 64-bit MMIO register specified by Address, performs a bitwise
2192 inclusive OR between the read result and the value specified by OrData, and
2193 writes the result to the 64-bit MMIO register specified by Address. The value
2194 written to the MMIO register is returned. This function must guarantee that
2195 all MMIO read and write operations are serialized. Extra left bits in OrData
2196 are stripped.
2197
2198 If 64-bit MMIO register operations are not supported, then ASSERT().
2199 If StartBit is greater than 63, then ASSERT().
2200 If EndBit is greater than 63, then ASSERT().
2201 If EndBit is less than StartBit, then ASSERT().
2202 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2203
2204 @param Address MMIO register to write.
2205 @param StartBit The ordinal of the least significant bit in the bit field.
2206 Range 0..63.
2207 @param EndBit The ordinal of the most significant bit in the bit field.
2208 Range 0..63.
2209 @param OrData The value to OR with read value from the MMIO register.
2210
2211 @return The value written back to the MMIO register.
2212
2213 **/
2214 UINT64
2215 EFIAPI
2216 MmioBitFieldOr64 (
2217 IN UINTN Address,
2218 IN UINTN StartBit,
2219 IN UINTN EndBit,
2220 IN UINT64 OrData
2221 )
2222 {
2223 return MmioWrite64 (
2224 Address,
2225 BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData)
2226 );
2227 }
2228
2229 /**
2230 Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and
2231 writes the result back to the bit field in the 64-bit MMIO register.
2232
2233 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2234 between the read result and the value specified by AndData, and writes the
2235 result to the 64-bit MMIO register specified by Address. The value written to
2236 the MMIO register is returned. This function must guarantee that all MMIO
2237 read and write operations are serialized. Extra left bits in AndData are
2238 stripped.
2239
2240 If 64-bit MMIO register operations are not supported, then ASSERT().
2241 If StartBit is greater than 63, then ASSERT().
2242 If EndBit is greater than 63, then ASSERT().
2243 If EndBit is less than StartBit, then ASSERT().
2244 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2245
2246 @param Address MMIO register to write.
2247 @param StartBit The ordinal of the least significant bit in the bit field.
2248 Range 0..63.
2249 @param EndBit The ordinal of the most significant bit in the bit field.
2250 Range 0..63.
2251 @param AndData The value to AND with read value from the MMIO register.
2252
2253 @return The value written back to the MMIO register.
2254
2255 **/
2256 UINT64
2257 EFIAPI
2258 MmioBitFieldAnd64 (
2259 IN UINTN Address,
2260 IN UINTN StartBit,
2261 IN UINTN EndBit,
2262 IN UINT64 AndData
2263 )
2264 {
2265 return MmioWrite64 (
2266 Address,
2267 BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData)
2268 );
2269 }
2270
2271 /**
2272 Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed
2273 by a bitwise OR, and writes the result back to the bit field in the
2274 64-bit MMIO register.
2275
2276 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2277 followed by a bitwise OR between the read result and the value
2278 specified by AndData, and writes the result to the 64-bit MMIO register
2279 specified by Address. The value written to the MMIO register is returned.
2280 This function must guarantee that all MMIO read and write operations are
2281 serialized. Extra left bits in both AndData and OrData are stripped.
2282
2283 If 64-bit MMIO register operations are not supported, then ASSERT().
2284 If StartBit is greater than 63, then ASSERT().
2285 If EndBit is greater than 63, then ASSERT().
2286 If EndBit is less than StartBit, then ASSERT().
2287 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2288 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2289
2290 @param Address MMIO register to write.
2291 @param StartBit The ordinal of the least significant bit in the bit field.
2292 Range 0..63.
2293 @param EndBit The ordinal of the most significant bit in the bit field.
2294 Range 0..63.
2295 @param AndData The value to AND with read value from the MMIO register.
2296 @param OrData The value to OR with the result of the AND operation.
2297
2298 @return The value written back to the MMIO register.
2299
2300 **/
2301 UINT64
2302 EFIAPI
2303 MmioBitFieldAndThenOr64 (
2304 IN UINTN Address,
2305 IN UINTN StartBit,
2306 IN UINTN EndBit,
2307 IN UINT64 AndData,
2308 IN UINT64 OrData
2309 )
2310 {
2311 return MmioWrite64 (
2312 Address,
2313 BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData)
2314 );
2315 }