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