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>
20 Saves an I/O port value to the boot script.
22 This internal worker function saves an I/O port value in the S3 script
23 to be replayed on S3 resume.
25 If the saving process fails, then ASSERT().
27 @param Width The width of I/O port.
28 @param Port The I/O port to write.
29 @param Buffer The buffer containing value.
33 InternalSaveIoWriteValueToBootScript (
34 IN S3_BOOT_SCRIPT_LIB_WIDTH Width
,
41 Status
= S3BootScriptSaveIoWrite (
47 ASSERT (Status
== RETURN_SUCCESS
);
51 Saves an 8-bit I/O port value to the boot script.
53 This internal worker function saves an 8-bit I/O port value in the S3 script
54 to be replayed on S3 resume.
56 If the saving process fails, then ASSERT().
58 @param Port The I/O port to write.
59 @param Value The value saved to boot script.
65 InternalSaveIoWrite8ValueToBootScript (
70 InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint8
, Port
, &Value
);
76 Reads an 8-bit I/O port and saves the value in the S3 script to be replayed
79 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
80 This function must guarantee that all I/O read and write operations are
83 If 8-bit I/O port operations are not supported, then ASSERT().
85 @param Port The I/O port to read.
87 @return The value read.
96 return InternalSaveIoWrite8ValueToBootScript (Port
, IoRead8 (Port
));
100 Writes an 8-bit I/O port and saves the value in the S3 script to be replayed
103 Writes the 8-bit I/O port specified by Port with the value specified by Value
104 and returns Value. This function must guarantee that all I/O read and write
105 operations are serialized.
107 If 8-bit I/O port operations are not supported, then ASSERT().
109 @param Port The I/O port to write.
110 @param Value The value to write to the I/O port.
112 @return The value written the I/O port.
122 return InternalSaveIoWrite8ValueToBootScript (Port
, IoWrite8 (Port
, Value
));
126 Reads an 8-bit I/O port, performs a bitwise OR, and writes the
127 result back to the 8-bit I/O port and saves the value in the S3 script to be
128 replayed on S3 resume.
130 Reads the 8-bit I/O port specified by Port, performs a bitwise OR
131 between the read result and the value specified by OrData, and writes the
132 result to the 8-bit I/O port specified by Port. The value written to the I/O
133 port is returned. This function must guarantee that all I/O read and write
134 operations are serialized.
136 If 8-bit I/O port operations are not supported, then ASSERT().
138 @param Port The I/O port to write.
139 @param OrData The value to OR with the read value from the I/O port.
141 @return The value written back to the I/O port.
151 return InternalSaveIoWrite8ValueToBootScript (Port
, IoOr8 (Port
, OrData
));
155 Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back
156 to the 8-bit I/O port and saves the value in the S3 script to be replayed
159 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
160 the read result and the value specified by AndData, and writes the result to
161 the 8-bit I/O port specified by Port. The value written to the I/O port is
162 returned. This function must guarantee that all I/O read and write operations
165 If 8-bit I/O port operations are not supported, then ASSERT().
167 @param Port The I/O port to write.
168 @param AndData The value to AND with the read value from the I/O port.
170 @return The value written back to the I/O port.
180 return InternalSaveIoWrite8ValueToBootScript (Port
, IoAnd8 (Port
, AndData
));
184 Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise
185 inclusive OR, and writes the result back to the 8-bit I/O port and saves
186 the value in the S3 script to be replayed on S3 resume.
188 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
189 the read result and the value specified by AndData, performs a bitwise OR
190 between the result of the AND operation and the value specified by OrData,
191 and writes the result to the 8-bit I/O port specified by Port. The value
192 written to the I/O port is returned. This function must guarantee that all
193 I/O read and write operations are serialized.
195 If 8-bit I/O port operations are not supported, then ASSERT().
197 @param Port The I/O port to write.
198 @param AndData The value to AND with the read value from the I/O port.
199 @param OrData The value to OR with the result of the AND operation.
201 @return The value written back to the I/O port.
212 return InternalSaveIoWrite8ValueToBootScript (Port
, IoAndThenOr8 (Port
, AndData
, OrData
));
216 Reads a bit field of an I/O register and saves the value in the S3 script to
217 be replayed on S3 resume.
219 Reads the bit field in an 8-bit I/O register. The bit field is specified by
220 the StartBit and the EndBit. The value of the bit field is returned.
222 If 8-bit I/O port operations are not supported, then ASSERT().
223 If StartBit is greater than 7, then ASSERT().
224 If EndBit is greater than 7, then ASSERT().
225 If EndBit is less than StartBit, then ASSERT().
227 @param Port The I/O port to read.
228 @param StartBit The ordinal of the least significant bit in the bit field.
230 @param EndBit The ordinal of the most significant bit in the bit field.
233 @return The value read.
244 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldRead8 (Port
, StartBit
, EndBit
));
248 Writes a bit field to an I/O register and saves the value in the S3 script to
249 be replayed on S3 resume.
251 Writes Value to the bit field of the I/O register. The bit field is specified
252 by the StartBit and the EndBit. All other bits in the destination I/O
253 register are preserved. The value written to the I/O port is returned. Extra
254 left bits in Value are stripped.
256 If 8-bit I/O port operations are not supported, then ASSERT().
257 If StartBit is greater than 7, then ASSERT().
258 If EndBit is greater than 7, then ASSERT().
259 If EndBit is less than StartBit, then ASSERT().
260 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
262 @param Port The I/O port to write.
263 @param StartBit The ordinal of the least significant bit in the bit field.
265 @param EndBit The ordinal of the most significant bit in the bit field.
267 @param Value New value of the bit field.
269 @return The value written back to the I/O port.
281 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldWrite8 (Port
, StartBit
, EndBit
, Value
));
285 Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the
286 result back to the bit field in the 8-bit port and saves the value in the
287 S3 script to be replayed on S3 resume.
289 Reads the 8-bit I/O port specified by Port, performs a bitwise OR
290 between the read result and the value specified by OrData, and writes the
291 result to the 8-bit I/O port specified by Port. The value written to the I/O
292 port is returned. This function must guarantee that all I/O read and write
293 operations are serialized. Extra left bits in OrData are stripped.
295 If 8-bit I/O port operations are not supported, then ASSERT().
296 If StartBit is greater than 7, then ASSERT().
297 If EndBit is greater than 7, then ASSERT().
298 If EndBit is less than StartBit, then ASSERT().
299 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
301 @param Port The I/O port to write.
302 @param StartBit The ordinal of the least significant bit in the bit field.
304 @param EndBit The ordinal of the most significant bit in the bit field.
306 @param OrData The value to OR with the read value from the I/O port.
308 @return The value written back to the I/O port.
320 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldOr8 (Port
, StartBit
, EndBit
, OrData
));
324 Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the
325 result back to the bit field in the 8-bit port and saves the value in the
326 S3 script to be replayed on S3 resume.
328 Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
329 the read result and the value specified by AndData, and writes the result to
330 the 8-bit I/O port specified by Port. The value written to the I/O port is
331 returned. This function must guarantee that all I/O read and write operations
332 are serialized. Extra left bits in AndData are stripped.
334 If 8-bit I/O port operations are not supported, then ASSERT().
335 If StartBit is greater than 7, then ASSERT().
336 If EndBit is greater than 7, then ASSERT().
337 If EndBit is less than StartBit, then ASSERT().
338 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
340 @param Port The I/O port to write.
341 @param StartBit The ordinal of the least significant bit in the bit field.
343 @param EndBit The ordinal of the most significant bit in the bit field.
345 @param AndData The value to AND with the read value from the I/O port.
347 @return The value written back to the I/O port.
359 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldAnd8 (Port
, StartBit
, EndBit
, AndData
));
363 Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
364 bitwise OR, and writes the result back to the bit field in the
365 8-bit port and saves the value in the S3 script to be replayed on S3 resume.
367 Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed
368 by a bitwise OR between the read result and the value specified by
369 AndData, and writes the result to the 8-bit I/O port specified by Port. The
370 value written to the I/O port is returned. This function must guarantee that
371 all I/O read and write operations are serialized. Extra left bits in both
372 AndData and OrData are stripped.
374 If 8-bit I/O port operations are not supported, then ASSERT().
375 If StartBit is greater than 7, then ASSERT().
376 If EndBit is greater than 7, then ASSERT().
377 If EndBit is less than StartBit, then ASSERT().
378 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
379 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
381 @param Port The I/O port to write.
382 @param StartBit The ordinal of the least significant bit in the bit field.
384 @param EndBit The ordinal of the most significant bit in the bit field.
386 @param AndData The value to AND with the read value from the I/O port.
387 @param OrData The value to OR with the result of the AND operation.
389 @return The value written back to the I/O port.
394 S3IoBitFieldAndThenOr8 (
402 return InternalSaveIoWrite8ValueToBootScript (Port
, IoBitFieldAndThenOr8 (Port
, StartBit
, EndBit
, AndData
, OrData
));
406 Saves a 16-bit I/O port value to the boot script.
408 This internal worker function saves a 16-bit I/O port value in the S3 script
409 to be replayed on S3 resume.
411 If the saving process fails, then ASSERT().
413 @param Port The I/O port to write.
414 @param Value The value saved to boot script.
420 InternalSaveIoWrite16ValueToBootScript (
425 InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint16
, Port
, &Value
);
431 Reads a 16-bit I/O port and saves the value in the S3 script to be replayed
434 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
435 This function must guarantee that all I/O read and write operations are
438 If 16-bit I/O port operations are not supported, then ASSERT().
440 @param Port The I/O port to read.
442 @return The value read.
451 return InternalSaveIoWrite16ValueToBootScript (Port
, IoRead16 (Port
));
455 Writes a 16-bit I/O port and saves the value in the S3 script to be replayed
458 Writes the 16-bit I/O port specified by Port with the value specified by Value
459 and returns Value. This function must guarantee that all I/O read and write
460 operations are serialized.
462 If 16-bit I/O port operations are not supported, then ASSERT().
464 @param Port The I/O port to write.
465 @param Value The value to write to the I/O port.
467 @return The value written the I/O port.
477 return InternalSaveIoWrite16ValueToBootScript (Port
, IoWrite16 (Port
, Value
));
481 Reads a 16-bit I/O port, performs a bitwise OR, and writes the
482 result back to the 16-bit I/O port and saves the value in the S3 script to
483 be replayed on S3 resume.
485 Reads the 16-bit I/O port specified by Port, performs a bitwise OR
486 between the read result and the value specified by OrData, and writes the
487 result to the 16-bit I/O port specified by Port. The value written to the I/O
488 port is returned. This function must guarantee that all I/O read and write
489 operations are serialized.
491 If 16-bit I/O port operations are not supported, then ASSERT().
493 @param Port The I/O port to write.
494 @param OrData The value to OR with the read value from the I/O port.
496 @return The value written back to the I/O port.
506 return InternalSaveIoWrite16ValueToBootScript (Port
, IoOr16 (Port
, OrData
));
510 Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back
511 to the 16-bit I/O port and saves the value in the S3 script to be replayed
514 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
515 the read result and the value specified by AndData, and writes the result to
516 the 16-bit I/O port specified by Port. The value written to the I/O port is
517 returned. This function must guarantee that all I/O read and write operations
520 If 16-bit I/O port operations are not supported, then ASSERT().
522 @param Port The I/O port to write.
523 @param AndData The value to AND with the read value from the I/O port.
525 @return The value written back to the I/O port.
535 return InternalSaveIoWrite16ValueToBootScript (Port
, IoAnd16 (Port
, AndData
));
539 Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise
540 inclusive OR, and writes the result back to the 16-bit I/O port and saves
541 the value in the S3 script to be replayed on S3 resume.
543 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
544 the read result and the value specified by AndData, performs a bitwise OR
545 between the result of the AND operation and the value specified by OrData,
546 and writes the result to the 16-bit I/O port specified by Port. The value
547 written to the I/O port is returned. This function must guarantee that all
548 I/O read and write operations are serialized.
550 If 16-bit I/O port operations are not supported, then ASSERT().
552 @param Port The I/O port to write.
553 @param AndData The value to AND with the read value from the I/O port.
554 @param OrData The value to OR with the result of the AND operation.
556 @return The value written back to the I/O port.
567 return InternalSaveIoWrite16ValueToBootScript (Port
, IoAndThenOr16 (Port
, AndData
, OrData
));
571 Reads a bit field of an I/O register saves the value in the S3 script to be
572 replayed on S3 resume.
574 Reads the bit field in a 16-bit I/O register. The bit field is specified by
575 the StartBit and the EndBit. The value of the bit field is returned.
577 If 16-bit I/O port operations are not supported, then ASSERT().
578 If StartBit is greater than 15, then ASSERT().
579 If EndBit is greater than 15, then ASSERT().
580 If EndBit is less than StartBit, then ASSERT().
582 @param Port The I/O port to read.
583 @param StartBit The ordinal of the least significant bit in the bit field.
585 @param EndBit The ordinal of the most significant bit in the bit field.
588 @return The value read.
599 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldRead16 (Port
, StartBit
, EndBit
));
603 Writes a bit field to an I/O register and saves the value in the S3 script
604 to be replayed on S3 resume.
606 Writes Value to the bit field of the I/O register. The bit field is specified
607 by the StartBit and the EndBit. All other bits in the destination I/O
608 register are preserved. The value written to the I/O port is returned. Extra
609 left bits in Value are stripped.
611 If 16-bit I/O port operations are not supported, then ASSERT().
612 If StartBit is greater than 15, then ASSERT().
613 If EndBit is greater than 15, then ASSERT().
614 If EndBit is less than StartBit, then ASSERT().
615 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
617 @param Port The I/O port to write.
618 @param StartBit The ordinal of the least significant bit in the bit field.
620 @param EndBit The ordinal of the most significant bit in the bit field.
622 @param Value New value of the bit field.
624 @return The value written back to the I/O port.
629 S3IoBitFieldWrite16 (
636 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldWrite16 (Port
, StartBit
, EndBit
, Value
));
640 Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the
641 result back to the bit field in the 16-bit port and saves the value in the
642 S3 script to be replayed on S3 resume.
644 Reads the 16-bit I/O port specified by Port, performs a bitwise OR
645 between the read result and the value specified by OrData, and writes the
646 result to the 16-bit I/O port specified by Port. The value written to the I/O
647 port is returned. This function must guarantee that all I/O read and write
648 operations are serialized. Extra left bits in OrData are stripped.
650 If 16-bit I/O port operations are not supported, then ASSERT().
651 If StartBit is greater than 15, then ASSERT().
652 If EndBit is greater than 15, then ASSERT().
653 If EndBit is less than StartBit, then ASSERT().
654 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
656 @param Port The I/O port to write.
657 @param StartBit The ordinal of the least significant bit in the bit field.
659 @param EndBit The ordinal of the most significant bit in the bit field.
661 @param OrData The value to OR with the read value from the I/O port.
663 @return The value written back to the I/O port.
675 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldOr16 (Port
, StartBit
, EndBit
, OrData
));
679 Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the
680 result back to the bit field in the 16-bit port and saves the value in the
681 S3 script to be replayed on S3 resume.
683 Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
684 the read result and the value specified by AndData, and writes the result to
685 the 16-bit I/O port specified by Port. The value written to the I/O port is
686 returned. This function must guarantee that all I/O read and write operations
687 are serialized. Extra left bits in AndData are stripped.
689 If 16-bit I/O port operations are not supported, then ASSERT().
690 If StartBit is greater than 15, then ASSERT().
691 If EndBit is greater than 15, then ASSERT().
692 If EndBit is less than StartBit, then ASSERT().
693 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
695 @param Port The I/O port to write.
696 @param StartBit The ordinal of the least significant bit in the bit field.
698 @param EndBit The ordinal of the most significant bit in the bit field.
700 @param AndData The value to AND with the read value from the I/O port.
702 @return The value written back to the I/O port.
714 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldAnd16 (Port
, StartBit
, EndBit
, AndData
));
718 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
719 bitwise OR, and writes the result back to the bit field in the
720 16-bit port and saves the value in the S3 script to be replayed on S3
723 Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed
724 by a bitwise OR between the read result and the value specified by
725 AndData, and writes the result to the 16-bit I/O port specified by Port. The
726 value written to the I/O port is returned. This function must guarantee that
727 all I/O read and write operations are serialized. Extra left bits in both
728 AndData and OrData are stripped.
730 If 16-bit I/O port operations are not supported, then ASSERT().
731 If StartBit is greater than 15, then ASSERT().
732 If EndBit is greater than 15, then ASSERT().
733 If EndBit is less than StartBit, then ASSERT().
734 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
735 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
737 @param Port The I/O port to write.
738 @param StartBit The ordinal of the least significant bit in the bit field.
740 @param EndBit The ordinal of the most significant bit in the bit field.
742 @param AndData The value to AND with the read value from the I/O port.
743 @param OrData The value to OR with the result of the AND operation.
745 @return The value written back to the I/O port.
750 S3IoBitFieldAndThenOr16 (
758 return InternalSaveIoWrite16ValueToBootScript (Port
, IoBitFieldAndThenOr16 (Port
, StartBit
, EndBit
, AndData
, OrData
));
762 Saves a 32-bit I/O port value to the boot script.
764 This internal worker function saves a 32-bit I/O port value in the S3 script
765 to be replayed on S3 resume.
767 If the saving process fails, then ASSERT().
769 @param Port The I/O port to write.
770 @param Value The value saved to boot script.
776 InternalSaveIoWrite32ValueToBootScript (
781 InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint32
, Port
, &Value
);
787 Reads a 32-bit I/O port and saves the value in the S3 script to be replayed
790 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
791 This function must guarantee that all I/O read and write operations are
794 If 32-bit I/O port operations are not supported, then ASSERT().
796 @param Port The I/O port to read.
798 @return The value read.
807 return InternalSaveIoWrite32ValueToBootScript (Port
, IoRead32 (Port
));
811 Writes a 32-bit I/O port and saves the value in the S3 script to be replayed
814 Writes the 32-bit I/O port specified by Port with the value specified by Value
815 and returns Value. This function must guarantee that all I/O read and write
816 operations are serialized.
818 If 32-bit I/O port operations are not supported, then ASSERT().
820 @param Port The I/O port to write.
821 @param Value The value to write to the I/O port.
823 @return The value written the I/O port.
833 return InternalSaveIoWrite32ValueToBootScript (Port
, IoWrite32 (Port
, Value
));
837 Reads a 32-bit I/O port, performs a bitwise OR, and writes the
838 result back to the 32-bit I/O port and saves the value in the S3 script to
839 be replayed on S3 resume.
841 Reads the 32-bit I/O port specified by Port, performs a bitwise OR
842 between the read result and the value specified by OrData, and writes the
843 result to the 32-bit I/O port specified by Port. The value written to the I/O
844 port is returned. This function must guarantee that all I/O read and write
845 operations are serialized.
847 If 32-bit I/O port operations are not supported, then ASSERT().
849 @param Port The I/O port to write.
850 @param OrData The value to OR with the read value from the I/O port.
852 @return The value written back to the I/O port.
862 return InternalSaveIoWrite32ValueToBootScript (Port
, IoOr32 (Port
, OrData
));
866 Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back
867 to the 32-bit I/O port and saves the value in the S3 script to be replayed
870 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
871 the read result and the value specified by AndData, and writes the result to
872 the 32-bit I/O port specified by Port. The value written to the I/O port is
873 returned. This function must guarantee that all I/O read and write operations
876 If 32-bit I/O port operations are not supported, then ASSERT().
878 @param Port The I/O port to write.
879 @param AndData The value to AND with the read value from the I/O port.
881 @return The value written back to the I/O port.
891 return InternalSaveIoWrite32ValueToBootScript (Port
, IoAnd32 (Port
, AndData
));
895 Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise
896 inclusive OR, and writes the result back to the 32-bit I/O port and saves
897 the value in the S3 script to be replayed on S3 resume.
899 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
900 the read result and the value specified by AndData, performs a bitwise OR
901 between the result of the AND operation and the value specified by OrData,
902 and writes the result to the 32-bit I/O port specified by Port. The value
903 written to the I/O port is returned. This function must guarantee that all
904 I/O read and write operations are serialized.
906 If 32-bit I/O port operations are not supported, then ASSERT().
908 @param Port The I/O port to write.
909 @param AndData The value to AND with the read value from the I/O port.
910 @param OrData The value to OR with the result of the AND operation.
912 @return The value written back to the I/O port.
923 return InternalSaveIoWrite32ValueToBootScript (Port
, IoAndThenOr32 (Port
, AndData
, OrData
));
927 Reads a bit field of an I/O register and saves the value in the S3 script to
928 be replayed on S3 resume.
930 Reads the bit field in a 32-bit I/O register. The bit field is specified by
931 the StartBit and the EndBit. The value of the bit field is returned.
933 If 32-bit I/O port operations are not supported, then ASSERT().
934 If StartBit is greater than 31, then ASSERT().
935 If EndBit is greater than 31, then ASSERT().
936 If EndBit is less than StartBit, then ASSERT().
938 @param Port The I/O port to read.
939 @param StartBit The ordinal of the least significant bit in the bit field.
941 @param EndBit The ordinal of the most significant bit in the bit field.
944 @return The value read.
955 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldRead32 (Port
, StartBit
, EndBit
));
959 Writes a bit field to an I/O register and saves the value in the S3 script to
960 be replayed on S3 resume.
962 Writes Value to the bit field of the I/O register. The bit field is specified
963 by the StartBit and the EndBit. All other bits in the destination I/O
964 register are preserved. The value written to the I/O port is returned. Extra
965 left bits in Value are stripped.
967 If 32-bit I/O port operations are not supported, then ASSERT().
968 If StartBit is greater than 31, then ASSERT().
969 If EndBit is greater than 31, then ASSERT().
970 If EndBit is less than StartBit, then ASSERT().
971 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
973 @param Port The I/O port to write.
974 @param StartBit The ordinal of the least significant bit in the bit field.
976 @param EndBit The ordinal of the most significant bit in the bit field.
978 @param Value New value of the bit field.
980 @return The value written back to the I/O port.
985 S3IoBitFieldWrite32 (
992 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldWrite32 (Port
, StartBit
, EndBit
, Value
));
996 Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the
997 result back to the bit field in the 32-bit port and saves the value in the
998 S3 script to be replayed on S3 resume.
1000 Reads the 32-bit I/O port specified by Port, performs a bitwise OR
1001 between the read result and the value specified by OrData, and writes the
1002 result to the 32-bit I/O port specified by Port. The value written to the I/O
1003 port is returned. This function must guarantee that all I/O read and write
1004 operations are serialized. Extra left bits in OrData are stripped.
1006 If 32-bit I/O port operations are not supported, then ASSERT().
1007 If StartBit is greater than 31, then ASSERT().
1008 If EndBit is greater than 31, then ASSERT().
1009 If EndBit is less than StartBit, then ASSERT().
1010 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1012 @param Port The I/O port to write.
1013 @param StartBit The ordinal of the least significant bit in the bit field.
1015 @param EndBit The ordinal of the most significant bit in the bit field.
1017 @param OrData The value to OR with the read value from the I/O port.
1019 @return The value written back to the I/O port.
1031 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldOr32 (Port
, StartBit
, EndBit
, OrData
));
1035 Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the
1036 result back to the bit field in the 32-bit port and saves the value in the
1037 S3 script to be replayed on S3 resume.
1039 Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
1040 the read result and the value specified by AndData, and writes the result to
1041 the 32-bit I/O port specified by Port. The value written to the I/O port is
1042 returned. This function must guarantee that all I/O read and write operations
1043 are serialized. Extra left bits in AndData are stripped.
1045 If 32-bit I/O port operations are not supported, then ASSERT().
1046 If StartBit is greater than 31, then ASSERT().
1047 If EndBit is greater than 31, then ASSERT().
1048 If EndBit is less than StartBit, then ASSERT().
1049 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1051 @param Port The I/O port to write.
1052 @param StartBit The ordinal of the least significant bit in the bit field.
1054 @param EndBit The ordinal of the most significant bit in the bit field.
1056 @param AndData The value to AND with the read value from the I/O port.
1058 @return The value written back to the I/O port.
1070 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldAnd32 (Port
, StartBit
, EndBit
, AndData
));
1074 Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
1075 bitwise OR, and writes the result back to the bit field in the
1076 32-bit port and saves the value in the S3 script to be replayed on S3
1079 Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed
1080 by a bitwise OR between the read result and the value specified by
1081 AndData, and writes the result to the 32-bit I/O port specified by Port. The
1082 value written to the I/O port is returned. This function must guarantee that
1083 all I/O read and write operations are serialized. Extra left bits in both
1084 AndData and OrData are stripped.
1086 If 32-bit I/O port operations are not supported, then ASSERT().
1087 If StartBit is greater than 31, then ASSERT().
1088 If EndBit is greater than 31, then ASSERT().
1089 If EndBit is less than StartBit, then ASSERT().
1090 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1091 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1093 @param Port The I/O port to write.
1094 @param StartBit The ordinal of the least significant bit in the bit field.
1096 @param EndBit The ordinal of the most significant bit in the bit field.
1098 @param AndData The value to AND with the read value from the I/O port.
1099 @param OrData The value to OR with the result of the AND operation.
1101 @return The value written back to the I/O port.
1106 S3IoBitFieldAndThenOr32 (
1114 return InternalSaveIoWrite32ValueToBootScript (Port
, IoBitFieldAndThenOr32 (Port
, StartBit
, EndBit
, AndData
, OrData
));
1118 Saves a 64-bit I/O port value to the boot script.
1120 This internal worker function saves a 64-bit I/O port value in the S3 script
1121 to be replayed on S3 resume.
1123 If the saving process fails, then ASSERT().
1125 @param Port The I/O port to write.
1126 @param Value The value saved to boot script.
1132 InternalSaveIoWrite64ValueToBootScript (
1137 InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint64
, Port
, &Value
);
1143 Reads a 64-bit I/O port and saves the value in the S3 script to be replayed
1146 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
1147 This function must guarantee that all I/O read and write operations are
1150 If 64-bit I/O port operations are not supported, then ASSERT().
1152 @param Port The I/O port to read.
1154 @return The value read.
1163 return InternalSaveIoWrite64ValueToBootScript (Port
, IoRead64 (Port
));
1167 Writes a 64-bit I/O port and saves the value in the S3 script to be replayed
1170 Writes the 64-bit I/O port specified by Port with the value specified by Value
1171 and returns Value. This function must guarantee that all I/O read and write
1172 operations are serialized.
1174 If 64-bit I/O port operations are not supported, then ASSERT().
1176 @param Port The I/O port to write.
1177 @param Value The value to write to the I/O port.
1179 @return The value written the I/O port.
1189 return InternalSaveIoWrite64ValueToBootScript (Port
, IoWrite64 (Port
, Value
));
1193 Reads a 64-bit I/O port, performs a bitwise OR, and writes the
1194 result back to the 64-bit I/O port and saves the value in the S3 script to
1195 be replayed on S3 resume.
1197 Reads the 64-bit I/O port specified by Port, performs a bitwise OR
1198 between the read result and the value specified by OrData, and writes the
1199 result to the 64-bit I/O port specified by Port. The value written to the I/O
1200 port is returned. This function must guarantee that all I/O read and write
1201 operations are serialized.
1203 If 64-bit I/O port operations are not supported, then ASSERT().
1205 @param Port The I/O port to write.
1206 @param OrData The value to OR with the read value from the I/O port.
1208 @return The value written back to the I/O port.
1218 return InternalSaveIoWrite64ValueToBootScript (Port
, IoOr64 (Port
, OrData
));
1222 Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back
1223 to the 64-bit I/O port and saves the value in the S3 script to be replayed
1226 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
1227 the read result and the value specified by AndData, and writes the result to
1228 the 64-bit I/O port specified by Port. The value written to the I/O port is
1229 returned. This function must guarantee that all I/O read and write operations
1232 If 64-bit I/O port operations are not supported, then ASSERT().
1234 @param Port The I/O port to write.
1235 @param AndData The value to AND with the read value from the I/O port.
1237 @return The value written back to the I/O port.
1247 return InternalSaveIoWrite64ValueToBootScript (Port
, IoAnd64 (Port
, AndData
));
1251 Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise
1252 inclusive OR, and writes the result back to the 64-bit I/O port and saves
1253 the value in the S3 script to be replayed on S3 resume.
1255 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
1256 the read result and the value specified by AndData, performs a bitwise OR
1257 between the result of the AND operation and the value specified by OrData,
1258 and writes the result to the 64-bit I/O port specified by Port. The value
1259 written to the I/O port is returned. This function must guarantee that all
1260 I/O read and write operations are serialized.
1262 If 64-bit I/O port operations are not supported, then ASSERT().
1264 @param Port The I/O port to write.
1265 @param AndData The value to AND with the read value from the I/O port.
1266 @param OrData The value to OR with the result of the AND operation.
1268 @return The value written back to the I/O port.
1279 return InternalSaveIoWrite64ValueToBootScript (Port
, IoAndThenOr64 (Port
, AndData
, OrData
));
1283 Reads a bit field of an I/O register and saves the value in the S3 script to
1284 be replayed on S3 resume.
1286 Reads the bit field in a 64-bit I/O register. The bit field is specified by
1287 the StartBit and the EndBit. The value of the bit field is returned.
1289 If 64-bit I/O port operations are not supported, then ASSERT().
1290 If StartBit is greater than 63, then ASSERT().
1291 If EndBit is greater than 63, then ASSERT().
1292 If EndBit is less than StartBit, then ASSERT().
1294 @param Port The I/O port to read.
1295 @param StartBit The ordinal of the least significant bit in the bit field.
1297 @param EndBit The ordinal of the most significant bit in the bit field.
1300 @return The value read.
1305 S3IoBitFieldRead64 (
1311 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldRead64 (Port
, StartBit
, EndBit
));
1315 Writes a bit field to an I/O register and saves the value in the S3 script to
1316 be replayed on S3 resume.
1318 Writes Value to the bit field of the I/O register. The bit field is specified
1319 by the StartBit and the EndBit. All other bits in the destination I/O
1320 register are preserved. The value written to the I/O port is returned. Extra
1321 left bits in Value are stripped.
1323 If 64-bit I/O port operations are not supported, then ASSERT().
1324 If StartBit is greater than 63, then ASSERT().
1325 If EndBit is greater than 63, then ASSERT().
1326 If EndBit is less than StartBit, then ASSERT().
1327 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1329 @param Port The I/O port to write.
1330 @param StartBit The ordinal of the least significant bit in the bit field.
1332 @param EndBit The ordinal of the most significant bit in the bit field.
1334 @param Value New value of the bit field.
1336 @return The value written back to the I/O port.
1341 S3IoBitFieldWrite64 (
1348 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldWrite64 (Port
, StartBit
, EndBit
, Value
));
1352 Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the
1353 result back to the bit field in the 64-bit port and saves the value in the
1354 S3 script to be replayed on S3 resume.
1356 Reads the 64-bit I/O port specified by Port, performs a bitwise OR
1357 between the read result and the value specified by OrData, and writes the
1358 result to the 64-bit I/O port specified by Port. The value written to the I/O
1359 port is returned. This function must guarantee that all I/O read and write
1360 operations are serialized. Extra left bits in OrData are stripped.
1362 If 64-bit I/O port operations are not supported, then ASSERT().
1363 If StartBit is greater than 63, then ASSERT().
1364 If EndBit is greater than 63, then ASSERT().
1365 If EndBit is less than StartBit, then ASSERT().
1366 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1368 @param Port The I/O port to write.
1369 @param StartBit The ordinal of the least significant bit in the bit field.
1371 @param EndBit The ordinal of the most significant bit in the bit field.
1373 @param OrData The value to OR with the read value from the I/O port.
1375 @return The value written back to the I/O port.
1387 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldOr64 (Port
, StartBit
, EndBit
, OrData
));
1391 Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the
1392 result back to the bit field in the 64-bit port and saves the value in the
1393 S3 script to be replayed on S3 resume.
1395 Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
1396 the read result and the value specified by AndData, and writes the result to
1397 the 64-bit I/O port specified by Port. The value written to the I/O port is
1398 returned. This function must guarantee that all I/O read and write operations
1399 are serialized. Extra left bits in AndData are stripped.
1401 If 64-bit I/O port operations are not supported, then ASSERT().
1402 If StartBit is greater than 63, then ASSERT().
1403 If EndBit is greater than 63, then ASSERT().
1404 If EndBit is less than StartBit, then ASSERT().
1405 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1407 @param Port The I/O port to write.
1408 @param StartBit The ordinal of the least significant bit in the bit field.
1410 @param EndBit The ordinal of the most significant bit in the bit field.
1412 @param AndData The value to AND with the read value from the I/O port.
1414 @return The value written back to the I/O port.
1426 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldAnd64 (Port
, StartBit
, EndBit
, AndData
));
1430 Reads a bit field in a 64-bit port, performs a bitwise AND followed by a
1431 bitwise OR, and writes the result back to the bit field in the
1432 64-bit port and saves the value in the S3 script to be replayed on S3
1435 Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed
1436 by a bitwise OR between the read result and the value specified by
1437 AndData, and writes the result to the 64-bit I/O port specified by Port. The
1438 value written to the I/O port is returned. This function must guarantee that
1439 all I/O read and write operations are serialized. Extra left bits in both
1440 AndData and OrData are stripped.
1442 If 64-bit I/O port operations are not supported, then ASSERT().
1443 If StartBit is greater than 63, then ASSERT().
1444 If EndBit is greater than 63, then ASSERT().
1445 If EndBit is less than StartBit, then ASSERT().
1446 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1447 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1449 @param Port The I/O port to write.
1450 @param StartBit The ordinal of the least significant bit in the bit field.
1452 @param EndBit The ordinal of the most significant bit in the bit field.
1454 @param AndData The value to AND with the read value from the I/O port.
1455 @param OrData The value to OR with the result of the AND operation.
1457 @return The value written back to the I/O port.
1462 S3IoBitFieldAndThenOr64 (
1470 return InternalSaveIoWrite64ValueToBootScript (Port
, IoBitFieldAndThenOr64 (Port
, StartBit
, EndBit
, AndData
, OrData
));
1474 Saves an MMIO register value to the boot script.
1476 This internal worker function saves an MMIO register value in the S3 script
1477 to be replayed on S3 resume.
1479 If the saving process fails, then ASSERT().
1481 @param Width The width of MMIO register.
1482 @param Address The MMIO register to write.
1483 @param Buffer The buffer containing value.
1487 InternalSaveMmioWriteValueToBootScript (
1488 IN S3_BOOT_SCRIPT_LIB_WIDTH Width
,
1493 RETURN_STATUS Status
;
1495 Status
= S3BootScriptSaveMemWrite (
1501 ASSERT (Status
== RETURN_SUCCESS
);
1505 Saves an 8-bit MMIO register value to the boot script.
1507 This internal worker function saves an 8-bit MMIO register value in the S3 script
1508 to be replayed on S3 resume.
1510 If the saving process fails, then ASSERT().
1512 @param Address The MMIO register to write.
1513 @param Value The value saved to boot script.
1519 InternalSaveMmioWrite8ValueToBootScript (
1524 InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint8
, Address
, &Value
);
1530 Reads an 8-bit MMIO register and saves the value in the S3 script to be
1531 replayed on S3 resume.
1533 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
1534 returned. This function must guarantee that all MMIO read and write
1535 operations are serialized.
1537 If 8-bit MMIO register operations are not supported, then ASSERT().
1539 @param Address The MMIO register to read.
1541 @return The value read.
1550 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioRead8 (Address
));
1554 Writes an 8-bit MMIO register and saves the value in the S3 script to be
1555 replayed on S3 resume.
1557 Writes the 8-bit MMIO register specified by Address with the value specified
1558 by Value and returns Value. This function must guarantee that all MMIO read
1559 and write operations are serialized.
1561 If 8-bit MMIO register operations are not supported, then ASSERT().
1563 @param Address The MMIO register to write.
1564 @param Value The value to write to the MMIO register.
1566 @return The value written the MMIO register.
1576 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioWrite8 (Address
, Value
));
1580 Reads an 8-bit MMIO register, performs a bitwise OR, and writes the
1581 result back to the 8-bit MMIO register and saves the value in the S3 script
1582 to be replayed on S3 resume.
1584 Reads the 8-bit MMIO register specified by Address, performs a bitwise
1585 inclusive OR between the read result and the value specified by OrData, and
1586 writes the result to the 8-bit MMIO register specified by Address. The value
1587 written to the MMIO register is returned. This function must guarantee that
1588 all MMIO read and write operations are serialized.
1590 If 8-bit MMIO register operations are not supported, then ASSERT().
1592 @param Address The MMIO register to write.
1593 @param OrData The value to OR with the read value from the MMIO register.
1595 @return The value written back to the MMIO register.
1605 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioOr8 (Address
, OrData
));
1609 Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result
1610 back to the 8-bit MMIO register and saves the value in the S3 script to be
1611 replayed on S3 resume.
1613 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1614 between the read result and the value specified by AndData, and writes the
1615 result to the 8-bit MMIO register specified by Address. The value written to
1616 the MMIO register is returned. This function must guarantee that all MMIO
1617 read and write operations are serialized.
1619 If 8-bit MMIO register operations are not supported, then ASSERT().
1621 @param Address The MMIO register to write.
1622 @param AndData The value to AND with the read value from the MMIO register.
1624 @return The value written back to the MMIO register.
1634 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioAnd8 (Address
, AndData
));
1638 Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise
1639 inclusive OR, and writes the result back to the 8-bit MMIO register and saves
1640 the value in the S3 script to be replayed on S3 resume.
1642 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1643 between the read result and the value specified by AndData, performs a
1644 bitwise OR between the result of the AND operation and the value specified by
1645 OrData, and writes the result to the 8-bit MMIO register specified by
1646 Address. The value written to the MMIO register is returned. This function
1647 must guarantee that all MMIO read and write operations are serialized.
1649 If 8-bit MMIO register operations are not supported, then ASSERT().
1651 @param Address The MMIO register to write.
1652 @param AndData The value to AND with the read value from the MMIO register.
1653 @param OrData The value to OR with the result of the AND operation.
1655 @return The value written back to the MMIO register.
1666 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioAndThenOr8 (Address
, AndData
, OrData
));
1670 Reads a bit field of a MMIO register and saves the value in the S3 script to
1671 be replayed on S3 resume.
1673 Reads the bit field in an 8-bit MMIO register. The bit field is specified by
1674 the StartBit and the EndBit. The value of the bit field is returned.
1676 If 8-bit MMIO register operations are not supported, then ASSERT().
1677 If StartBit is greater than 7, then ASSERT().
1678 If EndBit is greater than 7, then ASSERT().
1679 If EndBit is less than StartBit, then ASSERT().
1681 @param Address MMIO register to read.
1682 @param StartBit The ordinal of the least significant bit in the bit field.
1684 @param EndBit The ordinal of the most significant bit in the bit field.
1687 @return The value read.
1692 S3MmioBitFieldRead8 (
1698 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldRead8 (Address
, StartBit
, EndBit
));
1702 Writes a bit field to an MMIO register and saves the value in the S3 script to
1703 be replayed on S3 resume.
1705 Writes Value to the bit field of the MMIO register. The bit field is
1706 specified by the StartBit and the EndBit. All other bits in the destination
1707 MMIO register are preserved. The new value of the 8-bit register is returned.
1709 If 8-bit MMIO register operations are not supported, then ASSERT().
1710 If StartBit is greater than 7, then ASSERT().
1711 If EndBit is greater than 7, then ASSERT().
1712 If EndBit is less than StartBit, then ASSERT().
1713 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1715 @param Address The MMIO register to write.
1716 @param StartBit The ordinal of the least significant bit in the bit field.
1718 @param EndBit The ordinal of the most significant bit in the bit field.
1720 @param Value New value of the bit field.
1722 @return The value written back to the MMIO register.
1727 S3MmioBitFieldWrite8 (
1734 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldWrite8 (Address
, StartBit
, EndBit
, Value
));
1738 Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and
1739 writes the result back to the bit field in the 8-bit MMIO register and saves
1740 the value in the S3 script to be replayed on S3 resume.
1742 Reads the 8-bit MMIO register specified by Address, performs a bitwise
1743 inclusive OR between the read result and the value specified by OrData, and
1744 writes the result to the 8-bit MMIO register specified by Address. The value
1745 written to the MMIO register is returned. This function must guarantee that
1746 all MMIO read and write operations are serialized. Extra left bits in OrData
1749 If 8-bit MMIO register operations are not supported, then ASSERT().
1750 If StartBit is greater than 7, then ASSERT().
1751 If EndBit is greater than 7, then ASSERT().
1752 If EndBit is less than StartBit, then ASSERT().
1753 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1755 @param Address The MMIO register to write.
1756 @param StartBit The ordinal of the least significant bit in the bit field.
1758 @param EndBit The ordinal of the most significant bit in the bit field.
1760 @param OrData The value to OR with the read value from the MMIO register.
1762 @return The value written back to the MMIO register.
1774 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldOr8 (Address
, StartBit
, EndBit
, OrData
));
1778 Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and
1779 writes the result back to the bit field in the 8-bit MMIO register and saves
1780 the value in the S3 script to be replayed on S3 resume.
1782 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1783 between the read result and the value specified by AndData, and writes the
1784 result to the 8-bit MMIO register specified by Address. The value written to
1785 the MMIO register is returned. This function must guarantee that all MMIO
1786 read and write operations are serialized. Extra left bits in AndData are
1789 If 8-bit MMIO register operations are not supported, then ASSERT().
1790 If StartBit is greater than 7, then ASSERT().
1791 If EndBit is greater than 7, then ASSERT().
1792 If EndBit is less than StartBit, then ASSERT().
1793 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1795 @param Address The MMIO register to write.
1796 @param StartBit The ordinal of the least significant bit in the bit field.
1798 @param EndBit The ordinal of the most significant bit in the bit field.
1800 @param AndData The value to AND with the read value from the MMIO register.
1802 @return The value written back to the MMIO register.
1807 S3MmioBitFieldAnd8 (
1814 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldAnd8 (Address
, StartBit
, EndBit
, AndData
));
1818 Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed
1819 by a bitwise OR, and writes the result back to the bit field in the
1820 8-bit MMIO register and saves the value in the S3 script to be replayed
1823 Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
1824 followed by a bitwise OR between the read result and the value
1825 specified by AndData, and writes the result to the 8-bit MMIO register
1826 specified by Address. The value written to the MMIO register is returned.
1827 This function must guarantee that all MMIO read and write operations are
1828 serialized. Extra left bits in both AndData and OrData are stripped.
1830 If 8-bit MMIO register operations are not supported, then ASSERT().
1831 If StartBit is greater than 7, then ASSERT().
1832 If EndBit is greater than 7, then ASSERT().
1833 If EndBit is less than StartBit, then ASSERT().
1834 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1835 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1837 @param Address The MMIO register to write.
1838 @param StartBit The ordinal of the least significant bit in the bit field.
1840 @param EndBit The ordinal of the most significant bit in the bit field.
1842 @param AndData The value to AND with the read value from the MMIO register.
1843 @param OrData The value to OR with the result of the AND operation.
1845 @return The value written back to the MMIO register.
1850 S3MmioBitFieldAndThenOr8 (
1858 return InternalSaveMmioWrite8ValueToBootScript (Address
, MmioBitFieldAndThenOr8 (Address
, StartBit
, EndBit
, AndData
, OrData
));
1862 Saves a 16-bit MMIO register value to the boot script.
1864 This internal worker function saves a 16-bit MMIO register value in the S3 script
1865 to be replayed on S3 resume.
1867 If the saving process fails, then ASSERT().
1869 @param Address The MMIO register to write.
1870 @param Value The value saved to boot script.
1876 InternalSaveMmioWrite16ValueToBootScript (
1881 InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint16
, Address
, &Value
);
1887 Reads a 16-bit MMIO register and saves the value in the S3 script to be replayed
1890 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
1891 returned. This function must guarantee that all MMIO read and write
1892 operations are serialized.
1894 If 16-bit MMIO register operations are not supported, then ASSERT().
1896 @param Address The MMIO register to read.
1898 @return The value read.
1907 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioRead16 (Address
));
1911 Writes a 16-bit MMIO register and saves the value in the S3 script to be replayed
1914 Writes the 16-bit MMIO register specified by Address with the value specified
1915 by Value and returns Value. This function must guarantee that all MMIO read
1916 and write operations are serialized and saves the value in the S3 script to be
1917 replayed on S3 resume.
1919 If 16-bit MMIO register operations are not supported, then ASSERT().
1921 @param Address The MMIO register to write.
1922 @param Value The value to write to the MMIO register.
1924 @return The value written the MMIO register.
1934 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioWrite16 (Address
, Value
));
1938 Reads a 16-bit MMIO register, performs a bitwise OR, and writes the
1939 result back to the 16-bit MMIO register and saves the value in the S3 script
1940 to be replayed on S3 resume.
1942 Reads the 16-bit MMIO register specified by Address, performs a bitwise
1943 inclusive OR between the read result and the value specified by OrData, and
1944 writes the result to the 16-bit MMIO register specified by Address. The value
1945 written to the MMIO register is returned. This function must guarantee that
1946 all MMIO read and write operations are serialized.
1948 If 16-bit MMIO register operations are not supported, then ASSERT().
1950 @param Address The MMIO register to write.
1951 @param OrData The value to OR with the read value from the MMIO register.
1953 @return The value written back to the MMIO register.
1963 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioOr16 (Address
, OrData
));
1967 Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result
1968 back to the 16-bit MMIO register and saves the value in the S3 script to be
1969 replayed on S3 resume.
1971 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
1972 between the read result and the value specified by AndData, and writes the
1973 result to the 16-bit MMIO register specified by Address. The value written to
1974 the MMIO register is returned. This function must guarantee that all MMIO
1975 read and write operations are serialized.
1977 If 16-bit MMIO register operations are not supported, then ASSERT().
1979 @param Address The MMIO register to write.
1980 @param AndData The value to AND with the read value from the MMIO register.
1982 @return The value written back to the MMIO register.
1992 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioAnd16 (Address
, AndData
));
1996 Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise
1997 inclusive OR, and writes the result back to the 16-bit MMIO register and
1998 saves the value in the S3 script to be replayed on S3 resume.
2000 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
2001 between the read result and the value specified by AndData, performs a
2002 bitwise OR between the result of the AND operation and the value specified by
2003 OrData, and writes the result to the 16-bit MMIO register specified by
2004 Address. The value written to the MMIO register is returned. This function
2005 must guarantee that all MMIO read and write operations are serialized.
2007 If 16-bit MMIO register operations are not supported, then ASSERT().
2009 @param Address The MMIO register to write.
2010 @param AndData The value to AND with the read value from the MMIO register.
2011 @param OrData The value to OR with the result of the AND operation.
2013 @return The value written back to the MMIO register.
2024 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioAndThenOr16 (Address
, AndData
, OrData
));
2028 Reads a bit field of a MMIO register and saves the value in the S3 script to
2029 be replayed on S3 resume.
2031 Reads the bit field in a 16-bit MMIO register. The bit field is specified by
2032 the StartBit and the EndBit. The value of the bit field is returned.
2034 If 16-bit MMIO register operations are not supported, then ASSERT().
2035 If StartBit is greater than 15, then ASSERT().
2036 If EndBit is greater than 15, then ASSERT().
2037 If EndBit is less than StartBit, then ASSERT().
2039 @param Address MMIO register to read.
2040 @param StartBit The ordinal of the least significant bit in the bit field.
2042 @param EndBit The ordinal of the most significant bit in the bit field.
2045 @return The value read.
2050 S3MmioBitFieldRead16 (
2056 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldRead16 (Address
, StartBit
, EndBit
));
2060 Writes a bit field to a MMIO register and saves the value in the S3 script to
2061 be replayed on S3 resume.
2063 Writes Value to the bit field of the MMIO register. The bit field is
2064 specified by the StartBit and the EndBit. All other bits in the destination
2065 MMIO register are preserved. The new value of the 16-bit register is returned.
2067 If 16-bit MMIO register operations are not supported, then ASSERT().
2068 If StartBit is greater than 15, then ASSERT().
2069 If EndBit is greater than 15, then ASSERT().
2070 If EndBit is less than StartBit, then ASSERT().
2071 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2073 @param Address The MMIO register to write.
2074 @param StartBit The ordinal of the least significant bit in the bit field.
2076 @param EndBit The ordinal of the most significant bit in the bit field.
2078 @param Value New value of the bit field.
2080 @return The value written back to the MMIO register.
2085 S3MmioBitFieldWrite16 (
2092 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldWrite16 (Address
, StartBit
, EndBit
, Value
));
2096 Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and
2097 writes the result back to the bit field in the 16-bit MMIO register and
2098 saves the value in the S3 script to be replayed on S3 resume.
2100 Reads the 16-bit MMIO register specified by Address, performs a bitwise
2101 inclusive OR between the read result and the value specified by OrData, and
2102 writes the result to the 16-bit MMIO register specified by Address. The value
2103 written to the MMIO register is returned. This function must guarantee that
2104 all MMIO read and write operations are serialized. Extra left bits in OrData
2107 If 16-bit MMIO register operations are not supported, then ASSERT().
2108 If StartBit is greater than 15, then ASSERT().
2109 If EndBit is greater than 15, then ASSERT().
2110 If EndBit is less than StartBit, then ASSERT().
2111 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2113 @param Address The MMIO register to write.
2114 @param StartBit The ordinal of the least significant bit in the bit field.
2116 @param EndBit The ordinal of the most significant bit in the bit field.
2118 @param OrData The value to OR with the read value from the MMIO register.
2120 @return The value written back to the MMIO register.
2125 S3MmioBitFieldOr16 (
2132 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldOr16 (Address
, StartBit
, EndBit
, OrData
));
2136 Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and
2137 writes the result back to the bit field in the 16-bit MMIO register and
2138 saves the value in the S3 script to be replayed on S3 resume.
2140 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
2141 between the read result and the value specified by AndData, and writes the
2142 result to the 16-bit MMIO register specified by Address. The value written to
2143 the MMIO register is returned. This function must guarantee that all MMIO
2144 read and write operations are serialized. Extra left bits in AndData are
2147 If 16-bit MMIO register operations are not supported, then ASSERT().
2148 If StartBit is greater than 15, then ASSERT().
2149 If EndBit is greater than 15, then ASSERT().
2150 If EndBit is less than StartBit, then ASSERT().
2151 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2153 @param Address The MMIO register to write.
2154 @param StartBit The ordinal of the least significant bit in the bit field.
2156 @param EndBit The ordinal of the most significant bit in the bit field.
2158 @param AndData The value to AND with the read value from the MMIO register.
2160 @return The value written back to the MMIO register.
2165 S3MmioBitFieldAnd16 (
2172 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldAnd16 (Address
, StartBit
, EndBit
, AndData
));
2176 Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed
2177 by a bitwise OR, and writes the result back to the bit field in the
2178 16-bit MMIO register and saves the value in the S3 script to be replayed
2181 Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
2182 followed by a bitwise OR between the read result and the value
2183 specified by AndData, and writes the result to the 16-bit MMIO register
2184 specified by Address. The value written to the MMIO register is returned.
2185 This function must guarantee that all MMIO read and write operations are
2186 serialized. Extra left bits in both AndData and OrData are stripped.
2188 If 16-bit MMIO register operations are not supported, then ASSERT().
2189 If StartBit is greater than 15, then ASSERT().
2190 If EndBit is greater than 15, then ASSERT().
2191 If EndBit is less than StartBit, then ASSERT().
2192 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2193 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2195 @param Address The MMIO register to write.
2196 @param StartBit The ordinal of the least significant bit in the bit field.
2198 @param EndBit The ordinal of the most significant bit in the bit field.
2200 @param AndData The value to AND with the read value from the MMIO register.
2201 @param OrData The value to OR with the result of the AND operation.
2203 @return The value written back to the MMIO register.
2208 S3MmioBitFieldAndThenOr16 (
2216 return InternalSaveMmioWrite16ValueToBootScript (Address
, MmioBitFieldAndThenOr16 (Address
, StartBit
, EndBit
, AndData
, OrData
));
2220 Saves a 32-bit MMIO register value to the boot script.
2222 This internal worker function saves a 32-bit MMIO register value in the S3 script
2223 to be replayed on S3 resume.
2225 If the saving process fails, then ASSERT().
2227 @param Address The MMIO register to write.
2228 @param Value The value saved to boot script.
2234 InternalSaveMmioWrite32ValueToBootScript (
2239 InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint32
, Address
, &Value
);
2245 Reads a 32-bit MMIO register saves the value in the S3 script to be
2246 replayed on S3 resume.
2248 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
2249 returned. This function must guarantee that all MMIO read and write
2250 operations are serialized.
2252 If 32-bit MMIO register operations are not supported, then ASSERT().
2254 @param Address The MMIO register to read.
2256 @return The value read.
2265 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioRead32 (Address
));
2269 Writes a 32-bit MMIO register and saves the value in the S3 script to be
2270 replayed on S3 resume.
2272 Writes the 32-bit MMIO register specified by Address with the value specified
2273 by Value and returns Value. This function must guarantee that all MMIO read
2274 and write operations are serialized.
2276 If 32-bit MMIO register operations are not supported, then ASSERT().
2278 @param Address The MMIO register to write.
2279 @param Value The value to write to the MMIO register.
2281 @return The value written the MMIO register.
2291 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioWrite32 (Address
, Value
));
2295 Reads a 32-bit MMIO register, performs a bitwise OR, and writes the
2296 result back to the 32-bit MMIO register and saves the value in the S3 script
2297 to be replayed on S3 resume.
2299 Reads the 32-bit MMIO register specified by Address, performs a bitwise
2300 inclusive OR between the read result and the value specified by OrData, and
2301 writes the result to the 32-bit MMIO register specified by Address. The value
2302 written to the MMIO register is returned. This function must guarantee that
2303 all MMIO read and write operations are serialized.
2305 If 32-bit MMIO register operations are not supported, then ASSERT().
2307 @param Address The MMIO register to write.
2308 @param OrData The value to OR with the read value from the MMIO register.
2310 @return The value written back to the MMIO register.
2320 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioOr32 (Address
, OrData
));
2324 Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result
2325 back to the 32-bit MMIO register and saves the value in the S3 script to be
2326 replayed on S3 resume.
2328 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
2329 between the read result and the value specified by AndData, and writes the
2330 result to the 32-bit MMIO register specified by Address. The value written to
2331 the MMIO register is returned. This function must guarantee that all MMIO
2332 read and write operations are serialized.
2334 If 32-bit MMIO register operations are not supported, then ASSERT().
2336 @param Address The MMIO register to write.
2337 @param AndData The value to AND with the read value from the MMIO register.
2339 @return The value written back to the MMIO register.
2349 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioAnd32 (Address
, AndData
));
2353 Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise
2354 inclusive OR, and writes the result back to the 32-bit MMIO register and
2355 saves the value in the S3 script to be replayed on S3 resume.
2357 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
2358 between the read result and the value specified by AndData, performs a
2359 bitwise OR between the result of the AND operation and the value specified by
2360 OrData, and writes the result to the 32-bit MMIO register specified by
2361 Address. The value written to the MMIO register is returned. This function
2362 must guarantee that all MMIO read and write operations are serialized.
2364 If 32-bit MMIO register operations are not supported, then ASSERT().
2366 @param Address The MMIO register to write.
2367 @param AndData The value to AND with the read value from the MMIO register.
2368 @param OrData The value to OR with the result of the AND operation.
2370 @return The value written back to the MMIO register.
2381 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioAndThenOr32 (Address
, AndData
, OrData
));
2385 Reads a bit field of a MMIO register and saves the value in the S3 script
2386 to be replayed on S3 resume.
2388 Reads the bit field in a 32-bit MMIO register. The bit field is specified by
2389 the StartBit and the EndBit. The value of the bit field is returned.
2391 If 32-bit MMIO register operations are not supported, then ASSERT().
2392 If StartBit is greater than 31, then ASSERT().
2393 If EndBit is greater than 31, then ASSERT().
2394 If EndBit is less than StartBit, then ASSERT().
2396 @param Address MMIO register to read.
2397 @param StartBit The ordinal of the least significant bit in the bit field.
2399 @param EndBit The ordinal of the most significant bit in the bit field.
2402 @return The value read.
2407 S3MmioBitFieldRead32 (
2413 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldRead32 (Address
, StartBit
, EndBit
));
2417 Writes a bit field to a MMIO register and saves the value in the S3 script
2418 to be replayed on S3 resume.
2420 Writes Value to the bit field of the MMIO register. The bit field is
2421 specified by the StartBit and the EndBit. All other bits in the destination
2422 MMIO register are preserved. The new value of the 32-bit register is returned.
2424 If 32-bit MMIO register operations are not supported, then ASSERT().
2425 If StartBit is greater than 31, then ASSERT().
2426 If EndBit is greater than 31, then ASSERT().
2427 If EndBit is less than StartBit, then ASSERT().
2428 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2430 @param Address The MMIO register to write.
2431 @param StartBit The ordinal of the least significant bit in the bit field.
2433 @param EndBit The ordinal of the most significant bit in the bit field.
2435 @param Value New value of the bit field.
2437 @return The value written back to the MMIO register.
2442 S3MmioBitFieldWrite32 (
2449 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldWrite32 (Address
, StartBit
, EndBit
, Value
));
2453 Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and
2454 writes the result back to the bit field in the 32-bit MMIO register and
2455 saves the value in the S3 script to be replayed on S3 resume.
2457 Reads the 32-bit MMIO register specified by Address, performs a bitwise
2458 inclusive OR between the read result and the value specified by OrData, and
2459 writes the result to the 32-bit MMIO register specified by Address. The value
2460 written to the MMIO register is returned. This function must guarantee that
2461 all MMIO read and write operations are serialized. Extra left bits in OrData
2464 If 32-bit MMIO register operations are not supported, then ASSERT().
2465 If StartBit is greater than 31, then ASSERT().
2466 If EndBit is greater than 31, then ASSERT().
2467 If EndBit is less than StartBit, then ASSERT().
2468 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2470 @param Address The MMIO register to write.
2471 @param StartBit The ordinal of the least significant bit in the bit field.
2473 @param EndBit The ordinal of the most significant bit in the bit field.
2475 @param OrData The value to OR with the read value from the MMIO register.
2477 @return The value written back to the MMIO register.
2482 S3MmioBitFieldOr32 (
2489 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldOr32 (Address
, StartBit
, EndBit
, OrData
));
2493 Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and
2494 writes the result back to the bit field in the 32-bit MMIO register and
2495 saves the value in the S3 script to be replayed on S3 resume.
2497 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
2498 between the read result and the value specified by AndData, and writes the
2499 result to the 32-bit MMIO register specified by Address. The value written to
2500 the MMIO register is returned. This function must guarantee that all MMIO
2501 read and write operations are serialized. Extra left bits in AndData are
2504 If 32-bit MMIO register operations are not supported, then ASSERT().
2505 If StartBit is greater than 31, then ASSERT().
2506 If EndBit is greater than 31, then ASSERT().
2507 If EndBit is less than StartBit, then ASSERT().
2508 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2510 @param Address The MMIO register to write.
2511 @param StartBit The ordinal of the least significant bit in the bit field.
2513 @param EndBit The ordinal of the most significant bit in the bit field.
2515 @param AndData The value to AND with the read value from the MMIO register.
2517 @return The value written back to the MMIO register.
2522 S3MmioBitFieldAnd32 (
2529 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldAnd32 (Address
, StartBit
, EndBit
, AndData
));
2533 Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed
2534 by a bitwise OR, and writes the result back to the bit field in the
2535 32-bit MMIO register and saves the value in the S3 script to be replayed
2538 Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
2539 followed by a bitwise OR between the read result and the value
2540 specified by AndData, and writes the result to the 32-bit MMIO register
2541 specified by Address. The value written to the MMIO register is returned.
2542 This function must guarantee that all MMIO read and write operations are
2543 serialized. Extra left bits in both AndData and OrData are stripped.
2545 If 32-bit MMIO register operations are not supported, then ASSERT().
2546 If StartBit is greater than 31, then ASSERT().
2547 If EndBit is greater than 31, then ASSERT().
2548 If EndBit is less than StartBit, then ASSERT().
2549 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2550 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2552 @param Address The MMIO register to write.
2553 @param StartBit The ordinal of the least significant bit in the bit field.
2555 @param EndBit The ordinal of the most significant bit in the bit field.
2557 @param AndData The value to AND with the read value from the MMIO register.
2558 @param OrData The value to OR with the result of the AND operation.
2560 @return The value written back to the MMIO register.
2565 S3MmioBitFieldAndThenOr32 (
2573 return InternalSaveMmioWrite32ValueToBootScript (Address
, MmioBitFieldAndThenOr32 (Address
, StartBit
, EndBit
, AndData
, OrData
));
2577 Saves a 64-bit MMIO register value to the boot script.
2579 This internal worker function saves a 64-bit MMIO register value in the S3 script
2580 to be replayed on S3 resume.
2582 If the saving process fails, then ASSERT().
2584 @param Address The MMIO register to write.
2585 @param Value The value saved to boot script.
2591 InternalSaveMmioWrite64ValueToBootScript (
2596 InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint64
, Address
, &Value
);
2602 Reads a 64-bit MMIO register and saves the value in the S3 script to be
2603 replayed on S3 resume.
2605 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
2606 returned. This function must guarantee that all MMIO read and write
2607 operations are serialized.
2609 If 64-bit MMIO register operations are not supported, then ASSERT().
2611 @param Address The MMIO register to read.
2613 @return The value read.
2622 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioRead64 (Address
));
2626 Writes a 64-bit MMIO register and saves the value in the S3 script to be
2627 replayed on S3 resume.
2629 Writes the 64-bit MMIO register specified by Address with the value specified
2630 by Value and returns Value. This function must guarantee that all MMIO read
2631 and write operations are serialized.
2633 If 64-bit MMIO register operations are not supported, then ASSERT().
2635 @param Address The MMIO register to write.
2636 @param Value The value to write to the MMIO register.
2638 @return The value written the MMIO register.
2648 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioWrite64 (Address
, Value
));
2652 Reads a 64-bit MMIO register, performs a bitwise OR, and writes the
2653 result back to the 64-bit MMIO register and saves the value in the S3 script
2654 to be replayed on S3 resume.
2656 Reads the 64-bit MMIO register specified by Address, performs a bitwise
2657 inclusive OR between the read result and the value specified by OrData, and
2658 writes the result to the 64-bit MMIO register specified by Address. The value
2659 written to the MMIO register is returned. This function must guarantee that
2660 all MMIO read and write operations are serialized.
2662 If 64-bit MMIO register operations are not supported, then ASSERT().
2664 @param Address The MMIO register to write.
2665 @param OrData The value to OR with the read value from the MMIO register.
2667 @return The value written back to the MMIO register.
2677 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioOr64 (Address
, OrData
));
2681 Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result
2682 back to the 64-bit MMIO register and saves the value in the S3 script to be
2683 replayed on S3 resume.
2685 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2686 between the read result and the value specified by AndData, and writes the
2687 result to the 64-bit MMIO register specified by Address. The value written to
2688 the MMIO register is returned. This function must guarantee that all MMIO
2689 read and write operations are serialized.
2691 If 64-bit MMIO register operations are not supported, then ASSERT().
2693 @param Address The MMIO register to write.
2694 @param AndData The value to AND with the read value from the MMIO register.
2696 @return The value written back to the MMIO register.
2706 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioAnd64 (Address
, AndData
));
2710 Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise
2711 inclusive OR, and writes the result back to the 64-bit MMIO register and
2712 saves the value in the S3 script to be replayed on S3 resume.
2714 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2715 between the read result and the value specified by AndData, performs a
2716 bitwise OR between the result of the AND operation and the value specified by
2717 OrData, and writes the result to the 64-bit MMIO register specified by
2718 Address. The value written to the MMIO register is returned. This function
2719 must guarantee that all MMIO read and write operations are serialized.
2721 If 64-bit MMIO register operations are not supported, then ASSERT().
2723 @param Address The MMIO register to write.
2724 @param AndData The value to AND with the read value from the MMIO register.
2725 @param OrData The value to OR with the result of the AND operation.
2727 @return The value written back to the MMIO register.
2738 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioAndThenOr64 (Address
, AndData
, OrData
));
2742 Reads a bit field of a MMIO register saves the value in the S3 script to
2743 be replayed on S3 resume.
2745 Reads the bit field in a 64-bit MMIO register. The bit field is specified by
2746 the StartBit and the EndBit. The value of the bit field is returned.
2748 If 64-bit MMIO register operations are not supported, then ASSERT().
2749 If StartBit is greater than 63, then ASSERT().
2750 If EndBit is greater than 63, then ASSERT().
2751 If EndBit is less than StartBit, then ASSERT().
2753 @param Address MMIO register to read.
2754 @param StartBit The ordinal of the least significant bit in the bit field.
2756 @param EndBit The ordinal of the most significant bit in the bit field.
2759 @return The value read.
2764 S3MmioBitFieldRead64 (
2770 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldRead64 (Address
, StartBit
, EndBit
));
2774 Writes a bit field to a MMIO register and saves the value in the S3 script to
2775 be replayed on S3 resume.
2777 Writes Value to the bit field of the MMIO register. The bit field is
2778 specified by the StartBit and the EndBit. All other bits in the destination
2779 MMIO register are preserved. The new value of the 64-bit register is returned.
2781 If 64-bit MMIO register operations are not supported, then ASSERT().
2782 If StartBit is greater than 63, then ASSERT().
2783 If EndBit is greater than 63, then ASSERT().
2784 If EndBit is less than StartBit, then ASSERT().
2785 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2787 @param Address The MMIO register to write.
2788 @param StartBit The ordinal of the least significant bit in the bit field.
2790 @param EndBit The ordinal of the most significant bit in the bit field.
2792 @param Value New value of the bit field.
2794 @return The value written back to the MMIO register.
2799 S3MmioBitFieldWrite64 (
2806 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldWrite64 (Address
, StartBit
, EndBit
, Value
));
2810 Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and
2811 writes the result back to the bit field in the 64-bit MMIO register and
2812 saves the value in the S3 script to be replayed on S3 resume.
2814 Reads the 64-bit MMIO register specified by Address, performs a bitwise
2815 inclusive OR between the read result and the value specified by OrData, and
2816 writes the result to the 64-bit MMIO register specified by Address. The value
2817 written to the MMIO register is returned. This function must guarantee that
2818 all MMIO read and write operations are serialized. Extra left bits in OrData
2821 If 64-bit MMIO register operations are not supported, then ASSERT().
2822 If StartBit is greater than 63, then ASSERT().
2823 If EndBit is greater than 63, then ASSERT().
2824 If EndBit is less than StartBit, then ASSERT().
2825 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2827 @param Address The MMIO register to write.
2828 @param StartBit The ordinal of the least significant bit in the bit field.
2830 @param EndBit The ordinal of the most significant bit in the bit field.
2832 @param OrData The value to OR with the read value from the MMIO register.
2834 @return The value written back to the MMIO register.
2839 S3MmioBitFieldOr64 (
2846 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldOr64 (Address
, StartBit
, EndBit
, OrData
));
2850 Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and
2851 writes the result back to the bit field in the 64-bit MMIO register and saves
2852 the value in the S3 script to be replayed on S3 resume.
2854 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2855 between the read result and the value specified by AndData, and writes the
2856 result to the 64-bit MMIO register specified by Address. The value written to
2857 the MMIO register is returned. This function must guarantee that all MMIO
2858 read and write operations are serialized. Extra left bits in AndData are
2861 If 64-bit MMIO register operations are not supported, then ASSERT().
2862 If StartBit is greater than 63, then ASSERT().
2863 If EndBit is greater than 63, then ASSERT().
2864 If EndBit is less than StartBit, then ASSERT().
2865 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2867 @param Address The MMIO register to write.
2868 @param StartBit The ordinal of the least significant bit in the bit field.
2870 @param EndBit The ordinal of the most significant bit in the bit field.
2872 @param AndData The value to AND with the read value from the MMIO register.
2874 @return The value written back to the MMIO register.
2879 S3MmioBitFieldAnd64 (
2886 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldAnd64 (Address
, StartBit
, EndBit
, AndData
));
2890 Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed
2891 by a bitwise OR, and writes the result back to the bit field in the
2892 64-bit MMIO register and saves the value in the S3 script to be replayed
2895 Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
2896 followed by a bitwise OR between the read result and the value
2897 specified by AndData, and writes the result to the 64-bit MMIO register
2898 specified by Address. The value written to the MMIO register is returned.
2899 This function must guarantee that all MMIO read and write operations are
2900 serialized. Extra left bits in both AndData and OrData are stripped.
2902 If 64-bit MMIO register operations are not supported, then ASSERT().
2903 If StartBit is greater than 63, then ASSERT().
2904 If EndBit is greater than 63, then ASSERT().
2905 If EndBit is less than StartBit, then ASSERT().
2906 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2907 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2909 @param Address The MMIO register to write.
2910 @param StartBit The ordinal of the least significant bit in the bit field.
2912 @param EndBit The ordinal of the most significant bit in the bit field.
2914 @param AndData The value to AND with the read value from the MMIO register.
2915 @param OrData The value to OR with the result of the AND operation.
2917 @return The value written back to the MMIO register.
2922 S3MmioBitFieldAndThenOr64 (
2930 return InternalSaveMmioWrite64ValueToBootScript (Address
, MmioBitFieldAndThenOr64 (Address
, StartBit
, EndBit
, AndData
, OrData
));
2934 Copy data from MMIO region to system memory by using 8-bit access
2935 and saves the value in the S3 script to be replayed on S3 resume.
2937 Copy data from MMIO region specified by starting address StartAddress
2938 to system memory specified by Buffer by using 8-bit access. The total
2939 number of byte to be copied is specified by Length. Buffer is returned.
2941 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
2942 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2945 @param StartAddress Starting address for the MMIO region to be copied from.
2946 @param Length Size in bytes of the copy.
2947 @param Buffer Pointer to a system memory buffer receiving the data read.
2955 IN UINTN StartAddress
,
2960 UINT8
*ReturnBuffer
;
2961 RETURN_STATUS Status
;
2963 ReturnBuffer
= MmioReadBuffer8 (StartAddress
, Length
, Buffer
);
2965 Status
= S3BootScriptSaveMemWrite (
2966 S3BootScriptWidthUint8
,
2968 Length
/ sizeof (UINT8
),
2971 ASSERT (Status
== RETURN_SUCCESS
);
2973 return ReturnBuffer
;
2977 Copy data from MMIO region to system memory by using 16-bit access
2978 and saves the value in the S3 script to be replayed on S3 resume.
2980 Copy data from MMIO region specified by starting address StartAddress
2981 to system memory specified by Buffer by using 16-bit access. The total
2982 number of byte to be copied is specified by Length. Buffer is returned.
2984 If StartAddress is not aligned on a 16-bit boundary, then ASSERT().
2986 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
2987 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2989 If Length is not aligned on a 16-bit boundary, then ASSERT().
2990 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2992 @param StartAddress Starting address for the MMIO region to be copied from.
2993 @param Length Size in bytes of the copy.
2994 @param Buffer Pointer to a system memory buffer receiving the data read.
3001 S3MmioReadBuffer16 (
3002 IN UINTN StartAddress
,
3007 UINT16
*ReturnBuffer
;
3008 RETURN_STATUS Status
;
3010 ReturnBuffer
= MmioReadBuffer16 (StartAddress
, Length
, Buffer
);
3012 Status
= S3BootScriptSaveMemWrite (
3013 S3BootScriptWidthUint16
,
3015 Length
/ sizeof (UINT16
),
3018 ASSERT (Status
== RETURN_SUCCESS
);
3020 return ReturnBuffer
;
3024 Copy data from MMIO region to system memory by using 32-bit access
3025 and saves the value in the S3 script to be replayed on S3 resume.
3027 Copy data from MMIO region specified by starting address StartAddress
3028 to system memory specified by Buffer by using 32-bit access. The total
3029 number of byte to be copied is specified by Length. Buffer is returned.
3031 If StartAddress is not aligned on a 32-bit boundary, then ASSERT().
3033 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3034 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3036 If Length is not aligned on a 32-bit boundary, then ASSERT().
3037 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3039 @param StartAddress Starting address for the MMIO region to be copied from.
3040 @param Length Size in bytes of the copy.
3041 @param Buffer Pointer to a system memory buffer receiving the data read.
3048 S3MmioReadBuffer32 (
3049 IN UINTN StartAddress
,
3054 UINT32
*ReturnBuffer
;
3055 RETURN_STATUS Status
;
3057 ReturnBuffer
= MmioReadBuffer32 (StartAddress
, Length
, Buffer
);
3059 Status
= S3BootScriptSaveMemWrite (
3060 S3BootScriptWidthUint32
,
3062 Length
/ sizeof (UINT32
),
3065 ASSERT (Status
== RETURN_SUCCESS
);
3067 return ReturnBuffer
;
3071 Copy data from MMIO region to system memory by using 64-bit access
3072 and saves the value in the S3 script to be replayed on S3 resume.
3074 Copy data from MMIO region specified by starting address StartAddress
3075 to system memory specified by Buffer by using 64-bit access. The total
3076 number of byte to be copied is specified by Length. Buffer is returned.
3078 If StartAddress is not aligned on a 64-bit boundary, then ASSERT().
3080 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3081 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3083 If Length is not aligned on a 64-bit boundary, then ASSERT().
3084 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3086 @param StartAddress Starting address for the MMIO region to be copied from.
3087 @param Length Size in bytes of the copy.
3088 @param Buffer Pointer to a system memory buffer receiving the data read.
3095 S3MmioReadBuffer64 (
3096 IN UINTN StartAddress
,
3101 UINT64
*ReturnBuffer
;
3102 RETURN_STATUS Status
;
3104 ReturnBuffer
= MmioReadBuffer64 (StartAddress
, Length
, Buffer
);
3106 Status
= S3BootScriptSaveMemWrite (
3107 S3BootScriptWidthUint64
,
3109 Length
/ sizeof (UINT64
),
3112 ASSERT (Status
== RETURN_SUCCESS
);
3114 return ReturnBuffer
;
3119 Copy data from system memory to MMIO region by using 8-bit access
3120 and saves the value in the S3 script to be replayed on S3 resume.
3122 Copy data from system memory specified by Buffer to MMIO region specified
3123 by starting address StartAddress by using 8-bit access. The total number
3124 of byte to be copied is specified by Length. Buffer is returned.
3126 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3127 If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
3130 @param StartAddress Starting address for the MMIO region to be copied to.
3131 @param Length Size in bytes of the copy.
3132 @param Buffer Pointer to a system memory buffer containing the data to write.
3139 S3MmioWriteBuffer8 (
3140 IN UINTN StartAddress
,
3142 IN CONST UINT8
*Buffer
3145 UINT8
*ReturnBuffer
;
3146 RETURN_STATUS Status
;
3148 ReturnBuffer
= MmioWriteBuffer8 (StartAddress
, Length
, Buffer
);
3150 Status
= S3BootScriptSaveMemWrite (
3151 S3BootScriptWidthUint8
,
3153 Length
/ sizeof (UINT8
),
3156 ASSERT (Status
== RETURN_SUCCESS
);
3158 return ReturnBuffer
;
3162 Copy data from system memory to MMIO region by using 16-bit access
3163 and saves the value in the S3 script to be replayed on S3 resume.
3165 Copy data from system memory specified by Buffer to MMIO region specified
3166 by starting address StartAddress by using 16-bit access. The total number
3167 of byte to be copied is specified by Length. Buffer is returned.
3169 If StartAddress is not aligned on a 16-bit boundary, then ASSERT().
3171 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3172 If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
3174 If Length is not aligned on a 16-bit boundary, then ASSERT().
3176 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3178 @param StartAddress Starting address for the MMIO region to be copied to.
3179 @param Length Size in bytes of the copy.
3180 @param Buffer Pointer to a system memory buffer containing the data to write.
3187 S3MmioWriteBuffer16 (
3188 IN UINTN StartAddress
,
3190 IN CONST UINT16
*Buffer
3193 UINT16
*ReturnBuffer
;
3194 RETURN_STATUS Status
;
3196 ReturnBuffer
= MmioWriteBuffer16 (StartAddress
, Length
, Buffer
);
3198 Status
= S3BootScriptSaveMemWrite (
3199 S3BootScriptWidthUint16
,
3201 Length
/ sizeof (UINT16
),
3204 ASSERT (Status
== RETURN_SUCCESS
);
3206 return ReturnBuffer
;
3211 Copy data from system memory to MMIO region by using 32-bit access
3212 and saves the value in the S3 script to be replayed on S3 resume.
3214 Copy data from system memory specified by Buffer to MMIO region specified
3215 by starting address StartAddress by using 32-bit access. The total number
3216 of byte to be copied is specified by Length. Buffer is returned.
3218 If StartAddress is not aligned on a 32-bit boundary, then ASSERT().
3220 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3221 If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
3223 If Length is not aligned on a 32-bit boundary, then ASSERT().
3225 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3227 @param StartAddress Starting address for the MMIO region to be copied to.
3228 @param Length Size in bytes of the copy.
3229 @param Buffer Pointer to a system memory buffer containing the data to write.
3236 S3MmioWriteBuffer32 (
3237 IN UINTN StartAddress
,
3239 IN CONST UINT32
*Buffer
3242 UINT32
*ReturnBuffer
;
3243 RETURN_STATUS Status
;
3245 ReturnBuffer
= MmioWriteBuffer32 (StartAddress
, Length
, Buffer
);
3247 Status
= S3BootScriptSaveMemWrite (
3248 S3BootScriptWidthUint32
,
3250 Length
/ sizeof (UINT32
),
3253 ASSERT (Status
== RETURN_SUCCESS
);
3255 return ReturnBuffer
;
3259 Copy data from system memory to MMIO region by using 64-bit access
3260 and saves the value in the S3 script to be replayed on S3 resume.
3262 Copy data from system memory specified by Buffer to MMIO region specified
3263 by starting address StartAddress by using 64-bit access. The total number
3264 of byte to be copied is specified by Length. Buffer is returned.
3266 If StartAddress is not aligned on a 64-bit boundary, then ASSERT().
3268 If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
3269 If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
3271 If Length is not aligned on a 64-bit boundary, then ASSERT().
3273 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3275 @param StartAddress Starting address for the MMIO region to be copied to.
3276 @param Length Size in bytes of the copy.
3277 @param Buffer Pointer to a system memory buffer containing the data to write.
3284 S3MmioWriteBuffer64 (
3285 IN UINTN StartAddress
,
3287 IN CONST UINT64
*Buffer
3290 UINT64
*ReturnBuffer
;
3291 RETURN_STATUS Status
;
3293 ReturnBuffer
= MmioWriteBuffer64 (StartAddress
, Length
, Buffer
);
3295 Status
= S3BootScriptSaveMemWrite (
3296 S3BootScriptWidthUint64
,
3298 Length
/ sizeof (UINT64
),
3301 ASSERT (Status
== RETURN_SUCCESS
);
3303 return ReturnBuffer
;