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