Home | History | Annotate | Download | only in Protocol
      1 /** @file
      2   SMM Periodic Timer Dispatch Protocol as defined in PI 1.1 Specification
      3   Volume 4 System Management Mode Core Interface.
      4 
      5   This protocol provides the parent dispatch service for the periodical timer SMI source generator.
      6 
      7   Copyright (c) 2009 - 2010, 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.1.
     18 
     19 **/
     20 
     21 #ifndef _SMM_PERIODIC_TIMER_DISPATCH2_H_
     22 #define _SMM_PERIODIC_TIMER_DISPATCH2_H_
     23 
     24 #include <Pi/PiSmmCis.h>
     25 
     26 #define EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL_GUID \
     27   { \
     28     0x4cec368e, 0x8e8e, 0x4d71, {0x8b, 0xe1, 0x95, 0x8c, 0x45, 0xfc, 0x8a, 0x53 } \
     29   }
     30 
     31 ///
     32 /// Example: A chipset supports periodic SMIs on every 64ms or 2 seconds.
     33 ///   A child wishes schedule a period SMI 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 ///        SmiTickInterval = 20000
     38 ///      The resulting SMI will occur every 2 seconds with the child called back on
     39 ///      every 2nd SMI.
     40 ///      NOTE: the same result would occur if the child set SmiTickInterval = 0.
     41 ///   2. The child may choose the finer granularity SMI (64ms):
     42 ///        Period = 30000
     43 ///        SmiTickInterval = 640
     44 ///      The resulting SMI will occur every 64ms with the child called back on
     45 ///      every 47th SMI.
     46 ///      NOTE: the child driver should be aware that this will result in more
     47 ///        SMIs 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 SMIs. Children of this interface should use this
     58   /// field when registering for periodic timer intervals when a finer granularity periodic
     59   /// SMI is desired.
     60   ///
     61   UINT64  SmiTickInterval;
     62 } EFI_SMM_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_SMM_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_SMM_PERIODIC_TIMER_CONTEXT;
     76 
     77 typedef struct _EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL  EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL;
     78 
     79 /**
     80   Register a child SMI source dispatch function for SMM 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_SMM_PERIODIC_TIMER_CONTEXT and CommBufferSize pointing to its size.
     88 
     89   @param[in]  This               Pointer to the EFI_SMM_PERIODIC_TIMER_DISPATCH2_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 SMI source has been enabled.
    101   @retval EFI_DEVICE_ERROR       The driver was unable to enable the SMI 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 SMM) to manage this child.
    105 **/
    106 typedef
    107 EFI_STATUS
    108 (EFIAPI *EFI_SMM_PERIODIC_TIMER_REGISTER2)(
    109   IN CONST EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL  *This,
    110   IN       EFI_SMM_HANDLER_ENTRY_POINT2               DispatchFunction,
    111   IN CONST EFI_SMM_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_SMM_PERIODIC_TIMER_DISPATCH2_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_SMM_PERIODIC_TIMER_UNREGISTER2)(
    130   IN CONST EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL  *This,
    131   IN       EFI_HANDLE                                 DispatchHandle
    132   );
    133 
    134 /**
    135   Returns the next SMI 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_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL instance.
    140   @param[in,out] SmiTickInterval  Pointer to pointer of next shorter SMI 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, *SmiTickInterval
    143                                   should be set to NULL to get the longest SMI interval.The returned
    144                                   *SmiTickInterval should be passed in on subsequent calls to get the
    145                                   next shorter interval period until *SmiTickInterval = NULL.
    146 
    147   @retval EFI_SUCCESS             The service returned successfully.
    148 **/
    149 typedef
    150 EFI_STATUS
    151 (EFIAPI *EFI_SMM_PERIODIC_TIMER_INTERVAL2)(
    152   IN CONST EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL  *This,
    153   IN OUT UINT64                                       **SmiTickInterval
    154   );
    155 
    156 ///
    157 /// Interface structure for the SMM Periodic Timer Dispatch Protocol
    158 ///
    159 /// This protocol provides the parent dispatch service for the periodical timer SMI source generator.
    160 ///
    161 struct _EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL {
    162   EFI_SMM_PERIODIC_TIMER_REGISTER2    Register;
    163   EFI_SMM_PERIODIC_TIMER_UNREGISTER2  UnRegister;
    164   EFI_SMM_PERIODIC_TIMER_INTERVAL2    GetNextShorterInterval;
    165 };
    166 
    167 extern EFI_GUID gEfiSmmPeriodicTimerDispatch2ProtocolGuid;
    168 
    169 #endif
    170 
    171