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