+++ /dev/null
-/*++\r
-\r
-Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved\r
- \r\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
- \r\r
-\r
---*/\r
-\r
-/** @file\r
-**/\r
-\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
-#include <Protocol/PlatformGopPolicy.h>\r
-\r
-#include <Guid/SetupVariable.h>\r
-#include <SetupMode.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-\r
-PLATFORM_GOP_POLICY_PROTOCOL mPlatformGOPPolicy;\r
-\r
-//\r
-// Function implementations\r
-//\r
-\r
-/**\r
- The function will execute with as the platform policy, and gives\r
- the Platform Lid Status. IBV/OEM can customize this code for their specific\r
- policy action.\r
-\r
- @param CurrentLidStatus Gives the current LID Status\r
-\r
- @retval EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GetPlatformLidStatus (\r
- OUT LID_STATUS *CurrentLidStatus\r
-)\r
-{\r
- *CurrentLidStatus = LidOpen;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- The function will execute and gives the Video Bios Table Size and Address.\r
-\r
- @param VbtAddress Gives the Physical Address of Video BIOS Table\r
-\r
- @param VbtSize Gives the Size of Video BIOS Table\r
-\r
- @retval EFI_STATUS.\r
-\r
-**/\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetVbtData (\r
- OUT EFI_PHYSICAL_ADDRESS *VbtAddress,\r
- OUT UINT32 *VbtSize\r
-)\r
-{\r
- EFI_STATUS Status;\r
- UINTN FvProtocolCount;\r
- EFI_HANDLE *FvHandles;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
- UINTN Index;\r
- UINT32 AuthenticationStatus;\r
-\r
- UINT8 *Buffer;\r
- UINTN VbtBufferSize;\r
-\r
- Buffer = 0;\r
- FvHandles = NULL;\r
-\r
- if (VbtAddress == NULL || VbtSize == NULL){\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- Status = gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiFirmwareVolume2ProtocolGuid,\r
- NULL,\r
- &FvProtocolCount,\r
- &FvHandles\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
- for (Index = 0; Index < FvProtocolCount; Index++) {\r
- Status = gBS->HandleProtocol (\r
- FvHandles[Index],\r
- &gEfiFirmwareVolume2ProtocolGuid,\r
- (VOID **) &Fv\r
- );\r
- VbtBufferSize = 0;\r
- Status = Fv->ReadSection (\r
- Fv,\r
- &gBmpImageGuid,\r
- EFI_SECTION_RAW,\r
- 0,\r
- (void **)&Buffer,\r
- &VbtBufferSize,\r
- &AuthenticationStatus\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
- *VbtAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;\r
- *VbtSize = (UINT32)VbtBufferSize;\r
- Status = EFI_SUCCESS;\r
- break;\r
- }\r
- }\r
- } else {\r
- Status = EFI_NOT_FOUND;\r
- }\r
-\r
- if (FvHandles != NULL) {\r
- gBS->FreePool (FvHandles);\r
- FvHandles = NULL;\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-/**\r
- Entry point for the Platform GOP Policy Driver.\r
-\r
- @param ImageHandle Image handle of this driver.\r
- @param SystemTable Global system service table.\r
-\r
- @retval EFI_SUCCESS Initialization complete.\r
- @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.\r
-\r
-**/\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PlatformGOPPolicyEntryPoint (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-\r
-{\r
- EFI_STATUS Status = EFI_SUCCESS;\r
- SYSTEM_CONFIGURATION SystemConfiguration;\r
- UINTN VarSize;\r
-\r
-\r
- gBS = SystemTable->BootServices;\r
-\r
- gBS->SetMem (\r
- &mPlatformGOPPolicy,\r
- sizeof (PLATFORM_GOP_POLICY_PROTOCOL),\r
- 0\r
- );\r
-\r
- mPlatformGOPPolicy.Revision = PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01;\r
- mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus;\r
- mPlatformGOPPolicy.GetVbtData = GetVbtData;\r
-\r
- //\r
- // Install protocol to allow access to this Policy.\r
- //\r
- VarSize = sizeof(SYSTEM_CONFIGURATION);\r
- Status = gRT->GetVariable(\r
- L"Setup",\r
- &gEfiNormalSetupGuid,\r
- NULL,\r
- &VarSize,\r
- &SystemConfiguration\r
- );\r
- if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r
- //The setup variable is corrupted\r
- VarSize = sizeof(SYSTEM_CONFIGURATION);\r
- Status = gRT->GetVariable(\r
- L"SetupRecovery",\r
- &gEfiNormalSetupGuid,\r
- NULL,\r
- &VarSize,\r
- &SystemConfiguration\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- }\r
- \r
- if (SystemConfiguration.GOPEnable == 1)\r
- {\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &ImageHandle,\r
- &gPlatformGOPPolicyGuid,\r
- &mPlatformGOPPolicy,\r
- NULL\r
- );\r
- }\r
-\r
- return Status;\r
-}\r