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