Data is transferred between S3 Suspend and S3 Resume as follows:

S3 Suspend (DXE):

(1) prepare boot script:

    EFI_S3_SAVE_STATE_PROTOCOL.Write() [S3SaveStateDxe]
      S3BootScriptLib [PiDxeS3BootScriptLib]
      - opcodes & arguments are saved in NVS.  ---------+
                                                        |
(2) any DXE driver issues a notification by installing  |
    EFI_DXE_SMM_READY_TO_LOCK_PROTOCOL:                 |
                                                        |
    EFI_S3_SAVE_STATE_PROTOCOL [S3SaveStateDxe]         |
      S3BootScriptLib [PiDxeS3BootScriptLib]            |
      - closes script with special opcode  <------------+
      - script is available in non-volatile memory
        via PcdS3BootScriptTablePrivateDataPtr  --------------+
                                                              |
    BootScriptExecutorDxe                                     |
      S3BootScriptLib [PiDxeS3BootScriptLib]                  |
      - Knows about boot script location by synchronizing  <--+
        with the other library instance via
        PcdS3BootScriptTablePrivateDataPtr.
      - Copies relocated image of itself to
        reserved memory. -----------------------------------+
      - Saved image contains pointer to boot script.  ------|--+
                                                            |  |
(3) BdsLibBootViaBootOption()                               |  |
      EFI_ACPI_S3_SAVE_PROTOCOL [AcpiS3SaveDxe]             |  |
        - saves ACPI S3 Context to SMRAM LockBox  --------+ |  |
          (including FACS address -- FACS ACPI table      | |  |
          contains OS waking vector)                      | |  |
                                                          | |  |
Runtime:                                                  | |  |
                                                          | |  |
(4) OS is booted, writes OS waking vector to FACS,        | |  |
    suspends machine                                      | |  |
                                                          | |  |
S3 Resume (PEI):                                          | |  |
                                                          | |  |
(5) PlatformPei sets S3 Boot Mode based on CMOS           | |  |
                                                          | |  |
(6) DXE core is skipped and EFI_PEI_S3_RESUME2 is called  | |  |
    as last step of PEI                                   | |  |
                                                          | |  |
(7) S3Resume2Pei retrieves from SMRAM LockBox:            | |  |
    - ACPI S3 Context (path to FACS)  <-------------------+ |  |
                                      ----------------------|--|--+
    - Boot Script Executor Image  <-------------------------+  |  |
                                                               |  |
(8) BootScriptExecutorDxe                                      |  |
      S3BootScriptLib [PiDxeS3BootScriptLib]                   |  |
      - executes boot script  <--------------------------------+  |
                                                                  |
(9) OS waking vector available from ACPI S3 Context / FACS  <-----+
    is called

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 OvmfPkg/PlatformPei/Platform.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 426ff45..23f9809 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -261,13 +261,16 @@ MiscInitialization (
 
 VOID
 BootModeInitialization (
   )
 {
-  EFI_STATUS Status;
+  EFI_BOOT_MODE BootMode;
+  EFI_STATUS    Status;
 
-  Status = PeiServicesSetBootMode (BOOT_WITH_FULL_CONFIGURATION);
+  BootMode = (CmosRead8 (0xF) == 0xFE) ? BOOT_ON_S3_RESUME :
+                                         BOOT_WITH_FULL_CONFIGURATION;
+  Status = PeiServicesSetBootMode (BootMode);
   ASSERT_EFI_ERROR (Status);
 
   Status = PeiServicesInstallPpi (mPpiBootMode);
   ASSERT_EFI_ERROR (Status);
 }
-- 
1.8.3.1


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to