]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseIoLibIntrinsic/IoHighLevel.c
Make comments match the Spec.
[mirror_edk2.git] / MdePkg / Library / BaseIoLibIntrinsic / 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 - 2008, 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 contain the same copy of this file:
17
18 BaseIoLibIntrinsic
19 DxeIoLibCpuIo
20 PeiIoLibCpuIo
21
22 **/
23
24 #include "BaseIoLibIntrinsicInternal.h"
25
26 /**
27 Reads an 8-bit I/O port, performs a bitwise OR, and writes the
28 result back to the 8-bit I/O port.
29
30 Reads the 8-bit I/O port specified by Port, performs a bitwise OR
31 between the read result and the value specified by OrData, and writes the
32 result to the 8-bit I/O port specified by Port. The value written to the I/O
33 port is returned. This function must guarantee that all I/O read and write
34 operations are serialized.
35
36 If 8-bit I/O port operations are not supported, then ASSERT().
37
38 @param Port The I/O port to write.
39 @param OrData The value to OR with the read value from the I/O port.
40
41 @return The value written back to the I/O port.
42
43 **/
44 UINT8
45 EFIAPI
46 IoOr8 (
47 IN UINTN Port,
48 IN UINT8 OrData
49 )
50 {
51 return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData));
52 }
53
54 /**
55 Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back
56 to the 8-bit I/O port.
57
58 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
59 the read result and the value specified by AndData, and writes the result to
60 the 8-bit I/O port specified by Port. The value written to the I/O port is
61 returned. This function must guarantee that all I/O read and write operations
62 are serialized.
63
64 If 8-bit I/O port operations are not supported, then ASSERT().
65
66 @param Port The I/O port to write.
67 @param AndData The value to AND with the read value from the I/O port.
68
69 @return The value written back to the I/O port.
70
71 **/
72 UINT8
73 EFIAPI
74 IoAnd8 (
75 IN UINTN Port,
76 IN UINT8 AndData
77 )
78 {
79 return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData));
80 }
81
82 /**
83 Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise
84 OR, and writes the result back to the 8-bit I/O port.
85
86 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
87 the read result and the value specified by AndData, performs a bitwise OR
88 between the result of the AND operation and the value specified by OrData,
89 and writes the result to the 8-bit I/O port specified by Port. The value
90 written to the I/O port is returned. This function must guarantee that all
91 I/O read and write operations are serialized.
92
93 If 8-bit I/O port operations are not supported, then ASSERT().
94
95 @param Port The I/O port to write.
96 @param AndData The value to AND with the read value from the I/O port.
97 @param OrData The value to OR with the result of the AND operation.
98
99 @return The value written back to the I/O port.
100
101 **/
102 UINT8
103 EFIAPI
104 IoAndThenOr8 (
105 IN UINTN Port,
106 IN UINT8 AndData,
107 IN UINT8 OrData
108 )
109 {
110 return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData));
111 }
112
113 /**
114 Reads a bit field of an I/O register.
115
116 Reads the bit field in an 8-bit I/O register. The bit field is specified by
117 the StartBit and the EndBit. The value of the bit field is returned.
118
119 If 8-bit I/O port operations are not supported, then ASSERT().
120 If StartBit is greater than 7, then ASSERT().
121 If EndBit is greater than 7, then ASSERT().
122 If EndBit is less than StartBit, then ASSERT().
123
124 @param Port The I/O port to read.
125 @param StartBit The ordinal of the least significant bit in the bit field.
126 Range 0..7.
127 @param EndBit The ordinal of the most significant bit in the bit field.
128 Range 0..7.
129
130 @return The value read from I/O port specified by StartBit and
131 EndBit.
132
133 **/
134 UINT8
135 EFIAPI
136 IoBitFieldRead8 (
137 IN UINTN Port,
138 IN UINTN StartBit,
139 IN UINTN EndBit
140 )
141 {
142 return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit);
143 }
144
145 /**
146 Writes a bit field to an I/O register.
147
148 Writes Value to the bit field of the I/O register. The bit field is specified
149 by the StartBit and the EndBit. All other bits in the destination I/O
150 register are preserved. The value written to the I/O port is returned.
151
152 If 8-bit I/O port operations are not supported, then ASSERT().
153 If StartBit is greater than 7, then ASSERT().
154 If EndBit is greater than 7, then ASSERT().
155 If EndBit is less than StartBit, then ASSERT().
156
157 @param Port The I/O port to write.
158 @param StartBit The ordinal of the least significant bit in the bit field.
159 Range 0..7.
160 @param EndBit The ordinal of the most significant bit in the bit field.
161 Range 0..7.
162 @param Value New value of the bit field.
163
164 @return The value written back to the I/O port.
165
166 **/
167 UINT8
168 EFIAPI
169 IoBitFieldWrite8 (
170 IN UINTN Port,
171 IN UINTN StartBit,
172 IN UINTN EndBit,
173 IN UINT8 Value
174 )
175 {
176 return IoWrite8 (
177 Port,
178 BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value)
179 );
180 }
181
182 /**
183 Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the
184 result back to the bit field in the 8-bit port.
185
186 Reads the 8-bit I/O port specified by Port, performs a bitwise OR
187 between the read result and the value specified by OrData, and writes the
188 result to the 8-bit I/O port specified by Port. The value written to the I/O
189 port is returned. This function must guarantee that all I/O read and write
190 operations are serialized. Extra left bits in OrData are stripped.
191
192 If 8-bit I/O port operations are not supported, then ASSERT().
193 If StartBit is greater than 7, then ASSERT().
194 If EndBit is greater than 7, then ASSERT().
195 If EndBit is less than StartBit, then ASSERT().
196
197 @param Port The I/O port to write.
198 @param StartBit The ordinal of the least significant bit in the bit field.
199 Range 0..7.
200 @param EndBit The ordinal of the most significant bit in the bit field.
201 Range 0..7.
202 @param OrData The value to OR with the read value from the I/O port.
203
204 @return The value written back to the I/O port.
205
206 **/
207 UINT8
208 EFIAPI
209 IoBitFieldOr8 (
210 IN UINTN Port,
211 IN UINTN StartBit,
212 IN UINTN EndBit,
213 IN UINT8 OrData
214 )
215 {
216 return IoWrite8 (
217 Port,
218 BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData)
219 );
220 }
221
222 /**
223 Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the
224 result back to the bit field in the 8-bit port.
225
226 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
227 the read result and the value specified by AndData, and writes the result to
228 the 8-bit I/O port specified by Port. The value written to the I/O port is
229 returned. This function must guarantee that all I/O read and write operations
230 are serialized. Extra left bits in AndData are stripped.
231
232 If 8-bit I/O port operations are not supported, then ASSERT().
233 If StartBit is greater than 7, then ASSERT().
234 If EndBit is greater than 7, then ASSERT().
235 If EndBit is less than StartBit, then ASSERT().
236
237 @param Port The I/O port to write.
238 @param StartBit The ordinal of the least significant bit in the bit field.
239 Range 0..7.
240 @param EndBit The ordinal of the most significant bit in the bit field.
241 Range 0..7.
242 @param AndData The value to AND with the read value from the I/O port.
243
244 @return The value written back to the I/O port.
245
246 **/
247 UINT8
248 EFIAPI
249 IoBitFieldAnd8 (
250 IN UINTN Port,
251 IN UINTN StartBit,
252 IN UINTN EndBit,
253 IN UINT8 AndData
254 )
255 {
256 return IoWrite8 (
257 Port,
258 BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData)
259 );
260 }
261
262 /**
263 Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
264 bitwise OR, and writes the result back to the bit field in the
265 8-bit port.
266
267 Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed
268 by a bitwise OR between the read result and the value specified by
269 AndData, and writes the result to the 8-bit I/O port specified by Port. The
270 value written to the I/O port is returned. This function must guarantee that
271 all I/O read and write operations are serialized. Extra left bits in both
272 AndData and OrData are stripped.
273
274 If 8-bit I/O port operations are not supported, then ASSERT().
275 If StartBit is greater than 7, then ASSERT().
276 If EndBit is greater than 7, then ASSERT().
277 If EndBit is less than StartBit, then ASSERT().
278
279 @param Port The I/O port to write.
280 @param StartBit The ordinal of the least significant bit in the bit field.
281 Range 0..7.
282 @param EndBit The ordinal of the most significant bit in the bit field.
283 Range 0..7.
284 @param AndData The value to AND with the read value from the I/O port.
285 @param OrData The value to OR with the result of the AND operation.
286
287 @return The value written back to the I/O port.
288
289 **/
290 UINT8
291 EFIAPI
292 IoBitFieldAndThenOr8 (
293 IN UINTN Port,
294 IN UINTN StartBit,
295 IN UINTN EndBit,
296 IN UINT8 AndData,
297 IN UINT8 OrData
298 )
299 {
300 return IoWrite8 (
301 Port,
302 BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData)
303 );
304 }
305
306 /**
307 Reads a 16-bit I/O port, performs a bitwise OR, and writes the
308 result back to the 16-bit I/O port.
309
310 Reads the 16-bit I/O port specified by Port, performs a bitwise OR
311 between the read result and the value specified by OrData, and writes the
312 result to the 16-bit I/O port specified by Port. The value written to the I/O
313 port is returned. This function must guarantee that all I/O read and write
314 operations are serialized.
315
316 If 16-bit I/O port operations are not supported, then ASSERT().
317
318 @param Port The I/O port to write.
319 @param OrData The value to OR with the read value from the I/O port.
320
321 @return The value written back to the I/O port.
322
323 **/
324 UINT16
325 EFIAPI
326 IoOr16 (
327 IN UINTN Port,
328 IN UINT16 OrData
329 )
330 {
331 return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData));
332 }
333
334 /**
335 Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back
336 to the 16-bit I/O port.
337
338 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
339 the read result and the value specified by AndData, and writes the result to
340 the 16-bit I/O port specified by Port. The value written to the I/O port is
341 returned. This function must guarantee that all I/O read and write operations
342 are serialized.
343
344 If 16-bit I/O port operations are not supported, then ASSERT().
345
346 @param Port The I/O port to write.
347 @param AndData The value to AND with the read value from the I/O port.
348
349 @return The value written back to the I/O port.
350
351 **/
352 UINT16
353 EFIAPI
354 IoAnd16 (
355 IN UINTN Port,
356 IN UINT16 AndData
357 )
358 {
359 return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData));
360 }
361
362 /**
363 Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise
364 OR, and writes the result back to the 16-bit I/O port.
365
366 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
367 the read result and the value specified by AndData, performs a bitwise OR
368 between the result of the AND operation and the value specified by OrData,
369 and writes the result to the 16-bit I/O port specified by Port. The value
370 written to the I/O port is returned. This function must guarantee that all
371 I/O read and write operations are serialized.
372
373 If 16-bit I/O port operations are not supported, then ASSERT().
374
375 @param Port The I/O port to write.
376 @param AndData The value to AND with the read value from the I/O port.
377 @param OrData The value to OR with the result of the AND operation.
378
379 @return The value written back to the I/O port.
380
381 **/
382 UINT16
383 EFIAPI
384 IoAndThenOr16 (
385 IN UINTN Port,
386 IN UINT16 AndData,
387 IN UINT16 OrData
388 )
389 {
390 return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData));
391 }
392
393 /**
394 Reads a bit field of an I/O register.
395
396 Reads the bit field in a 16-bit I/O register. The bit field is specified by
397 the StartBit and the EndBit. The value of the bit field is returned.
398
399 If 16-bit I/O port operations are not supported, then ASSERT().
400 If StartBit is greater than 15, then ASSERT().
401 If EndBit is greater than 15, then ASSERT().
402 If EndBit is less than StartBit, then ASSERT().
403
404 @param Port The I/O port to read.
405 @param StartBit The ordinal of the least significant bit in the bit field.
406 Range 0..15.
407 @param EndBit The ordinal of the most significant bit in the bit field.
408 Range 0..15.
409
410 @return The value read from I/O port specified by StartBit and
411 EndBit.
412
413 **/
414 UINT16
415 EFIAPI
416 IoBitFieldRead16 (
417 IN UINTN Port,
418 IN UINTN StartBit,
419 IN UINTN EndBit
420 )
421 {
422 return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit);
423 }
424
425 /**
426 Writes a bit field to an I/O register.
427
428 Writes Value to the bit field of the I/O register. The bit field is specified
429 by the StartBit and the EndBit. All other bits in the destination I/O
430 register are preserved. The value written to the I/O port is returned. Extra
431 left bits in Value are stripped.
432
433 If 16-bit I/O port operations are not supported, then ASSERT().
434 If StartBit is greater than 15, then ASSERT().
435 If EndBit is greater than 15, then ASSERT().
436 If EndBit is less than StartBit, then ASSERT().
437
438 @param Port The I/O port to write.
439 @param StartBit The ordinal of the least significant bit in the bit field.
440 Range 0..15.
441 @param EndBit The ordinal of the most significant bit in the bit field.
442 Range 0..15.
443 @param Value New value of the bit field.
444
445 @return The value written back to the I/O port.
446
447 **/
448 UINT16
449 EFIAPI
450 IoBitFieldWrite16 (
451 IN UINTN Port,
452 IN UINTN StartBit,
453 IN UINTN EndBit,
454 IN UINT16 Value
455 )
456 {
457 return IoWrite16 (
458 Port,
459 BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value)
460 );
461 }
462
463 /**
464 Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the
465 result back to the bit field in the 16-bit port.
466
467 Reads the 16-bit I/O port specified by Port, performs a bitwise OR
468 between the read result and the value specified by OrData, and writes the
469 result to the 16-bit I/O port specified by Port. The value written to the I/O
470 port is returned. This function must guarantee that all I/O read and write
471 operations are serialized. Extra left bits in OrData are stripped.
472
473 If 16-bit I/O port operations are not supported, then ASSERT().
474 If StartBit is greater than 15, then ASSERT().
475 If EndBit is greater than 15, then ASSERT().
476 If EndBit is less than StartBit, then ASSERT().
477
478 @param Port The I/O port to write.
479 @param StartBit The ordinal of the least significant bit in the bit field.
480 Range 0..15.
481 @param EndBit The ordinal of the most significant bit in the bit field.
482 Range 0..15.
483 @param OrData The value to OR with the read value from the I/O port.
484
485 @return The value written back to the I/O port.
486
487 **/
488 UINT16
489 EFIAPI
490 IoBitFieldOr16 (
491 IN UINTN Port,
492 IN UINTN StartBit,
493 IN UINTN EndBit,
494 IN UINT16 OrData
495 )
496 {
497 return IoWrite16 (
498 Port,
499 BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData)
500 );
501 }
502
503 /**
504 Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the
505 result back to the bit field in the 16-bit port.
506
507 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
508 the read result and the value specified by AndData, and writes the result to
509 the 16-bit I/O port specified by Port. The value written to the I/O port is
510 returned. This function must guarantee that all I/O read and write operations
511 are serialized. Extra left bits in AndData are stripped.
512
513 If 16-bit I/O port operations are not supported, then ASSERT().
514 If StartBit is greater than 15, then ASSERT().
515 If EndBit is greater than 15, then ASSERT().
516 If EndBit is less than StartBit, then ASSERT().
517
518 @param Port The I/O port to write.
519 @param StartBit The ordinal of the least significant bit in the bit field.
520 Range 0..15.
521 @param EndBit The ordinal of the most significant bit in the bit field.
522 Range 0..15.
523 @param AndData The value to AND with the read value from the I/O port.
524
525 @return The value written back to the I/O port.
526
527 **/
528 UINT16
529 EFIAPI
530 IoBitFieldAnd16 (
531 IN UINTN Port,
532 IN UINTN StartBit,
533 IN UINTN EndBit,
534 IN UINT16 AndData
535 )
536 {
537 return IoWrite16 (
538 Port,
539 BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData)
540 );
541 }
542
543 /**
544 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
545 bitwise OR, and writes the result back to the bit field in the
546 16-bit port.
547
548 Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed
549 by a bitwise OR between the read result and the value specified by
550 AndData, and writes the result to the 16-bit I/O port specified by Port. The
551 value written to the I/O port is returned. This function must guarantee that
552 all I/O read and write operations are serialized. Extra left bits in both
553 AndData and OrData are stripped.
554
555 If 16-bit I/O port operations are not supported, then ASSERT().
556 If StartBit is greater than 15, then ASSERT().
557 If EndBit is greater than 15, then ASSERT().
558 If EndBit is less than StartBit, then ASSERT().
559
560 @param Port The I/O port to write.
561 @param StartBit The ordinal of the least significant bit in the bit field.
562 Range 0..15.
563 @param EndBit The ordinal of the most significant bit in the bit field.
564 Range 0..15.
565 @param AndData The value to AND with the read value from the I/O port.
566 @param OrData The value to OR with the result of the AND operation.
567
568 @return The value written back to the I/O port.
569
570 **/
571 UINT16
572 EFIAPI
573 IoBitFieldAndThenOr16 (
574 IN UINTN Port,
575 IN UINTN StartBit,
576 IN UINTN EndBit,
577 IN UINT16 AndData,
578 IN UINT16 OrData
579 )
580 {
581 return IoWrite16 (
582 Port,
583 BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData)
584 );
585 }
586
587 /**
588 Reads a 32-bit I/O port, performs a bitwise OR, and writes the
589 result back to the 32-bit I/O port.
590
591 Reads the 32-bit I/O port specified by Port, performs a bitwise OR
592 between the read result and the value specified by OrData, and writes the
593 result to the 32-bit I/O port specified by Port. The value written to the I/O
594 port is returned. This function must guarantee that all I/O read and write
595 operations are serialized.
596
597 If 32-bit I/O port operations are not supported, then ASSERT().
598
599 @param Port The I/O port to write.
600 @param OrData The value to OR with the read value from the I/O port.
601
602 @return The value written back to the I/O port.
603
604 **/
605 UINT32
606 EFIAPI
607 IoOr32 (
608 IN UINTN Port,
609 IN UINT32 OrData
610 )
611 {
612 return IoWrite32 (Port, IoRead32 (Port) | OrData);
613 }
614
615 /**
616 Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back
617 to the 32-bit I/O port.
618
619 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
620 the read result and the value specified by AndData, and writes the result to
621 the 32-bit I/O port specified by Port. The value written to the I/O port is
622 returned. This function must guarantee that all I/O read and write operations
623 are serialized.
624
625 If 32-bit I/O port operations are not supported, then ASSERT().
626
627 @param Port The I/O port to write.
628 @param AndData The value to AND with the read value from the I/O port.
629
630 @return The value written back to the I/O port.
631
632 **/
633 UINT32
634 EFIAPI
635 IoAnd32 (
636 IN UINTN Port,
637 IN UINT32 AndData
638 )
639 {
640 return IoWrite32 (Port, IoRead32 (Port) & AndData);
641 }
642
643 /**
644 Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise
645 OR, and writes the result back to the 32-bit I/O port.
646
647 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
648 the read result and the value specified by AndData, performs a bitwise OR
649 between the result of the AND operation and the value specified by OrData,
650 and writes the result to the 32-bit I/O port specified by Port. The value
651 written to the I/O port is returned. This function must guarantee that all
652 I/O read and write operations are serialized.
653
654 If 32-bit I/O port operations are not supported, then ASSERT().
655
656 @param Port The I/O port to write.
657 @param AndData The value to AND with the read value from the I/O port.
658 @param OrData The value to OR with the result of the AND operation.
659
660 @return The value written back to the I/O port.
661
662 **/
663 UINT32
664 EFIAPI
665 IoAndThenOr32 (
666 IN UINTN Port,
667 IN UINT32 AndData,
668 IN UINT32 OrData
669 )
670 {
671 return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData);
672 }
673
674 /**
675 Reads a bit field of an I/O register.
676
677 Reads the bit field in a 32-bit I/O register. The bit field is specified by
678 the StartBit and the EndBit. The value of the bit field is returned.
679
680 If 32-bit I/O port operations are not supported, then ASSERT().
681 If StartBit is greater than 31, then ASSERT().
682 If EndBit is greater than 31, then ASSERT().
683 If EndBit is less than StartBit, then ASSERT().
684
685 @param Port The I/O port to read.
686 @param StartBit The ordinal of the least significant bit in the bit field.
687 Range 0..31.
688 @param EndBit The ordinal of the most significant bit in the bit field.
689 Range 0..31.
690
691 @return The value read from I/O port specified by StartBit and
692 EndBit.
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 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 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 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 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 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 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 from I/O port specified by StartBit and
973 EndBit.
974
975 **/
976 UINT64
977 EFIAPI
978 IoBitFieldRead64 (
979 IN UINTN Port,
980 IN UINTN StartBit,
981 IN UINTN EndBit
982 )
983 {
984 return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit);
985 }
986
987 /**
988 Writes a bit field to an I/O register.
989
990 Writes Value to the bit field of the I/O register. The bit field is specified
991 by the StartBit and the EndBit. All other bits in the destination I/O
992 register are preserved. The value written to the I/O port is returned. Extra
993 left bits in Value are stripped.
994
995 If 64-bit I/O port operations are not supported, then ASSERT().
996 If StartBit is greater than 63, then ASSERT().
997 If EndBit is greater than 63, then ASSERT().
998 If EndBit is less than StartBit, then ASSERT().
999
1000 @param Port The I/O port to write.
1001 @param StartBit The ordinal of the least significant bit in the bit field.
1002 Range 0..63.
1003 @param EndBit The ordinal of the most significant bit in the bit field.
1004 Range 0..63.
1005 @param Value New value of the bit field.
1006
1007 @return The value written back to the I/O port.
1008
1009 **/
1010 UINT64
1011 EFIAPI
1012 IoBitFieldWrite64 (
1013 IN UINTN Port,
1014 IN UINTN StartBit,
1015 IN UINTN EndBit,
1016 IN UINT64 Value
1017 )
1018 {
1019 return IoWrite64 (
1020 Port,
1021 BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value)
1022 );
1023 }
1024
1025 /**
1026 Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the
1027 result back to the bit field in the 64-bit port.
1028
1029 Reads the 64-bit I/O port specified by Port, performs a bitwise OR
1030 between the read result and the value specified by OrData, and writes the
1031 result to the 64-bit I/O port specified by Port. The value written to the I/O
1032 port is returned. This function must guarantee that all I/O read and write
1033 operations are serialized. Extra left bits in OrData are stripped.
1034
1035 If 64-bit I/O port operations are not supported, then ASSERT().
1036 If StartBit is greater than 63, then ASSERT().
1037 If EndBit is greater than 63, then ASSERT().
1038 If EndBit is less than StartBit, then ASSERT().
1039
1040 @param Port The I/O port to write.
1041 @param StartBit The ordinal of the least significant bit in the bit field.
1042 Range 0..63.
1043 @param EndBit The ordinal of the most significant bit in the bit field.
1044 Range 0..63.
1045 @param OrData The value to OR with the read value from the I/O port.
1046
1047 @return The value written back to the I/O port.
1048
1049 **/
1050 UINT64
1051 EFIAPI
1052 IoBitFieldOr64 (
1053 IN UINTN Port,
1054 IN UINTN StartBit,
1055 IN UINTN EndBit,
1056 IN UINT64 OrData
1057 )
1058 {
1059 return IoWrite64 (
1060 Port,
1061 BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData)
1062 );
1063 }
1064
1065 /**
1066 Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the
1067 result back to the bit field in the 64-bit port.
1068
1069 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
1070 the read result and the value specified by AndData, and writes the result to
1071 the 64-bit I/O port specified by Port. The value written to the I/O port is
1072 returned. This function must guarantee that all I/O read and write operations
1073 are serialized. Extra left bits in AndData are stripped.
1074
1075 If 64-bit I/O port operations are not supported, then ASSERT().
1076 If StartBit is greater than 63, then ASSERT().
1077 If EndBit is greater than 63, then ASSERT().
1078 If EndBit is less than StartBit, then ASSERT().
1079
1080 @param Port The I/O port to write.
1081 @param StartBit The ordinal of the least significant bit in the bit field.
1082 Range 0..63.
1083 @param EndBit The ordinal of the most significant bit in the bit field.
1084 Range 0..63.
1085 @param AndData The value to AND with the read value from the I/O port.
1086
1087 @return The value written back to the I/O port.
1088
1089 **/
1090 UINT64
1091 EFIAPI
1092 IoBitFieldAnd64 (
1093 IN UINTN Port,
1094 IN UINTN StartBit,
1095 IN UINTN EndBit,
1096 IN UINT64 AndData
1097 )
1098 {
1099 return IoWrite64 (
1100 Port,
1101 BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData)
1102 );
1103 }
1104
1105 /**
1106 Reads a bit field in a 64-bit port, performs a bitwise AND followed by a
1107 bitwise OR, and writes the result back to the bit field in the
1108 64-bit port.
1109
1110 Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed
1111 by a bitwise OR between the read result and the value specified by
1112 AndData, and writes the result to the 64-bit I/O port specified by Port. The
1113 value written to the I/O port is returned. This function must guarantee that
1114 all I/O read and write operations are serialized. Extra left bits in both
1115 AndData and OrData are stripped.
1116
1117 If 64-bit I/O port operations are not supported, then ASSERT().
1118 If StartBit is greater than 63, then ASSERT().
1119 If EndBit is greater than 63, then ASSERT().
1120 If EndBit is less than StartBit, then ASSERT().
1121
1122 @param Port The I/O port to write.
1123 @param StartBit The ordinal of the least significant bit in the bit field.
1124 Range 0..63.
1125 @param EndBit The ordinal of the most significant bit in the bit field.
1126 Range 0..63.
1127 @param AndData The value to AND with the read value from the I/O port.
1128 @param OrData The value to OR with the result of the AND operation.
1129
1130 @return The value written back to the I/O port.
1131
1132 **/
1133 UINT64
1134 EFIAPI
1135 IoBitFieldAndThenOr64 (
1136 IN UINTN Port,
1137 IN UINTN StartBit,
1138 IN UINTN EndBit,
1139 IN UINT64 AndData,
1140 IN UINT64 OrData
1141 )
1142 {
1143 return IoWrite64 (
1144 Port,
1145 BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData)
1146 );
1147 }
1148
1149 /**
1150 Reads an 8-bit MMIO register, performs a bitwise OR, and writes the
1151 result back to the 8-bit MMIO register.
1152
1153 Reads the 8-bit MMIO register specified by Address, performs a bitwise
1154 OR between the read result and the value specified by OrData, and
1155 writes the result to the 8-bit MMIO register specified by Address. The value
1156 written to the MMIO register is returned. This function must guarantee that
1157 all MMIO read and write operations are serialized.
1158
1159 If 8-bit MMIO register operations are not supported, then ASSERT().
1160
1161 @param Address The MMIO register to write.
1162 @param OrData The value to OR with the read value from the MMIO register.
1163
1164 @return The value written back to the MMIO register.
1165
1166 **/
1167 UINT8
1168 EFIAPI
1169 MmioOr8 (
1170 IN UINTN Address,
1171 IN UINT8 OrData
1172 )
1173 {
1174 return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData));
1175 }
1176
1177 /**
1178 Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result
1179 back to the 8-bit MMIO register.
1180
1181 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1182 between the read result and the value specified by AndData, and writes the
1183 result to the 8-bit MMIO register specified by Address. The value written to
1184 the MMIO register is returned. This function must guarantee that all MMIO
1185 read and write operations are serialized.
1186
1187 If 8-bit MMIO register operations are not supported, then ASSERT().
1188
1189 @param Address The MMIO register to write.
1190 @param AndData The value to AND with the read value from the MMIO register.
1191
1192 @return The value written back to the MMIO register.
1193
1194 **/
1195 UINT8
1196 EFIAPI
1197 MmioAnd8 (
1198 IN UINTN Address,
1199 IN UINT8 AndData
1200 )
1201 {
1202 return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData));
1203 }
1204
1205 /**
1206 Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise
1207 OR, and writes the result back to the 8-bit MMIO register.
1208
1209 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1210 between the read result and the value specified by AndData, performs a
1211 bitwise OR between the result of the AND operation and the value specified by
1212 OrData, and writes the result to the 8-bit MMIO register specified by
1213 Address. The value written to the MMIO register is returned. This function
1214 must guarantee that all MMIO read and write operations are serialized.
1215
1216 If 8-bit MMIO register operations are not supported, then ASSERT().
1217
1218
1219 @param Address The MMIO register to write.
1220 @param AndData The value to AND with the read value from the MMIO register.
1221 @param OrData The value to OR with the result of the AND operation.
1222
1223 @return The value written back to the MMIO register.
1224
1225 **/
1226 UINT8
1227 EFIAPI
1228 MmioAndThenOr8 (
1229 IN UINTN Address,
1230 IN UINT8 AndData,
1231 IN UINT8 OrData
1232 )
1233 {
1234 return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData));
1235 }
1236
1237 /**
1238 Reads a bit field of a MMIO register.
1239
1240 Reads the bit field in an 8-bit MMIO register. The bit field is specified by
1241 the StartBit and the EndBit. The value of the bit field is returned.
1242
1243 If 8-bit MMIO register operations are not supported, then ASSERT().
1244 If StartBit is greater than 7, then ASSERT().
1245 If EndBit is greater than 7, then ASSERT().
1246 If EndBit is less than StartBit, then ASSERT().
1247
1248 @param Address MMIO register to read.
1249 @param StartBit The ordinal of the least significant bit in the bit field.
1250 Range 0..7.
1251 @param EndBit The ordinal of the most significant bit in the bit field.
1252 Range 0..7.
1253
1254 @return The value read from I/O port specified by StartBit and
1255 EndBit.
1256
1257 **/
1258 UINT8
1259 EFIAPI
1260 MmioBitFieldRead8 (
1261 IN UINTN Address,
1262 IN UINTN StartBit,
1263 IN UINTN EndBit
1264 )
1265 {
1266 return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit);
1267 }
1268
1269 /**
1270 Writes a bit field to a MMIO register.
1271
1272 Writes Value to the bit field of the MMIO register. The bit field is
1273 specified by the StartBit and the EndBit. All other bits in the destination
1274 MMIO register are preserved. The new value of the 8-bit register is returned.
1275
1276 If 8-bit MMIO register operations are not supported, then ASSERT().
1277 If StartBit is greater than 7, then ASSERT().
1278 If EndBit is greater than 7, then ASSERT().
1279 If EndBit is less than StartBit, then ASSERT().
1280
1281 @param Address MMIO register to write.
1282 @param StartBit The ordinal of the least significant bit in the bit field.
1283 Range 0..7.
1284 @param EndBit The ordinal of the most significant bit in the bit field.
1285 Range 0..7.
1286 @param Value New value of the bit field.
1287
1288 @return The value written back to the MMIO register.
1289
1290 **/
1291 UINT8
1292 EFIAPI
1293 MmioBitFieldWrite8 (
1294 IN UINTN Address,
1295 IN UINTN StartBit,
1296 IN UINTN EndBit,
1297 IN UINT8 Value
1298 )
1299 {
1300 return MmioWrite8 (
1301 Address,
1302 BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value)
1303 );
1304 }
1305
1306 /**
1307 Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and
1308 writes the result back to the bit field in the 8-bit MMIO register.
1309
1310 Reads the 8-bit MMIO register specified by Address, performs a bitwise
1311 OR between the read result and the value specified by OrData, and
1312 writes the result to the 8-bit MMIO register specified by Address. The value
1313 written to the MMIO register is returned. This function must guarantee that
1314 all MMIO read and write operations are serialized. Extra left bits in OrData
1315 are stripped.
1316
1317 If 8-bit MMIO register operations are not supported, then ASSERT().
1318 If StartBit is greater than 7, then ASSERT().
1319 If EndBit is greater than 7, then ASSERT().
1320 If EndBit is less than StartBit, then ASSERT().
1321
1322 @param Address MMIO register to write.
1323 @param StartBit The ordinal of the least significant bit in the bit field.
1324 Range 0..7.
1325 @param EndBit The ordinal of the most significant bit in the bit field.
1326 Range 0..7.
1327 @param OrData The value to OR with read value from the MMIO register.
1328
1329 @return The value written back to the MMIO register.
1330
1331 **/
1332 UINT8
1333 EFIAPI
1334 MmioBitFieldOr8 (
1335 IN UINTN Address,
1336 IN UINTN StartBit,
1337 IN UINTN EndBit,
1338 IN UINT8 OrData
1339 )
1340 {
1341 return MmioWrite8 (
1342 Address,
1343 BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData)
1344 );
1345 }
1346
1347 /**
1348 Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and
1349 writes the result back to the bit field in the 8-bit MMIO register.
1350
1351 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1352 between the read result and the value specified by AndData, and writes the
1353 result to the 8-bit MMIO register specified by Address. The value written to
1354 the MMIO register is returned. This function must guarantee that all MMIO
1355 read and write operations are serialized. Extra left bits in AndData are
1356 stripped.
1357
1358 If 8-bit MMIO register operations are not supported, then ASSERT().
1359 If StartBit is greater than 7, then ASSERT().
1360 If EndBit is greater than 7, then ASSERT().
1361 If EndBit is less than StartBit, then ASSERT().
1362
1363 @param Address MMIO register to write.
1364 @param StartBit The ordinal of the least significant bit in the bit field.
1365 Range 0..7.
1366 @param EndBit The ordinal of the most significant bit in the bit field.
1367 Range 0..7.
1368 @param AndData The value to AND with read value from the MMIO register.
1369
1370 @return The value written back to the MMIO register.
1371
1372 **/
1373 UINT8
1374 EFIAPI
1375 MmioBitFieldAnd8 (
1376 IN UINTN Address,
1377 IN UINTN StartBit,
1378 IN UINTN EndBit,
1379 IN UINT8 AndData
1380 )
1381 {
1382 return MmioWrite8 (
1383 Address,
1384 BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData)
1385 );
1386 }
1387
1388 /**
1389 Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed
1390 by a bitwise OR, and writes the result back to the bit field in the
1391 8-bit MMIO register.
1392
1393 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1394 followed by a bitwise OR between the read result and the value
1395 specified by AndData, and writes the result to the 8-bit MMIO register
1396 specified by Address. The value written to the MMIO register is returned.
1397 This function must guarantee that all MMIO read and write operations are
1398 serialized. Extra left bits in both AndData and OrData are stripped.
1399
1400 If 8-bit MMIO register operations are not supported, then ASSERT().
1401 If StartBit is greater than 7, then ASSERT().
1402 If EndBit is greater than 7, then ASSERT().
1403 If EndBit is less than StartBit, then ASSERT().
1404
1405 @param Address MMIO register to write.
1406 @param StartBit The ordinal of the least significant bit in the bit field.
1407 Range 0..7.
1408 @param EndBit The ordinal of the most significant bit in the bit field.
1409 Range 0..7.
1410 @param AndData The value to AND with read value from the MMIO register.
1411 @param OrData The value to OR with the result of the AND operation.
1412
1413 @return The value written back to the MMIO register.
1414
1415 **/
1416 UINT8
1417 EFIAPI
1418 MmioBitFieldAndThenOr8 (
1419 IN UINTN Address,
1420 IN UINTN StartBit,
1421 IN UINTN EndBit,
1422 IN UINT8 AndData,
1423 IN UINT8 OrData
1424 )
1425 {
1426 return MmioWrite8 (
1427 Address,
1428 BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData)
1429 );
1430 }
1431
1432 /**
1433 Reads a 16-bit MMIO register, performs a bitwise OR, and writes the
1434 result back to the 16-bit MMIO register.
1435
1436 Reads the 16-bit MMIO register specified by Address, performs a bitwise
1437 OR between the read result and the value specified by OrData, and
1438 writes the result to the 16-bit MMIO register specified by Address. The value
1439 written to the MMIO register is returned. This function must guarantee that
1440 all MMIO read and write operations are serialized.
1441
1442 If 16-bit MMIO register operations are not supported, then ASSERT().
1443
1444 @param Address The MMIO register to write.
1445 @param OrData The value to OR with the read value from the MMIO register.
1446
1447 @return The value written back to the MMIO register.
1448
1449 **/
1450 UINT16
1451 EFIAPI
1452 MmioOr16 (
1453 IN UINTN Address,
1454 IN UINT16 OrData
1455 )
1456 {
1457 return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData));
1458 }
1459
1460 /**
1461 Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result
1462 back to the 16-bit MMIO register.
1463
1464 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1465 between the read result and the value specified by AndData, and writes the
1466 result to the 16-bit MMIO register specified by Address. The value written to
1467 the MMIO register is returned. This function must guarantee that all MMIO
1468 read and write operations are serialized.
1469
1470 If 16-bit MMIO register operations are not supported, then ASSERT().
1471
1472 @param Address The MMIO register to write.
1473 @param AndData The value to AND with the read value from the MMIO register.
1474
1475 @return The value written back to the MMIO register.
1476
1477 **/
1478 UINT16
1479 EFIAPI
1480 MmioAnd16 (
1481 IN UINTN Address,
1482 IN UINT16 AndData
1483 )
1484 {
1485 return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData));
1486 }
1487
1488 /**
1489 Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise
1490 OR, and writes the result back to the 16-bit MMIO register.
1491
1492 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1493 between the read result and the value specified by AndData, performs a
1494 bitwise OR between the result of the AND operation and the value specified by
1495 OrData, and writes the result to the 16-bit MMIO register specified by
1496 Address. The value written to the MMIO register is returned. This function
1497 must guarantee that all MMIO read and write operations are serialized.
1498
1499 If 16-bit MMIO register operations are not supported, then ASSERT().
1500
1501
1502 @param Address The MMIO register to write.
1503 @param AndData The value to AND with the read value from the MMIO register.
1504 @param OrData The value to OR with the result of the AND operation.
1505
1506 @return The value written back to the MMIO register.
1507
1508 **/
1509 UINT16
1510 EFIAPI
1511 MmioAndThenOr16 (
1512 IN UINTN Address,
1513 IN UINT16 AndData,
1514 IN UINT16 OrData
1515 )
1516 {
1517 return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData));
1518 }
1519
1520 /**
1521 Reads a bit field of a MMIO register.
1522
1523 Reads the bit field in a 16-bit MMIO register. The bit field is specified by
1524 the StartBit and the EndBit. The value of the bit field is returned.
1525
1526 If 16-bit MMIO register operations are not supported, then ASSERT().
1527 If StartBit is greater than 15, then ASSERT().
1528 If EndBit is greater than 15, then ASSERT().
1529 If EndBit is less than StartBit, then ASSERT().
1530
1531 @param Address MMIO register to read.
1532 @param StartBit The ordinal of the least significant bit in the bit field.
1533 Range 0..15.
1534 @param EndBit The ordinal of the most significant bit in the bit field.
1535 Range 0..15.
1536
1537 @return The value read from I/O port specified by StartBit and
1538 EndBit.
1539
1540 **/
1541 UINT16
1542 EFIAPI
1543 MmioBitFieldRead16 (
1544 IN UINTN Address,
1545 IN UINTN StartBit,
1546 IN UINTN EndBit
1547 )
1548 {
1549 return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit);
1550 }
1551
1552 /**
1553 Writes a bit field to a MMIO register.
1554
1555 Writes Value to the bit field of the MMIO register. The bit field is
1556 specified by the StartBit and the EndBit. All other bits in the destination
1557 MMIO register are preserved. The new value of the 16-bit register is returned.
1558
1559 If 16-bit MMIO register operations are not supported, then ASSERT().
1560 If StartBit is greater than 15, then ASSERT().
1561 If EndBit is greater than 15, then ASSERT().
1562 If EndBit is less than StartBit, then ASSERT().
1563
1564 @param Address MMIO register to write.
1565 @param StartBit The ordinal of the least significant bit in the bit field.
1566 Range 0..15.
1567 @param EndBit The ordinal of the most significant bit in the bit field.
1568 Range 0..15.
1569 @param Value New value of the bit field.
1570
1571 @return The value written back to the MMIO register.
1572
1573 **/
1574 UINT16
1575 EFIAPI
1576 MmioBitFieldWrite16 (
1577 IN UINTN Address,
1578 IN UINTN StartBit,
1579 IN UINTN EndBit,
1580 IN UINT16 Value
1581 )
1582 {
1583 return MmioWrite16 (
1584 Address,
1585 BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value)
1586 );
1587 }
1588
1589 /**
1590 Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and
1591 writes the result back to the bit field in the 16-bit MMIO register.
1592
1593 Reads the 16-bit MMIO register specified by Address, performs a bitwise
1594 OR between the read result and the value specified by OrData, and
1595 writes the result to the 16-bit MMIO register specified by Address. The value
1596 written to the MMIO register is returned. This function must guarantee that
1597 all MMIO read and write operations are serialized. Extra left bits in OrData
1598 are stripped.
1599
1600 If 16-bit MMIO register operations are not supported, then ASSERT().
1601 If StartBit is greater than 15, then ASSERT().
1602 If EndBit is greater than 15, then ASSERT().
1603 If EndBit is less than StartBit, then ASSERT().
1604
1605 @param Address MMIO register to write.
1606 @param StartBit The ordinal of the least significant bit in the bit field.
1607 Range 0..15.
1608 @param EndBit The ordinal of the most significant bit in the bit field.
1609 Range 0..15.
1610 @param OrData The value to OR with read value from the MMIO register.
1611
1612 @return The value written back to the MMIO register.
1613
1614 **/
1615 UINT16
1616 EFIAPI
1617 MmioBitFieldOr16 (
1618 IN UINTN Address,
1619 IN UINTN StartBit,
1620 IN UINTN EndBit,
1621 IN UINT16 OrData
1622 )
1623 {
1624 return MmioWrite16 (
1625 Address,
1626 BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData)
1627 );
1628 }
1629
1630 /**
1631 Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and
1632 writes the result back to the bit field in the 16-bit MMIO register.
1633
1634 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1635 between the read result and the value specified by AndData, and writes the
1636 result to the 16-bit MMIO register specified by Address. The value written to
1637 the MMIO register is returned. This function must guarantee that all MMIO
1638 read and write operations are serialized. Extra left bits in AndData are
1639 stripped.
1640
1641 If 16-bit MMIO register operations are not supported, then ASSERT().
1642 If StartBit is greater than 15, then ASSERT().
1643 If EndBit is greater than 15, then ASSERT().
1644 If EndBit is less than StartBit, then ASSERT().
1645
1646 @param Address MMIO register to write.
1647 @param StartBit The ordinal of the least significant bit in the bit field.
1648 Range 0..15.
1649 @param EndBit The ordinal of the most significant bit in the bit field.
1650 Range 0..15.
1651 @param AndData The value to AND with read value from the MMIO register.
1652
1653 @return The value written back to the MMIO register.
1654
1655 **/
1656 UINT16
1657 EFIAPI
1658 MmioBitFieldAnd16 (
1659 IN UINTN Address,
1660 IN UINTN StartBit,
1661 IN UINTN EndBit,
1662 IN UINT16 AndData
1663 )
1664 {
1665 return MmioWrite16 (
1666 Address,
1667 BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData)
1668 );
1669 }
1670
1671 /**
1672 Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed
1673 by a bitwise OR, and writes the result back to the bit field in the
1674 16-bit MMIO register.
1675
1676 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1677 followed by a bitwise OR between the read result and the value
1678 specified by AndData, and writes the result to the 16-bit MMIO register
1679 specified by Address. The value written to the MMIO register is returned.
1680 This function must guarantee that all MMIO read and write operations are
1681 serialized. Extra left bits in both AndData and OrData are stripped.
1682
1683 If 16-bit MMIO register operations are not supported, then ASSERT().
1684 If StartBit is greater than 15, then ASSERT().
1685 If EndBit is greater than 15, then ASSERT().
1686 If EndBit is less than StartBit, then ASSERT().
1687
1688 @param Address MMIO register to write.
1689 @param StartBit The ordinal of the least significant bit in the bit field.
1690 Range 0..15.
1691 @param EndBit The ordinal of the most significant bit in the bit field.
1692 Range 0..15.
1693 @param AndData The value to AND with read value from the MMIO register.
1694 @param OrData The value to OR with the result of the AND operation.
1695
1696 @return The value written back to the MMIO register.
1697
1698 **/
1699 UINT16
1700 EFIAPI
1701 MmioBitFieldAndThenOr16 (
1702 IN UINTN Address,
1703 IN UINTN StartBit,
1704 IN UINTN EndBit,
1705 IN UINT16 AndData,
1706 IN UINT16 OrData
1707 )
1708 {
1709 return MmioWrite16 (
1710 Address,
1711 BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData)
1712 );
1713 }
1714
1715 /**
1716 Reads a 32-bit MMIO register, performs a bitwise OR, and writes the
1717 result back to the 32-bit MMIO register.
1718
1719 Reads the 32-bit MMIO register specified by Address, performs a bitwise
1720 OR between the read result and the value specified by OrData, and
1721 writes the result to the 32-bit MMIO register specified by Address. The value
1722 written to the MMIO register is returned. This function must guarantee that
1723 all MMIO read and write operations are serialized.
1724
1725 If 32-bit MMIO register operations are not supported, then ASSERT().
1726
1727 @param Address The MMIO register to write.
1728 @param OrData The value to OR with the read value from the MMIO register.
1729
1730 @return The value written back to the MMIO register.
1731
1732 **/
1733 UINT32
1734 EFIAPI
1735 MmioOr32 (
1736 IN UINTN Address,
1737 IN UINT32 OrData
1738 )
1739 {
1740 return MmioWrite32 (Address, MmioRead32 (Address) | OrData);
1741 }
1742
1743 /**
1744 Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result
1745 back to the 32-bit MMIO register.
1746
1747 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
1748 between the read result and the value specified by AndData, and writes the
1749 result to the 32-bit MMIO register specified by Address. The value written to
1750 the MMIO register is returned. This function must guarantee that all MMIO
1751 read and write operations are serialized.
1752
1753 If 32-bit MMIO register operations are not supported, then ASSERT().
1754
1755 @param Address The MMIO register to write.
1756 @param AndData The value to AND with the read value from the MMIO register.
1757
1758 @return The value written back to the MMIO register.
1759
1760 **/
1761 UINT32
1762 EFIAPI
1763 MmioAnd32 (
1764 IN UINTN Address,
1765 IN UINT32 AndData
1766 )
1767 {
1768 return MmioWrite32 (Address, MmioRead32 (Address) & AndData);
1769 }
1770
1771 /**
1772 Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise
1773 OR, and writes the result back to the 32-bit MMIO register.
1774
1775 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
1776 between the read result and the value specified by AndData, performs a
1777 bitwise OR between the result of the AND operation and the value specified by
1778 OrData, and writes the result to the 32-bit MMIO register specified by
1779 Address. The value written to the MMIO register is returned. This function
1780 must guarantee that all MMIO read and write operations are serialized.
1781
1782 If 32-bit MMIO register operations are not supported, then ASSERT().
1783
1784
1785 @param Address The MMIO register to write.
1786 @param AndData The value to AND with the read value from the MMIO register.
1787 @param OrData The value to OR with the result of the AND operation.
1788
1789 @return The value written back to the MMIO register.
1790
1791 **/
1792 UINT32
1793 EFIAPI
1794 MmioAndThenOr32 (
1795 IN UINTN Address,
1796 IN UINT32 AndData,
1797 IN UINT32 OrData
1798 )
1799 {
1800 return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData);
1801 }
1802
1803 /**
1804 Reads a bit field of a MMIO register.
1805
1806 Reads the bit field in a 32-bit MMIO register. The bit field is specified by
1807 the StartBit and the EndBit. The value of the bit field is returned.
1808
1809 If 32-bit MMIO register operations are not supported, then ASSERT().
1810 If StartBit is greater than 31, then ASSERT().
1811 If EndBit is greater than 31, then ASSERT().
1812 If EndBit is less than StartBit, then ASSERT().
1813
1814 @param Address MMIO register to read.
1815 @param StartBit The ordinal of the least significant bit in the bit field.
1816 Range 0..31.
1817 @param EndBit The ordinal of the most significant bit in the bit field.
1818 Range 0..31.
1819
1820 @return The value read from I/O port specified by StartBit and
1821 EndBit.
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 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 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 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 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 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 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 from I/O port specified by StartBit and
2104 EndBit.
2105
2106 **/
2107 UINT64
2108 EFIAPI
2109 MmioBitFieldRead64 (
2110 IN UINTN Address,
2111 IN UINTN StartBit,
2112 IN UINTN EndBit
2113 )
2114 {
2115 return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit);
2116 }
2117
2118 /**
2119 Writes a bit field to a MMIO register.
2120
2121 Writes Value to the bit field of the MMIO register. The bit field is
2122 specified by the StartBit and the EndBit. All other bits in the destination
2123 MMIO register are preserved. The new value of the 64-bit register is returned.
2124
2125 If 64-bit MMIO register operations are not supported, then ASSERT().
2126 If StartBit is greater than 63, then ASSERT().
2127 If EndBit is greater than 63, then ASSERT().
2128 If EndBit is less than StartBit, then ASSERT().
2129
2130 @param Address MMIO register to write.
2131 @param StartBit The ordinal of the least significant bit in the bit field.
2132 Range 0..63.
2133 @param EndBit The ordinal of the most significant bit in the bit field.
2134 Range 0..63.
2135 @param Value New value of the bit field.
2136
2137 @return The value written back to the MMIO register.
2138
2139 **/
2140 UINT64
2141 EFIAPI
2142 MmioBitFieldWrite64 (
2143 IN UINTN Address,
2144 IN UINTN StartBit,
2145 IN UINTN EndBit,
2146 IN UINT64 Value
2147 )
2148 {
2149 return MmioWrite64 (
2150 Address,
2151 BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value)
2152 );
2153 }
2154
2155 /**
2156 Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and
2157 writes the result back to the bit field in the 64-bit MMIO register.
2158
2159 Reads the 64-bit MMIO register specified by Address, performs a bitwise
2160 OR between the read result and the value specified by OrData, and
2161 writes the result to the 64-bit MMIO register specified by Address. The value
2162 written to the MMIO register is returned. This function must guarantee that
2163 all MMIO read and write operations are serialized. Extra left bits in OrData
2164 are stripped.
2165
2166 If 64-bit MMIO register operations are not supported, then ASSERT().
2167 If StartBit is greater than 63, then ASSERT().
2168 If EndBit is greater than 63, then ASSERT().
2169 If EndBit is less than StartBit, then ASSERT().
2170
2171 @param Address MMIO register to write.
2172 @param StartBit The ordinal of the least significant bit in the bit field.
2173 Range 0..63.
2174 @param EndBit The ordinal of the most significant bit in the bit field.
2175 Range 0..63.
2176 @param OrData The value to OR with read value from the MMIO register.
2177
2178 @return The value written back to the MMIO register.
2179
2180 **/
2181 UINT64
2182 EFIAPI
2183 MmioBitFieldOr64 (
2184 IN UINTN Address,
2185 IN UINTN StartBit,
2186 IN UINTN EndBit,
2187 IN UINT64 OrData
2188 )
2189 {
2190 return MmioWrite64 (
2191 Address,
2192 BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData)
2193 );
2194 }
2195
2196 /**
2197 Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and
2198 writes the result back to the bit field in the 64-bit MMIO register.
2199
2200 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2201 between the read result and the value specified by AndData, and writes the
2202 result to the 64-bit MMIO register specified by Address. The value written to
2203 the MMIO register is returned. This function must guarantee that all MMIO
2204 read and write operations are serialized. Extra left bits in AndData are
2205 stripped.
2206
2207 If 64-bit MMIO register operations are not supported, then ASSERT().
2208 If StartBit is greater than 63, then ASSERT().
2209 If EndBit is greater than 63, then ASSERT().
2210 If EndBit is less than StartBit, then ASSERT().
2211
2212 @param Address MMIO register to write.
2213 @param StartBit The ordinal of the least significant bit in the bit field.
2214 Range 0..63.
2215 @param EndBit The ordinal of the most significant bit in the bit field.
2216 Range 0..63.
2217 @param AndData The value to AND with read value from the MMIO register.
2218
2219 @return The value written back to the MMIO register.
2220
2221 **/
2222 UINT64
2223 EFIAPI
2224 MmioBitFieldAnd64 (
2225 IN UINTN Address,
2226 IN UINTN StartBit,
2227 IN UINTN EndBit,
2228 IN UINT64 AndData
2229 )
2230 {
2231 return MmioWrite64 (
2232 Address,
2233 BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData)
2234 );
2235 }
2236
2237 /**
2238 Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed
2239 by a bitwise OR, and writes the result back to the bit field in the
2240 64-bit MMIO register.
2241
2242 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2243 followed by a bitwise OR between the read result and the value
2244 specified by AndData, and writes the result to the 64-bit MMIO register
2245 specified by Address. The value written to the MMIO register is returned.
2246 This function must guarantee that all MMIO read and write operations are
2247 serialized. Extra left bits in both AndData and OrData are stripped.
2248
2249 If 64-bit MMIO register operations are not supported, then ASSERT().
2250 If StartBit is greater than 63, then ASSERT().
2251 If EndBit is greater than 63, then ASSERT().
2252 If EndBit is less than StartBit, then ASSERT().
2253
2254 @param Address MMIO register to write.
2255 @param StartBit The ordinal of the least significant bit in the bit field.
2256 Range 0..63.
2257 @param EndBit The ordinal of the most significant bit in the bit field.
2258 Range 0..63.
2259 @param AndData The value to AND with read value from the MMIO register.
2260 @param OrData The value to OR with the result of the AND operation.
2261
2262 @return The value written back to the MMIO register.
2263
2264 **/
2265 UINT64
2266 EFIAPI
2267 MmioBitFieldAndThenOr64 (
2268 IN UINTN Address,
2269 IN UINTN StartBit,
2270 IN UINTN EndBit,
2271 IN UINT64 AndData,
2272 IN UINT64 OrData
2273 )
2274 {
2275 return MmioWrite64 (
2276 Address,
2277 BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData)
2278 );
2279 }