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