• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2 Include file for SMM CPU Services protocol implementation.
3 
4 Copyright (c) 2011 - 2015, 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 #ifndef _CPU_SERVICE_H_
16 #define _CPU_SERVICE_H_
17 
18 typedef enum {
19   SmmCpuNone,
20   SmmCpuAdd,
21   SmmCpuRemove,
22   SmmCpuSwitchBsp
23 } SMM_CPU_OPERATION;
24 
25 //
26 // SMM CPU Service Protocol function prototypes.
27 //
28 
29 /**
30   Gets processor information on the requested processor at the instant this call is made.
31 
32   @param[in]  This                 A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.
33   @param[in]  ProcessorNumber      The handle number of processor.
34   @param[out] ProcessorInfoBuffer  A pointer to the buffer where information for
35                                    the requested processor is deposited.
36 
37   @retval EFI_SUCCESS             Processor information was returned.
38   @retval EFI_INVALID_PARAMETER   ProcessorInfoBuffer is NULL.
39   @retval EFI_INVALID_PARAMETER   ProcessorNumber is invalid.
40   @retval EFI_NOT_FOUND           The processor with the handle specified by
41                                   ProcessorNumber does not exist in the platform.
42 
43 **/
44 EFI_STATUS
45 EFIAPI
46 SmmGetProcessorInfo (
47   IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
48   IN       UINTN                        ProcessorNumber,
49   OUT      EFI_PROCESSOR_INFORMATION    *ProcessorInfoBuffer
50   );
51 
52 /**
53   This service switches the requested AP to be the BSP since the next SMI.
54 
55   @param[in] This             A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.
56   @param[in] ProcessorNumber  The handle number of AP that is to become the new BSP.
57 
58   @retval EFI_SUCCESS             BSP will be switched in next SMI.
59   @retval EFI_UNSUPPORTED         Switching the BSP or a processor to be hot-removed is not supported.
60   @retval EFI_NOT_FOUND           The processor with the handle specified by ProcessorNumber does not exist.
61   @retval EFI_INVALID_PARAMETER   ProcessorNumber is invalid.
62 **/
63 EFI_STATUS
64 EFIAPI
65 SmmSwitchBsp (
66   IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
67   IN       UINTN                        ProcessorNumber
68   );
69 
70 /**
71   Notify that a processor was hot-added.
72 
73   @param[in] This                A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.
74   @param[in] ProcessorId         Local APIC ID of the hot-added processor.
75   @param[out] ProcessorNumber    The handle number of the hot-added processor.
76 
77   @retval EFI_SUCCESS            The hot-addition of the specified processors was successfully notified.
78   @retval EFI_UNSUPPORTED        Hot addition of processor is not supported.
79   @retval EFI_NOT_FOUND          The processor with the handle specified by ProcessorNumber does not exist.
80   @retval EFI_INVALID_PARAMETER  ProcessorNumber is invalid.
81   @retval EFI_ALREADY_STARTED    The processor is already online in the system.
82 **/
83 EFI_STATUS
84 EFIAPI
85 SmmAddProcessor (
86   IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL  *This,
87   IN       UINT64                        ProcessorId,
88   OUT      UINTN                         *ProcessorNumber
89   );
90 
91 /**
92   Notify that a processor was hot-removed.
93 
94   @param[in] This                A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.
95   @param[in] ProcessorNumber     The handle number of the hot-added processor.
96 
97   @retval EFI_SUCCESS            The hot-removal of the specified processors was successfully notified.
98   @retval EFI_UNSUPPORTED        Hot removal of processor is not supported.
99   @retval EFI_UNSUPPORTED        Hot removal of BSP is not supported.
100   @retval EFI_UNSUPPORTED        Hot removal of a processor with pending hot-plug operation is not supported.
101   @retval EFI_INVALID_PARAMETER  ProcessorNumber is invalid.
102 **/
103 EFI_STATUS
104 EFIAPI
105 SmmRemoveProcessor (
106   IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL  *This,
107   IN       UINTN                         ProcessorNumber
108   );
109 
110 /**
111   This return the handle number for the calling processor.
112 
113   @param[in] This                 A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.
114   @param[out] ProcessorNumber      The handle number of currently executing processor.
115 
116   @retval EFI_SUCCESS             The current processor handle number was returned
117                                   in ProcessorNumber.
118   @retval EFI_INVALID_PARAMETER   ProcessorNumber is NULL.
119 
120 **/
121 EFI_STATUS
122 EFIAPI
123 SmmWhoAmI (
124   IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
125   OUT      UINTN                        *ProcessorNumber
126   );
127 
128 /**
129   Register exception handler.
130 
131   @param  This                  A pointer to the SMM_CPU_SERVICE_PROTOCOL instance.
132   @param  ExceptionType         Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and
133                                 the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL
134                                 of the UEFI 2.0 specification.
135   @param  InterruptHandler      A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER
136                                 that is called when a processor interrupt occurs.
137                                 If this parameter is NULL, then the handler will be uninstalled.
138 
139   @retval EFI_SUCCESS           The handler for the processor interrupt was successfully installed or uninstalled.
140   @retval EFI_ALREADY_STARTED   InterruptHandler is not NULL, and a handler for InterruptType was previously installed.
141   @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed.
142   @retval EFI_UNSUPPORTED       The interrupt specified by InterruptType is not supported.
143 
144 **/
145 EFI_STATUS
146 EFIAPI
147 SmmRegisterExceptionHandler (
148   IN EFI_SMM_CPU_SERVICE_PROTOCOL  *This,
149   IN EFI_EXCEPTION_TYPE            ExceptionType,
150   IN EFI_CPU_INTERRUPT_HANDLER     InterruptHandler
151   );
152 
153 //
154 // Internal function prototypes
155 //
156 
157 /**
158   Update the SMM CPU list per the pending operation.
159 
160   This function is called after return from SMI handlers.
161 **/
162 VOID
163 SmmCpuUpdate (
164   VOID
165   );
166 
167 /**
168   Initialize SMM CPU Services.
169 
170   It installs EFI SMM CPU Services Protocol.
171 
172   @param ImageHandle The firmware allocated handle for the EFI image.
173 
174   @retval EFI_SUCCESS    EFI SMM CPU Services Protocol was installed successfully.
175 **/
176 EFI_STATUS
177 InitializeSmmCpuServices (
178   IN EFI_HANDLE  Handle
179   );
180 
181 #endif
182