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