]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseS3PciLib/S3PciLib.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseS3PciLib / S3PciLib.c
CommitLineData
fe69ac84 1/** @file\r
2 PCI configuration Library Services that do PCI configuration and also enable\r
3 the PCI operations to be replayed during an S3 resume. This library class\r
9095d37b 4 maps directly on top of the PciLib class.\r
fe69ac84 5\r
9095d37b 6 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
fe69ac84 7\r
9344f092 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
fe69ac84 9\r
10**/\r
11\r
12\r
13#include <Base.h>\r
14\r
15#include <Library/DebugLib.h>\r
16#include <Library/S3BootScriptLib.h>\r
17#include <Library/PciLib.h>\r
18#include <Library/S3PciLib.h>\r
19\r
20#define PCILIB_TO_COMMON_ADDRESS(Address) \\r
95ba3d92 21 ((((UINTN) ((Address>>20) & 0xff)) << 24) + (((UINTN) ((Address>>15) & 0x1f)) << 16) + (((UINTN) ((Address>>12) & 0x07)) << 8) + ((UINTN) (Address & 0xfff )))\r
fe69ac84 22\r
23/**\r
24 Saves a PCI configuration value to the boot script.\r
25\r
26 This internal worker function saves a PCI configuration value in\r
9095d37b 27 the S3 script to be replayed on S3 resume.\r
fe69ac84 28\r
29 If the saving process fails, then ASSERT().\r
30\r
31 @param Width The width of PCI configuration.\r
32 @param Address Address that encodes the PCI Bus, Device, Function and\r
33 Register.\r
34 @param Buffer The buffer containing value.\r
35\r
36**/\r
37VOID\r
38InternalSavePciWriteValueToBootScript (\r
39 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
40 IN UINTN Address,\r
41 IN VOID *Buffer\r
42 )\r
43{\r
44 RETURN_STATUS Status;\r
45\r
46 Status = S3BootScriptSavePciCfgWrite (\r
47 Width,\r
48 PCILIB_TO_COMMON_ADDRESS(Address),\r
49 1,\r
50 Buffer\r
51 );\r
52 ASSERT (Status == RETURN_SUCCESS);\r
53}\r
54\r
55/**\r
56 Saves an 8-bit PCI configuration value to the boot script.\r
57\r
58 This internal worker function saves an 8-bit PCI configuration value in\r
9095d37b 59 the S3 script to be replayed on S3 resume.\r
fe69ac84 60\r
61 If the saving process fails, then ASSERT().\r
62\r
63 @param Address Address that encodes the PCI Bus, Device, Function and\r
64 Register.\r
65 @param Value The value saved to boot script.\r
66\r
67 @return Value.\r
68\r
69**/\r
70UINT8\r
71InternalSavePciWrite8ValueToBootScript (\r
72 IN UINTN Address,\r
73 IN UINT8 Value\r
74 )\r
75{\r
76 InternalSavePciWriteValueToBootScript (S3BootScriptWidthUint8, Address, &Value);\r
77\r
78 return Value;\r
79}\r
80\r
81/**\r
82 Reads an 8-bit PCI configuration register and saves the value in the S3\r
83 script to be replayed on S3 resume.\r
84\r
85 Reads and returns the 8-bit PCI configuration register specified by Address.\r
86 This function must guarantee that all PCI read and write operations are\r
87 serialized.\r
88\r
89 If Address > 0x0FFFFFFF, then ASSERT().\r
90\r
91 @param Address Address that encodes the PCI Bus, Device, Function and\r
92 Register.\r
93\r
94 @return The read value from the PCI configuration register.\r
95\r
96**/\r
97UINT8\r
98EFIAPI\r
99S3PciRead8 (\r
100 IN UINTN Address\r
101 )\r
102{\r
103 return InternalSavePciWrite8ValueToBootScript (Address, PciRead8 (Address));\r
104}\r
105\r
106/**\r
107 Writes an 8-bit PCI configuration register and saves the value in the S3\r
108 script to be replayed on S3 resume.\r
109\r
110 Writes the 8-bit PCI configuration register specified by Address with the\r
111 value specified by Value. Value is returned. This function must guarantee\r
112 that all PCI read and write operations are serialized.\r
113\r
114 If Address > 0x0FFFFFFF, then ASSERT().\r
115\r
116 @param Address Address that encodes the PCI Bus, Device, Function and\r
117 Register.\r
118 @param Value The value to write.\r
119\r
120 @return The value written to the PCI configuration register.\r
121\r
122**/\r
123UINT8\r
124EFIAPI\r
125S3PciWrite8 (\r
126 IN UINTN Address,\r
127 IN UINT8 Value\r
128 )\r
129{\r
130 return InternalSavePciWrite8ValueToBootScript (Address, PciWrite8 (Address, Value));\r
131}\r
132\r
133/**\r
134 Performs a bitwise OR of an 8-bit PCI configuration register with\r
135 an 8-bit value and saves the value in the S3 script to be replayed on S3 resume.\r
136\r
137 Reads the 8-bit PCI configuration register specified by Address, performs a\r
138 bitwise OR between the read result and the value specified by\r
139 OrData, and writes the result to the 8-bit PCI configuration register\r
140 specified by Address. The value written to the PCI configuration register is\r
141 returned. This function must guarantee that all PCI read and write operations\r
142 are serialized.\r
143\r
144 If Address > 0x0FFFFFFF, then ASSERT().\r
145\r
146 @param Address Address that encodes the PCI Bus, Device, Function and\r
147 Register.\r
148 @param OrData The value to OR with the PCI configuration register.\r
149\r
150 @return The value written back to the PCI configuration register.\r
151\r
152**/\r
153UINT8\r
154EFIAPI\r
155S3PciOr8 (\r
156 IN UINTN Address,\r
157 IN UINT8 OrData\r
158 )\r
159{\r
160 return InternalSavePciWrite8ValueToBootScript (Address, PciOr8 (Address, OrData));\r
161}\r
162\r
163/**\r
164 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
165 value and saves the value in the S3 script to be replayed on S3 resume.\r
166\r
167 Reads the 8-bit PCI configuration register specified by Address, performs a\r
168 bitwise AND between the read result and the value specified by AndData, and\r
169 writes the result to the 8-bit PCI configuration register specified by\r
170 Address. The value written to the PCI configuration register is returned.\r
171 This function must guarantee that all PCI read and write operations are\r
172 serialized.\r
173\r
174 If Address > 0x0FFFFFFF, then ASSERT().\r
175\r
176 @param Address Address that encodes the PCI Bus, Device, Function and\r
177 Register.\r
178 @param AndData The value to AND with the PCI configuration register.\r
179\r
180 @return The value written back to the PCI configuration register.\r
181\r
182**/\r
183UINT8\r
184EFIAPI\r
185S3PciAnd8 (\r
186 IN UINTN Address,\r
187 IN UINT8 AndData\r
188 )\r
189{\r
190 return InternalSavePciWrite8ValueToBootScript (Address, PciAnd8 (Address, AndData));\r
191}\r
192\r
193/**\r
194 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
195 value, followed a bitwise OR with another 8-bit value and saves\r
196 the value in the S3 script to be replayed on S3 resume.\r
197\r
198 Reads the 8-bit PCI configuration register specified by Address, performs a\r
199 bitwise AND between the read result and the value specified by AndData,\r
200 performs a bitwise OR between the result of the AND operation and\r
201 the value specified by OrData, and writes the result to the 8-bit PCI\r
202 configuration register specified by Address. The value written to the PCI\r
203 configuration register is returned. This function must guarantee that all PCI\r
204 read and write operations are serialized.\r
205\r
206 If Address > 0x0FFFFFFF, then ASSERT().\r
207\r
208 @param Address Address that encodes the PCI Bus, Device, Function and\r
209 Register.\r
210 @param AndData The value to AND with the PCI configuration register.\r
211 @param OrData The value to OR with the result of the AND operation.\r
212\r
213 @return The value written back to the PCI configuration register.\r
214\r
215**/\r
216UINT8\r
217EFIAPI\r
218S3PciAndThenOr8 (\r
219 IN UINTN Address,\r
220 IN UINT8 AndData,\r
221 IN UINT8 OrData\r
222 )\r
223{\r
224 return InternalSavePciWrite8ValueToBootScript (Address, PciAndThenOr8 (Address, AndData, OrData));\r
225}\r
226\r
227/**\r
228 Reads a bit field of a PCI configuration register and saves the value in\r
229 the S3 script to be replayed on S3 resume.\r
230\r
231 Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
232 specified by the StartBit and the EndBit. The value of the bit field is\r
233 returned.\r
234\r
235 If Address > 0x0FFFFFFF, then ASSERT().\r
236 If StartBit is greater than 7, then ASSERT().\r
237 If EndBit is greater than 7, then ASSERT().\r
238 If EndBit is less than StartBit, then ASSERT().\r
239\r
240 @param Address PCI configuration register to read.\r
241 @param StartBit The ordinal of the least significant bit in the bit field.\r
242 Range 0..7.\r
243 @param EndBit The ordinal of the most significant bit in the bit field.\r
244 Range 0..7.\r
245\r
246 @return The value of the bit field read from the PCI configuration register.\r
247\r
248**/\r
249UINT8\r
250EFIAPI\r
251S3PciBitFieldRead8 (\r
252 IN UINTN Address,\r
253 IN UINTN StartBit,\r
254 IN UINTN EndBit\r
255 )\r
256{\r
257 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldRead8 (Address, StartBit, EndBit));\r
258}\r
259\r
260/**\r
261 Writes a bit field to a PCI configuration register and saves the value in\r
262 the S3 script to be replayed on S3 resume.\r
263\r
264 Writes Value to the bit field of the PCI configuration register. The bit\r
265 field is specified by the StartBit and the EndBit. All other bits in the\r
266 destination PCI configuration register are preserved. The new value of the\r
267 8-bit register is returned.\r
268\r
269 If Address > 0x0FFFFFFF, then ASSERT().\r
270 If StartBit is greater than 7, then ASSERT().\r
271 If EndBit is greater than 7, then ASSERT().\r
272 If EndBit is less than StartBit, then ASSERT().\r
94952554 273 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 274\r
275 @param Address PCI configuration register to write.\r
276 @param StartBit The ordinal of the least significant bit in the bit field.\r
277 Range 0..7.\r
278 @param EndBit The ordinal of the most significant bit in the bit field.\r
279 Range 0..7.\r
280 @param Value New value of the bit field.\r
281\r
282 @return The value written back to the PCI configuration register.\r
283\r
284**/\r
285UINT8\r
286EFIAPI\r
287S3PciBitFieldWrite8 (\r
288 IN UINTN Address,\r
289 IN UINTN StartBit,\r
290 IN UINTN EndBit,\r
291 IN UINT8 Value\r
292 )\r
293{\r
294 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldWrite8 (Address, StartBit, EndBit, Value));\r
295}\r
296\r
297/**\r
298 Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
299 writes the result back to the bit field in the 8-bit port and saves the value\r
300 in the S3 script to be replayed on S3 resume.\r
301\r
302 Reads the 8-bit PCI configuration register specified by Address, performs a\r
303 bitwise OR between the read result and the value specified by\r
304 OrData, and writes the result to the 8-bit PCI configuration register\r
305 specified by Address. The value written to the PCI configuration register is\r
306 returned. This function must guarantee that all PCI read and write operations\r
307 are serialized. Extra left bits in OrData are stripped.\r
308\r
309 If Address > 0x0FFFFFFF, then ASSERT().\r
310 If StartBit is greater than 7, then ASSERT().\r
311 If EndBit is greater than 7, then ASSERT().\r
312 If EndBit is less than StartBit, then ASSERT().\r
94952554 313 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 314\r
315 @param Address PCI configuration register to write.\r
316 @param StartBit The ordinal of the least significant bit in the bit field.\r
317 Range 0..7.\r
318 @param EndBit The ordinal of the most significant bit in the bit field.\r
319 Range 0..7.\r
320 @param OrData The value to OR with the PCI configuration register.\r
321\r
322 @return The value written back to the PCI configuration register.\r
323\r
324**/\r
325UINT8\r
326EFIAPI\r
327S3PciBitFieldOr8 (\r
328 IN UINTN Address,\r
329 IN UINTN StartBit,\r
330 IN UINTN EndBit,\r
331 IN UINT8 OrData\r
332 )\r
333{\r
334 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldOr8 (Address, StartBit, EndBit, OrData));\r
335}\r
336\r
337/**\r
338 Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
339 AND, and writes the result back to the bit field in the 8-bit register and\r
340 saves the value in the S3 script to be replayed on S3 resume.\r
341\r
342 Reads the 8-bit PCI configuration register specified by Address, performs a\r
343 bitwise AND between the read result and the value specified by AndData, and\r
344 writes the result to the 8-bit PCI configuration register specified by\r
345 Address. The value written to the PCI configuration register is returned.\r
346 This function must guarantee that all PCI read and write operations are\r
347 serialized. Extra left bits in AndData are stripped.\r
348\r
349 If Address > 0x0FFFFFFF, then ASSERT().\r
350 If StartBit is greater than 7, then ASSERT().\r
351 If EndBit is greater than 7, then ASSERT().\r
352 If EndBit is less than StartBit, then ASSERT().\r
94952554 353 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 354\r
355 @param Address PCI configuration register to write.\r
356 @param StartBit The ordinal of the least significant bit in the bit field.\r
357 Range 0..7.\r
358 @param EndBit The ordinal of the most significant bit in the bit field.\r
359 Range 0..7.\r
360 @param AndData The value to AND with the PCI configuration register.\r
361\r
362 @return The value written back to the PCI configuration register.\r
363\r
364**/\r
365UINT8\r
366EFIAPI\r
367S3PciBitFieldAnd8 (\r
368 IN UINTN Address,\r
369 IN UINTN StartBit,\r
370 IN UINTN EndBit,\r
371 IN UINT8 AndData\r
372 )\r
373{\r
374 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldAnd8 (Address, StartBit, EndBit, AndData));\r
375}\r
376\r
377/**\r
378 Reads a bit field in an 8-bit Address, performs a bitwise AND followed by a\r
379 bitwise OR, and writes the result back to the bit field in the\r
380 8-bit port and saves the value in the S3 script to be replayed on S3 resume.\r
381\r
382 Reads the 8-bit PCI configuration register specified by Address, performs a\r
383 bitwise AND followed by a bitwise OR between the read result and\r
384 the value specified by AndData, and writes the result to the 8-bit PCI\r
385 configuration register specified by Address. The value written to the PCI\r
386 configuration register is returned. This function must guarantee that all PCI\r
387 read and write operations are serialized. Extra left bits in both AndData and\r
388 OrData are stripped.\r
389\r
390 If Address > 0x0FFFFFFF, then ASSERT().\r
391 If StartBit is greater than 7, then ASSERT().\r
392 If EndBit is greater than 7, then ASSERT().\r
393 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
394 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
395 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 396\r
397 @param Address PCI configuration register to write.\r
398 @param StartBit The ordinal of the least significant bit in the bit field.\r
399 Range 0..7.\r
400 @param EndBit The ordinal of the most significant bit in the bit field.\r
401 Range 0..7.\r
402 @param AndData The value to AND with the PCI configuration register.\r
403 @param OrData The value to OR with the result of the AND operation.\r
404\r
405 @return The value written back to the PCI configuration register.\r
406\r
407**/\r
408UINT8\r
409EFIAPI\r
410S3PciBitFieldAndThenOr8 (\r
411 IN UINTN Address,\r
412 IN UINTN StartBit,\r
413 IN UINTN EndBit,\r
414 IN UINT8 AndData,\r
415 IN UINT8 OrData\r
416 )\r
417{\r
418 return InternalSavePciWrite8ValueToBootScript (Address, PciBitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData));\r
419}\r
420\r
421/**\r
422 Saves a 16-bit PCI configuration value to the boot script.\r
423\r
424 This internal worker function saves a 16-bit PCI configuration value in\r
9095d37b 425 the S3 script to be replayed on S3 resume.\r
fe69ac84 426\r
427 If the saving process fails, then ASSERT().\r
428\r
429 @param Address Address that encodes the PCI Bus, Device, Function and\r
430 Register.\r
431 @param Value The value to write.\r
432\r
433 @return Value.\r
434\r
435**/\r
436UINT16\r
437InternalSavePciWrite16ValueToBootScript (\r
438 IN UINTN Address,\r
439 IN UINT16 Value\r
440 )\r
441{\r
442 InternalSavePciWriteValueToBootScript (S3BootScriptWidthUint16, Address, &Value);\r
443\r
444 return Value;\r
445}\r
446\r
447/**\r
448 Reads a 16-bit PCI configuration register and saves the value in the S3\r
449 script to be replayed on S3 resume.\r
450\r
451 Reads and returns the 16-bit PCI configuration register specified by Address.\r
452 This function must guarantee that all PCI read and write operations are\r
453 serialized.\r
454\r
455 If Address > 0x0FFFFFFF, then ASSERT().\r
456 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
457\r
458 @param Address Address that encodes the PCI Bus, Device, Function and\r
459 Register.\r
460\r
461 @return The read value from the PCI configuration register.\r
462\r
463**/\r
464UINT16\r
465EFIAPI\r
466S3PciRead16 (\r
467 IN UINTN Address\r
468 )\r
469{\r
470 return InternalSavePciWrite16ValueToBootScript (Address, PciRead16 (Address));\r
471}\r
472\r
473/**\r
474 Writes a 16-bit PCI configuration register and saves the value in the S3\r
475 script to be replayed on S3 resume.\r
476\r
477 Writes the 16-bit PCI configuration register specified by Address with the\r
478 value specified by Value. Value is returned. This function must guarantee\r
479 that all PCI read and write operations are serialized.\r
480\r
481 If Address > 0x0FFFFFFF, then ASSERT().\r
482 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
483\r
484 @param Address Address that encodes the PCI Bus, Device, Function and\r
485 Register.\r
486 @param Value The value to write.\r
487\r
488 @return The value written to the PCI configuration register.\r
489\r
490**/\r
491UINT16\r
492EFIAPI\r
493S3PciWrite16 (\r
494 IN UINTN Address,\r
495 IN UINT16 Value\r
496 )\r
497{\r
498 return InternalSavePciWrite16ValueToBootScript (Address, PciWrite16 (Address, Value));\r
499}\r
500\r
501/**\r
502 Performs a bitwise OR of a 16-bit PCI configuration register with\r
503 a 16-bit value and saves the value in the S3 script to be replayed on S3 resume.\r
504\r
505 Reads the 16-bit PCI configuration register specified by Address, performs a\r
506 bitwise OR between the read result and the value specified by\r
507 OrData, and writes the result to the 16-bit PCI configuration register\r
508 specified by Address. The value written to the PCI configuration register is\r
509 returned. This function must guarantee that all PCI read and write operations\r
510 are serialized.\r
511\r
512 If Address > 0x0FFFFFFF, then ASSERT().\r
513 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
514\r
515 @param Address Address that encodes the PCI Bus, Device, Function and\r
516 Register.\r
517 @param OrData The value to OR with the PCI configuration register.\r
518\r
519 @return The value written back to the PCI configuration register.\r
520\r
521**/\r
522UINT16\r
523EFIAPI\r
524S3PciOr16 (\r
525 IN UINTN Address,\r
526 IN UINT16 OrData\r
527 )\r
528{\r
529 return InternalSavePciWrite16ValueToBootScript (Address, PciOr16 (Address, OrData));\r
530}\r
531\r
532/**\r
533 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
534 value and saves the value in the S3 script to be replayed on S3 resume.\r
535\r
536 Reads the 16-bit PCI configuration register specified by Address, performs a\r
537 bitwise AND between the read result and the value specified by AndData, and\r
538 writes the result to the 16-bit PCI configuration register specified by\r
539 Address. The value written to the PCI configuration register is returned.\r
540 This function must guarantee that all PCI read and write operations are\r
541 serialized.\r
542\r
543 If Address > 0x0FFFFFFF, then ASSERT().\r
544 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
545\r
546 @param Address Address that encodes the PCI Bus, Device, Function and\r
547 Register.\r
548 @param AndData The value to AND with the PCI configuration register.\r
549\r
550 @return The value written back to the PCI configuration register.\r
551\r
552**/\r
553UINT16\r
554EFIAPI\r
555S3PciAnd16 (\r
556 IN UINTN Address,\r
557 IN UINT16 AndData\r
558 )\r
559{\r
560 return InternalSavePciWrite16ValueToBootScript (Address, PciAnd16 (Address, AndData));\r
561}\r
562\r
563/**\r
564 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
565 value, followed a bitwise OR with another 16-bit value and saves\r
566 the value in the S3 script to be replayed on S3 resume.\r
567\r
568 Reads the 16-bit PCI configuration register specified by Address, performs a\r
569 bitwise AND between the read result and the value specified by AndData,\r
570 performs a bitwise OR between the result of the AND operation and\r
571 the value specified by OrData, and writes the result to the 16-bit PCI\r
572 configuration register specified by Address. The value written to the PCI\r
573 configuration register is returned. This function must guarantee that all PCI\r
574 read and write operations are serialized.\r
575\r
576 If Address > 0x0FFFFFFF, then ASSERT().\r
577 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
578\r
579 @param Address Address that encodes the PCI Bus, Device, Function and\r
580 Register.\r
581 @param AndData The value to AND with the PCI configuration register.\r
582 @param OrData The value to OR with the result of the AND operation.\r
583\r
584 @return The value written back to the PCI configuration register.\r
585\r
586**/\r
587UINT16\r
588EFIAPI\r
589S3PciAndThenOr16 (\r
590 IN UINTN Address,\r
591 IN UINT16 AndData,\r
592 IN UINT16 OrData\r
593 )\r
594{\r
595 return InternalSavePciWrite16ValueToBootScript (Address, PciAndThenOr16 (Address, AndData, OrData));\r
596}\r
597\r
598/**\r
599 Reads a bit field of a PCI configuration register and saves the value in\r
600 the S3 script to be replayed on S3 resume.\r
601\r
602 Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
603 specified by the StartBit and the EndBit. The value of the bit field is\r
604 returned.\r
605\r
606 If Address > 0x0FFFFFFF, then ASSERT().\r
607 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
608 If StartBit is greater than 15, then ASSERT().\r
609 If EndBit is greater than 15, then ASSERT().\r
610 If EndBit is less than StartBit, then ASSERT().\r
611\r
612 @param Address PCI configuration register to read.\r
613 @param StartBit The ordinal of the least significant bit in the bit field.\r
614 Range 0..15.\r
615 @param EndBit The ordinal of the most significant bit in the bit field.\r
616 Range 0..15.\r
617\r
618 @return The value of the bit field read from the PCI configuration register.\r
619\r
620**/\r
621UINT16\r
622EFIAPI\r
623S3PciBitFieldRead16 (\r
624 IN UINTN Address,\r
625 IN UINTN StartBit,\r
626 IN UINTN EndBit\r
627 )\r
628{\r
629 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldRead16 (Address, StartBit, EndBit));\r
630}\r
631\r
632/**\r
633 Writes a bit field to a PCI configuration register and saves the value in\r
634 the S3 script to be replayed on S3 resume.\r
635\r
636 Writes Value to the bit field of the PCI configuration register. The bit\r
637 field is specified by the StartBit and the EndBit. All other bits in the\r
638 destination PCI configuration register are preserved. The new value of the\r
639 16-bit register is returned.\r
640\r
641 If Address > 0x0FFFFFFF, then ASSERT().\r
642 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
643 If StartBit is greater than 15, then ASSERT().\r
644 If EndBit is greater than 15, then ASSERT().\r
645 If EndBit is less than StartBit, then ASSERT().\r
94952554 646 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 647\r
648 @param Address PCI configuration register to write.\r
649 @param StartBit The ordinal of the least significant bit in the bit field.\r
650 Range 0..15.\r
651 @param EndBit The ordinal of the most significant bit in the bit field.\r
652 Range 0..15.\r
653 @param Value New value of the bit field.\r
654\r
655 @return The value written back to the PCI configuration register.\r
656\r
657**/\r
658UINT16\r
659EFIAPI\r
660S3PciBitFieldWrite16 (\r
661 IN UINTN Address,\r
662 IN UINTN StartBit,\r
663 IN UINTN EndBit,\r
664 IN UINT16 Value\r
665 )\r
666{\r
667 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldWrite16 (Address, StartBit, EndBit, Value));\r
668}\r
669\r
670/**\r
671 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
672 writes the result back to the bit field in the 16-bit port and saves the value\r
673 in the S3 script to be replayed on S3 resume.\r
674\r
675 Reads the 16-bit PCI configuration register specified by Address, performs a\r
676 bitwise OR between the read result and the value specified by\r
677 OrData, and writes the result to the 16-bit PCI configuration register\r
678 specified by Address. The value written to the PCI configuration register is\r
679 returned. This function must guarantee that all PCI read and write operations\r
680 are serialized. Extra left bits in OrData are stripped.\r
681\r
682 If Address > 0x0FFFFFFF, then ASSERT().\r
683 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
684 If StartBit is greater than 15, then ASSERT().\r
685 If EndBit is greater than 15, then ASSERT().\r
686 If EndBit is less than StartBit, then ASSERT().\r
94952554 687 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 688\r
689 @param Address PCI configuration register to write.\r
690 @param StartBit The ordinal of the least significant bit in the bit field.\r
691 Range 0..15.\r
692 @param EndBit The ordinal of the most significant bit in the bit field.\r
693 Range 0..15.\r
694 @param OrData The value to OR with the PCI configuration register.\r
695\r
696 @return The value written back to the PCI configuration register.\r
697\r
698**/\r
699UINT16\r
700EFIAPI\r
701S3PciBitFieldOr16 (\r
702 IN UINTN Address,\r
703 IN UINTN StartBit,\r
704 IN UINTN EndBit,\r
705 IN UINT16 OrData\r
706 )\r
707{\r
708 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldOr16 (Address, StartBit, EndBit, OrData));\r
709}\r
710\r
711/**\r
712 Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
713 AND, and writes the result back to the bit field in the 16-bit register and\r
714 saves the value in the S3 script to be replayed on S3 resume.\r
715\r
716 Reads the 16-bit PCI configuration register specified by Address, performs a\r
717 bitwise AND between the read result and the value specified by AndData, and\r
718 writes the result to the 16-bit PCI configuration register specified by\r
719 Address. The value written to the PCI configuration register is returned.\r
720 This function must guarantee that all PCI read and write operations are\r
721 serialized. Extra left bits in AndData are stripped.\r
722\r
723 If Address > 0x0FFFFFFF, then ASSERT().\r
724 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
725 If StartBit is greater than 15, then ASSERT().\r
726 If EndBit is greater than 15, then ASSERT().\r
727 If EndBit is less than StartBit, then ASSERT().\r
94952554 728 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 729\r
730 @param Address PCI configuration register to write.\r
731 @param StartBit The ordinal of the least significant bit in the bit field.\r
732 Range 0..15.\r
733 @param EndBit The ordinal of the most significant bit in the bit field.\r
734 Range 0..15.\r
735 @param AndData The value to AND with the PCI configuration register.\r
736\r
737 @return The value written back to the PCI configuration register.\r
738\r
739**/\r
740UINT16\r
741EFIAPI\r
742S3PciBitFieldAnd16 (\r
743 IN UINTN Address,\r
744 IN UINTN StartBit,\r
745 IN UINTN EndBit,\r
746 IN UINT16 AndData\r
747 )\r
748{\r
749 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldAnd16 (Address, StartBit, EndBit, AndData));\r
750}\r
751\r
752/**\r
753 Reads a bit field in a 16-bit Address, performs a bitwise AND followed by a\r
754 bitwise OR, and writes the result back to the bit field in the\r
755 16-bit port and saves the value in the S3 script to be replayed on S3 resume.\r
756\r
757 Reads the 16-bit PCI configuration register specified by Address, performs a\r
758 bitwise AND followed by a bitwise OR between the read result and\r
759 the value specified by AndData, and writes the result to the 16-bit PCI\r
760 configuration register specified by Address. The value written to the PCI\r
761 configuration register is returned. This function must guarantee that all PCI\r
762 read and write operations are serialized. Extra left bits in both AndData and\r
763 OrData are stripped.\r
764\r
765 If Address > 0x0FFFFFFF, then ASSERT().\r
766 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
767 If StartBit is greater than 15, then ASSERT().\r
768 If EndBit is greater than 15, then ASSERT().\r
769 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
770 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
771 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 772\r
773 @param Address PCI configuration register to write.\r
774 @param StartBit The ordinal of the least significant bit in the bit field.\r
775 Range 0..15.\r
776 @param EndBit The ordinal of the most significant bit in the bit field.\r
777 Range 0..15.\r
778 @param AndData The value to AND with the PCI configuration register.\r
779 @param OrData The value to OR with the result of the AND operation.\r
780\r
781 @return The value written back to the PCI configuration register.\r
782\r
783**/\r
784UINT16\r
785EFIAPI\r
786S3PciBitFieldAndThenOr16 (\r
787 IN UINTN Address,\r
788 IN UINTN StartBit,\r
789 IN UINTN EndBit,\r
790 IN UINT16 AndData,\r
791 IN UINT16 OrData\r
792 )\r
793{\r
794 return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData));\r
795}\r
796\r
797/**\r
798 Saves a 32-bit PCI configuration value to the boot script.\r
799\r
800 This internal worker function saves a 32-bit PCI configuration value in the S3 script\r
9095d37b 801 to be replayed on S3 resume.\r
fe69ac84 802\r
803 If the saving process fails, then ASSERT().\r
804\r
805 @param Address Address that encodes the PCI Bus, Device, Function and\r
806 Register.\r
807 @param Value The value to write.\r
808\r
809 @return Value.\r
810\r
811**/\r
812UINT32\r
813InternalSavePciWrite32ValueToBootScript (\r
814 IN UINTN Address,\r
815 IN UINT32 Value\r
816 )\r
817{\r
818 InternalSavePciWriteValueToBootScript (S3BootScriptWidthUint32, Address, &Value);\r
819\r
820 return Value;\r
821}\r
822\r
823/**\r
824 Reads a 32-bit PCI configuration register and saves the value in the S3\r
825 script to be replayed on S3 resume.\r
826\r
827 Reads and returns the 32-bit PCI configuration register specified by Address.\r
828 This function must guarantee that all PCI read and write operations are\r
829 serialized.\r
830\r
831 If Address > 0x0FFFFFFF, then ASSERT().\r
832 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
833\r
834 @param Address Address that encodes the PCI Bus, Device, Function and\r
835 Register.\r
836\r
837 @return The read value from the PCI configuration register.\r
838\r
839**/\r
840UINT32\r
841EFIAPI\r
842S3PciRead32 (\r
843 IN UINTN Address\r
844 )\r
845{\r
846 return InternalSavePciWrite32ValueToBootScript (Address, PciRead32 (Address));\r
847}\r
848\r
849/**\r
850 Writes a 32-bit PCI configuration register and saves the value in the S3\r
851 script to be replayed on S3 resume.\r
852\r
853 Writes the 32-bit PCI configuration register specified by Address with the\r
854 value specified by Value. Value is returned. This function must guarantee\r
855 that all PCI read and write operations are serialized.\r
856\r
857 If Address > 0x0FFFFFFF, then ASSERT().\r
858 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
859\r
860 @param Address Address that encodes the PCI Bus, Device, Function and\r
861 Register.\r
862 @param Value The value to write.\r
863\r
864 @return The value written to the PCI configuration register.\r
865\r
866**/\r
867UINT32\r
868EFIAPI\r
869S3PciWrite32 (\r
870 IN UINTN Address,\r
871 IN UINT32 Value\r
872 )\r
873{\r
874 return InternalSavePciWrite32ValueToBootScript (Address, PciWrite32 (Address, Value));\r
875}\r
876\r
877/**\r
878 Performs a bitwise OR of a 32-bit PCI configuration register with\r
879 a 32-bit value and saves the value in the S3 script to be replayed on S3 resume.\r
880\r
881 Reads the 32-bit PCI configuration register specified by Address, performs a\r
882 bitwise OR between the read result and the value specified by\r
883 OrData, and writes the result to the 32-bit PCI configuration register\r
884 specified by Address. The value written to the PCI configuration register is\r
885 returned. This function must guarantee that all PCI read and write operations\r
886 are serialized.\r
887\r
888 If Address > 0x0FFFFFFF, then ASSERT().\r
889 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
890\r
891 @param Address Address that encodes the PCI Bus, Device, Function and\r
892 Register.\r
893 @param OrData The value to OR with the PCI configuration register.\r
894\r
895 @return The value written back to the PCI configuration register.\r
896\r
897**/\r
898UINT32\r
899EFIAPI\r
900S3PciOr32 (\r
901 IN UINTN Address,\r
902 IN UINT32 OrData\r
903 )\r
904{\r
905 return InternalSavePciWrite32ValueToBootScript (Address, PciOr32 (Address, OrData));\r
906}\r
907\r
908/**\r
909 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
910 value and saves the value in the S3 script to be replayed on S3 resume.\r
911\r
912 Reads the 32-bit PCI configuration register specified by Address, performs a\r
913 bitwise AND between the read result and the value specified by AndData, and\r
914 writes the result to the 32-bit PCI configuration register specified by\r
915 Address. The value written to the PCI configuration register is returned.\r
916 This function must guarantee that all PCI read and write operations are\r
917 serialized.\r
918\r
919 If Address > 0x0FFFFFFF, then ASSERT().\r
920 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
921\r
922 @param Address Address that encodes the PCI Bus, Device, Function and\r
923 Register.\r
924 @param AndData The value to AND with the PCI configuration register.\r
925\r
926 @return The value written back to the PCI configuration register.\r
927\r
928**/\r
929UINT32\r
930EFIAPI\r
931S3PciAnd32 (\r
932 IN UINTN Address,\r
933 IN UINT32 AndData\r
934 )\r
935{\r
936 return InternalSavePciWrite32ValueToBootScript (Address, PciAnd32 (Address, AndData));\r
937}\r
938\r
939/**\r
940 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
941 value, followed a bitwise OR with another 32-bit value and saves\r
942 the value in the S3 script to be replayed on S3 resume.\r
943\r
944 Reads the 32-bit PCI configuration register specified by Address, performs a\r
945 bitwise AND between the read result and the value specified by AndData,\r
946 performs a bitwise OR between the result of the AND operation and\r
947 the value specified by OrData, and writes the result to the 32-bit PCI\r
948 configuration register specified by Address. The value written to the PCI\r
949 configuration register is returned. This function must guarantee that all PCI\r
950 read and write operations are serialized.\r
951\r
952 If Address > 0x0FFFFFFF, then ASSERT().\r
953 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
954\r
955 @param Address Address that encodes the PCI Bus, Device, Function and\r
956 Register.\r
957 @param AndData The value to AND with the PCI configuration register.\r
958 @param OrData The value to OR with the result of the AND operation.\r
959\r
960 @return The value written back to the PCI configuration register.\r
961\r
962**/\r
963UINT32\r
964EFIAPI\r
965S3PciAndThenOr32 (\r
966 IN UINTN Address,\r
967 IN UINT32 AndData,\r
968 IN UINT32 OrData\r
969 )\r
970{\r
971 return InternalSavePciWrite32ValueToBootScript (Address, PciAndThenOr32 (Address, AndData, OrData));\r
972}\r
973\r
974/**\r
975 Reads a bit field of a PCI configuration register and saves the value in\r
976 the S3 script to be replayed on S3 resume.\r
977\r
978 Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
979 specified by the StartBit and the EndBit. The value of the bit field is\r
980 returned.\r
981\r
982 If Address > 0x0FFFFFFF, then ASSERT().\r
983 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
984 If StartBit is greater than 31, then ASSERT().\r
985 If EndBit is greater than 31, then ASSERT().\r
986 If EndBit is less than StartBit, then ASSERT().\r
987\r
988 @param Address PCI configuration register to read.\r
989 @param StartBit The ordinal of the least significant bit in the bit field.\r
990 Range 0..31.\r
991 @param EndBit The ordinal of the most significant bit in the bit field.\r
992 Range 0..31.\r
993\r
994 @return The value of the bit field read from the PCI configuration register.\r
995\r
996**/\r
997UINT32\r
998EFIAPI\r
999S3PciBitFieldRead32 (\r
1000 IN UINTN Address,\r
1001 IN UINTN StartBit,\r
1002 IN UINTN EndBit\r
1003 )\r
1004{\r
1005 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldRead32 (Address, StartBit, EndBit));\r
1006}\r
1007\r
1008/**\r
1009 Writes a bit field to a PCI configuration register and saves the value in\r
1010 the S3 script to be replayed on S3 resume.\r
1011\r
1012 Writes Value to the bit field of the PCI configuration register. The bit\r
1013 field is specified by the StartBit and the EndBit. All other bits in the\r
1014 destination PCI configuration register are preserved. The new value of the\r
1015 32-bit register is returned.\r
1016\r
1017 If Address > 0x0FFFFFFF, then ASSERT().\r
1018 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
1019 If StartBit is greater than 31, then ASSERT().\r
1020 If EndBit is greater than 31, then ASSERT().\r
1021 If EndBit is less than StartBit, then ASSERT().\r
94952554 1022 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 1023\r
1024 @param Address PCI configuration register to write.\r
1025 @param StartBit The ordinal of the least significant bit in the bit field.\r
1026 Range 0..31.\r
1027 @param EndBit The ordinal of the most significant bit in the bit field.\r
1028 Range 0..31.\r
1029 @param Value New value of the bit field.\r
1030\r
1031 @return The value written back to the PCI configuration register.\r
1032\r
1033**/\r
1034UINT32\r
1035EFIAPI\r
1036S3PciBitFieldWrite32 (\r
1037 IN UINTN Address,\r
1038 IN UINTN StartBit,\r
1039 IN UINTN EndBit,\r
1040 IN UINT32 Value\r
1041 )\r
1042{\r
1043 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldWrite32 (Address, StartBit, EndBit, Value));\r
1044}\r
1045\r
1046/**\r
1047 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
1048 writes the result back to the bit field in the 32-bit port and saves the value\r
1049 in the S3 script to be replayed on S3 resume.\r
1050\r
1051 Reads the 32-bit PCI configuration register specified by Address, performs a\r
1052 bitwise OR between the read result and the value specified by\r
1053 OrData, and writes the result to the 32-bit PCI configuration register\r
1054 specified by Address. The value written to the PCI configuration register is\r
1055 returned. This function must guarantee that all PCI read and write operations\r
1056 are serialized. Extra left bits in OrData are stripped.\r
1057\r
1058 If Address > 0x0FFFFFFF, then ASSERT().\r
1059 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
1060 If StartBit is greater than 31, then ASSERT().\r
1061 If EndBit is greater than 31, then ASSERT().\r
1062 If EndBit is less than StartBit, then ASSERT().\r
94952554 1063 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 1064\r
1065 @param Address PCI configuration register to write.\r
1066 @param StartBit The ordinal of the least significant bit in the bit field.\r
1067 Range 0..31.\r
1068 @param EndBit The ordinal of the most significant bit in the bit field.\r
1069 Range 0..31.\r
1070 @param OrData The value to OR with the PCI configuration register.\r
1071\r
1072 @return The value written back to the PCI configuration register.\r
1073\r
1074**/\r
1075UINT32\r
1076EFIAPI\r
1077S3PciBitFieldOr32 (\r
1078 IN UINTN Address,\r
1079 IN UINTN StartBit,\r
1080 IN UINTN EndBit,\r
1081 IN UINT32 OrData\r
1082 )\r
1083{\r
1084 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldOr32 (Address, StartBit, EndBit, OrData));\r
1085}\r
1086\r
1087/**\r
1088 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
1089 AND, and writes the result back to the bit field in the 32-bit register and\r
1090 saves the value in the S3 script to be replayed on S3 resume.\r
1091\r
1092 Reads the 32-bit PCI configuration register specified by Address, performs a\r
1093 bitwise AND between the read result and the value specified by AndData, and\r
1094 writes the result to the 32-bit PCI configuration register specified by\r
1095 Address. The value written to the PCI configuration register is returned.\r
1096 This function must guarantee that all PCI read and write operations are\r
1097 serialized. Extra left bits in AndData are stripped.\r
1098\r
1099 If Address > 0x0FFFFFFF, then ASSERT().\r
1100 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
1101 If StartBit is greater than 31, then ASSERT().\r
1102 If EndBit is greater than 31, then ASSERT().\r
1103 If EndBit is less than StartBit, then ASSERT().\r
94952554 1104 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 1105\r
1106 @param Address PCI configuration register to write.\r
1107 @param StartBit The ordinal of the least significant bit in the bit field.\r
1108 Range 0..31.\r
1109 @param EndBit The ordinal of the most significant bit in the bit field.\r
1110 Range 0..31.\r
1111 @param AndData The value to AND with the PCI configuration register.\r
1112\r
1113 @return The value written back to the PCI configuration register.\r
1114\r
1115**/\r
1116UINT32\r
1117EFIAPI\r
1118S3PciBitFieldAnd32 (\r
1119 IN UINTN Address,\r
1120 IN UINTN StartBit,\r
1121 IN UINTN EndBit,\r
1122 IN UINT32 AndData\r
1123 )\r
1124{\r
1125 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldAnd32 (Address, StartBit, EndBit, AndData));\r
1126}\r
1127\r
1128/**\r
1129 Reads a bit field in a 32-bit Address, performs a bitwise AND followed by a\r
1130 bitwise OR, and writes the result back to the bit field in the\r
1131 32-bit port and saves the value in the S3 script to be replayed on S3 resume.\r
1132\r
1133 Reads the 32-bit PCI configuration register specified by Address, performs a\r
1134 bitwise AND followed by a bitwise OR between the read result and\r
1135 the value specified by AndData, and writes the result to the 32-bit PCI\r
1136 configuration register specified by Address. The value written to the PCI\r
1137 configuration register is returned. This function must guarantee that all PCI\r
1138 read and write operations are serialized. Extra left bits in both AndData and\r
1139 OrData are stripped.\r
1140\r
1141 If Address > 0x0FFFFFFF, then ASSERT().\r
1142 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
1143 If StartBit is greater than 31, then ASSERT().\r
1144 If EndBit is greater than 31, then ASSERT().\r
1145 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
1146 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
1147 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 1148\r
1149 @param Address PCI configuration register to write.\r
1150 @param StartBit The ordinal of the least significant bit in the bit field.\r
1151 Range 0..31.\r
1152 @param EndBit The ordinal of the most significant bit in the bit field.\r
1153 Range 0..31.\r
1154 @param AndData The value to AND with the PCI configuration register.\r
1155 @param OrData The value to OR with the result of the AND operation.\r
1156\r
1157 @return The value written back to the PCI configuration register.\r
1158\r
1159**/\r
1160UINT32\r
1161EFIAPI\r
1162S3PciBitFieldAndThenOr32 (\r
1163 IN UINTN Address,\r
1164 IN UINTN StartBit,\r
1165 IN UINTN EndBit,\r
1166 IN UINT32 AndData,\r
1167 IN UINT32 OrData\r
1168 )\r
1169{\r
1170 return InternalSavePciWrite32ValueToBootScript (Address, PciBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData));\r
1171}\r
1172\r
1173/**\r
1174 Reads a range of PCI configuration registers into a caller supplied buffer\r
1175 and saves the value in the S3 script to be replayed on S3 resume.\r
1176\r
1177 Reads the range of PCI configuration registers specified by StartAddress and\r
1178 Size into the buffer specified by Buffer. This function only allows the PCI\r
1179 configuration registers from a single PCI function to be read. Size is\r
1180 returned. When possible 32-bit PCI configuration read cycles are used to read\r
1181 from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
1182 and 16-bit PCI configuration read cycles may be used at the beginning and the\r
1183 end of the range.\r
1184\r
1185 If StartAddress > 0x0FFFFFFF, then ASSERT().\r
1186 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
1187 If Size > 0 and Buffer is NULL, then ASSERT().\r
1188\r
1189 @param StartAddress Starting address that encodes the PCI Bus, Device,\r
1190 Function and Register.\r
1191 @param Size Size in bytes of the transfer.\r
1192 @param Buffer Pointer to a buffer receiving the data read.\r
1193\r
1194 @return Size\r
1195\r
1196**/\r
1197UINTN\r
1198EFIAPI\r
1199S3PciReadBuffer (\r
1200 IN UINTN StartAddress,\r
1201 IN UINTN Size,\r
1202 OUT VOID *Buffer\r
1203 )\r
1204{\r
1205 RETURN_STATUS Status;\r
1206\r
1207 Status = S3BootScriptSavePciCfgWrite (\r
1208 S3BootScriptWidthUint8,\r
1209 PCILIB_TO_COMMON_ADDRESS (StartAddress),\r
1210 PciReadBuffer (StartAddress, Size, Buffer),\r
1211 Buffer\r
1212 );\r
1213 ASSERT (Status == RETURN_SUCCESS);\r
1214\r
1215 return Size;\r
1216}\r
1217\r
1218/**\r
1219 Copies the data in a caller supplied buffer to a specified range of PCI\r
1220 configuration space and saves the value in the S3 script to be replayed on S3\r
1221 resume.\r
1222\r
1223 Writes the range of PCI configuration registers specified by StartAddress and\r
1224 Size from the buffer specified by Buffer. This function only allows the PCI\r
1225 configuration registers from a single PCI function to be written. Size is\r
1226 returned. When possible 32-bit PCI configuration write cycles are used to\r
1227 write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
1228 8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
1229 and the end of the range.\r
1230\r
1231 If StartAddress > 0x0FFFFFFF, then ASSERT().\r
1232 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
1233 If Size > 0 and Buffer is NULL, then ASSERT().\r
1234\r
1235 @param StartAddress Starting address that encodes the PCI Bus, Device,\r
1236 Function and Register.\r
1237 @param Size Size in bytes of the transfer.\r
1238 @param Buffer Pointer to a buffer containing the data to write.\r
1239\r
1240 @return Size\r
1241\r
1242**/\r
1243UINTN\r
1244EFIAPI\r
1245S3PciWriteBuffer (\r
1246 IN UINTN StartAddress,\r
1247 IN UINTN Size,\r
1248 IN VOID *Buffer\r
1249 )\r
1250{\r
1251 RETURN_STATUS Status;\r
1252\r
1253 Status = S3BootScriptSavePciCfgWrite (\r
1254 S3BootScriptWidthUint8,\r
1255 PCILIB_TO_COMMON_ADDRESS (StartAddress),\r
1256 PciWriteBuffer (StartAddress, Size, Buffer),\r
1257 Buffer\r
1258 );\r
1259 ASSERT (Status == RETURN_SUCCESS);\r
9095d37b 1260\r
fe69ac84 1261 return Size;\r
1262}\r