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