]>
Commit | Line | Data |
---|---|---|
3cbfba02 DW |
1 | /*++\r |
2 | \r | |
3 | Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved\r | |
4 | \r\r | |
5 | This program and the accompanying materials are licensed and made available under\r\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution. \r\r | |
7 | The full text of the license may be found at \r\r | |
8 | http://opensource.org/licenses/bsd-license.php. \r\r | |
9 | \r\r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r\r | |
12 | \r\r | |
13 | \r | |
14 | --*/\r | |
15 | \r | |
16 | /** @file\r | |
17 | **/\r | |
18 | \r | |
19 | #include <Library/BaseMemoryLib.h>\r | |
20 | #include <Library/DebugLib.h>\r | |
21 | #include <Protocol/FirmwareVolume2.h>\r | |
22 | #include <Protocol/PlatformGopPolicy.h>\r | |
23 | \r | |
24 | #include <Guid/SetupVariable.h>\r | |
25 | #include <SetupMode.h>\r | |
c50ff97c | 26 | #include <Library/UefiBootServicesTableLib.h>\r |
3cbfba02 DW |
27 | #include <Library/UefiRuntimeServicesTableLib.h>\r |
28 | \r | |
3cbfba02 DW |
29 | PLATFORM_GOP_POLICY_PROTOCOL mPlatformGOPPolicy;\r |
30 | \r | |
31 | //\r | |
32 | // Function implementations\r | |
33 | //\r | |
34 | \r | |
35 | /**\r | |
36 | The function will excute with as the platform policy, and gives\r | |
37 | the Platform Lid Status. IBV/OEM can customize this code for their specific\r | |
38 | policy action.\r | |
39 | \r | |
40 | @param CurrentLidStatus Gives the current LID Status\r | |
41 | \r | |
42 | @retval EFI_SUCCESS.\r | |
43 | \r | |
44 | **/\r | |
45 | EFI_STATUS\r | |
46 | EFIAPI\r | |
47 | GetPlatformLidStatus (\r | |
48 | OUT LID_STATUS *CurrentLidStatus\r | |
49 | )\r | |
50 | {\r | |
51 | *CurrentLidStatus = LidOpen;\r | |
52 | \r | |
53 | return EFI_SUCCESS;\r | |
54 | }\r | |
55 | \r | |
56 | /**\r | |
57 | The function will excute and gives the Video Bios Table Size and Address.\r | |
58 | \r | |
59 | @param VbtAddress Gives the Physical Address of Video BIOS Table\r | |
60 | \r | |
61 | @param VbtSize Gives the Size of Video BIOS Table\r | |
62 | \r | |
63 | @retval EFI_STATUS.\r | |
64 | \r | |
65 | **/\r | |
66 | \r | |
67 | EFI_STATUS\r | |
68 | EFIAPI\r | |
69 | GetVbtData (\r | |
70 | OUT EFI_PHYSICAL_ADDRESS *VbtAddress,\r | |
71 | OUT UINT32 *VbtSize\r | |
72 | )\r | |
73 | {\r | |
74 | EFI_STATUS Status;\r | |
75 | UINTN FvProtocolCount;\r | |
76 | EFI_HANDLE *FvHandles;\r | |
77 | EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r | |
78 | UINTN Index;\r | |
79 | UINT32 AuthenticationStatus;\r | |
80 | \r | |
81 | UINT8 *Buffer;\r | |
82 | UINTN VbtBufferSize;\r | |
83 | \r | |
84 | Buffer = 0;\r | |
85 | FvHandles = NULL;\r | |
86 | \r | |
87 | if (VbtAddress == NULL || VbtSize == NULL){\r | |
88 | return EFI_INVALID_PARAMETER;\r | |
89 | }\r | |
90 | Status = gBS->LocateHandleBuffer (\r | |
91 | ByProtocol,\r | |
92 | &gEfiFirmwareVolume2ProtocolGuid,\r | |
93 | NULL,\r | |
94 | &FvProtocolCount,\r | |
95 | &FvHandles\r | |
96 | );\r | |
97 | \r | |
98 | if (!EFI_ERROR (Status)) {\r | |
99 | for (Index = 0; Index < FvProtocolCount; Index++) {\r | |
100 | Status = gBS->HandleProtocol (\r | |
101 | FvHandles[Index],\r | |
102 | &gEfiFirmwareVolume2ProtocolGuid,\r | |
103 | (VOID **) &Fv\r | |
104 | );\r | |
105 | VbtBufferSize = 0;\r | |
106 | Status = Fv->ReadSection (\r | |
107 | Fv,\r | |
108 | &gBmpImageGuid,\r | |
109 | EFI_SECTION_RAW,\r | |
110 | 0,\r | |
111 | (void **)&Buffer,\r | |
112 | &VbtBufferSize,\r | |
113 | &AuthenticationStatus\r | |
114 | );\r | |
115 | \r | |
116 | if (!EFI_ERROR (Status)) {\r | |
117 | *VbtAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;\r | |
118 | *VbtSize = (UINT32)VbtBufferSize;\r | |
119 | Status = EFI_SUCCESS;\r | |
120 | break;\r | |
121 | }\r | |
122 | }\r | |
123 | } else {\r | |
124 | Status = EFI_NOT_FOUND;\r | |
125 | }\r | |
126 | \r | |
127 | if (FvHandles != NULL) {\r | |
128 | gBS->FreePool (FvHandles);\r | |
129 | FvHandles = NULL;\r | |
130 | }\r | |
131 | \r | |
132 | return Status;\r | |
133 | }\r | |
134 | \r | |
135 | /**\r | |
136 | Entry point for the Platform GOP Policy Driver.\r | |
137 | \r | |
138 | @param ImageHandle Image handle of this driver.\r | |
139 | @param SystemTable Global system service table.\r | |
140 | \r | |
141 | @retval EFI_SUCCESS Initialization complete.\r | |
142 | @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.\r | |
143 | \r | |
144 | **/\r | |
145 | \r | |
146 | EFI_STATUS\r | |
147 | EFIAPI\r | |
148 | PlatformGOPPolicyEntryPoint (\r | |
149 | IN EFI_HANDLE ImageHandle,\r | |
150 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
151 | )\r | |
152 | \r | |
153 | {\r | |
154 | EFI_STATUS Status = EFI_SUCCESS;\r | |
155 | SYSTEM_CONFIGURATION SystemConfiguration;\r | |
156 | UINTN VarSize;\r | |
157 | \r | |
158 | \r | |
159 | gBS = SystemTable->BootServices;\r | |
160 | \r | |
161 | gBS->SetMem (\r | |
162 | &mPlatformGOPPolicy,\r | |
163 | sizeof (PLATFORM_GOP_POLICY_PROTOCOL),\r | |
164 | 0\r | |
165 | );\r | |
166 | \r | |
167 | mPlatformGOPPolicy.Revision = PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01;\r | |
168 | mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus;\r | |
169 | mPlatformGOPPolicy.GetVbtData = GetVbtData;\r | |
170 | \r | |
171 | //\r | |
172 | // Install protocol to allow access to this Policy.\r | |
173 | //\r | |
174 | VarSize = sizeof(SYSTEM_CONFIGURATION);\r | |
175 | Status = gRT->GetVariable(\r | |
176 | L"Setup",\r | |
177 | &gEfiNormalSetupGuid,\r | |
178 | NULL,\r | |
179 | &VarSize,\r | |
180 | &SystemConfiguration\r | |
181 | );\r | |
620f2891 TH |
182 | if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r |
183 | //The setup variable is corrupted\r | |
184 | VarSize = sizeof(SYSTEM_CONFIGURATION);\r | |
185 | Status = gRT->GetVariable(\r | |
186 | L"SetupRecovery",\r | |
187 | &gEfiNormalSetupGuid,\r | |
188 | NULL,\r | |
189 | &VarSize,\r | |
190 | &SystemConfiguration\r | |
191 | );\r | |
192 | ASSERT_EFI_ERROR (Status);\r | |
193 | }\r | |
194 | \r | |
3cbfba02 DW |
195 | if (SystemConfiguration.GOPEnable == 1)\r |
196 | {\r | |
197 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
198 | &ImageHandle,\r | |
199 | &gPlatformGOPPolicyGuid,\r | |
200 | &mPlatformGOPPolicy,\r | |
201 | NULL\r | |
202 | );\r | |
203 | }\r | |
204 | \r | |
205 | return Status;\r | |
206 | }\r |