VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c@ 89916

Last change on this file since 89916 was 85718, checked in by vboxsync, 5 years ago

Devices/EFI: Merge edk-stable202005 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1/** @file
2 SMM Services Table Library.
3
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include <PiSmm.h>
10#include <Protocol/SmmBase2.h>
11#include <Library/SmmServicesTableLib.h>
12#include <Library/DebugLib.h>
13
14EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;
15
16/**
17 The constructor function caches the pointer of SMM Services Table.
18
19 @param ImageHandle The firmware allocated handle for the EFI image.
20 @param SystemTable A pointer to the EFI System Table.
21
22 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
23
24**/
25EFI_STATUS
26EFIAPI
27SmmServicesTableLibConstructor (
28 IN EFI_HANDLE ImageHandle,
29 IN EFI_SYSTEM_TABLE *SystemTable
30 )
31{
32 EFI_STATUS Status;
33 EFI_SMM_BASE2_PROTOCOL *InternalSmmBase2;
34
35 InternalSmmBase2 = NULL;
36 //
37 // Retrieve SMM Base2 Protocol, Do not use gBS from UefiBootServicesTableLib on purpose
38 // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the
39 // SMM driver explicitly declares that dependency.
40 //
41 Status = SystemTable->BootServices->LocateProtocol (
42 &gEfiSmmBase2ProtocolGuid,
43 NULL,
44 (VOID **)&InternalSmmBase2
45 );
46 ASSERT_EFI_ERROR (Status);
47 ASSERT (InternalSmmBase2 != NULL);
48
49 //
50 // We are in SMM, retrieve the pointer to SMM System Table
51 //
52 InternalSmmBase2->GetSmstLocation (InternalSmmBase2, &gSmst);
53 ASSERT (gSmst != NULL);
54
55 return EFI_SUCCESS;
56}
57
58/**
59 This function allows the caller to determine if the driver is executing in
60 System Management Mode(SMM).
61
62 This function returns TRUE if the driver is executing in SMM and FALSE if the
63 driver is not executing in SMM.
64
65 @retval TRUE The driver is executing in System Management Mode (SMM).
66 @retval FALSE The driver is not executing in System Management Mode (SMM).
67
68**/
69BOOLEAN
70EFIAPI
71InSmm (
72 VOID
73 )
74{
75 //
76 // We are already in SMM
77 //
78 return TRUE;
79}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette