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