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