]>
Commit | Line | Data |
---|---|---|
fe69ac84 | 1 | /** @file\r |
2 | I/O and MMIO Library Services that do I/O and also enable the I/O operatation\r | |
3 | to be replayed during an S3 resume.\r | |
9095d37b LG |
4 | \r |
5 | Copyright (c) 2006 -2018, Intel Corporation. All rights reserved.<BR>\r | |
fe69ac84 | 6 | \r |
9344f092 | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
fe69ac84 | 8 | \r |
9 | **/\r | |
10 | \r | |
11 | #include <Base.h>\r | |
12 | \r | |
13 | #include <Library/S3IoLib.h>\r | |
14 | #include <Library/DebugLib.h>\r | |
15 | #include <Library/IoLib.h>\r | |
16 | #include <Library/S3BootScriptLib.h>\r | |
17 | \r | |
18 | \r | |
19 | /**\r | |
20 | Saves an I/O port value to the boot script.\r | |
21 | \r | |
22 | This internal worker function saves an I/O port value in the S3 script\r | |
9095d37b | 23 | to be replayed on S3 resume.\r |
fe69ac84 | 24 | \r |
25 | If the saving process fails, then ASSERT().\r | |
26 | \r | |
27 | @param Width The width of I/O port.\r | |
28 | @param Port The I/O port to write.\r | |
29 | @param Buffer The buffer containing value.\r | |
30 | \r | |
31 | **/\r | |
32 | VOID\r | |
33 | InternalSaveIoWriteValueToBootScript (\r | |
34 | IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r | |
35 | IN UINTN Port,\r | |
36 | IN VOID *Buffer\r | |
37 | )\r | |
38 | {\r | |
39 | RETURN_STATUS Status;\r | |
9095d37b | 40 | \r |
fe69ac84 | 41 | Status = S3BootScriptSaveIoWrite (\r |
42 | Width,\r | |
43 | Port,\r | |
44 | 1,\r | |
45 | Buffer\r | |
46 | );\r | |
47 | ASSERT (Status == RETURN_SUCCESS);\r | |
48 | }\r | |
9095d37b | 49 | \r |
fe69ac84 | 50 | /**\r |
51 | Saves an 8-bit I/O port value to the boot script.\r | |
52 | \r | |
53 | This internal worker function saves an 8-bit I/O port value in the S3 script\r | |
9095d37b | 54 | to be replayed on S3 resume.\r |
fe69ac84 | 55 | \r |
56 | If the saving process fails, then ASSERT().\r | |
57 | \r | |
58 | @param Port The I/O port to write.\r | |
59 | @param Value The value saved to boot script.\r | |
60 | \r | |
61 | @return Value.\r | |
62 | \r | |
63 | **/\r | |
64 | UINT8\r | |
65 | InternalSaveIoWrite8ValueToBootScript (\r | |
66 | IN UINTN Port,\r | |
67 | IN UINT8 Value\r | |
68 | )\r | |
69 | {\r | |
70 | InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint8, Port, &Value);\r | |
71 | \r | |
72 | return Value;\r | |
73 | }\r | |
74 | \r | |
75 | /**\r | |
76 | Reads an 8-bit I/O port and saves the value in the S3 script to be replayed\r | |
77 | on S3 resume.\r | |
78 | \r | |
79 | Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.\r | |
80 | This function must guarantee that all I/O read and write operations are\r | |
81 | serialized.\r | |
82 | \r | |
83 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
84 | \r | |
85 | @param Port The I/O port to read.\r | |
86 | \r | |
87 | @return The value read.\r | |
88 | \r | |
89 | **/\r | |
90 | UINT8\r | |
91 | EFIAPI\r | |
92 | S3IoRead8 (\r | |
93 | IN UINTN Port\r | |
94 | )\r | |
95 | {\r | |
96 | return InternalSaveIoWrite8ValueToBootScript (Port, IoRead8 (Port));\r | |
97 | }\r | |
98 | \r | |
99 | /**\r | |
100 | Writes an 8-bit I/O port and saves the value in the S3 script to be replayed\r | |
101 | on S3 resume.\r | |
102 | \r | |
103 | Writes the 8-bit I/O port specified by Port with the value specified by Value\r | |
104 | and returns Value. This function must guarantee that all I/O read and write\r | |
105 | operations are serialized.\r | |
106 | \r | |
107 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
108 | \r | |
109 | @param Port The I/O port to write.\r | |
110 | @param Value The value to write to the I/O port.\r | |
111 | \r | |
112 | @return The value written the I/O port.\r | |
113 | \r | |
114 | **/\r | |
115 | UINT8\r | |
116 | EFIAPI\r | |
117 | S3IoWrite8 (\r | |
118 | IN UINTN Port,\r | |
119 | IN UINT8 Value\r | |
120 | )\r | |
121 | {\r | |
122 | return InternalSaveIoWrite8ValueToBootScript (Port, IoWrite8 (Port, Value));\r | |
123 | }\r | |
124 | \r | |
125 | /**\r | |
126 | Reads an 8-bit I/O port, performs a bitwise OR, and writes the\r | |
127 | result back to the 8-bit I/O port and saves the value in the S3 script to be\r | |
128 | replayed on S3 resume.\r | |
129 | \r | |
130 | Reads the 8-bit I/O port specified by Port, performs a bitwise OR\r | |
131 | between the read result and the value specified by OrData, and writes the\r | |
132 | result to the 8-bit I/O port specified by Port. The value written to the I/O\r | |
133 | port is returned. This function must guarantee that all I/O read and write\r | |
134 | operations are serialized.\r | |
135 | \r | |
136 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
137 | \r | |
138 | @param Port The I/O port to write.\r | |
139 | @param OrData The value to OR with the read value from the I/O port.\r | |
140 | \r | |
141 | @return The value written back to the I/O port.\r | |
142 | \r | |
143 | **/\r | |
144 | UINT8\r | |
145 | EFIAPI\r | |
146 | S3IoOr8 (\r | |
147 | IN UINTN Port,\r | |
148 | IN UINT8 OrData\r | |
149 | )\r | |
150 | {\r | |
151 | return InternalSaveIoWrite8ValueToBootScript (Port, IoOr8 (Port, OrData));\r | |
152 | }\r | |
153 | \r | |
154 | /**\r | |
155 | Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back\r | |
156 | to the 8-bit I/O port and saves the value in the S3 script to be replayed\r | |
157 | on S3 resume.\r | |
158 | \r | |
159 | Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r | |
160 | the read result and the value specified by AndData, and writes the result to\r | |
161 | the 8-bit I/O port specified by Port. The value written to the I/O port is\r | |
162 | returned. This function must guarantee that all I/O read and write operations\r | |
163 | are serialized.\r | |
164 | \r | |
165 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
166 | \r | |
167 | @param Port The I/O port to write.\r | |
168 | @param AndData The value to AND with the read value from the I/O port.\r | |
169 | \r | |
170 | @return The value written back to the I/O port.\r | |
171 | \r | |
172 | **/\r | |
173 | UINT8\r | |
174 | EFIAPI\r | |
175 | S3IoAnd8 (\r | |
176 | IN UINTN Port,\r | |
177 | IN UINT8 AndData\r | |
178 | )\r | |
179 | {\r | |
180 | return InternalSaveIoWrite8ValueToBootScript (Port, IoAnd8 (Port, AndData));\r | |
181 | }\r | |
182 | \r | |
183 | /**\r | |
184 | Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise\r | |
9095d37b | 185 | inclusive OR, and writes the result back to the 8-bit I/O port and saves\r |
fe69ac84 | 186 | the value in the S3 script to be replayed on S3 resume.\r |
187 | \r | |
188 | Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r | |
189 | the read result and the value specified by AndData, performs a bitwise OR\r | |
190 | between the result of the AND operation and the value specified by OrData,\r | |
191 | and writes the result to the 8-bit I/O port specified by Port. The value\r | |
192 | written to the I/O port is returned. This function must guarantee that all\r | |
193 | I/O read and write operations are serialized.\r | |
194 | \r | |
195 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
196 | \r | |
197 | @param Port The I/O port to write.\r | |
198 | @param AndData The value to AND with the read value from the I/O port.\r | |
199 | @param OrData The value to OR with the result of the AND operation.\r | |
200 | \r | |
201 | @return The value written back to the I/O port.\r | |
202 | \r | |
203 | **/\r | |
204 | UINT8\r | |
205 | EFIAPI\r | |
206 | S3IoAndThenOr8 (\r | |
207 | IN UINTN Port,\r | |
208 | IN UINT8 AndData,\r | |
209 | IN UINT8 OrData\r | |
210 | )\r | |
211 | {\r | |
212 | return InternalSaveIoWrite8ValueToBootScript (Port, IoAndThenOr8 (Port, AndData, OrData));\r | |
213 | }\r | |
214 | \r | |
215 | /**\r | |
216 | Reads a bit field of an I/O register and saves the value in the S3 script to\r | |
217 | be replayed on S3 resume.\r | |
218 | \r | |
219 | Reads the bit field in an 8-bit I/O register. The bit field is specified by\r | |
220 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
221 | \r | |
222 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
223 | If StartBit is greater than 7, then ASSERT().\r | |
224 | If EndBit is greater than 7, then ASSERT().\r | |
225 | If EndBit is less than StartBit, then ASSERT().\r | |
226 | \r | |
227 | @param Port The I/O port to read.\r | |
228 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
229 | Range 0..7.\r | |
230 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
231 | Range 0..7.\r | |
232 | \r | |
233 | @return The value read.\r | |
234 | \r | |
235 | **/\r | |
236 | UINT8\r | |
237 | EFIAPI\r | |
238 | S3IoBitFieldRead8 (\r | |
239 | IN UINTN Port,\r | |
240 | IN UINTN StartBit,\r | |
241 | IN UINTN EndBit\r | |
242 | )\r | |
243 | {\r | |
244 | return InternalSaveIoWrite8ValueToBootScript (Port, IoBitFieldRead8 (Port, StartBit, EndBit));\r | |
245 | }\r | |
246 | \r | |
247 | /**\r | |
248 | Writes a bit field to an I/O register and saves the value in the S3 script to\r | |
249 | be replayed on S3 resume.\r | |
250 | \r | |
251 | Writes Value to the bit field of the I/O register. The bit field is specified\r | |
252 | by the StartBit and the EndBit. All other bits in the destination I/O\r | |
253 | register are preserved. The value written to the I/O port is returned. Extra\r | |
254 | left bits in Value are stripped.\r | |
255 | \r | |
256 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
257 | If StartBit is greater than 7, then ASSERT().\r | |
258 | If EndBit is greater than 7, then ASSERT().\r | |
259 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 260 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 261 | \r |
262 | @param Port The I/O port to write.\r | |
263 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
264 | Range 0..7.\r | |
265 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
266 | Range 0..7.\r | |
267 | @param Value New value of the bit field.\r | |
268 | \r | |
269 | @return The value written back to the I/O port.\r | |
270 | \r | |
271 | **/\r | |
272 | UINT8\r | |
273 | EFIAPI\r | |
274 | S3IoBitFieldWrite8 (\r | |
275 | IN UINTN Port,\r | |
276 | IN UINTN StartBit,\r | |
277 | IN UINTN EndBit,\r | |
278 | IN UINT8 Value\r | |
279 | )\r | |
280 | {\r | |
281 | return InternalSaveIoWrite8ValueToBootScript (Port, IoBitFieldWrite8 (Port, StartBit, EndBit, Value));\r | |
282 | }\r | |
283 | \r | |
284 | /**\r | |
285 | Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the\r | |
9095d37b | 286 | result back to the bit field in the 8-bit port and saves the value in the\r |
fe69ac84 | 287 | S3 script to be replayed on S3 resume.\r |
288 | \r | |
289 | Reads the 8-bit I/O port specified by Port, performs a bitwise OR\r | |
290 | between the read result and the value specified by OrData, and writes the\r | |
291 | result to the 8-bit I/O port specified by Port. The value written to the I/O\r | |
292 | port is returned. This function must guarantee that all I/O read and write\r | |
293 | operations are serialized. Extra left bits in OrData are stripped.\r | |
294 | \r | |
295 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
296 | If StartBit is greater than 7, then ASSERT().\r | |
297 | If EndBit is greater than 7, then ASSERT().\r | |
298 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 299 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 300 | \r |
301 | @param Port The I/O port to write.\r | |
302 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
303 | Range 0..7.\r | |
304 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
305 | Range 0..7.\r | |
306 | @param OrData The value to OR with the read value from the I/O port.\r | |
307 | \r | |
308 | @return The value written back to the I/O port.\r | |
309 | \r | |
310 | **/\r | |
311 | UINT8\r | |
312 | EFIAPI\r | |
313 | S3IoBitFieldOr8 (\r | |
314 | IN UINTN Port,\r | |
315 | IN UINTN StartBit,\r | |
316 | IN UINTN EndBit,\r | |
317 | IN UINT8 OrData\r | |
318 | )\r | |
319 | {\r | |
320 | return InternalSaveIoWrite8ValueToBootScript (Port, IoBitFieldOr8 (Port, StartBit, EndBit, OrData));\r | |
321 | }\r | |
322 | \r | |
323 | /**\r | |
324 | Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the\r | |
9095d37b | 325 | result back to the bit field in the 8-bit port and saves the value in the\r |
fe69ac84 | 326 | S3 script to be replayed on S3 resume.\r |
327 | \r | |
328 | Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r | |
329 | the read result and the value specified by AndData, and writes the result to\r | |
330 | the 8-bit I/O port specified by Port. The value written to the I/O port is\r | |
331 | returned. This function must guarantee that all I/O read and write operations\r | |
332 | are serialized. Extra left bits in AndData are stripped.\r | |
333 | \r | |
334 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
335 | If StartBit is greater than 7, then ASSERT().\r | |
336 | If EndBit is greater than 7, then ASSERT().\r | |
337 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 338 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 339 | \r |
340 | @param Port The I/O port to write.\r | |
341 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
342 | Range 0..7.\r | |
343 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
344 | Range 0..7.\r | |
345 | @param AndData The value to AND with the read value from the I/O port.\r | |
346 | \r | |
347 | @return The value written back to the I/O port.\r | |
348 | \r | |
349 | **/\r | |
350 | UINT8\r | |
351 | EFIAPI\r | |
352 | S3IoBitFieldAnd8 (\r | |
353 | IN UINTN Port,\r | |
354 | IN UINTN StartBit,\r | |
355 | IN UINTN EndBit,\r | |
356 | IN UINT8 AndData\r | |
357 | )\r | |
358 | {\r | |
359 | return InternalSaveIoWrite8ValueToBootScript (Port, IoBitFieldAnd8 (Port, StartBit, EndBit, AndData));\r | |
360 | }\r | |
361 | \r | |
362 | /**\r | |
363 | Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r | |
364 | bitwise OR, and writes the result back to the bit field in the\r | |
365 | 8-bit port and saves the value in the S3 script to be replayed on S3 resume.\r | |
366 | \r | |
367 | Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed\r | |
368 | by a bitwise OR between the read result and the value specified by\r | |
369 | AndData, and writes the result to the 8-bit I/O port specified by Port. The\r | |
370 | value written to the I/O port is returned. This function must guarantee that\r | |
371 | all I/O read and write operations are serialized. Extra left bits in both\r | |
372 | AndData and OrData are stripped.\r | |
373 | \r | |
374 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
375 | If StartBit is greater than 7, then ASSERT().\r | |
376 | If EndBit is greater than 7, then ASSERT().\r | |
377 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
378 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
379 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fe69ac84 | 380 | \r |
381 | @param Port The I/O port to write.\r | |
382 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
383 | Range 0..7.\r | |
384 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
385 | Range 0..7.\r | |
386 | @param AndData The value to AND with the read value from the I/O port.\r | |
387 | @param OrData The value to OR with the result of the AND operation.\r | |
388 | \r | |
389 | @return The value written back to the I/O port.\r | |
390 | \r | |
391 | **/\r | |
392 | UINT8\r | |
393 | EFIAPI\r | |
394 | S3IoBitFieldAndThenOr8 (\r | |
395 | IN UINTN Port,\r | |
396 | IN UINTN StartBit,\r | |
397 | IN UINTN EndBit,\r | |
398 | IN UINT8 AndData,\r | |
399 | IN UINT8 OrData\r | |
400 | )\r | |
401 | {\r | |
402 | return InternalSaveIoWrite8ValueToBootScript (Port, IoBitFieldAndThenOr8 (Port, StartBit, EndBit, AndData, OrData));\r | |
403 | }\r | |
404 | \r | |
405 | /**\r | |
406 | Saves a 16-bit I/O port value to the boot script.\r | |
407 | \r | |
408 | This internal worker function saves a 16-bit I/O port value in the S3 script\r | |
9095d37b | 409 | to be replayed on S3 resume.\r |
fe69ac84 | 410 | \r |
411 | If the saving process fails, then ASSERT().\r | |
412 | \r | |
413 | @param Port The I/O port to write.\r | |
414 | @param Value The value saved to boot script.\r | |
415 | \r | |
416 | @return Value.\r | |
417 | \r | |
418 | **/\r | |
419 | UINT16\r | |
420 | InternalSaveIoWrite16ValueToBootScript (\r | |
421 | IN UINTN Port,\r | |
422 | IN UINT16 Value\r | |
423 | )\r | |
424 | {\r | |
425 | InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint16, Port, &Value);\r | |
9095d37b | 426 | \r |
fe69ac84 | 427 | return Value;\r |
428 | }\r | |
429 | \r | |
430 | /**\r | |
431 | Reads a 16-bit I/O port and saves the value in the S3 script to be replayed\r | |
432 | on S3 resume.\r | |
433 | \r | |
434 | Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.\r | |
435 | This function must guarantee that all I/O read and write operations are\r | |
436 | serialized.\r | |
437 | \r | |
438 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
439 | \r | |
440 | @param Port The I/O port to read.\r | |
441 | \r | |
442 | @return The value read.\r | |
443 | \r | |
444 | **/\r | |
445 | UINT16\r | |
446 | EFIAPI\r | |
447 | S3IoRead16 (\r | |
448 | IN UINTN Port\r | |
449 | )\r | |
450 | {\r | |
451 | return InternalSaveIoWrite16ValueToBootScript (Port, IoRead16 (Port));\r | |
452 | }\r | |
453 | \r | |
454 | /**\r | |
455 | Writes a 16-bit I/O port and saves the value in the S3 script to be replayed\r | |
456 | on S3 resume.\r | |
457 | \r | |
458 | Writes the 16-bit I/O port specified by Port with the value specified by Value\r | |
459 | and returns Value. This function must guarantee that all I/O read and write\r | |
460 | operations are serialized.\r | |
461 | \r | |
462 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
463 | \r | |
464 | @param Port The I/O port to write.\r | |
465 | @param Value The value to write to the I/O port.\r | |
466 | \r | |
467 | @return The value written the I/O port.\r | |
468 | \r | |
469 | **/\r | |
470 | UINT16\r | |
471 | EFIAPI\r | |
472 | S3IoWrite16 (\r | |
473 | IN UINTN Port,\r | |
474 | IN UINT16 Value\r | |
475 | )\r | |
476 | {\r | |
477 | return InternalSaveIoWrite16ValueToBootScript (Port, IoWrite16 (Port, Value));\r | |
478 | }\r | |
479 | \r | |
480 | /**\r | |
481 | Reads a 16-bit I/O port, performs a bitwise OR, and writes the\r | |
9095d37b | 482 | result back to the 16-bit I/O port and saves the value in the S3 script to\r |
fe69ac84 | 483 | be replayed on S3 resume.\r |
484 | \r | |
485 | Reads the 16-bit I/O port specified by Port, performs a bitwise OR\r | |
486 | between the read result and the value specified by OrData, and writes the\r | |
487 | result to the 16-bit I/O port specified by Port. The value written to the I/O\r | |
488 | port is returned. This function must guarantee that all I/O read and write\r | |
489 | operations are serialized.\r | |
490 | \r | |
491 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
492 | \r | |
493 | @param Port The I/O port to write.\r | |
494 | @param OrData The value to OR with the read value from the I/O port.\r | |
495 | \r | |
496 | @return The value written back to the I/O port.\r | |
497 | \r | |
498 | **/\r | |
499 | UINT16\r | |
500 | EFIAPI\r | |
501 | S3IoOr16 (\r | |
502 | IN UINTN Port,\r | |
503 | IN UINT16 OrData\r | |
504 | )\r | |
505 | {\r | |
506 | return InternalSaveIoWrite16ValueToBootScript (Port, IoOr16 (Port, OrData));\r | |
507 | }\r | |
508 | \r | |
509 | /**\r | |
510 | Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back\r | |
511 | to the 16-bit I/O port and saves the value in the S3 script to be replayed\r | |
512 | on S3 resume.\r | |
513 | \r | |
514 | Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r | |
515 | the read result and the value specified by AndData, and writes the result to\r | |
516 | the 16-bit I/O port specified by Port. The value written to the I/O port is\r | |
517 | returned. This function must guarantee that all I/O read and write operations\r | |
518 | are serialized.\r | |
519 | \r | |
520 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
521 | \r | |
522 | @param Port The I/O port to write.\r | |
523 | @param AndData The value to AND with the read value from the I/O port.\r | |
524 | \r | |
525 | @return The value written back to the I/O port.\r | |
526 | \r | |
527 | **/\r | |
528 | UINT16\r | |
529 | EFIAPI\r | |
530 | S3IoAnd16 (\r | |
531 | IN UINTN Port,\r | |
532 | IN UINT16 AndData\r | |
533 | )\r | |
534 | {\r | |
535 | return InternalSaveIoWrite16ValueToBootScript (Port, IoAnd16 (Port, AndData));\r | |
536 | }\r | |
537 | \r | |
538 | /**\r | |
539 | Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise\r | |
540 | inclusive OR, and writes the result back to the 16-bit I/O port and saves\r | |
541 | the value in the S3 script to be replayed on S3 resume.\r | |
542 | \r | |
543 | Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r | |
544 | the read result and the value specified by AndData, performs a bitwise OR\r | |
545 | between the result of the AND operation and the value specified by OrData,\r | |
546 | and writes the result to the 16-bit I/O port specified by Port. The value\r | |
547 | written to the I/O port is returned. This function must guarantee that all\r | |
548 | I/O read and write operations are serialized.\r | |
549 | \r | |
550 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
551 | \r | |
552 | @param Port The I/O port to write.\r | |
553 | @param AndData The value to AND with the read value from the I/O port.\r | |
554 | @param OrData The value to OR with the result of the AND operation.\r | |
555 | \r | |
556 | @return The value written back to the I/O port.\r | |
557 | \r | |
558 | **/\r | |
559 | UINT16\r | |
560 | EFIAPI\r | |
561 | S3IoAndThenOr16 (\r | |
562 | IN UINTN Port,\r | |
563 | IN UINT16 AndData,\r | |
564 | IN UINT16 OrData\r | |
565 | )\r | |
566 | {\r | |
567 | return InternalSaveIoWrite16ValueToBootScript (Port, IoAndThenOr16 (Port, AndData, OrData));\r | |
568 | }\r | |
569 | \r | |
570 | /**\r | |
571 | Reads a bit field of an I/O register saves the value in the S3 script to be\r | |
572 | replayed on S3 resume.\r | |
573 | \r | |
574 | Reads the bit field in a 16-bit I/O register. The bit field is specified by\r | |
575 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
576 | \r | |
577 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
578 | If StartBit is greater than 15, then ASSERT().\r | |
579 | If EndBit is greater than 15, then ASSERT().\r | |
580 | If EndBit is less than StartBit, then ASSERT().\r | |
581 | \r | |
582 | @param Port The I/O port to read.\r | |
583 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
584 | Range 0..15.\r | |
585 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
586 | Range 0..15.\r | |
587 | \r | |
588 | @return The value read.\r | |
589 | \r | |
590 | **/\r | |
591 | UINT16\r | |
592 | EFIAPI\r | |
593 | S3IoBitFieldRead16 (\r | |
594 | IN UINTN Port,\r | |
595 | IN UINTN StartBit,\r | |
596 | IN UINTN EndBit\r | |
597 | )\r | |
598 | {\r | |
599 | return InternalSaveIoWrite16ValueToBootScript (Port, IoBitFieldRead16 (Port, StartBit, EndBit));\r | |
600 | }\r | |
601 | \r | |
602 | /**\r | |
9095d37b | 603 | Writes a bit field to an I/O register and saves the value in the S3 script\r |
fe69ac84 | 604 | to be replayed on S3 resume.\r |
605 | \r | |
606 | Writes Value to the bit field of the I/O register. The bit field is specified\r | |
607 | by the StartBit and the EndBit. All other bits in the destination I/O\r | |
608 | register are preserved. The value written to the I/O port is returned. Extra\r | |
609 | left bits in Value are stripped.\r | |
610 | \r | |
611 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
612 | If StartBit is greater than 15, then ASSERT().\r | |
613 | If EndBit is greater than 15, then ASSERT().\r | |
614 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 615 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 616 | \r |
617 | @param Port The I/O port to write.\r | |
618 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
619 | Range 0..15.\r | |
620 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
621 | Range 0..15.\r | |
622 | @param Value New value of the bit field.\r | |
623 | \r | |
624 | @return The value written back to the I/O port.\r | |
625 | \r | |
626 | **/\r | |
627 | UINT16\r | |
628 | EFIAPI\r | |
629 | S3IoBitFieldWrite16 (\r | |
630 | IN UINTN Port,\r | |
631 | IN UINTN StartBit,\r | |
632 | IN UINTN EndBit,\r | |
633 | IN UINT16 Value\r | |
634 | )\r | |
635 | {\r | |
636 | return InternalSaveIoWrite16ValueToBootScript (Port, IoBitFieldWrite16 (Port, StartBit, EndBit, Value));\r | |
637 | }\r | |
638 | \r | |
639 | /**\r | |
640 | Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the\r | |
9095d37b | 641 | result back to the bit field in the 16-bit port and saves the value in the\r |
fe69ac84 | 642 | S3 script to be replayed on S3 resume.\r |
643 | \r | |
644 | Reads the 16-bit I/O port specified by Port, performs a bitwise OR\r | |
645 | between the read result and the value specified by OrData, and writes the\r | |
646 | result to the 16-bit I/O port specified by Port. The value written to the I/O\r | |
647 | port is returned. This function must guarantee that all I/O read and write\r | |
648 | operations are serialized. Extra left bits in OrData are stripped.\r | |
649 | \r | |
650 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
651 | If StartBit is greater than 15, then ASSERT().\r | |
652 | If EndBit is greater than 15, then ASSERT().\r | |
653 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 654 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 655 | \r |
656 | @param Port The I/O port to write.\r | |
657 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
658 | Range 0..15.\r | |
659 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
660 | Range 0..15.\r | |
661 | @param OrData The value to OR with the read value from the I/O port.\r | |
662 | \r | |
663 | @return The value written back to the I/O port.\r | |
664 | \r | |
665 | **/\r | |
666 | UINT16\r | |
667 | EFIAPI\r | |
668 | S3IoBitFieldOr16 (\r | |
669 | IN UINTN Port,\r | |
670 | IN UINTN StartBit,\r | |
671 | IN UINTN EndBit,\r | |
672 | IN UINT16 OrData\r | |
673 | )\r | |
674 | {\r | |
675 | return InternalSaveIoWrite16ValueToBootScript (Port, IoBitFieldOr16 (Port, StartBit, EndBit, OrData));\r | |
676 | }\r | |
677 | \r | |
678 | /**\r | |
679 | Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the\r | |
9095d37b | 680 | result back to the bit field in the 16-bit port and saves the value in the\r |
fe69ac84 | 681 | S3 script to be replayed on S3 resume.\r |
682 | \r | |
683 | Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r | |
684 | the read result and the value specified by AndData, and writes the result to\r | |
685 | the 16-bit I/O port specified by Port. The value written to the I/O port is\r | |
686 | returned. This function must guarantee that all I/O read and write operations\r | |
687 | are serialized. Extra left bits in AndData are stripped.\r | |
688 | \r | |
689 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
690 | If StartBit is greater than 15, then ASSERT().\r | |
691 | If EndBit is greater than 15, then ASSERT().\r | |
692 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 693 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 694 | \r |
695 | @param Port The I/O port to write.\r | |
696 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
697 | Range 0..15.\r | |
698 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
699 | Range 0..15.\r | |
700 | @param AndData The value to AND with the read value from the I/O port.\r | |
701 | \r | |
702 | @return The value written back to the I/O port.\r | |
703 | \r | |
704 | **/\r | |
705 | UINT16\r | |
706 | EFIAPI\r | |
707 | S3IoBitFieldAnd16 (\r | |
708 | IN UINTN Port,\r | |
709 | IN UINTN StartBit,\r | |
710 | IN UINTN EndBit,\r | |
711 | IN UINT16 AndData\r | |
712 | )\r | |
713 | {\r | |
714 | return InternalSaveIoWrite16ValueToBootScript (Port, IoBitFieldAnd16 (Port, StartBit, EndBit, AndData));\r | |
715 | }\r | |
716 | \r | |
717 | /**\r | |
718 | Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r | |
719 | bitwise OR, and writes the result back to the bit field in the\r | |
9095d37b | 720 | 16-bit port and saves the value in the S3 script to be replayed on S3\r |
fe69ac84 | 721 | resume.\r |
722 | \r | |
723 | Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed\r | |
724 | by a bitwise OR between the read result and the value specified by\r | |
725 | AndData, and writes the result to the 16-bit I/O port specified by Port. The\r | |
726 | value written to the I/O port is returned. This function must guarantee that\r | |
727 | all I/O read and write operations are serialized. Extra left bits in both\r | |
728 | AndData and OrData are stripped.\r | |
729 | \r | |
730 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
731 | If StartBit is greater than 15, then ASSERT().\r | |
732 | If EndBit is greater than 15, then ASSERT().\r | |
733 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
734 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
735 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fe69ac84 | 736 | \r |
737 | @param Port The I/O port to write.\r | |
738 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
739 | Range 0..15.\r | |
740 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
741 | Range 0..15.\r | |
742 | @param AndData The value to AND with the read value from the I/O port.\r | |
743 | @param OrData The value to OR with the result of the AND operation.\r | |
744 | \r | |
745 | @return The value written back to the I/O port.\r | |
746 | \r | |
747 | **/\r | |
748 | UINT16\r | |
749 | EFIAPI\r | |
750 | S3IoBitFieldAndThenOr16 (\r | |
751 | IN UINTN Port,\r | |
752 | IN UINTN StartBit,\r | |
753 | IN UINTN EndBit,\r | |
754 | IN UINT16 AndData,\r | |
755 | IN UINT16 OrData\r | |
756 | )\r | |
757 | {\r | |
758 | return InternalSaveIoWrite16ValueToBootScript (Port, IoBitFieldAndThenOr16 (Port, StartBit, EndBit, AndData, OrData));\r | |
759 | }\r | |
760 | \r | |
761 | /**\r | |
762 | Saves a 32-bit I/O port value to the boot script.\r | |
763 | \r | |
764 | This internal worker function saves a 32-bit I/O port value in the S3 script\r | |
9095d37b | 765 | to be replayed on S3 resume.\r |
fe69ac84 | 766 | \r |
767 | If the saving process fails, then ASSERT().\r | |
768 | \r | |
769 | @param Port The I/O port to write.\r | |
770 | @param Value The value saved to boot script.\r | |
771 | \r | |
772 | @return Value.\r | |
773 | \r | |
774 | **/\r | |
775 | UINT32\r | |
776 | InternalSaveIoWrite32ValueToBootScript (\r | |
777 | IN UINTN Port,\r | |
778 | IN UINT32 Value\r | |
779 | )\r | |
780 | {\r | |
781 | InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint32, Port, &Value);\r | |
9095d37b | 782 | \r |
fe69ac84 | 783 | return Value;\r |
784 | }\r | |
785 | \r | |
786 | /**\r | |
787 | Reads a 32-bit I/O port and saves the value in the S3 script to be replayed\r | |
788 | on S3 resume.\r | |
789 | \r | |
790 | Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.\r | |
791 | This function must guarantee that all I/O read and write operations are\r | |
792 | serialized.\r | |
793 | \r | |
794 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
795 | \r | |
796 | @param Port The I/O port to read.\r | |
797 | \r | |
798 | @return The value read.\r | |
799 | \r | |
800 | **/\r | |
801 | UINT32\r | |
802 | EFIAPI\r | |
803 | S3IoRead32 (\r | |
804 | IN UINTN Port\r | |
805 | )\r | |
806 | {\r | |
807 | return InternalSaveIoWrite32ValueToBootScript (Port, IoRead32 (Port));\r | |
808 | }\r | |
809 | \r | |
810 | /**\r | |
811 | Writes a 32-bit I/O port and saves the value in the S3 script to be replayed\r | |
812 | on S3 resume.\r | |
813 | \r | |
814 | Writes the 32-bit I/O port specified by Port with the value specified by Value\r | |
815 | and returns Value. This function must guarantee that all I/O read and write\r | |
816 | operations are serialized.\r | |
817 | \r | |
818 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
819 | \r | |
820 | @param Port The I/O port to write.\r | |
821 | @param Value The value to write to the I/O port.\r | |
822 | \r | |
823 | @return The value written the I/O port.\r | |
824 | \r | |
825 | **/\r | |
826 | UINT32\r | |
827 | EFIAPI\r | |
828 | S3IoWrite32 (\r | |
829 | IN UINTN Port,\r | |
830 | IN UINT32 Value\r | |
831 | )\r | |
832 | {\r | |
833 | return InternalSaveIoWrite32ValueToBootScript (Port, IoWrite32 (Port, Value));\r | |
834 | }\r | |
835 | \r | |
836 | /**\r | |
837 | Reads a 32-bit I/O port, performs a bitwise OR, and writes the\r | |
9095d37b | 838 | result back to the 32-bit I/O port and saves the value in the S3 script to\r |
fe69ac84 | 839 | be replayed on S3 resume.\r |
840 | \r | |
841 | Reads the 32-bit I/O port specified by Port, performs a bitwise OR\r | |
842 | between the read result and the value specified by OrData, and writes the\r | |
843 | result to the 32-bit I/O port specified by Port. The value written to the I/O\r | |
844 | port is returned. This function must guarantee that all I/O read and write\r | |
845 | operations are serialized.\r | |
846 | \r | |
847 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
848 | \r | |
849 | @param Port The I/O port to write.\r | |
850 | @param OrData The value to OR with the read value from the I/O port.\r | |
851 | \r | |
852 | @return The value written back to the I/O port.\r | |
853 | \r | |
854 | **/\r | |
855 | UINT32\r | |
856 | EFIAPI\r | |
857 | S3IoOr32 (\r | |
858 | IN UINTN Port,\r | |
859 | IN UINT32 OrData\r | |
860 | )\r | |
861 | {\r | |
862 | return InternalSaveIoWrite32ValueToBootScript (Port, IoOr32 (Port, OrData));\r | |
863 | }\r | |
864 | \r | |
865 | /**\r | |
866 | Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back\r | |
867 | to the 32-bit I/O port and saves the value in the S3 script to be replayed\r | |
868 | on S3 resume.\r | |
869 | \r | |
870 | Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r | |
871 | the read result and the value specified by AndData, and writes the result to\r | |
872 | the 32-bit I/O port specified by Port. The value written to the I/O port is\r | |
873 | returned. This function must guarantee that all I/O read and write operations\r | |
874 | are serialized.\r | |
875 | \r | |
876 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
877 | \r | |
878 | @param Port The I/O port to write.\r | |
879 | @param AndData The value to AND with the read value from the I/O port.\r | |
880 | \r | |
881 | @return The value written back to the I/O port.\r | |
882 | \r | |
883 | **/\r | |
884 | UINT32\r | |
885 | EFIAPI\r | |
886 | S3IoAnd32 (\r | |
887 | IN UINTN Port,\r | |
888 | IN UINT32 AndData\r | |
889 | )\r | |
890 | {\r | |
891 | return InternalSaveIoWrite32ValueToBootScript (Port, IoAnd32 (Port, AndData));\r | |
892 | }\r | |
893 | \r | |
894 | /**\r | |
895 | Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise\r | |
9095d37b | 896 | inclusive OR, and writes the result back to the 32-bit I/O port and saves\r |
fe69ac84 | 897 | the value in the S3 script to be replayed on S3 resume.\r |
898 | \r | |
899 | Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r | |
900 | the read result and the value specified by AndData, performs a bitwise OR\r | |
901 | between the result of the AND operation and the value specified by OrData,\r | |
902 | and writes the result to the 32-bit I/O port specified by Port. The value\r | |
903 | written to the I/O port is returned. This function must guarantee that all\r | |
904 | I/O read and write operations are serialized.\r | |
905 | \r | |
906 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
907 | \r | |
908 | @param Port The I/O port to write.\r | |
909 | @param AndData The value to AND with the read value from the I/O port.\r | |
910 | @param OrData The value to OR with the result of the AND operation.\r | |
911 | \r | |
912 | @return The value written back to the I/O port.\r | |
913 | \r | |
914 | **/\r | |
915 | UINT32\r | |
916 | EFIAPI\r | |
917 | S3IoAndThenOr32 (\r | |
918 | IN UINTN Port,\r | |
919 | IN UINT32 AndData,\r | |
920 | IN UINT32 OrData\r | |
921 | )\r | |
922 | {\r | |
923 | return InternalSaveIoWrite32ValueToBootScript (Port, IoAndThenOr32 (Port, AndData, OrData));\r | |
924 | }\r | |
925 | \r | |
926 | /**\r | |
927 | Reads a bit field of an I/O register and saves the value in the S3 script to\r | |
928 | be replayed on S3 resume.\r | |
929 | \r | |
930 | Reads the bit field in a 32-bit I/O register. The bit field is specified by\r | |
931 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
932 | \r | |
933 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
934 | If StartBit is greater than 31, then ASSERT().\r | |
935 | If EndBit is greater than 31, then ASSERT().\r | |
936 | If EndBit is less than StartBit, then ASSERT().\r | |
937 | \r | |
938 | @param Port The I/O port to read.\r | |
939 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
940 | Range 0..31.\r | |
941 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
942 | Range 0..31.\r | |
943 | \r | |
944 | @return The value read.\r | |
945 | \r | |
946 | **/\r | |
947 | UINT32\r | |
948 | EFIAPI\r | |
949 | S3IoBitFieldRead32 (\r | |
950 | IN UINTN Port,\r | |
951 | IN UINTN StartBit,\r | |
952 | IN UINTN EndBit\r | |
953 | )\r | |
954 | {\r | |
955 | return InternalSaveIoWrite32ValueToBootScript (Port, IoBitFieldRead32 (Port, StartBit, EndBit));\r | |
956 | }\r | |
957 | \r | |
958 | /**\r | |
959 | Writes a bit field to an I/O register and saves the value in the S3 script to\r | |
960 | be replayed on S3 resume.\r | |
961 | \r | |
962 | Writes Value to the bit field of the I/O register. The bit field is specified\r | |
963 | by the StartBit and the EndBit. All other bits in the destination I/O\r | |
964 | register are preserved. The value written to the I/O port is returned. Extra\r | |
965 | left bits in Value are stripped.\r | |
966 | \r | |
967 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
968 | If StartBit is greater than 31, then ASSERT().\r | |
969 | If EndBit is greater than 31, then ASSERT().\r | |
970 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 971 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 972 | \r |
973 | @param Port The I/O port to write.\r | |
974 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
975 | Range 0..31.\r | |
976 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
977 | Range 0..31.\r | |
978 | @param Value New value of the bit field.\r | |
979 | \r | |
980 | @return The value written back to the I/O port.\r | |
981 | \r | |
982 | **/\r | |
983 | UINT32\r | |
984 | EFIAPI\r | |
985 | S3IoBitFieldWrite32 (\r | |
986 | IN UINTN Port,\r | |
987 | IN UINTN StartBit,\r | |
988 | IN UINTN EndBit,\r | |
989 | IN UINT32 Value\r | |
990 | )\r | |
991 | {\r | |
992 | return InternalSaveIoWrite32ValueToBootScript (Port, IoBitFieldWrite32 (Port, StartBit, EndBit, Value));\r | |
993 | }\r | |
994 | \r | |
995 | /**\r | |
996 | Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the\r | |
9095d37b | 997 | result back to the bit field in the 32-bit port and saves the value in the\r |
fe69ac84 | 998 | S3 script to be replayed on S3 resume.\r |
999 | \r | |
1000 | Reads the 32-bit I/O port specified by Port, performs a bitwise OR\r | |
1001 | between the read result and the value specified by OrData, and writes the\r | |
1002 | result to the 32-bit I/O port specified by Port. The value written to the I/O\r | |
1003 | port is returned. This function must guarantee that all I/O read and write\r | |
1004 | operations are serialized. Extra left bits in OrData are stripped.\r | |
1005 | \r | |
1006 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
1007 | If StartBit is greater than 31, then ASSERT().\r | |
1008 | If EndBit is greater than 31, then ASSERT().\r | |
1009 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1010 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 1011 | \r |
1012 | @param Port The I/O port to write.\r | |
1013 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1014 | Range 0..31.\r | |
1015 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1016 | Range 0..31.\r | |
1017 | @param OrData The value to OR with the read value from the I/O port.\r | |
1018 | \r | |
1019 | @return The value written back to the I/O port.\r | |
1020 | \r | |
1021 | **/\r | |
1022 | UINT32\r | |
1023 | EFIAPI\r | |
1024 | S3IoBitFieldOr32 (\r | |
1025 | IN UINTN Port,\r | |
1026 | IN UINTN StartBit,\r | |
1027 | IN UINTN EndBit,\r | |
1028 | IN UINT32 OrData\r | |
1029 | )\r | |
1030 | {\r | |
1031 | return InternalSaveIoWrite32ValueToBootScript (Port, IoBitFieldOr32 (Port, StartBit, EndBit, OrData));\r | |
1032 | }\r | |
1033 | \r | |
1034 | /**\r | |
1035 | Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the\r | |
9095d37b | 1036 | result back to the bit field in the 32-bit port and saves the value in the\r |
fe69ac84 | 1037 | S3 script to be replayed on S3 resume.\r |
1038 | \r | |
1039 | Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r | |
1040 | the read result and the value specified by AndData, and writes the result to\r | |
1041 | the 32-bit I/O port specified by Port. The value written to the I/O port is\r | |
1042 | returned. This function must guarantee that all I/O read and write operations\r | |
1043 | are serialized. Extra left bits in AndData are stripped.\r | |
1044 | \r | |
1045 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
1046 | If StartBit is greater than 31, then ASSERT().\r | |
1047 | If EndBit is greater than 31, then ASSERT().\r | |
1048 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1049 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 1050 | \r |
1051 | @param Port The I/O port to write.\r | |
1052 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1053 | Range 0..31.\r | |
1054 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1055 | Range 0..31.\r | |
1056 | @param AndData The value to AND with the read value from the I/O port.\r | |
1057 | \r | |
1058 | @return The value written back to the I/O port.\r | |
1059 | \r | |
1060 | **/\r | |
1061 | UINT32\r | |
1062 | EFIAPI\r | |
1063 | S3IoBitFieldAnd32 (\r | |
1064 | IN UINTN Port,\r | |
1065 | IN UINTN StartBit,\r | |
1066 | IN UINTN EndBit,\r | |
1067 | IN UINT32 AndData\r | |
1068 | )\r | |
1069 | {\r | |
1070 | return InternalSaveIoWrite32ValueToBootScript (Port, IoBitFieldAnd32 (Port, StartBit, EndBit, AndData));\r | |
1071 | }\r | |
1072 | \r | |
1073 | /**\r | |
1074 | Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r | |
1075 | bitwise OR, and writes the result back to the bit field in the\r | |
9095d37b | 1076 | 32-bit port and saves the value in the S3 script to be replayed on S3\r |
fe69ac84 | 1077 | resume.\r |
1078 | \r | |
1079 | Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed\r | |
1080 | by a bitwise OR between the read result and the value specified by\r | |
1081 | AndData, and writes the result to the 32-bit I/O port specified by Port. The\r | |
1082 | value written to the I/O port is returned. This function must guarantee that\r | |
1083 | all I/O read and write operations are serialized. Extra left bits in both\r | |
1084 | AndData and OrData are stripped.\r | |
1085 | \r | |
1086 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
1087 | If StartBit is greater than 31, then ASSERT().\r | |
1088 | If EndBit is greater than 31, then ASSERT().\r | |
1089 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
1090 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
1091 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fe69ac84 | 1092 | \r |
1093 | @param Port The I/O port to write.\r | |
1094 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1095 | Range 0..31.\r | |
1096 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1097 | Range 0..31.\r | |
1098 | @param AndData The value to AND with the read value from the I/O port.\r | |
1099 | @param OrData The value to OR with the result of the AND operation.\r | |
1100 | \r | |
1101 | @return The value written back to the I/O port.\r | |
1102 | \r | |
1103 | **/\r | |
1104 | UINT32\r | |
1105 | EFIAPI\r | |
1106 | S3IoBitFieldAndThenOr32 (\r | |
1107 | IN UINTN Port,\r | |
1108 | IN UINTN StartBit,\r | |
1109 | IN UINTN EndBit,\r | |
1110 | IN UINT32 AndData,\r | |
1111 | IN UINT32 OrData\r | |
1112 | )\r | |
1113 | {\r | |
1114 | return InternalSaveIoWrite32ValueToBootScript (Port, IoBitFieldAndThenOr32 (Port, StartBit, EndBit, AndData, OrData));\r | |
1115 | }\r | |
1116 | \r | |
1117 | /**\r | |
1118 | Saves a 64-bit I/O port value to the boot script.\r | |
1119 | \r | |
1120 | This internal worker function saves a 64-bit I/O port value in the S3 script\r | |
9095d37b | 1121 | to be replayed on S3 resume.\r |
fe69ac84 | 1122 | \r |
1123 | If the saving process fails, then ASSERT().\r | |
1124 | \r | |
1125 | @param Port The I/O port to write.\r | |
1126 | @param Value The value saved to boot script.\r | |
1127 | \r | |
1128 | @return Value.\r | |
1129 | \r | |
1130 | **/\r | |
1131 | UINT64\r | |
1132 | InternalSaveIoWrite64ValueToBootScript (\r | |
1133 | IN UINTN Port,\r | |
1134 | IN UINT64 Value\r | |
1135 | )\r | |
1136 | {\r | |
1137 | InternalSaveIoWriteValueToBootScript (S3BootScriptWidthUint64, Port, &Value);\r | |
9095d37b | 1138 | \r |
fe69ac84 | 1139 | return Value;\r |
1140 | }\r | |
1141 | \r | |
1142 | /**\r | |
1143 | Reads a 64-bit I/O port and saves the value in the S3 script to be replayed\r | |
1144 | on S3 resume.\r | |
1145 | \r | |
1146 | Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.\r | |
1147 | This function must guarantee that all I/O read and write operations are\r | |
1148 | serialized.\r | |
1149 | \r | |
1150 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1151 | \r | |
1152 | @param Port The I/O port to read.\r | |
1153 | \r | |
1154 | @return The value read.\r | |
1155 | \r | |
1156 | **/\r | |
1157 | UINT64\r | |
1158 | EFIAPI\r | |
1159 | S3IoRead64 (\r | |
1160 | IN UINTN Port\r | |
1161 | )\r | |
1162 | {\r | |
1163 | return InternalSaveIoWrite64ValueToBootScript (Port, IoRead64 (Port));\r | |
1164 | }\r | |
1165 | \r | |
1166 | /**\r | |
1167 | Writes a 64-bit I/O port and saves the value in the S3 script to be replayed\r | |
1168 | on S3 resume.\r | |
1169 | \r | |
1170 | Writes the 64-bit I/O port specified by Port with the value specified by Value\r | |
1171 | and returns Value. This function must guarantee that all I/O read and write\r | |
1172 | operations are serialized.\r | |
1173 | \r | |
1174 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1175 | \r | |
1176 | @param Port The I/O port to write.\r | |
1177 | @param Value The value to write to the I/O port.\r | |
1178 | \r | |
1179 | @return The value written the I/O port.\r | |
1180 | \r | |
1181 | **/\r | |
1182 | UINT64\r | |
1183 | EFIAPI\r | |
1184 | S3IoWrite64 (\r | |
1185 | IN UINTN Port,\r | |
1186 | IN UINT64 Value\r | |
1187 | )\r | |
1188 | {\r | |
1189 | return InternalSaveIoWrite64ValueToBootScript (Port, IoWrite64 (Port, Value));\r | |
1190 | }\r | |
1191 | \r | |
1192 | /**\r | |
1193 | Reads a 64-bit I/O port, performs a bitwise OR, and writes the\r | |
9095d37b | 1194 | result back to the 64-bit I/O port and saves the value in the S3 script to\r |
fe69ac84 | 1195 | be replayed on S3 resume.\r |
1196 | \r | |
1197 | Reads the 64-bit I/O port specified by Port, performs a bitwise OR\r | |
1198 | between the read result and the value specified by OrData, and writes the\r | |
1199 | result to the 64-bit I/O port specified by Port. The value written to the I/O\r | |
1200 | port is returned. This function must guarantee that all I/O read and write\r | |
1201 | operations are serialized.\r | |
1202 | \r | |
1203 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1204 | \r | |
1205 | @param Port The I/O port to write.\r | |
1206 | @param OrData The value to OR with the read value from the I/O port.\r | |
1207 | \r | |
1208 | @return The value written back to the I/O port.\r | |
1209 | \r | |
1210 | **/\r | |
1211 | UINT64\r | |
1212 | EFIAPI\r | |
1213 | S3IoOr64 (\r | |
1214 | IN UINTN Port,\r | |
1215 | IN UINT64 OrData\r | |
1216 | )\r | |
1217 | {\r | |
1218 | return InternalSaveIoWrite64ValueToBootScript (Port, IoOr64 (Port, OrData));\r | |
1219 | }\r | |
1220 | \r | |
1221 | /**\r | |
1222 | Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back\r | |
1223 | to the 64-bit I/O port and saves the value in the S3 script to be replayed\r | |
1224 | on S3 resume.\r | |
1225 | \r | |
1226 | Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r | |
1227 | the read result and the value specified by AndData, and writes the result to\r | |
1228 | the 64-bit I/O port specified by Port. The value written to the I/O port is\r | |
1229 | returned. This function must guarantee that all I/O read and write operations\r | |
1230 | are serialized.\r | |
1231 | \r | |
1232 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1233 | \r | |
1234 | @param Port The I/O port to write.\r | |
1235 | @param AndData The value to AND with the read value from the I/O port.\r | |
1236 | \r | |
1237 | @return The value written back to the I/O port.\r | |
1238 | \r | |
1239 | **/\r | |
1240 | UINT64\r | |
1241 | EFIAPI\r | |
1242 | S3IoAnd64 (\r | |
1243 | IN UINTN Port,\r | |
1244 | IN UINT64 AndData\r | |
1245 | )\r | |
1246 | {\r | |
1247 | return InternalSaveIoWrite64ValueToBootScript (Port, IoAnd64 (Port, AndData));\r | |
1248 | }\r | |
1249 | \r | |
1250 | /**\r | |
1251 | Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise\r | |
1252 | inclusive OR, and writes the result back to the 64-bit I/O port and saves\r | |
1253 | the value in the S3 script to be replayed on S3 resume.\r | |
1254 | \r | |
1255 | Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r | |
1256 | the read result and the value specified by AndData, performs a bitwise OR\r | |
1257 | between the result of the AND operation and the value specified by OrData,\r | |
1258 | and writes the result to the 64-bit I/O port specified by Port. The value\r | |
1259 | written to the I/O port is returned. This function must guarantee that all\r | |
1260 | I/O read and write operations are serialized.\r | |
1261 | \r | |
1262 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1263 | \r | |
1264 | @param Port The I/O port to write.\r | |
1265 | @param AndData The value to AND with the read value from the I/O port.\r | |
1266 | @param OrData The value to OR with the result of the AND operation.\r | |
1267 | \r | |
1268 | @return The value written back to the I/O port.\r | |
1269 | \r | |
1270 | **/\r | |
1271 | UINT64\r | |
1272 | EFIAPI\r | |
1273 | S3IoAndThenOr64 (\r | |
1274 | IN UINTN Port,\r | |
1275 | IN UINT64 AndData,\r | |
1276 | IN UINT64 OrData\r | |
1277 | )\r | |
1278 | {\r | |
1279 | return InternalSaveIoWrite64ValueToBootScript (Port, IoAndThenOr64 (Port, AndData, OrData));\r | |
1280 | }\r | |
1281 | \r | |
1282 | /**\r | |
1283 | Reads a bit field of an I/O register and saves the value in the S3 script to\r | |
1284 | be replayed on S3 resume.\r | |
1285 | \r | |
1286 | Reads the bit field in a 64-bit I/O register. The bit field is specified by\r | |
1287 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
1288 | \r | |
1289 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1290 | If StartBit is greater than 63, then ASSERT().\r | |
1291 | If EndBit is greater than 63, then ASSERT().\r | |
1292 | If EndBit is less than StartBit, then ASSERT().\r | |
1293 | \r | |
1294 | @param Port The I/O port to read.\r | |
1295 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1296 | Range 0..63.\r | |
1297 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1298 | Range 0..63.\r | |
1299 | \r | |
1300 | @return The value read.\r | |
1301 | \r | |
1302 | **/\r | |
1303 | UINT64\r | |
1304 | EFIAPI\r | |
1305 | S3IoBitFieldRead64 (\r | |
1306 | IN UINTN Port,\r | |
1307 | IN UINTN StartBit,\r | |
1308 | IN UINTN EndBit\r | |
1309 | )\r | |
1310 | {\r | |
1311 | return InternalSaveIoWrite64ValueToBootScript (Port, IoBitFieldRead64 (Port, StartBit, EndBit));\r | |
1312 | }\r | |
1313 | \r | |
1314 | /**\r | |
1315 | Writes a bit field to an I/O register and saves the value in the S3 script to\r | |
1316 | be replayed on S3 resume.\r | |
1317 | \r | |
1318 | Writes Value to the bit field of the I/O register. The bit field is specified\r | |
1319 | by the StartBit and the EndBit. All other bits in the destination I/O\r | |
1320 | register are preserved. The value written to the I/O port is returned. Extra\r | |
1321 | left bits in Value are stripped.\r | |
1322 | \r | |
1323 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1324 | If StartBit is greater than 63, then ASSERT().\r | |
1325 | If EndBit is greater than 63, then ASSERT().\r | |
1326 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1327 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 1328 | \r |
1329 | @param Port The I/O port to write.\r | |
1330 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1331 | Range 0..63.\r | |
1332 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1333 | Range 0..63.\r | |
1334 | @param Value New value of the bit field.\r | |
1335 | \r | |
1336 | @return The value written back to the I/O port.\r | |
1337 | \r | |
1338 | **/\r | |
1339 | UINT64\r | |
1340 | EFIAPI\r | |
1341 | S3IoBitFieldWrite64 (\r | |
1342 | IN UINTN Port,\r | |
1343 | IN UINTN StartBit,\r | |
1344 | IN UINTN EndBit,\r | |
1345 | IN UINT64 Value\r | |
1346 | )\r | |
1347 | {\r | |
1348 | return InternalSaveIoWrite64ValueToBootScript (Port, IoBitFieldWrite64 (Port, StartBit, EndBit, Value));\r | |
1349 | }\r | |
1350 | \r | |
1351 | /**\r | |
1352 | Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the\r | |
9095d37b | 1353 | result back to the bit field in the 64-bit port and saves the value in the\r |
fe69ac84 | 1354 | S3 script to be replayed on S3 resume.\r |
1355 | \r | |
1356 | Reads the 64-bit I/O port specified by Port, performs a bitwise OR\r | |
1357 | between the read result and the value specified by OrData, and writes the\r | |
1358 | result to the 64-bit I/O port specified by Port. The value written to the I/O\r | |
1359 | port is returned. This function must guarantee that all I/O read and write\r | |
1360 | operations are serialized. Extra left bits in OrData are stripped.\r | |
1361 | \r | |
1362 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1363 | If StartBit is greater than 63, then ASSERT().\r | |
1364 | If EndBit is greater than 63, then ASSERT().\r | |
1365 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1366 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 1367 | \r |
1368 | @param Port The I/O port to write.\r | |
1369 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1370 | Range 0..63.\r | |
1371 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1372 | Range 0..63.\r | |
1373 | @param OrData The value to OR with the read value from the I/O port.\r | |
1374 | \r | |
1375 | @return The value written back to the I/O port.\r | |
1376 | \r | |
1377 | **/\r | |
1378 | UINT64\r | |
1379 | EFIAPI\r | |
1380 | S3IoBitFieldOr64 (\r | |
1381 | IN UINTN Port,\r | |
1382 | IN UINTN StartBit,\r | |
1383 | IN UINTN EndBit,\r | |
1384 | IN UINT64 OrData\r | |
1385 | )\r | |
1386 | {\r | |
1387 | return InternalSaveIoWrite64ValueToBootScript (Port, IoBitFieldOr64 (Port, StartBit, EndBit, OrData));\r | |
1388 | }\r | |
1389 | \r | |
1390 | /**\r | |
1391 | Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the\r | |
9095d37b | 1392 | result back to the bit field in the 64-bit port and saves the value in the\r |
fe69ac84 | 1393 | S3 script to be replayed on S3 resume.\r |
1394 | \r | |
1395 | Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r | |
1396 | the read result and the value specified by AndData, and writes the result to\r | |
1397 | the 64-bit I/O port specified by Port. The value written to the I/O port is\r | |
1398 | returned. This function must guarantee that all I/O read and write operations\r | |
1399 | are serialized. Extra left bits in AndData are stripped.\r | |
1400 | \r | |
1401 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1402 | If StartBit is greater than 63, then ASSERT().\r | |
1403 | If EndBit is greater than 63, then ASSERT().\r | |
1404 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1405 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 1406 | \r |
1407 | @param Port The I/O port to write.\r | |
1408 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1409 | Range 0..63.\r | |
1410 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1411 | Range 0..63.\r | |
1412 | @param AndData The value to AND with the read value from the I/O port.\r | |
1413 | \r | |
1414 | @return The value written back to the I/O port.\r | |
1415 | \r | |
1416 | **/\r | |
1417 | UINT64\r | |
1418 | EFIAPI\r | |
1419 | S3IoBitFieldAnd64 (\r | |
1420 | IN UINTN Port,\r | |
1421 | IN UINTN StartBit,\r | |
1422 | IN UINTN EndBit,\r | |
1423 | IN UINT64 AndData\r | |
1424 | )\r | |
1425 | {\r | |
1426 | return InternalSaveIoWrite64ValueToBootScript (Port, IoBitFieldAnd64 (Port, StartBit, EndBit, AndData));\r | |
1427 | }\r | |
1428 | \r | |
1429 | /**\r | |
1430 | Reads a bit field in a 64-bit port, performs a bitwise AND followed by a\r | |
1431 | bitwise OR, and writes the result back to the bit field in the\r | |
9095d37b | 1432 | 64-bit port and saves the value in the S3 script to be replayed on S3\r |
fe69ac84 | 1433 | resume.\r |
1434 | \r | |
1435 | Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed\r | |
1436 | by a bitwise OR between the read result and the value specified by\r | |
1437 | AndData, and writes the result to the 64-bit I/O port specified by Port. The\r | |
1438 | value written to the I/O port is returned. This function must guarantee that\r | |
1439 | all I/O read and write operations are serialized. Extra left bits in both\r | |
1440 | AndData and OrData are stripped.\r | |
1441 | \r | |
1442 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1443 | If StartBit is greater than 63, then ASSERT().\r | |
1444 | If EndBit is greater than 63, then ASSERT().\r | |
1445 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
1446 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
1447 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fe69ac84 | 1448 | \r |
1449 | @param Port The I/O port to write.\r | |
1450 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1451 | Range 0..63.\r | |
1452 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1453 | Range 0..63.\r | |
1454 | @param AndData The value to AND with the read value from the I/O port.\r | |
1455 | @param OrData The value to OR with the result of the AND operation.\r | |
1456 | \r | |
1457 | @return The value written back to the I/O port.\r | |
1458 | \r | |
1459 | **/\r | |
1460 | UINT64\r | |
1461 | EFIAPI\r | |
1462 | S3IoBitFieldAndThenOr64 (\r | |
1463 | IN UINTN Port,\r | |
1464 | IN UINTN StartBit,\r | |
1465 | IN UINTN EndBit,\r | |
1466 | IN UINT64 AndData,\r | |
1467 | IN UINT64 OrData\r | |
1468 | )\r | |
1469 | {\r | |
1470 | return InternalSaveIoWrite64ValueToBootScript (Port, IoBitFieldAndThenOr64 (Port, StartBit, EndBit, AndData, OrData));\r | |
1471 | }\r | |
1472 | \r | |
1473 | /**\r | |
1474 | Saves an MMIO register value to the boot script.\r | |
1475 | \r | |
1476 | This internal worker function saves an MMIO register value in the S3 script\r | |
9095d37b | 1477 | to be replayed on S3 resume.\r |
fe69ac84 | 1478 | \r |
1479 | If the saving process fails, then ASSERT().\r | |
1480 | \r | |
1481 | @param Width The width of MMIO register.\r | |
1482 | @param Address The MMIO register to write.\r | |
1483 | @param Buffer The buffer containing value.\r | |
1484 | \r | |
1485 | **/\r | |
1486 | VOID\r | |
1487 | InternalSaveMmioWriteValueToBootScript (\r | |
1488 | IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r | |
1489 | IN UINTN Address,\r | |
1490 | IN VOID *Buffer\r | |
1491 | )\r | |
1492 | {\r | |
1493 | RETURN_STATUS Status;\r | |
1494 | \r | |
1495 | Status = S3BootScriptSaveMemWrite (\r | |
1496 | Width,\r | |
1497 | Address,\r | |
1498 | 1,\r | |
1499 | Buffer\r | |
1500 | );\r | |
1501 | ASSERT (Status == RETURN_SUCCESS);\r | |
1502 | }\r | |
1503 | \r | |
1504 | /**\r | |
1505 | Saves an 8-bit MMIO register value to the boot script.\r | |
1506 | \r | |
1507 | This internal worker function saves an 8-bit MMIO register value in the S3 script\r | |
9095d37b | 1508 | to be replayed on S3 resume.\r |
fe69ac84 | 1509 | \r |
1510 | If the saving process fails, then ASSERT().\r | |
1511 | \r | |
1512 | @param Address The MMIO register to write.\r | |
1513 | @param Value The value saved to boot script.\r | |
1514 | \r | |
1515 | @return Value.\r | |
1516 | \r | |
1517 | **/\r | |
1518 | UINT8\r | |
1519 | InternalSaveMmioWrite8ValueToBootScript (\r | |
1520 | IN UINTN Address,\r | |
1521 | IN UINT8 Value\r | |
1522 | )\r | |
1523 | {\r | |
1524 | InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint8, Address, &Value);\r | |
1525 | \r | |
1526 | return Value;\r | |
1527 | }\r | |
1528 | \r | |
1529 | /**\r | |
9095d37b | 1530 | Reads an 8-bit MMIO register and saves the value in the S3 script to be\r |
fe69ac84 | 1531 | replayed on S3 resume.\r |
1532 | \r | |
1533 | Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r | |
1534 | returned. This function must guarantee that all MMIO read and write\r | |
1535 | operations are serialized.\r | |
1536 | \r | |
1537 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1538 | \r | |
1539 | @param Address The MMIO register to read.\r | |
1540 | \r | |
1541 | @return The value read.\r | |
1542 | \r | |
1543 | **/\r | |
1544 | UINT8\r | |
1545 | EFIAPI\r | |
1546 | S3MmioRead8 (\r | |
1547 | IN UINTN Address\r | |
1548 | )\r | |
1549 | {\r | |
1550 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioRead8 (Address));\r | |
1551 | }\r | |
1552 | \r | |
1553 | /**\r | |
9095d37b | 1554 | Writes an 8-bit MMIO register and saves the value in the S3 script to be\r |
fe69ac84 | 1555 | replayed on S3 resume.\r |
1556 | \r | |
1557 | Writes the 8-bit MMIO register specified by Address with the value specified\r | |
1558 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
1559 | and write operations are serialized.\r | |
1560 | \r | |
1561 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1562 | \r | |
1563 | @param Address The MMIO register to write.\r | |
1564 | @param Value The value to write to the MMIO register.\r | |
1565 | \r | |
1566 | @return The value written the MMIO register.\r | |
1567 | \r | |
1568 | **/\r | |
1569 | UINT8\r | |
1570 | EFIAPI\r | |
1571 | S3MmioWrite8 (\r | |
1572 | IN UINTN Address,\r | |
1573 | IN UINT8 Value\r | |
1574 | )\r | |
1575 | {\r | |
1576 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioWrite8 (Address, Value));\r | |
1577 | }\r | |
1578 | \r | |
1579 | /**\r | |
1580 | Reads an 8-bit MMIO register, performs a bitwise OR, and writes the\r | |
9095d37b | 1581 | result back to the 8-bit MMIO register and saves the value in the S3 script\r |
fe69ac84 | 1582 | to be replayed on S3 resume.\r |
1583 | \r | |
1584 | Reads the 8-bit MMIO register specified by Address, performs a bitwise\r | |
1585 | inclusive OR between the read result and the value specified by OrData, and\r | |
1586 | writes the result to the 8-bit MMIO register specified by Address. The value\r | |
1587 | written to the MMIO register is returned. This function must guarantee that\r | |
1588 | all MMIO read and write operations are serialized.\r | |
1589 | \r | |
1590 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1591 | \r | |
1592 | @param Address The MMIO register to write.\r | |
1593 | @param OrData The value to OR with the read value from the MMIO register.\r | |
1594 | \r | |
1595 | @return The value written back to the MMIO register.\r | |
1596 | \r | |
1597 | **/\r | |
1598 | UINT8\r | |
1599 | EFIAPI\r | |
1600 | S3MmioOr8 (\r | |
1601 | IN UINTN Address,\r | |
1602 | IN UINT8 OrData\r | |
1603 | )\r | |
1604 | {\r | |
1605 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioOr8 (Address, OrData));\r | |
1606 | }\r | |
1607 | \r | |
1608 | /**\r | |
1609 | Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result\r | |
9095d37b | 1610 | back to the 8-bit MMIO register and saves the value in the S3 script to be\r |
fe69ac84 | 1611 | replayed on S3 resume.\r |
1612 | \r | |
1613 | Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r | |
1614 | between the read result and the value specified by AndData, and writes the\r | |
1615 | result to the 8-bit MMIO register specified by Address. The value written to\r | |
1616 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
1617 | read and write operations are serialized.\r | |
1618 | \r | |
1619 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1620 | \r | |
1621 | @param Address The MMIO register to write.\r | |
1622 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1623 | \r | |
1624 | @return The value written back to the MMIO register.\r | |
1625 | \r | |
1626 | **/\r | |
1627 | UINT8\r | |
1628 | EFIAPI\r | |
1629 | S3MmioAnd8 (\r | |
1630 | IN UINTN Address,\r | |
1631 | IN UINT8 AndData\r | |
1632 | )\r | |
1633 | {\r | |
1634 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioAnd8 (Address, AndData));\r | |
1635 | }\r | |
1636 | \r | |
1637 | /**\r | |
1638 | Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise\r | |
9095d37b | 1639 | inclusive OR, and writes the result back to the 8-bit MMIO register and saves\r |
fe69ac84 | 1640 | the value in the S3 script to be replayed on S3 resume.\r |
1641 | \r | |
1642 | Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r | |
1643 | between the read result and the value specified by AndData, performs a\r | |
1644 | bitwise OR between the result of the AND operation and the value specified by\r | |
1645 | OrData, and writes the result to the 8-bit MMIO register specified by\r | |
1646 | Address. The value written to the MMIO register is returned. This function\r | |
1647 | must guarantee that all MMIO read and write operations are serialized.\r | |
1648 | \r | |
1649 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1650 | \r | |
1651 | @param Address The MMIO register to write.\r | |
1652 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1653 | @param OrData The value to OR with the result of the AND operation.\r | |
1654 | \r | |
1655 | @return The value written back to the MMIO register.\r | |
1656 | \r | |
1657 | **/\r | |
1658 | UINT8\r | |
1659 | EFIAPI\r | |
1660 | S3MmioAndThenOr8 (\r | |
1661 | IN UINTN Address,\r | |
1662 | IN UINT8 AndData,\r | |
1663 | IN UINT8 OrData\r | |
1664 | )\r | |
1665 | {\r | |
1666 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioAndThenOr8 (Address, AndData, OrData));\r | |
1667 | }\r | |
1668 | \r | |
1669 | /**\r | |
1670 | Reads a bit field of a MMIO register and saves the value in the S3 script to\r | |
1671 | be replayed on S3 resume.\r | |
1672 | \r | |
1673 | Reads the bit field in an 8-bit MMIO register. The bit field is specified by\r | |
1674 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
1675 | \r | |
1676 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1677 | If StartBit is greater than 7, then ASSERT().\r | |
1678 | If EndBit is greater than 7, then ASSERT().\r | |
1679 | If EndBit is less than StartBit, then ASSERT().\r | |
1680 | \r | |
1681 | @param Address MMIO register to read.\r | |
1682 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1683 | Range 0..7.\r | |
1684 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1685 | Range 0..7.\r | |
1686 | \r | |
1687 | @return The value read.\r | |
1688 | \r | |
1689 | **/\r | |
1690 | UINT8\r | |
1691 | EFIAPI\r | |
1692 | S3MmioBitFieldRead8 (\r | |
1693 | IN UINTN Address,\r | |
1694 | IN UINTN StartBit,\r | |
1695 | IN UINTN EndBit\r | |
1696 | )\r | |
1697 | {\r | |
1698 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioBitFieldRead8 (Address, StartBit, EndBit));\r | |
1699 | }\r | |
1700 | \r | |
1701 | /**\r | |
1702 | Writes a bit field to an MMIO register and saves the value in the S3 script to\r | |
1703 | be replayed on S3 resume.\r | |
1704 | \r | |
1705 | Writes Value to the bit field of the MMIO register. The bit field is\r | |
1706 | specified by the StartBit and the EndBit. All other bits in the destination\r | |
1707 | MMIO register are preserved. The new value of the 8-bit register is returned.\r | |
1708 | \r | |
1709 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1710 | If StartBit is greater than 7, then ASSERT().\r | |
1711 | If EndBit is greater than 7, then ASSERT().\r | |
1712 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1713 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 1714 | \r |
1715 | @param Address The MMIO register to write.\r | |
1716 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1717 | Range 0..7.\r | |
1718 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1719 | Range 0..7.\r | |
1720 | @param Value New value of the bit field.\r | |
1721 | \r | |
1722 | @return The value written back to the MMIO register.\r | |
1723 | \r | |
1724 | **/\r | |
1725 | UINT8\r | |
1726 | EFIAPI\r | |
1727 | S3MmioBitFieldWrite8 (\r | |
1728 | IN UINTN Address,\r | |
1729 | IN UINTN StartBit,\r | |
1730 | IN UINTN EndBit,\r | |
1731 | IN UINT8 Value\r | |
1732 | )\r | |
1733 | {\r | |
1734 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioBitFieldWrite8 (Address, StartBit, EndBit, Value));\r | |
1735 | }\r | |
1736 | \r | |
1737 | /**\r | |
1738 | Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and\r | |
1739 | writes the result back to the bit field in the 8-bit MMIO register and saves\r | |
1740 | the value in the S3 script to be replayed on S3 resume.\r | |
1741 | \r | |
1742 | Reads the 8-bit MMIO register specified by Address, performs a bitwise\r | |
1743 | inclusive OR between the read result and the value specified by OrData, and\r | |
1744 | writes the result to the 8-bit MMIO register specified by Address. The value\r | |
1745 | written to the MMIO register is returned. This function must guarantee that\r | |
1746 | all MMIO read and write operations are serialized. Extra left bits in OrData\r | |
1747 | are stripped.\r | |
1748 | \r | |
1749 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1750 | If StartBit is greater than 7, then ASSERT().\r | |
1751 | If EndBit is greater than 7, then ASSERT().\r | |
1752 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1753 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 1754 | \r |
1755 | @param Address The MMIO register to write.\r | |
1756 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1757 | Range 0..7.\r | |
1758 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1759 | Range 0..7.\r | |
1760 | @param OrData The value to OR with the read value from the MMIO register.\r | |
1761 | \r | |
1762 | @return The value written back to the MMIO register.\r | |
1763 | \r | |
1764 | **/\r | |
1765 | UINT8\r | |
1766 | EFIAPI\r | |
1767 | S3MmioBitFieldOr8 (\r | |
1768 | IN UINTN Address,\r | |
1769 | IN UINTN StartBit,\r | |
1770 | IN UINTN EndBit,\r | |
1771 | IN UINT8 OrData\r | |
1772 | )\r | |
1773 | {\r | |
1774 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioBitFieldOr8 (Address, StartBit, EndBit, OrData));\r | |
1775 | }\r | |
1776 | \r | |
1777 | /**\r | |
1778 | Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and\r | |
1779 | writes the result back to the bit field in the 8-bit MMIO register and saves\r | |
1780 | the value in the S3 script to be replayed on S3 resume.\r | |
1781 | \r | |
1782 | Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r | |
1783 | between the read result and the value specified by AndData, and writes the\r | |
1784 | result to the 8-bit MMIO register specified by Address. The value written to\r | |
1785 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
1786 | read and write operations are serialized. Extra left bits in AndData are\r | |
1787 | stripped.\r | |
1788 | \r | |
1789 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1790 | If StartBit is greater than 7, then ASSERT().\r | |
1791 | If EndBit is greater than 7, then ASSERT().\r | |
1792 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1793 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 1794 | \r |
1795 | @param Address The MMIO register to write.\r | |
1796 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1797 | Range 0..7.\r | |
1798 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1799 | Range 0..7.\r | |
1800 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1801 | \r | |
1802 | @return The value written back to the MMIO register.\r | |
1803 | \r | |
1804 | **/\r | |
1805 | UINT8\r | |
1806 | EFIAPI\r | |
1807 | S3MmioBitFieldAnd8 (\r | |
1808 | IN UINTN Address,\r | |
1809 | IN UINTN StartBit,\r | |
1810 | IN UINTN EndBit,\r | |
1811 | IN UINT8 AndData\r | |
1812 | )\r | |
1813 | {\r | |
1814 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioBitFieldAnd8 (Address, StartBit, EndBit, AndData));\r | |
1815 | }\r | |
1816 | \r | |
1817 | /**\r | |
1818 | Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed\r | |
1819 | by a bitwise OR, and writes the result back to the bit field in the\r | |
1820 | 8-bit MMIO register and saves the value in the S3 script to be replayed\r | |
1821 | on S3 resume.\r | |
1822 | \r | |
1823 | Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r | |
1824 | followed by a bitwise OR between the read result and the value\r | |
1825 | specified by AndData, and writes the result to the 8-bit MMIO register\r | |
1826 | specified by Address. The value written to the MMIO register is returned.\r | |
1827 | This function must guarantee that all MMIO read and write operations are\r | |
1828 | serialized. Extra left bits in both AndData and OrData are stripped.\r | |
1829 | \r | |
1830 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1831 | If StartBit is greater than 7, then ASSERT().\r | |
1832 | If EndBit is greater than 7, then ASSERT().\r | |
1833 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
1834 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
1835 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fe69ac84 | 1836 | \r |
1837 | @param Address The MMIO register to write.\r | |
1838 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1839 | Range 0..7.\r | |
1840 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1841 | Range 0..7.\r | |
1842 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1843 | @param OrData The value to OR with the result of the AND operation.\r | |
1844 | \r | |
1845 | @return The value written back to the MMIO register.\r | |
1846 | \r | |
1847 | **/\r | |
1848 | UINT8\r | |
1849 | EFIAPI\r | |
1850 | S3MmioBitFieldAndThenOr8 (\r | |
1851 | IN UINTN Address,\r | |
1852 | IN UINTN StartBit,\r | |
1853 | IN UINTN EndBit,\r | |
1854 | IN UINT8 AndData,\r | |
1855 | IN UINT8 OrData\r | |
1856 | )\r | |
1857 | {\r | |
1858 | return InternalSaveMmioWrite8ValueToBootScript (Address, MmioBitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData));\r | |
1859 | }\r | |
1860 | \r | |
1861 | /**\r | |
1862 | Saves a 16-bit MMIO register value to the boot script.\r | |
1863 | \r | |
1864 | This internal worker function saves a 16-bit MMIO register value in the S3 script\r | |
9095d37b | 1865 | to be replayed on S3 resume.\r |
fe69ac84 | 1866 | \r |
1867 | If the saving process fails, then ASSERT().\r | |
1868 | \r | |
1869 | @param Address The MMIO register to write.\r | |
1870 | @param Value The value saved to boot script.\r | |
1871 | \r | |
1872 | @return Value.\r | |
1873 | \r | |
1874 | **/\r | |
1875 | UINT16\r | |
1876 | InternalSaveMmioWrite16ValueToBootScript (\r | |
1877 | IN UINTN Address,\r | |
1878 | IN UINT16 Value\r | |
1879 | )\r | |
1880 | {\r | |
1881 | InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint16, Address, &Value);\r | |
9095d37b | 1882 | \r |
fe69ac84 | 1883 | return Value;\r |
1884 | }\r | |
1885 | \r | |
1886 | /**\r | |
1887 | Reads a 16-bit MMIO register and saves the value in the S3 script to be replayed\r | |
1888 | on S3 resume.\r | |
1889 | \r | |
1890 | Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r | |
1891 | returned. This function must guarantee that all MMIO read and write\r | |
1892 | operations are serialized.\r | |
1893 | \r | |
1894 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1895 | \r | |
1896 | @param Address The MMIO register to read.\r | |
1897 | \r | |
1898 | @return The value read.\r | |
1899 | \r | |
1900 | **/\r | |
1901 | UINT16\r | |
1902 | EFIAPI\r | |
1903 | S3MmioRead16 (\r | |
1904 | IN UINTN Address\r | |
1905 | )\r | |
1906 | {\r | |
1907 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioRead16 (Address));\r | |
1908 | }\r | |
1909 | \r | |
1910 | /**\r | |
1911 | Writes a 16-bit MMIO register and saves the value in the S3 script to be replayed\r | |
1912 | on S3 resume.\r | |
1913 | \r | |
1914 | Writes the 16-bit MMIO register specified by Address with the value specified\r | |
1915 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
1916 | and write operations are serialized and saves the value in the S3 script to be\r | |
1917 | replayed on S3 resume.\r | |
1918 | \r | |
1919 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1920 | \r | |
1921 | @param Address The MMIO register to write.\r | |
1922 | @param Value The value to write to the MMIO register.\r | |
1923 | \r | |
1924 | @return The value written the MMIO register.\r | |
1925 | \r | |
1926 | **/\r | |
1927 | UINT16\r | |
1928 | EFIAPI\r | |
1929 | S3MmioWrite16 (\r | |
1930 | IN UINTN Address,\r | |
1931 | IN UINT16 Value\r | |
1932 | )\r | |
1933 | {\r | |
1934 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioWrite16 (Address, Value));\r | |
1935 | }\r | |
1936 | \r | |
1937 | /**\r | |
1938 | Reads a 16-bit MMIO register, performs a bitwise OR, and writes the\r | |
9095d37b | 1939 | result back to the 16-bit MMIO register and saves the value in the S3 script\r |
fe69ac84 | 1940 | to be replayed on S3 resume.\r |
1941 | \r | |
1942 | Reads the 16-bit MMIO register specified by Address, performs a bitwise\r | |
1943 | inclusive OR between the read result and the value specified by OrData, and\r | |
1944 | writes the result to the 16-bit MMIO register specified by Address. The value\r | |
1945 | written to the MMIO register is returned. This function must guarantee that\r | |
1946 | all MMIO read and write operations are serialized.\r | |
1947 | \r | |
1948 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1949 | \r | |
1950 | @param Address The MMIO register to write.\r | |
1951 | @param OrData The value to OR with the read value from the MMIO register.\r | |
1952 | \r | |
1953 | @return The value written back to the MMIO register.\r | |
1954 | \r | |
1955 | **/\r | |
1956 | UINT16\r | |
1957 | EFIAPI\r | |
1958 | S3MmioOr16 (\r | |
1959 | IN UINTN Address,\r | |
1960 | IN UINT16 OrData\r | |
1961 | )\r | |
1962 | {\r | |
1963 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioOr16 (Address, OrData));\r | |
1964 | }\r | |
1965 | \r | |
1966 | /**\r | |
1967 | Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result\r | |
9095d37b | 1968 | back to the 16-bit MMIO register and saves the value in the S3 script to be\r |
fe69ac84 | 1969 | replayed on S3 resume.\r |
1970 | \r | |
1971 | Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r | |
1972 | between the read result and the value specified by AndData, and writes the\r | |
1973 | result to the 16-bit MMIO register specified by Address. The value written to\r | |
1974 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
1975 | read and write operations are serialized.\r | |
1976 | \r | |
1977 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1978 | \r | |
1979 | @param Address The MMIO register to write.\r | |
1980 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1981 | \r | |
1982 | @return The value written back to the MMIO register.\r | |
1983 | \r | |
1984 | **/\r | |
1985 | UINT16\r | |
1986 | EFIAPI\r | |
1987 | S3MmioAnd16 (\r | |
1988 | IN UINTN Address,\r | |
1989 | IN UINT16 AndData\r | |
1990 | )\r | |
1991 | {\r | |
1992 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioAnd16 (Address, AndData));\r | |
1993 | }\r | |
1994 | \r | |
1995 | /**\r | |
1996 | Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise\r | |
9095d37b | 1997 | inclusive OR, and writes the result back to the 16-bit MMIO register and\r |
fe69ac84 | 1998 | saves the value in the S3 script to be replayed on S3 resume.\r |
1999 | \r | |
2000 | Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r | |
2001 | between the read result and the value specified by AndData, performs a\r | |
2002 | bitwise OR between the result of the AND operation and the value specified by\r | |
2003 | OrData, and writes the result to the 16-bit MMIO register specified by\r | |
2004 | Address. The value written to the MMIO register is returned. This function\r | |
2005 | must guarantee that all MMIO read and write operations are serialized.\r | |
2006 | \r | |
2007 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
2008 | \r | |
2009 | @param Address The MMIO register to write.\r | |
2010 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2011 | @param OrData The value to OR with the result of the AND operation.\r | |
2012 | \r | |
2013 | @return The value written back to the MMIO register.\r | |
2014 | \r | |
2015 | **/\r | |
2016 | UINT16\r | |
2017 | EFIAPI\r | |
2018 | S3MmioAndThenOr16 (\r | |
2019 | IN UINTN Address,\r | |
2020 | IN UINT16 AndData,\r | |
2021 | IN UINT16 OrData\r | |
2022 | )\r | |
2023 | {\r | |
2024 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioAndThenOr16 (Address, AndData, OrData));\r | |
2025 | }\r | |
2026 | \r | |
2027 | /**\r | |
2028 | Reads a bit field of a MMIO register and saves the value in the S3 script to\r | |
2029 | be replayed on S3 resume.\r | |
2030 | \r | |
2031 | Reads the bit field in a 16-bit MMIO register. The bit field is specified by\r | |
2032 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
2033 | \r | |
2034 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
2035 | If StartBit is greater than 15, then ASSERT().\r | |
2036 | If EndBit is greater than 15, then ASSERT().\r | |
2037 | If EndBit is less than StartBit, then ASSERT().\r | |
2038 | \r | |
2039 | @param Address MMIO register to read.\r | |
2040 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2041 | Range 0..15.\r | |
2042 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2043 | Range 0..15.\r | |
2044 | \r | |
2045 | @return The value read.\r | |
2046 | \r | |
2047 | **/\r | |
2048 | UINT16\r | |
2049 | EFIAPI\r | |
2050 | S3MmioBitFieldRead16 (\r | |
2051 | IN UINTN Address,\r | |
2052 | IN UINTN StartBit,\r | |
2053 | IN UINTN EndBit\r | |
2054 | )\r | |
2055 | {\r | |
2056 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioBitFieldRead16 (Address, StartBit, EndBit));\r | |
2057 | }\r | |
2058 | \r | |
2059 | /**\r | |
2060 | Writes a bit field to a MMIO register and saves the value in the S3 script to\r | |
2061 | be replayed on S3 resume.\r | |
2062 | \r | |
2063 | Writes Value to the bit field of the MMIO register. The bit field is\r | |
2064 | specified by the StartBit and the EndBit. All other bits in the destination\r | |
2065 | MMIO register are preserved. The new value of the 16-bit register is returned.\r | |
2066 | \r | |
2067 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
2068 | If StartBit is greater than 15, then ASSERT().\r | |
2069 | If EndBit is greater than 15, then ASSERT().\r | |
2070 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2071 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 2072 | \r |
2073 | @param Address The MMIO register to write.\r | |
2074 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2075 | Range 0..15.\r | |
2076 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2077 | Range 0..15.\r | |
2078 | @param Value New value of the bit field.\r | |
2079 | \r | |
2080 | @return The value written back to the MMIO register.\r | |
2081 | \r | |
2082 | **/\r | |
2083 | UINT16\r | |
2084 | EFIAPI\r | |
2085 | S3MmioBitFieldWrite16 (\r | |
2086 | IN UINTN Address,\r | |
2087 | IN UINTN StartBit,\r | |
2088 | IN UINTN EndBit,\r | |
2089 | IN UINT16 Value\r | |
2090 | )\r | |
2091 | {\r | |
2092 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioBitFieldWrite16 (Address, StartBit, EndBit, Value));\r | |
2093 | }\r | |
2094 | \r | |
2095 | /**\r | |
2096 | Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and\r | |
9095d37b | 2097 | writes the result back to the bit field in the 16-bit MMIO register and\r |
fe69ac84 | 2098 | saves the value in the S3 script to be replayed on S3 resume.\r |
2099 | \r | |
2100 | Reads the 16-bit MMIO register specified by Address, performs a bitwise\r | |
2101 | inclusive OR between the read result and the value specified by OrData, and\r | |
2102 | writes the result to the 16-bit MMIO register specified by Address. The value\r | |
2103 | written to the MMIO register is returned. This function must guarantee that\r | |
2104 | all MMIO read and write operations are serialized. Extra left bits in OrData\r | |
2105 | are stripped.\r | |
2106 | \r | |
2107 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
2108 | If StartBit is greater than 15, then ASSERT().\r | |
2109 | If EndBit is greater than 15, then ASSERT().\r | |
2110 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2111 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 2112 | \r |
2113 | @param Address The MMIO register to write.\r | |
2114 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2115 | Range 0..15.\r | |
2116 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2117 | Range 0..15.\r | |
2118 | @param OrData The value to OR with the read value from the MMIO register.\r | |
2119 | \r | |
2120 | @return The value written back to the MMIO register.\r | |
2121 | \r | |
2122 | **/\r | |
2123 | UINT16\r | |
2124 | EFIAPI\r | |
2125 | S3MmioBitFieldOr16 (\r | |
2126 | IN UINTN Address,\r | |
2127 | IN UINTN StartBit,\r | |
2128 | IN UINTN EndBit,\r | |
2129 | IN UINT16 OrData\r | |
2130 | )\r | |
2131 | {\r | |
2132 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioBitFieldOr16 (Address, StartBit, EndBit, OrData));\r | |
2133 | }\r | |
2134 | \r | |
2135 | /**\r | |
2136 | Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and\r | |
9095d37b | 2137 | writes the result back to the bit field in the 16-bit MMIO register and\r |
fe69ac84 | 2138 | saves the value in the S3 script to be replayed on S3 resume.\r |
2139 | \r | |
2140 | Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r | |
2141 | between the read result and the value specified by AndData, and writes the\r | |
2142 | result to the 16-bit MMIO register specified by Address. The value written to\r | |
2143 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
2144 | read and write operations are serialized. Extra left bits in AndData are\r | |
2145 | stripped.\r | |
2146 | \r | |
2147 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
2148 | If StartBit is greater than 15, then ASSERT().\r | |
2149 | If EndBit is greater than 15, then ASSERT().\r | |
2150 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2151 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 2152 | \r |
2153 | @param Address The MMIO register to write.\r | |
2154 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2155 | Range 0..15.\r | |
2156 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2157 | Range 0..15.\r | |
2158 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2159 | \r | |
2160 | @return The value written back to the MMIO register.\r | |
2161 | \r | |
2162 | **/\r | |
2163 | UINT16\r | |
2164 | EFIAPI\r | |
2165 | S3MmioBitFieldAnd16 (\r | |
2166 | IN UINTN Address,\r | |
2167 | IN UINTN StartBit,\r | |
2168 | IN UINTN EndBit,\r | |
2169 | IN UINT16 AndData\r | |
2170 | )\r | |
2171 | {\r | |
2172 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioBitFieldAnd16 (Address, StartBit, EndBit, AndData));\r | |
2173 | }\r | |
2174 | \r | |
2175 | /**\r | |
2176 | Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed\r | |
2177 | by a bitwise OR, and writes the result back to the bit field in the\r | |
2178 | 16-bit MMIO register and saves the value in the S3 script to be replayed\r | |
2179 | on S3 resume.\r | |
2180 | \r | |
2181 | Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r | |
2182 | followed by a bitwise OR between the read result and the value\r | |
2183 | specified by AndData, and writes the result to the 16-bit MMIO register\r | |
2184 | specified by Address. The value written to the MMIO register is returned.\r | |
2185 | This function must guarantee that all MMIO read and write operations are\r | |
2186 | serialized. Extra left bits in both AndData and OrData are stripped.\r | |
2187 | \r | |
2188 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
2189 | If StartBit is greater than 15, then ASSERT().\r | |
2190 | If EndBit is greater than 15, then ASSERT().\r | |
2191 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
2192 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
2193 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fe69ac84 | 2194 | \r |
2195 | @param Address The MMIO register to write.\r | |
2196 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2197 | Range 0..15.\r | |
2198 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2199 | Range 0..15.\r | |
2200 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2201 | @param OrData The value to OR with the result of the AND operation.\r | |
2202 | \r | |
2203 | @return The value written back to the MMIO register.\r | |
2204 | \r | |
2205 | **/\r | |
2206 | UINT16\r | |
2207 | EFIAPI\r | |
2208 | S3MmioBitFieldAndThenOr16 (\r | |
2209 | IN UINTN Address,\r | |
2210 | IN UINTN StartBit,\r | |
2211 | IN UINTN EndBit,\r | |
2212 | IN UINT16 AndData,\r | |
2213 | IN UINT16 OrData\r | |
2214 | )\r | |
2215 | {\r | |
2216 | return InternalSaveMmioWrite16ValueToBootScript (Address, MmioBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData));\r | |
2217 | }\r | |
2218 | \r | |
2219 | /**\r | |
2220 | Saves a 32-bit MMIO register value to the boot script.\r | |
2221 | \r | |
2222 | This internal worker function saves a 32-bit MMIO register value in the S3 script\r | |
9095d37b | 2223 | to be replayed on S3 resume.\r |
fe69ac84 | 2224 | \r |
2225 | If the saving process fails, then ASSERT().\r | |
2226 | \r | |
2227 | @param Address The MMIO register to write.\r | |
2228 | @param Value The value saved to boot script.\r | |
2229 | \r | |
2230 | @return Value.\r | |
2231 | \r | |
2232 | **/\r | |
2233 | UINT32\r | |
2234 | InternalSaveMmioWrite32ValueToBootScript (\r | |
2235 | IN UINTN Address,\r | |
2236 | IN UINT32 Value\r | |
2237 | )\r | |
2238 | {\r | |
2239 | InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint32, Address, &Value);\r | |
2240 | \r | |
2241 | return Value;\r | |
2242 | }\r | |
2243 | \r | |
2244 | /**\r | |
9095d37b | 2245 | Reads a 32-bit MMIO register saves the value in the S3 script to be\r |
fe69ac84 | 2246 | replayed on S3 resume.\r |
2247 | \r | |
2248 | Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r | |
2249 | returned. This function must guarantee that all MMIO read and write\r | |
2250 | operations are serialized.\r | |
2251 | \r | |
2252 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2253 | \r | |
2254 | @param Address The MMIO register to read.\r | |
2255 | \r | |
2256 | @return The value read.\r | |
2257 | \r | |
2258 | **/\r | |
2259 | UINT32\r | |
2260 | EFIAPI\r | |
2261 | S3MmioRead32 (\r | |
2262 | IN UINTN Address\r | |
2263 | )\r | |
2264 | {\r | |
2265 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioRead32 (Address));\r | |
2266 | }\r | |
2267 | \r | |
2268 | /**\r | |
9095d37b | 2269 | Writes a 32-bit MMIO register and saves the value in the S3 script to be\r |
fe69ac84 | 2270 | replayed on S3 resume.\r |
2271 | \r | |
2272 | Writes the 32-bit MMIO register specified by Address with the value specified\r | |
2273 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
2274 | and write operations are serialized.\r | |
2275 | \r | |
2276 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2277 | \r | |
2278 | @param Address The MMIO register to write.\r | |
2279 | @param Value The value to write to the MMIO register.\r | |
2280 | \r | |
2281 | @return The value written the MMIO register.\r | |
2282 | \r | |
2283 | **/\r | |
2284 | UINT32\r | |
2285 | EFIAPI\r | |
2286 | S3MmioWrite32 (\r | |
2287 | IN UINTN Address,\r | |
2288 | IN UINT32 Value\r | |
2289 | )\r | |
2290 | {\r | |
2291 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioWrite32 (Address, Value));\r | |
2292 | }\r | |
2293 | \r | |
2294 | /**\r | |
2295 | Reads a 32-bit MMIO register, performs a bitwise OR, and writes the\r | |
9095d37b | 2296 | result back to the 32-bit MMIO register and saves the value in the S3 script\r |
fe69ac84 | 2297 | to be replayed on S3 resume.\r |
2298 | \r | |
2299 | Reads the 32-bit MMIO register specified by Address, performs a bitwise\r | |
2300 | inclusive OR between the read result and the value specified by OrData, and\r | |
2301 | writes the result to the 32-bit MMIO register specified by Address. The value\r | |
2302 | written to the MMIO register is returned. This function must guarantee that\r | |
2303 | all MMIO read and write operations are serialized.\r | |
2304 | \r | |
2305 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2306 | \r | |
2307 | @param Address The MMIO register to write.\r | |
2308 | @param OrData The value to OR with the read value from the MMIO register.\r | |
2309 | \r | |
2310 | @return The value written back to the MMIO register.\r | |
2311 | \r | |
2312 | **/\r | |
2313 | UINT32\r | |
2314 | EFIAPI\r | |
2315 | S3MmioOr32 (\r | |
2316 | IN UINTN Address,\r | |
2317 | IN UINT32 OrData\r | |
2318 | )\r | |
2319 | {\r | |
2320 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioOr32 (Address, OrData));\r | |
2321 | }\r | |
2322 | \r | |
2323 | /**\r | |
2324 | Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result\r | |
9095d37b | 2325 | back to the 32-bit MMIO register and saves the value in the S3 script to be\r |
fe69ac84 | 2326 | replayed on S3 resume.\r |
2327 | \r | |
2328 | Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r | |
2329 | between the read result and the value specified by AndData, and writes the\r | |
2330 | result to the 32-bit MMIO register specified by Address. The value written to\r | |
2331 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
2332 | read and write operations are serialized.\r | |
2333 | \r | |
2334 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2335 | \r | |
2336 | @param Address The MMIO register to write.\r | |
2337 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2338 | \r | |
2339 | @return The value written back to the MMIO register.\r | |
2340 | \r | |
2341 | **/\r | |
2342 | UINT32\r | |
2343 | EFIAPI\r | |
2344 | S3MmioAnd32 (\r | |
2345 | IN UINTN Address,\r | |
2346 | IN UINT32 AndData\r | |
2347 | )\r | |
2348 | {\r | |
2349 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioAnd32 (Address, AndData));\r | |
2350 | }\r | |
2351 | \r | |
2352 | /**\r | |
2353 | Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise\r | |
9095d37b | 2354 | inclusive OR, and writes the result back to the 32-bit MMIO register and\r |
fe69ac84 | 2355 | saves the value in the S3 script to be replayed on S3 resume.\r |
2356 | \r | |
2357 | Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r | |
2358 | between the read result and the value specified by AndData, performs a\r | |
2359 | bitwise OR between the result of the AND operation and the value specified by\r | |
2360 | OrData, and writes the result to the 32-bit MMIO register specified by\r | |
2361 | Address. The value written to the MMIO register is returned. This function\r | |
2362 | must guarantee that all MMIO read and write operations are serialized.\r | |
2363 | \r | |
2364 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2365 | \r | |
2366 | @param Address The MMIO register to write.\r | |
2367 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2368 | @param OrData The value to OR with the result of the AND operation.\r | |
2369 | \r | |
2370 | @return The value written back to the MMIO register.\r | |
2371 | \r | |
2372 | **/\r | |
2373 | UINT32\r | |
2374 | EFIAPI\r | |
2375 | S3MmioAndThenOr32 (\r | |
2376 | IN UINTN Address,\r | |
2377 | IN UINT32 AndData,\r | |
2378 | IN UINT32 OrData\r | |
2379 | )\r | |
2380 | {\r | |
2381 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioAndThenOr32 (Address, AndData, OrData));\r | |
2382 | }\r | |
2383 | \r | |
2384 | /**\r | |
9095d37b | 2385 | Reads a bit field of a MMIO register and saves the value in the S3 script\r |
fe69ac84 | 2386 | to be replayed on S3 resume.\r |
2387 | \r | |
2388 | Reads the bit field in a 32-bit MMIO register. The bit field is specified by\r | |
2389 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
2390 | \r | |
2391 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2392 | If StartBit is greater than 31, then ASSERT().\r | |
2393 | If EndBit is greater than 31, then ASSERT().\r | |
2394 | If EndBit is less than StartBit, then ASSERT().\r | |
2395 | \r | |
2396 | @param Address MMIO register to read.\r | |
2397 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2398 | Range 0..31.\r | |
2399 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2400 | Range 0..31.\r | |
2401 | \r | |
2402 | @return The value read.\r | |
2403 | \r | |
2404 | **/\r | |
2405 | UINT32\r | |
2406 | EFIAPI\r | |
2407 | S3MmioBitFieldRead32 (\r | |
2408 | IN UINTN Address,\r | |
2409 | IN UINTN StartBit,\r | |
2410 | IN UINTN EndBit\r | |
2411 | )\r | |
2412 | {\r | |
2413 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioBitFieldRead32 (Address, StartBit, EndBit));\r | |
2414 | }\r | |
2415 | \r | |
2416 | /**\r | |
9095d37b | 2417 | Writes a bit field to a MMIO register and saves the value in the S3 script\r |
fe69ac84 | 2418 | to be replayed on S3 resume.\r |
2419 | \r | |
2420 | Writes Value to the bit field of the MMIO register. The bit field is\r | |
2421 | specified by the StartBit and the EndBit. All other bits in the destination\r | |
2422 | MMIO register are preserved. The new value of the 32-bit register is returned.\r | |
2423 | \r | |
2424 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2425 | If StartBit is greater than 31, then ASSERT().\r | |
2426 | If EndBit is greater than 31, then ASSERT().\r | |
2427 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2428 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 2429 | \r |
2430 | @param Address The MMIO register to write.\r | |
2431 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2432 | Range 0..31.\r | |
2433 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2434 | Range 0..31.\r | |
2435 | @param Value New value of the bit field.\r | |
2436 | \r | |
2437 | @return The value written back to the MMIO register.\r | |
2438 | \r | |
2439 | **/\r | |
2440 | UINT32\r | |
2441 | EFIAPI\r | |
2442 | S3MmioBitFieldWrite32 (\r | |
2443 | IN UINTN Address,\r | |
2444 | IN UINTN StartBit,\r | |
2445 | IN UINTN EndBit,\r | |
2446 | IN UINT32 Value\r | |
2447 | )\r | |
2448 | {\r | |
2449 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioBitFieldWrite32 (Address, StartBit, EndBit, Value));\r | |
2450 | }\r | |
2451 | \r | |
2452 | /**\r | |
2453 | Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and\r | |
9095d37b | 2454 | writes the result back to the bit field in the 32-bit MMIO register and\r |
fe69ac84 | 2455 | saves the value in the S3 script to be replayed on S3 resume.\r |
2456 | \r | |
2457 | Reads the 32-bit MMIO register specified by Address, performs a bitwise\r | |
2458 | inclusive OR between the read result and the value specified by OrData, and\r | |
2459 | writes the result to the 32-bit MMIO register specified by Address. The value\r | |
2460 | written to the MMIO register is returned. This function must guarantee that\r | |
2461 | all MMIO read and write operations are serialized. Extra left bits in OrData\r | |
2462 | are stripped.\r | |
2463 | \r | |
2464 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2465 | If StartBit is greater than 31, then ASSERT().\r | |
2466 | If EndBit is greater than 31, then ASSERT().\r | |
2467 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2468 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 2469 | \r |
2470 | @param Address The MMIO register to write.\r | |
2471 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2472 | Range 0..31.\r | |
2473 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2474 | Range 0..31.\r | |
2475 | @param OrData The value to OR with the read value from the MMIO register.\r | |
2476 | \r | |
2477 | @return The value written back to the MMIO register.\r | |
2478 | \r | |
2479 | **/\r | |
2480 | UINT32\r | |
2481 | EFIAPI\r | |
2482 | S3MmioBitFieldOr32 (\r | |
2483 | IN UINTN Address,\r | |
2484 | IN UINTN StartBit,\r | |
2485 | IN UINTN EndBit,\r | |
2486 | IN UINT32 OrData\r | |
2487 | )\r | |
2488 | {\r | |
2489 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioBitFieldOr32 (Address, StartBit, EndBit, OrData));\r | |
2490 | }\r | |
2491 | \r | |
2492 | /**\r | |
2493 | Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and\r | |
9095d37b | 2494 | writes the result back to the bit field in the 32-bit MMIO register and\r |
fe69ac84 | 2495 | saves the value in the S3 script to be replayed on S3 resume.\r |
2496 | \r | |
2497 | Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r | |
2498 | between the read result and the value specified by AndData, and writes the\r | |
2499 | result to the 32-bit MMIO register specified by Address. The value written to\r | |
2500 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
2501 | read and write operations are serialized. Extra left bits in AndData are\r | |
2502 | stripped.\r | |
2503 | \r | |
2504 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2505 | If StartBit is greater than 31, then ASSERT().\r | |
2506 | If EndBit is greater than 31, then ASSERT().\r | |
2507 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2508 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 2509 | \r |
2510 | @param Address The MMIO register to write.\r | |
2511 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2512 | Range 0..31.\r | |
2513 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2514 | Range 0..31.\r | |
2515 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2516 | \r | |
2517 | @return The value written back to the MMIO register.\r | |
2518 | \r | |
2519 | **/\r | |
2520 | UINT32\r | |
2521 | EFIAPI\r | |
2522 | S3MmioBitFieldAnd32 (\r | |
2523 | IN UINTN Address,\r | |
2524 | IN UINTN StartBit,\r | |
2525 | IN UINTN EndBit,\r | |
2526 | IN UINT32 AndData\r | |
2527 | )\r | |
2528 | {\r | |
2529 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioBitFieldAnd32 (Address, StartBit, EndBit, AndData));\r | |
2530 | }\r | |
2531 | \r | |
2532 | /**\r | |
2533 | Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed\r | |
2534 | by a bitwise OR, and writes the result back to the bit field in the\r | |
2535 | 32-bit MMIO register and saves the value in the S3 script to be replayed\r | |
2536 | on S3 resume.\r | |
2537 | \r | |
2538 | Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r | |
2539 | followed by a bitwise OR between the read result and the value\r | |
2540 | specified by AndData, and writes the result to the 32-bit MMIO register\r | |
2541 | specified by Address. The value written to the MMIO register is returned.\r | |
2542 | This function must guarantee that all MMIO read and write operations are\r | |
2543 | serialized. Extra left bits in both AndData and OrData are stripped.\r | |
2544 | \r | |
2545 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
2546 | If StartBit is greater than 31, then ASSERT().\r | |
2547 | If EndBit is greater than 31, then ASSERT().\r | |
2548 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
2549 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
2550 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fe69ac84 | 2551 | \r |
2552 | @param Address The MMIO register to write.\r | |
2553 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2554 | Range 0..31.\r | |
2555 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2556 | Range 0..31.\r | |
2557 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2558 | @param OrData The value to OR with the result of the AND operation.\r | |
2559 | \r | |
2560 | @return The value written back to the MMIO register.\r | |
2561 | \r | |
2562 | **/\r | |
2563 | UINT32\r | |
2564 | EFIAPI\r | |
2565 | S3MmioBitFieldAndThenOr32 (\r | |
2566 | IN UINTN Address,\r | |
2567 | IN UINTN StartBit,\r | |
2568 | IN UINTN EndBit,\r | |
2569 | IN UINT32 AndData,\r | |
2570 | IN UINT32 OrData\r | |
2571 | )\r | |
2572 | {\r | |
2573 | return InternalSaveMmioWrite32ValueToBootScript (Address, MmioBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData));\r | |
2574 | }\r | |
2575 | \r | |
2576 | /**\r | |
2577 | Saves a 64-bit MMIO register value to the boot script.\r | |
2578 | \r | |
2579 | This internal worker function saves a 64-bit MMIO register value in the S3 script\r | |
9095d37b | 2580 | to be replayed on S3 resume.\r |
fe69ac84 | 2581 | \r |
2582 | If the saving process fails, then ASSERT().\r | |
2583 | \r | |
2584 | @param Address The MMIO register to write.\r | |
2585 | @param Value The value saved to boot script.\r | |
2586 | \r | |
2587 | @return Value.\r | |
2588 | \r | |
2589 | **/\r | |
2590 | UINT64\r | |
2591 | InternalSaveMmioWrite64ValueToBootScript (\r | |
2592 | IN UINTN Address,\r | |
2593 | IN UINT64 Value\r | |
2594 | )\r | |
2595 | {\r | |
2596 | InternalSaveMmioWriteValueToBootScript (S3BootScriptWidthUint64, Address, &Value);\r | |
2597 | \r | |
2598 | return Value;\r | |
2599 | }\r | |
2600 | \r | |
2601 | /**\r | |
9095d37b | 2602 | Reads a 64-bit MMIO register and saves the value in the S3 script to be\r |
fe69ac84 | 2603 | replayed on S3 resume.\r |
2604 | \r | |
2605 | Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r | |
2606 | returned. This function must guarantee that all MMIO read and write\r | |
2607 | operations are serialized.\r | |
2608 | \r | |
2609 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2610 | \r | |
2611 | @param Address The MMIO register to read.\r | |
2612 | \r | |
2613 | @return The value read.\r | |
2614 | \r | |
2615 | **/\r | |
2616 | UINT64\r | |
2617 | EFIAPI\r | |
2618 | S3MmioRead64 (\r | |
2619 | IN UINTN Address\r | |
2620 | )\r | |
2621 | {\r | |
2622 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioRead64 (Address));\r | |
2623 | }\r | |
2624 | \r | |
2625 | /**\r | |
9095d37b | 2626 | Writes a 64-bit MMIO register and saves the value in the S3 script to be\r |
fe69ac84 | 2627 | replayed on S3 resume.\r |
2628 | \r | |
2629 | Writes the 64-bit MMIO register specified by Address with the value specified\r | |
2630 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
2631 | and write operations are serialized.\r | |
2632 | \r | |
2633 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2634 | \r | |
2635 | @param Address The MMIO register to write.\r | |
2636 | @param Value The value to write to the MMIO register.\r | |
2637 | \r | |
2638 | @return The value written the MMIO register.\r | |
2639 | \r | |
2640 | **/\r | |
2641 | UINT64\r | |
2642 | EFIAPI\r | |
2643 | S3MmioWrite64 (\r | |
2644 | IN UINTN Address,\r | |
2645 | IN UINT64 Value\r | |
2646 | )\r | |
2647 | {\r | |
2648 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioWrite64 (Address, Value));\r | |
2649 | }\r | |
2650 | \r | |
2651 | /**\r | |
2652 | Reads a 64-bit MMIO register, performs a bitwise OR, and writes the\r | |
9095d37b | 2653 | result back to the 64-bit MMIO register and saves the value in the S3 script\r |
fe69ac84 | 2654 | to be replayed on S3 resume.\r |
2655 | \r | |
2656 | Reads the 64-bit MMIO register specified by Address, performs a bitwise\r | |
2657 | inclusive OR between the read result and the value specified by OrData, and\r | |
2658 | writes the result to the 64-bit MMIO register specified by Address. The value\r | |
2659 | written to the MMIO register is returned. This function must guarantee that\r | |
2660 | all MMIO read and write operations are serialized.\r | |
2661 | \r | |
2662 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2663 | \r | |
2664 | @param Address The MMIO register to write.\r | |
2665 | @param OrData The value to OR with the read value from the MMIO register.\r | |
2666 | \r | |
2667 | @return The value written back to the MMIO register.\r | |
2668 | \r | |
2669 | **/\r | |
2670 | UINT64\r | |
2671 | EFIAPI\r | |
2672 | S3MmioOr64 (\r | |
2673 | IN UINTN Address,\r | |
2674 | IN UINT64 OrData\r | |
2675 | )\r | |
2676 | {\r | |
2677 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioOr64 (Address, OrData));\r | |
2678 | }\r | |
2679 | \r | |
2680 | /**\r | |
2681 | Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result\r | |
9095d37b | 2682 | back to the 64-bit MMIO register and saves the value in the S3 script to be\r |
fe69ac84 | 2683 | replayed on S3 resume.\r |
2684 | \r | |
2685 | Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r | |
2686 | between the read result and the value specified by AndData, and writes the\r | |
2687 | result to the 64-bit MMIO register specified by Address. The value written to\r | |
2688 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
2689 | read and write operations are serialized.\r | |
2690 | \r | |
2691 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2692 | \r | |
2693 | @param Address The MMIO register to write.\r | |
2694 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2695 | \r | |
2696 | @return The value written back to the MMIO register.\r | |
2697 | \r | |
2698 | **/\r | |
2699 | UINT64\r | |
2700 | EFIAPI\r | |
2701 | S3MmioAnd64 (\r | |
2702 | IN UINTN Address,\r | |
2703 | IN UINT64 AndData\r | |
2704 | )\r | |
2705 | {\r | |
2706 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioAnd64 (Address, AndData));\r | |
2707 | }\r | |
2708 | \r | |
2709 | /**\r | |
2710 | Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise\r | |
9095d37b | 2711 | inclusive OR, and writes the result back to the 64-bit MMIO register and\r |
fe69ac84 | 2712 | saves the value in the S3 script to be replayed on S3 resume.\r |
2713 | \r | |
2714 | Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r | |
2715 | between the read result and the value specified by AndData, performs a\r | |
2716 | bitwise OR between the result of the AND operation and the value specified by\r | |
2717 | OrData, and writes the result to the 64-bit MMIO register specified by\r | |
2718 | Address. The value written to the MMIO register is returned. This function\r | |
2719 | must guarantee that all MMIO read and write operations are serialized.\r | |
2720 | \r | |
2721 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2722 | \r | |
2723 | @param Address The MMIO register to write.\r | |
2724 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2725 | @param OrData The value to OR with the result of the AND operation.\r | |
2726 | \r | |
2727 | @return The value written back to the MMIO register.\r | |
2728 | \r | |
2729 | **/\r | |
2730 | UINT64\r | |
2731 | EFIAPI\r | |
2732 | S3MmioAndThenOr64 (\r | |
2733 | IN UINTN Address,\r | |
2734 | IN UINT64 AndData,\r | |
2735 | IN UINT64 OrData\r | |
2736 | )\r | |
2737 | {\r | |
2738 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioAndThenOr64 (Address, AndData, OrData));\r | |
2739 | }\r | |
2740 | \r | |
2741 | /**\r | |
2742 | Reads a bit field of a MMIO register saves the value in the S3 script to\r | |
2743 | be replayed on S3 resume.\r | |
2744 | \r | |
2745 | Reads the bit field in a 64-bit MMIO register. The bit field is specified by\r | |
2746 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
2747 | \r | |
2748 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2749 | If StartBit is greater than 63, then ASSERT().\r | |
2750 | If EndBit is greater than 63, then ASSERT().\r | |
2751 | If EndBit is less than StartBit, then ASSERT().\r | |
2752 | \r | |
2753 | @param Address MMIO register to read.\r | |
2754 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2755 | Range 0..63.\r | |
2756 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2757 | Range 0..63.\r | |
2758 | \r | |
2759 | @return The value read.\r | |
2760 | \r | |
2761 | **/\r | |
2762 | UINT64\r | |
2763 | EFIAPI\r | |
2764 | S3MmioBitFieldRead64 (\r | |
2765 | IN UINTN Address,\r | |
2766 | IN UINTN StartBit,\r | |
2767 | IN UINTN EndBit\r | |
2768 | )\r | |
2769 | {\r | |
2770 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioBitFieldRead64 (Address, StartBit, EndBit));\r | |
2771 | }\r | |
2772 | \r | |
2773 | /**\r | |
2774 | Writes a bit field to a MMIO register and saves the value in the S3 script to\r | |
2775 | be replayed on S3 resume.\r | |
2776 | \r | |
2777 | Writes Value to the bit field of the MMIO register. The bit field is\r | |
2778 | specified by the StartBit and the EndBit. All other bits in the destination\r | |
2779 | MMIO register are preserved. The new value of the 64-bit register is returned.\r | |
2780 | \r | |
2781 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2782 | If StartBit is greater than 63, then ASSERT().\r | |
2783 | If EndBit is greater than 63, then ASSERT().\r | |
2784 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2785 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 2786 | \r |
2787 | @param Address The MMIO register to write.\r | |
2788 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2789 | Range 0..63.\r | |
2790 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2791 | Range 0..63.\r | |
2792 | @param Value New value of the bit field.\r | |
2793 | \r | |
2794 | @return The value written back to the MMIO register.\r | |
2795 | \r | |
2796 | **/\r | |
2797 | UINT64\r | |
2798 | EFIAPI\r | |
2799 | S3MmioBitFieldWrite64 (\r | |
2800 | IN UINTN Address,\r | |
2801 | IN UINTN StartBit,\r | |
2802 | IN UINTN EndBit,\r | |
2803 | IN UINT64 Value\r | |
2804 | )\r | |
2805 | {\r | |
2806 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioBitFieldWrite64 (Address, StartBit, EndBit, Value));\r | |
2807 | }\r | |
2808 | \r | |
2809 | /**\r | |
2810 | Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and\r | |
9095d37b | 2811 | writes the result back to the bit field in the 64-bit MMIO register and\r |
fe69ac84 | 2812 | saves the value in the S3 script to be replayed on S3 resume.\r |
2813 | \r | |
2814 | Reads the 64-bit MMIO register specified by Address, performs a bitwise\r | |
2815 | inclusive OR between the read result and the value specified by OrData, and\r | |
2816 | writes the result to the 64-bit MMIO register specified by Address. The value\r | |
2817 | written to the MMIO register is returned. This function must guarantee that\r | |
2818 | all MMIO read and write operations are serialized. Extra left bits in OrData\r | |
2819 | are stripped.\r | |
2820 | \r | |
2821 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2822 | If StartBit is greater than 63, then ASSERT().\r | |
2823 | If EndBit is greater than 63, then ASSERT().\r | |
2824 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2825 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 2826 | \r |
2827 | @param Address The MMIO register to write.\r | |
2828 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2829 | Range 0..63.\r | |
2830 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2831 | Range 0..63.\r | |
2832 | @param OrData The value to OR with the read value from the MMIO register.\r | |
2833 | \r | |
2834 | @return The value written back to the MMIO register.\r | |
2835 | \r | |
2836 | **/\r | |
2837 | UINT64\r | |
2838 | EFIAPI\r | |
2839 | S3MmioBitFieldOr64 (\r | |
2840 | IN UINTN Address,\r | |
2841 | IN UINTN StartBit,\r | |
2842 | IN UINTN EndBit,\r | |
2843 | IN UINT64 OrData\r | |
2844 | )\r | |
2845 | {\r | |
2846 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioBitFieldOr64 (Address, StartBit, EndBit, OrData));\r | |
2847 | }\r | |
2848 | \r | |
2849 | /**\r | |
2850 | Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and\r | |
2851 | writes the result back to the bit field in the 64-bit MMIO register and saves\r | |
2852 | the value in the S3 script to be replayed on S3 resume.\r | |
2853 | \r | |
2854 | Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r | |
2855 | between the read result and the value specified by AndData, and writes the\r | |
2856 | result to the 64-bit MMIO register specified by Address. The value written to\r | |
2857 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
2858 | read and write operations are serialized. Extra left bits in AndData are\r | |
2859 | stripped.\r | |
2860 | \r | |
2861 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2862 | If StartBit is greater than 63, then ASSERT().\r | |
2863 | If EndBit is greater than 63, then ASSERT().\r | |
2864 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2865 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fe69ac84 | 2866 | \r |
2867 | @param Address The MMIO register to write.\r | |
2868 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2869 | Range 0..63.\r | |
2870 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2871 | Range 0..63.\r | |
2872 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2873 | \r | |
2874 | @return The value written back to the MMIO register.\r | |
2875 | \r | |
2876 | **/\r | |
2877 | UINT64\r | |
2878 | EFIAPI\r | |
2879 | S3MmioBitFieldAnd64 (\r | |
2880 | IN UINTN Address,\r | |
2881 | IN UINTN StartBit,\r | |
2882 | IN UINTN EndBit,\r | |
2883 | IN UINT64 AndData\r | |
2884 | )\r | |
2885 | {\r | |
2886 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioBitFieldAnd64 (Address, StartBit, EndBit, AndData));\r | |
2887 | }\r | |
2888 | \r | |
2889 | /**\r | |
2890 | Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed\r | |
2891 | by a bitwise OR, and writes the result back to the bit field in the\r | |
2892 | 64-bit MMIO register and saves the value in the S3 script to be replayed\r | |
2893 | on S3 resume.\r | |
2894 | \r | |
2895 | Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r | |
2896 | followed by a bitwise OR between the read result and the value\r | |
2897 | specified by AndData, and writes the result to the 64-bit MMIO register\r | |
2898 | specified by Address. The value written to the MMIO register is returned.\r | |
2899 | This function must guarantee that all MMIO read and write operations are\r | |
2900 | serialized. Extra left bits in both AndData and OrData are stripped.\r | |
2901 | \r | |
2902 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2903 | If StartBit is greater than 63, then ASSERT().\r | |
2904 | If EndBit is greater than 63, then ASSERT().\r | |
2905 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
2906 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
2907 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fe69ac84 | 2908 | \r |
2909 | @param Address The MMIO register to write.\r | |
2910 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2911 | Range 0..63.\r | |
2912 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2913 | Range 0..63.\r | |
2914 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2915 | @param OrData The value to OR with the result of the AND operation.\r | |
2916 | \r | |
2917 | @return The value written back to the MMIO register.\r | |
2918 | \r | |
2919 | **/\r | |
2920 | UINT64\r | |
2921 | EFIAPI\r | |
2922 | S3MmioBitFieldAndThenOr64 (\r | |
2923 | IN UINTN Address,\r | |
2924 | IN UINTN StartBit,\r | |
2925 | IN UINTN EndBit,\r | |
2926 | IN UINT64 AndData,\r | |
2927 | IN UINT64 OrData\r | |
2928 | )\r | |
2929 | {\r | |
2930 | return InternalSaveMmioWrite64ValueToBootScript (Address, MmioBitFieldAndThenOr64 (Address, StartBit, EndBit, AndData, OrData));\r | |
2931 | }\r | |
2932 | \r | |
2933 | /**\r | |
2934 | Copy data from MMIO region to system memory by using 8-bit access\r | |
2935 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
2936 | \r | |
9095d37b LG |
2937 | Copy data from MMIO region specified by starting address StartAddress\r |
2938 | to system memory specified by Buffer by using 8-bit access. The total\r | |
fe69ac84 | 2939 | number of byte to be copied is specified by Length. Buffer is returned.\r |
9095d37b LG |
2940 | \r |
2941 | If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r | |
fe69ac84 | 2942 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r |
2943 | \r | |
2944 | \r | |
2945 | @param StartAddress Starting address for the MMIO region to be copied from.\r | |
2946 | @param Length Size in bytes of the copy.\r | |
2947 | @param Buffer Pointer to a system memory buffer receiving the data read.\r | |
2948 | \r | |
2949 | @return Buffer\r | |
2950 | \r | |
2951 | **/\r | |
2952 | UINT8 *\r | |
2953 | EFIAPI\r | |
2954 | S3MmioReadBuffer8 (\r | |
2955 | IN UINTN StartAddress,\r | |
2956 | IN UINTN Length,\r | |
2957 | OUT UINT8 *Buffer\r | |
2958 | )\r | |
2959 | {\r | |
2960 | UINT8 *ReturnBuffer;\r | |
2961 | RETURN_STATUS Status;\r | |
2962 | \r | |
2963 | ReturnBuffer = MmioReadBuffer8 (StartAddress, Length, Buffer);\r | |
2964 | \r | |
2965 | Status = S3BootScriptSaveMemWrite (\r | |
2966 | S3BootScriptWidthUint8,\r | |
2967 | StartAddress,\r | |
2968 | Length / sizeof (UINT8),\r | |
2969 | ReturnBuffer\r | |
2970 | );\r | |
2971 | ASSERT (Status == RETURN_SUCCESS);\r | |
2972 | \r | |
2973 | return ReturnBuffer;\r | |
2974 | }\r | |
2975 | \r | |
2976 | /**\r | |
2977 | Copy data from MMIO region to system memory by using 16-bit access\r | |
2978 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
2979 | \r | |
9095d37b LG |
2980 | Copy data from MMIO region specified by starting address StartAddress\r |
2981 | to system memory specified by Buffer by using 16-bit access. The total\r | |
fe69ac84 | 2982 | number of byte to be copied is specified by Length. Buffer is returned.\r |
9095d37b | 2983 | \r |
fe69ac84 | 2984 | If StartAddress is not aligned on a 16-bit boundary, then ASSERT().\r |
2985 | \r | |
9095d37b | 2986 | If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r |
fe69ac84 | 2987 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r |
2988 | \r | |
2989 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
2990 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
2991 | \r | |
2992 | @param StartAddress Starting address for the MMIO region to be copied from.\r | |
2993 | @param Length Size in bytes of the copy.\r | |
2994 | @param Buffer Pointer to a system memory buffer receiving the data read.\r | |
2995 | \r | |
2996 | @return Buffer\r | |
2997 | \r | |
2998 | **/\r | |
2999 | UINT16 *\r | |
3000 | EFIAPI\r | |
3001 | S3MmioReadBuffer16 (\r | |
3002 | IN UINTN StartAddress,\r | |
3003 | IN UINTN Length,\r | |
3004 | OUT UINT16 *Buffer\r | |
3005 | )\r | |
3006 | {\r | |
3007 | UINT16 *ReturnBuffer;\r | |
3008 | RETURN_STATUS Status;\r | |
3009 | \r | |
3010 | ReturnBuffer = MmioReadBuffer16 (StartAddress, Length, Buffer);\r | |
3011 | \r | |
3012 | Status = S3BootScriptSaveMemWrite (\r | |
3013 | S3BootScriptWidthUint16,\r | |
3014 | StartAddress,\r | |
3015 | Length / sizeof (UINT16),\r | |
3016 | ReturnBuffer\r | |
3017 | );\r | |
3018 | ASSERT (Status == RETURN_SUCCESS);\r | |
3019 | \r | |
3020 | return ReturnBuffer;\r | |
3021 | }\r | |
3022 | \r | |
3023 | /**\r | |
3024 | Copy data from MMIO region to system memory by using 32-bit access\r | |
3025 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
3026 | \r | |
9095d37b LG |
3027 | Copy data from MMIO region specified by starting address StartAddress\r |
3028 | to system memory specified by Buffer by using 32-bit access. The total\r | |
fe69ac84 | 3029 | number of byte to be copied is specified by Length. Buffer is returned.\r |
9095d37b | 3030 | \r |
fe69ac84 | 3031 | If StartAddress is not aligned on a 32-bit boundary, then ASSERT().\r |
3032 | \r | |
9095d37b | 3033 | If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r |
fe69ac84 | 3034 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r |
3035 | \r | |
3036 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
3037 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
3038 | \r | |
3039 | @param StartAddress Starting address for the MMIO region to be copied from.\r | |
3040 | @param Length Size in bytes of the copy.\r | |
3041 | @param Buffer Pointer to a system memory buffer receiving the data read.\r | |
3042 | \r | |
3043 | @return Buffer\r | |
3044 | \r | |
3045 | **/\r | |
3046 | UINT32 *\r | |
3047 | EFIAPI\r | |
3048 | S3MmioReadBuffer32 (\r | |
3049 | IN UINTN StartAddress,\r | |
3050 | IN UINTN Length,\r | |
3051 | OUT UINT32 *Buffer\r | |
3052 | )\r | |
3053 | {\r | |
3054 | UINT32 *ReturnBuffer;\r | |
3055 | RETURN_STATUS Status;\r | |
3056 | \r | |
3057 | ReturnBuffer = MmioReadBuffer32 (StartAddress, Length, Buffer);\r | |
3058 | \r | |
3059 | Status = S3BootScriptSaveMemWrite (\r | |
3060 | S3BootScriptWidthUint32,\r | |
3061 | StartAddress,\r | |
3062 | Length / sizeof (UINT32),\r | |
3063 | ReturnBuffer\r | |
3064 | );\r | |
3065 | ASSERT (Status == RETURN_SUCCESS);\r | |
3066 | \r | |
3067 | return ReturnBuffer;\r | |
3068 | }\r | |
3069 | \r | |
3070 | /**\r | |
3071 | Copy data from MMIO region to system memory by using 64-bit access\r | |
3072 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
3073 | \r | |
9095d37b LG |
3074 | Copy data from MMIO region specified by starting address StartAddress\r |
3075 | to system memory specified by Buffer by using 64-bit access. The total\r | |
fe69ac84 | 3076 | number of byte to be copied is specified by Length. Buffer is returned.\r |
9095d37b | 3077 | \r |
fe69ac84 | 3078 | If StartAddress is not aligned on a 64-bit boundary, then ASSERT().\r |
3079 | \r | |
9095d37b | 3080 | If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r |
fe69ac84 | 3081 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r |
3082 | \r | |
3083 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
3084 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
3085 | \r | |
3086 | @param StartAddress Starting address for the MMIO region to be copied from.\r | |
3087 | @param Length Size in bytes of the copy.\r | |
3088 | @param Buffer Pointer to a system memory buffer receiving the data read.\r | |
3089 | \r | |
3090 | @return Buffer\r | |
3091 | \r | |
3092 | **/\r | |
3093 | UINT64 *\r | |
3094 | EFIAPI\r | |
3095 | S3MmioReadBuffer64 (\r | |
3096 | IN UINTN StartAddress,\r | |
3097 | IN UINTN Length,\r | |
3098 | OUT UINT64 *Buffer\r | |
3099 | )\r | |
3100 | {\r | |
3101 | UINT64 *ReturnBuffer;\r | |
3102 | RETURN_STATUS Status;\r | |
3103 | \r | |
3104 | ReturnBuffer = MmioReadBuffer64 (StartAddress, Length, Buffer);\r | |
3105 | \r | |
3106 | Status = S3BootScriptSaveMemWrite (\r | |
3107 | S3BootScriptWidthUint64,\r | |
3108 | StartAddress,\r | |
3109 | Length / sizeof (UINT64),\r | |
3110 | ReturnBuffer\r | |
3111 | );\r | |
3112 | ASSERT (Status == RETURN_SUCCESS);\r | |
3113 | \r | |
3114 | return ReturnBuffer;\r | |
3115 | }\r | |
3116 | \r | |
3117 | \r | |
3118 | /**\r | |
3119 | Copy data from system memory to MMIO region by using 8-bit access\r | |
3120 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
3121 | \r | |
9095d37b LG |
3122 | Copy data from system memory specified by Buffer to MMIO region specified\r |
3123 | by starting address StartAddress by using 8-bit access. The total number\r | |
fe69ac84 | 3124 | of byte to be copied is specified by Length. Buffer is returned.\r |
9095d37b LG |
3125 | \r |
3126 | If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r | |
fe69ac84 | 3127 | If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r |
3128 | \r | |
3129 | \r | |
3130 | @param StartAddress Starting address for the MMIO region to be copied to.\r | |
3131 | @param Length Size in bytes of the copy.\r | |
3132 | @param Buffer Pointer to a system memory buffer containing the data to write.\r | |
3133 | \r | |
3134 | @return Buffer\r | |
3135 | \r | |
3136 | **/\r | |
3137 | UINT8 *\r | |
3138 | EFIAPI\r | |
3139 | S3MmioWriteBuffer8 (\r | |
3140 | IN UINTN StartAddress,\r | |
3141 | IN UINTN Length,\r | |
3142 | IN CONST UINT8 *Buffer\r | |
3143 | )\r | |
3144 | {\r | |
3145 | UINT8 *ReturnBuffer;\r | |
3146 | RETURN_STATUS Status;\r | |
3147 | \r | |
3148 | ReturnBuffer = MmioWriteBuffer8 (StartAddress, Length, Buffer);\r | |
3149 | \r | |
3150 | Status = S3BootScriptSaveMemWrite (\r | |
3151 | S3BootScriptWidthUint8,\r | |
3152 | StartAddress,\r | |
3153 | Length / sizeof (UINT8),\r | |
3154 | ReturnBuffer\r | |
3155 | );\r | |
3156 | ASSERT (Status == RETURN_SUCCESS);\r | |
3157 | \r | |
3158 | return ReturnBuffer;\r | |
3159 | }\r | |
3160 | \r | |
3161 | /**\r | |
3162 | Copy data from system memory to MMIO region by using 16-bit access\r | |
3163 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
3164 | \r | |
9095d37b LG |
3165 | Copy data from system memory specified by Buffer to MMIO region specified\r |
3166 | by starting address StartAddress by using 16-bit access. The total number\r | |
fe69ac84 | 3167 | of byte to be copied is specified by Length. Buffer is returned.\r |
9095d37b | 3168 | \r |
fe69ac84 | 3169 | If StartAddress is not aligned on a 16-bit boundary, then ASSERT().\r |
3170 | \r | |
9095d37b | 3171 | If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r |
fe69ac84 | 3172 | If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r |
3173 | \r | |
3174 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
3175 | \r | |
3176 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
3177 | \r | |
3178 | @param StartAddress Starting address for the MMIO region to be copied to.\r | |
3179 | @param Length Size in bytes of the copy.\r | |
3180 | @param Buffer Pointer to a system memory buffer containing the data to write.\r | |
3181 | \r | |
3182 | @return Buffer\r | |
3183 | \r | |
3184 | **/\r | |
3185 | UINT16 *\r | |
3186 | EFIAPI\r | |
3187 | S3MmioWriteBuffer16 (\r | |
3188 | IN UINTN StartAddress,\r | |
3189 | IN UINTN Length,\r | |
3190 | IN CONST UINT16 *Buffer\r | |
3191 | )\r | |
3192 | {\r | |
3193 | UINT16 *ReturnBuffer;\r | |
3194 | RETURN_STATUS Status;\r | |
3195 | \r | |
3196 | ReturnBuffer = MmioWriteBuffer16 (StartAddress, Length, Buffer);\r | |
3197 | \r | |
3198 | Status = S3BootScriptSaveMemWrite (\r | |
3199 | S3BootScriptWidthUint16,\r | |
3200 | StartAddress,\r | |
3201 | Length / sizeof (UINT16),\r | |
3202 | ReturnBuffer\r | |
3203 | );\r | |
3204 | ASSERT (Status == RETURN_SUCCESS);\r | |
3205 | \r | |
3206 | return ReturnBuffer;\r | |
3207 | }\r | |
3208 | \r | |
3209 | \r | |
3210 | /**\r | |
3211 | Copy data from system memory to MMIO region by using 32-bit access\r | |
3212 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
3213 | \r | |
9095d37b LG |
3214 | Copy data from system memory specified by Buffer to MMIO region specified\r |
3215 | by starting address StartAddress by using 32-bit access. The total number\r | |
fe69ac84 | 3216 | of byte to be copied is specified by Length. Buffer is returned.\r |
9095d37b | 3217 | \r |
fe69ac84 | 3218 | If StartAddress is not aligned on a 32-bit boundary, then ASSERT().\r |
3219 | \r | |
9095d37b | 3220 | If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r |
fe69ac84 | 3221 | If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r |
3222 | \r | |
3223 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
3224 | \r | |
3225 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
3226 | \r | |
3227 | @param StartAddress Starting address for the MMIO region to be copied to.\r | |
3228 | @param Length Size in bytes of the copy.\r | |
3229 | @param Buffer Pointer to a system memory buffer containing the data to write.\r | |
3230 | \r | |
3231 | @return Buffer\r | |
3232 | \r | |
3233 | **/\r | |
3234 | UINT32 *\r | |
3235 | EFIAPI\r | |
3236 | S3MmioWriteBuffer32 (\r | |
3237 | IN UINTN StartAddress,\r | |
3238 | IN UINTN Length,\r | |
3239 | IN CONST UINT32 *Buffer\r | |
3240 | )\r | |
3241 | {\r | |
3242 | UINT32 *ReturnBuffer;\r | |
3243 | RETURN_STATUS Status;\r | |
3244 | \r | |
3245 | ReturnBuffer = MmioWriteBuffer32 (StartAddress, Length, Buffer);\r | |
3246 | \r | |
3247 | Status = S3BootScriptSaveMemWrite (\r | |
3248 | S3BootScriptWidthUint32,\r | |
3249 | StartAddress,\r | |
3250 | Length / sizeof (UINT32),\r | |
3251 | ReturnBuffer\r | |
3252 | );\r | |
3253 | ASSERT (Status == RETURN_SUCCESS);\r | |
3254 | \r | |
3255 | return ReturnBuffer;\r | |
3256 | }\r | |
3257 | \r | |
3258 | /**\r | |
3259 | Copy data from system memory to MMIO region by using 64-bit access\r | |
3260 | and saves the value in the S3 script to be replayed on S3 resume.\r | |
3261 | \r | |
9095d37b LG |
3262 | Copy data from system memory specified by Buffer to MMIO region specified\r |
3263 | by starting address StartAddress by using 64-bit access. The total number\r | |
fe69ac84 | 3264 | of byte to be copied is specified by Length. Buffer is returned.\r |
9095d37b | 3265 | \r |
fe69ac84 | 3266 | If StartAddress is not aligned on a 64-bit boundary, then ASSERT().\r |
3267 | \r | |
9095d37b | 3268 | If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().\r |
fe69ac84 | 3269 | If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r |
3270 | \r | |
3271 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
3272 | \r | |
3273 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
3274 | \r | |
3275 | @param StartAddress Starting address for the MMIO region to be copied to.\r | |
3276 | @param Length Size in bytes of the copy.\r | |
3277 | @param Buffer Pointer to a system memory buffer containing the data to write.\r | |
3278 | \r | |
3279 | @return Buffer\r | |
3280 | \r | |
3281 | **/\r | |
3282 | UINT64 *\r | |
3283 | EFIAPI\r | |
3284 | S3MmioWriteBuffer64 (\r | |
3285 | IN UINTN StartAddress,\r | |
3286 | IN UINTN Length,\r | |
3287 | IN CONST UINT64 *Buffer\r | |
3288 | )\r | |
3289 | {\r | |
3290 | UINT64 *ReturnBuffer;\r | |
3291 | RETURN_STATUS Status;\r | |
3292 | \r | |
3293 | ReturnBuffer = MmioWriteBuffer64 (StartAddress, Length, Buffer);\r | |
3294 | \r | |
3295 | Status = S3BootScriptSaveMemWrite (\r | |
3296 | S3BootScriptWidthUint64,\r | |
3297 | StartAddress,\r | |
3298 | Length / sizeof (UINT64),\r | |
3299 | ReturnBuffer\r | |
3300 | );\r | |
3301 | ASSERT (Status == RETURN_SUCCESS);\r | |
3302 | \r | |
3303 | return ReturnBuffer;\r | |
3304 | }\r | |
3305 | \r |