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