1 /*++
2 
3   Copyright (c) 2004  - 2019, Intel Corporation. All rights reserved.<BR>
4 
5   SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7 **/
8 
9 
10 #ifndef __PEI_PLATFORM_H__
11 #define __PEI_PLATFORM_H__
12 
13 #define PEI_STALL_RESOLUTION            1
14 #define STALL_PEIM_SIGNATURE   SIGNATURE_32('p','p','u','s')
15 
16 typedef struct {
17   UINT32                      Signature;
18   EFI_FFS_FILE_HEADER         *FfsHeader;
19   EFI_PEI_NOTIFY_DESCRIPTOR   StallNotify;
20 } STALL_CALLBACK_STATE_INFORMATION;
21 
22 #define STALL_PEIM_FROM_THIS(a) CR (a, STALL_CALLBACK_STATE_INFORMATION, StallNotify, STALL_PEIM_SIGNATURE)
23 
24 /**
25   Peform the boot mode determination logic
26   If the box is closed, then
27   1. If it's first time to boot, it's boot with full config .
28   2. If the ChassisIntrution is selected, force to be a boot with full config
29   3. Otherwise it's boot with no change.
30 
31   @param  PeiServices General purpose services available to every PEIM.
32   @param  BootMode The detected boot mode.
33 
34   @retval EFI_SUCCESS if the boot mode could be set
35 **/
36 EFI_STATUS
37 UpdateBootMode (
38   IN CONST EFI_PEI_SERVICES     **PeiServices
39   );
40 
41 /**
42   This function reset the entire platform, including all processor and devices, and
43   reboots the system.
44 
45   Declaration of this function goes to MdeModulePkg/Include/Library/ResetSystemLib.h
46 
47   @param  PeiServices General purpose services available to every PEIM.
48 
49   @retval EFI_SUCCESS if it completed successfully.
50 **/
51 // EFI_STATUS
52 // EFIAPI
53 // ResetSystem (
54   // IN CONST EFI_PEI_SERVICES          **PeiServices
55   // );
56 
57 /**
58   This function will be called when MRC is done.
59 
60   @param  PeiServices        General purpose services available to every PEIM.
61   @param  NotifyDescriptor   Information about the notify event..
62   @param  Ppi                The notify context.
63 
64   @retval EFI_SUCCESS        If the function completed successfully.
65 **/
66 EFI_STATUS
67 EFIAPI
68 MemoryDiscoveredPpiNotifyCallback (
69   IN EFI_PEI_SERVICES                     **PeiServices,
70   IN EFI_PEI_NOTIFY_DESCRIPTOR            *NotifyDescriptor,
71   IN VOID                                 *Ppi
72   );
73 
74 /**
75   This is the callback function notified by FvFileLoader PPI, it depends on FvFileLoader PPI to load
76   the PEIM into memory.
77 
78   @param  PeiServices       General purpose services available to every PEIM.
79   @param  NotifyDescriptor  The context of notification.
80   @param  Ppi               The notify PPI.
81 
82   @retval EFI_SUCCESS       if it completed successfully.
83 **/
84 EFI_STATUS
85 EFIAPI
86 FvFileLoaderPpiNotifyCallback (
87   IN EFI_PEI_SERVICES           **PeiServices,
88   IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,
89   IN VOID                       *Ppi
90   );
91 
92 /**
93   This function provides a blocking stall for reset at least the given number of microseconds
94   stipulated in the final argument.
95 
96   @param  PeiServices    General purpose services available to every PEIM.
97   @param  this Pointer   to the local data for the interface.
98   @param  Microseconds   number of microseconds for which to stall.
99 
100   @retval EFI_SUCCESS    the function provided at least the required stall.
101 **/
102 EFI_STATUS
103 EFIAPI
104 Stall (
105   IN CONST EFI_PEI_SERVICES   **PeiServices,
106   IN CONST EFI_PEI_STALL_PPI  *This,
107   IN UINTN                    Microseconds
108   );
109 
110 /**
111   This function initialize recovery functionality by installing the recovery PPI.
112 
113   @param  PeiServices  General purpose services available to every PEIM.
114 
115   @retval EFI_SUCCESS  If the interface could be successfully installed.
116 **/
117 EFI_STATUS
118 EFIAPI
119 InitializeRecovery (
120   IN EFI_PEI_SERVICES     **PeiServices
121   );
122 
123 /**
124   This function
125     1. Calling MRC to initialize memory.
126     2. Install EFI Memory.
127     3. Capsule coalesce if capsule boot mode.
128     4. Create HOB of system memory.
129 
130   @param  PeiServices Pointer to the PEI Service Table
131 
132   @retval EFI_SUCCESS If it completes successfully.
133 
134 **/
135 EFI_STATUS
136 MemoryInit (
137   IN EFI_PEI_SERVICES          **PeiServices
138   );
139 
140 /**
141   This function provides the implementation of AtaController PPI Enable Channel function.
142 
143   @param  PeiServices General purpose services available to every PEIM.
144   @param  this Pointer to the local data for the interface.
145   @param  ChannelMask This parameter is used to specify primary or slavery IDE channel.
146 
147   @retval EFI_SUCCESS  Procedure returned successfully.
148 **/
149 EFI_STATUS
150 EnableAtaChannel (
151   IN EFI_PEI_SERVICES               **PeiServices,
152   IN PEI_ATA_CONTROLLER_PPI         *This,
153   IN UINT8                          ChannelMask
154   );
155 
156 /**
157   This function provides the implementation of AtaController PPI Get IDE channel Register Base Address
158 
159   @param  PeiServices      General purpose services available to every PEIM.
160   @param  this             Pointer to the local data for the interface.
161   @param  IdeRegsBaseAddr  Pointer to IDE_REGS_BASE_ADDR struct, which is used to record
162                            IDE Command and Control regeisters Base Address.
163 
164   @retval EFI_SUCCESS  Procedure returned successfully.
165 **/
166 EFI_STATUS
167 GetIdeRegsBaseAddr (
168   IN EFI_PEI_SERVICES               **PeiServices,
169   IN PEI_ATA_CONTROLLER_PPI         *This,
170   IN IDE_REGS_BASE_ADDR             *IdeRegsBaseAddr
171   );
172 
173 /**
174   This function provides the implementation to properly setup both LM & PDM functionality.
175 
176   @param  PeiServices      General purpose services available to every PEIM.
177 
178   @retval EFI_SUCCESS  Procedure returned successfully.
179 
180 **/
181 EFI_STATUS
182 ConfigureLM(
183   IN EFI_PEI_SERVICES **PeiServices
184   );
185 
186 #include <Ppi/VlvMmioPolicy.h>
187 
188 BOOLEAN
189 EFIAPI
190 IsFastBootEnabled (
191   IN CONST EFI_PEI_SERVICES **PeiServices
192   );
193 
194 EFI_STATUS
195 PrioritizeBootMode (
196   IN OUT EFI_BOOT_MODE    *CurrentBootMode,
197   IN EFI_BOOT_MODE        NewBootMode
198   );
199 
200 EFI_STATUS
201 EFIAPI
202 CapsulePpiNotifyCallback (
203   IN EFI_PEI_SERVICES           **PeiServices,
204   IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,
205   IN VOID                       *Ppi
206   );
207 #endif
208