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