]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkPkg/Include/Framework/SmmCis.h
1ff1400a517355807e167c838c3241223cd4fc39
[mirror_edk2.git] / IntelFrameworkPkg / Include / Framework / SmmCis.h
1 /** @file
2 Include file for definitions in the Intel Platform Innovation Framework for EFI
3 System Management Mode Core Interface Specification (SMM CIS) version 0.91.
4
5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _SMM_CIS_H_
11 #define _SMM_CIS_H_
12
13 //
14 // Share some common definitions with PI SMM
15 //
16 #include <Pi/PiSmmCis.h>
17 #include <Protocol/SmmCpuIo.h>
18
19 typedef struct _EFI_SMM_SYSTEM_TABLE EFI_SMM_SYSTEM_TABLE;
20
21 //
22 // SMM Base specification constant and types
23 //
24 #define EFI_SMM_SYSTEM_TABLE_REVISION (0 << 16) | (0x09)
25
26 /**
27 Allocates pool memory from SMRAM for IA-32, or runtime memory for
28 the Itanium processor family.
29
30 @param PoolType The type of pool to allocate. The only supported type
31 is EfiRuntimeServicesData.
32 @param Size The number of bytes to allocate from the pool.
33 @param Buffer A pointer to a pointer to the allocated buffer if the
34 call succeeds. Otherwise, undefined.
35
36 @retval EFI_SUCCESS The requested number of bytes was allocated.
37 @retval EFI_OUT_OF_RESOURCES The pool requested could not be allocated.
38 @retval EFI_UNSUPPORTED In runtime.
39 @note Inconsistent with specification here:
40 In Framework Spec, this definition is named EFI_SMM_ALLOCATE_POOL.
41 To avoid a naming conflict, the definition is renamed.
42 **/
43 typedef
44 EFI_STATUS
45 (EFIAPI *EFI_SMMCORE_ALLOCATE_POOL)(
46 IN EFI_MEMORY_TYPE PoolType,
47 IN UINTN Size,
48 OUT VOID **Buffer
49 );
50
51 /**
52 Returns pool memory to the system.
53
54 @param Buffer The pointer to the buffer to free.
55
56 @retval EFI_SUCCESS The memory was returned to the system.
57 @retval EFI_INVALID_PARAMETER Buffer was invalid.
58 @retval EFI_UNSUPPORTED In runtime.
59 @note Inconsistent with specification here:
60 In Framework Spec, this definition is named EFI_SMM_FREE_POOL.
61 To avoid a naming conflict, the definition is renamed.
62 **/
63 typedef
64 EFI_STATUS
65 (EFIAPI *EFI_SMMCORE_FREE_POOL)(
66 IN VOID *Buffer
67 );
68
69 /**
70 Allocates memory pages from the system.
71
72 @param Type The type of allocation to perform.
73 @param MemoryType The only supported type is EfiRuntimeServicesData.
74 @param NumberofPages The number of contiguous 4 KB pages to allocate.
75 @param Memory Pointer to a physical address. On input, the way in which
76 the address is used depends on the value of Type. On output, the address
77 is set to the base of the page range that was allocated.
78
79 @retval EFI_SUCCESS The requested pages were allocated.
80 @retval EFI_OUT_OF_RESOURCES The pages requested could not be allocated.
81 @retval EFI_NOT_FOUND The requested pages could not be found.
82 @retval EFI_INVALID_PARAMETER Type is not AllocateAnyPages or AllocateMaxAddress
83 or AllocateAddress. Or, MemoryType is in the range EfiMaxMemoryType..0x7FFFFFFF.
84 @note Inconsistent with specification here:
85 In the Framework Spec, this definition is named EFI_SMM_ALLOCATE_PAGES.
86 To avoid a naming conflict, the definition here is renamed.
87 **/
88 typedef
89 EFI_STATUS
90 (EFIAPI *EFI_SMMCORE_ALLOCATE_PAGES)(
91 IN EFI_ALLOCATE_TYPE Type,
92 IN EFI_MEMORY_TYPE MemoryType,
93 IN UINTN NumberOfPages,
94 OUT EFI_PHYSICAL_ADDRESS *Memory
95 );
96
97 /**
98 Frees memory pages for the system.
99
100 @param Memory The base physical address of the pages to be freed.
101 @param NumberOfPages The number of contiguous 4 KB pages to free.
102
103 @retval EFI_SUCCESS The requested memory pages were freed.
104 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or NumberOfPages is invalid.
105 @retval EFI_NOT_FOUND The requested memory pages were not allocated with SmmAllocatePages().
106
107 @note Inconsistent with specification here:
108 In the Framework Spec, this definition is named EFI_SMM_FREE_PAGES.
109 To avoid a naming conflict, the definition here is renamed.
110 **/
111 typedef
112 EFI_STATUS
113 (EFIAPI *EFI_SMMCORE_FREE_PAGES)(
114 IN EFI_PHYSICAL_ADDRESS Memory,
115 IN UINTN NumberOfPages
116 );
117
118 ///
119 /// The processor save-state information for IA-32 processors. This information is important in that the
120 /// SMM drivers may need to ascertain the state of the processor before invoking the SMI.
121 ///
122 typedef struct {
123 ///
124 /// Reserved for future processors. As such, software should not attempt to interpret or
125 /// write to this region.
126 ///
127 UINT8 Reserved1[248];
128 ///
129 /// The location of the processor SMBASE, which is the location where the processor
130 /// will pass control upon receipt of an SMI.
131 ///
132 UINT32 SMBASE;
133 ///
134 /// The revision of the SMM save state. This value is set by the processor.
135 ///
136 UINT32 SMMRevId;
137 ///
138 /// The value of the I/O restart field. Allows for restarting an in-process I/O instruction.
139 ///
140 UINT16 IORestart;
141 ///
142 /// Describes behavior that should be commenced in response to a halt instruction.
143 ///
144 UINT16 AutoHALTRestart;
145 ///
146 /// Reserved for future processors. As such, software should not attempt to interpret or
147 /// write to this region.
148 ///
149 UINT8 Reserved2[164];
150
151 //
152 // Registers in IA-32 processors.
153 //
154 UINT32 ES;
155 UINT32 CS;
156 UINT32 SS;
157 UINT32 DS;
158 UINT32 FS;
159 UINT32 GS;
160 UINT32 LDTBase;
161 UINT32 TR;
162 UINT32 DR7;
163 UINT32 DR6;
164 UINT32 EAX;
165 UINT32 ECX;
166 UINT32 EDX;
167 UINT32 EBX;
168 UINT32 ESP;
169 UINT32 EBP;
170 UINT32 ESI;
171 UINT32 EDI;
172 UINT32 EIP;
173 UINT32 EFLAGS;
174 UINT32 CR3;
175 UINT32 CR0;
176 } EFI_SMI_CPU_SAVE_STATE;
177
178 ///
179 /// The processor save-state information for the Itanium processor family. This information is
180 /// important in that the SMM drivers may need to ascertain the state of the processor before invoking
181 /// the PMI. This structure is mandatory and must be 512 byte aligned.
182 ///
183 typedef struct {
184 UINT64 reserved;
185 UINT64 r1;
186 UINT64 r2;
187 UINT64 r3;
188 UINT64 r4;
189 UINT64 r5;
190 UINT64 r6;
191 UINT64 r7;
192 UINT64 r8;
193 UINT64 r9;
194 UINT64 r10;
195 UINT64 r11;
196 UINT64 r12;
197 UINT64 r13;
198 UINT64 r14;
199 UINT64 r15;
200 UINT64 r16;
201 UINT64 r17;
202 UINT64 r18;
203 UINT64 r19;
204 UINT64 r20;
205 UINT64 r21;
206 UINT64 r22;
207 UINT64 r23;
208 UINT64 r24;
209 UINT64 r25;
210 UINT64 r26;
211 UINT64 r27;
212 UINT64 r28;
213 UINT64 r29;
214 UINT64 r30;
215 UINT64 r31;
216
217 UINT64 pr;
218
219 UINT64 b0;
220 UINT64 b1;
221 UINT64 b2;
222 UINT64 b3;
223 UINT64 b4;
224 UINT64 b5;
225 UINT64 b6;
226 UINT64 b7;
227
228 // application registers
229 UINT64 ar_rsc;
230 UINT64 ar_bsp;
231 UINT64 ar_bspstore;
232 UINT64 ar_rnat;
233
234 UINT64 ar_fcr;
235
236 UINT64 ar_eflag;
237 UINT64 ar_csd;
238 UINT64 ar_ssd;
239 UINT64 ar_cflg;
240 UINT64 ar_fsr;
241 UINT64 ar_fir;
242 UINT64 ar_fdr;
243
244 UINT64 ar_ccv;
245
246 UINT64 ar_unat;
247
248 UINT64 ar_fpsr;
249
250 UINT64 ar_pfs;
251 UINT64 ar_lc;
252 UINT64 ar_ec;
253
254 // control registers
255 UINT64 cr_dcr;
256 UINT64 cr_itm;
257 UINT64 cr_iva;
258 UINT64 cr_pta;
259 UINT64 cr_ipsr;
260 UINT64 cr_isr;
261 UINT64 cr_iip;
262 UINT64 cr_ifa;
263 UINT64 cr_itir;
264 UINT64 cr_iipa;
265 UINT64 cr_ifs;
266 UINT64 cr_iim;
267 UINT64 cr_iha;
268
269 // debug registers
270 UINT64 dbr0;
271 UINT64 dbr1;
272 UINT64 dbr2;
273 UINT64 dbr3;
274 UINT64 dbr4;
275 UINT64 dbr5;
276 UINT64 dbr6;
277 UINT64 dbr7;
278
279 UINT64 ibr0;
280 UINT64 ibr1;
281 UINT64 ibr2;
282 UINT64 ibr3;
283 UINT64 ibr4;
284 UINT64 ibr5;
285 UINT64 ibr6;
286 UINT64 ibr7;
287
288 // virtual registers
289 UINT64 int_nat; // nat bits for R1-R31
290
291 } EFI_PMI_SYSTEM_CONTEXT;
292
293 ///
294 /// The processor save-state information for IA-32 and Itanium processors. This information is
295 /// important in that the SMM drivers may need to ascertain the state of the processor before invoking
296 /// the SMI or PMI.
297 ///
298 typedef union {
299 ///
300 /// The processor save-state information for IA-32 processors.
301 ///
302 EFI_SMI_CPU_SAVE_STATE Ia32SaveState;
303 ///
304 /// Note: Inconsistency with the Framework SMM CIS spec - Itanium save state not included.
305 ///
306 /// The processor save-state information for Itanium processors.
307 ///
308 /// EFI_PMI_SYSTEM_CONTEXT ItaniumSaveState;
309 } EFI_SMM_CPU_SAVE_STATE;
310
311 ///
312 /// The optional floating point save-state information for IA-32 processors. If the optional floating
313 /// point save is indicated for any handler, the following data structure must be preserved.
314 ///
315 typedef struct {
316 UINT16 Fcw;
317 UINT16 Fsw;
318 UINT16 Ftw;
319 UINT16 Opcode;
320 UINT32 Eip;
321 UINT16 Cs;
322 UINT16 Rsvd1;
323 UINT32 DataOffset;
324 UINT16 Ds;
325 UINT8 Rsvd2[10];
326 UINT8 St0Mm0[10], Rsvd3[6];
327 UINT8 St0Mm1[10], Rsvd4[6];
328 UINT8 St0Mm2[10], Rsvd5[6];
329 UINT8 St0Mm3[10], Rsvd6[6];
330 UINT8 St0Mm4[10], Rsvd7[6];
331 UINT8 St0Mm5[10], Rsvd8[6];
332 UINT8 St0Mm6[10], Rsvd9[6];
333 UINT8 St0Mm7[10], Rsvd10[6];
334 UINT8 Rsvd11[22*16];
335 } EFI_SMI_OPTIONAL_FPSAVE_STATE;
336
337 ///
338 /// The optional floating point save-state information for the Itanium processor family. If the optional
339 /// floating point save is indicated for any handler, then this data structure must be preserved.
340 ///
341 typedef struct {
342 UINT64 f2[2];
343 UINT64 f3[2];
344 UINT64 f4[2];
345 UINT64 f5[2];
346 UINT64 f6[2];
347 UINT64 f7[2];
348 UINT64 f8[2];
349 UINT64 f9[2];
350 UINT64 f10[2];
351 UINT64 f11[2];
352 UINT64 f12[2];
353 UINT64 f13[2];
354 UINT64 f14[2];
355 UINT64 f15[2];
356 UINT64 f16[2];
357 UINT64 f17[2];
358 UINT64 f18[2];
359 UINT64 f19[2];
360 UINT64 f20[2];
361 UINT64 f21[2];
362 UINT64 f22[2];
363 UINT64 f23[2];
364 UINT64 f24[2];
365 UINT64 f25[2];
366 UINT64 f26[2];
367 UINT64 f27[2];
368 UINT64 f28[2];
369 UINT64 f29[2];
370 UINT64 f30[2];
371 UINT64 f31[2];
372 } EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT;
373
374 ///
375 /// The processor save-state information for IA-32 and Itanium processors. If the optional floating
376 /// point save is indicated for any handler, then this data structure must be preserved.
377 ///
378 typedef union {
379 ///
380 /// The optional floating point save-state information for IA-32 processors.
381 ///
382 EFI_SMI_OPTIONAL_FPSAVE_STATE Ia32FpSave;
383 ///
384 /// The optional floating point save-state information for Itanium processors.
385 ///
386 EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT ItaniumFpSave;
387 } EFI_SMM_FLOATING_POINT_SAVE_STATE;
388
389 /**
390 This function is the main entry point for an SMM handler dispatch
391 or communicate-based callback.
392
393 @param SmmImageHandle A unique value returned by the SMM infrastructure
394 in response to registration for a communicate-based callback or dispatch.
395 @param CommunicationBuffer
396 An optional buffer that will be populated
397 by the SMM infrastructure in response to a non-SMM agent (preboot or runtime)
398 invoking the EFI_SMM_BASE_PROTOCOL.Communicate() service.
399 @param SourceSize If CommunicationBuffer is non-NULL, this field
400 indicates the size of the data payload in this buffer.
401
402 @return Status Code
403
404 **/
405 typedef
406 EFI_STATUS
407 (EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT)(
408 IN EFI_HANDLE SmmImageHandle,
409 IN OUT VOID *CommunicationBuffer OPTIONAL,
410 IN OUT UINTN *SourceSize OPTIONAL
411 );
412
413 /**
414 The SmmInstallConfigurationTable() function is used to maintain the list
415 of configuration tables that are stored in the System Management System
416 Table. The list is stored as an array of (GUID, Pointer) pairs. The list
417 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
418
419 @param SystemTable A pointer to the SMM System Table.
420 @param Guid A pointer to the GUID for the entry to add, update, or remove.
421 @param Table A pointer to the buffer of the table to add.
422 @param TableSize The size of the table to install.
423
424 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
425 @retval EFI_INVALID_PARAMETER Guid is not valid.
426 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
427 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
428
429 **/
430 typedef
431 EFI_STATUS
432 (EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE)(
433 IN EFI_SMM_SYSTEM_TABLE *SystemTable,
434 IN EFI_GUID *Guid,
435 IN VOID *Table,
436 IN UINTN TableSize
437 );
438
439 //
440 // System Management System Table (SMST)
441 //
442 struct _EFI_SMM_SYSTEM_TABLE {
443 ///
444 /// The table header for the System Management System Table (SMST).
445 ///
446 EFI_TABLE_HEADER Hdr;
447
448 ///
449 /// A pointer to a NULL-terminated Unicode string containing the vendor name. It is
450 /// permissible for this pointer to be NULL.
451 ///
452 CHAR16 *SmmFirmwareVendor;
453 ///
454 /// The particular revision of the firmware.
455 ///
456 UINT32 SmmFirmwareRevision;
457
458 ///
459 /// Adds, updates, or removes a configuration table entry from the SMST.
460 ///
461 EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;
462
463 //
464 // I/O Services
465 //
466 ///
467 /// A GUID that designates the particular CPU I/O services.
468 ///
469 EFI_GUID EfiSmmCpuIoGuid;
470 ///
471 /// Provides the basic memory and I/O interfaces that are used to abstract accesses to
472 /// devices.
473 ///
474 EFI_SMM_CPU_IO_INTERFACE SmmIo;
475
476 //
477 // Runtime memory service
478 //
479 ///
480 ///
481 /// Allocates pool memory from SMRAM for IA-32 or runtime memory for the
482 /// Itanium processor family.
483 ///
484 EFI_SMMCORE_ALLOCATE_POOL SmmAllocatePool;
485 ///
486 /// Returns pool memory to the system.
487 ///
488 EFI_SMMCORE_FREE_POOL SmmFreePool;
489 ///
490 /// Allocates memory pages from the system.
491 ///
492 EFI_SMMCORE_ALLOCATE_PAGES SmmAllocatePages;
493 ///
494 /// Frees memory pages for the system.
495 ///
496 EFI_SMMCORE_FREE_PAGES SmmFreePages;
497
498 //
499 // MP service
500 //
501
502 /// Inconsistent with specification here:
503 /// In Framework Spec, this definition does not exist. This method is introduced in PI1.1 specification for
504 /// the implementation needed.
505 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;
506
507 //
508 // CPU information records
509 //
510 ///
511 /// A 1-relative number between 1 and the NumberOfCpus field. This field designates
512 /// which processor is executing the SMM infrastructure. This number also serves as an
513 /// index into the CpuSaveState and CpuOptionalFloatingPointState
514 /// fields.
515 ///
516 UINTN CurrentlyExecutingCpu;
517 ///
518 /// The number of EFI Configuration Tables in the buffer
519 /// SmmConfigurationTable.
520 ///
521 UINTN NumberOfCpus;
522 ///
523 /// A pointer to the EFI Configuration Tables. The number of entries in the table is
524 /// NumberOfTableEntries.
525 ///
526 EFI_SMM_CPU_SAVE_STATE *CpuSaveState;
527 ///
528 /// A pointer to a catenation of the EFI_SMM_FLOATING_POINT_SAVE_STATE.
529 /// The size of this entire table is NumberOfCpus* size of the
530 /// EFI_SMM_FLOATING_POINT_SAVE_STATE. These fields are populated only if
531 /// there is at least one SMM driver that has registered for a callback with the
532 /// FloatingPointSave field in EFI_SMM_BASE_PROTOCOL.RegisterCallback() set to TRUE.
533 ///
534 EFI_SMM_FLOATING_POINT_SAVE_STATE *CpuOptionalFloatingPointState;
535
536 //
537 // Extensibility table
538 //
539 ///
540 /// The number of EFI Configuration Tables in the buffer
541 /// SmmConfigurationTable.
542 ///
543 UINTN NumberOfTableEntries;
544 ///
545 /// A pointer to the EFI Configuration Tables. The number of entries in the table is
546 /// NumberOfTableEntries.
547 ///
548 EFI_CONFIGURATION_TABLE *SmmConfigurationTable;
549 };
550
551 #endif