]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / UefiCpuPkg / CpuFeatures / CpuFeaturesPei.c
1 /** @file
2 CPU Features PEIM driver to initialize CPU features.
3
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
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.
12
13 **/
14
15 #include <PiPei.h>
16
17 #include <Library/BaseLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/PeiServicesLib.h>
20 #include <Library/RegisterCpuFeaturesLib.h>
21 #include <Library/HobLib.h>
22
23 #include <Guid/CpuFeaturesInitDone.h>
24
25 EFI_PEI_PPI_DESCRIPTOR mPeiCpuFeaturesInitDonePpiDesc = {
26 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
27 &gEdkiiCpuFeaturesInitDoneGuid,
28 NULL
29 };
30
31 /**
32 CPU Features driver entry point function.
33
34 It will perform CPU features initialization, except for
35 PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume.
36
37 @param FileHandle Handle of the file being invoked.
38 @param PeiServices Describes the list of possible PEI Services.
39
40 @retval EFI_SUCCESS CPU Features is initialized successfully.
41 **/
42 EFI_STATUS
43 EFIAPI
44 CpuFeaturesPeimInitialize (
45 IN EFI_PEI_FILE_HANDLE FileHandle,
46 IN CONST EFI_PEI_SERVICES **PeiServices
47 )
48 {
49 EFI_STATUS Status;
50 EFI_BOOT_MODE BootMode;
51
52 Status = PeiServicesGetBootMode (&BootMode);
53 ASSERT_EFI_ERROR (Status);
54
55 if (BootMode == BOOT_ON_S3_RESUME &&
56 !PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) {
57 //
58 // Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE
59 // on S3 boot mode
60 //
61 return EFI_SUCCESS;
62 }
63
64 CpuFeaturesDetect ();
65
66 CpuFeaturesInitialize ();
67
68 //
69 // Install CPU Features Init Done PPI
70 //
71 Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc);
72 ASSERT_EFI_ERROR (Status);
73
74 //
75 // Build HOB to let CpuFeatureDxe driver skip the initialization process.
76 //
77 BuildGuidHob (&gEdkiiCpuFeaturesInitDoneGuid, 0);
78
79 return EFI_SUCCESS;
80 }
81