EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c

Go to the documentation of this file.
00001 
00015 #include <PiSmm.h>
00016 #include <Protocol/SmmBase2.h>
00017 #include <Library/SmmServicesTableLib.h>
00018 #include <Library/DebugLib.h>
00019 
00020 EFI_SMM_SYSTEM_TABLE2   *gSmst             = NULL;
00021 EFI_SMM_BASE2_PROTOCOL  *mInternalSmmBase2 = NULL;
00022 
00032 EFI_STATUS
00033 EFIAPI
00034 SmmServicesTableLibConstructor (
00035   IN EFI_HANDLE        ImageHandle,
00036   IN EFI_SYSTEM_TABLE  *SystemTable
00037   )
00038 {
00039   EFI_STATUS  Status;
00040 
00041   //
00042   // Retrieve SMM Base2 Protocol,  Do not use gBS from UefiBootServicesTableLib on purpose
00043   // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the 
00044   // SMM driver explicity declares that dependency. 
00045   //
00046   Status = SystemTable->BootServices->LocateProtocol (
00047                                         &gEfiSmmBase2ProtocolGuid,
00048                                         NULL,
00049                                         (VOID **)&mInternalSmmBase2
00050                                         );
00051   ASSERT_EFI_ERROR (Status);
00052   ASSERT (mInternalSmmBase2 != NULL);
00053 
00054   //
00055   // Check to see if we are already in SMM
00056   //
00057   if (!InSmm ()) {
00058     //
00059     // We are not in SMM, so SMST is not needed
00060     //
00061     return EFI_SUCCESS;
00062   }
00063 
00064   //
00065   // We are in SMM, retrieve the pointer to SMM System Table
00066   //
00067   mInternalSmmBase2->GetSmstLocation (mInternalSmmBase2, &gSmst);
00068   ASSERT (gSmst != NULL);
00069 
00070   return EFI_SUCCESS;
00071 }
00072 
00084 BOOLEAN
00085 EFIAPI
00086 InSmm (
00087   VOID
00088   )
00089 {
00090   BOOLEAN  InSmm;
00091 
00092   //
00093   // Check to see if we are already in SMM
00094   //
00095   mInternalSmmBase2->InSmm (mInternalSmmBase2, &InSmm);
00096   return InSmm;
00097 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines