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