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