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