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