]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/S3PciLib.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Include / Library / S3PciLib.h
CommitLineData
fe69ac84 1/** @file\r
2 The PCI configuration Library Services that carry out PCI configuration and 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#ifndef __S3_PCI_LIB_H__\r
13#define __S3_PCI_LIB_H__\r
14\r
15/**\r
16 Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an\r
17 address that can be passed to the S3 PCI Library functions.\r
18\r
19 @param Bus The PCI Bus number. Range 0..255.\r
20 @param Device The PCI Device number. Range 0..31.\r
21 @param Function The PCI Function number. Range 0..7.\r
22 @param Register The PCI Register number. Range 0..255 for PCI. Range 0..4095\r
23 for PCI Express.\r
24\r
25 @return The encoded PCI address.\r
26\r
27**/\r
2f88bd3a 28#define S3_PCI_LIB_ADDRESS(Bus, Device, Function, Register) \\r
fe69ac84 29 (((Register) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20))\r
30\r
31/**\r
9095d37b
LG
32\r
33 Reads and returns the 8-bit PCI configuration register specified by Address,\r
fe69ac84 34 and saves the value in the S3 script to be replayed on S3 resume.\r
35 This function must guarantee that all PCI read and write operations are\r
36 serialized.\r
37\r
38 If Address > 0x0FFFFFFF, then ASSERT().\r
39\r
40 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
41 Register.\r
42\r
43 @return The value read from the PCI configuration register.\r
44\r
45**/\r
46UINT8\r
47EFIAPI\r
48S3PciRead8 (\r
49 IN UINTN Address\r
50 );\r
51\r
52/**\r
53 Writes an 8-bit PCI configuration register, and saves the value in the S3\r
54 script to be replayed on S3 resume.\r
55\r
56 Writes the 8-bit PCI configuration register specified by Address with the\r
57 value specified by Value. Value is returned. This function must guarantee\r
58 that all PCI read and write operations are serialized.\r
59\r
60 If Address > 0x0FFFFFFF, then ASSERT().\r
61\r
62 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
63 Register.\r
64 @param[in] Value The value to write.\r
65\r
66 @return The value written to the PCI configuration register.\r
67\r
68**/\r
69UINT8\r
70EFIAPI\r
71S3PciWrite8 (\r
72 IN UINTN Address,\r
73 IN UINT8 Value\r
74 );\r
75\r
76/**\r
77 Performs a bitwise OR of an 8-bit PCI configuration register with\r
78 an 8-bit value, and saves the value in the S3 script to be replayed on S3 resume.\r
79\r
80 Reads the 8-bit PCI configuration register specified by Address, performs a\r
81 bitwise OR between the read result and the value specified by\r
82 OrData, and writes the result to the 8-bit PCI configuration register\r
83 specified by Address. The value written to the PCI configuration register is\r
84 returned. This function must guarantee that all PCI read and write operations\r
85 are serialized.\r
86\r
87 If Address > 0x0FFFFFFF, then ASSERT().\r
88\r
89 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
90 Register.\r
91 @param[in] OrData The value to OR with the PCI configuration register.\r
92\r
93 @return The value written back to the PCI configuration register.\r
94\r
95**/\r
96UINT8\r
97EFIAPI\r
98S3PciOr8 (\r
99 IN UINTN Address,\r
100 IN UINT8 OrData\r
101 );\r
102\r
103/**\r
104 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
105 value, and saves the value in the S3 script to be replayed on S3 resume.\r
106\r
107 Reads the 8-bit PCI configuration register specified by Address, performs a\r
108 bitwise AND between the read result and the value specified by AndData, and\r
109 writes the result to the 8-bit PCI configuration register specified by\r
110 Address. The value written to the PCI configuration register is returned.\r
111 This function must guarantee that all PCI read and write operations are\r
112 serialized.\r
113\r
114 If Address > 0x0FFFFFFF, then ASSERT().\r
115\r
116 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
117 Register.\r
118 @param[in] AndData The value to AND with the PCI configuration register.\r
119\r
120 @return The value written back to the PCI configuration register.\r
121\r
122**/\r
123UINT8\r
124EFIAPI\r
125S3PciAnd8 (\r
126 IN UINTN Address,\r
127 IN UINT8 AndData\r
128 );\r
129\r
130/**\r
131 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
132 value, followed a bitwise OR with another 8-bit value, and saves\r
133 the value in the S3 script to be replayed on S3 resume.\r
134\r
135 Reads the 8-bit PCI configuration register specified by Address, performs a\r
136 bitwise AND between the read result and the value specified by AndData,\r
137 performs a bitwise OR between the result of the AND operation and\r
138 the value specified by OrData, and writes the result to the 8-bit PCI\r
139 configuration register specified by Address. The value written to the PCI\r
140 configuration register is returned. This function must guarantee that all PCI\r
141 read and write operations are serialized.\r
142\r
143 If Address > 0x0FFFFFFF, then ASSERT().\r
144\r
145 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
146 Register.\r
147 @param[in] AndData The value to AND with the PCI configuration register.\r
148 @param[in] OrData The value to OR with the result of the AND operation.\r
149\r
150 @return The value written back to the PCI configuration register.\r
151\r
152**/\r
153UINT8\r
154EFIAPI\r
155S3PciAndThenOr8 (\r
156 IN UINTN Address,\r
157 IN UINT8 AndData,\r
158 IN UINT8 OrData\r
159 );\r
160\r
161/**\r
162 Reads a bit field of a PCI configuration register, and saves the value in\r
163 the S3 script to be replayed on S3 resume.\r
164\r
165 Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
166 specified by the StartBit and the EndBit. The value of the bit field is\r
167 returned.\r
168\r
169 If Address > 0x0FFFFFFF, then ASSERT().\r
170 If StartBit is greater than 7, then ASSERT().\r
171 If EndBit is greater than 7, then ASSERT().\r
172 If EndBit is less than StartBit, then ASSERT().\r
173\r
174 @param[in] Address The PCI configuration register to read.\r
175 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
176 Range 0..7.\r
177 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
178 Range 0..7.\r
179\r
180 @return The value of the bit field read from the PCI configuration register.\r
181\r
182**/\r
183UINT8\r
184EFIAPI\r
185S3PciBitFieldRead8 (\r
186 IN UINTN Address,\r
187 IN UINTN StartBit,\r
188 IN UINTN EndBit\r
189 );\r
190\r
191/**\r
192 Writes a bit field to a PCI configuration register, and saves the value in\r
193 the S3 script to be replayed on S3 resume.\r
194\r
195 Writes Value to the bit field of the PCI configuration register. The bit\r
196 field is specified by the StartBit and the EndBit. All other bits in the\r
197 destination PCI configuration register are preserved. The new value of the\r
198 8-bit register is returned.\r
199\r
200 If Address > 0x0FFFFFFF, then ASSERT().\r
201 If StartBit is greater than 7, then ASSERT().\r
202 If EndBit is greater than 7, then ASSERT().\r
203 If EndBit is less than StartBit, then ASSERT().\r
94952554 204 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 205\r
206 @param[in] Address The PCI configuration register to write.\r
207 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
208 Range 0..7.\r
209 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
210 Range 0..7.\r
211 @param[in] Value New value of the bit field.\r
212\r
213 @return The value written back to the PCI configuration register.\r
214\r
215**/\r
216UINT8\r
217EFIAPI\r
218S3PciBitFieldWrite8 (\r
219 IN UINTN Address,\r
220 IN UINTN StartBit,\r
221 IN UINTN EndBit,\r
222 IN UINT8 Value\r
223 );\r
224\r
225/**\r
226 Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
227 writes the result back to the bit field in the 8-bit port, and saves the value\r
228 in the S3 script to be replayed on S3 resume.\r
229\r
230 Reads the 8-bit PCI configuration register specified by Address, performs a\r
231 bitwise OR between the read result and the value specified by\r
232 OrData, and writes the result to the 8-bit PCI configuration register\r
233 specified by Address. The value written to the PCI configuration register is\r
234 returned. This function must guarantee that all PCI read and write operations\r
235 are serialized. Extra left bits in OrData are stripped.\r
236\r
237 If Address > 0x0FFFFFFF, then ASSERT().\r
238 If StartBit is greater than 7, then ASSERT().\r
239 If EndBit is greater than 7, then ASSERT().\r
240 If EndBit is less than StartBit, then ASSERT().\r
94952554 241 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 242\r
243 @param[in] Address The PCI configuration register to write.\r
244 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
245 Range 0..7.\r
246 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
247 Range 0..7.\r
248 @param[in] OrData The value to OR with the PCI configuration register.\r
249\r
250 @return The value written back to the PCI configuration register.\r
251\r
252**/\r
253UINT8\r
254EFIAPI\r
255S3PciBitFieldOr8 (\r
256 IN UINTN Address,\r
257 IN UINTN StartBit,\r
258 IN UINTN EndBit,\r
259 IN UINT8 OrData\r
260 );\r
261\r
262/**\r
263 Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
264 AND, and writes the result back to the bit field in the 8-bit register and\r
265 saves the value in the S3 script to be replayed on S3 resume.\r
266\r
267 Reads the 8-bit PCI configuration register specified by Address, performs a\r
268 bitwise AND between the read result and the value specified by AndData, and\r
269 writes the result to the 8-bit PCI configuration register specified by\r
270 Address. The value written to the PCI configuration register is returned.\r
271 This function must guarantee that all PCI read and write operations are\r
272 serialized. Extra left bits in AndData are stripped.\r
273\r
274 If Address > 0x0FFFFFFF, then ASSERT().\r
275 If StartBit is greater than 7, then ASSERT().\r
276 If EndBit is greater than 7, then ASSERT().\r
277 If EndBit is less than StartBit, then ASSERT().\r
94952554 278 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 279\r
280 @param[in] Address The PCI configuration register to write.\r
281 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
282 Range 0..7.\r
283 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
284 Range 0..7.\r
285 @param[in] AndData The value to AND with the PCI configuration register.\r
286\r
287 @return The value written back to the PCI configuration register.\r
288\r
289**/\r
290UINT8\r
291EFIAPI\r
292S3PciBitFieldAnd8 (\r
293 IN UINTN Address,\r
294 IN UINTN StartBit,\r
295 IN UINTN EndBit,\r
296 IN UINT8 AndData\r
297 );\r
298\r
299/**\r
300 Reads a bit field in an 8-bit Address, performs a bitwise AND followed by a\r
301 bitwise OR, and writes the result back to the bit field in the\r
302 8-bit port, and saves the value in the S3 script to be replayed on S3 resume.\r
303\r
304 Reads the 8-bit PCI configuration register specified by Address, performs a\r
305 bitwise AND followed by a bitwise OR between the read result and\r
306 the value specified by AndData, and writes the result to the 8-bit PCI\r
307 configuration register specified by Address. The value written to the PCI\r
308 configuration register is returned. This function must guarantee that all PCI\r
309 read and write operations are serialized. Extra left bits in both AndData and\r
310 OrData are stripped.\r
311\r
312 If Address > 0x0FFFFFFF, then ASSERT().\r
313 If StartBit is greater than 7, then ASSERT().\r
314 If EndBit is greater than 7, then ASSERT().\r
315 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
316 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
317 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 318\r
319 @param[in] Address The PCI configuration register to write.\r
320 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
321 Range 0..7.\r
322 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
323 Range 0..7.\r
324 @param[in] AndData The value to AND with the PCI configuration register.\r
325 @param[in] OrData The value to OR with the result of the AND operation.\r
326\r
327 @return The value written back to the PCI configuration register.\r
328\r
329**/\r
330UINT8\r
331EFIAPI\r
332S3PciBitFieldAndThenOr8 (\r
333 IN UINTN Address,\r
334 IN UINTN StartBit,\r
335 IN UINTN EndBit,\r
336 IN UINT8 AndData,\r
337 IN UINT8 OrData\r
338 );\r
339\r
340/**\r
341 Reads a 16-bit PCI configuration register, and saves the value in the S3\r
342 script to be replayed on S3 resume.\r
343\r
344 Reads and returns the 16-bit PCI configuration register specified by Address.\r
345 This function must guarantee that all PCI read and write operations are\r
346 serialized.\r
347\r
348 If Address > 0x0FFFFFFF, then ASSERT().\r
349 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
350\r
351 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
352 Register.\r
353\r
354 @return The read value from the PCI configuration register.\r
355\r
356**/\r
357UINT16\r
358EFIAPI\r
359S3PciRead16 (\r
360 IN UINTN Address\r
361 );\r
362\r
363/**\r
364 Writes a 16-bit PCI configuration register, and saves the value in the S3\r
365 script to be replayed on S3 resume.\r
366\r
367 Writes the 16-bit PCI configuration register specified by Address with the\r
368 value specified by Value. Value is returned. This function must guarantee\r
369 that all PCI read and write operations are serialized.\r
370\r
371 If Address > 0x0FFFFFFF, then ASSERT().\r
372 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
373\r
374 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
375 Register.\r
376 @param[in] Value The value to write.\r
377\r
378 @return The value written to the PCI configuration register.\r
379\r
380**/\r
381UINT16\r
382EFIAPI\r
383S3PciWrite16 (\r
384 IN UINTN Address,\r
385 IN UINT16 Value\r
386 );\r
387\r
388/**\r
389 Performs a bitwise OR of a 16-bit PCI configuration register with\r
390 a 16-bit value, and saves the value in the S3 script to be replayed on S3 resume.\r
391\r
392 Reads the 16-bit PCI configuration register specified by Address, performs a\r
393 bitwise OR between the read result and the value specified by\r
394 OrData, and writes the result to the 16-bit PCI configuration register\r
395 specified by Address. The value written to the PCI configuration register is\r
396 returned. This function must guarantee that all PCI read and write operations\r
397 are serialized.\r
398\r
399 If Address > 0x0FFFFFFF, then ASSERT().\r
400 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
401\r
402 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
403 Register.\r
404 @param[in] OrData The value to OR with the PCI configuration register.\r
405\r
406 @return The value written back to the PCI configuration register.\r
407\r
408**/\r
409UINT16\r
410EFIAPI\r
411S3PciOr16 (\r
412 IN UINTN Address,\r
413 IN UINT16 OrData\r
414 );\r
415\r
416/**\r
417 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
418 value, and saves the value in the S3 script to be replayed on S3 resume.\r
419\r
420 Reads the 16-bit PCI configuration register specified by Address, performs a\r
421 bitwise AND between the read result and the value specified by AndData, and\r
422 writes the result to the 16-bit PCI configuration register specified by\r
423 Address. The value written to the PCI configuration register is returned.\r
424 This function must guarantee that all PCI read and write operations are\r
425 serialized.\r
426\r
427 If Address > 0x0FFFFFFF, then ASSERT().\r
428 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
429\r
430 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
431 Register.\r
432 @param[in] AndData The value to AND with the PCI configuration register.\r
433\r
434 @return The value written back to the PCI configuration register.\r
435\r
436**/\r
437UINT16\r
438EFIAPI\r
439S3PciAnd16 (\r
440 IN UINTN Address,\r
441 IN UINT16 AndData\r
442 );\r
443\r
444/**\r
445 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
446 value, followed a bitwise OR with another 16-bit value, and saves\r
447 the value in the S3 script to be replayed on S3 resume.\r
448\r
449 Reads the 16-bit PCI configuration register specified by Address, performs a\r
450 bitwise AND between the read result and the value specified by AndData,\r
451 performs a bitwise OR between the result of the AND operation and\r
452 the value specified by OrData, and writes the result to the 16-bit PCI\r
453 configuration register specified by Address. The value written to the PCI\r
454 configuration register is returned. This function must guarantee that all PCI\r
455 read and write operations are serialized.\r
456\r
457 If Address > 0x0FFFFFFF, then ASSERT().\r
458 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
459\r
460 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
461 Register.\r
462 @param[in] AndData The value to AND with the PCI configuration register.\r
463 @param[in] OrData The value to OR with the result of the AND operation.\r
464\r
465 @return The value written back to the PCI configuration register.\r
466\r
467**/\r
468UINT16\r
469EFIAPI\r
470S3PciAndThenOr16 (\r
471 IN UINTN Address,\r
472 IN UINT16 AndData,\r
473 IN UINT16 OrData\r
474 );\r
475\r
476/**\r
477 Reads a bit field of a PCI configuration register, and saves the value in\r
478 the S3 script to be replayed on S3 resume.\r
479\r
480 Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
481 specified by the StartBit and the EndBit. The value of the bit field is\r
482 returned.\r
483\r
484 If Address > 0x0FFFFFFF, then ASSERT().\r
485 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
486 If StartBit is greater than 15, then ASSERT().\r
487 If EndBit is greater than 15, then ASSERT().\r
488 If EndBit is less than StartBit, then ASSERT().\r
489\r
490 @param[in] Address The PCI configuration register to read.\r
491 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
492 Range 0..15.\r
493 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
494 Range 0..15.\r
495\r
496 @return The value of the bit field read from the PCI configuration register.\r
497\r
498**/\r
499UINT16\r
500EFIAPI\r
501S3PciBitFieldRead16 (\r
502 IN UINTN Address,\r
503 IN UINTN StartBit,\r
504 IN UINTN EndBit\r
505 );\r
506\r
507/**\r
508 Writes a bit field to a PCI configuration register, and saves the value in\r
509 the S3 script to be replayed on S3 resume.\r
510\r
511 Writes Value to the bit field of the PCI configuration register. The bit\r
512 field is specified by the StartBit and the EndBit. All other bits in the\r
513 destination PCI configuration register are preserved. The new value of the\r
514 16-bit register is returned.\r
515\r
516 If Address > 0x0FFFFFFF, then ASSERT().\r
517 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
518 If StartBit is greater than 15, then ASSERT().\r
519 If EndBit is greater than 15, then ASSERT().\r
520 If EndBit is less than StartBit, then ASSERT().\r
94952554 521 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 522\r
523 @param[in] Address The PCI configuration register to write.\r
524 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
525 Range 0..15.\r
526 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
527 Range 0..15.\r
528 @param[in] Value New value of the bit field.\r
529\r
530 @return The value written back to the PCI configuration register.\r
531\r
532**/\r
533UINT16\r
534EFIAPI\r
535S3PciBitFieldWrite16 (\r
536 IN UINTN Address,\r
537 IN UINTN StartBit,\r
538 IN UINTN EndBit,\r
539 IN UINT16 Value\r
540 );\r
541\r
542/**\r
543 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
544 writes the result back to the bit field in the 16-bit port, and saves the value\r
545 in the S3 script to be replayed on S3 resume.\r
546\r
547 Reads the 16-bit PCI configuration register specified by Address, performs a\r
548 bitwise OR between the read result and the value specified by\r
549 OrData, and writes the result to the 16-bit PCI configuration register\r
550 specified by Address. The value written to the PCI configuration register is\r
551 returned. This function must guarantee that all PCI read and write operations\r
552 are serialized. Extra left bits in OrData are stripped.\r
553\r
554 If Address > 0x0FFFFFFF, then ASSERT().\r
555 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
556 If StartBit is greater than 15, then ASSERT().\r
557 If EndBit is greater than 15, then ASSERT().\r
558 If EndBit is less than StartBit, then ASSERT().\r
94952554 559 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 560\r
561 @param[in] Address The PCI configuration register to write.\r
562 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
563 Range 0..15.\r
564 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
565 Range 0..15.\r
566 @param[in] OrData The value to OR with the PCI configuration register.\r
567\r
568 @return The value written back to the PCI configuration register.\r
569\r
570**/\r
571UINT16\r
572EFIAPI\r
573S3PciBitFieldOr16 (\r
574 IN UINTN Address,\r
575 IN UINTN StartBit,\r
576 IN UINTN EndBit,\r
577 IN UINT16 OrData\r
578 );\r
579\r
580/**\r
581 Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
582 AND, and writes the result back to the bit field in the 16-bit register and\r
583 saves the value in the S3 script to be replayed on S3 resume.\r
584\r
585 Reads the 16-bit PCI configuration register specified by Address, performs a\r
586 bitwise AND between the read result and the value specified by AndData, and\r
587 writes the result to the 16-bit PCI configuration register specified by\r
588 Address. The value written to the PCI configuration register is returned.\r
589 This function must guarantee that all PCI read and write operations are\r
590 serialized. Extra left bits in AndData are stripped.\r
591\r
592 If Address > 0x0FFFFFFF, then ASSERT().\r
593 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
594 If StartBit is greater than 15, then ASSERT().\r
595 If EndBit is greater than 15, then ASSERT().\r
596 If EndBit is less than StartBit, then ASSERT().\r
94952554 597 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 598\r
599 @param[in] Address The PCI configuration register to write.\r
600 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
601 Range 0..15.\r
602 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
603 Range 0..15.\r
604 @param[in] AndData The value to AND with the PCI configuration register.\r
605\r
606 @return The value written back to the PCI configuration register.\r
607\r
608**/\r
609UINT16\r
610EFIAPI\r
611S3PciBitFieldAnd16 (\r
612 IN UINTN Address,\r
613 IN UINTN StartBit,\r
614 IN UINTN EndBit,\r
615 IN UINT16 AndData\r
616 );\r
617\r
618/**\r
619 Reads a bit field in a 16-bit Address, performs a bitwise AND followed by a\r
620 bitwise OR, and writes the result back to the bit field in the\r
621 16-bit port, and saves the value in the S3 script to be replayed on S3 resume.\r
622\r
623 Reads the 16-bit PCI configuration register specified by Address, performs a\r
624 bitwise AND followed by a bitwise OR between the read result and\r
625 the value specified by AndData, and writes the result to the 16-bit PCI\r
626 configuration register specified by Address. The value written to the PCI\r
627 configuration register is returned. This function must guarantee that all PCI\r
628 read and write operations are serialized. Extra left bits in both AndData and\r
629 OrData are stripped.\r
630\r
631 If Address > 0x0FFFFFFF, then ASSERT().\r
632 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
633 If StartBit is greater than 15, then ASSERT().\r
634 If EndBit is greater than 15, then ASSERT().\r
635 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
636 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
637 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 638\r
639 @param[in] Address The PCI configuration register to write.\r
640 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
641 Range 0..15.\r
642 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
643 Range 0..15.\r
644 @param[in] AndData The value to AND with the PCI configuration register.\r
645 @param[in] OrData The value to OR with the result of the AND operation.\r
646\r
647 @return The value written back to the PCI configuration register.\r
648\r
649**/\r
650UINT16\r
651EFIAPI\r
652S3PciBitFieldAndThenOr16 (\r
653 IN UINTN Address,\r
654 IN UINTN StartBit,\r
655 IN UINTN EndBit,\r
656 IN UINT16 AndData,\r
657 IN UINT16 OrData\r
658 );\r
659\r
660/**\r
661 Reads a 32-bit PCI configuration register, and saves the value in the S3\r
662 script to be replayed on S3 resume.\r
663\r
664 Reads and returns the 32-bit PCI configuration register specified by Address.\r
665 This function must guarantee that all PCI read and write operations are\r
666 serialized.\r
667\r
668 If Address > 0x0FFFFFFF, then ASSERT().\r
669 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
670\r
671 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
672 Register.\r
673\r
674 @return The read value from the PCI configuration register.\r
675\r
676**/\r
677UINT32\r
678EFIAPI\r
679S3PciRead32 (\r
680 IN UINTN Address\r
681 );\r
682\r
683/**\r
684 Writes a 32-bit PCI configuration register, and saves the value in the S3\r
685 script to be replayed on S3 resume.\r
686\r
687 Writes the 32-bit PCI configuration register specified by Address with the\r
688 value specified by Value. Value is returned. This function must guarantee\r
689 that all PCI read and write operations are serialized.\r
690\r
691 If Address > 0x0FFFFFFF, then ASSERT().\r
692 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
693\r
694 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
695 Register.\r
696 @param[in] Value The value to write.\r
697\r
698 @return The value written to the PCI configuration register.\r
699\r
700**/\r
701UINT32\r
702EFIAPI\r
703S3PciWrite32 (\r
704 IN UINTN Address,\r
705 IN UINT32 Value\r
706 );\r
707\r
708/**\r
709 Performs a bitwise OR of a 32-bit PCI configuration register with\r
710 a 32-bit value, and saves the value in the S3 script to be replayed on S3 resume.\r
711\r
712 Reads the 32-bit PCI configuration register specified by Address, performs a\r
713 bitwise OR between the read result and the value specified by\r
714 OrData, and writes the result to the 32-bit PCI configuration register\r
715 specified by Address. The value written to the PCI configuration register is\r
716 returned. This function must guarantee that all PCI read and write operations\r
717 are serialized.\r
718\r
719 If Address > 0x0FFFFFFF, then ASSERT().\r
720 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
721\r
722 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
723 Register.\r
724 @param[in] OrData The value to OR with the PCI configuration register.\r
725\r
726 @return The value written back to the PCI configuration register.\r
727\r
728**/\r
729UINT32\r
730EFIAPI\r
731S3PciOr32 (\r
732 IN UINTN Address,\r
733 IN UINT32 OrData\r
734 );\r
735\r
736/**\r
737 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
738 value, and saves the value in the S3 script to be replayed on S3 resume.\r
739\r
740 Reads the 32-bit PCI configuration register specified by Address, performs a\r
741 bitwise AND between the read result and the value specified by AndData, and\r
742 writes the result to the 32-bit PCI configuration register specified by\r
743 Address. The value written to the PCI configuration register is returned.\r
744 This function must guarantee that all PCI read and write operations are\r
745 serialized.\r
746\r
747 If Address > 0x0FFFFFFF, then ASSERT().\r
748 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
749\r
750 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
751 Register.\r
752 @param[in] AndData The value to AND with the PCI configuration register.\r
753\r
754 @return The value written back to the PCI configuration register.\r
755\r
756**/\r
757UINT32\r
758EFIAPI\r
759S3PciAnd32 (\r
760 IN UINTN Address,\r
761 IN UINT32 AndData\r
762 );\r
763\r
764/**\r
765 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
766 value, followed a bitwise OR with another 32-bit value, and saves\r
767 the value in the S3 script to be replayed on S3 resume.\r
768\r
769 Reads the 32-bit PCI configuration register specified by Address, performs a\r
770 bitwise AND between the read result and the value specified by AndData,\r
771 performs a bitwise OR between the result of the AND operation and\r
772 the value specified by OrData, and writes the result to the 32-bit PCI\r
773 configuration register specified by Address. The value written to the PCI\r
774 configuration register is returned. This function must guarantee that all PCI\r
775 read and write operations are serialized.\r
776\r
777 If Address > 0x0FFFFFFF, then ASSERT().\r
778 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
779\r
780 @param[in] Address The address that encodes the PCI Bus, Device, Function and\r
781 Register.\r
782 @param[in] AndData The value to AND with the PCI configuration register.\r
783 @param[in] OrData The value to OR with the result of the AND operation.\r
784\r
785 @return The value written back to the PCI configuration register.\r
786\r
787**/\r
788UINT32\r
789EFIAPI\r
790S3PciAndThenOr32 (\r
791 IN UINTN Address,\r
792 IN UINT32 AndData,\r
793 IN UINT32 OrData\r
794 );\r
795\r
796/**\r
797 Reads a bit field of a PCI configuration register, and saves the value in\r
798 the S3 script to be replayed on S3 resume.\r
799\r
800 Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
801 specified by the StartBit and the EndBit. The value of the bit field is\r
802 returned.\r
803\r
804 If Address > 0x0FFFFFFF, then ASSERT().\r
805 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
806 If StartBit is greater than 31, then ASSERT().\r
807 If EndBit is greater than 31, then ASSERT().\r
808 If EndBit is less than StartBit, then ASSERT().\r
9095d37b 809\r
fe69ac84 810 @param[in] Address The PCI configuration register to read.\r
811 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
812 Range 0..31.\r
813 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
814 Range 0..31.\r
815\r
816 @return The value of the bit field read from the PCI configuration register.\r
817\r
818**/\r
819UINT32\r
820EFIAPI\r
821S3PciBitFieldRead32 (\r
822 IN UINTN Address,\r
823 IN UINTN StartBit,\r
824 IN UINTN EndBit\r
825 );\r
826\r
827/**\r
828 Writes a bit field to a PCI configuration register, and saves the value in\r
829 the S3 script to be replayed on S3 resume.\r
830\r
831 Writes Value to the bit field of the PCI configuration register. The bit\r
832 field is specified by the StartBit and the EndBit. All other bits in the\r
833 destination PCI configuration register are preserved. The new value of the\r
834 32-bit register is returned.\r
835\r
836 If Address > 0x0FFFFFFF, then ASSERT().\r
837 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
838 If StartBit is greater than 31, then ASSERT().\r
839 If EndBit is greater than 31, then ASSERT().\r
840 If EndBit is less than StartBit, then ASSERT().\r
94952554 841 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 842\r
843 @param[in] Address The PCI configuration register to write.\r
844 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
845 Range 0..31.\r
846 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
847 Range 0..31.\r
848 @param[in] Value New value of the bit field.\r
849\r
850 @return The value written back to the PCI configuration register.\r
851\r
852**/\r
853UINT32\r
854EFIAPI\r
855S3PciBitFieldWrite32 (\r
856 IN UINTN Address,\r
857 IN UINTN StartBit,\r
858 IN UINTN EndBit,\r
859 IN UINT32 Value\r
860 );\r
861\r
862/**\r
863 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
864 writes the result back to the bit field in the 32-bit port, and saves the value\r
865 in the S3 script to be replayed on S3 resume.\r
866\r
867 Reads the 32-bit PCI configuration register specified by Address, performs a\r
868 bitwise OR between the read result and the value specified by\r
869 OrData, and writes the result to the 32-bit PCI configuration register\r
870 specified by Address. The value written to the PCI configuration register is\r
871 returned. This function must guarantee that all PCI read and write operations\r
872 are serialized. Extra left bits in OrData are stripped.\r
873\r
874 If Address > 0x0FFFFFFF, then ASSERT().\r
875 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
876 If StartBit is greater than 31, then ASSERT().\r
877 If EndBit is greater than 31, then ASSERT().\r
878 If EndBit is less than StartBit, then ASSERT().\r
94952554 879 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 880\r
881 @param[in] Address The PCI configuration register to write.\r
882 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
883 Range 0..31.\r
884 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
885 Range 0..31.\r
886 @param[in] OrData The value to OR with the PCI configuration register.\r
887\r
888 @return The value written back to the PCI configuration register.\r
889\r
890**/\r
891UINT32\r
892EFIAPI\r
893S3PciBitFieldOr32 (\r
894 IN UINTN Address,\r
895 IN UINTN StartBit,\r
896 IN UINTN EndBit,\r
897 IN UINT32 OrData\r
898 );\r
899\r
900/**\r
901 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
902 AND, and writes the result back to the bit field in the 32-bit register and\r
903 saves the value in the S3 script to be replayed on S3 resume.\r
904\r
905 Reads the 32-bit PCI configuration register specified by Address, performs a\r
906 bitwise AND between the read result and the value specified by AndData, and\r
907 writes the result to the 32-bit PCI configuration register specified by\r
908 Address. The value written to the PCI configuration register is returned.\r
909 This function must guarantee that all PCI read and write operations are\r
910 serialized. Extra left bits in AndData are stripped.\r
911\r
912 If Address > 0x0FFFFFFF, then ASSERT().\r
913 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
914 If StartBit is greater than 31, then ASSERT().\r
915 If EndBit is greater than 31, then ASSERT().\r
916 If EndBit is less than StartBit, then ASSERT().\r
94952554 917 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 918\r
919 @param[in] Address The PCI configuration register to write.\r
920 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
921 Range 0..31.\r
922 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
923 Range 0..31.\r
924 @param[in] 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
931S3PciBitFieldAnd32 (\r
932 IN UINTN Address,\r
933 IN UINTN StartBit,\r
934 IN UINTN EndBit,\r
935 IN UINT32 AndData\r
936 );\r
937\r
938/**\r
939 Reads a bit field in a 32-bit Address, performs a bitwise AND followed by a\r
940 bitwise OR, and writes the result back to the bit field in the\r
941 32-bit port, and saves the value in the S3 script to be replayed on S3 resume.\r
942\r
943 Reads the 32-bit PCI configuration register specified by Address, performs a\r
944 bitwise AND followed by a bitwise OR between the read result and\r
945 the value specified by AndData, and writes the result to the 32-bit PCI\r
946 configuration register specified by Address. The value written to the PCI\r
947 configuration register is returned. This function must guarantee that all PCI\r
948 read and write operations are serialized. Extra left bits in both AndData and\r
949 OrData are stripped.\r
950\r
951 If Address > 0x0FFFFFFF, then ASSERT().\r
952 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
953 If StartBit is greater than 31, then ASSERT().\r
954 If EndBit is greater than 31, then ASSERT().\r
955 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
956 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
957 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
fe69ac84 958\r
959 @param[in] Address The PCI configuration register to write.\r
960 @param[in] StartBit The ordinal of the least significant bit in the bit field.\r
961 Range 0..31.\r
962 @param[in] EndBit The ordinal of the most significant bit in the bit field.\r
963 Range 0..31.\r
964 @param[in] AndData The value to AND with the PCI configuration register.\r
965 @param[in] OrData The value to OR with the result of the AND operation.\r
966\r
967 @return The value written back to the PCI configuration register.\r
968\r
969**/\r
970UINT32\r
971EFIAPI\r
972S3PciBitFieldAndThenOr32 (\r
973 IN UINTN Address,\r
974 IN UINTN StartBit,\r
975 IN UINTN EndBit,\r
976 IN UINT32 AndData,\r
977 IN UINT32 OrData\r
978 );\r
979\r
980/**\r
981 Reads a range of PCI configuration registers into a caller supplied buffer,\r
982 and saves the value in the S3 script to be replayed on S3 resume.\r
983\r
984 Reads the range of PCI configuration registers specified by StartAddress and\r
985 Size into the buffer specified by Buffer. This function only allows the PCI\r
986 configuration registers from a single PCI function to be read. Size is\r
987 returned. When possible 32-bit PCI configuration read cycles are used to read\r
988 from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
989 and 16-bit PCI configuration read cycles may be used at the beginning and the\r
990 end of the range.\r
991\r
992 If StartAddress > 0x0FFFFFFF, then ASSERT().\r
993 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
994 If Size > 0 and Buffer is NULL, then ASSERT().\r
995\r
996 @param[in] StartAddress Starting address that encodes the PCI Bus, Device,\r
997 Function and Register.\r
998 @param[in] Size Size in bytes of the transfer.\r
999 @param[out] Buffer The pointer to a buffer receiving the data read.\r
1000\r
1001 @return Size.\r
1002\r
1003**/\r
1004UINTN\r
1005EFIAPI\r
1006S3PciReadBuffer (\r
1007 IN UINTN StartAddress,\r
1008 IN UINTN Size,\r
1009 OUT VOID *Buffer\r
1010 );\r
1011\r
1012/**\r
1013 Copies the data in a caller supplied buffer to a specified range of PCI\r
1014 configuration space, and saves the value in the S3 script to be replayed on S3\r
1015 resume.\r
1016\r
1017 Writes the range of PCI configuration registers specified by StartAddress and\r
1018 Size from the buffer specified by Buffer. This function only allows the PCI\r
1019 configuration registers from a single PCI function to be written. Size is\r
1020 returned. When possible 32-bit PCI configuration write cycles are used to\r
1021 write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
1022 8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
1023 and the end of the range.\r
1024\r
1025 If StartAddress > 0x0FFFFFFF, then ASSERT().\r
1026 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
1027 If Size > 0 and Buffer is NULL, then ASSERT().\r
1028\r
1029 @param[in] StartAddress Starting address that encodes the PCI Bus, Device,\r
1030 Function and Register.\r
1031 @param[in] Size Size in bytes of the transfer.\r
1032 @param[in] Buffer The pointer to a buffer containing the data to write.\r
1033\r
1034 @return Size.\r
1035\r
1036**/\r
1037UINTN\r
1038EFIAPI\r
1039S3PciWriteBuffer (\r
1040 IN UINTN StartAddress,\r
1041 IN UINTN Size,\r
1042 IN VOID *Buffer\r
1043 );\r
1044\r
1045#endif\r