]>
Commit | Line | Data |
---|---|---|
8c71ec8f | 1 | /** @file\r |
2 | The module entry point for SecureBoot configuration module.\r | |
3 | \r | |
4 | Copyright (c) 2011, 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 "SecureBootConfigImpl.h"\r | |
16 | \r | |
17 | /**\r | |
18 | The entry point for SecureBoot configuration driver.\r | |
19 | \r | |
20 | @param[in] ImageHandle The image handle of the driver.\r | |
21 | @param[in] SystemTable The system table.\r | |
22 | \r | |
23 | @retval EFI_ALREADY_STARTED The driver already exists in system.\r | |
24 | @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of resources.\r | |
25 | @retval EFI_SUCCES All the related protocols are installed on the driver.\r | |
26 | @retval Others Fail to get the SecureBootEnable variable.\r | |
27 | \r | |
28 | **/\r | |
29 | EFI_STATUS\r | |
30 | EFIAPI\r | |
31 | SecureBootConfigDriverEntryPoint (\r | |
32 | IN EFI_HANDLE ImageHandle,\r | |
33 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
34 | )\r | |
35 | {\r | |
36 | EFI_STATUS Status;\r | |
37 | SECUREBOOT_CONFIG_PRIVATE_DATA *PrivateData;\r | |
38 | \r | |
39 | //\r | |
40 | // If already started, return.\r | |
41 | //\r | |
42 | Status = gBS->OpenProtocol (\r | |
43 | ImageHandle,\r | |
44 | &gEfiCallerIdGuid,\r | |
45 | NULL,\r | |
46 | ImageHandle,\r | |
47 | ImageHandle,\r | |
48 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r | |
49 | );\r | |
50 | if (!EFI_ERROR (Status)) {\r | |
51 | return EFI_ALREADY_STARTED;\r | |
52 | }\r | |
53 | \r | |
54 | //\r | |
55 | // Create a private data structure.\r | |
56 | //\r | |
57 | PrivateData = AllocateCopyPool (sizeof (SECUREBOOT_CONFIG_PRIVATE_DATA), &mSecureBootConfigPrivateDateTemplate);\r | |
58 | if (PrivateData == NULL) {\r | |
59 | return EFI_OUT_OF_RESOURCES;\r | |
60 | }\r | |
61 | \r | |
62 | //\r | |
63 | // Install SecureBoot configuration form\r | |
64 | //\r | |
65 | Status = InstallSecureBootConfigForm (PrivateData);\r | |
66 | if (EFI_ERROR (Status)) {\r | |
67 | goto ErrorExit;\r | |
68 | }\r | |
69 | \r | |
70 | //\r | |
71 | // Install private GUID.\r | |
72 | // \r | |
73 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
74 | &ImageHandle,\r | |
75 | &gEfiCallerIdGuid,\r | |
76 | PrivateData,\r | |
77 | NULL\r | |
78 | );\r | |
79 | \r | |
80 | if (EFI_ERROR (Status)) {\r | |
81 | goto ErrorExit;\r | |
82 | }\r | |
83 | \r | |
84 | return EFI_SUCCESS;\r | |
85 | \r | |
86 | ErrorExit:\r | |
87 | if (PrivateData != NULL) {\r | |
88 | UninstallSecureBootConfigForm (PrivateData);\r | |
89 | } \r | |
90 | \r | |
91 | return Status;\r | |
92 | }\r | |
93 | \r | |
94 | /**\r | |
95 | Unload the SecureBoot configuration form.\r | |
96 | \r | |
97 | @param[in] ImageHandle The driver's image handle.\r | |
98 | \r | |
99 | @retval EFI_SUCCESS The SecureBoot configuration form is unloaded.\r | |
100 | @retval Others Failed to unload the form.\r | |
101 | \r | |
102 | **/\r | |
103 | EFI_STATUS\r | |
104 | EFIAPI\r | |
105 | SecureBootConfigDriverUnload (\r | |
106 | IN EFI_HANDLE ImageHandle\r | |
107 | )\r | |
108 | {\r | |
109 | EFI_STATUS Status;\r | |
110 | SECUREBOOT_CONFIG_PRIVATE_DATA *PrivateData;\r | |
111 | \r | |
112 | Status = gBS->HandleProtocol (\r | |
113 | ImageHandle,\r | |
114 | &gEfiCallerIdGuid,\r | |
115 | (VOID **) &PrivateData\r | |
116 | ); \r | |
117 | if (EFI_ERROR (Status)) {\r | |
118 | return Status; \r | |
119 | }\r | |
120 | \r | |
121 | ASSERT (PrivateData->Signature == SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE);\r | |
122 | \r | |
123 | gBS->UninstallMultipleProtocolInterfaces (\r | |
124 | &ImageHandle,\r | |
125 | &gEfiCallerIdGuid,\r | |
126 | PrivateData,\r | |
127 | NULL\r | |
128 | );\r | |
129 | \r | |
130 | UninstallSecureBootConfigForm (PrivateData);\r | |
131 | \r | |
132 | return EFI_SUCCESS;\r | |
133 | }\r |