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
15 #include <Library/DebugLib.h>
16 #include <Library/S3BootScriptLib.h>
17 #include <Library/PciLib.h>
18 #include <Library/S3PciLib.h>
20 #define PCILIB_TO_COMMON_ADDRESS(Address) \
21 ((((UINTN) ((Address>>20) & 0xff)) << 24) + (((UINTN) ((Address>>15) & 0x1f)) << 16) + (((UINTN) ((Address>>12) & 0x07)) << 8) + ((UINTN) (Address & 0xfff )))
24 Saves a PCI configuration value to the boot script.
26 This internal worker function saves a PCI configuration value in
27 the S3 script to be replayed on S3 resume.
29 If the saving process fails, then ASSERT().
31 @param Width The width of PCI configuration.
32 @param Address Address that encodes the PCI Bus, Device, Function and
34 @param Buffer The buffer containing value.
38 InternalSavePciWriteValueToBootScript (
39 IN S3_BOOT_SCRIPT_LIB_WIDTH Width
,
46 Status
= S3BootScriptSavePciCfgWrite (
48 PCILIB_TO_COMMON_ADDRESS(Address
),
52 ASSERT (Status
== RETURN_SUCCESS
);
56 Saves an 8-bit PCI configuration value to the boot script.
58 This internal worker function saves an 8-bit PCI configuration value in
59 the S3 script to be replayed on S3 resume.
61 If the saving process fails, then ASSERT().
63 @param Address Address that encodes the PCI Bus, Device, Function and
65 @param Value The value saved to boot script.
71 InternalSavePciWrite8ValueToBootScript (
76 InternalSavePciWriteValueToBootScript (S3BootScriptWidthUint8
, Address
, &Value
);
82 Reads an 8-bit PCI configuration register and saves the value in the S3
83 script to be replayed on S3 resume.
85 Reads and returns the 8-bit PCI configuration register specified by Address.
86 This function must guarantee that all PCI read and write operations are
89 If Address > 0x0FFFFFFF, then ASSERT().
91 @param Address Address that encodes the PCI Bus, Device, Function and
94 @return The read value from the PCI configuration register.
103 return InternalSavePciWrite8ValueToBootScript (Address
, PciRead8 (Address
));
107 Writes an 8-bit PCI configuration register and saves the value in the S3
108 script to be replayed on S3 resume.
110 Writes the 8-bit PCI configuration register specified by Address with the
111 value specified by Value. Value is returned. This function must guarantee
112 that all PCI read and write operations are serialized.
114 If Address > 0x0FFFFFFF, then ASSERT().
116 @param Address Address that encodes the PCI Bus, Device, Function and
118 @param Value The value to write.
120 @return The value written to the PCI configuration register.
130 return InternalSavePciWrite8ValueToBootScript (Address
, PciWrite8 (Address
, Value
));
134 Performs a bitwise OR of an 8-bit PCI configuration register with
135 an 8-bit value and saves the value in the S3 script to be replayed on S3 resume.
137 Reads the 8-bit PCI configuration register specified by Address, performs a
138 bitwise OR between the read result and the value specified by
139 OrData, and writes the result to the 8-bit PCI configuration register
140 specified by Address. The value written to the PCI configuration register is
141 returned. This function must guarantee that all PCI read and write operations
144 If Address > 0x0FFFFFFF, then ASSERT().
146 @param Address Address that encodes the PCI Bus, Device, Function and
148 @param OrData The value to OR with the PCI configuration register.
150 @return The value written back to the PCI configuration register.
160 return InternalSavePciWrite8ValueToBootScript (Address
, PciOr8 (Address
, OrData
));
164 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
165 value and saves the value in the S3 script to be replayed on S3 resume.
167 Reads the 8-bit PCI configuration register specified by Address, performs a
168 bitwise AND between the read result and the value specified by AndData, and
169 writes the result to the 8-bit PCI configuration register specified by
170 Address. The value written to the PCI configuration register is returned.
171 This function must guarantee that all PCI read and write operations are
174 If Address > 0x0FFFFFFF, then ASSERT().
176 @param Address Address that encodes the PCI Bus, Device, Function and
178 @param AndData The value to AND with the PCI configuration register.
180 @return The value written back to the PCI configuration register.
190 return InternalSavePciWrite8ValueToBootScript (Address
, PciAnd8 (Address
, AndData
));
194 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
195 value, followed a bitwise OR with another 8-bit value and saves
196 the value in the S3 script to be replayed on S3 resume.
198 Reads the 8-bit PCI configuration register specified by Address, performs a
199 bitwise AND between the read result and the value specified by AndData,
200 performs a bitwise OR between the result of the AND operation and
201 the value specified by OrData, and writes the result to the 8-bit PCI
202 configuration register specified by Address. The value written to the PCI
203 configuration register is returned. This function must guarantee that all PCI
204 read and write operations are serialized.
206 If Address > 0x0FFFFFFF, then ASSERT().
208 @param Address Address that encodes the PCI Bus, Device, Function and
210 @param AndData The value to AND with the PCI configuration register.
211 @param OrData The value to OR with the result of the AND operation.
213 @return The value written back to the PCI configuration register.
224 return InternalSavePciWrite8ValueToBootScript (Address
, PciAndThenOr8 (Address
, AndData
, OrData
));
228 Reads a bit field of a PCI configuration register and saves the value in
229 the S3 script to be replayed on S3 resume.
231 Reads the bit field in an 8-bit PCI configuration register. The bit field is
232 specified by the StartBit and the EndBit. The value of the bit field is
235 If Address > 0x0FFFFFFF, then ASSERT().
236 If StartBit is greater than 7, then ASSERT().
237 If EndBit is greater than 7, then ASSERT().
238 If EndBit is less than StartBit, then ASSERT().
240 @param Address PCI configuration register to read.
241 @param StartBit The ordinal of the least significant bit in the bit field.
243 @param EndBit The ordinal of the most significant bit in the bit field.
246 @return The value of the bit field read from the PCI configuration register.
257 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldRead8 (Address
, StartBit
, EndBit
));
261 Writes a bit field to a PCI configuration register and saves the value in
262 the S3 script to be replayed on S3 resume.
264 Writes Value to the bit field of the PCI configuration register. The bit
265 field is specified by the StartBit and the EndBit. All other bits in the
266 destination PCI configuration register are preserved. The new value of the
267 8-bit register is returned.
269 If Address > 0x0FFFFFFF, then ASSERT().
270 If StartBit is greater than 7, then ASSERT().
271 If EndBit is greater than 7, then ASSERT().
272 If EndBit is less than StartBit, then ASSERT().
273 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
275 @param Address PCI configuration register to write.
276 @param StartBit The ordinal of the least significant bit in the bit field.
278 @param EndBit The ordinal of the most significant bit in the bit field.
280 @param Value New value of the bit field.
282 @return The value written back to the PCI configuration register.
287 S3PciBitFieldWrite8 (
294 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldWrite8 (Address
, StartBit
, EndBit
, Value
));
298 Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
299 writes the result back to the bit field in the 8-bit port and saves the value
300 in the S3 script to be replayed on S3 resume.
302 Reads the 8-bit PCI configuration register specified by Address, performs a
303 bitwise OR between the read result and the value specified by
304 OrData, and writes the result to the 8-bit PCI configuration register
305 specified by Address. The value written to the PCI configuration register is
306 returned. This function must guarantee that all PCI read and write operations
307 are serialized. Extra left bits in OrData are stripped.
309 If Address > 0x0FFFFFFF, then ASSERT().
310 If StartBit is greater than 7, then ASSERT().
311 If EndBit is greater than 7, then ASSERT().
312 If EndBit is less than StartBit, then ASSERT().
313 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
315 @param Address PCI configuration register to write.
316 @param StartBit The ordinal of the least significant bit in the bit field.
318 @param EndBit The ordinal of the most significant bit in the bit field.
320 @param OrData The value to OR with the PCI configuration register.
322 @return The value written back to the PCI configuration register.
334 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldOr8 (Address
, StartBit
, EndBit
, OrData
));
338 Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
339 AND, and writes the result back to the bit field in the 8-bit register and
340 saves the value in the S3 script to be replayed on S3 resume.
342 Reads the 8-bit PCI configuration register specified by Address, performs a
343 bitwise AND between the read result and the value specified by AndData, and
344 writes the result to the 8-bit PCI configuration register specified by
345 Address. The value written to the PCI configuration register is returned.
346 This function must guarantee that all PCI read and write operations are
347 serialized. Extra left bits in AndData are stripped.
349 If Address > 0x0FFFFFFF, then ASSERT().
350 If StartBit is greater than 7, then ASSERT().
351 If EndBit is greater than 7, then ASSERT().
352 If EndBit is less than StartBit, then ASSERT().
353 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
355 @param Address PCI configuration register to write.
356 @param StartBit The ordinal of the least significant bit in the bit field.
358 @param EndBit The ordinal of the most significant bit in the bit field.
360 @param AndData The value to AND with the PCI configuration register.
362 @return The value written back to the PCI configuration register.
374 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldAnd8 (Address
, StartBit
, EndBit
, AndData
));
378 Reads a bit field in an 8-bit Address, performs a bitwise AND followed by a
379 bitwise OR, and writes the result back to the bit field in the
380 8-bit port and saves the value in the S3 script to be replayed on S3 resume.
382 Reads the 8-bit PCI configuration register specified by Address, performs a
383 bitwise AND followed by a bitwise OR between the read result and
384 the value specified by AndData, and writes the result to the 8-bit PCI
385 configuration register specified by Address. The value written to the PCI
386 configuration register is returned. This function must guarantee that all PCI
387 read and write operations are serialized. Extra left bits in both AndData and
390 If Address > 0x0FFFFFFF, then ASSERT().
391 If StartBit is greater than 7, then ASSERT().
392 If EndBit is greater than 7, then ASSERT().
393 If EndBit is less than StartBit, then ASSERT().
394 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
395 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
397 @param Address PCI configuration register to write.
398 @param StartBit The ordinal of the least significant bit in the bit field.
400 @param EndBit The ordinal of the most significant bit in the bit field.
402 @param AndData The value to AND with the PCI configuration register.
403 @param OrData The value to OR with the result of the AND operation.
405 @return The value written back to the PCI configuration register.
410 S3PciBitFieldAndThenOr8 (
418 return InternalSavePciWrite8ValueToBootScript (Address
, PciBitFieldAndThenOr8 (Address
, StartBit
, EndBit
, AndData
, OrData
));
422 Saves a 16-bit PCI configuration value to the boot script.
424 This internal worker function saves a 16-bit PCI configuration value in
425 the S3 script to be replayed on S3 resume.
427 If the saving process fails, then ASSERT().
429 @param Address Address that encodes the PCI Bus, Device, Function and
431 @param Value The value to write.
437 InternalSavePciWrite16ValueToBootScript (
442 InternalSavePciWriteValueToBootScript (S3BootScriptWidthUint16
, Address
, &Value
);
448 Reads a 16-bit PCI configuration register and saves the value in the S3
449 script to be replayed on S3 resume.
451 Reads and returns the 16-bit PCI configuration register specified by Address.
452 This function must guarantee that all PCI read and write operations are
455 If Address > 0x0FFFFFFF, then ASSERT().
456 If Address is not aligned on a 16-bit boundary, then ASSERT().
458 @param Address Address that encodes the PCI Bus, Device, Function and
461 @return The read value from the PCI configuration register.
470 return InternalSavePciWrite16ValueToBootScript (Address
, PciRead16 (Address
));
474 Writes a 16-bit PCI configuration register and saves the value in the S3
475 script to be replayed on S3 resume.
477 Writes the 16-bit PCI configuration register specified by Address with the
478 value specified by Value. Value is returned. This function must guarantee
479 that all PCI read and write operations are serialized.
481 If Address > 0x0FFFFFFF, then ASSERT().
482 If Address is not aligned on a 16-bit boundary, then ASSERT().
484 @param Address Address that encodes the PCI Bus, Device, Function and
486 @param Value The value to write.
488 @return The value written to the PCI configuration register.
498 return InternalSavePciWrite16ValueToBootScript (Address
, PciWrite16 (Address
, Value
));
502 Performs a bitwise OR of a 16-bit PCI configuration register with
503 a 16-bit value and saves the value in the S3 script to be replayed on S3 resume.
505 Reads the 16-bit PCI configuration register specified by Address, performs a
506 bitwise OR between the read result and the value specified by
507 OrData, and writes the result to the 16-bit PCI configuration register
508 specified by Address. The value written to the PCI configuration register is
509 returned. This function must guarantee that all PCI read and write operations
512 If Address > 0x0FFFFFFF, then ASSERT().
513 If Address is not aligned on a 16-bit boundary, then ASSERT().
515 @param Address Address that encodes the PCI Bus, Device, Function and
517 @param OrData The value to OR with the PCI configuration register.
519 @return The value written back to the PCI configuration register.
529 return InternalSavePciWrite16ValueToBootScript (Address
, PciOr16 (Address
, OrData
));
533 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
534 value and saves the value in the S3 script to be replayed on S3 resume.
536 Reads the 16-bit PCI configuration register specified by Address, performs a
537 bitwise AND between the read result and the value specified by AndData, and
538 writes the result to the 16-bit PCI configuration register specified by
539 Address. The value written to the PCI configuration register is returned.
540 This function must guarantee that all PCI read and write operations are
543 If Address > 0x0FFFFFFF, then ASSERT().
544 If Address is not aligned on a 16-bit boundary, then ASSERT().
546 @param Address Address that encodes the PCI Bus, Device, Function and
548 @param AndData The value to AND with the PCI configuration register.
550 @return The value written back to the PCI configuration register.
560 return InternalSavePciWrite16ValueToBootScript (Address
, PciAnd16 (Address
, AndData
));
564 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
565 value, followed a bitwise OR with another 16-bit value and saves
566 the value in the S3 script to be replayed on S3 resume.
568 Reads the 16-bit PCI configuration register specified by Address, performs a
569 bitwise AND between the read result and the value specified by AndData,
570 performs a bitwise OR between the result of the AND operation and
571 the value specified by OrData, and writes the result to the 16-bit PCI
572 configuration register specified by Address. The value written to the PCI
573 configuration register is returned. This function must guarantee that all PCI
574 read and write operations are serialized.
576 If Address > 0x0FFFFFFF, then ASSERT().
577 If Address is not aligned on a 16-bit boundary, then ASSERT().
579 @param Address Address that encodes the PCI Bus, Device, Function and
581 @param AndData The value to AND with the PCI configuration register.
582 @param OrData The value to OR with the result of the AND operation.
584 @return The value written back to the PCI configuration register.
595 return InternalSavePciWrite16ValueToBootScript (Address
, PciAndThenOr16 (Address
, AndData
, OrData
));
599 Reads a bit field of a PCI configuration register and saves the value in
600 the S3 script to be replayed on S3 resume.
602 Reads the bit field in a 16-bit PCI configuration register. The bit field is
603 specified by the StartBit and the EndBit. The value of the bit field is
606 If Address > 0x0FFFFFFF, then ASSERT().
607 If Address is not aligned on a 16-bit boundary, then ASSERT().
608 If StartBit is greater than 15, then ASSERT().
609 If EndBit is greater than 15, then ASSERT().
610 If EndBit is less than StartBit, then ASSERT().
612 @param Address PCI configuration register to read.
613 @param StartBit The ordinal of the least significant bit in the bit field.
615 @param EndBit The ordinal of the most significant bit in the bit field.
618 @return The value of the bit field read from the PCI configuration register.
623 S3PciBitFieldRead16 (
629 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldRead16 (Address
, StartBit
, EndBit
));
633 Writes a bit field to a PCI configuration register and saves the value in
634 the S3 script to be replayed on S3 resume.
636 Writes Value to the bit field of the PCI configuration register. The bit
637 field is specified by the StartBit and the EndBit. All other bits in the
638 destination PCI configuration register are preserved. The new value of the
639 16-bit register is returned.
641 If Address > 0x0FFFFFFF, then ASSERT().
642 If Address is not aligned on a 16-bit boundary, then ASSERT().
643 If StartBit is greater than 15, then ASSERT().
644 If EndBit is greater than 15, then ASSERT().
645 If EndBit is less than StartBit, then ASSERT().
646 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
648 @param Address PCI configuration register to write.
649 @param StartBit The ordinal of the least significant bit in the bit field.
651 @param EndBit The ordinal of the most significant bit in the bit field.
653 @param Value New value of the bit field.
655 @return The value written back to the PCI configuration register.
660 S3PciBitFieldWrite16 (
667 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldWrite16 (Address
, StartBit
, EndBit
, Value
));
671 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
672 writes the result back to the bit field in the 16-bit port and saves the value
673 in the S3 script to be replayed on S3 resume.
675 Reads the 16-bit PCI configuration register specified by Address, performs a
676 bitwise OR between the read result and the value specified by
677 OrData, and writes the result to the 16-bit PCI configuration register
678 specified by Address. The value written to the PCI configuration register is
679 returned. This function must guarantee that all PCI read and write operations
680 are serialized. Extra left bits in OrData are stripped.
682 If Address > 0x0FFFFFFF, then ASSERT().
683 If Address is not aligned on a 16-bit boundary, then ASSERT().
684 If StartBit is greater than 15, then ASSERT().
685 If EndBit is greater than 15, then ASSERT().
686 If EndBit is less than StartBit, then ASSERT().
687 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
689 @param Address PCI configuration register to write.
690 @param StartBit The ordinal of the least significant bit in the bit field.
692 @param EndBit The ordinal of the most significant bit in the bit field.
694 @param OrData The value to OR with the PCI configuration register.
696 @return The value written back to the PCI configuration register.
708 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldOr16 (Address
, StartBit
, EndBit
, OrData
));
712 Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
713 AND, and writes the result back to the bit field in the 16-bit register and
714 saves the value in the S3 script to be replayed on S3 resume.
716 Reads the 16-bit PCI configuration register specified by Address, performs a
717 bitwise AND between the read result and the value specified by AndData, and
718 writes the result to the 16-bit PCI configuration register specified by
719 Address. The value written to the PCI configuration register is returned.
720 This function must guarantee that all PCI read and write operations are
721 serialized. Extra left bits in AndData are stripped.
723 If Address > 0x0FFFFFFF, then ASSERT().
724 If Address is not aligned on a 16-bit boundary, then ASSERT().
725 If StartBit is greater than 15, then ASSERT().
726 If EndBit is greater than 15, then ASSERT().
727 If EndBit is less than StartBit, then ASSERT().
728 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
730 @param Address PCI configuration register to write.
731 @param StartBit The ordinal of the least significant bit in the bit field.
733 @param EndBit The ordinal of the most significant bit in the bit field.
735 @param AndData The value to AND with the PCI configuration register.
737 @return The value written back to the PCI configuration register.
749 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldAnd16 (Address
, StartBit
, EndBit
, AndData
));
753 Reads a bit field in a 16-bit Address, performs a bitwise AND followed by a
754 bitwise OR, and writes the result back to the bit field in the
755 16-bit port and saves the value in the S3 script to be replayed on S3 resume.
757 Reads the 16-bit PCI configuration register specified by Address, performs a
758 bitwise AND followed by a bitwise OR between the read result and
759 the value specified by AndData, and writes the result to the 16-bit PCI
760 configuration register specified by Address. The value written to the PCI
761 configuration register is returned. This function must guarantee that all PCI
762 read and write operations are serialized. Extra left bits in both AndData and
765 If Address > 0x0FFFFFFF, then ASSERT().
766 If Address is not aligned on a 16-bit boundary, then ASSERT().
767 If StartBit is greater than 15, then ASSERT().
768 If EndBit is greater than 15, then ASSERT().
769 If EndBit is less than StartBit, then ASSERT().
770 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
771 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
773 @param Address PCI configuration register to write.
774 @param StartBit The ordinal of the least significant bit in the bit field.
776 @param EndBit The ordinal of the most significant bit in the bit field.
778 @param AndData The value to AND with the PCI configuration register.
779 @param OrData The value to OR with the result of the AND operation.
781 @return The value written back to the PCI configuration register.
786 S3PciBitFieldAndThenOr16 (
794 return InternalSavePciWrite16ValueToBootScript (Address
, PciBitFieldAndThenOr16 (Address
, StartBit
, EndBit
, AndData
, OrData
));
798 Saves a 32-bit PCI configuration value to the boot script.
800 This internal worker function saves a 32-bit PCI configuration value in the S3 script
801 to be replayed on S3 resume.
803 If the saving process fails, then ASSERT().
805 @param Address Address that encodes the PCI Bus, Device, Function and
807 @param Value The value to write.
813 InternalSavePciWrite32ValueToBootScript (
818 InternalSavePciWriteValueToBootScript (S3BootScriptWidthUint32
, Address
, &Value
);
824 Reads a 32-bit PCI configuration register and saves the value in the S3
825 script to be replayed on S3 resume.
827 Reads and returns the 32-bit PCI configuration register specified by Address.
828 This function must guarantee that all PCI read and write operations are
831 If Address > 0x0FFFFFFF, then ASSERT().
832 If Address is not aligned on a 32-bit boundary, then ASSERT().
834 @param Address Address that encodes the PCI Bus, Device, Function and
837 @return The read value from the PCI configuration register.
846 return InternalSavePciWrite32ValueToBootScript (Address
, PciRead32 (Address
));
850 Writes a 32-bit PCI configuration register and saves the value in the S3
851 script to be replayed on S3 resume.
853 Writes the 32-bit PCI configuration register specified by Address with the
854 value specified by Value. Value is returned. This function must guarantee
855 that all PCI read and write operations are serialized.
857 If Address > 0x0FFFFFFF, then ASSERT().
858 If Address is not aligned on a 32-bit boundary, then ASSERT().
860 @param Address Address that encodes the PCI Bus, Device, Function and
862 @param Value The value to write.
864 @return The value written to the PCI configuration register.
874 return InternalSavePciWrite32ValueToBootScript (Address
, PciWrite32 (Address
, Value
));
878 Performs a bitwise OR of a 32-bit PCI configuration register with
879 a 32-bit value and saves the value in the S3 script to be replayed on S3 resume.
881 Reads the 32-bit PCI configuration register specified by Address, performs a
882 bitwise OR between the read result and the value specified by
883 OrData, and writes the result to the 32-bit PCI configuration register
884 specified by Address. The value written to the PCI configuration register is
885 returned. This function must guarantee that all PCI read and write operations
888 If Address > 0x0FFFFFFF, then ASSERT().
889 If Address is not aligned on a 32-bit boundary, then ASSERT().
891 @param Address Address that encodes the PCI Bus, Device, Function and
893 @param OrData The value to OR with the PCI configuration register.
895 @return The value written back to the PCI configuration register.
905 return InternalSavePciWrite32ValueToBootScript (Address
, PciOr32 (Address
, OrData
));
909 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
910 value and saves the value in the S3 script to be replayed on S3 resume.
912 Reads the 32-bit PCI configuration register specified by Address, performs a
913 bitwise AND between the read result and the value specified by AndData, and
914 writes the result to the 32-bit PCI configuration register specified by
915 Address. The value written to the PCI configuration register is returned.
916 This function must guarantee that all PCI read and write operations are
919 If Address > 0x0FFFFFFF, then ASSERT().
920 If Address is not aligned on a 32-bit boundary, then ASSERT().
922 @param Address Address that encodes the PCI Bus, Device, Function and
924 @param AndData The value to AND with the PCI configuration register.
926 @return The value written back to the PCI configuration register.
936 return InternalSavePciWrite32ValueToBootScript (Address
, PciAnd32 (Address
, AndData
));
940 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
941 value, followed a bitwise OR with another 32-bit value and saves
942 the value in the S3 script to be replayed on S3 resume.
944 Reads the 32-bit PCI configuration register specified by Address, performs a
945 bitwise AND between the read result and the value specified by AndData,
946 performs a bitwise OR between the result of the AND operation and
947 the value specified by OrData, and writes the result to the 32-bit PCI
948 configuration register specified by Address. The value written to the PCI
949 configuration register is returned. This function must guarantee that all PCI
950 read and write operations are serialized.
952 If Address > 0x0FFFFFFF, then ASSERT().
953 If Address is not aligned on a 32-bit boundary, then ASSERT().
955 @param Address Address that encodes the PCI Bus, Device, Function and
957 @param AndData The value to AND with the PCI configuration register.
958 @param OrData The value to OR with the result of the AND operation.
960 @return The value written back to the PCI configuration register.
971 return InternalSavePciWrite32ValueToBootScript (Address
, PciAndThenOr32 (Address
, AndData
, OrData
));
975 Reads a bit field of a PCI configuration register and saves the value in
976 the S3 script to be replayed on S3 resume.
978 Reads the bit field in a 32-bit PCI configuration register. The bit field is
979 specified by the StartBit and the EndBit. The value of the bit field is
982 If Address > 0x0FFFFFFF, then ASSERT().
983 If Address is not aligned on a 32-bit boundary, then ASSERT().
984 If StartBit is greater than 31, then ASSERT().
985 If EndBit is greater than 31, then ASSERT().
986 If EndBit is less than StartBit, then ASSERT().
988 @param Address PCI configuration register to read.
989 @param StartBit The ordinal of the least significant bit in the bit field.
991 @param EndBit The ordinal of the most significant bit in the bit field.
994 @return The value of the bit field read from the PCI configuration register.
999 S3PciBitFieldRead32 (
1005 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldRead32 (Address
, StartBit
, EndBit
));
1009 Writes a bit field to a PCI configuration register and saves the value in
1010 the S3 script to be replayed on S3 resume.
1012 Writes Value to the bit field of the PCI configuration register. The bit
1013 field is specified by the StartBit and the EndBit. All other bits in the
1014 destination PCI configuration register are preserved. The new value of the
1015 32-bit register is returned.
1017 If Address > 0x0FFFFFFF, then ASSERT().
1018 If Address is not aligned on a 32-bit boundary, then ASSERT().
1019 If StartBit is greater than 31, then ASSERT().
1020 If EndBit is greater than 31, then ASSERT().
1021 If EndBit is less than StartBit, then ASSERT().
1022 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1024 @param Address PCI configuration register to write.
1025 @param StartBit The ordinal of the least significant bit in the bit field.
1027 @param EndBit The ordinal of the most significant bit in the bit field.
1029 @param Value New value of the bit field.
1031 @return The value written back to the PCI configuration register.
1036 S3PciBitFieldWrite32 (
1043 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldWrite32 (Address
, StartBit
, EndBit
, Value
));
1047 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
1048 writes the result back to the bit field in the 32-bit port and saves the value
1049 in the S3 script to be replayed on S3 resume.
1051 Reads the 32-bit PCI configuration register specified by Address, performs a
1052 bitwise OR between the read result and the value specified by
1053 OrData, and writes the result to the 32-bit PCI configuration register
1054 specified by Address. The value written to the PCI configuration register is
1055 returned. This function must guarantee that all PCI read and write operations
1056 are serialized. Extra left bits in OrData are stripped.
1058 If Address > 0x0FFFFFFF, then ASSERT().
1059 If Address is not aligned on a 32-bit boundary, then ASSERT().
1060 If StartBit is greater than 31, then ASSERT().
1061 If EndBit is greater than 31, then ASSERT().
1062 If EndBit is less than StartBit, then ASSERT().
1063 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1065 @param Address PCI configuration register to write.
1066 @param StartBit The ordinal of the least significant bit in the bit field.
1068 @param EndBit The ordinal of the most significant bit in the bit field.
1070 @param OrData The value to OR with the PCI configuration register.
1072 @return The value written back to the PCI configuration register.
1084 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldOr32 (Address
, StartBit
, EndBit
, OrData
));
1088 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
1089 AND, and writes the result back to the bit field in the 32-bit register and
1090 saves the value in the S3 script to be replayed on S3 resume.
1092 Reads the 32-bit PCI configuration register specified by Address, performs a
1093 bitwise AND between the read result and the value specified by AndData, and
1094 writes the result to the 32-bit PCI configuration register specified by
1095 Address. The value written to the PCI configuration register is returned.
1096 This function must guarantee that all PCI read and write operations are
1097 serialized. Extra left bits in AndData are stripped.
1099 If Address > 0x0FFFFFFF, then ASSERT().
1100 If Address is not aligned on a 32-bit boundary, then ASSERT().
1101 If StartBit is greater than 31, then ASSERT().
1102 If EndBit is greater than 31, then ASSERT().
1103 If EndBit is less than StartBit, then ASSERT().
1104 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1106 @param Address PCI configuration register to write.
1107 @param StartBit The ordinal of the least significant bit in the bit field.
1109 @param EndBit The ordinal of the most significant bit in the bit field.
1111 @param AndData The value to AND with the PCI configuration register.
1113 @return The value written back to the PCI configuration register.
1118 S3PciBitFieldAnd32 (
1125 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldAnd32 (Address
, StartBit
, EndBit
, AndData
));
1129 Reads a bit field in a 32-bit Address, performs a bitwise AND followed by a
1130 bitwise OR, and writes the result back to the bit field in the
1131 32-bit port and saves the value in the S3 script to be replayed on S3 resume.
1133 Reads the 32-bit PCI configuration register specified by Address, performs a
1134 bitwise AND followed by a bitwise OR between the read result and
1135 the value specified by AndData, and writes the result to the 32-bit PCI
1136 configuration register specified by Address. The value written to the PCI
1137 configuration register is returned. This function must guarantee that all PCI
1138 read and write operations are serialized. Extra left bits in both AndData and
1139 OrData are stripped.
1141 If Address > 0x0FFFFFFF, then ASSERT().
1142 If Address is not aligned on a 32-bit boundary, then ASSERT().
1143 If StartBit is greater than 31, then ASSERT().
1144 If EndBit is greater than 31, then ASSERT().
1145 If EndBit is less than StartBit, then ASSERT().
1146 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1147 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
1149 @param Address PCI configuration register to write.
1150 @param StartBit The ordinal of the least significant bit in the bit field.
1152 @param EndBit The ordinal of the most significant bit in the bit field.
1154 @param AndData The value to AND with the PCI configuration register.
1155 @param OrData The value to OR with the result of the AND operation.
1157 @return The value written back to the PCI configuration register.
1162 S3PciBitFieldAndThenOr32 (
1170 return InternalSavePciWrite32ValueToBootScript (Address
, PciBitFieldAndThenOr32 (Address
, StartBit
, EndBit
, AndData
, OrData
));
1174 Reads a range of PCI configuration registers into a caller supplied buffer
1175 and saves the value in the S3 script to be replayed on S3 resume.
1177 Reads the range of PCI configuration registers specified by StartAddress and
1178 Size into the buffer specified by Buffer. This function only allows the PCI
1179 configuration registers from a single PCI function to be read. Size is
1180 returned. When possible 32-bit PCI configuration read cycles are used to read
1181 from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
1182 and 16-bit PCI configuration read cycles may be used at the beginning and the
1185 If StartAddress > 0x0FFFFFFF, then ASSERT().
1186 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1187 If Size > 0 and Buffer is NULL, then ASSERT().
1189 @param StartAddress Starting address that encodes the PCI Bus, Device,
1190 Function and Register.
1191 @param Size Size in bytes of the transfer.
1192 @param Buffer Pointer to a buffer receiving the data read.
1200 IN UINTN StartAddress
,
1205 RETURN_STATUS Status
;
1207 Status
= S3BootScriptSavePciCfgWrite (
1208 S3BootScriptWidthUint8
,
1209 PCILIB_TO_COMMON_ADDRESS (StartAddress
),
1210 PciReadBuffer (StartAddress
, Size
, Buffer
),
1213 ASSERT (Status
== RETURN_SUCCESS
);
1219 Copies the data in a caller supplied buffer to a specified range of PCI
1220 configuration space and saves the value in the S3 script to be replayed on S3
1223 Writes the range of PCI configuration registers specified by StartAddress and
1224 Size from the buffer specified by Buffer. This function only allows the PCI
1225 configuration registers from a single PCI function to be written. Size is
1226 returned. When possible 32-bit PCI configuration write cycles are used to
1227 write from StartAdress to StartAddress + Size. Due to alignment restrictions,
1228 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
1229 and the end of the range.
1231 If StartAddress > 0x0FFFFFFF, then ASSERT().
1232 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1233 If Size > 0 and Buffer is NULL, then ASSERT().
1235 @param StartAddress Starting address that encodes the PCI Bus, Device,
1236 Function and Register.
1237 @param Size Size in bytes of the transfer.
1238 @param Buffer Pointer to a buffer containing the data to write.
1246 IN UINTN StartAddress
,
1251 RETURN_STATUS Status
;
1253 Status
= S3BootScriptSavePciCfgWrite (
1254 S3BootScriptWidthUint8
,
1255 PCILIB_TO_COMMON_ADDRESS (StartAddress
),
1256 PciWriteBuffer (StartAddress
, Size
, Buffer
),
1259 ASSERT (Status
== RETURN_SUCCESS
);