1 /** @file
2   Provides the parent dispatch service for a given Sx-state source generator.
3 
4 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 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   @par Revision Reference:
14   This Protocol is defined in Framework of EFI SMM Core Interface Spec
15   Version 0.9.
16 
17 **/
18 
19 #ifndef _EFI_SMM_SX_DISPATCH_H_
20 #define _EFI_SMM_SX_DISPATCH_H_
21 
22 //
23 // Share some common definitions with PI SMM
24 //
25 #include <Protocol/SmmSxDispatch2.h>
26 
27 //
28 // Global ID for the Sx SMI Protocol
29 //
30 #define EFI_SMM_SX_DISPATCH_PROTOCOL_GUID \
31   { \
32     0x14fc52be, 0x1dc, 0x426c, {0x91, 0xae, 0xa2, 0x3c, 0x3e, 0x22, 0xa, 0xe8 } \
33   }
34 
35 typedef struct _EFI_SMM_SX_DISPATCH_PROTOCOL  EFI_SMM_SX_DISPATCH_PROTOCOL;
36 
37 typedef struct {
38   EFI_SLEEP_TYPE  Type;
39   EFI_SLEEP_PHASE Phase;
40 } EFI_SMM_SX_DISPATCH_CONTEXT;
41 
42 //
43 // Member functions
44 //
45 /**
46   Dispatch function for a Sx state SMI handler.
47 
48   @param  DispatchHandle        The handle of this dispatch function.
49   @param  DispatchContext       The pointer to the dispatch function's context.
50                                 The Type and Phase fields are filled in by the Sx dispatch driver
51                                 prior to invoking this dispatch function. For this interface,
52                                 the Sx driver will call the dispatch function for all Sx type
53                                 and phases, so the Sx state handler(s) must check the Type and
54                                 Phase field of EFI_SMM_SX_DISPATCH_CONTEXT, and act accordingly.
55 
56   @return None
57 
58 **/
59 typedef
60 VOID
61 (EFIAPI *EFI_SMM_SX_DISPATCH)(
62   IN  EFI_HANDLE                    DispatchHandle,
63   IN  EFI_SMM_SX_DISPATCH_CONTEXT   *DispatchContext
64   );
65 
66 /**
67   Register a child SMI source dispatch function with a parent SMM driver.
68 
69   @param  This                  The pointer to the EFI_SMM_SX_DISPATCH_PROTOCOL instance.
70   @param  DispatchFunction      The function to install.
71   @param  DispatchContext       The pointer to the dispatch function's context.
72                                 The caller fills in this context before calling
73                                 the register function to indicates to the register
74                                 function which Sx state type and phase the caller
75                                 wishes to be called back on. For this interface,
76                                 the Sx driver will call the registered handlers for
77                                 all Sx type and phases, so the Sx state handler(s)
78                                 must check the Type and Phase field of the Dispatch
79                                 context, and act accordingly.
80   @param  DispatchHandle        The handle of dispatch function, for interfacing
81                                 with the parent Sx state SMM driver.
82 
83   @retval EFI_SUCCESS           The dispatch function has been successfully
84                                 registered and the SMI source has been enabled.
85   @retval EFI_UNSUPPORTED       The Sx driver or hardware does not support that
86                                 Sx Type/Phase.
87   @retval EFI_DEVICE_ERROR      The Sx driver was unable to enable the SMI source.
88   @retval EFI_OUT_OF_RESOURCES  Not enough memory (system or SMM) to manage this
89                                 child.
90   @retval EFI_INVALID_PARAMETER DispatchContext is invalid. Type & Phase are not
91                                 within a valid range.
92 
93 **/
94 typedef
95 EFI_STATUS
96 (EFIAPI *EFI_SMM_SX_REGISTER)(
97   IN EFI_SMM_SX_DISPATCH_PROTOCOL          *This,
98   IN EFI_SMM_SX_DISPATCH                   DispatchFunction,
99   IN EFI_SMM_SX_DISPATCH_CONTEXT           *DispatchContext,
100   OUT EFI_HANDLE                           *DispatchHandle
101   );
102 
103 /**
104   Unregisters an Sx-state service
105 
106   @param  This                  The pointer to the EFI_SMM_SX_DISPATCH_PROTOCOL instance.
107   @param  DispatchHandle        The handle of the service to remove.
108 
109   @retval EFI_SUCCESS           The dispatch function has been successfully unregistered, and the
110                                 SMI source has been disabled, if there are no other registered child
111                                 dispatch functions for this SMI source.
112   @retval EFI_INVALID_PARAMETER Handle is invalid.
113 
114 **/
115 typedef
116 EFI_STATUS
117 (EFIAPI *EFI_SMM_SX_UNREGISTER)(
118   IN EFI_SMM_SX_DISPATCH_PROTOCOL          *This,
119   IN EFI_HANDLE                            DispatchHandle
120   );
121 
122 //
123 // Interface structure for the SMM Child Dispatch Protocol
124 //
125 /**
126   Provides the parent dispatch service for a given Sx-state source generator.
127 **/
128 struct _EFI_SMM_SX_DISPATCH_PROTOCOL {
129   EFI_SMM_SX_REGISTER   Register;     ///< Installs a child service to be dispatched by this protocol.
130   EFI_SMM_SX_UNREGISTER UnRegister;   ///< Removes a child service dispatched by this protocol.
131 };
132 
133 extern EFI_GUID gEfiSmmSxDispatchProtocolGuid;
134 
135 #endif
136