1/** @file
2  SMM Sx Dispatch Protocol as defined in PI 1.2 Specification
3  Volume 4 System Management Mode Core Interface.
4
5  Provides the parent dispatch service for a given Sx-state 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**/
17
18#ifndef _SMM_SX_DISPATCH2_H_
19#define _SMM_SX_DISPATCH2_H_
20
21#include <Pi/PiSmmCis.h>
22
23#define EFI_SMM_SX_DISPATCH2_PROTOCOL_GUID \
24  { \
25    0x456d2859, 0xa84b, 0x4e47, {0xa2, 0xee, 0x32, 0x76, 0xd8, 0x86, 0x99, 0x7d } \
26  }
27
28///
29/// Sleep states S0-S5
30///
31typedef enum {
32  SxS0,
33  SxS1,
34  SxS2,
35  SxS3,
36  SxS4,
37  SxS5,
38  EfiMaximumSleepType
39} EFI_SLEEP_TYPE;
40
41///
42/// Sleep state phase: entry or exit
43///
44typedef enum {
45  SxEntry,
46  SxExit,
47  EfiMaximumPhase
48} EFI_SLEEP_PHASE;
49
50///
51/// The dispatch function's context
52///
53typedef struct {
54  EFI_SLEEP_TYPE  Type;
55  EFI_SLEEP_PHASE Phase;
56} EFI_SMM_SX_REGISTER_CONTEXT;
57
58typedef struct _EFI_SMM_SX_DISPATCH2_PROTOCOL  EFI_SMM_SX_DISPATCH2_PROTOCOL;
59
60/**
61  Provides the parent dispatch service for a given Sx source generator.
62
63  This service registers a function (DispatchFunction) which will be called when the sleep state
64  event specified by RegisterContext is detected. On return, DispatchHandle contains a
65  unique handle which may be used later to unregister the function using UnRegister().
66  The DispatchFunction will be called with Context set to the same value as was passed into
67  this function in RegisterContext and with CommBuffer and CommBufferSize set to
68  NULL and 0 respectively.
69
70  @param[in] This                Pointer to the EFI_SMM_SX_DISPATCH2_PROTOCOL instance.
71  @param[in] DispatchFunction    Function to register for handler when the specified sleep state event occurs.
72  @param[in] RegisterContext     Pointer to the dispatch function's context.
73                                 The caller fills this context in before calling
74                                 the register function to indicate to the register
75                                 function which Sx state type and phase the caller
76                                 wishes to be called back on. For this intertace,
77                                 the Sx driver will call the registered handlers for
78                                 all Sx type and phases, so the Sx state handler(s)
79                                 must check the Type and Phase field of the Dispatch
80                                 context and act accordingly.
81  @param[out]  DispatchHandle    Handle of dispatch function, for when interfacing
82                                 with the parent Sx state SMM driver.
83
84  @retval EFI_SUCCESS            The dispatch function has been successfully
85                                 registered and the SMI source has been enabled.
86  @retval EFI_UNSUPPORTED        The Sx driver or hardware does not support that
87                                 Sx Type/Phase.
88  @retval EFI_DEVICE_ERROR       The Sx driver was unable to enable the SMI source.
89  @retval EFI_INVALID_PARAMETER  RegisterContext is invalid. Type & Phase are not
90                                 within valid range.
91  @retval EFI_OUT_OF_RESOURCES   There is not enough memory (system or SMM) to manage this
92                                 child.
93**/
94typedef
95EFI_STATUS
96(EFIAPI *EFI_SMM_SX_REGISTER2)(
97  IN  CONST EFI_SMM_SX_DISPATCH2_PROTOCOL  *This,
98  IN        EFI_SMM_HANDLER_ENTRY_POINT2   DispatchFunction,
99  IN  CONST EFI_SMM_SX_REGISTER_CONTEXT    *RegisterContext,
100  OUT       EFI_HANDLE                     *DispatchHandle
101  );
102
103/**
104  Unregisters an Sx-state service.
105
106  This service removes the handler associated with DispatchHandle so that it will no longer be
107  called in response to sleep event.
108
109  @param[in] This                Pointer to the EFI_SMM_SX_DISPATCH2_PROTOCOL instance.
110  @param[in] DispatchHandle      Handle of the service to remove.
111
112  @retval EFI_SUCCESS            The service has been successfully removed.
113  @retval EFI_INVALID_PARAMETER  The DispatchHandle was not valid.
114**/
115typedef
116EFI_STATUS
117(EFIAPI *EFI_SMM_SX_UNREGISTER2)(
118  IN CONST EFI_SMM_SX_DISPATCH2_PROTOCOL  *This,
119  IN       EFI_HANDLE                     DispatchHandle
120  );
121
122///
123/// Interface structure for the SMM Sx Dispatch Protocol
124///
125/// The EFI_SMM_SX_DISPATCH2_PROTOCOL provides the ability to install child handlers to
126/// respond to sleep state related events.
127///
128struct _EFI_SMM_SX_DISPATCH2_PROTOCOL {
129  EFI_SMM_SX_REGISTER2    Register;
130  EFI_SMM_SX_UNREGISTER2  UnRegister;
131};
132
133extern EFI_GUID gEfiSmmSxDispatch2ProtocolGuid;
134
135#endif
136