]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c
6292f5bf873c1dcf08a2b9e3229ea5f50f747317
[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
22 #include <Guid/CpuFeaturesInitDone.h>
23
24 EFI_PEI_PPI_DESCRIPTOR mPeiCpuFeaturesInitDonePpiDesc = {
25 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
26 &gEdkiiCpuFeaturesInitDoneGuid,
27 NULL
28 };
29
30 /**
31 CPU Features driver entry point function.
32
33 It will perform CPU features initialization, except for
34 PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume.
35
36 @param FileHandle Handle of the file being invoked.
37 @param PeiServices Describes the list of possible PEI Services.
38
39 @retval EFI_SUCCESS CPU Features is initialized successfully.
40 **/
41 EFI_STATUS
42 EFIAPI
43 CpuFeaturesPeimInitialize (
44 IN EFI_PEI_FILE_HANDLE FileHandle,
45 IN CONST EFI_PEI_SERVICES **PeiServices
46 )
47 {
48 EFI_STATUS Status;
49 EFI_BOOT_MODE BootMode;
50
51 Status = PeiServicesGetBootMode (&BootMode);
52 ASSERT_EFI_ERROR (Status);
53
54 if (BootMode == BOOT_ON_S3_RESUME &&
55 !PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) {
56 //
57 // Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE
58 // on S3 boot mode
59 //
60 return EFI_SUCCESS;
61 }
62
63 CpuFeaturesDetect ();
64
65 CpuFeaturesInitialize ();
66
67 //
68 // Install CPU Features Init Done PPI
69 //
70 Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc);
71 ASSERT_EFI_ERROR (Status);
72
73 return EFI_SUCCESS;
74 }
75