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