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