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/UefiRuntimeServicesTableLib.h>
28 EFI_BOOT_SERVICES
*gBS
;
31 PLATFORM_GOP_POLICY_PROTOCOL mPlatformGOPPolicy
;
34 // Function implementations
38 The function will excute with as the platform policy, and gives
39 the Platform Lid Status. IBV/OEM can customize this code for their specific
42 @param CurrentLidStatus Gives the current LID Status
49 GetPlatformLidStatus (
50 OUT LID_STATUS
*CurrentLidStatus
53 *CurrentLidStatus
= LidOpen
;
59 The function will excute and gives the Video Bios Table Size and Address.
61 @param VbtAddress Gives the Physical Address of Video BIOS Table
63 @param VbtSize Gives the Size of Video BIOS Table
72 OUT EFI_PHYSICAL_ADDRESS
*VbtAddress
,
77 UINTN FvProtocolCount
;
78 EFI_HANDLE
*FvHandles
;
79 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
81 UINT32 AuthenticationStatus
;
89 if (VbtAddress
== NULL
|| VbtSize
== NULL
){
90 return EFI_INVALID_PARAMETER
;
92 Status
= gBS
->LocateHandleBuffer (
94 &gEfiFirmwareVolume2ProtocolGuid
,
100 if (!EFI_ERROR (Status
)) {
101 for (Index
= 0; Index
< FvProtocolCount
; Index
++) {
102 Status
= gBS
->HandleProtocol (
104 &gEfiFirmwareVolume2ProtocolGuid
,
108 Status
= Fv
->ReadSection (
115 &AuthenticationStatus
118 if (!EFI_ERROR (Status
)) {
119 *VbtAddress
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)Buffer
;
120 *VbtSize
= (UINT32
)VbtBufferSize
;
121 Status
= EFI_SUCCESS
;
126 Status
= EFI_NOT_FOUND
;
129 if (FvHandles
!= NULL
) {
130 gBS
->FreePool (FvHandles
);
138 Entry point for the Platform GOP Policy Driver.
140 @param ImageHandle Image handle of this driver.
141 @param SystemTable Global system service table.
143 @retval EFI_SUCCESS Initialization complete.
144 @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
150 PlatformGOPPolicyEntryPoint (
151 IN EFI_HANDLE ImageHandle
,
152 IN EFI_SYSTEM_TABLE
*SystemTable
156 EFI_STATUS Status
= EFI_SUCCESS
;
157 SYSTEM_CONFIGURATION SystemConfiguration
;
161 gBS
= SystemTable
->BootServices
;
165 sizeof (PLATFORM_GOP_POLICY_PROTOCOL
),
169 mPlatformGOPPolicy
.Revision
= PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01
;
170 mPlatformGOPPolicy
.GetPlatformLidStatus
= GetPlatformLidStatus
;
171 mPlatformGOPPolicy
.GetVbtData
= GetVbtData
;
174 // Install protocol to allow access to this Policy.
176 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
177 Status
= gRT
->GetVariable(
179 &gEfiNormalSetupGuid
,
184 ASSERT_EFI_ERROR(Status
);
185 if (SystemConfiguration
.GOPEnable
== 1)
187 Status
= gBS
->InstallMultipleProtocolInterfaces (
189 &gPlatformGOPPolicyGuid
,