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