2 PCI configuration Library Services that do PCI configuration and also enable
3 the PCI operations to be replayed during an S3 resume. This library class
4 maps directly on top of the PciLib class.
6 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/DebugLib.h>
15 #include <Library/S3BootScriptLib.h>
16 #include <Library/PciLib.h>
17 #include <Library/S3PciLib.h>
19 #define PCILIB_TO_COMMON_ADDRESS(Address) \
20 ((((UINTN) ((Address>>20) & 0xff)) << 24) + (((UINTN) ((Address>>15) & 0x1f)) << 16) + (((UINTN) ((Address>>12) & 0x07)) << 8) + ((UINTN) (Address & 0xfff )))
23 Saves a PCI configuration value to the boot script.
25 This internal worker function saves a PCI configuration value in
26 the S3 script to be replayed on S3 resume.
28 If the saving process fails, then ASSERT().
30 @param Width The width of PCI configuration.
31 @param Address Address that encodes the PCI Bus, Device, Function and
33 @param Buffer The buffer containing value.
37 InternalSavePciWriteValueToBootScript (
38 IN S3_BOOT_SCRIPT_LIB_WIDTH Width
,
45 Status
= S3BootScriptSavePciCfgWrite (
47 PCILIB_TO_COMMON_ADDRESS (Address
),
51 ASSERT (Status
== RETURN_SUCCESS
);
55 Saves an 8-bit PCI configuration value to the boot script.
57 This internal worker function saves an 8-bit PCI configuration value in
58 the S3 script to be replayed on S3 resume.
60 If the saving process fails, then ASSERT().
62 @param Address Address that encodes the PCI Bus, Device, Function and
64 @param Value The value saved to boot script.
70 InternalSavePciWrite8ValueToBootScript (
75 InternalSavePciWriteValueToBootScript (S3BootScriptWidthUint8
, Address
, &Value
);
81 Reads an 8-bit PCI configuration register and saves the value in the S3
82 script to be replayed on S3 resume.
84 Reads and returns the 8-bit PCI configuration register specified by Address.
85 This function must guarantee that all PCI read and write operations are
88 If Address > 0x0FFFFFFF, then ASSERT().
90 @param Address Address that encodes the PCI Bus, Device, Function and
93 @return The read value from the PCI configuration register.
102 return InternalSavePciWrite8ValueToBootScript (Address
, PciRead8 (Address
));
106 Writes an 8-bit PCI configuration register and saves the value in the S3
107 script to be replayed on S3 resume.
109 Writes the 8-bit PCI configuration register specified by Address with the
110 value specified by Value. Value is returned. This function must guarantee
111 that all PCI read and write operations are serialized.
113 If Address > 0x0FFFFFFF, then ASSERT().
115 @param Address Address that encodes the PCI Bus, Device, Function and
117 @param Value The value to write.
119 @return The value written to the PCI configuration register.
129 return InternalSavePciWrite8ValueToBootScript (Address
, PciWrite8 (Address
, Value
));
133 Performs a bitwise OR of an 8-bit PCI configuration register with
134 an 8-bit value and saves the value in the S3 script to be replayed on S3 resume.
136 Reads the 8-bit PCI configuration register specified by Address, performs a
137 bitwise OR between the read result and the value specified by
138 OrData, and writes the result to the 8-bit PCI configuration register
139 specified by Address. The value written to the PCI configuration register is
140 returned. This function must guarantee that all PCI read and write operations
143 If Address > 0x0FFFFFFF, then ASSERT().
145 @param Address Address that encodes the PCI Bus, Device, Function and
147 @param OrData The value to OR with the PCI configuration register.
149 @return The value written back to the PCI configuration register.
159 return InternalSavePciWrite8ValueToBootScript (Address
, PciOr8 (Address
, OrData
));
163 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
164 value and saves the value in the S3 script to be replayed on S3 resume.
166 Reads the 8-bit PCI configuration register specified by Address, performs a
167 bitwise AND between the read result and the value specified by AndData, and
168 writes the result to the 8-bit PCI configuration register specified by
169 Address. The value written to the PCI configuration register is returned.
170 This function must guarantee that all PCI read and write operations are
173 If Address > 0x0FFFFFFF, then ASSERT().
175 @param Address Address that encodes the PCI Bus, Device, Function and
177 @param AndData The value to AND with the PCI configuration register.
179 @return The value written back to the PCI configuration register.
189 return InternalSavePciWrite8ValueToBootScript (Address
, PciAnd8 (Address
, AndData
));
193 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
194 value, followed a bitwise OR with another 8-bit value and saves
195 the value in the S3 script to be replayed on S3 resume.
197 Reads the 8-bit PCI configuration register specified by Address, performs a
198 bitwise AND between the read result and the value specified by AndData,
199 performs a bitwise OR between the result of the AND operation and
200 the value specified by OrData, and writes the result to the 8-bit PCI
201 configuration register specified by Address. The value written to the PCI
202 configuration register is returned. This function must guarantee that all PCI
203 read and write operations are serialized.
205 If Address > 0x0FFFFFFF, then ASSERT().
207 @param Address Address that encodes the PCI Bus, Device, Function and
209 @param AndData The value to AND with the PCI configuration register.
210 @param OrData The value to OR with the result of the AND operation.
212 @return The value written back to the PCI configuration register.
223 return InternalSavePciWrite8ValueToBootScript (Address
, PciAndThenOr8 (Address
, AndData
, OrData
));
227 Reads a bit field of a PCI configuration register and saves the value in
228 the S3 script to be replayed on S3 resume.
230 Reads the bit field in an 8-bit PCI configuration register. The bit field is
231 specified by the StartBit and the EndBit. The value of the bit field is
234 If Address > 0x0FFFFFFF, then ASSERT().
235 If StartBit is greater than 7, then ASSERT().
236 If EndBit is greater than 7, then ASSERT().
237 If EndBit is less than StartBit, then ASSERT().
239 @param Address PCI configuration register to read.
240 @param StartBit The ordinal of the least significant bit in the bit field.
242 @param EndBit The ordinal of the most significant bit in the bit field.
245 @return The value of the bit field read from the PCI configuration register.
256 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldRead8 (Address
, StartBit
, EndBit
));
260 Writes a bit field to a PCI configuration register and saves the value in
261 the S3 script to be replayed on S3 resume.
263 Writes Value to the bit field of the PCI configuration register. The bit
264 field is specified by the StartBit and the EndBit. All other bits in the
265 destination PCI configuration register are preserved. The new value of the
266 8-bit register is returned.
268 If Address > 0x0FFFFFFF, then ASSERT().
269 If StartBit is greater than 7, then ASSERT().
270 If EndBit is greater than 7, then ASSERT().
271 If EndBit is less than StartBit, then ASSERT().
272 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
274 @param Address PCI configuration register to write.
275 @param StartBit The ordinal of the least significant bit in the bit field.
277 @param EndBit The ordinal of the most significant bit in the bit field.
279 @param Value New value of the bit field.
281 @return The value written back to the PCI configuration register.
286 S3PciBitFieldWrite8 (
293 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldWrite8 (Address
, StartBit
, EndBit
, Value
));
297 Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
298 writes the result back to the bit field in the 8-bit port and saves the value
299 in the S3 script to be replayed on S3 resume.
301 Reads the 8-bit PCI configuration register specified by Address, performs a
302 bitwise OR between the read result and the value specified by
303 OrData, and writes the result to the 8-bit PCI configuration register
304 specified by Address. The value written to the PCI configuration register is
305 returned. This function must guarantee that all PCI read and write operations
306 are serialized. Extra left bits in OrData are stripped.
308 If Address > 0x0FFFFFFF, then ASSERT().
309 If StartBit is greater than 7, then ASSERT().
310 If EndBit is greater than 7, then ASSERT().
311 If EndBit is less than StartBit, then ASSERT().
312 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
314 @param Address PCI configuration register to write.
315 @param StartBit The ordinal of the least significant bit in the bit field.
317 @param EndBit The ordinal of the most significant bit in the bit field.
319 @param OrData The value to OR with the PCI configuration register.
321 @return The value written back to the PCI configuration register.
333 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldOr8 (Address
, StartBit
, EndBit
, OrData
));
337 Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
338 AND, and writes the result back to the bit field in the 8-bit register and
339 saves the value in the S3 script to be replayed on S3 resume.
341 Reads the 8-bit PCI configuration register specified by Address, performs a
342 bitwise AND between the read result and the value specified by AndData, and
343 writes the result to the 8-bit PCI configuration register specified by
344 Address. The value written to the PCI configuration register is returned.
345 This function must guarantee that all PCI read and write operations are
346 serialized. Extra left bits in AndData are stripped.
348 If Address > 0x0FFFFFFF, then ASSERT().
349 If StartBit is greater than 7, then ASSERT().
350 If EndBit is greater than 7, then ASSERT().
351 If EndBit is less than StartBit, then ASSERT().
352 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
354 @param Address PCI configuration register to write.
355 @param StartBit The ordinal of the least significant bit in the bit field.
357 @param EndBit The ordinal of the most significant bit in the bit field.
359 @param AndData The value to AND with the PCI configuration register.
361 @return The value written back to the PCI configuration register.
373 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldAnd8 (Address
, StartBit
, EndBit
, AndData
));
377 Reads a bit field in an 8-bit Address, performs a bitwise AND followed by a
378 bitwise OR, and writes the result back to the bit field in the
379 8-bit port and saves the value in the S3 script to be replayed on S3 resume.
381 Reads the 8-bit PCI configuration register specified by Address, performs a
382 bitwise AND followed by a bitwise OR between the read result and
383 the value specified by AndData, and writes the result to the 8-bit PCI
384 configuration register specified by Address. The value written to the PCI
385 configuration register is returned. This function must guarantee that all PCI
386 read and write operations are serialized. Extra left bits in both AndData and
389 If Address > 0x0FFFFFFF, then ASSERT().
390 If StartBit is greater than 7, then ASSERT().
391 If EndBit is greater than 7, then ASSERT().
392 If EndBit is less than StartBit, then ASSERT().
393 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
394 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
396 @param Address PCI configuration register to write.
397 @param StartBit The ordinal of the least significant bit in the bit field.
399 @param EndBit The ordinal of the most significant bit in the bit field.
401 @param AndData The value to AND with the PCI configuration register.
402 @param OrData The value to OR with the result of the AND operation.
404 @return The value written back to the PCI configuration register.
409 S3PciBitFieldAndThenOr8 (
417 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldAndThenOr8 (Address
, StartBit
, EndBit
, AndData
, OrData
));
421 Saves a 16-bit PCI configuration value to the boot script.
423 This internal worker function saves a 16-bit PCI configuration value in
424 the S3 script to be replayed on S3 resume.
426 If the saving process fails, then ASSERT().
428 @param Address Address that encodes the PCI Bus, Device, Function and
430 @param Value The value to write.
436 InternalSavePciWrite16ValueToBootScript (
441 InternalSavePciWriteValueToBootScript (S3BootScriptWidthUint16
, Address
, &Value
);
447 Reads a 16-bit PCI configuration register and saves the value in the S3
448 script to be replayed on S3 resume.
450 Reads and returns the 16-bit PCI configuration register specified by Address.
451 This function must guarantee that all PCI read and write operations are
454 If Address > 0x0FFFFFFF, then ASSERT().
455 If Address is not aligned on a 16-bit boundary, then ASSERT().
457 @param Address Address that encodes the PCI Bus, Device, Function and
460 @return The read value from the PCI configuration register.
469 return InternalSavePciWrite16ValueToBootScript (Address
, PciRead16 (Address
));
473 Writes a 16-bit PCI configuration register and saves the value in the S3
474 script to be replayed on S3 resume.
476 Writes the 16-bit PCI configuration register specified by Address with the
477 value specified by Value. Value is returned. This function must guarantee
478 that all PCI read and write operations are serialized.
480 If Address > 0x0FFFFFFF, then ASSERT().
481 If Address is not aligned on a 16-bit boundary, then ASSERT().
483 @param Address Address that encodes the PCI Bus, Device, Function and
485 @param Value The value to write.
487 @return The value written to the PCI configuration register.
497 return InternalSavePciWrite16ValueToBootScript (Address
, PciWrite16 (Address
, Value
));
501 Performs a bitwise OR of a 16-bit PCI configuration register with
502 a 16-bit value and saves the value in the S3 script to be replayed on S3 resume.
504 Reads the 16-bit PCI configuration register specified by Address, performs a
505 bitwise OR between the read result and the value specified by
506 OrData, and writes the result to the 16-bit PCI configuration register
507 specified by Address. The value written to the PCI configuration register is
508 returned. This function must guarantee that all PCI read and write operations
511 If Address > 0x0FFFFFFF, then ASSERT().
512 If Address is not aligned on a 16-bit boundary, then ASSERT().
514 @param Address Address that encodes the PCI Bus, Device, Function and
516 @param OrData The value to OR with the PCI configuration register.
518 @return The value written back to the PCI configuration register.
528 return InternalSavePciWrite16ValueToBootScript (Address
, PciOr16 (Address
, OrData
));
532 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
533 value and saves the value in the S3 script to be replayed on S3 resume.
535 Reads the 16-bit PCI configuration register specified by Address, performs a
536 bitwise AND between the read result and the value specified by AndData, and
537 writes the result to the 16-bit PCI configuration register specified by
538 Address. The value written to the PCI configuration register is returned.
539 This function must guarantee that all PCI read and write operations are
542 If Address > 0x0FFFFFFF, then ASSERT().
543 If Address is not aligned on a 16-bit boundary, then ASSERT().
545 @param Address Address that encodes the PCI Bus, Device, Function and
547 @param AndData The value to AND with the PCI configuration register.
549 @return The value written back to the PCI configuration register.
559 return InternalSavePciWrite16ValueToBootScript (Address
, PciAnd16 (Address
, AndData
));
563 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
564 value, followed a bitwise OR with another 16-bit value and saves
565 the value in the S3 script to be replayed on S3 resume.
567 Reads the 16-bit PCI configuration register specified by Address, performs a
568 bitwise AND between the read result and the value specified by AndData,
569 performs a bitwise OR between the result of the AND operation and
570 the value specified by OrData, and writes the result to the 16-bit PCI
571 configuration register specified by Address. The value written to the PCI
572 configuration register is returned. This function must guarantee that all PCI
573 read and write operations are serialized.
575 If Address > 0x0FFFFFFF, then ASSERT().
576 If Address is not aligned on a 16-bit boundary, then ASSERT().
578 @param Address Address that encodes the PCI Bus, Device, Function and
580 @param AndData The value to AND with the PCI configuration register.
581 @param OrData The value to OR with the result of the AND operation.
583 @return The value written back to the PCI configuration register.
594 return InternalSavePciWrite16ValueToBootScript (Address
, PciAndThenOr16 (Address
, AndData
, OrData
));
598 Reads a bit field of a PCI configuration register and saves the value in
599 the S3 script to be replayed on S3 resume.
601 Reads the bit field in a 16-bit PCI configuration register. The bit field is
602 specified by the StartBit and the EndBit. The value of the bit field is
605 If Address > 0x0FFFFFFF, then ASSERT().
606 If Address is not aligned on a 16-bit boundary, then ASSERT().
607 If StartBit is greater than 15, then ASSERT().
608 If EndBit is greater than 15, then ASSERT().
609 If EndBit is less than StartBit, then ASSERT().
611 @param Address PCI configuration register to read.
612 @param StartBit The ordinal of the least significant bit in the bit field.
614 @param EndBit The ordinal of the most significant bit in the bit field.
617 @return The value of the bit field read from the PCI configuration register.
622 S3PciBitFieldRead16 (
628 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldRead16 (Address
, StartBit
, EndBit
));
632 Writes a bit field to a PCI configuration register and saves the value in
633 the S3 script to be replayed on S3 resume.
635 Writes Value to the bit field of the PCI configuration register. The bit
636 field is specified by the StartBit and the EndBit. All other bits in the
637 destination PCI configuration register are preserved. The new value of the
638 16-bit register is returned.
640 If Address > 0x0FFFFFFF, then ASSERT().
641 If Address is not aligned on a 16-bit boundary, then ASSERT().
642 If StartBit is greater than 15, then ASSERT().
643 If EndBit is greater than 15, then ASSERT().
644 If EndBit is less than StartBit, then ASSERT().
645 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
647 @param Address PCI configuration register to write.
648 @param StartBit The ordinal of the least significant bit in the bit field.
650 @param EndBit The ordinal of the most significant bit in the bit field.
652 @param Value New value of the bit field.
654 @return The value written back to the PCI configuration register.
659 S3PciBitFieldWrite16 (
666 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldWrite16 (Address
, StartBit
, EndBit
, Value
));
670 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
671 writes the result back to the bit field in the 16-bit port and saves the value
672 in the S3 script to be replayed on S3 resume.
674 Reads the 16-bit PCI configuration register specified by Address, performs a
675 bitwise OR between the read result and the value specified by
676 OrData, and writes the result to the 16-bit PCI configuration register
677 specified by Address. The value written to the PCI configuration register is
678 returned. This function must guarantee that all PCI read and write operations
679 are serialized. Extra left bits in OrData are stripped.
681 If Address > 0x0FFFFFFF, then ASSERT().
682 If Address is not aligned on a 16-bit boundary, then ASSERT().
683 If StartBit is greater than 15, then ASSERT().
684 If EndBit is greater than 15, then ASSERT().
685 If EndBit is less than StartBit, then ASSERT().
686 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
688 @param Address PCI configuration register to write.
689 @param StartBit The ordinal of the least significant bit in the bit field.
691 @param EndBit The ordinal of the most significant bit in the bit field.
693 @param OrData The value to OR with the PCI configuration register.
695 @return The value written back to the PCI configuration register.
707 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldOr16 (Address
, StartBit
, EndBit
, OrData
));
711 Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
712 AND, and writes the result back to the bit field in the 16-bit register and
713 saves the value in the S3 script to be replayed on S3 resume.
715 Reads the 16-bit PCI configuration register specified by Address, performs a
716 bitwise AND between the read result and the value specified by AndData, and
717 writes the result to the 16-bit PCI configuration register specified by
718 Address. The value written to the PCI configuration register is returned.
719 This function must guarantee that all PCI read and write operations are
720 serialized. Extra left bits in AndData are stripped.
722 If Address > 0x0FFFFFFF, then ASSERT().
723 If Address is not aligned on a 16-bit boundary, then ASSERT().
724 If StartBit is greater than 15, then ASSERT().
725 If EndBit is greater than 15, then ASSERT().
726 If EndBit is less than StartBit, then ASSERT().
727 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
729 @param Address PCI configuration register to write.
730 @param StartBit The ordinal of the least significant bit in the bit field.
732 @param EndBit The ordinal of the most significant bit in the bit field.
734 @param AndData The value to AND with the PCI configuration register.
736 @return The value written back to the PCI configuration register.
748 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldAnd16 (Address
, StartBit
, EndBit
, AndData
));
752 Reads a bit field in a 16-bit Address, performs a bitwise AND followed by a
753 bitwise OR, and writes the result back to the bit field in the
754 16-bit port and saves the value in the S3 script to be replayed on S3 resume.
756 Reads the 16-bit PCI configuration register specified by Address, performs a
757 bitwise AND followed by a bitwise OR between the read result and
758 the value specified by AndData, and writes the result to the 16-bit PCI
759 configuration register specified by Address. The value written to the PCI
760 configuration register is returned. This function must guarantee that all PCI
761 read and write operations are serialized. Extra left bits in both AndData and
764 If Address > 0x0FFFFFFF, then ASSERT().
765 If Address is not aligned on a 16-bit boundary, then ASSERT().
766 If StartBit is greater than 15, then ASSERT().
767 If EndBit is greater than 15, then ASSERT().
768 If EndBit is less than StartBit, then ASSERT().
769 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
770 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
772 @param Address PCI configuration register to write.
773 @param StartBit The ordinal of the least significant bit in the bit field.
775 @param EndBit The ordinal of the most significant bit in the bit field.
777 @param AndData The value to AND with the PCI configuration register.
778 @param OrData The value to OR with the result of the AND operation.
780 @return The value written back to the PCI configuration register.
785 S3PciBitFieldAndThenOr16 (
793 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldAndThenOr16 (Address
, StartBit
, EndBit
, AndData
, OrData
));
797 Saves a 32-bit PCI configuration value to the boot script.
799 This internal worker function saves a 32-bit PCI configuration value in the S3 script
800 to be replayed on S3 resume.
802 If the saving process fails, then ASSERT().
804 @param Address Address that encodes the PCI Bus, Device, Function and
806 @param Value The value to write.
812 InternalSavePciWrite32ValueToBootScript (
817 InternalSavePciWriteValueToBootScript (S3BootScriptWidthUint32
, Address
, &Value
);
823 Reads a 32-bit PCI configuration register and saves the value in the S3
824 script to be replayed on S3 resume.
826 Reads and returns the 32-bit PCI configuration register specified by Address.
827 This function must guarantee that all PCI read and write operations are
830 If Address > 0x0FFFFFFF, then ASSERT().
831 If Address is not aligned on a 32-bit boundary, then ASSERT().
833 @param Address Address that encodes the PCI Bus, Device, Function and
836 @return The read value from the PCI configuration register.
845 return InternalSavePciWrite32ValueToBootScript (Address
, PciRead32 (Address
));
849 Writes a 32-bit PCI configuration register and saves the value in the S3
850 script to be replayed on S3 resume.
852 Writes the 32-bit PCI configuration register specified by Address with the
853 value specified by Value. Value is returned. This function must guarantee
854 that all PCI read and write operations are serialized.
856 If Address > 0x0FFFFFFF, then ASSERT().
857 If Address is not aligned on a 32-bit boundary, then ASSERT().
859 @param Address Address that encodes the PCI Bus, Device, Function and
861 @param Value The value to write.
863 @return The value written to the PCI configuration register.
873 return InternalSavePciWrite32ValueToBootScript (Address
, PciWrite32 (Address
, Value
));
877 Performs a bitwise OR of a 32-bit PCI configuration register with
878 a 32-bit value and saves the value in the S3 script to be replayed on S3 resume.
880 Reads the 32-bit PCI configuration register specified by Address, performs a
881 bitwise OR between the read result and the value specified by
882 OrData, and writes the result to the 32-bit PCI configuration register
883 specified by Address. The value written to the PCI configuration register is
884 returned. This function must guarantee that all PCI read and write operations
887 If Address > 0x0FFFFFFF, then ASSERT().
888 If Address is not aligned on a 32-bit boundary, then ASSERT().
890 @param Address Address that encodes the PCI Bus, Device, Function and
892 @param OrData The value to OR with the PCI configuration register.
894 @return The value written back to the PCI configuration register.
904 return InternalSavePciWrite32ValueToBootScript (Address
, PciOr32 (Address
, OrData
));
908 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
909 value and saves the value in the S3 script to be replayed on S3 resume.
911 Reads the 32-bit PCI configuration register specified by Address, performs a
912 bitwise AND between the read result and the value specified by AndData, and
913 writes the result to the 32-bit PCI configuration register specified by
914 Address. The value written to the PCI configuration register is returned.
915 This function must guarantee that all PCI read and write operations are
918 If Address > 0x0FFFFFFF, then ASSERT().
919 If Address is not aligned on a 32-bit boundary, then ASSERT().
921 @param Address Address that encodes the PCI Bus, Device, Function and
923 @param AndData The value to AND with the PCI configuration register.
925 @return The value written back to the PCI configuration register.
935 return InternalSavePciWrite32ValueToBootScript (Address
, PciAnd32 (Address
, AndData
));
939 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
940 value, followed a bitwise OR with another 32-bit value and saves
941 the value in the S3 script to be replayed on S3 resume.
943 Reads the 32-bit PCI configuration register specified by Address, performs a
944 bitwise AND between the read result and the value specified by AndData,
945 performs a bitwise OR between the result of the AND operation and
946 the value specified by OrData, and writes the result to the 32-bit PCI
947 configuration register specified by Address. The value written to the PCI
948 configuration register is returned. This function must guarantee that all PCI
949 read and write operations are serialized.
951 If Address > 0x0FFFFFFF, then ASSERT().
952 If Address is not aligned on a 32-bit boundary, then ASSERT().
954 @param Address Address that encodes the PCI Bus, Device, Function and
956 @param AndData The value to AND with the PCI configuration register.
957 @param OrData The value to OR with the result of the AND operation.
959 @return The value written back to the PCI configuration register.
970 return InternalSavePciWrite32ValueToBootScript (Address
, PciAndThenOr32 (Address
, AndData
, OrData
));
974 Reads a bit field of a PCI configuration register and saves the value in
975 the S3 script to be replayed on S3 resume.
977 Reads the bit field in a 32-bit PCI configuration register. The bit field is
978 specified by the StartBit and the EndBit. The value of the bit field is
981 If Address > 0x0FFFFFFF, then ASSERT().
982 If Address is not aligned on a 32-bit boundary, then ASSERT().
983 If StartBit is greater than 31, then ASSERT().
984 If EndBit is greater than 31, then ASSERT().
985 If EndBit is less than StartBit, then ASSERT().
987 @param Address PCI configuration register to read.
988 @param StartBit The ordinal of the least significant bit in the bit field.
990 @param EndBit The ordinal of the most significant bit in the bit field.
993 @return The value of the bit field read from the PCI configuration register.
998 S3PciBitFieldRead32 (
1004 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldRead32 (Address
, StartBit
, EndBit
));
1008 Writes a bit field to a PCI configuration register and saves the value in
1009 the S3 script to be replayed on S3 resume.
1011 Writes Value to the bit field of the PCI configuration register. The bit
1012 field is specified by the StartBit and the EndBit. All other bits in the
1013 destination PCI configuration register are preserved. The new value of the
1014 32-bit register is returned.
1016 If Address > 0x0FFFFFFF, then ASSERT().
1017 If Address is not aligned on a 32-bit boundary, then ASSERT().
1018 If StartBit is greater than 31, then ASSERT().
1019 If EndBit is greater than 31, then ASSERT().
1020 If EndBit is less than StartBit, then ASSERT().
1021 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1023 @param Address PCI configuration register to write.
1024 @param StartBit The ordinal of the least significant bit in the bit field.
1026 @param EndBit The ordinal of the most significant bit in the bit field.
1028 @param Value New value of the bit field.
1030 @return The value written back to the PCI configuration register.
1035 S3PciBitFieldWrite32 (
1042 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldWrite32 (Address
, StartBit
, EndBit
, Value
));
1046 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
1047 writes the result back to the bit field in the 32-bit port and saves the value
1048 in the S3 script to be replayed on S3 resume.
1050 Reads the 32-bit PCI configuration register specified by Address, performs a
1051 bitwise OR between the read result and the value specified by
1052 OrData, and writes the result to the 32-bit PCI configuration register
1053 specified by Address. The value written to the PCI configuration register is
1054 returned. This function must guarantee that all PCI read and write operations
1055 are serialized. Extra left bits in OrData are stripped.
1057 If Address > 0x0FFFFFFF, then ASSERT().
1058 If Address is not aligned on a 32-bit boundary, then ASSERT().
1059 If StartBit is greater than 31, then ASSERT().
1060 If EndBit is greater than 31, then ASSERT().
1061 If EndBit is less than StartBit, then ASSERT().
1062 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1064 @param Address PCI configuration register to write.
1065 @param StartBit The ordinal of the least significant bit in the bit field.
1067 @param EndBit The ordinal of the most significant bit in the bit field.
1069 @param OrData The value to OR with the PCI configuration register.
1071 @return The value written back to the PCI configuration register.
1083 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldOr32 (Address
, StartBit
, EndBit
, OrData
));
1087 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
1088 AND, and writes the result back to the bit field in the 32-bit register and
1089 saves the value in the S3 script to be replayed on S3 resume.
1091 Reads the 32-bit PCI configuration register specified by Address, performs a
1092 bitwise AND between the read result and the value specified by AndData, and
1093 writes the result to the 32-bit PCI configuration register specified by
1094 Address. The value written to the PCI configuration register is returned.
1095 This function must guarantee that all PCI read and write operations are
1096 serialized. Extra left bits in AndData are stripped.
1098 If Address > 0x0FFFFFFF, then ASSERT().
1099 If Address is not aligned on a 32-bit boundary, then ASSERT().
1100 If StartBit is greater than 31, then ASSERT().
1101 If EndBit is greater than 31, then ASSERT().
1102 If EndBit is less than StartBit, then ASSERT().
1103 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1105 @param Address PCI configuration register to write.
1106 @param StartBit The ordinal of the least significant bit in the bit field.
1108 @param EndBit The ordinal of the most significant bit in the bit field.
1110 @param AndData The value to AND with the PCI configuration register.
1112 @return The value written back to the PCI configuration register.
1117 S3PciBitFieldAnd32 (
1124 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldAnd32 (Address
, StartBit
, EndBit
, AndData
));
1128 Reads a bit field in a 32-bit Address, performs a bitwise AND followed by a
1129 bitwise OR, and writes the result back to the bit field in the
1130 32-bit port and saves the value in the S3 script to be replayed on S3 resume.
1132 Reads the 32-bit PCI configuration register specified by Address, performs a
1133 bitwise AND followed by a bitwise OR between the read result and
1134 the value specified by AndData, and writes the result to the 32-bit PCI
1135 configuration register specified by Address. The value written to the PCI
1136 configuration register is returned. This function must guarantee that all PCI
1137 read and write operations are serialized. Extra left bits in both AndData and
1138 OrData are stripped.
1140 If Address > 0x0FFFFFFF, then ASSERT().
1141 If Address is not aligned on a 32-bit boundary, then ASSERT().
1142 If StartBit is greater than 31, then ASSERT().
1143 If EndBit is greater than 31, then ASSERT().
1144 If EndBit is less than StartBit, then ASSERT().
1145 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1146 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1148 @param Address PCI configuration register to write.
1149 @param StartBit The ordinal of the least significant bit in the bit field.
1151 @param EndBit The ordinal of the most significant bit in the bit field.
1153 @param AndData The value to AND with the PCI configuration register.
1154 @param OrData The value to OR with the result of the AND operation.
1156 @return The value written back to the PCI configuration register.
1161 S3PciBitFieldAndThenOr32 (
1169 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldAndThenOr32 (Address
, StartBit
, EndBit
, AndData
, OrData
));
1173 Reads a range of PCI configuration registers into a caller supplied buffer
1174 and saves the value in the S3 script to be replayed on S3 resume.
1176 Reads the range of PCI configuration registers specified by StartAddress and
1177 Size into the buffer specified by Buffer. This function only allows the PCI
1178 configuration registers from a single PCI function to be read. Size is
1179 returned. When possible 32-bit PCI configuration read cycles are used to read
1180 from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
1181 and 16-bit PCI configuration read cycles may be used at the beginning and the
1184 If StartAddress > 0x0FFFFFFF, then ASSERT().
1185 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1186 If Size > 0 and Buffer is NULL, then ASSERT().
1188 @param StartAddress Starting address that encodes the PCI Bus, Device,
1189 Function and Register.
1190 @param Size Size in bytes of the transfer.
1191 @param Buffer Pointer to a buffer receiving the data read.
1199 IN UINTN StartAddress
,
1204 RETURN_STATUS Status
;
1206 Status
= S3BootScriptSavePciCfgWrite (
1207 S3BootScriptWidthUint8
,
1208 PCILIB_TO_COMMON_ADDRESS (StartAddress
),
1209 PciReadBuffer (StartAddress
, Size
, Buffer
),
1212 ASSERT (Status
== RETURN_SUCCESS
);
1218 Copies the data in a caller supplied buffer to a specified range of PCI
1219 configuration space and saves the value in the S3 script to be replayed on S3
1222 Writes the range of PCI configuration registers specified by StartAddress and
1223 Size from the buffer specified by Buffer. This function only allows the PCI
1224 configuration registers from a single PCI function to be written. Size is
1225 returned. When possible 32-bit PCI configuration write cycles are used to
1226 write from StartAdress to StartAddress + Size. Due to alignment restrictions,
1227 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
1228 and the end of the range.
1230 If StartAddress > 0x0FFFFFFF, then ASSERT().
1231 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1232 If Size > 0 and Buffer is NULL, then ASSERT().
1234 @param StartAddress Starting address that encodes the PCI Bus, Device,
1235 Function and Register.
1236 @param Size Size in bytes of the transfer.
1237 @param Buffer Pointer to a buffer containing the data to write.
1245 IN UINTN StartAddress
,
1250 RETURN_STATUS Status
;
1252 Status
= S3BootScriptSavePciCfgWrite (
1253 S3BootScriptWidthUint8
,
1254 PCILIB_TO_COMMON_ADDRESS (StartAddress
),
1255 PciWriteBuffer (StartAddress
, Size
, Buffer
),
1258 ASSERT (Status
== RETURN_SUCCESS
);