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