]>
Commit | Line | Data |
---|---|---|
b7c5912a | 1 | /** @file\r |
2 | SMM Services Table Library.\r | |
3 | \r | |
4 | Copyright (c) 2009, Intel Corporation<BR>\r | |
5 | All rights reserved. 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 <PiDxe.h>\r | |
16 | #include <PiSmm.h>\r | |
17 | #include <Protocol/SmmBase2.h>\r | |
18 | #include <Library/UefiBootServicesTableLib.h>\r | |
19 | #include <Library/SmmServicesTableLib.h>\r | |
20 | #include <Library/DebugLib.h>\r | |
21 | \r | |
22 | EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;\r | |
23 | EFI_SMM_BASE2_PROTOCOL *mInternalSmmBase2 = NULL;\r | |
24 | \r | |
25 | \r | |
26 | /**\r | |
27 | The constructor function caches the pointer of Smm Services Table.\r | |
28 | \r | |
29 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
30 | @param SystemTable A pointer to the EFI System Table.\r | |
31 | \r | |
32 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
33 | \r | |
34 | **/\r | |
35 | EFI_STATUS\r | |
36 | EFIAPI\r | |
37 | SmmServicesTableLibConstructor (\r | |
38 | IN EFI_HANDLE ImageHandle,\r | |
39 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
40 | )\r | |
41 | {\r | |
42 | EFI_STATUS Status;\r | |
43 | BOOLEAN InSmm;\r | |
44 | \r | |
45 | //\r | |
46 | // Retrieve SMM Base2 Protocol\r | |
47 | //\r | |
48 | Status = gBS->LocateProtocol (\r | |
49 | &gEfiSmmBase2ProtocolGuid,\r | |
50 | NULL,\r | |
51 | (VOID **) &mInternalSmmBase2\r | |
52 | );\r | |
53 | ASSERT_EFI_ERROR (Status);\r | |
54 | ASSERT (mInternalSmmBase2 != NULL);\r | |
55 | \r | |
56 | //\r | |
57 | // Check to see if we are already in SMM\r | |
58 | //\r | |
59 | mInternalSmmBase2->InSmm (mInternalSmmBase2, &InSmm);\r | |
60 | \r | |
61 | if (!InSmm) {\r | |
62 | //\r | |
63 | // We are not in SMM, so SMST is not needed\r | |
64 | //\r | |
65 | return EFI_SUCCESS;\r | |
66 | }\r | |
67 | \r | |
68 | //\r | |
69 | // We are in SMM, retrieve the pointer to SMM System Table\r | |
70 | //\r | |
71 | mInternalSmmBase2->GetSmstLocation (mInternalSmmBase2, &gSmst);\r | |
72 | \r | |
73 | ASSERT (gSmst != NULL);\r | |
74 | \r | |
75 | return EFI_SUCCESS;\r | |
76 | }\r | |
77 | \r | |
78 | \r | |
79 | /**\r | |
80 | This function allows the caller to determine if the driver is executing in \r | |
81 | System Management Mode(SMM).\r | |
82 | \r | |
83 | This function returns TRUE if the driver is executing in SMM and FALSE if the \r | |
84 | driver is not executing in SMM.\r | |
85 | \r | |
86 | @retval TRUE The driver is executing in System Management Mode (SMM).\r | |
87 | @retval FALSE The driver is not executing in System Management Mode (SMM). \r | |
88 | \r | |
89 | **/\r | |
90 | BOOLEAN\r | |
91 | EFIAPI\r | |
92 | InSmm (\r | |
93 | VOID\r | |
94 | )\r | |
95 | {\r | |
96 | BOOLEAN InSmm;\r | |
97 | \r | |
98 | //\r | |
99 | // Check to see if we are already in SMM\r | |
100 | //\r | |
101 | mInternalSmmBase2->InSmm (mInternalSmmBase2, &InSmm);\r | |
102 | \r | |
103 | return InSmm;\r | |
104 | }\r |