automagically convert ELF to PE/COFF (i386 only)
[mirror_edk2.git] / MdePkg / Include / Dxe / SmmCis.h
CommitLineData
878ddf1f 1/** @file\r
2 Include file matches things in the Smm CIS spec.\r
3\r
4 Copyright (c) 2006, Intel Corporation \r
5 All rights reserved. This program and the accompanying materials \r
6 are licensed and made available under the terms and conditions of the BSD License \r
7 which accompanies this distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13 Module Name: SmmCis.h\r
14\r
15 @par Revision Reference:\r
16 Version 0.9.\r
17\r
18**/\r
19\r
20#ifndef __SMM_CIS__\r
21#define __SMM_CIS__\r
22\r
23#define EFI_SMM_CPU_IO_GUID \\r
24 { \\r
25 0x5f439a0b, 0x45d8, 0x4682, {0xa4, 0xf4, 0xf0, 0x57, 0x6b, 0x51, 0x34, 0x41 } \\r
26 }\r
27\r
28typedef struct _EFI_SMM_SYSTEM_TABLE EFI_SMM_SYSTEM_TABLE;\r
29typedef struct _EFI_SMM_CPU_IO_INTERFACE EFI_SMM_CPU_IO_INTERFACE;\r
30\r
31\r
32//\r
33// SMM Base specification constant and types\r
34//\r
35#define SMM_SMST_SIGNATURE EFI_SIGNATURE_32 ('S', 'M', 'S', 'T')\r
36#define EFI_SMM_SYSTEM_TABLE_REVISION (0 << 16) | (0x09)\r
37\r
38//\r
39// *******************************************************\r
40// EFI_SMM_IO_WIDTH\r
41// *******************************************************\r
42//\r
43typedef enum {\r
44 SMM_IO_UINT8 = 0,\r
45 SMM_IO_UINT16 = 1,\r
46 SMM_IO_UINT32 = 2,\r
47 SMM_IO_UINT64 = 3\r
48} EFI_SMM_IO_WIDTH;\r
49\r
50/**\r
51 Provides the basic memory and I/O interfaces that are used to \r
52 abstract accesses to devices.\r
53\r
0647c9ad
LG
54 @param This The EFI_SMM_CPU_IO_INTERFACE instance.\r
55 @param Width Signifies the width of the I/O operations.\r
56 @param Address The base address of the I/O operations.\r
57 @param Count The number of I/O operations to perform.\r
58 @param Buffer For read operations, the destination buffer to store the results.\r
59 For write operations, the source buffer from which to write data.\r
60\r
61 @retval EFI_SUCCESS The data was read from or written to the device.\r
62 @retval EFI_UNSUPPORTED The Address is not valid for this system.\r
878ddf1f 63 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.\r
0647c9ad 64 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
878ddf1f 65\r
66**/\r
67typedef\r
68EFI_STATUS\r
69(EFIAPI *EFI_SMM_CPU_IO) (\r
70 IN EFI_SMM_CPU_IO_INTERFACE *This,\r
71 IN EFI_SMM_IO_WIDTH Width,\r
72 IN UINT64 Address,\r
73 IN UINTN Count,\r
74 IN OUT VOID *Buffer\r
75 );\r
76\r
77typedef struct {\r
78 EFI_SMM_CPU_IO Read;\r
79 EFI_SMM_CPU_IO Write;\r
80} EFI_SMM_IO_ACCESS;\r
81\r
82struct _EFI_SMM_CPU_IO_INTERFACE {\r
83 EFI_SMM_IO_ACCESS Mem;\r
84 EFI_SMM_IO_ACCESS Io;\r
85};\r
86\r
87/**\r
88 Allocates pool memory from SMRAM for IA-32 or runtime memory for \r
89 the Itanium processor family.\r
90\r
0647c9ad
LG
91 @param PoolType The type of pool to allocate.The only supported type is EfiRuntimeServicesData\r
92 @param Size The number of bytes to allocate from the pool.\r
93 @param Buffer A pointer to a pointer to the allocated buffer if the call\r
94 succeeds; undefined otherwise.\r
878ddf1f 95\r
0647c9ad 96 @retval EFI_SUCCESS The requested number of bytes was allocated.\r
878ddf1f 97 @retval EFI_OUT_OF_RESOURCES The pool requested could not be allocated.\r
0647c9ad 98 @retval EFI_UNSUPPORTED In runtime.\r
878ddf1f 99\r
100**/\r
101typedef\r
102EFI_STATUS\r
103(EFIAPI *EFI_SMMCORE_ALLOCATE_POOL) (\r
104 IN EFI_MEMORY_TYPE PoolType,\r
105 IN UINTN Size,\r
106 OUT VOID **Buffer\r
107 );\r
108\r
109/**\r
110 Returns pool memory to the system.\r
111\r
0647c9ad 112 @param Buffer Pointer to the buffer to free.\r
878ddf1f 113\r
0647c9ad
LG
114 @retval EFI_SUCCESS The memory was returned to the system.\r
115 @retval EFI_INVALID_PARAMETER Buffer was invalid.\r
116 @retval EFI_UNSUPPORTED In runtime.\r
878ddf1f 117\r
118**/\r
119typedef\r
120EFI_STATUS\r
121(EFIAPI *EFI_SMMCORE_FREE_POOL) (\r
122 IN VOID *Buffer\r
123 );\r
124\r
125/**\r
126 Allocates memory pages from the system.\r
127\r
0647c9ad
LG
128 @param Type The type of allocation to perform.\r
129 @param MemoryType The only supported type is EfiRuntimeServicesData\r
130 @param NumberofPages The number of contiguous 4 KB pages to allocate\r
131 @param Memory Pointer to a physical address. On input, the way in which\r
132 the address is used depends on the value of Type. On output, the address\r
133 is set to the base of the page range that was allocated.\r
134\r
135 @retval EFI_SUCCESS The requested pages were allocated.\r
878ddf1f 136 @retval EFI_OUT_OF_RESOURCES The pages requested could not be allocated.\r
0647c9ad
LG
137 @retval EFI_NOT_FOUND The requested pages could not be found.\r
138 @retval EFI_INVALID_PARAMETER Type is not AllocateAnyPages or AllocateMaxAddress\r
139 or AllocateAddress. Or MemoryType is in the range EfiMaxMemoryType..0x7FFFFFFF.\r
878ddf1f 140\r
141**/\r
142typedef\r
143EFI_STATUS\r
144(EFIAPI *EFI_SMMCORE_ALLOCATE_PAGES) (\r
145 IN EFI_ALLOCATE_TYPE Type,\r
146 IN EFI_MEMORY_TYPE MemoryType,\r
147 IN UINTN NumberOfPages,\r
148 OUT EFI_PHYSICAL_ADDRESS *Memory\r
149 );\r
150\r
151/**\r
152 Frees memory pages for the system.\r
153\r
0647c9ad
LG
154 @param Memory The base physical address of the pages to be freed\r
155 @param NumberOfPages The number of contiguous 4 KB pages to free.\r
878ddf1f 156\r
0647c9ad
LG
157 @retval EFI_SUCCESS The requested memory pages were freed.\r
158 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or NumberOfPages is invalid.\r
159 @retval EFI_NOT_FOUND The requested memory pages were not allocated with SmmAllocatePages().\r
878ddf1f 160\r
161**/\r
162typedef\r
163EFI_STATUS\r
164(EFIAPI *EFI_SMMCORE_FREE_PAGES) (\r
165 IN EFI_PHYSICAL_ADDRESS Memory,\r
166 IN UINTN NumberOfPages\r
167 );\r
168\r
878ddf1f 169typedef\r
170EFI_STATUS\r
171(EFIAPI *EFI_SMM_STARTUP_THIS_AP) (\r
172 IN EFI_AP_PROCEDURE Procedure,\r
173 IN UINTN CpuNumber,\r
174 IN OUT VOID *ProcArguments OPTIONAL\r
175 );\r
176\r
177typedef struct {\r
178 UINT8 Reserved1[248];\r
179 UINT32 SMBASE;\r
180 UINT32 SMMRevId;\r
181 UINT16 IORestart;\r
182 UINT16 AutoHALTRestart;\r
183 UINT8 Reserved2[164];\r
184 UINT32 ES;\r
185 UINT32 CS;\r
186 UINT32 SS;\r
187 UINT32 DS;\r
188 UINT32 FS;\r
189 UINT32 GS;\r
190 UINT32 LDTBase;\r
191 UINT32 TR;\r
192 UINT32 DR7;\r
193 UINT32 DR6;\r
194 UINT32 EAX;\r
195 UINT32 ECX;\r
196 UINT32 EDX;\r
197 UINT32 EBX;\r
198 UINT32 ESP;\r
199 UINT32 EBP;\r
200 UINT32 ESI;\r
201 UINT32 EDI;\r
202 UINT32 EIP;\r
203 UINT32 EFLAGS;\r
204 UINT32 CR3;\r
205 UINT32 CR0;\r
206} EFI_SMI_CPU_SAVE_STATE;\r
207\r
208typedef struct {\r
209 UINT64 reserved; \r
210 UINT64 r1;\r
211 UINT64 r2;\r
212 UINT64 r3;\r
213 UINT64 r4;\r
214 UINT64 r5;\r
215 UINT64 r6;\r
216 UINT64 r7;\r
217 UINT64 r8;\r
218 UINT64 r9;\r
219 UINT64 r10;\r
220 UINT64 r11;\r
221 UINT64 r12;\r
222 UINT64 r13;\r
223 UINT64 r14;\r
224 UINT64 r15;\r
225 UINT64 r16;\r
226 UINT64 r17;\r
227 UINT64 r18;\r
228 UINT64 r19;\r
229 UINT64 r20;\r
230 UINT64 r21;\r
231 UINT64 r22;\r
232 UINT64 r23;\r
233 UINT64 r24;\r
234 UINT64 r25;\r
235 UINT64 r26;\r
236 UINT64 r27;\r
237 UINT64 r28;\r
238 UINT64 r29;\r
239 UINT64 r30;\r
240 UINT64 r31;\r
241\r
242 UINT64 pr;\r
243\r
244 UINT64 b0;\r
245 UINT64 b1;\r
246 UINT64 b2;\r
247 UINT64 b3;\r
248 UINT64 b4;\r
249 UINT64 b5;\r
250 UINT64 b6;\r
251 UINT64 b7;\r
252\r
253 // application registers\r
254 UINT64 ar_rsc;\r
255 UINT64 ar_bsp;\r
256 UINT64 ar_bspstore;\r
257 UINT64 ar_rnat;\r
258\r
259 UINT64 ar_fcr;\r
260\r
261 UINT64 ar_eflag;\r
262 UINT64 ar_csd;\r
263 UINT64 ar_ssd;\r
264 UINT64 ar_cflg;\r
265 UINT64 ar_fsr;\r
266 UINT64 ar_fir;\r
267 UINT64 ar_fdr;\r
268\r
269 UINT64 ar_ccv;\r
270\r
271 UINT64 ar_unat;\r
272\r
273 UINT64 ar_fpsr;\r
274\r
275 UINT64 ar_pfs;\r
276 UINT64 ar_lc;\r
277 UINT64 ar_ec;\r
278\r
279 // control registers\r
280 UINT64 cr_dcr;\r
281 UINT64 cr_itm;\r
282 UINT64 cr_iva;\r
283 UINT64 cr_pta;\r
284 UINT64 cr_ipsr;\r
285 UINT64 cr_isr;\r
286 UINT64 cr_iip;\r
287 UINT64 cr_ifa;\r
288 UINT64 cr_itir;\r
289 UINT64 cr_iipa;\r
290 UINT64 cr_ifs;\r
291 UINT64 cr_iim;\r
292 UINT64 cr_iha;\r
293\r
294 // debug registers\r
295 UINT64 dbr0;\r
296 UINT64 dbr1;\r
297 UINT64 dbr2;\r
298 UINT64 dbr3;\r
299 UINT64 dbr4;\r
300 UINT64 dbr5;\r
301 UINT64 dbr6;\r
302 UINT64 dbr7;\r
303\r
304 UINT64 ibr0;\r
305 UINT64 ibr1;\r
306 UINT64 ibr2;\r
307 UINT64 ibr3;\r
308 UINT64 ibr4;\r
309 UINT64 ibr5;\r
310 UINT64 ibr6;\r
311 UINT64 ibr7;\r
312\r
313 // virtual registers\r
314 UINT64 int_nat; // nat bits for R1-R31\r
315\r
316} EFI_PMI_SYSTEM_CONTEXT;\r
317\r
318typedef union {\r
319 EFI_SMI_CPU_SAVE_STATE Ia32SaveState;\r
320 EFI_PMI_SYSTEM_CONTEXT ItaniumSaveState;\r
321} EFI_SMM_CPU_SAVE_STATE;\r
322\r
323typedef struct {\r
324 UINT16 Fcw;\r
325 UINT16 Fsw;\r
326 UINT16 Ftw;\r
327 UINT16 Opcode;\r
328 UINT32 Eip;\r
329 UINT16 Cs;\r
330 UINT16 Rsvd1;\r
331 UINT32 DataOffset;\r
332 UINT16 Ds;\r
333 UINT8 Rsvd2[10];\r
334 UINT8 St0Mm0[10], Rsvd3[6];\r
335 UINT8 St0Mm1[10], Rsvd4[6];\r
336 UINT8 St0Mm2[10], Rsvd5[6];\r
337 UINT8 St0Mm3[10], Rsvd6[6];\r
338 UINT8 St0Mm4[10], Rsvd7[6];\r
339 UINT8 St0Mm5[10], Rsvd8[6];\r
340 UINT8 St0Mm6[10], Rsvd9[6];\r
341 UINT8 St0Mm7[10], Rsvd10[6];\r
342 UINT8 Rsvd11[22*16];\r
343} EFI_SMI_OPTIONAL_FPSAVE_STATE;\r
344\r
345typedef struct {\r
346 UINT64 f2[2];\r
347 UINT64 f3[2];\r
348 UINT64 f4[2];\r
349 UINT64 f5[2];\r
350 UINT64 f6[2];\r
351 UINT64 f7[2];\r
352 UINT64 f8[2];\r
353 UINT64 f9[2];\r
354 UINT64 f10[2];\r
355 UINT64 f11[2];\r
356 UINT64 f12[2];\r
357 UINT64 f13[2];\r
358 UINT64 f14[2];\r
359 UINT64 f15[2];\r
360 UINT64 f16[2];\r
361 UINT64 f17[2];\r
362 UINT64 f18[2];\r
363 UINT64 f19[2];\r
364 UINT64 f20[2];\r
365 UINT64 f21[2];\r
366 UINT64 f22[2];\r
367 UINT64 f23[2];\r
368 UINT64 f24[2];\r
369 UINT64 f25[2];\r
370 UINT64 f26[2];\r
371 UINT64 f27[2];\r
372 UINT64 f28[2];\r
373 UINT64 f29[2];\r
374 UINT64 f30[2];\r
375 UINT64 f31[2];\r
376} EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT;\r
377\r
378typedef union {\r
379 EFI_SMI_OPTIONAL_FPSAVE_STATE Ia32FpSave;\r
380 EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT ItaniumFpSave;\r
381} EFI_SMM_FLOATING_POINT_SAVE_STATE;\r
382\r
383/**\r
384 This function is the main entry point for an SMM handler dispatch \r
385 or communicate-based callback. \r
386\r
0647c9ad
LG
387 @param SmmImageHandle A unique value returned by the SMM infrastructure\r
388 in response to registration for a communicate-based callback or dispatch.\r
389 @param CommunicationBuffer \r
390 An optional buffer that will be populated\r
391 by the SMM infrastructure in response to a non-SMM agent (preboot or runtime)\r
392 invoking the EFI_SMM_BASE_PROTOCOL.Communicate() service.\r
393 @param SourceSize If CommunicationBuffer is non-NULL, this field\r
394 indicates the size of the data payload in this buffer.\r
878ddf1f 395\r
396 @return Status Code\r
397\r
398**/\r
399typedef\r
400EFI_STATUS\r
401(EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT) (\r
402 IN EFI_HANDLE SmmImageHandle,\r
403 IN OUT VOID *CommunicationBuffer OPTIONAL,\r
404 IN OUT UINTN *SourceSize OPTIONAL\r
405 );\r
406\r
407/**\r
408 The SmmInstallConfigurationTable() function is used to maintain the list \r
409 of configuration tables that are stored in the System Management System \r
410 Table. The list is stored as an array of (GUID, Pointer) pairs. The list \r
411 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.\r
412\r
0647c9ad
LG
413 @param SystemTable A pointer to the SMM System Table.\r
414 @param Guid A pointer to the GUID for the entry to add, update, or remove.\r
415 @param Table A pointer to the buffer of the table to add.\r
416 @param TableSize The size of the table to install.\r
878ddf1f 417\r
0647c9ad 418 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.\r
878ddf1f 419 @retval EFI_INVALID_PARAMETER Guid is not valid.\r
0647c9ad
LG
420 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.\r
421 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.\r
878ddf1f 422\r
423**/\r
424typedef\r
425EFI_STATUS\r
426(EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE) (\r
427 IN EFI_SMM_SYSTEM_TABLE *SystemTable,\r
428 IN EFI_GUID *Guid,\r
429 IN VOID *Table,\r
430 IN UINTN TableSize\r
431 )\r
432;\r
433\r
434//\r
435// System Management System Table (SMST)\r
436//\r
437struct _EFI_SMM_SYSTEM_TABLE {\r
438 EFI_TABLE_HEADER Hdr;\r
439\r
440 CHAR16 *SmmFirmwareVendor;\r
441 UINT32 SmmFirmwareRevision;\r
442\r
443 EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;\r
444\r
445 //\r
446 // I/O Services\r
447 //\r
448 EFI_GUID EfiSmmCpuIoGuid;\r
449 EFI_SMM_CPU_IO_INTERFACE SmmIo;\r
450\r
451 //\r
452 // Runtime memory service\r
453 //\r
454 EFI_SMMCORE_ALLOCATE_POOL SmmAllocatePool;\r
455 EFI_SMMCORE_FREE_POOL SmmFreePool;\r
456 EFI_SMMCORE_ALLOCATE_PAGES SmmAllocatePages;\r
457 EFI_SMMCORE_FREE_PAGES SmmFreePages;\r
458\r
459 //\r
460 // MP service\r
461 //\r
462 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;\r
463\r
464 //\r
465 // CPU information records\r
466 //\r
467 UINTN CurrentlyExecutingCpu;\r
468 UINTN NumberOfCpus;\r
469 EFI_SMM_CPU_SAVE_STATE *CpuSaveState;\r
470 EFI_SMM_FLOATING_POINT_SAVE_STATE *CpuOptionalFloatingPointState;\r
471\r
472 //\r
473 // Extensibility table\r
474 //\r
475 UINTN NumberOfTableEntries;\r
476 EFI_CONFIGURATION_TABLE *SmmConfigurationTable;\r
477\r
478};\r
479\r
480#include <Guid/SmmCommunicate.h>\r
481#include <Guid/SmramMemoryReserve.h>\r
482#include <Protocol/SmmBase.h>\r
483#include <Protocol/SmmAccess.h>\r
484#include <Protocol/SmmControl.h>\r
485#include <Protocol/SmmGpiDispatch.h>\r
486#include <Protocol/SmmIchnDispatch.h>\r
487#include <Protocol/SmmPeriodicTimerDispatch.h>\r
488#include <Protocol/SmmPowerButtonDispatch.h>\r
489#include <Protocol/SmmStandbyButtonDispatch.h>\r
490#include <Protocol/SmmStatusCode.h>\r
491#include <Protocol/SmmSwDispatch.h>\r
492#include <Protocol/SmmSxDispatch.h>\r
493#include <Protocol/SmmUsbDispatch.h>\r
494\r
495extern EFI_GUID gEfiSmmCpuIoGuid;\r
496\r
497#endif\r