]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/SmmPeriodicSmiLib.h
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Include / Library / SmmPeriodicSmiLib.h
CommitLineData
40039e28 1/** @file\r
2 Provides services to enable and disable periodic SMI handlers.\r
3\r
9095d37b 4Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
40039e28 5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __PERIODIC_SMI_LIB_H__\r
16#define __PERIODIC_SMI_LIB_H__\r
17\r
18#define PERIODIC_SMI_LIBRARY_ANY_CPU 0xffffffff\r
19\r
20/**\r
21 This function returns a pointer to a table of supported periodic\r
9095d37b
LG
22 SMI tick periods in 100 ns units sorted from largest to smallest.\r
23 The table contains a array of UINT64 values terminated by a tick\r
40039e28 24 period value of 0. The returned table must be treated as read-only\r
25 data and must not be freed.\r
9095d37b
LG
26\r
27 @return A pointer to a table of UINT64 tick period values in\r
28 100ns units sorted from largest to smallest terminated\r
40039e28 29 by a tick period of 0.\r
9095d37b 30\r
40039e28 31**/\r
32UINT64 *\r
33EFIAPI\r
34PeriodicSmiSupportedTickPeriod (\r
35 VOID\r
36 );\r
37\r
38/**\r
39 This function returns the time in 100ns units since the periodic SMI\r
40 handler function was called. If the periodic SMI handler was resumed\r
41 through PeriodicSmiYield(), then the time returned is the time in\r
42 100ns units since PeriodicSmiYield() returned.\r
43\r
44 @return The actual time in 100ns units that the periodic SMI handler\r
45 has been executing. If this function is not called from within\r
46 an enabled periodic SMI handler, then 0 is returned.\r
47\r
48**/\r
49UINT64\r
50EFIAPI\r
51PeriodicSmiExecutionTime (\r
52 VOID\r
53 );\r
54\r
55/**\r
9095d37b 56 This function returns control back to the SMM Foundation. When the next\r
40039e28 57 periodic SMI for the currently executing handler is triggered, the periodic\r
58 SMI handler will restarted from its registered DispatchFunction entry point.\r
9095d37b 59 If this function is not called from within an enabled periodic SMI handler,\r
40039e28 60 then control is returned to the calling function.\r
61\r
62**/\r
63VOID\r
9095d37b 64EFIAPI\r
40039e28 65PeriodicSmiExit (\r
66 VOID\r
67 );\r
68\r
69/**\r
9095d37b 70 This function yields control back to the SMM Foundation. When the next\r
40039e28 71 periodic SMI for the currently executing handler is triggered, the periodic\r
9095d37b 72 SMI handler will be resumed and this function will return. Use of this\r
40039e28 73 function requires a seperate stack for the periodic SMI handler. A non zero\r
9095d37b
LG
74 stack size must be specified in PeriodicSmiEnable() for this function to be\r
75 used.\r
76\r
40039e28 77 If the stack size passed into PeriodicSmiEnable() was zero, the 0 is returned.\r
9095d37b
LG
78\r
79 If this function is not called from within an enabled periodic SMI handler,\r
40039e28 80 then 0 is returned.\r
81\r
a750b4ae 82 @return The actual time in 100ns units elapsed since this function was\r
40039e28 83 called. A value of 0 indicates an unknown amount of time.\r
84\r
85**/\r
86UINT64\r
9095d37b 87EFIAPI\r
40039e28 88PeriodicSmiYield (\r
89 VOID\r
90 );\r
91\r
92/**\r
9095d37b 93 This function is a prototype for a periodic SMI handler function\r
40039e28 94 that may be enabled with PeriodicSmiEnable() and disabled with\r
95 PeriodicSmiDisable().\r
96\r
97 @param[in] Context Content registered with PeriodicSmiEnable().\r
a750b4ae 98 @param[in] ElapsedTime The actual time in 100ns units elapsed since\r
9095d37b 99 this function was called. A value of 0 indicates\r
40039e28 100 an unknown amount of time.\r
9095d37b 101\r
40039e28 102**/\r
103typedef\r
104VOID\r
105(EFIAPI *PERIODIC_SMI_LIBRARY_HANDLER) (\r
106 IN CONST VOID *Context OPTIONAL,\r
107 IN UINT64 ElapsedTime\r
108 );\r
9095d37b 109\r
40039e28 110/**\r
111 This function enables a periodic SMI handler.\r
9095d37b
LG
112\r
113 @param[in, out] DispatchHandle A pointer to the handle associated with the\r
114 enabled periodic SMI handler. This is an\r
115 optional parameter that may be NULL. If it is\r
116 NULL, then the handle will not be returned,\r
117 which means that the periodic SMI handler can\r
40039e28 118 never be disabled.\r
119 @param[in] DispatchFunction A pointer to a periodic SMI handler function.\r
120 @param[in] Context Optional content to pass into DispatchFunction.\r
9095d37b 121 @param[in] TickPeriod The requested tick period in 100ns units that\r
40039e28 122 control should be givien to the periodic SMI\r
123 handler. Must be one of the supported values\r
124 returned by PeriodicSmiSupportedPickPeriod().\r
125 @param[in] Cpu Specifies the CPU that is required to execute\r
9095d37b
LG
126 the periodic SMI handler. If Cpu is\r
127 PERIODIC_SMI_LIBRARY_ANY_CPU, then the periodic\r
128 SMI handler will always be executed on the SMST\r
129 CurrentlyExecutingCpu, which may vary across\r
130 periodic SMIs. If Cpu is between 0 and the SMST\r
40039e28 131 NumberOfCpus, then the periodic SMI will always\r
132 be executed on the requested CPU.\r
133 @param[in] StackSize The size, in bytes, of the stack to allocate for\r
134 use by the periodic SMI handler. If 0, then the\r
135 default stack will be used.\r
9095d37b 136\r
40039e28 137 @retval EFI_INVALID_PARAMETER DispatchFunction is NULL.\r
9095d37b
LG
138 @retval EFI_UNSUPPORTED TickPeriod is not a supported tick period. The\r
139 supported tick periods can be retrieved using\r
40039e28 140 PeriodicSmiSupportedTickPeriod().\r
9095d37b 141 @retval EFI_INVALID_PARAMETER Cpu is not PERIODIC_SMI_LIBRARY_ANY_CPU or in\r
40039e28 142 the range 0 to SMST NumberOfCpus.\r
9095d37b 143 @retval EFI_OUT_OF_RESOURCES There are not enough resources to enable the\r
40039e28 144 periodic SMI handler.\r
9095d37b 145 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the\r
40039e28 146 stack speficied by StackSize.\r
147 @retval EFI_SUCCESS The periodic SMI handler was enabled.\r
9095d37b 148\r
40039e28 149**/\r
9095d37b 150EFI_STATUS\r
40039e28 151EFIAPI\r
152PeriodicSmiEnable (\r
153 IN OUT EFI_HANDLE *DispatchHandle, OPTIONAL\r
154 IN PERIODIC_SMI_LIBRARY_HANDLER DispatchFunction,\r
155 IN CONST VOID *Context, OPTIONAL\r
156 IN UINT64 TickPeriod,\r
157 IN UINTN Cpu,\r
158 IN UINTN StackSize\r
159 );\r
160\r
161/**\r
162 This function disables a periodic SMI handler that has been previously\r
163 enabled with PeriodicSmiEnable().\r
9095d37b
LG
164\r
165 @param[in] DispatchHandle A handle associated with a previously enabled periodic\r
40039e28 166 SMI handler. This is an optional parameter that may\r
167 be NULL. If it is NULL, then the active periodic SMI\r
168 handlers is disabled.\r
169\r
170 @retval FALSE DispatchHandle is NULL and there is no active periodic SMI handler.\r
9095d37b 171 @retval FALSE The periodic SMI handler specified by DispatchHandle has\r
40039e28 172 not been enabled with PeriodicSmiEnable().\r
9095d37b 173 @retval TRUE The periodic SMI handler specified by DispatchHandle has\r
40039e28 174 been disabled. If DispatchHandle is NULL, then the active\r
175 periodic SMI handler has been disabled.\r
9095d37b 176\r
40039e28 177**/\r
9095d37b 178BOOLEAN\r
40039e28 179EFIAPI\r
180PeriodicSmiDisable (\r
181 IN EFI_HANDLE DispatchHandle OPTIONAL\r
182 );\r
9095d37b 183\r
40039e28 184#endif\r