]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Dxe/SmmCis.h
Only include SmmCis.h if the CPU Arch is IA32 or X64
[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 EFI_STATUS
171 (EFIAPI *EFI_SMM_STARTUP_THIS_AP) (
172 IN EFI_AP_PROCEDURE Procedure,
173 IN UINTN CpuNumber,
174 IN OUT VOID *ProcArguments OPTIONAL
175 );
176
177 typedef struct {
178 UINT8 Reserved1[248];
179 UINT32 SMBASE;
180 UINT32 SMMRevId;
181 UINT16 IORestart;
182 UINT16 AutoHALTRestart;
183 UINT8 Reserved2[164];
184 UINT32 ES;
185 UINT32 CS;
186 UINT32 SS;
187 UINT32 DS;
188 UINT32 FS;
189 UINT32 GS;
190 UINT32 LDTBase;
191 UINT32 TR;
192 UINT32 DR7;
193 UINT32 DR6;
194 UINT32 EAX;
195 UINT32 ECX;
196 UINT32 EDX;
197 UINT32 EBX;
198 UINT32 ESP;
199 UINT32 EBP;
200 UINT32 ESI;
201 UINT32 EDI;
202 UINT32 EIP;
203 UINT32 EFLAGS;
204 UINT32 CR3;
205 UINT32 CR0;
206 } EFI_SMI_CPU_SAVE_STATE;
207
208 typedef struct {
209 UINT64 reserved;
210 UINT64 r1;
211 UINT64 r2;
212 UINT64 r3;
213 UINT64 r4;
214 UINT64 r5;
215 UINT64 r6;
216 UINT64 r7;
217 UINT64 r8;
218 UINT64 r9;
219 UINT64 r10;
220 UINT64 r11;
221 UINT64 r12;
222 UINT64 r13;
223 UINT64 r14;
224 UINT64 r15;
225 UINT64 r16;
226 UINT64 r17;
227 UINT64 r18;
228 UINT64 r19;
229 UINT64 r20;
230 UINT64 r21;
231 UINT64 r22;
232 UINT64 r23;
233 UINT64 r24;
234 UINT64 r25;
235 UINT64 r26;
236 UINT64 r27;
237 UINT64 r28;
238 UINT64 r29;
239 UINT64 r30;
240 UINT64 r31;
241
242 UINT64 pr;
243
244 UINT64 b0;
245 UINT64 b1;
246 UINT64 b2;
247 UINT64 b3;
248 UINT64 b4;
249 UINT64 b5;
250 UINT64 b6;
251 UINT64 b7;
252
253 // application registers
254 UINT64 ar_rsc;
255 UINT64 ar_bsp;
256 UINT64 ar_bspstore;
257 UINT64 ar_rnat;
258
259 UINT64 ar_fcr;
260
261 UINT64 ar_eflag;
262 UINT64 ar_csd;
263 UINT64 ar_ssd;
264 UINT64 ar_cflg;
265 UINT64 ar_fsr;
266 UINT64 ar_fir;
267 UINT64 ar_fdr;
268
269 UINT64 ar_ccv;
270
271 UINT64 ar_unat;
272
273 UINT64 ar_fpsr;
274
275 UINT64 ar_pfs;
276 UINT64 ar_lc;
277 UINT64 ar_ec;
278
279 // control registers
280 UINT64 cr_dcr;
281 UINT64 cr_itm;
282 UINT64 cr_iva;
283 UINT64 cr_pta;
284 UINT64 cr_ipsr;
285 UINT64 cr_isr;
286 UINT64 cr_iip;
287 UINT64 cr_ifa;
288 UINT64 cr_itir;
289 UINT64 cr_iipa;
290 UINT64 cr_ifs;
291 UINT64 cr_iim;
292 UINT64 cr_iha;
293
294 // debug registers
295 UINT64 dbr0;
296 UINT64 dbr1;
297 UINT64 dbr2;
298 UINT64 dbr3;
299 UINT64 dbr4;
300 UINT64 dbr5;
301 UINT64 dbr6;
302 UINT64 dbr7;
303
304 UINT64 ibr0;
305 UINT64 ibr1;
306 UINT64 ibr2;
307 UINT64 ibr3;
308 UINT64 ibr4;
309 UINT64 ibr5;
310 UINT64 ibr6;
311 UINT64 ibr7;
312
313 // virtual registers
314 UINT64 int_nat; // nat bits for R1-R31
315
316 } EFI_PMI_SYSTEM_CONTEXT;
317
318 typedef union {
319 EFI_SMI_CPU_SAVE_STATE Ia32SaveState;
320 EFI_PMI_SYSTEM_CONTEXT ItaniumSaveState;
321 } EFI_SMM_CPU_SAVE_STATE;
322
323 typedef struct {
324 UINT16 Fcw;
325 UINT16 Fsw;
326 UINT16 Ftw;
327 UINT16 Opcode;
328 UINT32 Eip;
329 UINT16 Cs;
330 UINT16 Rsvd1;
331 UINT32 DataOffset;
332 UINT16 Ds;
333 UINT8 Rsvd2[10];
334 UINT8 St0Mm0[10], Rsvd3[6];
335 UINT8 St0Mm1[10], Rsvd4[6];
336 UINT8 St0Mm2[10], Rsvd5[6];
337 UINT8 St0Mm3[10], Rsvd6[6];
338 UINT8 St0Mm4[10], Rsvd7[6];
339 UINT8 St0Mm5[10], Rsvd8[6];
340 UINT8 St0Mm6[10], Rsvd9[6];
341 UINT8 St0Mm7[10], Rsvd10[6];
342 UINT8 Rsvd11[22*16];
343 } EFI_SMI_OPTIONAL_FPSAVE_STATE;
344
345 typedef struct {
346 UINT64 f2[2];
347 UINT64 f3[2];
348 UINT64 f4[2];
349 UINT64 f5[2];
350 UINT64 f6[2];
351 UINT64 f7[2];
352 UINT64 f8[2];
353 UINT64 f9[2];
354 UINT64 f10[2];
355 UINT64 f11[2];
356 UINT64 f12[2];
357 UINT64 f13[2];
358 UINT64 f14[2];
359 UINT64 f15[2];
360 UINT64 f16[2];
361 UINT64 f17[2];
362 UINT64 f18[2];
363 UINT64 f19[2];
364 UINT64 f20[2];
365 UINT64 f21[2];
366 UINT64 f22[2];
367 UINT64 f23[2];
368 UINT64 f24[2];
369 UINT64 f25[2];
370 UINT64 f26[2];
371 UINT64 f27[2];
372 UINT64 f28[2];
373 UINT64 f29[2];
374 UINT64 f30[2];
375 UINT64 f31[2];
376 } EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT;
377
378 typedef union {
379 EFI_SMI_OPTIONAL_FPSAVE_STATE Ia32FpSave;
380 EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT ItaniumFpSave;
381 } EFI_SMM_FLOATING_POINT_SAVE_STATE;
382
383 /**
384 This function is the main entry point for an SMM handler dispatch
385 or communicate-based callback.
386
387 @param SmmImageHandle A unique value returned by the SMM infrastructure
388 in response to registration for a communicate-based callback or dispatch.
389 @param CommunicationBuffer
390 An optional buffer that will be populated
391 by the SMM infrastructure in response to a non-SMM agent (preboot or runtime)
392 invoking the EFI_SMM_BASE_PROTOCOL.Communicate() service.
393 @param SourceSize If CommunicationBuffer is non-NULL, this field
394 indicates the size of the data payload in this buffer.
395
396 @return Status Code
397
398 **/
399 typedef
400 EFI_STATUS
401 (EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT) (
402 IN EFI_HANDLE SmmImageHandle,
403 IN OUT VOID *CommunicationBuffer OPTIONAL,
404 IN OUT UINTN *SourceSize OPTIONAL
405 );
406
407 /**
408 The SmmInstallConfigurationTable() function is used to maintain the list
409 of configuration tables that are stored in the System Management System
410 Table. The list is stored as an array of (GUID, Pointer) pairs. The list
411 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
412
413 @param SystemTable A pointer to the SMM System Table.
414 @param Guid A pointer to the GUID for the entry to add, update, or remove.
415 @param Table A pointer to the buffer of the table to add.
416 @param TableSize The size of the table to install.
417
418 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
419 @retval EFI_INVALID_PARAMETER Guid is not valid.
420 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
421 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
422
423 **/
424 typedef
425 EFI_STATUS
426 (EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE) (
427 IN EFI_SMM_SYSTEM_TABLE *SystemTable,
428 IN EFI_GUID *Guid,
429 IN VOID *Table,
430 IN UINTN TableSize
431 )
432 ;
433
434 //
435 // System Management System Table (SMST)
436 //
437 struct _EFI_SMM_SYSTEM_TABLE {
438 EFI_TABLE_HEADER Hdr;
439
440 CHAR16 *SmmFirmwareVendor;
441 UINT32 SmmFirmwareRevision;
442
443 EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;
444
445 //
446 // I/O Services
447 //
448 EFI_GUID EfiSmmCpuIoGuid;
449 EFI_SMM_CPU_IO_INTERFACE SmmIo;
450
451 //
452 // Runtime memory service
453 //
454 EFI_SMMCORE_ALLOCATE_POOL SmmAllocatePool;
455 EFI_SMMCORE_FREE_POOL SmmFreePool;
456 EFI_SMMCORE_ALLOCATE_PAGES SmmAllocatePages;
457 EFI_SMMCORE_FREE_PAGES SmmFreePages;
458
459 //
460 // MP service
461 //
462 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;
463
464 //
465 // CPU information records
466 //
467 UINTN CurrentlyExecutingCpu;
468 UINTN NumberOfCpus;
469 EFI_SMM_CPU_SAVE_STATE *CpuSaveState;
470 EFI_SMM_FLOATING_POINT_SAVE_STATE *CpuOptionalFloatingPointState;
471
472 //
473 // Extensibility table
474 //
475 UINTN NumberOfTableEntries;
476 EFI_CONFIGURATION_TABLE *SmmConfigurationTable;
477
478 };
479
480 #include <Guid/SmmCommunicate.h>
481 #include <Guid/SmramMemoryReserve.h>
482 #include <Protocol/SmmBase.h>
483 #include <Protocol/SmmAccess.h>
484 #include <Protocol/SmmControl.h>
485 #include <Protocol/SmmGpiDispatch.h>
486 #include <Protocol/SmmIchnDispatch.h>
487 #include <Protocol/SmmPeriodicTimerDispatch.h>
488 #include <Protocol/SmmPowerButtonDispatch.h>
489 #include <Protocol/SmmStandbyButtonDispatch.h>
490 #include <Protocol/SmmStatusCode.h>
491 #include <Protocol/SmmSwDispatch.h>
492 #include <Protocol/SmmSxDispatch.h>
493 #include <Protocol/SmmUsbDispatch.h>
494
495 extern EFI_GUID gEfiSmmCpuIoGuid;
496
497 #endif