]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/MmPeriodicTimerDispatch.h
MdePkg: Add new definitions for Management Mode.
[mirror_edk2.git] / MdePkg / Include / Protocol / MmPeriodicTimerDispatch.h
1 /** @file
2 MM Periodic Timer Dispatch Protocol as defined in PI 1.5 Specification
3 Volume 4 Management Mode Core Interface.
4
5 This protocol provides the parent dispatch service for the periodical timer MMI source generator.
6
7 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 @par Revision Reference:
17 This protocol is from PI Version 1.5.
18
19 **/
20
21 #ifndef _MM_PERIODIC_TIMER_DISPATCH_H_
22 #define _MM_PERIODIC_TIMER_DISPATCH_H_
23
24 #include <Pi/PiMmCis.h>
25
26 #define EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL_GUID \
27 { \
28 0x4cec368e, 0x8e8e, 0x4d71, {0x8b, 0xe1, 0x95, 0x8c, 0x45, 0xfc, 0x8a, 0x53 } \
29 }
30
31 ///
32 /// Example: A chipset supports periodic MMIs on every 64ms or 2 seconds.
33 /// A child wishes schedule a period MMI to fire on a period of 3 seconds, there
34 /// are several ways to approach the problem:
35 /// 1. The child may accept a 4 second periodic rate, in which case it registers with
36 /// Period = 40000
37 /// MmiTickInterval = 20000
38 /// The resulting MMI will occur every 2 seconds with the child called back on
39 /// every 2nd MMI.
40 /// NOTE: the same result would occur if the child set MmiTickInterval = 0.
41 /// 2. The child may choose the finer granularity MMI (64ms):
42 /// Period = 30000
43 /// MmiTickInterval = 640
44 /// The resulting MMI will occur every 64ms with the child called back on
45 /// every 47th MMI.
46 /// NOTE: the child driver should be aware that this will result in more
47 /// MMIs occuring during system runtime which can negatively impact system
48 /// performance.
49 ///
50 typedef struct {
51 ///
52 /// The minimum period of time in 100 nanosecond units that the child gets called. The
53 /// child will be called back after a time greater than the time Period.
54 ///
55 UINT64 Period;
56 ///
57 /// The period of time interval between MMIs. Children of this interface should use this
58 /// field when registering for periodic timer intervals when a finer granularity periodic
59 /// MMI is desired.
60 ///
61 UINT64 MmiTickInterval;
62 } EFI_MM_PERIODIC_TIMER_REGISTER_CONTEXT;
63
64 ///
65 /// The DispatchFunction will be called with Context set to the same value as was passed into
66 /// Register() in RegisterContext and with CommBuffer pointing to an instance of
67 /// EFI_MM_PERIODIC_TIMER_CONTEXT and CommBufferSize pointing to its size.
68 ///
69 typedef struct {
70 ///
71 /// ElapsedTime is the actual time in 100 nanosecond units elapsed since last called, a
72 /// value of 0 indicates an unknown amount of time.
73 ///
74 UINT64 ElapsedTime;
75 } EFI_MM_PERIODIC_TIMER_CONTEXT;
76
77 typedef struct _EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL;
78
79 /**
80 Register a child MMI source dispatch function for MM periodic timer.
81
82 This service registers a function (DispatchFunction) which will be called when at least the
83 amount of time specified by RegisterContext has elapsed. On return, DispatchHandle
84 contains a unique handle which may be used later to unregister the function using UnRegister().
85 The DispatchFunction will be called with Context set to the same value as was passed into
86 this function in RegisterContext and with CommBuffer pointing to an instance of
87 EFI_MM_PERIODIC_TIMER_CONTEXT and CommBufferSize pointing to its size.
88
89 @param[in] This Pointer to the EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL instance.
90 @param[in] DispatchFunction Function to register for handler when at least the specified amount
91 of time has elapsed.
92 @param[in] RegisterContext Pointer to the dispatch function's context.
93 The caller fills this context in before calling
94 the register function to indicate to the register
95 function the period at which the dispatch function
96 should be invoked.
97 @param[out] DispatchHandle Handle generated by the dispatcher to track the function instance.
98
99 @retval EFI_SUCCESS The dispatch function has been successfully
100 registered and the MMI source has been enabled.
101 @retval EFI_DEVICE_ERROR The driver was unable to enable the MMI source.
102 @retval EFI_INVALID_PARAMETER RegisterContext is invalid. The period input value
103 is not within valid range.
104 @retval EFI_OUT_OF_RESOURCES There is not enough memory (system or MM) to manage this child.
105 **/
106 typedef
107 EFI_STATUS
108 (EFIAPI *EFI_MM_PERIODIC_TIMER_REGISTER)(
109 IN CONST EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
110 IN EFI_MM_HANDLER_ENTRY_POINT DispatchFunction,
111 IN CONST EFI_MM_PERIODIC_TIMER_REGISTER_CONTEXT *RegisterContext,
112 OUT EFI_HANDLE *DispatchHandle
113 );
114
115 /**
116 Unregisters a periodic timer service.
117
118 This service removes the handler associated with DispatchHandle so that it will no longer be
119 called when the time has elapsed.
120
121 @param[in] This Pointer to the EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL instance.
122 @param[in] DispatchHandle Handle of the service to remove.
123
124 @retval EFI_SUCCESS The service has been successfully removed.
125 @retval EFI_INVALID_PARAMETER The DispatchHandle was not valid.
126 **/
127 typedef
128 EFI_STATUS
129 (EFIAPI *EFI_MM_PERIODIC_TIMER_UNREGISTER)(
130 IN CONST EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
131 IN EFI_HANDLE DispatchHandle
132 );
133
134 /**
135 Returns the next MMI tick period supported by the chipset.
136
137 The order returned is from longest to shortest interval period.
138
139 @param[in] This Pointer to the EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL instance.
140 @param[in,out] MmiTickInterval Pointer to pointer of next shorter MMI interval
141 period supported by the child. This parameter works as a get-first,
142 get-next field.The first time this function is called, *MmiTickInterval
143 should be set to NULL to get the longest MMI interval.The returned
144 *MmiTickInterval should be passed in on subsequent calls to get the
145 next shorter interval period until *MmiTickInterval = NULL.
146
147 @retval EFI_SUCCESS The service returned successfully.
148 **/
149 typedef
150 EFI_STATUS
151 (EFIAPI *EFI_MM_PERIODIC_TIMER_INTERVAL)(
152 IN CONST EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
153 IN OUT UINT64 **MmiTickInterval
154 );
155
156 ///
157 /// Interface structure for the MM Periodic Timer Dispatch Protocol
158 ///
159 /// This protocol provides the parent dispatch service for the periodical timer MMI source generator.
160 ///
161 struct _EFI_MM_PERIODIC_TIMER_DISPATCH_PROTOCOL {
162 EFI_MM_PERIODIC_TIMER_REGISTER Register;
163 EFI_MM_PERIODIC_TIMER_UNREGISTER UnRegister;
164 EFI_MM_PERIODIC_TIMER_INTERVAL GetNextShorterInterval;
165 };
166
167 extern EFI_GUID gEfiMmPeriodicTimerDispatchProtocolGuid;
168
169 #endif
170