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