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