1 /** @file
2 
3 This is QNC Smm Power Management driver
4 
5 Copyright (c) 2013-2015 Intel Corporation.
6 
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution.  The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11 
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 
15 
16 **/
17 
18 #include "SmmPowerManagement.h"
19 
20 //
21 // Global variables
22 //
23 EFI_SMM_CPU_PROTOCOL                    *mSmmCpu = NULL;
24 EFI_GLOBAL_NVS_AREA                     *mGlobalNvsAreaPtr = NULL;
25 EFI_MP_SERVICES_PROTOCOL                *mMpService = NULL;
26 EFI_ACPI_SDT_PROTOCOL                   *mAcpiSdt = NULL;
27 EFI_ACPI_TABLE_PROTOCOL                 *mAcpiTable = NULL;
28 
29 EFI_GUID    mS3CpuRegisterTableGuid = S3_CPU_REGISTER_TABLE_GUID;
30 
31 EFI_STATUS
32 EFIAPI
InitializePowerManagement(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)33 InitializePowerManagement (
34   IN EFI_HANDLE        ImageHandle,
35   IN EFI_SYSTEM_TABLE  *SystemTable
36   )
37 /*++
38 
39 Routine Description:
40 
41   Initializes the SMM Handler Driver
42 
43 Arguments:
44 
45   ImageHandle -
46 
47   SystemTable -
48 
49 Returns:
50 
51   None
52 
53 --*/
54 {
55   EFI_STATUS                                Status;
56   EFI_SMM_SW_DISPATCH2_PROTOCOL             *SwDispatch;
57   EFI_GLOBAL_NVS_AREA_PROTOCOL              *GlobalNvsAreaProtocol;
58 
59   //
60   // Get SMM CPU protocol
61   //
62   Status = gSmst->SmmLocateProtocol (
63                     &gEfiSmmCpuProtocolGuid,
64                     NULL,
65                     (VOID **)&mSmmCpu
66                     );
67   ASSERT_EFI_ERROR (Status);
68 
69   //
70   //  Get the Sw dispatch protocol
71   //
72   Status = gSmst->SmmLocateProtocol (
73                     &gEfiSmmSwDispatch2ProtocolGuid,
74                     NULL,
75                     (VOID**)&SwDispatch
76                     );
77   ASSERT_EFI_ERROR (Status);
78 
79   //
80   // Get Global NVS Area Protocol
81   //
82   Status = gBS->LocateProtocol (&gEfiGlobalNvsAreaProtocolGuid, NULL, (VOID **)&GlobalNvsAreaProtocol);
83   ASSERT_EFI_ERROR (Status);
84   mGlobalNvsAreaPtr = GlobalNvsAreaProtocol->Area;
85 
86   //
87   // Locate and cache PI AcpiSdt Protocol.
88   //
89   Status = gBS->LocateProtocol (
90                   &gEfiAcpiSdtProtocolGuid,
91                   NULL,
92                   (VOID **) &mAcpiSdt
93                   );
94   ASSERT_EFI_ERROR (Status);
95 
96 
97   //
98   // Locate and cache PI AcpiSdt Protocol.
99   //
100   Status = gBS->LocateProtocol (
101                   &gEfiAcpiTableProtocolGuid,
102                   NULL,
103                   (VOID **) &mAcpiTable
104                   );
105   ASSERT_EFI_ERROR (Status);
106 
107 
108   //
109   // Get MpService protocol
110   //
111   Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&mMpService);
112   ASSERT_EFI_ERROR (Status);
113   //
114   // Initialize power management features on processors
115   //
116   PpmInit();
117 
118   return Status;
119 }
120