]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Dxe/SmmCis.h
d2f2e17de5089c36865a5405feb756064e161e26
[mirror_edk2.git] / MdePkg / Include / Dxe / SmmCis.h
1 /** @file
2 Include file matches things in the Smm CIS spec.
3
4 Copyright (c) 2006, 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: SmmCis.h
14
15 @par Revision Reference:
16 Version 0.9.
17
18 **/
19
20 #ifndef __SMM_CIS__
21 #define __SMM_CIS__
22
23 #define EFI_SMM_CPU_IO_GUID \
24 { \
25 0x5f439a0b, 0x45d8, 0x4682, {0xa4, 0xf4, 0xf0, 0x57, 0x6b, 0x51, 0x34, 0x41 } \
26 }
27
28 typedef struct _EFI_SMM_SYSTEM_TABLE EFI_SMM_SYSTEM_TABLE;
29 typedef struct _EFI_SMM_CPU_IO_INTERFACE EFI_SMM_CPU_IO_INTERFACE;
30
31
32 //
33 // SMM Base specification constant and types
34 //
35 #define SMM_SMST_SIGNATURE EFI_SIGNATURE_32 ('S', 'M', 'S', 'T')
36 #define EFI_SMM_SYSTEM_TABLE_REVISION (0 << 16) | (0x09)
37
38 //
39 // *******************************************************
40 // EFI_SMM_IO_WIDTH
41 // *******************************************************
42 //
43 typedef enum {
44 SMM_IO_UINT8 = 0,
45 SMM_IO_UINT16 = 1,
46 SMM_IO_UINT32 = 2,
47 SMM_IO_UINT64 = 3
48 } EFI_SMM_IO_WIDTH;
49
50 /**
51 Provides the basic memory and I/O interfaces that are used to
52 abstract accesses to devices.
53
54 @param This The EFI_SMM_CPU_IO_INTERFACE instance.
55 @param Width Signifies the width of the I/O operations.
56 @param Address The base address of the I/O operations.
57 @param Count The number of I/O operations to perform.
58 @param Buffer For read operations, the destination buffer to store the results.
59 For write operations, the source buffer from which to write data.
60
61 @retval EFI_SUCCESS The data was read from or written to the device.
62 @retval EFI_UNSUPPORTED The Address is not valid for this system.
63 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
64 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
65
66 **/
67 typedef
68 EFI_STATUS
69 (EFIAPI *EFI_SMM_CPU_IO) (
70 IN EFI_SMM_CPU_IO_INTERFACE *This,
71 IN EFI_SMM_IO_WIDTH Width,
72 IN UINT64 Address,
73 IN UINTN Count,
74 IN OUT VOID *Buffer
75 );
76
77 typedef struct {
78 EFI_SMM_CPU_IO Read;
79 EFI_SMM_CPU_IO Write;
80 } EFI_SMM_IO_ACCESS;
81
82 struct _EFI_SMM_CPU_IO_INTERFACE {
83 EFI_SMM_IO_ACCESS Mem;
84 EFI_SMM_IO_ACCESS Io;
85 };
86
87 /**
88 Allocates pool memory from SMRAM for IA-32 or runtime memory for
89 the Itanium processor family.
90
91 @param PoolType The type of pool to allocate.The only supported type is EfiRuntimeServicesData
92 @param Size The number of bytes to allocate from the pool.
93 @param Buffer A pointer to a pointer to the allocated buffer if the call
94 succeeds; undefined otherwise.
95
96 @retval EFI_SUCCESS The requested number of bytes was allocated.
97 @retval EFI_OUT_OF_RESOURCES The pool requested could not be allocated.
98 @retval EFI_UNSUPPORTED In runtime.
99
100 **/
101 typedef
102 EFI_STATUS
103 (EFIAPI *EFI_SMMCORE_ALLOCATE_POOL) (
104 IN EFI_MEMORY_TYPE PoolType,
105 IN UINTN Size,
106 OUT VOID **Buffer
107 );
108
109 /**
110 Returns pool memory to the system.
111
112 @param Buffer Pointer to the buffer to free.
113
114 @retval EFI_SUCCESS The memory was returned to the system.
115 @retval EFI_INVALID_PARAMETER Buffer was invalid.
116 @retval EFI_UNSUPPORTED In runtime.
117
118 **/
119 typedef
120 EFI_STATUS
121 (EFIAPI *EFI_SMMCORE_FREE_POOL) (
122 IN VOID *Buffer
123 );
124
125 /**
126 Allocates memory pages from the system.
127
128 @param Type The type of allocation to perform.
129 @param MemoryType The only supported type is EfiRuntimeServicesData
130 @param NumberofPages The number of contiguous 4 KB pages to allocate
131 @param Memory Pointer to a physical address. On input, the way in which
132 the address is used depends on the value of Type. On output, the address
133 is set to the base of the page range that was allocated.
134
135 @retval EFI_SUCCESS The requested pages were allocated.
136 @retval EFI_OUT_OF_RESOURCES The pages requested could not be allocated.
137 @retval EFI_NOT_FOUND The requested pages could not be found.
138 @retval EFI_INVALID_PARAMETER Type is not AllocateAnyPages or AllocateMaxAddress
139 or AllocateAddress. Or MemoryType is in the range EfiMaxMemoryType..0x7FFFFFFF.
140
141 **/
142 typedef
143 EFI_STATUS
144 (EFIAPI *EFI_SMMCORE_ALLOCATE_PAGES) (
145 IN EFI_ALLOCATE_TYPE Type,
146 IN EFI_MEMORY_TYPE MemoryType,
147 IN UINTN NumberOfPages,
148 OUT EFI_PHYSICAL_ADDRESS *Memory
149 );
150
151 /**
152 Frees memory pages for the system.
153
154 @param Memory The base physical address of the pages to be freed
155 @param NumberOfPages The number of contiguous 4 KB pages to free.
156
157 @retval EFI_SUCCESS The requested memory pages were freed.
158 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or NumberOfPages is invalid.
159 @retval EFI_NOT_FOUND The requested memory pages were not allocated with SmmAllocatePages().
160
161 **/
162 typedef
163 EFI_STATUS
164 (EFIAPI *EFI_SMMCORE_FREE_PAGES) (
165 IN EFI_PHYSICAL_ADDRESS Memory,
166 IN UINTN NumberOfPages
167 );
168
169 typedef
170 VOID
171 (EFIAPI *EFI_AP_PROCEDURE) (
172 IN VOID *Buffer
173 );
174
175 typedef
176 EFI_STATUS
177 (EFIAPI *EFI_SMM_STARTUP_THIS_AP) (
178 IN EFI_AP_PROCEDURE Procedure,
179 IN UINTN CpuNumber,
180 IN OUT VOID *ProcArguments OPTIONAL
181 );
182
183 typedef struct {
184 UINT8 Reserved1[248];
185 UINT32 SMBASE;
186 UINT32 SMMRevId;
187 UINT16 IORestart;
188 UINT16 AutoHALTRestart;
189 UINT8 Reserved2[164];
190 UINT32 ES;
191 UINT32 CS;
192 UINT32 SS;
193 UINT32 DS;
194 UINT32 FS;
195 UINT32 GS;
196 UINT32 LDTBase;
197 UINT32 TR;
198 UINT32 DR7;
199 UINT32 DR6;
200 UINT32 EAX;
201 UINT32 ECX;
202 UINT32 EDX;
203 UINT32 EBX;
204 UINT32 ESP;
205 UINT32 EBP;
206 UINT32 ESI;
207 UINT32 EDI;
208 UINT32 EIP;
209 UINT32 EFLAGS;
210 UINT32 CR3;
211 UINT32 CR0;
212 } EFI_SMI_CPU_SAVE_STATE;
213
214 typedef struct {
215 UINT64 reserved;
216 UINT64 r1;
217 UINT64 r2;
218 UINT64 r3;
219 UINT64 r4;
220 UINT64 r5;
221 UINT64 r6;
222 UINT64 r7;
223 UINT64 r8;
224 UINT64 r9;
225 UINT64 r10;
226 UINT64 r11;
227 UINT64 r12;
228 UINT64 r13;
229 UINT64 r14;
230 UINT64 r15;
231 UINT64 r16;
232 UINT64 r17;
233 UINT64 r18;
234 UINT64 r19;
235 UINT64 r20;
236 UINT64 r21;
237 UINT64 r22;
238 UINT64 r23;
239 UINT64 r24;
240 UINT64 r25;
241 UINT64 r26;
242 UINT64 r27;
243 UINT64 r28;
244 UINT64 r29;
245 UINT64 r30;
246 UINT64 r31;
247
248 UINT64 pr;
249
250 UINT64 b0;
251 UINT64 b1;
252 UINT64 b2;
253 UINT64 b3;
254 UINT64 b4;
255 UINT64 b5;
256 UINT64 b6;
257 UINT64 b7;
258
259 // application registers
260 UINT64 ar_rsc;
261 UINT64 ar_bsp;
262 UINT64 ar_bspstore;
263 UINT64 ar_rnat;
264
265 UINT64 ar_fcr;
266
267 UINT64 ar_eflag;
268 UINT64 ar_csd;
269 UINT64 ar_ssd;
270 UINT64 ar_cflg;
271 UINT64 ar_fsr;
272 UINT64 ar_fir;
273 UINT64 ar_fdr;
274
275 UINT64 ar_ccv;
276
277 UINT64 ar_unat;
278
279 UINT64 ar_fpsr;
280
281 UINT64 ar_pfs;
282 UINT64 ar_lc;
283 UINT64 ar_ec;
284
285 // control registers
286 UINT64 cr_dcr;
287 UINT64 cr_itm;
288 UINT64 cr_iva;
289 UINT64 cr_pta;
290 UINT64 cr_ipsr;
291 UINT64 cr_isr;
292 UINT64 cr_iip;
293 UINT64 cr_ifa;
294 UINT64 cr_itir;
295 UINT64 cr_iipa;
296 UINT64 cr_ifs;
297 UINT64 cr_iim;
298 UINT64 cr_iha;
299
300 // debug registers
301 UINT64 dbr0;
302 UINT64 dbr1;
303 UINT64 dbr2;
304 UINT64 dbr3;
305 UINT64 dbr4;
306 UINT64 dbr5;
307 UINT64 dbr6;
308 UINT64 dbr7;
309
310 UINT64 ibr0;
311 UINT64 ibr1;
312 UINT64 ibr2;
313 UINT64 ibr3;
314 UINT64 ibr4;
315 UINT64 ibr5;
316 UINT64 ibr6;
317 UINT64 ibr7;
318
319 // virtual registers
320 UINT64 int_nat; // nat bits for R1-R31
321
322 } EFI_PMI_SYSTEM_CONTEXT;
323
324 typedef union {
325 EFI_SMI_CPU_SAVE_STATE Ia32SaveState;
326 EFI_PMI_SYSTEM_CONTEXT ItaniumSaveState;
327 } EFI_SMM_CPU_SAVE_STATE;
328
329 typedef struct {
330 UINT16 Fcw;
331 UINT16 Fsw;
332 UINT16 Ftw;
333 UINT16 Opcode;
334 UINT32 Eip;
335 UINT16 Cs;
336 UINT16 Rsvd1;
337 UINT32 DataOffset;
338 UINT16 Ds;
339 UINT8 Rsvd2[10];
340 UINT8 St0Mm0[10], Rsvd3[6];
341 UINT8 St0Mm1[10], Rsvd4[6];
342 UINT8 St0Mm2[10], Rsvd5[6];
343 UINT8 St0Mm3[10], Rsvd6[6];
344 UINT8 St0Mm4[10], Rsvd7[6];
345 UINT8 St0Mm5[10], Rsvd8[6];
346 UINT8 St0Mm6[10], Rsvd9[6];
347 UINT8 St0Mm7[10], Rsvd10[6];
348 UINT8 Rsvd11[22*16];
349 } EFI_SMI_OPTIONAL_FPSAVE_STATE;
350
351 typedef struct {
352 UINT64 f2[2];
353 UINT64 f3[2];
354 UINT64 f4[2];
355 UINT64 f5[2];
356 UINT64 f6[2];
357 UINT64 f7[2];
358 UINT64 f8[2];
359 UINT64 f9[2];
360 UINT64 f10[2];
361 UINT64 f11[2];
362 UINT64 f12[2];
363 UINT64 f13[2];
364 UINT64 f14[2];
365 UINT64 f15[2];
366 UINT64 f16[2];
367 UINT64 f17[2];
368 UINT64 f18[2];
369 UINT64 f19[2];
370 UINT64 f20[2];
371 UINT64 f21[2];
372 UINT64 f22[2];
373 UINT64 f23[2];
374 UINT64 f24[2];
375 UINT64 f25[2];
376 UINT64 f26[2];
377 UINT64 f27[2];
378 UINT64 f28[2];
379 UINT64 f29[2];
380 UINT64 f30[2];
381 UINT64 f31[2];
382 } EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT;
383
384 typedef union {
385 EFI_SMI_OPTIONAL_FPSAVE_STATE Ia32FpSave;
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 //
441 // System Management System Table (SMST)
442 //
443 struct _EFI_SMM_SYSTEM_TABLE {
444 EFI_TABLE_HEADER Hdr;
445
446 CHAR16 *SmmFirmwareVendor;
447 UINT32 SmmFirmwareRevision;
448
449 EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;
450
451 //
452 // I/O Services
453 //
454 EFI_GUID EfiSmmCpuIoGuid;
455 EFI_SMM_CPU_IO_INTERFACE SmmIo;
456
457 //
458 // Runtime memory service
459 //
460 EFI_SMMCORE_ALLOCATE_POOL SmmAllocatePool;
461 EFI_SMMCORE_FREE_POOL SmmFreePool;
462 EFI_SMMCORE_ALLOCATE_PAGES SmmAllocatePages;
463 EFI_SMMCORE_FREE_PAGES SmmFreePages;
464
465 //
466 // MP service
467 //
468 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;
469
470 //
471 // CPU information records
472 //
473 UINTN CurrentlyExecutingCpu;
474 UINTN NumberOfCpus;
475 EFI_SMM_CPU_SAVE_STATE *CpuSaveState;
476 EFI_SMM_FLOATING_POINT_SAVE_STATE *CpuOptionalFloatingPointState;
477
478 //
479 // Extensibility table
480 //
481 UINTN NumberOfTableEntries;
482 EFI_CONFIGURATION_TABLE *SmmConfigurationTable;
483
484 };
485
486 #include <Guid/SmmCommunicate.h>
487 #include <Guid/SmramMemoryReserve.h>
488 #include <Protocol/SmmBase.h>
489 #include <Protocol/SmmAccess.h>
490 #include <Protocol/SmmControl.h>
491 #include <Protocol/SmmGpiDispatch.h>
492 #include <Protocol/SmmIchnDispatch.h>
493 #include <Protocol/SmmPeriodicTimerDispatch.h>
494 #include <Protocol/SmmPowerButtonDispatch.h>
495 #include <Protocol/SmmStandbyButtonDispatch.h>
496 #include <Protocol/SmmStatusCode.h>
497 #include <Protocol/SmmSwDispatch.h>
498 #include <Protocol/SmmSxDispatch.h>
499 #include <Protocol/SmmUsbDispatch.h>
500
501 extern EFI_GUID gEfiSmmCpuIoGuid;
502
503 #endif