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