2 I/O and MMIO Library Services that do I/O and also enable the I/O operatation
3 to be replayed during an S3 resume.
5 Copyright (c) 2006 -2018, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Library/S3IoLib.h>
14 #include <Library/DebugLib.h>
15 #include <Library/IoLib.h>
16 #include <Library/S3BootScriptLib.h>
19 Saves an I/O port value to the boot script.
21 This internal worker function saves an I/O port value in the S3 script
22 to be replayed on S3 resume.
24 If the saving process fails, then ASSERT().
26 @param Width The width of I/O port.
27 @param Port The I/O port to write.
28 @param Buffer The buffer containing value.
32 InternalSaveIoWriteValueToBootScript (
33 IN S3_BOOT_SCRIPT_LIB_WIDTH Width
,
40 Status
= S3BootScriptSaveIoWrite (
46 ASSERT (Status
== RETURN_SUCCESS
);
50 Saves an 8-bit I/O port value to the boot script.
52 This internal worker function saves an 8-bit I/O port value in the S3 script
53 to be replayed on S3 resume.
55 If the saving process fails, then ASSERT().
57 @param Port The I/O port to write.
58 @param Value The value saved to boot script.
64 InternalSaveIoWrite8ValueToBootScript (
69 InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint8
, Port
, &Value
);
75 Reads an 8-bit I/O port and saves the value in the S3 script to be replayed
78 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
79 This function must guarantee that all I/O read and write operations are
82 If 8-bit I/O port operations are not supported, then ASSERT().
84 @param Port The I/O port to read.
86 @return The value read.
95 return InternalSaveIoWrite8ValueToBootScript (Port
, IoRead8 (Port
));
99 Writes an 8-bit I/O port and saves the value in the S3 script to be replayed
102 Writes the 8-bit I/O port specified by Port with the value specified by Value
103 and returns Value. This function must guarantee that all I/O read and write
104 operations are serialized.
106 If 8-bit I/O port operations are not supported, then ASSERT().
108 @param Port The I/O port to write.
109 @param Value The value to write to the I/O port.
111 @return The value written the I/O port.
121 return InternalSaveIoWrite8ValueToBootScript (Port
, IoWrite8 (Port
, Value
));
125 Reads an 8-bit I/O port, performs a bitwise OR, and writes the
126 result back to the 8-bit I/O port and saves the value in the S3 script to be
127 replayed on S3 resume.
129 Reads the 8-bit I/O port specified by Port, performs a bitwise OR
130 between the read result and the value specified by OrData, and writes the
131 result to the 8-bit I/O port specified by Port. The value written to the I/O
132 port is returned. This function must guarantee that all I/O read and write
133 operations are serialized.
135 If 8-bit I/O port operations are not supported, then ASSERT().
137 @param Port The I/O port to write.
138 @param OrData The value to OR with the read value from the I/O port.
140 @return The value written back to the I/O port.
150 return InternalSaveIoWrite8ValueToBootScript (Port
, IoOr8 (Port
, OrData
));
154 Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back
155 to the 8-bit I/O port and saves the value in the S3 script to be replayed
158 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
159 the read result and the value specified by AndData, and writes the result to
160 the 8-bit I/O port specified by Port. The value written to the I/O port is
161 returned. This function must guarantee that all I/O read and write operations
164 If 8-bit I/O port operations are not supported, then ASSERT().
166 @param Port The I/O port to write.
167 @param AndData The value to AND with the read value from the I/O port.
169 @return The value written back to the I/O port.
179 return InternalSaveIoWrite8ValueToBootScript (Port
, IoAnd8 (Port
, AndData
));
183 Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise
184 inclusive OR, and writes the result back to the 8-bit I/O port and saves
185 the value in the S3 script to be replayed on S3 resume.
187 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
188 the read result and the value specified by AndData, performs a bitwise OR
189 between the result of the AND operation and the value specified by OrData,
190 and writes the result to the 8-bit I/O port specified by Port. The value
191 written to the I/O port is returned. This function must guarantee that all
192 I/O read and write operations are serialized.
194 If 8-bit I/O port operations are not supported, then ASSERT().
196 @param Port The I/O port to write.
197 @param AndData The value to AND with the read value from the I/O port.
198 @param OrData The value to OR with the result of the AND operation.
200 @return The value written back to the I/O port.
211 return InternalSaveIoWrite8ValueToBootScript (Port
, IoAndThenOr8 (Port
, AndData
, OrData
));
215 Reads a bit field of an I/O register and saves the value in the S3 script to
216 be replayed on S3 resume.
218 Reads the bit field in an 8-bit I/O register. The bit field is specified by
219 the StartBit and the EndBit. The value of the bit field is returned.
221 If 8-bit I/O port operations are not supported, then ASSERT().
222 If StartBit is greater than 7, then ASSERT().
223 If EndBit is greater than 7, then ASSERT().
224 If EndBit is less than StartBit, then ASSERT().
226 @param Port The I/O port to read.
227 @param StartBit The ordinal of the least significant bit in the bit field.
229 @param EndBit The ordinal of the most significant bit in the bit field.
232 @return The value read.
243 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldRead8 (Port
, StartBit
, EndBit
));
247 Writes a bit field to an I/O register and saves the value in the S3 script to
248 be replayed on S3 resume.
250 Writes Value to the bit field of the I/O register. The bit field is specified
251 by the StartBit and the EndBit. All other bits in the destination I/O
252 register are preserved. The value written to the I/O port is returned. Extra
253 left bits in Value are stripped.
255 If 8-bit I/O port operations are not supported, then ASSERT().
256 If StartBit is greater than 7, then ASSERT().
257 If EndBit is greater than 7, then ASSERT().
258 If EndBit is less than StartBit, then ASSERT().
259 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
261 @param Port The I/O port to write.
262 @param StartBit The ordinal of the least significant bit in the bit field.
264 @param EndBit The ordinal of the most significant bit in the bit field.
266 @param Value New value of the bit field.
268 @return The value written back to the I/O port.
280 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldWrite8 (Port
, StartBit
, EndBit
, Value
));
284 Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the
285 result back to the bit field in the 8-bit port and saves the value in the
286 S3 script to be replayed on S3 resume.
288 Reads the 8-bit I/O port specified by Port, performs a bitwise OR
289 between the read result and the value specified by OrData, and writes the
290 result to the 8-bit I/O port specified by Port. The value written to the I/O
291 port is returned. This function must guarantee that all I/O read and write
292 operations are serialized. Extra left bits in OrData are stripped.
294 If 8-bit I/O port operations are not supported, then ASSERT().
295 If StartBit is greater than 7, then ASSERT().
296 If EndBit is greater than 7, then ASSERT().
297 If EndBit is less than StartBit, then ASSERT().
298 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
300 @param Port The I/O port to write.
301 @param StartBit The ordinal of the least significant bit in the bit field.
303 @param EndBit The ordinal of the most significant bit in the bit field.
305 @param OrData The value to OR with the read value from the I/O port.
307 @return The value written back to the I/O port.
319 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldOr8 (Port
, StartBit
, EndBit
, OrData
));
323 Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the
324 result back to the bit field in the 8-bit port and saves the value in the
325 S3 script to be replayed on S3 resume.
327 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
328 the read result and the value specified by AndData, and writes the result to
329 the 8-bit I/O port specified by Port. The value written to the I/O port is
330 returned. This function must guarantee that all I/O read and write operations
331 are serialized. Extra left bits in AndData are stripped.
333 If 8-bit I/O port operations are not supported, then ASSERT().
334 If StartBit is greater than 7, then ASSERT().
335 If EndBit is greater than 7, then ASSERT().
336 If EndBit is less than StartBit, then ASSERT().
337 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
339 @param Port The I/O port to write.
340 @param StartBit The ordinal of the least significant bit in the bit field.
342 @param EndBit The ordinal of the most significant bit in the bit field.
344 @param AndData The value to AND with the read value from the I/O port.
346 @return The value written back to the I/O port.
358 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldAnd8 (Port
, StartBit
, EndBit
, AndData
));
362 Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
363 bitwise OR, and writes the result back to the bit field in the
364 8-bit port and saves the value in the S3 script to be replayed on S3 resume.
366 Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed
367 by a bitwise OR between the read result and the value specified by
368 AndData, and writes the result to the 8-bit I/O port specified by Port. The
369 value written to the I/O port is returned. This function must guarantee that
370 all I/O read and write operations are serialized. Extra left bits in both
371 AndData and OrData are stripped.
373 If 8-bit I/O port operations are not supported, then ASSERT().
374 If StartBit is greater than 7, then ASSERT().
375 If EndBit is greater than 7, then ASSERT().
376 If EndBit is less than StartBit, then ASSERT().
377 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
378 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
380 @param Port The I/O port to write.
381 @param StartBit The ordinal of the least significant bit in the bit field.
383 @param EndBit The ordinal of the most significant bit in the bit field.
385 @param AndData The value to AND with the read value from the I/O port.
386 @param OrData The value to OR with the result of the AND operation.
388 @return The value written back to the I/O port.
393 S3IoBitFieldAndThenOr8 (
401 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldAndThenOr8 (Port
, StartBit
, EndBit
, AndData
, OrData
));
405 Saves a 16-bit I/O port value to the boot script.
407 This internal worker function saves a 16-bit I/O port value in the S3 script
408 to be replayed on S3 resume.
410 If the saving process fails, then ASSERT().
412 @param Port The I/O port to write.
413 @param Value The value saved to boot script.
419 InternalSaveIoWrite16ValueToBootScript (
424 InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint16
, Port
, &Value
);
430 Reads a 16-bit I/O port and saves the value in the S3 script to be replayed
433 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
434 This function must guarantee that all I/O read and write operations are
437 If 16-bit I/O port operations are not supported, then ASSERT().
439 @param Port The I/O port to read.
441 @return The value read.
450 return InternalSaveIoWrite16ValueToBootScript (Port
, IoRead16 (Port
));
454 Writes a 16-bit I/O port and saves the value in the S3 script to be replayed
457 Writes the 16-bit I/O port specified by Port with the value specified by Value
458 and returns Value. This function must guarantee that all I/O read and write
459 operations are serialized.
461 If 16-bit I/O port operations are not supported, then ASSERT().
463 @param Port The I/O port to write.
464 @param Value The value to write to the I/O port.
466 @return The value written the I/O port.
476 return InternalSaveIoWrite16ValueToBootScript (Port
, IoWrite16 (Port
, Value
));
480 Reads a 16-bit I/O port, performs a bitwise OR, and writes the
481 result back to the 16-bit I/O port and saves the value in the S3 script to
482 be replayed on S3 resume.
484 Reads the 16-bit I/O port specified by Port, performs a bitwise OR
485 between the read result and the value specified by OrData, and writes the
486 result to the 16-bit I/O port specified by Port. The value written to the I/O
487 port is returned. This function must guarantee that all I/O read and write
488 operations are serialized.
490 If 16-bit I/O port operations are not supported, then ASSERT().
492 @param Port The I/O port to write.
493 @param OrData The value to OR with the read value from the I/O port.
495 @return The value written back to the I/O port.
505 return InternalSaveIoWrite16ValueToBootScript (Port
, IoOr16 (Port
, OrData
));
509 Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back
510 to the 16-bit I/O port and saves the value in the S3 script to be replayed
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
519 If 16-bit I/O port operations are not supported, then ASSERT().
521 @param Port The I/O port to write.
522 @param AndData The value to AND with the read value from the I/O port.
524 @return The value written back to the I/O port.
534 return InternalSaveIoWrite16ValueToBootScript (Port
, IoAnd16 (Port
, AndData
));
538 Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise
539 inclusive OR, and writes the result back to the 16-bit I/O port and saves
540 the value in the S3 script to be replayed on S3 resume.
542 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
543 the read result and the value specified by AndData, performs a bitwise OR
544 between the result of the AND operation and the value specified by OrData,
545 and writes the result to the 16-bit I/O port specified by Port. The value
546 written to the I/O port is returned. This function must guarantee that all
547 I/O read and write operations are serialized.
549 If 16-bit I/O port operations are not supported, then ASSERT().
551 @param Port The I/O port to write.
552 @param AndData The value to AND with the read value from the I/O port.
553 @param OrData The value to OR with the result of the AND operation.
555 @return The value written back to the I/O port.
566 return InternalSaveIoWrite16ValueToBootScript (Port
, IoAndThenOr16 (Port
, AndData
, OrData
));
570 Reads a bit field of an I/O register saves the value in the S3 script to be
571 replayed on S3 resume.
573 Reads the bit field in a 16-bit I/O register. The bit field is specified by
574 the StartBit and the EndBit. The value of the bit field is returned.
576 If 16-bit I/O port operations are not supported, then ASSERT().
577 If StartBit is greater than 15, then ASSERT().
578 If EndBit is greater than 15, then ASSERT().
579 If EndBit is less than StartBit, then ASSERT().
581 @param Port The I/O port to read.
582 @param StartBit The ordinal of the least significant bit in the bit field.
584 @param EndBit The ordinal of the most significant bit in the bit field.
587 @return The value read.
598 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldRead16 (Port
, StartBit
, EndBit
));
602 Writes a bit field to an I/O register and saves the value in the S3 script
603 to be replayed on S3 resume.
605 Writes Value to the bit field of the I/O register. The bit field is specified
606 by the StartBit and the EndBit. All other bits in the destination I/O
607 register are preserved. The value written to the I/O port is returned. Extra
608 left bits in Value are stripped.
610 If 16-bit I/O port operations are not supported, then ASSERT().
611 If StartBit is greater than 15, then ASSERT().
612 If EndBit is greater than 15, then ASSERT().
613 If EndBit is less than StartBit, then ASSERT().
614 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
616 @param Port The I/O port to write.
617 @param StartBit The ordinal of the least significant bit in the bit field.
619 @param EndBit The ordinal of the most significant bit in the bit field.
621 @param Value New value of the bit field.
623 @return The value written back to the I/O port.
628 S3IoBitFieldWrite16 (
635 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldWrite16 (Port
, StartBit
, EndBit
, Value
));
639 Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the
640 result back to the bit field in the 16-bit port and saves the value in the
641 S3 script to be replayed on S3 resume.
643 Reads the 16-bit I/O port specified by Port, performs a bitwise OR
644 between the read result and the value specified by OrData, and writes the
645 result to the 16-bit I/O port specified by Port. The value written to the I/O
646 port is returned. This function must guarantee that all I/O read and write
647 operations are serialized. Extra left bits in OrData are stripped.
649 If 16-bit I/O port operations are not supported, then ASSERT().
650 If StartBit is greater than 15, then ASSERT().
651 If EndBit is greater than 15, then ASSERT().
652 If EndBit is less than StartBit, then ASSERT().
653 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
655 @param Port The I/O port to write.
656 @param StartBit The ordinal of the least significant bit in the bit field.
658 @param EndBit The ordinal of the most significant bit in the bit field.
660 @param OrData The value to OR with the read value from the I/O port.
662 @return The value written back to the I/O port.
674 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldOr16 (Port
, StartBit
, EndBit
, OrData
));
678 Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the
679 result back to the bit field in the 16-bit port and saves the value in the
680 S3 script to be replayed on S3 resume.
682 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
683 the read result and the value specified by AndData, and writes the result to
684 the 16-bit I/O port specified by Port. The value written to the I/O port is
685 returned. This function must guarantee that all I/O read and write operations
686 are serialized. Extra left bits in AndData are stripped.
688 If 16-bit I/O port operations are not supported, then ASSERT().
689 If StartBit is greater than 15, then ASSERT().
690 If EndBit is greater than 15, then ASSERT().
691 If EndBit is less than StartBit, then ASSERT().
692 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
694 @param Port The I/O port to write.
695 @param StartBit The ordinal of the least significant bit in the bit field.
697 @param EndBit The ordinal of the most significant bit in the bit field.
699 @param AndData The value to AND with the read value from the I/O port.
701 @return The value written back to the I/O port.
713 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldAnd16 (Port
, StartBit
, EndBit
, AndData
));
717 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
718 bitwise OR, and writes the result back to the bit field in the
719 16-bit port and saves the value in the S3 script to be replayed on S3
722 Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed
723 by a bitwise OR between the read result and the value specified by
724 AndData, and writes the result to the 16-bit I/O port specified by Port. The
725 value written to the I/O port is returned. This function must guarantee that
726 all I/O read and write operations are serialized. Extra left bits in both
727 AndData and OrData are stripped.
729 If 16-bit I/O port operations are not supported, then ASSERT().
730 If StartBit is greater than 15, then ASSERT().
731 If EndBit is greater than 15, then ASSERT().
732 If EndBit is less than StartBit, then ASSERT().
733 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
734 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
736 @param Port The I/O port to write.
737 @param StartBit The ordinal of the least significant bit in the bit field.
739 @param EndBit The ordinal of the most significant bit in the bit field.
741 @param AndData The value to AND with the read value from the I/O port.
742 @param OrData The value to OR with the result of the AND operation.
744 @return The value written back to the I/O port.
749 S3IoBitFieldAndThenOr16 (
757 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldAndThenOr16 (Port
, StartBit
, EndBit
, AndData
, OrData
));
761 Saves a 32-bit I/O port value to the boot script.
763 This internal worker function saves a 32-bit I/O port value in the S3 script
764 to be replayed on S3 resume.
766 If the saving process fails, then ASSERT().
768 @param Port The I/O port to write.
769 @param Value The value saved to boot script.
775 InternalSaveIoWrite32ValueToBootScript (
780 InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint32
, Port
, &Value
);
786 Reads a 32-bit I/O port and saves the value in the S3 script to be replayed
789 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
790 This function must guarantee that all I/O read and write operations are
793 If 32-bit I/O port operations are not supported, then ASSERT().
795 @param Port The I/O port to read.
797 @return The value read.
806 return InternalSaveIoWrite32ValueToBootScript (Port
, IoRead32 (Port
));
810 Writes a 32-bit I/O port and saves the value in the S3 script to be replayed
813 Writes the 32-bit I/O port specified by Port with the value specified by Value
814 and returns Value. This function must guarantee that all I/O read and write
815 operations are serialized.
817 If 32-bit I/O port operations are not supported, then ASSERT().
819 @param Port The I/O port to write.
820 @param Value The value to write to the I/O port.
822 @return The value written the I/O port.
832 return InternalSaveIoWrite32ValueToBootScript (Port
, IoWrite32 (Port
, Value
));
836 Reads a 32-bit I/O port, performs a bitwise OR, and writes the
837 result back to the 32-bit I/O port and saves the value in the S3 script to
838 be replayed on S3 resume.
840 Reads the 32-bit I/O port specified by Port, performs a bitwise OR
841 between the read result and the value specified by OrData, and writes the
842 result to the 32-bit I/O port specified by Port. The value written to the I/O
843 port is returned. This function must guarantee that all I/O read and write
844 operations are serialized.
846 If 32-bit I/O port operations are not supported, then ASSERT().
848 @param Port The I/O port to write.
849 @param OrData The value to OR with the read value from the I/O port.
851 @return The value written back to the I/O port.
861 return InternalSaveIoWrite32ValueToBootScript (Port
, IoOr32 (Port
, OrData
));
865 Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back
866 to the 32-bit I/O port and saves the value in the S3 script to be replayed
869 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
870 the read result and the value specified by AndData, and writes the result to
871 the 32-bit I/O port specified by Port. The value written to the I/O port is
872 returned. This function must guarantee that all I/O read and write operations
875 If 32-bit I/O port operations are not supported, then ASSERT().
877 @param Port The I/O port to write.
878 @param AndData The value to AND with the read value from the I/O port.
880 @return The value written back to the I/O port.
890 return InternalSaveIoWrite32ValueToBootScript (Port
, IoAnd32 (Port
, AndData
));
894 Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise
895 inclusive OR, and writes the result back to the 32-bit I/O port and saves
896 the value in the S3 script to be replayed on S3 resume.
898 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
899 the read result and the value specified by AndData, performs a bitwise OR
900 between the result of the AND operation and the value specified by OrData,
901 and writes the result to the 32-bit I/O port specified by Port. The value
902 written to the I/O port is returned. This function must guarantee that all
903 I/O read and write operations are serialized.
905 If 32-bit I/O port operations are not supported, then ASSERT().
907 @param Port The I/O port to write.
908 @param AndData The value to AND with the read value from the I/O port.
909 @param OrData The value to OR with the result of the AND operation.
911 @return The value written back to the I/O port.
922 return InternalSaveIoWrite32ValueToBootScript (Port
, IoAndThenOr32 (Port
, AndData
, OrData
));
926 Reads a bit field of an I/O register and saves the value in the S3 script to
927 be replayed on S3 resume.
929 Reads the bit field in a 32-bit I/O register. The bit field is specified by
930 the StartBit and the EndBit. The value of the bit field is returned.
932 If 32-bit I/O port operations are not supported, then ASSERT().
933 If StartBit is greater than 31, then ASSERT().
934 If EndBit is greater than 31, then ASSERT().
935 If EndBit is less than StartBit, then ASSERT().
937 @param Port The I/O port to read.
938 @param StartBit The ordinal of the least significant bit in the bit field.
940 @param EndBit The ordinal of the most significant bit in the bit field.
943 @return The value read.
954 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldRead32 (Port
, StartBit
, EndBit
));
958 Writes a bit field to an I/O register and saves the value in the S3 script to
959 be replayed on S3 resume.
961 Writes Value to the bit field of the I/O register. The bit field is specified
962 by the StartBit and the EndBit. All other bits in the destination I/O
963 register are preserved. The value written to the I/O port is returned. Extra
964 left bits in Value are stripped.
966 If 32-bit I/O port operations are not supported, then ASSERT().
967 If StartBit is greater than 31, then ASSERT().
968 If EndBit is greater than 31, then ASSERT().
969 If EndBit is less than StartBit, then ASSERT().
970 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
972 @param Port The I/O port to write.
973 @param StartBit The ordinal of the least significant bit in the bit field.
975 @param EndBit The ordinal of the most significant bit in the bit field.
977 @param Value New value of the bit field.
979 @return The value written back to the I/O port.
984 S3IoBitFieldWrite32 (
991 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldWrite32 (Port
, StartBit
, EndBit
, Value
));
995 Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the
996 result back to the bit field in the 32-bit port and saves the value in the
997 S3 script to be replayed on S3 resume.
999 Reads the 32-bit I/O port specified by Port, performs a bitwise OR
1000 between the read result and the value specified by OrData, and writes the
1001 result to the 32-bit I/O port specified by Port. The value written to the I/O
1002 port is returned. This function must guarantee that all I/O read and write
1003 operations are serialized. Extra left bits in OrData are stripped.
1005 If 32-bit I/O port operations are not supported, then ASSERT().
1006 If StartBit is greater than 31, then ASSERT().
1007 If EndBit is greater than 31, then ASSERT().
1008 If EndBit is less than StartBit, then ASSERT().
1009 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1011 @param Port The I/O port to write.
1012 @param StartBit The ordinal of the least significant bit in the bit field.
1014 @param EndBit The ordinal of the most significant bit in the bit field.
1016 @param OrData The value to OR with the read value from the I/O port.
1018 @return The value written back to the I/O port.
1030 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldOr32 (Port
, StartBit
, EndBit
, OrData
));
1034 Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the
1035 result back to the bit field in the 32-bit port and saves the value in the
1036 S3 script to be replayed on S3 resume.
1038 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
1039 the read result and the value specified by AndData, and writes the result to
1040 the 32-bit I/O port specified by Port. The value written to the I/O port is
1041 returned. This function must guarantee that all I/O read and write operations
1042 are serialized. Extra left bits in AndData are stripped.
1044 If 32-bit I/O port operations are not supported, then ASSERT().
1045 If StartBit is greater than 31, then ASSERT().
1046 If EndBit is greater than 31, then ASSERT().
1047 If EndBit is less than StartBit, then ASSERT().
1048 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1050 @param Port The I/O port to write.
1051 @param StartBit The ordinal of the least significant bit in the bit field.
1053 @param EndBit The ordinal of the most significant bit in the bit field.
1055 @param AndData The value to AND with the read value from the I/O port.
1057 @return The value written back to the I/O port.
1069 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldAnd32 (Port
, StartBit
, EndBit
, AndData
));
1073 Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
1074 bitwise OR, and writes the result back to the bit field in the
1075 32-bit port and saves the value in the S3 script to be replayed on S3
1078 Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed
1079 by a bitwise OR between the read result and the value specified by
1080 AndData, and writes the result to the 32-bit I/O port specified by Port. The
1081 value written to the I/O port is returned. This function must guarantee that
1082 all I/O read and write operations are serialized. Extra left bits in both
1083 AndData and OrData are stripped.
1085 If 32-bit I/O port operations are not supported, then ASSERT().
1086 If StartBit is greater than 31, then ASSERT().
1087 If EndBit is greater than 31, then ASSERT().
1088 If EndBit is less than StartBit, then ASSERT().
1089 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1090 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1092 @param Port The I/O port to write.
1093 @param StartBit The ordinal of the least significant bit in the bit field.
1095 @param EndBit The ordinal of the most significant bit in the bit field.
1097 @param AndData The value to AND with the read value from the I/O port.
1098 @param OrData The value to OR with the result of the AND operation.
1100 @return The value written back to the I/O port.
1105 S3IoBitFieldAndThenOr32 (
1113 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldAndThenOr32 (Port
, StartBit
, EndBit
, AndData
, OrData
));
1117 Saves a 64-bit I/O port value to the boot script.
1119 This internal worker function saves a 64-bit I/O port value in the S3 script
1120 to be replayed on S3 resume.
1122 If the saving process fails, then ASSERT().
1124 @param Port The I/O port to write.
1125 @param Value The value saved to boot script.
1131 InternalSaveIoWrite64ValueToBootScript (
1136 InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint64
, Port
, &Value
);
1142 Reads a 64-bit I/O port and saves the value in the S3 script to be replayed
1145 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
1146 This function must guarantee that all I/O read and write operations are
1149 If 64-bit I/O port operations are not supported, then ASSERT().
1151 @param Port The I/O port to read.
1153 @return The value read.
1162 return InternalSaveIoWrite64ValueToBootScript (Port
, IoRead64 (Port
));
1166 Writes a 64-bit I/O port and saves the value in the S3 script to be replayed
1169 Writes the 64-bit I/O port specified by Port with the value specified by Value
1170 and returns Value. This function must guarantee that all I/O read and write
1171 operations are serialized.
1173 If 64-bit I/O port operations are not supported, then ASSERT().
1175 @param Port The I/O port to write.
1176 @param Value The value to write to the I/O port.
1178 @return The value written the I/O port.
1188 return InternalSaveIoWrite64ValueToBootScript (Port
, IoWrite64 (Port
, Value
));
1192 Reads a 64-bit I/O port, performs a bitwise OR, and writes the
1193 result back to the 64-bit I/O port and saves the value in the S3 script to
1194 be replayed on S3 resume.
1196 Reads the 64-bit I/O port specified by Port, performs a bitwise OR
1197 between the read result and the value specified by OrData, and writes the
1198 result to the 64-bit I/O port specified by Port. The value written to the I/O
1199 port is returned. This function must guarantee that all I/O read and write
1200 operations are serialized.
1202 If 64-bit I/O port operations are not supported, then ASSERT().
1204 @param Port The I/O port to write.
1205 @param OrData The value to OR with the read value from the I/O port.
1207 @return The value written back to the I/O port.
1217 return InternalSaveIoWrite64ValueToBootScript (Port
, IoOr64 (Port
, OrData
));
1221 Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back
1222 to the 64-bit I/O port and saves the value in the S3 script to be replayed
1225 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
1226 the read result and the value specified by AndData, and writes the result to
1227 the 64-bit I/O port specified by Port. The value written to the I/O port is
1228 returned. This function must guarantee that all I/O read and write operations
1231 If 64-bit I/O port operations are not supported, then ASSERT().
1233 @param Port The I/O port to write.
1234 @param AndData The value to AND with the read value from the I/O port.
1236 @return The value written back to the I/O port.
1246 return InternalSaveIoWrite64ValueToBootScript (Port
, IoAnd64 (Port
, AndData
));
1250 Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise
1251 inclusive OR, and writes the result back to the 64-bit I/O port and saves
1252 the value in the S3 script to be replayed on S3 resume.
1254 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
1255 the read result and the value specified by AndData, performs a bitwise OR
1256 between the result of the AND operation and the value specified by OrData,
1257 and writes the result to the 64-bit I/O port specified by Port. The value
1258 written to the I/O port is returned. This function must guarantee that all
1259 I/O read and write operations are serialized.
1261 If 64-bit I/O port operations are not supported, then ASSERT().
1263 @param Port The I/O port to write.
1264 @param AndData The value to AND with the read value from the I/O port.
1265 @param OrData The value to OR with the result of the AND operation.
1267 @return The value written back to the I/O port.
1278 return InternalSaveIoWrite64ValueToBootScript (Port
, IoAndThenOr64 (Port
, AndData
, OrData
));
1282 Reads a bit field of an I/O register and saves the value in the S3 script to
1283 be replayed on S3 resume.
1285 Reads the bit field in a 64-bit I/O register. The bit field is specified by
1286 the StartBit and the EndBit. The value of the bit field is returned.
1288 If 64-bit I/O port operations are not supported, then ASSERT().
1289 If StartBit is greater than 63, then ASSERT().
1290 If EndBit is greater than 63, then ASSERT().
1291 If EndBit is less than StartBit, then ASSERT().
1293 @param Port The I/O port to read.
1294 @param StartBit The ordinal of the least significant bit in the bit field.
1296 @param EndBit The ordinal of the most significant bit in the bit field.
1299 @return The value read.
1304 S3IoBitFieldRead64 (
1310 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldRead64 (Port
, StartBit
, EndBit
));
1314 Writes a bit field to an I/O register and saves the value in the S3 script to
1315 be replayed on S3 resume.
1317 Writes Value to the bit field of the I/O register. The bit field is specified
1318 by the StartBit and the EndBit. All other bits in the destination I/O
1319 register are preserved. The value written to the I/O port is returned. Extra
1320 left bits in Value are stripped.
1322 If 64-bit I/O port operations are not supported, then ASSERT().
1323 If StartBit is greater than 63, then ASSERT().
1324 If EndBit is greater than 63, then ASSERT().
1325 If EndBit is less than StartBit, then ASSERT().
1326 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1328 @param Port The I/O port to write.
1329 @param StartBit The ordinal of the least significant bit in the bit field.
1331 @param EndBit The ordinal of the most significant bit in the bit field.
1333 @param Value New value of the bit field.
1335 @return The value written back to the I/O port.
1340 S3IoBitFieldWrite64 (
1347 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldWrite64 (Port
, StartBit
, EndBit
, Value
));
1351 Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the
1352 result back to the bit field in the 64-bit port and saves the value in the
1353 S3 script to be replayed on S3 resume.
1355 Reads the 64-bit I/O port specified by Port, performs a bitwise OR
1356 between the read result and the value specified by OrData, and writes the
1357 result to the 64-bit I/O port specified by Port. The value written to the I/O
1358 port is returned. This function must guarantee that all I/O read and write
1359 operations are serialized. Extra left bits in OrData are stripped.
1361 If 64-bit I/O port operations are not supported, then ASSERT().
1362 If StartBit is greater than 63, then ASSERT().
1363 If EndBit is greater than 63, then ASSERT().
1364 If EndBit is less than StartBit, then ASSERT().
1365 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1367 @param Port The I/O port to write.
1368 @param StartBit The ordinal of the least significant bit in the bit field.
1370 @param EndBit The ordinal of the most significant bit in the bit field.
1372 @param OrData The value to OR with the read value from the I/O port.
1374 @return The value written back to the I/O port.
1386 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldOr64 (Port
, StartBit
, EndBit
, OrData
));
1390 Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the
1391 result back to the bit field in the 64-bit port and saves the value in the
1392 S3 script to be replayed on S3 resume.
1394 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
1395 the read result and the value specified by AndData, and writes the result to
1396 the 64-bit I/O port specified by Port. The value written to the I/O port is
1397 returned. This function must guarantee that all I/O read and write operations
1398 are serialized. Extra left bits in AndData are stripped.
1400 If 64-bit I/O port operations are not supported, then ASSERT().
1401 If StartBit is greater than 63, then ASSERT().
1402 If EndBit is greater than 63, then ASSERT().
1403 If EndBit is less than StartBit, then ASSERT().
1404 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1406 @param Port The I/O port to write.
1407 @param StartBit The ordinal of the least significant bit in the bit field.
1409 @param EndBit The ordinal of the most significant bit in the bit field.
1411 @param AndData The value to AND with the read value from the I/O port.
1413 @return The value written back to the I/O port.
1425 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldAnd64 (Port
, StartBit
, EndBit
, AndData
));
1429 Reads a bit field in a 64-bit port, performs a bitwise AND followed by a
1430 bitwise OR, and writes the result back to the bit field in the
1431 64-bit port and saves the value in the S3 script to be replayed on S3
1434 Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed
1435 by a bitwise OR between the read result and the value specified by
1436 AndData, and writes the result to the 64-bit I/O port specified by Port. The
1437 value written to the I/O port is returned. This function must guarantee that
1438 all I/O read and write operations are serialized. Extra left bits in both
1439 AndData and OrData are stripped.
1441 If 64-bit I/O port operations are not supported, then ASSERT().
1442 If StartBit is greater than 63, then ASSERT().
1443 If EndBit is greater than 63, then ASSERT().
1444 If EndBit is less than StartBit, then ASSERT().
1445 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1446 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1448 @param Port The I/O port to write.
1449 @param StartBit The ordinal of the least significant bit in the bit field.
1451 @param EndBit The ordinal of the most significant bit in the bit field.
1453 @param AndData The value to AND with the read value from the I/O port.
1454 @param OrData The value to OR with the result of the AND operation.
1456 @return The value written back to the I/O port.
1461 S3IoBitFieldAndThenOr64 (
1469 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldAndThenOr64 (Port
, StartBit
, EndBit
, AndData
, OrData
));
1473 Saves an MMIO register value to the boot script.
1475 This internal worker function saves an MMIO register value in the S3 script
1476 to be replayed on S3 resume.
1478 If the saving process fails, then ASSERT().
1480 @param Width The width of MMIO register.
1481 @param Address The MMIO register to write.
1482 @param Buffer The buffer containing value.
1486 InternalSaveMmioWriteValueToBootScript (
1487 IN S3_BOOT_SCRIPT_LIB_WIDTH Width
,
1492 RETURN_STATUS Status
;
1494 Status
= S3BootScriptSaveMemWrite (
1500 ASSERT (Status
== RETURN_SUCCESS
);
1504 Saves an 8-bit MMIO register value to the boot script.
1506 This internal worker function saves an 8-bit MMIO register value in the S3 script
1507 to be replayed on S3 resume.
1509 If the saving process fails, then ASSERT().
1511 @param Address The MMIO register to write.
1512 @param Value The value saved to boot script.
1518 InternalSaveMmioWrite8ValueToBootScript (
1523 InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint8
, Address
, &Value
);
1529 Reads an 8-bit MMIO register and saves the value in the S3 script to be
1530 replayed on S3 resume.
1532 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
1533 returned. This function must guarantee that all MMIO read and write
1534 operations are serialized.
1536 If 8-bit MMIO register operations are not supported, then ASSERT().
1538 @param Address The MMIO register to read.
1540 @return The value read.
1549 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioRead8 (Address
));
1553 Writes an 8-bit MMIO register and saves the value in the S3 script to be
1554 replayed on S3 resume.
1556 Writes the 8-bit MMIO register specified by Address with the value specified
1557 by Value and returns Value. This function must guarantee that all MMIO read
1558 and write operations are serialized.
1560 If 8-bit MMIO register operations are not supported, then ASSERT().
1562 @param Address The MMIO register to write.
1563 @param Value The value to write to the MMIO register.
1565 @return The value written the MMIO register.
1575 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioWrite8 (Address
, Value
));
1579 Reads an 8-bit MMIO register, performs a bitwise OR, and writes the
1580 result back to the 8-bit MMIO register and saves the value in the S3 script
1581 to be replayed on S3 resume.
1583 Reads the 8-bit MMIO register specified by Address, performs a bitwise
1584 inclusive OR between the read result and the value specified by OrData, and
1585 writes the result to the 8-bit MMIO register specified by Address. The value
1586 written to the MMIO register is returned. This function must guarantee that
1587 all MMIO read and write operations are serialized.
1589 If 8-bit MMIO register operations are not supported, then ASSERT().
1591 @param Address The MMIO register to write.
1592 @param OrData The value to OR with the read value from the MMIO register.
1594 @return The value written back to the MMIO register.
1604 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioOr8 (Address
, OrData
));
1608 Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result
1609 back to the 8-bit MMIO register and saves the value in the S3 script to be
1610 replayed on S3 resume.
1612 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1613 between the read result and the value specified by AndData, and writes the
1614 result to the 8-bit MMIO register specified by Address. The value written to
1615 the MMIO register is returned. This function must guarantee that all MMIO
1616 read and write operations are serialized.
1618 If 8-bit MMIO register operations are not supported, then ASSERT().
1620 @param Address The MMIO register to write.
1621 @param AndData The value to AND with the read value from the MMIO register.
1623 @return The value written back to the MMIO register.
1633 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioAnd8 (Address
, AndData
));
1637 Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise
1638 inclusive OR, and writes the result back to the 8-bit MMIO register and saves
1639 the value in the S3 script to be replayed on S3 resume.
1641 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1642 between the read result and the value specified by AndData, performs a
1643 bitwise OR between the result of the AND operation and the value specified by
1644 OrData, and writes the result to the 8-bit MMIO register specified by
1645 Address. The value written to the MMIO register is returned. This function
1646 must guarantee that all MMIO read and write operations are serialized.
1648 If 8-bit MMIO register operations are not supported, then ASSERT().
1650 @param Address The MMIO register to write.
1651 @param AndData The value to AND with the read value from the MMIO register.
1652 @param OrData The value to OR with the result of the AND operation.
1654 @return The value written back to the MMIO register.
1665 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioAndThenOr8 (Address
, AndData
, OrData
));
1669 Reads a bit field of a MMIO register and saves the value in the S3 script to
1670 be replayed on S3 resume.
1672 Reads the bit field in an 8-bit MMIO register. The bit field is specified by
1673 the StartBit and the EndBit. The value of the bit field is returned.
1675 If 8-bit MMIO register operations are not supported, then ASSERT().
1676 If StartBit is greater than 7, then ASSERT().
1677 If EndBit is greater than 7, then ASSERT().
1678 If EndBit is less than StartBit, then ASSERT().
1680 @param Address MMIO register to read.
1681 @param StartBit The ordinal of the least significant bit in the bit field.
1683 @param EndBit The ordinal of the most significant bit in the bit field.
1686 @return The value read.
1691 S3MmioBitFieldRead8 (
1697 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldRead8 (Address
, StartBit
, EndBit
));
1701 Writes a bit field to an MMIO register and saves the value in the S3 script to
1702 be replayed on S3 resume.
1704 Writes Value to the bit field of the MMIO register. The bit field is
1705 specified by the StartBit and the EndBit. All other bits in the destination
1706 MMIO register are preserved. The new value of the 8-bit register is returned.
1708 If 8-bit MMIO register operations are not supported, then ASSERT().
1709 If StartBit is greater than 7, then ASSERT().
1710 If EndBit is greater than 7, then ASSERT().
1711 If EndBit is less than StartBit, then ASSERT().
1712 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1714 @param Address The MMIO register to write.
1715 @param StartBit The ordinal of the least significant bit in the bit field.
1717 @param EndBit The ordinal of the most significant bit in the bit field.
1719 @param Value New value of the bit field.
1721 @return The value written back to the MMIO register.
1726 S3MmioBitFieldWrite8 (
1733 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldWrite8 (Address
, StartBit
, EndBit
, Value
));
1737 Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and
1738 writes the result back to the bit field in the 8-bit MMIO register and saves
1739 the value in the S3 script to be replayed on S3 resume.
1741 Reads the 8-bit MMIO register specified by Address, performs a bitwise
1742 inclusive OR between the read result and the value specified by OrData, and
1743 writes the result to the 8-bit MMIO register specified by Address. The value
1744 written to the MMIO register is returned. This function must guarantee that
1745 all MMIO read and write operations are serialized. Extra left bits in OrData
1748 If 8-bit MMIO register operations are not supported, then ASSERT().
1749 If StartBit is greater than 7, then ASSERT().
1750 If EndBit is greater than 7, then ASSERT().
1751 If EndBit is less than StartBit, then ASSERT().
1752 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1754 @param Address The MMIO register to write.
1755 @param StartBit The ordinal of the least significant bit in the bit field.
1757 @param EndBit The ordinal of the most significant bit in the bit field.
1759 @param OrData The value to OR with the read value from the MMIO register.
1761 @return The value written back to the MMIO register.
1773 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldOr8 (Address
, StartBit
, EndBit
, OrData
));
1777 Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and
1778 writes the result back to the bit field in the 8-bit MMIO register and saves
1779 the value in the S3 script to be replayed on S3 resume.
1781 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1782 between the read result and the value specified by AndData, and writes the
1783 result to the 8-bit MMIO register specified by Address. The value written to
1784 the MMIO register is returned. This function must guarantee that all MMIO
1785 read and write operations are serialized. Extra left bits in AndData are
1788 If 8-bit MMIO register operations are not supported, then ASSERT().
1789 If StartBit is greater than 7, then ASSERT().
1790 If EndBit is greater than 7, then ASSERT().
1791 If EndBit is less than StartBit, then ASSERT().
1792 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1794 @param Address The MMIO register to write.
1795 @param StartBit The ordinal of the least significant bit in the bit field.
1797 @param EndBit The ordinal of the most significant bit in the bit field.
1799 @param AndData The value to AND with the read value from the MMIO register.
1801 @return The value written back to the MMIO register.
1806 S3MmioBitFieldAnd8 (
1813 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldAnd8 (Address
, StartBit
, EndBit
, AndData
));
1817 Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed
1818 by a bitwise OR, and writes the result back to the bit field in the
1819 8-bit MMIO register and saves the value in the S3 script to be replayed
1822 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1823 followed by a bitwise OR between the read result and the value
1824 specified by AndData, and writes the result to the 8-bit MMIO register
1825 specified by Address. The value written to the MMIO register is returned.
1826 This function must guarantee that all MMIO read and write operations are
1827 serialized. Extra left bits in both AndData and OrData are stripped.
1829 If 8-bit MMIO register operations are not supported, then ASSERT().
1830 If StartBit is greater than 7, then ASSERT().
1831 If EndBit is greater than 7, then ASSERT().
1832 If EndBit is less than StartBit, then ASSERT().
1833 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1834 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1836 @param Address The MMIO register to write.
1837 @param StartBit The ordinal of the least significant bit in the bit field.
1839 @param EndBit The ordinal of the most significant bit in the bit field.
1841 @param AndData The value to AND with the read value from the MMIO register.
1842 @param OrData The value to OR with the result of the AND operation.
1844 @return The value written back to the MMIO register.
1849 S3MmioBitFieldAndThenOr8 (
1857 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldAndThenOr8 (Address
, StartBit
, EndBit
, AndData
, OrData
));
1861 Saves a 16-bit MMIO register value to the boot script.
1863 This internal worker function saves a 16-bit MMIO register value in the S3 script
1864 to be replayed on S3 resume.
1866 If the saving process fails, then ASSERT().
1868 @param Address The MMIO register to write.
1869 @param Value The value saved to boot script.
1875 InternalSaveMmioWrite16ValueToBootScript (
1880 InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint16
, Address
, &Value
);
1886 Reads a 16-bit MMIO register and saves the value in the S3 script to be replayed
1889 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
1890 returned. This function must guarantee that all MMIO read and write
1891 operations are serialized.
1893 If 16-bit MMIO register operations are not supported, then ASSERT().
1895 @param Address The MMIO register to read.
1897 @return The value read.
1906 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioRead16 (Address
));
1910 Writes a 16-bit MMIO register and saves the value in the S3 script to be replayed
1913 Writes the 16-bit MMIO register specified by Address with the value specified
1914 by Value and returns Value. This function must guarantee that all MMIO read
1915 and write operations are serialized and saves the value in the S3 script to be
1916 replayed on S3 resume.
1918 If 16-bit MMIO register operations are not supported, then ASSERT().
1920 @param Address The MMIO register to write.
1921 @param Value The value to write to the MMIO register.
1923 @return The value written the MMIO register.
1933 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioWrite16 (Address
, Value
));
1937 Reads a 16-bit MMIO register, performs a bitwise OR, and writes the
1938 result back to the 16-bit MMIO register and saves the value in the S3 script
1939 to be replayed on S3 resume.
1941 Reads the 16-bit MMIO register specified by Address, performs a bitwise
1942 inclusive OR between the read result and the value specified by OrData, and
1943 writes the result to the 16-bit MMIO register specified by Address. The value
1944 written to the MMIO register is returned. This function must guarantee that
1945 all MMIO read and write operations are serialized.
1947 If 16-bit MMIO register operations are not supported, then ASSERT().
1949 @param Address The MMIO register to write.
1950 @param OrData The value to OR with the read value from the MMIO register.
1952 @return The value written back to the MMIO register.
1962 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioOr16 (Address
, OrData
));
1966 Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result
1967 back to the 16-bit MMIO register and saves the value in the S3 script to be
1968 replayed on S3 resume.
1970 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1971 between the read result and the value specified by AndData, and writes the
1972 result to the 16-bit MMIO register specified by Address. The value written to
1973 the MMIO register is returned. This function must guarantee that all MMIO
1974 read and write operations are serialized.
1976 If 16-bit MMIO register operations are not supported, then ASSERT().
1978 @param Address The MMIO register to write.
1979 @param AndData The value to AND with the read value from the MMIO register.
1981 @return The value written back to the MMIO register.
1991 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioAnd16 (Address
, AndData
));
1995 Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise
1996 inclusive OR, and writes the result back to the 16-bit MMIO register and
1997 saves the value in the S3 script to be replayed on S3 resume.
1999 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
2000 between the read result and the value specified by AndData, performs a
2001 bitwise OR between the result of the AND operation and the value specified by
2002 OrData, and writes the result to the 16-bit MMIO register specified by
2003 Address. The value written to the MMIO register is returned. This function
2004 must guarantee that all MMIO read and write operations are serialized.
2006 If 16-bit MMIO register operations are not supported, then ASSERT().
2008 @param Address The MMIO register to write.
2009 @param AndData The value to AND with the read value from the MMIO register.
2010 @param OrData The value to OR with the result of the AND operation.
2012 @return The value written back to the MMIO register.
2023 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioAndThenOr16 (Address
, AndData
, OrData
));
2027 Reads a bit field of a MMIO register and saves the value in the S3 script to
2028 be replayed on S3 resume.
2030 Reads the bit field in a 16-bit MMIO register. The bit field is specified by
2031 the StartBit and the EndBit. The value of the bit field is returned.
2033 If 16-bit MMIO register operations are not supported, then ASSERT().
2034 If StartBit is greater than 15, then ASSERT().
2035 If EndBit is greater than 15, then ASSERT().
2036 If EndBit is less than StartBit, then ASSERT().
2038 @param Address MMIO register to read.
2039 @param StartBit The ordinal of the least significant bit in the bit field.
2041 @param EndBit The ordinal of the most significant bit in the bit field.
2044 @return The value read.
2049 S3MmioBitFieldRead16 (
2055 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldRead16 (Address
, StartBit
, EndBit
));
2059 Writes a bit field to a MMIO register and saves the value in the S3 script to
2060 be replayed on S3 resume.
2062 Writes Value to the bit field of the MMIO register. The bit field is
2063 specified by the StartBit and the EndBit. All other bits in the destination
2064 MMIO register are preserved. The new value of the 16-bit register is returned.
2066 If 16-bit MMIO register operations are not supported, then ASSERT().
2067 If StartBit is greater than 15, then ASSERT().
2068 If EndBit is greater than 15, then ASSERT().
2069 If EndBit is less than StartBit, then ASSERT().
2070 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2072 @param Address The MMIO register to write.
2073 @param StartBit The ordinal of the least significant bit in the bit field.
2075 @param EndBit The ordinal of the most significant bit in the bit field.
2077 @param Value New value of the bit field.
2079 @return The value written back to the MMIO register.
2084 S3MmioBitFieldWrite16 (
2091 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldWrite16 (Address
, StartBit
, EndBit
, Value
));
2095 Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and
2096 writes the result back to the bit field in the 16-bit MMIO register and
2097 saves the value in the S3 script to be replayed on S3 resume.
2099 Reads the 16-bit MMIO register specified by Address, performs a bitwise
2100 inclusive OR between the read result and the value specified by OrData, and
2101 writes the result to the 16-bit MMIO register specified by Address. The value
2102 written to the MMIO register is returned. This function must guarantee that
2103 all MMIO read and write operations are serialized. Extra left bits in OrData
2106 If 16-bit MMIO register operations are not supported, then ASSERT().
2107 If StartBit is greater than 15, then ASSERT().
2108 If EndBit is greater than 15, then ASSERT().
2109 If EndBit is less than StartBit, then ASSERT().
2110 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2112 @param Address The MMIO register to write.
2113 @param StartBit The ordinal of the least significant bit in the bit field.
2115 @param EndBit The ordinal of the most significant bit in the bit field.
2117 @param OrData The value to OR with the read value from the MMIO register.
2119 @return The value written back to the MMIO register.
2124 S3MmioBitFieldOr16 (
2131 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldOr16 (Address
, StartBit
, EndBit
, OrData
));
2135 Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and
2136 writes the result back to the bit field in the 16-bit MMIO register and
2137 saves the value in the S3 script to be replayed on S3 resume.
2139 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
2140 between the read result and the value specified by AndData, and writes the
2141 result to the 16-bit MMIO register specified by Address. The value written to
2142 the MMIO register is returned. This function must guarantee that all MMIO
2143 read and write operations are serialized. Extra left bits in AndData are
2146 If 16-bit MMIO register operations are not supported, then ASSERT().
2147 If StartBit is greater than 15, then ASSERT().
2148 If EndBit is greater than 15, then ASSERT().
2149 If EndBit is less than StartBit, then ASSERT().
2150 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2152 @param Address The MMIO register to write.
2153 @param StartBit The ordinal of the least significant bit in the bit field.
2155 @param EndBit The ordinal of the most significant bit in the bit field.
2157 @param AndData The value to AND with the read value from the MMIO register.
2159 @return The value written back to the MMIO register.
2164 S3MmioBitFieldAnd16 (
2171 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldAnd16 (Address
, StartBit
, EndBit
, AndData
));
2175 Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed
2176 by a bitwise OR, and writes the result back to the bit field in the
2177 16-bit MMIO register and saves the value in the S3 script to be replayed
2180 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
2181 followed by a bitwise OR between the read result and the value
2182 specified by AndData, and writes the result to the 16-bit MMIO register
2183 specified by Address. The value written to the MMIO register is returned.
2184 This function must guarantee that all MMIO read and write operations are
2185 serialized. Extra left bits in both AndData and OrData are stripped.
2187 If 16-bit MMIO register operations are not supported, then ASSERT().
2188 If StartBit is greater than 15, then ASSERT().
2189 If EndBit is greater than 15, then ASSERT().
2190 If EndBit is less than StartBit, then ASSERT().
2191 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2192 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2194 @param Address The MMIO register to write.
2195 @param StartBit The ordinal of the least significant bit in the bit field.
2197 @param EndBit The ordinal of the most significant bit in the bit field.
2199 @param AndData The value to AND with the read value from the MMIO register.
2200 @param OrData The value to OR with the result of the AND operation.
2202 @return The value written back to the MMIO register.
2207 S3MmioBitFieldAndThenOr16 (
2215 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldAndThenOr16 (Address
, StartBit
, EndBit
, AndData
, OrData
));
2219 Saves a 32-bit MMIO register value to the boot script.
2221 This internal worker function saves a 32-bit MMIO register value in the S3 script
2222 to be replayed on S3 resume.
2224 If the saving process fails, then ASSERT().
2226 @param Address The MMIO register to write.
2227 @param Value The value saved to boot script.
2233 InternalSaveMmioWrite32ValueToBootScript (
2238 InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint32
, Address
, &Value
);
2244 Reads a 32-bit MMIO register saves the value in the S3 script to be
2245 replayed on S3 resume.
2247 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
2248 returned. This function must guarantee that all MMIO read and write
2249 operations are serialized.
2251 If 32-bit MMIO register operations are not supported, then ASSERT().
2253 @param Address The MMIO register to read.
2255 @return The value read.
2264 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioRead32 (Address
));
2268 Writes a 32-bit MMIO register and saves the value in the S3 script to be
2269 replayed on S3 resume.
2271 Writes the 32-bit MMIO register specified by Address with the value specified
2272 by Value and returns Value. This function must guarantee that all MMIO read
2273 and write operations are serialized.
2275 If 32-bit MMIO register operations are not supported, then ASSERT().
2277 @param Address The MMIO register to write.
2278 @param Value The value to write to the MMIO register.
2280 @return The value written the MMIO register.
2290 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioWrite32 (Address
, Value
));
2294 Reads a 32-bit MMIO register, performs a bitwise OR, and writes the
2295 result back to the 32-bit MMIO register and saves the value in the S3 script
2296 to be replayed on S3 resume.
2298 Reads the 32-bit MMIO register specified by Address, performs a bitwise
2299 inclusive OR between the read result and the value specified by OrData, and
2300 writes the result to the 32-bit MMIO register specified by Address. The value
2301 written to the MMIO register is returned. This function must guarantee that
2302 all MMIO read and write operations are serialized.
2304 If 32-bit MMIO register operations are not supported, then ASSERT().
2306 @param Address The MMIO register to write.
2307 @param OrData The value to OR with the read value from the MMIO register.
2309 @return The value written back to the MMIO register.
2319 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioOr32 (Address
, OrData
));
2323 Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result
2324 back to the 32-bit MMIO register and saves the value in the S3 script to be
2325 replayed on S3 resume.
2327 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
2328 between the read result and the value specified by AndData, and writes the
2329 result to the 32-bit MMIO register specified by Address. The value written to
2330 the MMIO register is returned. This function must guarantee that all MMIO
2331 read and write operations are serialized.
2333 If 32-bit MMIO register operations are not supported, then ASSERT().
2335 @param Address The MMIO register to write.
2336 @param AndData The value to AND with the read value from the MMIO register.
2338 @return The value written back to the MMIO register.
2348 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioAnd32 (Address
, AndData
));
2352 Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise
2353 inclusive OR, and writes the result back to the 32-bit MMIO register and
2354 saves the value in the S3 script to be replayed on S3 resume.
2356 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
2357 between the read result and the value specified by AndData, performs a
2358 bitwise OR between the result of the AND operation and the value specified by
2359 OrData, and writes the result to the 32-bit MMIO register specified by
2360 Address. The value written to the MMIO register is returned. This function
2361 must guarantee that all MMIO read and write operations are serialized.
2363 If 32-bit MMIO register operations are not supported, then ASSERT().
2365 @param Address The MMIO register to write.
2366 @param AndData The value to AND with the read value from the MMIO register.
2367 @param OrData The value to OR with the result of the AND operation.
2369 @return The value written back to the MMIO register.
2380 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioAndThenOr32 (Address
, AndData
, OrData
));
2384 Reads a bit field of a MMIO register and saves the value in the S3 script
2385 to be replayed on S3 resume.
2387 Reads the bit field in a 32-bit MMIO register. The bit field is specified by
2388 the StartBit and the EndBit. The value of the bit field is returned.
2390 If 32-bit MMIO register operations are not supported, then ASSERT().
2391 If StartBit is greater than 31, then ASSERT().
2392 If EndBit is greater than 31, then ASSERT().
2393 If EndBit is less than StartBit, then ASSERT().
2395 @param Address MMIO register to read.
2396 @param StartBit The ordinal of the least significant bit in the bit field.
2398 @param EndBit The ordinal of the most significant bit in the bit field.
2401 @return The value read.
2406 S3MmioBitFieldRead32 (
2412 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldRead32 (Address
, StartBit
, EndBit
));
2416 Writes a bit field to a MMIO register and saves the value in the S3 script
2417 to be replayed on S3 resume.
2419 Writes Value to the bit field of the MMIO register. The bit field is
2420 specified by the StartBit and the EndBit. All other bits in the destination
2421 MMIO register are preserved. The new value of the 32-bit register is returned.
2423 If 32-bit MMIO register operations are not supported, then ASSERT().
2424 If StartBit is greater than 31, then ASSERT().
2425 If EndBit is greater than 31, then ASSERT().
2426 If EndBit is less than StartBit, then ASSERT().
2427 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2429 @param Address The MMIO register to write.
2430 @param StartBit The ordinal of the least significant bit in the bit field.
2432 @param EndBit The ordinal of the most significant bit in the bit field.
2434 @param Value New value of the bit field.
2436 @return The value written back to the MMIO register.
2441 S3MmioBitFieldWrite32 (
2448 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldWrite32 (Address
, StartBit
, EndBit
, Value
));
2452 Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and
2453 writes the result back to the bit field in the 32-bit MMIO register and
2454 saves the value in the S3 script to be replayed on S3 resume.
2456 Reads the 32-bit MMIO register specified by Address, performs a bitwise
2457 inclusive OR between the read result and the value specified by OrData, and
2458 writes the result to the 32-bit MMIO register specified by Address. The value
2459 written to the MMIO register is returned. This function must guarantee that
2460 all MMIO read and write operations are serialized. Extra left bits in OrData
2463 If 32-bit MMIO register operations are not supported, then ASSERT().
2464 If StartBit is greater than 31, then ASSERT().
2465 If EndBit is greater than 31, then ASSERT().
2466 If EndBit is less than StartBit, then ASSERT().
2467 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2469 @param Address The MMIO register to write.
2470 @param StartBit The ordinal of the least significant bit in the bit field.
2472 @param EndBit The ordinal of the most significant bit in the bit field.
2474 @param OrData The value to OR with the read value from the MMIO register.
2476 @return The value written back to the MMIO register.
2481 S3MmioBitFieldOr32 (
2488 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldOr32 (Address
, StartBit
, EndBit
, OrData
));
2492 Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and
2493 writes the result back to the bit field in the 32-bit MMIO register and
2494 saves the value in the S3 script to be replayed on S3 resume.
2496 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
2497 between the read result and the value specified by AndData, and writes the
2498 result to the 32-bit MMIO register specified by Address. The value written to
2499 the MMIO register is returned. This function must guarantee that all MMIO
2500 read and write operations are serialized. Extra left bits in AndData are
2503 If 32-bit MMIO register operations are not supported, then ASSERT().
2504 If StartBit is greater than 31, then ASSERT().
2505 If EndBit is greater than 31, then ASSERT().
2506 If EndBit is less than StartBit, then ASSERT().
2507 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2509 @param Address The MMIO register to write.
2510 @param StartBit The ordinal of the least significant bit in the bit field.
2512 @param EndBit The ordinal of the most significant bit in the bit field.
2514 @param AndData The value to AND with the read value from the MMIO register.
2516 @return The value written back to the MMIO register.
2521 S3MmioBitFieldAnd32 (
2528 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldAnd32 (Address
, StartBit
, EndBit
, AndData
));
2532 Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed
2533 by a bitwise OR, and writes the result back to the bit field in the
2534 32-bit MMIO register and saves the value in the S3 script to be replayed
2537 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
2538 followed by a bitwise OR between the read result and the value
2539 specified by AndData, and writes the result to the 32-bit MMIO register
2540 specified by Address. The value written to the MMIO register is returned.
2541 This function must guarantee that all MMIO read and write operations are
2542 serialized. Extra left bits in both AndData and OrData are stripped.
2544 If 32-bit MMIO register operations are not supported, then ASSERT().
2545 If StartBit is greater than 31, then ASSERT().
2546 If EndBit is greater than 31, then ASSERT().
2547 If EndBit is less than StartBit, then ASSERT().
2548 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2549 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2551 @param Address The MMIO register to write.
2552 @param StartBit The ordinal of the least significant bit in the bit field.
2554 @param EndBit The ordinal of the most significant bit in the bit field.
2556 @param AndData The value to AND with the read value from the MMIO register.
2557 @param OrData The value to OR with the result of the AND operation.
2559 @return The value written back to the MMIO register.
2564 S3MmioBitFieldAndThenOr32 (
2572 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldAndThenOr32 (Address
, StartBit
, EndBit
, AndData
, OrData
));
2576 Saves a 64-bit MMIO register value to the boot script.
2578 This internal worker function saves a 64-bit MMIO register value in the S3 script
2579 to be replayed on S3 resume.
2581 If the saving process fails, then ASSERT().
2583 @param Address The MMIO register to write.
2584 @param Value The value saved to boot script.
2590 InternalSaveMmioWrite64ValueToBootScript (
2595 InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint64
, Address
, &Value
);
2601 Reads a 64-bit MMIO register and saves the value in the S3 script to be
2602 replayed on S3 resume.
2604 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
2605 returned. This function must guarantee that all MMIO read and write
2606 operations are serialized.
2608 If 64-bit MMIO register operations are not supported, then ASSERT().
2610 @param Address The MMIO register to read.
2612 @return The value read.
2621 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioRead64 (Address
));
2625 Writes a 64-bit MMIO register and saves the value in the S3 script to be
2626 replayed on S3 resume.
2628 Writes the 64-bit MMIO register specified by Address with the value specified
2629 by Value and returns Value. This function must guarantee that all MMIO read
2630 and write operations are serialized.
2632 If 64-bit MMIO register operations are not supported, then ASSERT().
2634 @param Address The MMIO register to write.
2635 @param Value The value to write to the MMIO register.
2637 @return The value written the MMIO register.
2647 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioWrite64 (Address
, Value
));
2651 Reads a 64-bit MMIO register, performs a bitwise OR, and writes the
2652 result back to the 64-bit MMIO register and saves the value in the S3 script
2653 to be replayed on S3 resume.
2655 Reads the 64-bit MMIO register specified by Address, performs a bitwise
2656 inclusive OR between the read result and the value specified by OrData, and
2657 writes the result to the 64-bit MMIO register specified by Address. The value
2658 written to the MMIO register is returned. This function must guarantee that
2659 all MMIO read and write operations are serialized.
2661 If 64-bit MMIO register operations are not supported, then ASSERT().
2663 @param Address The MMIO register to write.
2664 @param OrData The value to OR with the read value from the MMIO register.
2666 @return The value written back to the MMIO register.
2676 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioOr64 (Address
, OrData
));
2680 Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result
2681 back to the 64-bit MMIO register and saves the value in the S3 script to be
2682 replayed on S3 resume.
2684 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2685 between the read result and the value specified by AndData, and writes the
2686 result to the 64-bit MMIO register specified by Address. The value written to
2687 the MMIO register is returned. This function must guarantee that all MMIO
2688 read and write operations are serialized.
2690 If 64-bit MMIO register operations are not supported, then ASSERT().
2692 @param Address The MMIO register to write.
2693 @param AndData The value to AND with the read value from the MMIO register.
2695 @return The value written back to the MMIO register.
2705 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioAnd64 (Address
, AndData
));
2709 Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise
2710 inclusive OR, and writes the result back to the 64-bit MMIO register and
2711 saves the value in the S3 script to be replayed on S3 resume.
2713 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2714 between the read result and the value specified by AndData, performs a
2715 bitwise OR between the result of the AND operation and the value specified by
2716 OrData, and writes the result to the 64-bit MMIO register specified by
2717 Address. The value written to the MMIO register is returned. This function
2718 must guarantee that all MMIO read and write operations are serialized.
2720 If 64-bit MMIO register operations are not supported, then ASSERT().
2722 @param Address The MMIO register to write.
2723 @param AndData The value to AND with the read value from the MMIO register.
2724 @param OrData The value to OR with the result of the AND operation.
2726 @return The value written back to the MMIO register.
2737 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioAndThenOr64 (Address
, AndData
, OrData
));
2741 Reads a bit field of a MMIO register saves the value in the S3 script to
2742 be replayed on S3 resume.
2744 Reads the bit field in a 64-bit MMIO register. The bit field is specified by
2745 the StartBit and the EndBit. The value of the bit field is returned.
2747 If 64-bit MMIO register operations are not supported, then ASSERT().
2748 If StartBit is greater than 63, then ASSERT().
2749 If EndBit is greater than 63, then ASSERT().
2750 If EndBit is less than StartBit, then ASSERT().
2752 @param Address MMIO register to read.
2753 @param StartBit The ordinal of the least significant bit in the bit field.
2755 @param EndBit The ordinal of the most significant bit in the bit field.
2758 @return The value read.
2763 S3MmioBitFieldRead64 (
2769 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldRead64 (Address
, StartBit
, EndBit
));
2773 Writes a bit field to a MMIO register and saves the value in the S3 script to
2774 be replayed on S3 resume.
2776 Writes Value to the bit field of the MMIO register. The bit field is
2777 specified by the StartBit and the EndBit. All other bits in the destination
2778 MMIO register are preserved. The new value of the 64-bit register is returned.
2780 If 64-bit MMIO register operations are not supported, then ASSERT().
2781 If StartBit is greater than 63, then ASSERT().
2782 If EndBit is greater than 63, then ASSERT().
2783 If EndBit is less than StartBit, then ASSERT().
2784 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2786 @param Address The MMIO register to write.
2787 @param StartBit The ordinal of the least significant bit in the bit field.
2789 @param EndBit The ordinal of the most significant bit in the bit field.
2791 @param Value New value of the bit field.
2793 @return The value written back to the MMIO register.
2798 S3MmioBitFieldWrite64 (
2805 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldWrite64 (Address
, StartBit
, EndBit
, Value
));
2809 Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and
2810 writes the result back to the bit field in the 64-bit MMIO register and
2811 saves the value in the S3 script to be replayed on S3 resume.
2813 Reads the 64-bit MMIO register specified by Address, performs a bitwise
2814 inclusive OR between the read result and the value specified by OrData, and
2815 writes the result to the 64-bit MMIO register specified by Address. The value
2816 written to the MMIO register is returned. This function must guarantee that
2817 all MMIO read and write operations are serialized. Extra left bits in OrData
2820 If 64-bit MMIO register operations are not supported, then ASSERT().
2821 If StartBit is greater than 63, then ASSERT().
2822 If EndBit is greater than 63, then ASSERT().
2823 If EndBit is less than StartBit, then ASSERT().
2824 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2826 @param Address The MMIO register to write.
2827 @param StartBit The ordinal of the least significant bit in the bit field.
2829 @param EndBit The ordinal of the most significant bit in the bit field.
2831 @param OrData The value to OR with the read value from the MMIO register.
2833 @return The value written back to the MMIO register.
2838 S3MmioBitFieldOr64 (
2845 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldOr64 (Address
, StartBit
, EndBit
, OrData
));
2849 Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and
2850 writes the result back to the bit field in the 64-bit MMIO register and saves
2851 the value in the S3 script to be replayed on S3 resume.
2853 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2854 between the read result and the value specified by AndData, and writes the
2855 result to the 64-bit MMIO register specified by Address. The value written to
2856 the MMIO register is returned. This function must guarantee that all MMIO
2857 read and write operations are serialized. Extra left bits in AndData are
2860 If 64-bit MMIO register operations are not supported, then ASSERT().
2861 If StartBit is greater than 63, then ASSERT().
2862 If EndBit is greater than 63, then ASSERT().
2863 If EndBit is less than StartBit, then ASSERT().
2864 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2866 @param Address The MMIO register to write.
2867 @param StartBit The ordinal of the least significant bit in the bit field.
2869 @param EndBit The ordinal of the most significant bit in the bit field.
2871 @param AndData The value to AND with the read value from the MMIO register.
2873 @return The value written back to the MMIO register.
2878 S3MmioBitFieldAnd64 (
2885 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldAnd64 (Address
, StartBit
, EndBit
, AndData
));
2889 Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed
2890 by a bitwise OR, and writes the result back to the bit field in the
2891 64-bit MMIO register and saves the value in the S3 script to be replayed
2894 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2895 followed by a bitwise OR between the read result and the value
2896 specified by AndData, and writes the result to the 64-bit MMIO register
2897 specified by Address. The value written to the MMIO register is returned.
2898 This function must guarantee that all MMIO read and write operations are
2899 serialized. Extra left bits in both AndData and OrData are stripped.
2901 If 64-bit MMIO register operations are not supported, then ASSERT().
2902 If StartBit is greater than 63, then ASSERT().
2903 If EndBit is greater than 63, then ASSERT().
2904 If EndBit is less than StartBit, then ASSERT().
2905 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2906 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2908 @param Address The MMIO register to write.
2909 @param StartBit The ordinal of the least significant bit in the bit field.
2911 @param EndBit The ordinal of the most significant bit in the bit field.
2913 @param AndData The value to AND with the read value from the MMIO register.
2914 @param OrData The value to OR with the result of the AND operation.
2916 @return The value written back to the MMIO register.
2921 S3MmioBitFieldAndThenOr64 (
2929 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldAndThenOr64 (Address
, StartBit
, EndBit
, AndData
, OrData
));
2933 Copy data from MMIO region to system memory by using 8-bit access
2934 and saves the value in the S3 script to be replayed on S3 resume.
2936 Copy data from MMIO region specified by starting address StartAddress
2937 to system memory specified by Buffer by using 8-bit access. The total
2938 number of byte to be copied is specified by Length. Buffer is returned.
2940 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
2941 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2944 @param StartAddress Starting address for the MMIO region to be copied from.
2945 @param Length Size in bytes of the copy.
2946 @param Buffer Pointer to a system memory buffer receiving the data read.
2954 IN UINTN StartAddress
,
2959 UINT8
*ReturnBuffer
;
2960 RETURN_STATUS Status
;
2962 ReturnBuffer
= MmioReadBuffer8 (StartAddress
, Length
, Buffer
);
2964 Status
= S3BootScriptSaveMemWrite (
2965 S3BootScriptWidthUint8
,
2967 Length
/ sizeof (UINT8
),
2970 ASSERT (Status
== RETURN_SUCCESS
);
2972 return ReturnBuffer
;
2976 Copy data from MMIO region to system memory by using 16-bit access
2977 and saves the value in the S3 script to be replayed on S3 resume.
2979 Copy data from MMIO region specified by starting address StartAddress
2980 to system memory specified by Buffer by using 16-bit access. The total
2981 number of byte to be copied is specified by Length. Buffer is returned.
2983 If StartAddress is not aligned on a 16-bit boundary, then ASSERT().
2985 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
2986 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2988 If Length is not aligned on a 16-bit boundary, then ASSERT().
2989 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2991 @param StartAddress Starting address for the MMIO region to be copied from.
2992 @param Length Size in bytes of the copy.
2993 @param Buffer Pointer to a system memory buffer receiving the data read.
3000 S3MmioReadBuffer16 (
3001 IN UINTN StartAddress
,
3006 UINT16
*ReturnBuffer
;
3007 RETURN_STATUS Status
;
3009 ReturnBuffer
= MmioReadBuffer16 (StartAddress
, Length
, Buffer
);
3011 Status
= S3BootScriptSaveMemWrite (
3012 S3BootScriptWidthUint16
,
3014 Length
/ sizeof (UINT16
),
3017 ASSERT (Status
== RETURN_SUCCESS
);
3019 return ReturnBuffer
;
3023 Copy data from MMIO region to system memory by using 32-bit access
3024 and saves the value in the S3 script to be replayed on S3 resume.
3026 Copy data from MMIO region specified by starting address StartAddress
3027 to system memory specified by Buffer by using 32-bit access. The total
3028 number of byte to be copied is specified by Length. Buffer is returned.
3030 If StartAddress is not aligned on a 32-bit boundary, then ASSERT().
3032 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3033 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3035 If Length is not aligned on a 32-bit boundary, then ASSERT().
3036 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3038 @param StartAddress Starting address for the MMIO region to be copied from.
3039 @param Length Size in bytes of the copy.
3040 @param Buffer Pointer to a system memory buffer receiving the data read.
3047 S3MmioReadBuffer32 (
3048 IN UINTN StartAddress
,
3053 UINT32
*ReturnBuffer
;
3054 RETURN_STATUS Status
;
3056 ReturnBuffer
= MmioReadBuffer32 (StartAddress
, Length
, Buffer
);
3058 Status
= S3BootScriptSaveMemWrite (
3059 S3BootScriptWidthUint32
,
3061 Length
/ sizeof (UINT32
),
3064 ASSERT (Status
== RETURN_SUCCESS
);
3066 return ReturnBuffer
;
3070 Copy data from MMIO region to system memory by using 64-bit access
3071 and saves the value in the S3 script to be replayed on S3 resume.
3073 Copy data from MMIO region specified by starting address StartAddress
3074 to system memory specified by Buffer by using 64-bit access. The total
3075 number of byte to be copied is specified by Length. Buffer is returned.
3077 If StartAddress is not aligned on a 64-bit boundary, then ASSERT().
3079 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3080 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3082 If Length is not aligned on a 64-bit boundary, then ASSERT().
3083 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3085 @param StartAddress Starting address for the MMIO region to be copied from.
3086 @param Length Size in bytes of the copy.
3087 @param Buffer Pointer to a system memory buffer receiving the data read.
3094 S3MmioReadBuffer64 (
3095 IN UINTN StartAddress
,
3100 UINT64
*ReturnBuffer
;
3101 RETURN_STATUS Status
;
3103 ReturnBuffer
= MmioReadBuffer64 (StartAddress
, Length
, Buffer
);
3105 Status
= S3BootScriptSaveMemWrite (
3106 S3BootScriptWidthUint64
,
3108 Length
/ sizeof (UINT64
),
3111 ASSERT (Status
== RETURN_SUCCESS
);
3113 return ReturnBuffer
;
3117 Copy data from system memory to MMIO region by using 8-bit access
3118 and saves the value in the S3 script to be replayed on S3 resume.
3120 Copy data from system memory specified by Buffer to MMIO region specified
3121 by starting address StartAddress by using 8-bit access. The total number
3122 of byte to be copied is specified by Length. Buffer is returned.
3124 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3125 If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
3128 @param StartAddress Starting address for the MMIO region to be copied to.
3129 @param Length Size in bytes of the copy.
3130 @param Buffer Pointer to a system memory buffer containing the data to write.
3137 S3MmioWriteBuffer8 (
3138 IN UINTN StartAddress
,
3140 IN CONST UINT8
*Buffer
3143 UINT8
*ReturnBuffer
;
3144 RETURN_STATUS Status
;
3146 ReturnBuffer
= MmioWriteBuffer8 (StartAddress
, Length
, Buffer
);
3148 Status
= S3BootScriptSaveMemWrite (
3149 S3BootScriptWidthUint8
,
3151 Length
/ sizeof (UINT8
),
3154 ASSERT (Status
== RETURN_SUCCESS
);
3156 return ReturnBuffer
;
3160 Copy data from system memory to MMIO region by using 16-bit access
3161 and saves the value in the S3 script to be replayed on S3 resume.
3163 Copy data from system memory specified by Buffer to MMIO region specified
3164 by starting address StartAddress by using 16-bit access. The total number
3165 of byte to be copied is specified by Length. Buffer is returned.
3167 If StartAddress is not aligned on a 16-bit boundary, then ASSERT().
3169 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3170 If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
3172 If Length is not aligned on a 16-bit boundary, then ASSERT().
3174 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3176 @param StartAddress Starting address for the MMIO region to be copied to.
3177 @param Length Size in bytes of the copy.
3178 @param Buffer Pointer to a system memory buffer containing the data to write.
3185 S3MmioWriteBuffer16 (
3186 IN UINTN StartAddress
,
3188 IN CONST UINT16
*Buffer
3191 UINT16
*ReturnBuffer
;
3192 RETURN_STATUS Status
;
3194 ReturnBuffer
= MmioWriteBuffer16 (StartAddress
, Length
, Buffer
);
3196 Status
= S3BootScriptSaveMemWrite (
3197 S3BootScriptWidthUint16
,
3199 Length
/ sizeof (UINT16
),
3202 ASSERT (Status
== RETURN_SUCCESS
);
3204 return ReturnBuffer
;
3208 Copy data from system memory to MMIO region by using 32-bit access
3209 and saves the value in the S3 script to be replayed on S3 resume.
3211 Copy data from system memory specified by Buffer to MMIO region specified
3212 by starting address StartAddress by using 32-bit access. The total number
3213 of byte to be copied is specified by Length. Buffer is returned.
3215 If StartAddress is not aligned on a 32-bit boundary, then ASSERT().
3217 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3218 If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
3220 If Length is not aligned on a 32-bit boundary, then ASSERT().
3222 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3224 @param StartAddress Starting address for the MMIO region to be copied to.
3225 @param Length Size in bytes of the copy.
3226 @param Buffer Pointer to a system memory buffer containing the data to write.
3233 S3MmioWriteBuffer32 (
3234 IN UINTN StartAddress
,
3236 IN CONST UINT32
*Buffer
3239 UINT32
*ReturnBuffer
;
3240 RETURN_STATUS Status
;
3242 ReturnBuffer
= MmioWriteBuffer32 (StartAddress
, Length
, Buffer
);
3244 Status
= S3BootScriptSaveMemWrite (
3245 S3BootScriptWidthUint32
,
3247 Length
/ sizeof (UINT32
),
3250 ASSERT (Status
== RETURN_SUCCESS
);
3252 return ReturnBuffer
;
3256 Copy data from system memory to MMIO region by using 64-bit access
3257 and saves the value in the S3 script to be replayed on S3 resume.
3259 Copy data from system memory specified by Buffer to MMIO region specified
3260 by starting address StartAddress by using 64-bit access. The total number
3261 of byte to be copied is specified by Length. Buffer is returned.
3263 If StartAddress is not aligned on a 64-bit boundary, then ASSERT().
3265 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3266 If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
3268 If Length is not aligned on a 64-bit boundary, then ASSERT().
3270 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3272 @param StartAddress Starting address for the MMIO region to be copied to.
3273 @param Length Size in bytes of the copy.
3274 @param Buffer Pointer to a system memory buffer containing the data to write.
3281 S3MmioWriteBuffer64 (
3282 IN UINTN StartAddress
,
3284 IN CONST UINT64
*Buffer
3287 UINT64
*ReturnBuffer
;
3288 RETURN_STATUS Status
;
3290 ReturnBuffer
= MmioWriteBuffer64 (StartAddress
, Length
, Buffer
);
3292 Status
= S3BootScriptSaveMemWrite (
3293 S3BootScriptWidthUint64
,
3295 Length
/ sizeof (UINT64
),
3298 ASSERT (Status
== RETURN_SUCCESS
);
3300 return ReturnBuffer
;