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