]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | SMM Services Table Library.\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php.\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include <PiSmm.h>\r | |
16 | #include <Protocol/SmmBase2.h>\r | |
17 | #include <Library/SmmServicesTableLib.h>\r | |
18 | #include <Library/DebugLib.h>\r | |
19 | \r | |
20 | EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;\r | |
21 | \r | |
22 | /**\r | |
23 | The constructor function caches the pointer of SMM Services Table.\r | |
24 | \r | |
25 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
26 | @param SystemTable A pointer to the EFI System Table.\r | |
27 | \r | |
28 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
29 | \r | |
30 | **/\r | |
31 | EFI_STATUS\r | |
32 | EFIAPI\r | |
33 | SmmServicesTableLibConstructor (\r | |
34 | IN EFI_HANDLE ImageHandle,\r | |
35 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
36 | )\r | |
37 | {\r | |
38 | EFI_STATUS Status;\r | |
39 | EFI_SMM_BASE2_PROTOCOL *InternalSmmBase2;\r | |
40 | \r | |
41 | InternalSmmBase2 = NULL;\r | |
42 | //\r | |
43 | // Retrieve SMM Base2 Protocol, Do not use gBS from UefiBootServicesTableLib on purpose\r | |
44 | // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the \r | |
45 | // SMM driver explicity declares that dependency. \r | |
46 | //\r | |
47 | Status = SystemTable->BootServices->LocateProtocol (\r | |
48 | &gEfiSmmBase2ProtocolGuid,\r | |
49 | NULL,\r | |
50 | (VOID **)&InternalSmmBase2\r | |
51 | );\r | |
52 | ASSERT_EFI_ERROR (Status);\r | |
53 | ASSERT (InternalSmmBase2 != NULL);\r | |
54 | \r | |
55 | //\r | |
56 | // We are in SMM, retrieve the pointer to SMM System Table\r | |
57 | //\r | |
58 | InternalSmmBase2->GetSmstLocation (InternalSmmBase2, &gSmst);\r | |
59 | ASSERT (gSmst != NULL);\r | |
60 | \r | |
61 | return EFI_SUCCESS;\r | |
62 | }\r | |
63 | \r | |
64 | /**\r | |
65 | This function allows the caller to determine if the driver is executing in \r | |
66 | System Management Mode(SMM).\r | |
67 | \r | |
68 | This function returns TRUE if the driver is executing in SMM and FALSE if the \r | |
69 | driver is not executing in SMM.\r | |
70 | \r | |
71 | @retval TRUE The driver is executing in System Management Mode (SMM).\r | |
72 | @retval FALSE The driver is not executing in System Management Mode (SMM). \r | |
73 | \r | |
74 | **/\r | |
75 | BOOLEAN\r | |
76 | EFIAPI\r | |
77 | InSmm (\r | |
78 | VOID\r | |
79 | )\r | |
80 | {\r | |
81 | //\r | |
82 | // We are already in SMM\r | |
83 | //\r | |
84 | return TRUE;\r | |
85 | }\r |