]>
Commit | Line | Data |
---|---|---|
a2285a89 RN |
1 | /** @file\r |
2 | The multiple segments PCI configuration Library Services that carry out\r | |
3 | PCI configuration and enable the PCI operations to be replayed during an\r | |
4 | S3 resume. This library class maps directly on top of the PciSegmentLib class.\r | |
5 | \r | |
6 | Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r | |
9344f092 | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a2285a89 RN |
8 | \r |
9 | **/\r | |
10 | \r | |
11 | \r | |
12 | #include <Base.h>\r | |
13 | \r | |
14 | #include <Library/DebugLib.h>\r | |
15 | #include <Library/S3BootScriptLib.h>\r | |
16 | #include <Library/PciSegmentLib.h>\r | |
17 | \r | |
18 | /**\r | |
19 | Macro that converts address in PciSegmentLib format to the new address that can be pass\r | |
20 | to the S3 Boot Script Library functions. The Segment is dropped.\r | |
21 | \r | |
22 | @param Address Address in PciSegmentLib format.\r | |
23 | \r | |
24 | @retval New address that can be pass to the S3 Boot Script Library functions.\r | |
25 | **/\r | |
26 | #define PCI_SEGMENT_LIB_ADDRESS_TO_S3_BOOT_SCRIPT_PCI_ADDRESS(Address) \\r | |
27 | ((((UINT32)(Address) >> 20) & 0xff) << 24) | \\r | |
28 | ((((UINT32)(Address) >> 15) & 0x1f) << 16) | \\r | |
29 | ((((UINT32)(Address) >> 12) & 0x07) << 8) | \\r | |
30 | LShiftU64 ((Address) & 0xfff, 32) // Always put Register in high four bytes.\r | |
31 | \r | |
32 | /**\r | |
33 | Saves a PCI configuration value to the boot script.\r | |
34 | \r | |
35 | This internal worker function saves a PCI configuration value in\r | |
36 | the S3 script to be replayed on S3 resume.\r | |
37 | \r | |
38 | If the saving process fails, then ASSERT().\r | |
39 | \r | |
40 | @param Width The width of PCI configuration.\r | |
41 | @param Address Address that encodes the PCI Bus, Device, Function and\r | |
42 | Register.\r | |
43 | @param Buffer The buffer containing value.\r | |
44 | \r | |
45 | **/\r | |
46 | VOID\r | |
47 | InternalSavePciSegmentWriteValueToBootScript (\r | |
48 | IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r | |
49 | IN UINT64 Address,\r | |
50 | IN VOID *Buffer\r | |
51 | )\r | |
52 | {\r | |
53 | RETURN_STATUS Status;\r | |
54 | \r | |
55 | Status = S3BootScriptSavePciCfg2Write (\r | |
56 | Width,\r | |
57 | RShiftU64 ((Address), 32) & 0xffff,\r | |
58 | PCI_SEGMENT_LIB_ADDRESS_TO_S3_BOOT_SCRIPT_PCI_ADDRESS (Address),\r | |
59 | 1,\r | |
60 | Buffer\r | |
61 | );\r | |
62 | ASSERT_RETURN_ERROR (Status);\r | |
63 | }\r | |
64 | \r | |
65 | /**\r | |
66 | Saves an 8-bit PCI configuration value to the boot script.\r | |
67 | \r | |
68 | This internal worker function saves an 8-bit PCI configuration value in\r | |
69 | the S3 script to be replayed on S3 resume.\r | |
70 | \r | |
71 | If the saving process fails, then ASSERT().\r | |
72 | \r | |
73 | @param Address Address that encodes the PCI Bus, Device, Function and\r | |
74 | Register.\r | |
75 | @param Value The value saved to boot script.\r | |
76 | \r | |
77 | @return Value.\r | |
78 | \r | |
79 | **/\r | |
80 | UINT8\r | |
81 | InternalSavePciSegmentWrite8ValueToBootScript (\r | |
82 | IN UINT64 Address,\r | |
83 | IN UINT8 Value\r | |
84 | )\r | |
85 | {\r | |
86 | InternalSavePciSegmentWriteValueToBootScript (S3BootScriptWidthUint8, Address, &Value);\r | |
87 | \r | |
88 | return Value;\r | |
89 | }\r | |
90 | \r | |
91 | /**\r | |
92 | Reads an 8-bit PCI configuration register, and saves the value in the S3 script to\r | |
93 | be replayed on S3 resume.\r | |
94 | \r | |
95 | Reads and returns the 8-bit PCI configuration register specified by Address.\r | |
96 | This function must guarantee that all PCI read and write operations are serialized.\r | |
97 | \r | |
98 | If any reserved bits in Address are set, then ASSERT().\r | |
99 | \r | |
100 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
101 | \r | |
102 | @return The 8-bit PCI configuration register specified by Address.\r | |
103 | \r | |
104 | **/\r | |
105 | UINT8\r | |
106 | EFIAPI\r | |
107 | S3PciSegmentRead8 (\r | |
108 | IN UINT64 Address\r | |
109 | )\r | |
110 | {\r | |
111 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentRead8 (Address));\r | |
112 | }\r | |
113 | \r | |
114 | /**\r | |
115 | Writes an 8-bit PCI configuration register, and saves the value in the S3 script to\r | |
116 | be replayed on S3 resume.\r | |
117 | \r | |
118 | Writes the 8-bit PCI configuration register specified by Address with the value specified by Value.\r | |
119 | Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r | |
120 | \r | |
121 | If any reserved bits in Address are set, then ASSERT().\r | |
122 | \r | |
123 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
124 | @param Value The value to write.\r | |
125 | \r | |
126 | @return The value written to the PCI configuration register.\r | |
127 | \r | |
128 | **/\r | |
129 | UINT8\r | |
130 | EFIAPI\r | |
131 | S3PciSegmentWrite8 (\r | |
132 | IN UINT64 Address,\r | |
133 | IN UINT8 Value\r | |
134 | )\r | |
135 | {\r | |
136 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentWrite8 (Address, Value));\r | |
137 | }\r | |
138 | \r | |
139 | /**\r | |
140 | Performs a bitwise OR of an 8-bit PCI configuration register with an 8-bit value, and saves\r | |
141 | the value in the S3 script to be replayed on S3 resume.\r | |
142 | \r | |
143 | Reads the 8-bit PCI configuration register specified by Address,\r | |
144 | performs a bitwise OR between the read result and the value specified by OrData,\r | |
145 | and writes the result to the 8-bit PCI configuration register specified by Address.\r | |
146 | The value written to the PCI configuration register is returned.\r | |
147 | This function must guarantee that all PCI read and write operations are serialized.\r | |
148 | \r | |
149 | If any reserved bits in Address are set, then ASSERT().\r | |
150 | \r | |
151 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
152 | @param OrData The value to OR with the PCI configuration register.\r | |
153 | \r | |
154 | @return The value written to the PCI configuration register.\r | |
155 | \r | |
156 | **/\r | |
157 | UINT8\r | |
158 | EFIAPI\r | |
159 | S3PciSegmentOr8 (\r | |
160 | IN UINT64 Address,\r | |
161 | IN UINT8 OrData\r | |
162 | )\r | |
163 | {\r | |
164 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentOr8 (Address, OrData));\r | |
165 | }\r | |
166 | \r | |
167 | /**\r | |
168 | Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value, and\r | |
169 | saves the value in the S3 script to be replayed on S3 resume.\r | |
170 | \r | |
171 | Reads the 8-bit PCI configuration register specified by Address,\r | |
172 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
173 | and writes the result to the 8-bit PCI configuration register specified by Address.\r | |
174 | The value written to the PCI configuration register is returned.\r | |
175 | This function must guarantee that all PCI read and write operations are serialized.\r | |
176 | If any reserved bits in Address are set, then ASSERT().\r | |
177 | \r | |
178 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
179 | @param AndData The value to AND with the PCI configuration register.\r | |
180 | \r | |
181 | @return The value written to the PCI configuration register.\r | |
182 | \r | |
183 | **/\r | |
184 | UINT8\r | |
185 | EFIAPI\r | |
186 | S3PciSegmentAnd8 (\r | |
187 | IN UINT64 Address,\r | |
188 | IN UINT8 AndData\r | |
189 | )\r | |
190 | {\r | |
191 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentAnd8 (Address, AndData));\r | |
192 | }\r | |
193 | \r | |
194 | /**\r | |
195 | Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value,\r | |
196 | followed a bitwise OR with another 8-bit value, and saves the value in the S3 script to\r | |
197 | be replayed on S3 resume.\r | |
198 | \r | |
199 | Reads the 8-bit PCI configuration register specified by Address,\r | |
200 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
201 | performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r | |
202 | and writes the result to the 8-bit PCI configuration register specified by Address.\r | |
203 | The value written to the PCI configuration register is returned.\r | |
204 | This function must guarantee that all PCI read and write operations are serialized.\r | |
205 | \r | |
206 | If any reserved bits in Address are set, then ASSERT().\r | |
207 | \r | |
208 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
209 | @param AndData The value to AND with the PCI configuration register.\r | |
210 | @param OrData The value to OR with the PCI configuration register.\r | |
211 | \r | |
212 | @return The value written to the PCI configuration register.\r | |
213 | \r | |
214 | **/\r | |
215 | UINT8\r | |
216 | EFIAPI\r | |
217 | S3PciSegmentAndThenOr8 (\r | |
218 | IN UINT64 Address,\r | |
219 | IN UINT8 AndData,\r | |
220 | IN UINT8 OrData\r | |
221 | )\r | |
222 | {\r | |
223 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentAndThenOr8 (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 the\r | |
228 | 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 any reserved bits in Address are set, 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 | S3PciSegmentBitFieldRead8 (\r | |
251 | IN UINT64 Address,\r | |
252 | IN UINTN StartBit,\r | |
253 | IN UINTN EndBit\r | |
254 | )\r | |
255 | {\r | |
256 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldRead8 (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 any reserved bits in Address are set, 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 | |
272 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
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 | S3PciSegmentBitFieldWrite8 (\r | |
287 | IN UINT64 Address,\r | |
288 | IN UINTN StartBit,\r | |
289 | IN UINTN EndBit,\r | |
290 | IN UINT8 Value\r | |
291 | )\r | |
292 | {\r | |
293 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldWrite8 (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, writes\r | |
298 | the result back to the bit field in the 8-bit port, and saves the value in the\r | |
299 | 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 any reserved bits in Address are set, 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 | |
312 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
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 | S3PciSegmentBitFieldOr8 (\r | |
327 | IN UINT64 Address,\r | |
328 | IN UINTN StartBit,\r | |
329 | IN UINTN EndBit,\r | |
330 | IN UINT8 OrData\r | |
331 | )\r | |
332 | {\r | |
333 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldOr8 (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, 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 any reserved bits in Address are set, 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 | |
352 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
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 | S3PciSegmentBitFieldAnd8 (\r | |
367 | IN UINT64 Address,\r | |
368 | IN UINTN StartBit,\r | |
369 | IN UINTN EndBit,\r | |
370 | IN UINT8 AndData\r | |
371 | )\r | |
372 | {\r | |
373 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldAnd8 (Address, StartBit, EndBit, AndData));\r | |
374 | }\r | |
375 | \r | |
376 | /**\r | |
377 | Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r | |
378 | bitwise OR, writes the result back to the bit field in the 8-bit port,\r | |
379 | 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 any reserved bits in Address are set, 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 | |
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 | |
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 | S3PciSegmentBitFieldAndThenOr8 (\r | |
410 | IN UINT64 Address,\r | |
411 | IN UINTN StartBit,\r | |
412 | IN UINTN EndBit,\r | |
413 | IN UINT8 AndData,\r | |
414 | IN UINT8 OrData\r | |
415 | )\r | |
416 | {\r | |
417 | return InternalSavePciSegmentWrite8ValueToBootScript (Address, PciSegmentBitFieldAndThenOr8 (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 | |
424 | the S3 script to be replayed on S3 resume.\r | |
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 saved to boot script.\r | |
431 | \r | |
432 | @return Value.\r | |
433 | \r | |
434 | **/\r | |
435 | UINT16\r | |
436 | InternalSavePciSegmentWrite16ValueToBootScript (\r | |
437 | IN UINT64 Address,\r | |
438 | IN UINT16 Value\r | |
439 | )\r | |
440 | {\r | |
441 | InternalSavePciSegmentWriteValueToBootScript (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 script\r | |
448 | 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 serialized.\r | |
452 | \r | |
453 | If any reserved bits in Address are set, then ASSERT().\r | |
454 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
455 | \r | |
456 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
457 | \r | |
458 | @return The 16-bit PCI configuration register specified by Address.\r | |
459 | \r | |
460 | **/\r | |
461 | UINT16\r | |
462 | EFIAPI\r | |
463 | S3PciSegmentRead16 (\r | |
464 | IN UINT64 Address\r | |
465 | )\r | |
466 | {\r | |
467 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentRead16 (Address));\r | |
468 | }\r | |
469 | \r | |
470 | /**\r | |
471 | Writes a 16-bit PCI configuration register, and saves the value in the S3 script to\r | |
472 | be replayed on S3 resume.\r | |
473 | \r | |
474 | Writes the 16-bit PCI configuration register specified by Address with the value specified by Value.\r | |
475 | Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r | |
476 | \r | |
477 | If any reserved bits in Address are set, then ASSERT().\r | |
478 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
479 | \r | |
480 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
481 | @param Value The value to write.\r | |
482 | \r | |
483 | @return The parameter of Value.\r | |
484 | \r | |
485 | **/\r | |
486 | UINT16\r | |
487 | EFIAPI\r | |
488 | S3PciSegmentWrite16 (\r | |
489 | IN UINT64 Address,\r | |
490 | IN UINT16 Value\r | |
491 | )\r | |
492 | {\r | |
493 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentWrite16 (Address, Value));\r | |
494 | }\r | |
495 | \r | |
496 | /**\r | |
497 | Performs a bitwise OR of a 16-bit PCI configuration register with a 16-bit\r | |
498 | value, and saves the value in the S3 script to be replayed on S3 resume.\r | |
499 | \r | |
500 | Reads the 16-bit PCI configuration register specified by Address, performs a\r | |
501 | bitwise OR between the read result and the value specified by OrData, and\r | |
502 | writes the result to the 16-bit PCI configuration register specified by Address.\r | |
503 | The value written to the PCI configuration register is returned. This function\r | |
504 | must guarantee that all PCI read and write operations are serialized.\r | |
505 | \r | |
506 | If any reserved bits in Address are set, then ASSERT().\r | |
507 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
508 | \r | |
509 | @param Address Address that encodes the PCI Segment, Bus, Device, Function and\r | |
510 | Register.\r | |
511 | @param OrData The value to OR with the PCI configuration register.\r | |
512 | \r | |
513 | @return The value written back to the PCI configuration register.\r | |
514 | \r | |
515 | **/\r | |
516 | UINT16\r | |
517 | EFIAPI\r | |
518 | S3PciSegmentOr16 (\r | |
519 | IN UINT64 Address,\r | |
520 | IN UINT16 OrData\r | |
521 | )\r | |
522 | {\r | |
523 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentOr16 (Address, OrData));\r | |
524 | }\r | |
525 | \r | |
526 | /**\r | |
527 | Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value, and\r | |
528 | saves the value in the S3 script to be replayed on S3 resume.\r | |
529 | \r | |
530 | Reads the 16-bit PCI configuration register specified by Address,\r | |
531 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
532 | and writes the result to the 16-bit PCI configuration register specified by Address.\r | |
533 | The value written to the PCI configuration register is returned.\r | |
534 | This function must guarantee that all PCI read and write operations are serialized.\r | |
535 | \r | |
536 | If any reserved bits in Address are set, then ASSERT().\r | |
537 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
538 | \r | |
539 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
540 | @param AndData The value to AND with the PCI configuration register.\r | |
541 | \r | |
542 | @return The value written to the PCI configuration register.\r | |
543 | \r | |
544 | **/\r | |
545 | UINT16\r | |
546 | EFIAPI\r | |
547 | S3PciSegmentAnd16 (\r | |
548 | IN UINT64 Address,\r | |
549 | IN UINT16 AndData\r | |
550 | )\r | |
551 | {\r | |
552 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentAnd16 (Address, AndData));\r | |
553 | }\r | |
554 | \r | |
555 | /**\r | |
556 | Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value,\r | |
557 | followed a bitwise OR with another 16-bit value, and saves the value in the S3 script to\r | |
558 | be replayed on S3 resume.\r | |
559 | \r | |
560 | Reads the 16-bit PCI configuration register specified by Address,\r | |
561 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
562 | performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r | |
563 | and writes the result to the 16-bit PCI configuration register specified by Address.\r | |
564 | The value written to the PCI configuration register is returned.\r | |
565 | This function must guarantee that all PCI read and write operations are serialized.\r | |
566 | \r | |
567 | If any reserved bits in Address are set, then ASSERT().\r | |
568 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
569 | \r | |
570 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
571 | @param AndData The value to AND with the PCI configuration register.\r | |
572 | @param OrData The value to OR with the PCI configuration register.\r | |
573 | \r | |
574 | @return The value written to the PCI configuration register.\r | |
575 | \r | |
576 | **/\r | |
577 | UINT16\r | |
578 | EFIAPI\r | |
579 | S3PciSegmentAndThenOr16 (\r | |
580 | IN UINT64 Address,\r | |
581 | IN UINT16 AndData,\r | |
582 | IN UINT16 OrData\r | |
583 | )\r | |
584 | {\r | |
585 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentAndThenOr16 (Address, AndData, OrData));\r | |
586 | }\r | |
587 | \r | |
588 | /**\r | |
589 | Reads a bit field of a PCI configuration register, and saves the value in the\r | |
590 | S3 script to be replayed on S3 resume.\r | |
591 | \r | |
592 | Reads the bit field in a 16-bit PCI configuration register. The bit field is\r | |
593 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
594 | returned.\r | |
595 | \r | |
596 | If any reserved bits in Address are set, then ASSERT().\r | |
597 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
598 | If StartBit is greater than 15, then ASSERT().\r | |
599 | If EndBit is greater than 15, then ASSERT().\r | |
600 | If EndBit is less than StartBit, then ASSERT().\r | |
601 | \r | |
602 | @param Address PCI configuration register to read.\r | |
603 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
604 | Range 0..15.\r | |
605 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
606 | Range 0..15.\r | |
607 | \r | |
608 | @return The value of the bit field read from the PCI configuration register.\r | |
609 | \r | |
610 | **/\r | |
611 | UINT16\r | |
612 | EFIAPI\r | |
613 | S3PciSegmentBitFieldRead16 (\r | |
614 | IN UINT64 Address,\r | |
615 | IN UINTN StartBit,\r | |
616 | IN UINTN EndBit\r | |
617 | )\r | |
618 | {\r | |
619 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldRead16 (Address, StartBit, EndBit));\r | |
620 | }\r | |
621 | \r | |
622 | /**\r | |
623 | Writes a bit field to a PCI configuration register, and saves the value in\r | |
624 | the S3 script to be replayed on S3 resume.\r | |
625 | \r | |
626 | Writes Value to the bit field of the PCI configuration register. The bit\r | |
627 | field is specified by the StartBit and the EndBit. All other bits in the\r | |
628 | destination PCI configuration register are preserved. The new value of the\r | |
629 | 16-bit register is returned.\r | |
630 | \r | |
631 | If any reserved bits in Address are set, 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 | |
636 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
637 | \r | |
638 | @param Address PCI configuration register to write.\r | |
639 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
640 | Range 0..15.\r | |
641 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
642 | Range 0..15.\r | |
643 | @param Value New value of the bit field.\r | |
644 | \r | |
645 | @return The value written back to the PCI configuration register.\r | |
646 | \r | |
647 | **/\r | |
648 | UINT16\r | |
649 | EFIAPI\r | |
650 | S3PciSegmentBitFieldWrite16 (\r | |
651 | IN UINT64 Address,\r | |
652 | IN UINTN StartBit,\r | |
653 | IN UINTN EndBit,\r | |
654 | IN UINT16 Value\r | |
655 | )\r | |
656 | {\r | |
657 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldWrite16 (Address, StartBit, EndBit, Value));\r | |
658 | }\r | |
659 | \r | |
660 | /**\r | |
661 | Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, writes\r | |
662 | the result back to the bit field in the 16-bit port, and saves the value in the\r | |
663 | S3 script to be replayed on S3 resume.\r | |
664 | \r | |
665 | Reads the 16-bit PCI configuration register specified by Address, performs a\r | |
666 | bitwise OR between the read result and the value specified by\r | |
667 | OrData, and writes the result to the 16-bit PCI configuration register\r | |
668 | specified by Address. The value written to the PCI configuration register is\r | |
669 | returned. This function must guarantee that all PCI read and write operations\r | |
670 | are serialized. Extra left bits in OrData are stripped.\r | |
671 | \r | |
672 | If any reserved bits in Address are set, then ASSERT().\r | |
673 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
674 | If StartBit is greater than 15, then ASSERT().\r | |
675 | If EndBit is greater than 15, then ASSERT().\r | |
676 | If EndBit is less than StartBit, then ASSERT().\r | |
677 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
678 | \r | |
679 | @param Address PCI configuration register to write.\r | |
680 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
681 | Range 0..15.\r | |
682 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
683 | Range 0..15.\r | |
684 | @param OrData The value to OR with the PCI configuration register.\r | |
685 | \r | |
686 | @return The value written back to the PCI configuration register.\r | |
687 | \r | |
688 | **/\r | |
689 | UINT16\r | |
690 | EFIAPI\r | |
691 | S3PciSegmentBitFieldOr16 (\r | |
692 | IN UINT64 Address,\r | |
693 | IN UINTN StartBit,\r | |
694 | IN UINTN EndBit,\r | |
695 | IN UINT16 OrData\r | |
696 | )\r | |
697 | {\r | |
698 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldOr16 (Address, StartBit, EndBit, OrData));\r | |
699 | }\r | |
700 | \r | |
701 | /**\r | |
702 | Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r | |
703 | AND, writes the result back to the bit field in the 16-bit register, and\r | |
704 | saves the value in the S3 script to be replayed on S3 resume.\r | |
705 | \r | |
706 | Reads the 16-bit PCI configuration register specified by Address, performs a\r | |
707 | bitwise AND between the read result and the value specified by AndData, and\r | |
708 | writes the result to the 16-bit PCI configuration register specified by\r | |
709 | Address. The value written to the PCI configuration register is returned.\r | |
710 | This function must guarantee that all PCI read and write operations are\r | |
711 | serialized. Extra left bits in AndData are stripped.\r | |
712 | \r | |
713 | If any reserved bits in Address are set, then ASSERT().\r | |
714 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
715 | If StartBit is greater than 15, then ASSERT().\r | |
716 | If EndBit is greater than 15, then ASSERT().\r | |
717 | If EndBit is less than StartBit, then ASSERT().\r | |
718 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
719 | \r | |
720 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
721 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
722 | Range 0..15.\r | |
723 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
724 | Range 0..15.\r | |
725 | @param AndData The value to AND with the PCI configuration register.\r | |
726 | \r | |
727 | @return The value written back to the PCI configuration register.\r | |
728 | \r | |
729 | **/\r | |
730 | UINT16\r | |
731 | EFIAPI\r | |
732 | S3PciSegmentBitFieldAnd16 (\r | |
733 | IN UINT64 Address,\r | |
734 | IN UINTN StartBit,\r | |
735 | IN UINTN EndBit,\r | |
736 | IN UINT16 AndData\r | |
737 | )\r | |
738 | {\r | |
739 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldAnd16 (Address, StartBit, EndBit, AndData));\r | |
740 | }\r | |
741 | \r | |
742 | /**\r | |
743 | Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r | |
744 | bitwise OR, writes the result back to the bit field in the 16-bit port,\r | |
745 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
746 | \r | |
747 | Reads the 16-bit PCI configuration register specified by Address, performs a\r | |
748 | bitwise AND followed by a bitwise OR between the read result and\r | |
749 | the value specified by AndData, and writes the result to the 16-bit PCI\r | |
750 | configuration register specified by Address. The value written to the PCI\r | |
751 | configuration register is returned. This function must guarantee that all PCI\r | |
752 | read and write operations are serialized. Extra left bits in both AndData and\r | |
753 | OrData are stripped.\r | |
754 | \r | |
755 | If any reserved bits in Address are set, then ASSERT().\r | |
756 | If StartBit is greater than 15, then ASSERT().\r | |
757 | If EndBit is greater than 15, then ASSERT().\r | |
758 | If EndBit is less than StartBit, then ASSERT().\r | |
759 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
760 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
761 | \r | |
762 | @param Address PCI configuration register to write.\r | |
763 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
764 | Range 0..15.\r | |
765 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
766 | Range 0..15.\r | |
767 | @param AndData The value to AND with the PCI configuration register.\r | |
768 | @param OrData The value to OR with the result of the AND operation.\r | |
769 | \r | |
770 | @return The value written back to the PCI configuration register.\r | |
771 | \r | |
772 | **/\r | |
773 | UINT16\r | |
774 | EFIAPI\r | |
775 | S3PciSegmentBitFieldAndThenOr16 (\r | |
776 | IN UINT64 Address,\r | |
777 | IN UINTN StartBit,\r | |
778 | IN UINTN EndBit,\r | |
779 | IN UINT16 AndData,\r | |
780 | IN UINT16 OrData\r | |
781 | )\r | |
782 | {\r | |
783 | return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData));\r | |
784 | }\r | |
785 | \r | |
786 | \r | |
787 | \r | |
788 | /**\r | |
789 | Saves a 32-bit PCI configuration value to the boot script.\r | |
790 | \r | |
791 | This internal worker function saves a 32-bit PCI configuration value in the S3 script\r | |
792 | to be replayed on S3 resume.\r | |
793 | \r | |
794 | If the saving process fails, then ASSERT().\r | |
795 | \r | |
796 | @param Address Address that encodes the PCI Bus, Device, Function and\r | |
797 | Register.\r | |
798 | @param Value The value saved to boot script.\r | |
799 | \r | |
800 | @return Value.\r | |
801 | \r | |
802 | **/\r | |
803 | UINT32\r | |
804 | InternalSavePciSegmentWrite32ValueToBootScript (\r | |
805 | IN UINT64 Address,\r | |
806 | IN UINT32 Value\r | |
807 | )\r | |
808 | {\r | |
809 | InternalSavePciSegmentWriteValueToBootScript (S3BootScriptWidthUint32, Address, &Value);\r | |
810 | \r | |
811 | return Value;\r | |
812 | }\r | |
813 | \r | |
814 | /**\r | |
815 | Reads a 32-bit PCI configuration register, and saves the value in the S3 script\r | |
816 | to be replayed on S3 resume.\r | |
817 | \r | |
818 | Reads and returns the 32-bit PCI configuration register specified by Address.\r | |
819 | This function must guarantee that all PCI read and write operations are serialized.\r | |
820 | \r | |
821 | If any reserved bits in Address are set, then ASSERT().\r | |
822 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
823 | \r | |
824 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
825 | \r | |
826 | @return The 32-bit PCI configuration register specified by Address.\r | |
827 | \r | |
828 | **/\r | |
829 | UINT32\r | |
830 | EFIAPI\r | |
831 | S3PciSegmentRead32 (\r | |
832 | IN UINT64 Address\r | |
833 | )\r | |
834 | {\r | |
835 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentRead32 (Address));\r | |
836 | }\r | |
837 | \r | |
838 | /**\r | |
839 | Writes a 32-bit PCI configuration register, and saves the value in the S3 script to\r | |
840 | be replayed on S3 resume.\r | |
841 | \r | |
842 | Writes the 32-bit PCI configuration register specified by Address with the value specified by Value.\r | |
843 | Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r | |
844 | \r | |
845 | If any reserved bits in Address are set, then ASSERT().\r | |
846 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
847 | \r | |
848 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
849 | @param Value The value to write.\r | |
850 | \r | |
851 | @return The parameter of Value.\r | |
852 | \r | |
853 | **/\r | |
854 | UINT32\r | |
855 | EFIAPI\r | |
856 | S3PciSegmentWrite32 (\r | |
857 | IN UINT64 Address,\r | |
858 | IN UINT32 Value\r | |
859 | )\r | |
860 | {\r | |
861 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentWrite32 (Address, Value));\r | |
862 | }\r | |
863 | \r | |
864 | /**\r | |
865 | Performs a bitwise OR of a 32-bit PCI configuration register with a 32-bit\r | |
866 | value, and saves the value in the S3 script to be replayed on S3 resume.\r | |
867 | \r | |
868 | Reads the 32-bit PCI configuration register specified by Address, performs a\r | |
869 | bitwise OR between the read result and the value specified by OrData, and\r | |
870 | writes the result to the 32-bit PCI configuration register specified by Address.\r | |
871 | The value written to the PCI configuration register is returned. This function\r | |
872 | must guarantee that all PCI read and write operations are serialized.\r | |
873 | \r | |
874 | If any reserved bits in Address are set, then ASSERT().\r | |
875 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
876 | \r | |
877 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and\r | |
878 | Register.\r | |
879 | @param OrData The value to OR with the PCI configuration register.\r | |
880 | \r | |
881 | @return The value written back to the PCI configuration register.\r | |
882 | \r | |
883 | **/\r | |
884 | UINT32\r | |
885 | EFIAPI\r | |
886 | S3PciSegmentOr32 (\r | |
887 | IN UINT64 Address,\r | |
888 | IN UINT32 OrData\r | |
889 | )\r | |
890 | {\r | |
891 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentOr32 (Address, OrData));\r | |
892 | }\r | |
893 | \r | |
894 | /**\r | |
895 | Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value, and\r | |
896 | saves the value in the S3 script to be replayed on S3 resume.\r | |
897 | \r | |
898 | Reads the 32-bit PCI configuration register specified by Address,\r | |
899 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
900 | and writes the result to the 32-bit PCI configuration register specified by Address.\r | |
901 | The value written to the PCI configuration register is returned.\r | |
902 | This function must guarantee that all PCI read and write operations are serialized.\r | |
903 | \r | |
904 | If any reserved bits in Address are set, then ASSERT().\r | |
905 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
906 | \r | |
907 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
908 | @param AndData The value to AND with the PCI configuration register.\r | |
909 | \r | |
910 | @return The value written to the PCI configuration register.\r | |
911 | \r | |
912 | **/\r | |
913 | UINT32\r | |
914 | EFIAPI\r | |
915 | S3PciSegmentAnd32 (\r | |
916 | IN UINT64 Address,\r | |
917 | IN UINT32 AndData\r | |
918 | )\r | |
919 | {\r | |
920 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentAnd32 (Address, AndData));\r | |
921 | }\r | |
922 | \r | |
923 | /**\r | |
924 | Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value,\r | |
925 | followed a bitwise OR with another 32-bit value, and saves the value in the S3 script to\r | |
926 | be replayed on S3 resume.\r | |
927 | \r | |
928 | Reads the 32-bit PCI configuration register specified by Address,\r | |
929 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
930 | performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r | |
931 | and writes the result to the 32-bit PCI configuration register specified by Address.\r | |
932 | The value written to the PCI configuration register is returned.\r | |
933 | This function must guarantee that all PCI read and write operations are serialized.\r | |
934 | \r | |
935 | If any reserved bits in Address are set, then ASSERT().\r | |
936 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
937 | \r | |
938 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
939 | @param AndData The value to AND with the PCI configuration register.\r | |
940 | @param OrData The value to OR with the PCI configuration register.\r | |
941 | \r | |
942 | @return The value written to the PCI configuration register.\r | |
943 | \r | |
944 | **/\r | |
945 | UINT32\r | |
946 | EFIAPI\r | |
947 | S3PciSegmentAndThenOr32 (\r | |
948 | IN UINT64 Address,\r | |
949 | IN UINT32 AndData,\r | |
950 | IN UINT32 OrData\r | |
951 | )\r | |
952 | {\r | |
953 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentAndThenOr32 (Address, AndData, OrData));\r | |
954 | }\r | |
955 | \r | |
956 | /**\r | |
957 | Reads a bit field of a PCI configuration register, and saves the value in the\r | |
958 | S3 script to be replayed on S3 resume.\r | |
959 | \r | |
960 | Reads the bit field in a 32-bit PCI configuration register. The bit field is\r | |
961 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
962 | returned.\r | |
963 | \r | |
964 | If any reserved bits in Address are set, then ASSERT().\r | |
965 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
966 | If StartBit is greater than 31, then ASSERT().\r | |
967 | If EndBit is greater than 31, then ASSERT().\r | |
968 | If EndBit is less than StartBit, then ASSERT().\r | |
969 | \r | |
970 | @param Address PCI configuration register to read.\r | |
971 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
972 | Range 0..31.\r | |
973 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
974 | Range 0..31.\r | |
975 | \r | |
976 | @return The value of the bit field read from the PCI configuration register.\r | |
977 | \r | |
978 | **/\r | |
979 | UINT32\r | |
980 | EFIAPI\r | |
981 | S3PciSegmentBitFieldRead32 (\r | |
982 | IN UINT64 Address,\r | |
983 | IN UINTN StartBit,\r | |
984 | IN UINTN EndBit\r | |
985 | )\r | |
986 | {\r | |
987 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldRead32 (Address, StartBit, EndBit));\r | |
988 | }\r | |
989 | \r | |
990 | /**\r | |
991 | Writes a bit field to a PCI configuration register, and saves the value in\r | |
992 | the S3 script to be replayed on S3 resume.\r | |
993 | \r | |
994 | Writes Value to the bit field of the PCI configuration register. The bit\r | |
995 | field is specified by the StartBit and the EndBit. All other bits in the\r | |
996 | destination PCI configuration register are preserved. The new value of the\r | |
997 | 32-bit register is returned.\r | |
998 | \r | |
999 | If any reserved bits in Address are set, then ASSERT().\r | |
1000 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
1001 | If StartBit is greater than 31, then ASSERT().\r | |
1002 | If EndBit is greater than 31, then ASSERT().\r | |
1003 | If EndBit is less than StartBit, then ASSERT().\r | |
1004 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
1005 | \r | |
1006 | @param Address PCI configuration register to write.\r | |
1007 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1008 | Range 0..31.\r | |
1009 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1010 | Range 0..31.\r | |
1011 | @param Value New value of the bit field.\r | |
1012 | \r | |
1013 | @return The value written back to the PCI configuration register.\r | |
1014 | \r | |
1015 | **/\r | |
1016 | UINT32\r | |
1017 | EFIAPI\r | |
1018 | S3PciSegmentBitFieldWrite32 (\r | |
1019 | IN UINT64 Address,\r | |
1020 | IN UINTN StartBit,\r | |
1021 | IN UINTN EndBit,\r | |
1022 | IN UINT32 Value\r | |
1023 | )\r | |
1024 | {\r | |
1025 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldWrite32 (Address, StartBit, EndBit, Value));\r | |
1026 | }\r | |
1027 | \r | |
1028 | /**\r | |
1029 | Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, writes\r | |
1030 | the result back to the bit field in the 32-bit port, and saves the value in the\r | |
1031 | S3 script to be replayed on S3 resume.\r | |
1032 | \r | |
1033 | Reads the 32-bit PCI configuration register specified by Address, performs a\r | |
1034 | bitwise OR between the read result and the value specified by\r | |
1035 | OrData, and writes the result to the 32-bit PCI configuration register\r | |
1036 | specified by Address. The value written to the PCI configuration register is\r | |
1037 | returned. This function must guarantee that all PCI read and write operations\r | |
1038 | are serialized. Extra left bits in OrData are stripped.\r | |
1039 | \r | |
1040 | If any reserved bits in Address are set, then ASSERT().\r | |
1041 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
1042 | If StartBit is greater than 31, then ASSERT().\r | |
1043 | If EndBit is greater than 31, then ASSERT().\r | |
1044 | If EndBit is less than StartBit, then ASSERT().\r | |
1045 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
1046 | \r | |
1047 | @param Address PCI configuration register to write.\r | |
1048 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1049 | Range 0..31.\r | |
1050 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1051 | Range 0..31.\r | |
1052 | @param OrData The value to OR with the PCI configuration register.\r | |
1053 | \r | |
1054 | @return The value written back to the PCI configuration register.\r | |
1055 | \r | |
1056 | **/\r | |
1057 | UINT32\r | |
1058 | EFIAPI\r | |
1059 | S3PciSegmentBitFieldOr32 (\r | |
1060 | IN UINT64 Address,\r | |
1061 | IN UINTN StartBit,\r | |
1062 | IN UINTN EndBit,\r | |
1063 | IN UINT32 OrData\r | |
1064 | )\r | |
1065 | {\r | |
1066 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldOr32 (Address, StartBit, EndBit, OrData));\r | |
1067 | }\r | |
1068 | \r | |
1069 | /**\r | |
1070 | Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r | |
1071 | AND, and writes the result back to the bit field in the 32-bit register, and\r | |
1072 | saves the value in the S3 script to be replayed on S3 resume.\r | |
1073 | \r | |
1074 | Reads the 32-bit PCI configuration register specified by Address, performs a\r | |
1075 | bitwise AND between the read result and the value specified by AndData, and\r | |
1076 | writes the result to the 32-bit PCI configuration register specified by\r | |
1077 | Address. The value written to the PCI configuration register is returned.\r | |
1078 | This function must guarantee that all PCI read and write operations are\r | |
1079 | serialized. Extra left bits in AndData are stripped.\r | |
1080 | \r | |
1081 | If any reserved bits in Address are set, then ASSERT().\r | |
1082 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
1083 | If StartBit is greater than 31, then ASSERT().\r | |
1084 | If EndBit is greater than 31, then ASSERT().\r | |
1085 | If EndBit is less than StartBit, then ASSERT().\r | |
1086 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
1087 | \r | |
1088 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
1089 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1090 | Range 0..31.\r | |
1091 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1092 | Range 0..31.\r | |
1093 | @param AndData The value to AND with the PCI configuration register.\r | |
1094 | \r | |
1095 | @return The value written back to the PCI configuration register.\r | |
1096 | \r | |
1097 | **/\r | |
1098 | UINT32\r | |
1099 | EFIAPI\r | |
1100 | S3PciSegmentBitFieldAnd32 (\r | |
1101 | IN UINT64 Address,\r | |
1102 | IN UINTN StartBit,\r | |
1103 | IN UINTN EndBit,\r | |
1104 | IN UINT32 AndData\r | |
1105 | )\r | |
1106 | {\r | |
1107 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldAnd32 (Address, StartBit, EndBit, AndData));\r | |
1108 | }\r | |
1109 | \r | |
1110 | /**\r | |
1111 | Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r | |
1112 | bitwise OR, writes the result back to the bit field in the 32-bit port,\r | |
1113 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
1114 | \r | |
1115 | Reads the 32-bit PCI configuration register specified by Address, performs a\r | |
1116 | bitwise AND followed by a bitwise OR between the read result and\r | |
1117 | the value specified by AndData, and writes the result to the 32-bit PCI\r | |
1118 | configuration register specified by Address. The value written to the PCI\r | |
1119 | configuration register is returned. This function must guarantee that all PCI\r | |
1120 | read and write operations are serialized. Extra left bits in both AndData and\r | |
1121 | OrData are stripped.\r | |
1122 | \r | |
1123 | If any reserved bits in Address are set, then ASSERT().\r | |
1124 | If StartBit is greater than 31, then ASSERT().\r | |
1125 | If EndBit is greater than 31, then ASSERT().\r | |
1126 | If EndBit is less than StartBit, then ASSERT().\r | |
1127 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
1128 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
1129 | \r | |
1130 | @param Address PCI configuration register to write.\r | |
1131 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1132 | Range 0..31.\r | |
1133 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1134 | Range 0..31.\r | |
1135 | @param AndData The value to AND with the PCI configuration register.\r | |
1136 | @param OrData The value to OR with the result of the AND operation.\r | |
1137 | \r | |
1138 | @return The value written back to the PCI configuration register.\r | |
1139 | \r | |
1140 | **/\r | |
1141 | UINT32\r | |
1142 | EFIAPI\r | |
1143 | S3PciSegmentBitFieldAndThenOr32 (\r | |
1144 | IN UINT64 Address,\r | |
1145 | IN UINTN StartBit,\r | |
1146 | IN UINTN EndBit,\r | |
1147 | IN UINT32 AndData,\r | |
1148 | IN UINT32 OrData\r | |
1149 | )\r | |
1150 | {\r | |
1151 | return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData));\r | |
1152 | }\r | |
1153 | \r | |
1154 | /**\r | |
1155 | Reads a range of PCI configuration registers into a caller supplied buffer,\r | |
1156 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
1157 | \r | |
1158 | Reads the range of PCI configuration registers specified by StartAddress and\r | |
1159 | Size into the buffer specified by Buffer. This function only allows the PCI\r | |
1160 | configuration registers from a single PCI function to be read. Size is\r | |
1161 | returned. When possible 32-bit PCI configuration read cycles are used to read\r | |
1162 | from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r | |
1163 | and 16-bit PCI configuration read cycles may be used at the beginning and the\r | |
1164 | end of the range.\r | |
1165 | \r | |
1166 | If any reserved bits in StartAddress are set, then ASSERT().\r | |
1167 | If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r | |
1168 | If Size > 0 and Buffer is NULL, then ASSERT().\r | |
1169 | \r | |
1170 | @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r | |
1171 | Function and Register.\r | |
1172 | @param Size Size in bytes of the transfer.\r | |
1173 | @param Buffer Pointer to a buffer receiving the data read.\r | |
1174 | \r | |
1175 | @return Size\r | |
1176 | \r | |
1177 | **/\r | |
1178 | UINTN\r | |
1179 | EFIAPI\r | |
1180 | S3PciSegmentReadBuffer (\r | |
1181 | IN UINT64 StartAddress,\r | |
1182 | IN UINTN Size,\r | |
1183 | OUT VOID *Buffer\r | |
1184 | )\r | |
1185 | {\r | |
1186 | RETURN_STATUS Status;\r | |
1187 | \r | |
1188 | Status = S3BootScriptSavePciCfg2Write (\r | |
1189 | S3BootScriptWidthUint8,\r | |
1190 | RShiftU64 (StartAddress, 32) & 0xffff,\r | |
1191 | PCI_SEGMENT_LIB_ADDRESS_TO_S3_BOOT_SCRIPT_PCI_ADDRESS (StartAddress),\r | |
1192 | PciSegmentReadBuffer (StartAddress, Size, Buffer),\r | |
1193 | Buffer\r | |
1194 | );\r | |
1195 | ASSERT_RETURN_ERROR (Status);\r | |
1196 | return Size;\r | |
1197 | }\r | |
1198 | \r | |
1199 | /**\r | |
1200 | Copies the data in a caller supplied buffer to a specified range of PCI\r | |
1201 | configuration space, and saves the value in the S3 script to be replayed on S3\r | |
1202 | resume.\r | |
1203 | \r | |
1204 | Writes the range of PCI configuration registers specified by StartAddress and\r | |
1205 | Size from the buffer specified by Buffer. This function only allows the PCI\r | |
1206 | configuration registers from a single PCI function to be written. Size is\r | |
1207 | returned. When possible 32-bit PCI configuration write cycles are used to\r | |
1208 | write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r | |
1209 | 8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r | |
1210 | and the end of the range.\r | |
1211 | \r | |
1212 | If any reserved bits in StartAddress are set, then ASSERT().\r | |
1213 | If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r | |
1214 | If Size > 0 and Buffer is NULL, then ASSERT().\r | |
1215 | \r | |
1216 | @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r | |
1217 | Function and Register.\r | |
1218 | @param Size Size in bytes of the transfer.\r | |
1219 | @param Buffer Pointer to a buffer containing the data to write.\r | |
1220 | \r | |
1221 | @return The parameter of Size.\r | |
1222 | \r | |
1223 | **/\r | |
1224 | UINTN\r | |
1225 | EFIAPI\r | |
1226 | S3PciSegmentWriteBuffer (\r | |
1227 | IN UINT64 StartAddress,\r | |
1228 | IN UINTN Size,\r | |
1229 | IN VOID *Buffer\r | |
1230 | )\r | |
1231 | {\r | |
1232 | RETURN_STATUS Status;\r | |
1233 | \r | |
1234 | Status = S3BootScriptSavePciCfg2Write (\r | |
1235 | S3BootScriptWidthUint8,\r | |
1236 | RShiftU64 (StartAddress, 32) & 0xffff,\r | |
1237 | PCI_SEGMENT_LIB_ADDRESS_TO_S3_BOOT_SCRIPT_PCI_ADDRESS (StartAddress),\r | |
1238 | PciSegmentWriteBuffer (StartAddress, Size, Buffer),\r | |
1239 | Buffer\r | |
1240 | );\r | |
1241 | ASSERT_RETURN_ERROR (Status);\r | |
1242 | return Size;\r | |
1243 | }\r |