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