3 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
5 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/BaseMemoryLib.h>
15 #include <Library/DebugLib.h>
16 #include <Protocol/FirmwareVolume2.h>
17 #include <Protocol/PlatformGopPolicy.h>
19 #include <Guid/SetupVariable.h>
20 #include <SetupMode.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Library/UefiRuntimeServicesTableLib.h>
24 PLATFORM_GOP_POLICY_PROTOCOL mPlatformGOPPolicy
;
27 // Function implementations
31 The function will execute with as the platform policy, and gives
32 the Platform Lid Status. IBV/OEM can customize this code for their specific
35 @param CurrentLidStatus Gives the current LID Status
42 GetPlatformLidStatus (
43 OUT LID_STATUS
*CurrentLidStatus
46 *CurrentLidStatus
= LidOpen
;
52 The function will execute and gives the Video Bios Table Size and Address.
54 @param VbtAddress Gives the Physical Address of Video BIOS Table
56 @param VbtSize Gives the Size of Video BIOS Table
65 OUT EFI_PHYSICAL_ADDRESS
*VbtAddress
,
70 UINTN FvProtocolCount
;
71 EFI_HANDLE
*FvHandles
;
72 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
74 UINT32 AuthenticationStatus
;
82 if (VbtAddress
== NULL
|| VbtSize
== NULL
){
83 return EFI_INVALID_PARAMETER
;
85 Status
= gBS
->LocateHandleBuffer (
87 &gEfiFirmwareVolume2ProtocolGuid
,
93 if (!EFI_ERROR (Status
)) {
94 for (Index
= 0; Index
< FvProtocolCount
; Index
++) {
95 Status
= gBS
->HandleProtocol (
97 &gEfiFirmwareVolume2ProtocolGuid
,
101 Status
= Fv
->ReadSection (
108 &AuthenticationStatus
111 if (!EFI_ERROR (Status
)) {
112 *VbtAddress
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)Buffer
;
113 *VbtSize
= (UINT32
)VbtBufferSize
;
114 Status
= EFI_SUCCESS
;
119 Status
= EFI_NOT_FOUND
;
122 if (FvHandles
!= NULL
) {
123 gBS
->FreePool (FvHandles
);
131 Entry point for the Platform GOP Policy Driver.
133 @param ImageHandle Image handle of this driver.
134 @param SystemTable Global system service table.
136 @retval EFI_SUCCESS Initialization complete.
137 @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
143 PlatformGOPPolicyEntryPoint (
144 IN EFI_HANDLE ImageHandle
,
145 IN EFI_SYSTEM_TABLE
*SystemTable
149 EFI_STATUS Status
= EFI_SUCCESS
;
150 SYSTEM_CONFIGURATION SystemConfiguration
;
154 gBS
= SystemTable
->BootServices
;
158 sizeof (PLATFORM_GOP_POLICY_PROTOCOL
),
162 mPlatformGOPPolicy
.Revision
= PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01
;
163 mPlatformGOPPolicy
.GetPlatformLidStatus
= GetPlatformLidStatus
;
164 mPlatformGOPPolicy
.GetVbtData
= GetVbtData
;
167 // Install protocol to allow access to this Policy.
169 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
170 Status
= gRT
->GetVariable(
172 &gEfiNormalSetupGuid
,
177 if (EFI_ERROR (Status
) || VarSize
!= sizeof(SYSTEM_CONFIGURATION
)) {
178 //The setup variable is corrupted
179 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
180 Status
= gRT
->GetVariable(
182 &gEfiNormalSetupGuid
,
187 ASSERT_EFI_ERROR (Status
);
190 if (SystemConfiguration
.GOPEnable
== 1)
192 Status
= gBS
->InstallMultipleProtocolInterfaces (
194 &gPlatformGOPPolicyGuid
,