3 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Library/BaseMemoryLib.h>
20 #include <Library/DebugLib.h>
21 #include <Protocol/FirmwareVolume2.h>
22 #include <Protocol/PlatformGopPolicy.h>
24 #include <Guid/SetupVariable.h>
25 #include <SetupMode.h>
26 #include <Library/UefiBootServicesTableLib.h>
27 #include <Library/UefiRuntimeServicesTableLib.h>
29 PLATFORM_GOP_POLICY_PROTOCOL mPlatformGOPPolicy
;
32 // Function implementations
36 The function will execute with as the platform policy, and gives
37 the Platform Lid Status. IBV/OEM can customize this code for their specific
40 @param CurrentLidStatus Gives the current LID Status
47 GetPlatformLidStatus (
48 OUT LID_STATUS
*CurrentLidStatus
51 *CurrentLidStatus
= LidOpen
;
57 The function will execute and gives the Video Bios Table Size and Address.
59 @param VbtAddress Gives the Physical Address of Video BIOS Table
61 @param VbtSize Gives the Size of Video BIOS Table
70 OUT EFI_PHYSICAL_ADDRESS
*VbtAddress
,
75 UINTN FvProtocolCount
;
76 EFI_HANDLE
*FvHandles
;
77 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
79 UINT32 AuthenticationStatus
;
87 if (VbtAddress
== NULL
|| VbtSize
== NULL
){
88 return EFI_INVALID_PARAMETER
;
90 Status
= gBS
->LocateHandleBuffer (
92 &gEfiFirmwareVolume2ProtocolGuid
,
98 if (!EFI_ERROR (Status
)) {
99 for (Index
= 0; Index
< FvProtocolCount
; Index
++) {
100 Status
= gBS
->HandleProtocol (
102 &gEfiFirmwareVolume2ProtocolGuid
,
106 Status
= Fv
->ReadSection (
113 &AuthenticationStatus
116 if (!EFI_ERROR (Status
)) {
117 *VbtAddress
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)Buffer
;
118 *VbtSize
= (UINT32
)VbtBufferSize
;
119 Status
= EFI_SUCCESS
;
124 Status
= EFI_NOT_FOUND
;
127 if (FvHandles
!= NULL
) {
128 gBS
->FreePool (FvHandles
);
136 Entry point for the Platform GOP Policy Driver.
138 @param ImageHandle Image handle of this driver.
139 @param SystemTable Global system service table.
141 @retval EFI_SUCCESS Initialization complete.
142 @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
148 PlatformGOPPolicyEntryPoint (
149 IN EFI_HANDLE ImageHandle
,
150 IN EFI_SYSTEM_TABLE
*SystemTable
154 EFI_STATUS Status
= EFI_SUCCESS
;
155 SYSTEM_CONFIGURATION SystemConfiguration
;
159 gBS
= SystemTable
->BootServices
;
163 sizeof (PLATFORM_GOP_POLICY_PROTOCOL
),
167 mPlatformGOPPolicy
.Revision
= PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01
;
168 mPlatformGOPPolicy
.GetPlatformLidStatus
= GetPlatformLidStatus
;
169 mPlatformGOPPolicy
.GetVbtData
= GetVbtData
;
172 // Install protocol to allow access to this Policy.
174 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
175 Status
= gRT
->GetVariable(
177 &gEfiNormalSetupGuid
,
182 if (EFI_ERROR (Status
) || VarSize
!= sizeof(SYSTEM_CONFIGURATION
)) {
183 //The setup variable is corrupted
184 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
185 Status
= gRT
->GetVariable(
187 &gEfiNormalSetupGuid
,
192 ASSERT_EFI_ERROR (Status
);
195 if (SystemConfiguration
.GOPEnable
== 1)
197 Status
= gBS
->InstallMultipleProtocolInterfaces (
199 &gPlatformGOPPolicyGuid
,