Home | History | Annotate | Download | only in BootScriptThunkHelper
      1 /** @file
      2   Boot Script Helper SMM driver.
      3 
      4   This driver is responsible to store BootScriptThunk from ReservedMemory to SMRAM for security consideration.
      5 
      6 Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
      7 
      8 This program and the accompanying materials
      9 are licensed and made available under the terms and conditions
     10 of the BSD License which accompanies this distribution.  The
     11 full text of the license may be found at
     12 http://opensource.org/licenses/bsd-license.php
     13 
     14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     16 
     17 **/
     18 
     19 #include <PiDxe.h>
     20 #include <Library/BaseLib.h>
     21 #include <Library/PcdLib.h>
     22 #include <Library/DebugLib.h>
     23 #include <Library/LockBoxLib.h>
     24 
     25 #include <Guid/BootScriptThunkData.h>
     26 
     27 EFI_GUID mBootScriptThunkGuid = {
     28   0xa053f561, 0xf56b, 0x4140, {0x89, 0x1, 0xb4, 0xcb, 0x5d, 0x70, 0x92, 0x9e}
     29 };
     30 
     31 /**
     32   Entry point function of the Boot Script Thunk Helper SMM driver.
     33 
     34   @param[in] ImageHandle  The firmware allocated handle for the EFI image.
     35   @param[in] SystemTable  A pointer to the EFI System Table.
     36 
     37   @retval EFI_SUCCESS     The entry point is executed successfully.
     38   @retval other           Some error occurs when executing this entry point.
     39 **/
     40 EFI_STATUS
     41 EFIAPI
     42 BootScriptThunkHelperMain (
     43   IN EFI_HANDLE        ImageHandle,
     44   IN EFI_SYSTEM_TABLE  *SystemTable
     45   )
     46 {
     47   BOOT_SCRIPT_THUNK_DATA        *BootScriptThunkData;
     48   EFI_STATUS                    Status;
     49 
     50   //
     51   // Get BootScriptThunk variable
     52   //
     53   BootScriptThunkData = (BOOT_SCRIPT_THUNK_DATA *)(UINTN)PcdGet64(BootScriptThunkDataPtr);
     54   ASSERT (BootScriptThunkData != NULL);
     55   if (BootScriptThunkData == NULL) {
     56     return EFI_NOT_FOUND;
     57   }
     58 
     59   //
     60   // Save BootScriptThunk image
     61   //
     62   Status = SaveLockBox (
     63              &mBootScriptThunkGuid,
     64              (VOID *)(UINTN)BootScriptThunkData->BootScriptThunkBase,
     65              (UINTN)BootScriptThunkData->BootScriptThunkLength
     66              );
     67   ASSERT_EFI_ERROR (Status);
     68 
     69   Status = SetLockBoxAttributes (&mBootScriptThunkGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);
     70   ASSERT_EFI_ERROR (Status);
     71 
     72   return Status;
     73 }
     74