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