summaryrefslogtreecommitdiff
path: root/Core/EM/SMM/SmmDispatcher.h
blob: 2b0f07cb1be35755df403a0137c8436b2ffd28f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2009, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************

//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/SMM/SMMDispatcher/SmmDispatcher.h 2     2/07/11 3:29p Markw $
//
// $Revision: 2 $
//
// $Date: 2/07/11 3:29p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/SMM/SMMDispatcher/SmmDispatcher.h $
// 
// 2     2/07/11 3:29p Markw
// [TAG]  		EIP53481
// [Category]  	New Feature
// [Description]  	Add PIWG 1.1 SMM support
// [Files]  		Smm.sdl, SmmPrivateShared.h, SmmDispatcher.mak,
// SmmDispatcher.h, SmmDispatcher.c,
// Smst.c, SmmPiSmst.c, SmmInit.c, SmmBase.c, SmmBase2.c,
// SmmDriverDispatcher.c, Smm Framewwork Protocol files, SmmPi.h,
// Smm Pi Protocol files, SmmPciRbio files
// 
//**********************************************************************

//<AMI_FHDR_START>
//---------------------------------------------------------------------------
//
// Name:		SmmDispatcher.h
//
// Description:	SmmDispatcher header file
//
//---------------------------------------------------------------------------
//<AMI_FHDR_END>

#ifndef __SMM_DISPATCHER__H__
#define __SMM_DISPATCHER__H__

#include <SmmPi.h>
#include <AmiLib.h>

//
//  CONTAINING_RECORD - returns a pointer to the structure
//      from one of it's elements.
//
#ifndef _CR
#define _CR(Record, TYPE, Field)  ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
#endif

#ifndef CR
#define CR(record, TYPE, field, signature) _CR(record, TYPE, field)
#endif

//
// Define macros to build data structure signatures from characters.
//
#define SIGNATURE_16(A, B)        ((A) | (B << 8))
#define SIGNATURE_32(A, B, C, D)  (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16))
#define SIGNATURE_64(A, B, C, D, E, F, G, H) \
   (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32))
//---- Added from Core\Tiano.h


//
// SMM_HANDLER - used for each SMM handler
//

#define SMI_ENTRY_SIGNATURE  SIGNATURE_32('s','m','i','e')

 typedef struct {
  UINTN             Signature;
  EFI_LIST_ENTRY    AllEntries;  // All entries

  EFI_GUID          HandlerType; // Type of interrupt
  EFI_LIST_ENTRY    SmiHandlers; // All handlers
} SMM_SMI_ENTRY;

#define SMI_HANDLER_SIGNATURE  SIGNATURE_32('s','m','i','h')

typedef struct {
  UINTN                         Signature;
  EFI_LIST_ENTRY                Link;        // Link on SMI_ENTRY.SmiHandlers
  EFI_SMM_HANDLER_ENTRY_POINT2  Handler;     // The smm handler's entry point
  SMM_SMI_ENTRY                 *SmiEntry;
} SMM_SMI_HANDLER;




#define SMM_EFI_HANDLE_SIGNATURE            SIGNATURE_32('S','h','n','d')
//#define ASSERT_IS_HANDLE(a)  ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)

#define SMM_PROTOCOL_ENTRY_SIGNATURE        SIGNATURE_32('S','p','r','E')

#define SMM_SMST_SIGNATURE2                 SIGNATURE_32('S','M','T','2')


#ifndef EFI_LIST_ENTRY_DEFINED
#define EFI_LIST_ENTRY_DEFINED
typedef struct _EFI_LIST_ENTRY {
    struct _EFI_LIST_ENTRY *ForwardLink;
    struct _EFI_LIST_ENTRY *BackLink;
} EFI_LIST_ENTRY;
#endif


typedef struct {
  UINTN               Signature;
  /// All handles list of IHANDLE
  EFI_LIST_ENTRY          AllHandles;
  /// List of PROTOCOL_INTERFACE's for this handle
  EFI_LIST_ENTRY          Protocols;
  UINTN               LocateRequest;
} SMM_IHANDLE;



typedef struct {
  UINTN               Signature;
  /// Link Entry inserted to mProtocolDatabase
  EFI_LIST_ENTRY          AllEntries;
  /// ID of the protocol
  EFI_GUID            ProtocolID;
  /// All protocol interfaces
  EFI_LIST_ENTRY          Protocols;
  /// Registerd notification handlers
  EFI_LIST_ENTRY          Notify;
} SMM_PROTOCOL_ENTRY;


#define SMM_PROTOCOL_INTERFACE_SIGNATURE  SIGNATURE_32('S','p','i','f')

typedef struct {
  UINTN                       Signature;
  /// Link on IHANDLE.Protocols
  EFI_LIST_ENTRY                  Link;
  /// Back pointer
  SMM_IHANDLE                     *Handle;
  /// Link on PROTOCOL_ENTRY.Protocols
  EFI_LIST_ENTRY                  ByProtocol;
  /// The protocol ID
  SMM_PROTOCOL_ENTRY              *Protocol;
  /// The interface value
  VOID                        *Interface;
} SMM_PROTOCOL_INTERFACE;

#define SMM_PROTOCOL_NOTIFY_SIGNATURE       ('S','p','r','n')

typedef struct {
  UINTN               Signature;
  SMM_PROTOCOL_ENTRY      *Protocol;
  /// All notifications for this protocol
  EFI_LIST_ENTRY          Link;
  /// Notification function
  EFI_SMM_NOTIFY_FN   Function;
  /// Last position notified
  EFI_LIST_ENTRY          *Position;
} SMM_PROTOCOL_NOTIFY;

typedef struct {
  EFI_GUID        *Protocol;
  VOID            *SearchKey;
  EFI_LIST_ENTRY  *Position;
  SMM_PROTOCOL_ENTRY  *ProtEntry;
} SMM_LOCATE_POSITION;

typedef
SMM_IHANDLE *
(* SMM_CORE_GET_NEXT) (
  IN OUT SMM_LOCATE_POSITION    *Position,
  OUT VOID                      **Interface
  );

VOID
SmmNotifyProtocol (
  IN SMM_PROTOCOL_INTERFACE   *Prot
  );

EFI_STATUS
SmmSmstInstallProtocolInterfaceNotify (       
  IN OUT EFI_HANDLE     *UserHandle,
  IN EFI_GUID           *Protocol,
  IN EFI_INTERFACE_TYPE InterfaceType,
  IN VOID               *Interface,
  IN BOOLEAN            Notify
  );

EFI_STATUS
EFIAPI
SmmSmstHandleProtocol (
  IN EFI_HANDLE       UserHandle,
  IN EFI_GUID         *Protocol,
  OUT VOID            **Interface
  );


EFI_STATUS
EFIAPI
SmmSmstLocateProtocol (
  IN  EFI_GUID  *Protocol,
  IN  VOID      *Registration OPTIONAL,
  OUT VOID      **Interface
  );

EFI_STATUS
EFIAPI
SmmUninstallProtocolInterface (
  IN EFI_HANDLE       UserHandle,
  IN EFI_GUID         *Protocol,
  IN VOID             *Interface
  );

SMM_PROTOCOL_INTERFACE *
SmmRemoveInterfaceFromProtocol (
  IN SMM_IHANDLE   *Handle,
  IN EFI_GUID  *Protocol,
  IN VOID      *Interface
  );




/****** DO NOT WRITE BELOW THIS LINE *******/
#ifdef __cplusplus
}
#endif
#endif

//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2009, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************