]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Dxe/SmmCis.h
Remove BugBug in comments and adjust function header according to code style doc.
[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
169typedef\r
170VOID\r
171(EFIAPI *EFI_AP_PROCEDURE) (\r
172 IN VOID *Buffer\r
173 );\r
174\r
175typedef\r
176EFI_STATUS\r
177(EFIAPI *EFI_SMM_STARTUP_THIS_AP) (\r
178 IN EFI_AP_PROCEDURE Procedure,\r
179 IN UINTN CpuNumber,\r
180 IN OUT VOID *ProcArguments OPTIONAL\r
181 );\r
182\r
183typedef struct {\r
184 UINT8 Reserved1[248];\r
185 UINT32 SMBASE;\r
186 UINT32 SMMRevId;\r
187 UINT16 IORestart;\r
188 UINT16 AutoHALTRestart;\r
189 UINT8 Reserved2[164];\r
190 UINT32 ES;\r
191 UINT32 CS;\r
192 UINT32 SS;\r
193 UINT32 DS;\r
194 UINT32 FS;\r
195 UINT32 GS;\r
196 UINT32 LDTBase;\r
197 UINT32 TR;\r
198 UINT32 DR7;\r
199 UINT32 DR6;\r
200 UINT32 EAX;\r
201 UINT32 ECX;\r
202 UINT32 EDX;\r
203 UINT32 EBX;\r
204 UINT32 ESP;\r
205 UINT32 EBP;\r
206 UINT32 ESI;\r
207 UINT32 EDI;\r
208 UINT32 EIP;\r
209 UINT32 EFLAGS;\r
210 UINT32 CR3;\r
211 UINT32 CR0;\r
212} EFI_SMI_CPU_SAVE_STATE;\r
213\r
214typedef struct {\r
215 UINT64 reserved; \r
216 UINT64 r1;\r
217 UINT64 r2;\r
218 UINT64 r3;\r
219 UINT64 r4;\r
220 UINT64 r5;\r
221 UINT64 r6;\r
222 UINT64 r7;\r
223 UINT64 r8;\r
224 UINT64 r9;\r
225 UINT64 r10;\r
226 UINT64 r11;\r
227 UINT64 r12;\r
228 UINT64 r13;\r
229 UINT64 r14;\r
230 UINT64 r15;\r
231 UINT64 r16;\r
232 UINT64 r17;\r
233 UINT64 r18;\r
234 UINT64 r19;\r
235 UINT64 r20;\r
236 UINT64 r21;\r
237 UINT64 r22;\r
238 UINT64 r23;\r
239 UINT64 r24;\r
240 UINT64 r25;\r
241 UINT64 r26;\r
242 UINT64 r27;\r
243 UINT64 r28;\r
244 UINT64 r29;\r
245 UINT64 r30;\r
246 UINT64 r31;\r
247\r
248 UINT64 pr;\r
249\r
250 UINT64 b0;\r
251 UINT64 b1;\r
252 UINT64 b2;\r
253 UINT64 b3;\r
254 UINT64 b4;\r
255 UINT64 b5;\r
256 UINT64 b6;\r
257 UINT64 b7;\r
258\r
259 // application registers\r
260 UINT64 ar_rsc;\r
261 UINT64 ar_bsp;\r
262 UINT64 ar_bspstore;\r
263 UINT64 ar_rnat;\r
264\r
265 UINT64 ar_fcr;\r
266\r
267 UINT64 ar_eflag;\r
268 UINT64 ar_csd;\r
269 UINT64 ar_ssd;\r
270 UINT64 ar_cflg;\r
271 UINT64 ar_fsr;\r
272 UINT64 ar_fir;\r
273 UINT64 ar_fdr;\r
274\r
275 UINT64 ar_ccv;\r
276\r
277 UINT64 ar_unat;\r
278\r
279 UINT64 ar_fpsr;\r
280\r
281 UINT64 ar_pfs;\r
282 UINT64 ar_lc;\r
283 UINT64 ar_ec;\r
284\r
285 // control registers\r
286 UINT64 cr_dcr;\r
287 UINT64 cr_itm;\r
288 UINT64 cr_iva;\r
289 UINT64 cr_pta;\r
290 UINT64 cr_ipsr;\r
291 UINT64 cr_isr;\r
292 UINT64 cr_iip;\r
293 UINT64 cr_ifa;\r
294 UINT64 cr_itir;\r
295 UINT64 cr_iipa;\r
296 UINT64 cr_ifs;\r
297 UINT64 cr_iim;\r
298 UINT64 cr_iha;\r
299\r
300 // debug registers\r
301 UINT64 dbr0;\r
302 UINT64 dbr1;\r
303 UINT64 dbr2;\r
304 UINT64 dbr3;\r
305 UINT64 dbr4;\r
306 UINT64 dbr5;\r
307 UINT64 dbr6;\r
308 UINT64 dbr7;\r
309\r
310 UINT64 ibr0;\r
311 UINT64 ibr1;\r
312 UINT64 ibr2;\r
313 UINT64 ibr3;\r
314 UINT64 ibr4;\r
315 UINT64 ibr5;\r
316 UINT64 ibr6;\r
317 UINT64 ibr7;\r
318\r
319 // virtual registers\r
320 UINT64 int_nat; // nat bits for R1-R31\r
321\r
322} EFI_PMI_SYSTEM_CONTEXT;\r
323\r
324typedef union {\r
325 EFI_SMI_CPU_SAVE_STATE Ia32SaveState;\r
326 EFI_PMI_SYSTEM_CONTEXT ItaniumSaveState;\r
327} EFI_SMM_CPU_SAVE_STATE;\r
328\r
329typedef struct {\r
330 UINT16 Fcw;\r
331 UINT16 Fsw;\r
332 UINT16 Ftw;\r
333 UINT16 Opcode;\r
334 UINT32 Eip;\r
335 UINT16 Cs;\r
336 UINT16 Rsvd1;\r
337 UINT32 DataOffset;\r
338 UINT16 Ds;\r
339 UINT8 Rsvd2[10];\r
340 UINT8 St0Mm0[10], Rsvd3[6];\r
341 UINT8 St0Mm1[10], Rsvd4[6];\r
342 UINT8 St0Mm2[10], Rsvd5[6];\r
343 UINT8 St0Mm3[10], Rsvd6[6];\r
344 UINT8 St0Mm4[10], Rsvd7[6];\r
345 UINT8 St0Mm5[10], Rsvd8[6];\r
346 UINT8 St0Mm6[10], Rsvd9[6];\r
347 UINT8 St0Mm7[10], Rsvd10[6];\r
348 UINT8 Rsvd11[22*16];\r
349} EFI_SMI_OPTIONAL_FPSAVE_STATE;\r
350\r
351typedef struct {\r
352 UINT64 f2[2];\r
353 UINT64 f3[2];\r
354 UINT64 f4[2];\r
355 UINT64 f5[2];\r
356 UINT64 f6[2];\r
357 UINT64 f7[2];\r
358 UINT64 f8[2];\r
359 UINT64 f9[2];\r
360 UINT64 f10[2];\r
361 UINT64 f11[2];\r
362 UINT64 f12[2];\r
363 UINT64 f13[2];\r
364 UINT64 f14[2];\r
365 UINT64 f15[2];\r
366 UINT64 f16[2];\r
367 UINT64 f17[2];\r
368 UINT64 f18[2];\r
369 UINT64 f19[2];\r
370 UINT64 f20[2];\r
371 UINT64 f21[2];\r
372 UINT64 f22[2];\r
373 UINT64 f23[2];\r
374 UINT64 f24[2];\r
375 UINT64 f25[2];\r
376 UINT64 f26[2];\r
377 UINT64 f27[2];\r
378 UINT64 f28[2];\r
379 UINT64 f29[2];\r
380 UINT64 f30[2];\r
381 UINT64 f31[2];\r
382} EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT;\r
383\r
384typedef union {\r
385 EFI_SMI_OPTIONAL_FPSAVE_STATE Ia32FpSave;\r
386 EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT ItaniumFpSave;\r
387} EFI_SMM_FLOATING_POINT_SAVE_STATE;\r
388\r
389/**\r
390 This function is the main entry point for an SMM handler dispatch \r
391 or communicate-based callback. \r
392\r
0647c9ad
LG
393 @param SmmImageHandle A unique value returned by the SMM infrastructure\r
394 in response to registration for a communicate-based callback or dispatch.\r
395 @param CommunicationBuffer \r
396 An optional buffer that will be populated\r
397 by the SMM infrastructure in response to a non-SMM agent (preboot or runtime)\r
398 invoking the EFI_SMM_BASE_PROTOCOL.Communicate() service.\r
399 @param SourceSize If CommunicationBuffer is non-NULL, this field\r
400 indicates the size of the data payload in this buffer.\r
878ddf1f 401\r
402 @return Status Code\r
403\r
404**/\r
405typedef\r
406EFI_STATUS\r
407(EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT) (\r
408 IN EFI_HANDLE SmmImageHandle,\r
409 IN OUT VOID *CommunicationBuffer OPTIONAL,\r
410 IN OUT UINTN *SourceSize OPTIONAL\r
411 );\r
412\r
413/**\r
414 The SmmInstallConfigurationTable() function is used to maintain the list \r
415 of configuration tables that are stored in the System Management System \r
416 Table. The list is stored as an array of (GUID, Pointer) pairs. The list \r
417 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.\r
418\r
0647c9ad
LG
419 @param SystemTable A pointer to the SMM System Table.\r
420 @param Guid A pointer to the GUID for the entry to add, update, or remove.\r
421 @param Table A pointer to the buffer of the table to add.\r
422 @param TableSize The size of the table to install.\r
878ddf1f 423\r
0647c9ad 424 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.\r
878ddf1f 425 @retval EFI_INVALID_PARAMETER Guid is not valid.\r
0647c9ad
LG
426 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.\r
427 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.\r
878ddf1f 428\r
429**/\r
430typedef\r
431EFI_STATUS\r
432(EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE) (\r
433 IN EFI_SMM_SYSTEM_TABLE *SystemTable,\r
434 IN EFI_GUID *Guid,\r
435 IN VOID *Table,\r
436 IN UINTN TableSize\r
437 )\r
438;\r
439\r
440//\r
441// System Management System Table (SMST)\r
442//\r
443struct _EFI_SMM_SYSTEM_TABLE {\r
444 EFI_TABLE_HEADER Hdr;\r
445\r
446 CHAR16 *SmmFirmwareVendor;\r
447 UINT32 SmmFirmwareRevision;\r
448\r
449 EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;\r
450\r
451 //\r
452 // I/O Services\r
453 //\r
454 EFI_GUID EfiSmmCpuIoGuid;\r
455 EFI_SMM_CPU_IO_INTERFACE SmmIo;\r
456\r
457 //\r
458 // Runtime memory service\r
459 //\r
460 EFI_SMMCORE_ALLOCATE_POOL SmmAllocatePool;\r
461 EFI_SMMCORE_FREE_POOL SmmFreePool;\r
462 EFI_SMMCORE_ALLOCATE_PAGES SmmAllocatePages;\r
463 EFI_SMMCORE_FREE_PAGES SmmFreePages;\r
464\r
465 //\r
466 // MP service\r
467 //\r
468 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;\r
469\r
470 //\r
471 // CPU information records\r
472 //\r
473 UINTN CurrentlyExecutingCpu;\r
474 UINTN NumberOfCpus;\r
475 EFI_SMM_CPU_SAVE_STATE *CpuSaveState;\r
476 EFI_SMM_FLOATING_POINT_SAVE_STATE *CpuOptionalFloatingPointState;\r
477\r
478 //\r
479 // Extensibility table\r
480 //\r
481 UINTN NumberOfTableEntries;\r
482 EFI_CONFIGURATION_TABLE *SmmConfigurationTable;\r
483\r
484};\r
485\r
486#include <Guid/SmmCommunicate.h>\r
487#include <Guid/SmramMemoryReserve.h>\r
488#include <Protocol/SmmBase.h>\r
489#include <Protocol/SmmAccess.h>\r
490#include <Protocol/SmmControl.h>\r
491#include <Protocol/SmmGpiDispatch.h>\r
492#include <Protocol/SmmIchnDispatch.h>\r
493#include <Protocol/SmmPeriodicTimerDispatch.h>\r
494#include <Protocol/SmmPowerButtonDispatch.h>\r
495#include <Protocol/SmmStandbyButtonDispatch.h>\r
496#include <Protocol/SmmStatusCode.h>\r
497#include <Protocol/SmmSwDispatch.h>\r
498#include <Protocol/SmmSxDispatch.h>\r
499#include <Protocol/SmmUsbDispatch.h>\r
500\r
501extern EFI_GUID gEfiSmmCpuIoGuid;\r
502\r
503#endif\r