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