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