]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/TianoTools/Include/Dxe/SmmCis.h
35a1a64682b4143c52c74cba57841a0a2e588377
[mirror_edk2.git] / Tools / Source / TianoTools / 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
56 @param Width Signifies the width of the I/O operations.
57
58 @param Address The base address of the I/O operations.
59
60 @param Count The number of I/O operations to perform.
61
62 @param Buffer For read operations, the destination buffer to store the results.
63 For write operations, the source buffer from which to write data.
64
65 @retval EFI_SUCCESS The data was read from or written to the device.
66
67 @retval EFI_UNSUPPORTED The Address is not valid for this system.
68
69 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
70
71 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
72
73 **/
74 typedef
75 EFI_STATUS
76 (EFIAPI *EFI_SMM_CPU_IO) (
77 IN EFI_SMM_CPU_IO_INTERFACE *This,
78 IN EFI_SMM_IO_WIDTH Width,
79 IN UINT64 Address,
80 IN UINTN Count,
81 IN OUT VOID *Buffer
82 );
83
84 typedef struct {
85 EFI_SMM_CPU_IO Read;
86 EFI_SMM_CPU_IO Write;
87 } EFI_SMM_IO_ACCESS;
88
89 struct _EFI_SMM_CPU_IO_INTERFACE {
90 EFI_SMM_IO_ACCESS Mem;
91 EFI_SMM_IO_ACCESS Io;
92 };
93
94 /**
95 Allocates pool memory from SMRAM for IA-32 or runtime memory for
96 the Itanium processor family.
97
98 @param PoolType The type of pool to allocate.The only supported type is EfiRuntimeServicesData
99
100 @param Size The number of bytes to allocate from the pool.
101
102 @param Buffer A pointer to a pointer to the allocated buffer if the call
103 succeeds; undefined otherwise.
104
105 @retval EFI_SUCCESS The requested number of bytes was allocated.
106
107 @retval EFI_OUT_OF_RESOURCES The pool requested could not be allocated.
108
109 @retval EFI_UNSUPPORTED In runtime.
110
111 **/
112 typedef
113 EFI_STATUS
114 (EFIAPI *EFI_SMMCORE_ALLOCATE_POOL) (
115 IN EFI_MEMORY_TYPE PoolType,
116 IN UINTN Size,
117 OUT VOID **Buffer
118 );
119
120 /**
121 Returns pool memory to the system.
122
123 @param Buffer Pointer to the buffer to free.
124
125 @retval EFI_SUCCESS The memory was returned to the system.
126
127 @retval EFI_INVALID_PARAMETER Buffer was invalid.
128
129 @retval EFI_UNSUPPORTED In runtime.
130
131 **/
132 typedef
133 EFI_STATUS
134 (EFIAPI *EFI_SMMCORE_FREE_POOL) (
135 IN VOID *Buffer
136 );
137
138 /**
139 Allocates memory pages from the system.
140
141 @param Type The type of allocation to perform.
142
143 @param MemoryType The only supported type is EfiRuntimeServicesData
144
145 @param NumberofPages The number of contiguous 4 KB pages to allocate
146
147 @param Memory Pointer to a physical address. On input, the way in which
148 the address is used depends on the value of Type. On output, the address
149 is set to the base of the page range that was allocated.
150
151 @retval EFI_SUCCESS The requested pages were allocated.
152
153 @retval EFI_OUT_OF_RESOURCES The pages requested could not be allocated.
154
155 @retval EFI_NOT_FOUND The requested pages could not be found.
156
157 @retval EFI_INVALID_PARAMETER Type is not AllocateAnyPages or AllocateMaxAddress
158 or AllocateAddress. Or MemoryType is in the range EfiMaxMemoryType..0x7FFFFFFF.
159
160 **/
161 typedef
162 EFI_STATUS
163 (EFIAPI *EFI_SMMCORE_ALLOCATE_PAGES) (
164 IN EFI_ALLOCATE_TYPE Type,
165 IN EFI_MEMORY_TYPE MemoryType,
166 IN UINTN NumberOfPages,
167 OUT EFI_PHYSICAL_ADDRESS *Memory
168 );
169
170 /**
171 Frees memory pages for the system.
172
173 @param Memory The base physical address of the pages to be freed
174
175 @param NumberOfPages The number of contiguous 4 KB pages to free.
176
177 @retval EFI_SUCCESS The requested memory pages were freed.
178
179 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or NumberOfPages is invalid.
180
181 @retval EFI_NOT_FOUND The requested memory pages were not allocated with SmmAllocatePages().
182
183 **/
184 typedef
185 EFI_STATUS
186 (EFIAPI *EFI_SMMCORE_FREE_PAGES) (
187 IN EFI_PHYSICAL_ADDRESS Memory,
188 IN UINTN NumberOfPages
189 );
190
191 typedef
192 VOID
193 (EFIAPI *EFI_AP_PROCEDURE) (
194 IN VOID *Buffer
195 );
196
197 typedef
198 EFI_STATUS
199 (EFIAPI *EFI_SMM_STARTUP_THIS_AP) (
200 IN EFI_AP_PROCEDURE Procedure,
201 IN UINTN CpuNumber,
202 IN OUT VOID *ProcArguments OPTIONAL
203 );
204
205 typedef struct {
206 UINT8 Reserved1[248];
207 UINT32 SMBASE;
208 UINT32 SMMRevId;
209 UINT16 IORestart;
210 UINT16 AutoHALTRestart;
211 UINT8 Reserved2[164];
212 UINT32 ES;
213 UINT32 CS;
214 UINT32 SS;
215 UINT32 DS;
216 UINT32 FS;
217 UINT32 GS;
218 UINT32 LDTBase;
219 UINT32 TR;
220 UINT32 DR7;
221 UINT32 DR6;
222 UINT32 EAX;
223 UINT32 ECX;
224 UINT32 EDX;
225 UINT32 EBX;
226 UINT32 ESP;
227 UINT32 EBP;
228 UINT32 ESI;
229 UINT32 EDI;
230 UINT32 EIP;
231 UINT32 EFLAGS;
232 UINT32 CR3;
233 UINT32 CR0;
234 } EFI_SMI_CPU_SAVE_STATE;
235
236 typedef struct {
237 UINT64 reserved;
238 UINT64 r1;
239 UINT64 r2;
240 UINT64 r3;
241 UINT64 r4;
242 UINT64 r5;
243 UINT64 r6;
244 UINT64 r7;
245 UINT64 r8;
246 UINT64 r9;
247 UINT64 r10;
248 UINT64 r11;
249 UINT64 r12;
250 UINT64 r13;
251 UINT64 r14;
252 UINT64 r15;
253 UINT64 r16;
254 UINT64 r17;
255 UINT64 r18;
256 UINT64 r19;
257 UINT64 r20;
258 UINT64 r21;
259 UINT64 r22;
260 UINT64 r23;
261 UINT64 r24;
262 UINT64 r25;
263 UINT64 r26;
264 UINT64 r27;
265 UINT64 r28;
266 UINT64 r29;
267 UINT64 r30;
268 UINT64 r31;
269
270 UINT64 pr;
271
272 UINT64 b0;
273 UINT64 b1;
274 UINT64 b2;
275 UINT64 b3;
276 UINT64 b4;
277 UINT64 b5;
278 UINT64 b6;
279 UINT64 b7;
280
281 // application registers
282 UINT64 ar_rsc;
283 UINT64 ar_bsp;
284 UINT64 ar_bspstore;
285 UINT64 ar_rnat;
286
287 UINT64 ar_fcr;
288
289 UINT64 ar_eflag;
290 UINT64 ar_csd;
291 UINT64 ar_ssd;
292 UINT64 ar_cflg;
293 UINT64 ar_fsr;
294 UINT64 ar_fir;
295 UINT64 ar_fdr;
296
297 UINT64 ar_ccv;
298
299 UINT64 ar_unat;
300
301 UINT64 ar_fpsr;
302
303 UINT64 ar_pfs;
304 UINT64 ar_lc;
305 UINT64 ar_ec;
306
307 // control registers
308 UINT64 cr_dcr;
309 UINT64 cr_itm;
310 UINT64 cr_iva;
311 UINT64 cr_pta;
312 UINT64 cr_ipsr;
313 UINT64 cr_isr;
314 UINT64 cr_iip;
315 UINT64 cr_ifa;
316 UINT64 cr_itir;
317 UINT64 cr_iipa;
318 UINT64 cr_ifs;
319 UINT64 cr_iim;
320 UINT64 cr_iha;
321
322 // debug registers
323 UINT64 dbr0;
324 UINT64 dbr1;
325 UINT64 dbr2;
326 UINT64 dbr3;
327 UINT64 dbr4;
328 UINT64 dbr5;
329 UINT64 dbr6;
330 UINT64 dbr7;
331
332 UINT64 ibr0;
333 UINT64 ibr1;
334 UINT64 ibr2;
335 UINT64 ibr3;
336 UINT64 ibr4;
337 UINT64 ibr5;
338 UINT64 ibr6;
339 UINT64 ibr7;
340
341 // virtual registers
342 UINT64 int_nat; // nat bits for R1-R31
343
344 } EFI_PMI_SYSTEM_CONTEXT;
345
346 typedef union {
347 EFI_SMI_CPU_SAVE_STATE Ia32SaveState;
348 EFI_PMI_SYSTEM_CONTEXT ItaniumSaveState;
349 } EFI_SMM_CPU_SAVE_STATE;
350
351 typedef struct {
352 UINT16 Fcw;
353 UINT16 Fsw;
354 UINT16 Ftw;
355 UINT16 Opcode;
356 UINT32 Eip;
357 UINT16 Cs;
358 UINT16 Rsvd1;
359 UINT32 DataOffset;
360 UINT16 Ds;
361 UINT8 Rsvd2[10];
362 UINT8 St0Mm0[10], Rsvd3[6];
363 UINT8 St0Mm1[10], Rsvd4[6];
364 UINT8 St0Mm2[10], Rsvd5[6];
365 UINT8 St0Mm3[10], Rsvd6[6];
366 UINT8 St0Mm4[10], Rsvd7[6];
367 UINT8 St0Mm5[10], Rsvd8[6];
368 UINT8 St0Mm6[10], Rsvd9[6];
369 UINT8 St0Mm7[10], Rsvd10[6];
370 UINT8 Rsvd11[22*16];
371 } EFI_SMI_OPTIONAL_FPSAVE_STATE;
372
373 typedef struct {
374 UINT64 f2[2];
375 UINT64 f3[2];
376 UINT64 f4[2];
377 UINT64 f5[2];
378 UINT64 f6[2];
379 UINT64 f7[2];
380 UINT64 f8[2];
381 UINT64 f9[2];
382 UINT64 f10[2];
383 UINT64 f11[2];
384 UINT64 f12[2];
385 UINT64 f13[2];
386 UINT64 f14[2];
387 UINT64 f15[2];
388 UINT64 f16[2];
389 UINT64 f17[2];
390 UINT64 f18[2];
391 UINT64 f19[2];
392 UINT64 f20[2];
393 UINT64 f21[2];
394 UINT64 f22[2];
395 UINT64 f23[2];
396 UINT64 f24[2];
397 UINT64 f25[2];
398 UINT64 f26[2];
399 UINT64 f27[2];
400 UINT64 f28[2];
401 UINT64 f29[2];
402 UINT64 f30[2];
403 UINT64 f31[2];
404 } EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT;
405
406 typedef union {
407 EFI_SMI_OPTIONAL_FPSAVE_STATE Ia32FpSave;
408 EFI_PMI_OPTIONAL_FLOATING_POINT_CONTEXT ItaniumFpSave;
409 } EFI_SMM_FLOATING_POINT_SAVE_STATE;
410
411 /**
412 This function is the main entry point for an SMM handler dispatch
413 or communicate-based callback.
414
415 @param SmmImageHandle A unique value returned by the SMM infrastructure
416 in response to registration for a communicate-based callback or dispatch.
417
418 @param CommunicationBuffer An optional buffer that will be populated
419 by the SMM infrastructure in response to a non-SMM agent (preboot or runtime)
420 invoking the EFI_SMM_BASE_PROTOCOL.Communicate() service.
421
422 @param SourceSize If CommunicationBuffer is non-NULL, this field
423 indicates the size of the data payload in this buffer.
424
425 @return Status Code
426
427 **/
428 typedef
429 EFI_STATUS
430 (EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT) (
431 IN EFI_HANDLE SmmImageHandle,
432 IN OUT VOID *CommunicationBuffer OPTIONAL,
433 IN OUT UINTN *SourceSize OPTIONAL
434 );
435
436 /**
437 The SmmInstallConfigurationTable() function is used to maintain the list
438 of configuration tables that are stored in the System Management System
439 Table. The list is stored as an array of (GUID, Pointer) pairs. The list
440 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
441
442 @param SystemTable A pointer to the SMM System Table.
443 @param Guid A pointer to the GUID for the entry to add, update, or remove.
444 @param Table A pointer to the buffer of the table to add.
445 @param TableSize The size of the table to install.
446
447 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
448 @retval EFI_INVALID_PARAMETER Guid is not valid.
449 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
450 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
451
452 **/
453 typedef
454 EFI_STATUS
455 (EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE) (
456 IN EFI_SMM_SYSTEM_TABLE *SystemTable,
457 IN EFI_GUID *Guid,
458 IN VOID *Table,
459 IN UINTN TableSize
460 )
461 ;
462
463 //
464 // System Management System Table (SMST)
465 //
466 struct _EFI_SMM_SYSTEM_TABLE {
467 EFI_TABLE_HEADER Hdr;
468
469 CHAR16 *SmmFirmwareVendor;
470 UINT32 SmmFirmwareRevision;
471
472 EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;
473
474 //
475 // I/O Services
476 //
477 EFI_GUID EfiSmmCpuIoGuid;
478 EFI_SMM_CPU_IO_INTERFACE SmmIo;
479
480 //
481 // Runtime memory service
482 //
483 EFI_SMMCORE_ALLOCATE_POOL SmmAllocatePool;
484 EFI_SMMCORE_FREE_POOL SmmFreePool;
485 EFI_SMMCORE_ALLOCATE_PAGES SmmAllocatePages;
486 EFI_SMMCORE_FREE_PAGES SmmFreePages;
487
488 //
489 // MP service
490 //
491 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;
492
493 //
494 // CPU information records
495 //
496 UINTN CurrentlyExecutingCpu;
497 UINTN NumberOfCpus;
498 EFI_SMM_CPU_SAVE_STATE *CpuSaveState;
499 EFI_SMM_FLOATING_POINT_SAVE_STATE *CpuOptionalFloatingPointState;
500
501 //
502 // Extensibility table
503 //
504 UINTN NumberOfTableEntries;
505 EFI_CONFIGURATION_TABLE *SmmConfigurationTable;
506
507 };
508
509 #include <Guid/SmmCommunicate.h>
510 #include <Guid/SmramMemoryReserve.h>
511 #include <Protocol/SmmBase.h>
512 #include <Protocol/SmmAccess.h>
513 #include <Protocol/SmmControl.h>
514 #include <Protocol/SmmGpiDispatch.h>
515 #include <Protocol/SmmIchnDispatch.h>
516 #include <Protocol/SmmPeriodicTimerDispatch.h>
517 #include <Protocol/SmmPowerButtonDispatch.h>
518 #include <Protocol/SmmStandbyButtonDispatch.h>
519 #include <Protocol/SmmStatusCode.h>
520 #include <Protocol/SmmSwDispatch.h>
521 #include <Protocol/SmmSxDispatch.h>
522 #include <Protocol/SmmUsbDispatch.h>
523
524 extern EFI_GUID gEfiSmmCpuIoGuid;
525
526 #endif