3 Copyright (c) 1999 - 2006, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 This file defines SMM Base abstraction protocol defined by the SMM Architecture
20 Specification. This is the base level of compatiblity for SMM drivers.
27 #include EFI_PROTOCOL_DEFINITION (DevicePath)
29 #define EFI_SMM_BASE_PROTOCOL_GUID \
31 0x1390954D, 0xda95, 0x4227, {0x93, 0x28, 0x72, 0x82, 0xc2, 0x17, 0xda, 0xa8} \
34 #define EFI_SMM_CPU_IO_GUID \
36 0x5f439a0b, 0x45d8, 0x4682, {0xa4, 0xf4, 0xf0, 0x57, 0x6b, 0x51, 0x34, 0x41} \
39 #define SMM_COMMUNICATE_HEADER_GUID \
41 0xF328E36C, 0x23B6, 0x4a95, {0x85, 0x4B, 0x32, 0xE1, 0x95, 0x34, 0xCD, 0x75} \
45 // SMM Base specification constant and types
47 #define SMM_SMST_SIGNATURE EFI_SIGNATURE_32 ('S', 'M', 'S', 'T')
48 #define EFI_SMM_SYSTEM_TABLE_REVISION (0 << 16) | (0x09)
50 EFI_FORWARD_DECLARATION (EFI_SMM_BASE_PROTOCOL
);
51 EFI_FORWARD_DECLARATION (EFI_SMM_CPU_IO_INTERFACE
);
52 EFI_FORWARD_DECLARATION (EFI_SMM_CPU_SAVE_STATE
);
53 EFI_FORWARD_DECLARATION (EFI_SMM_OPTIONAL_FP_SAVE_STATE
);
54 EFI_FORWARD_DECLARATION (EFI_SMM_SYSTEM_TABLE
);
57 // *******************************************************
59 // *******************************************************
69 // *******************************************************
71 // *******************************************************
75 (EFIAPI
*EFI_SMM_CPU_IO
) (
76 IN EFI_SMM_CPU_IO_INTERFACE
* This
,
77 IN EFI_SMM_IO_WIDTH Width
,
88 struct _EFI_SMM_CPU_IO_INTERFACE
{
89 EFI_SMM_IO_ACCESS Mem
;
95 (EFIAPI
*EFI_SMMCORE_ALLOCATE_POOL
) (
96 IN EFI_MEMORY_TYPE PoolType
,
103 (EFIAPI
*EFI_SMMCORE_FREE_POOL
) (
109 (EFIAPI
*EFI_SMMCORE_ALLOCATE_PAGES
) (
110 IN EFI_ALLOCATE_TYPE Type
,
111 IN EFI_MEMORY_TYPE MemoryType
,
112 IN UINTN NumberOfPages
,
113 OUT EFI_PHYSICAL_ADDRESS
* Memory
118 (EFIAPI
*EFI_SMMCORE_FREE_PAGES
) (
119 IN EFI_PHYSICAL_ADDRESS Memory
,
120 IN UINTN NumberOfPages
125 (EFIAPI
*EFI_AP_PROCEDURE
) (
131 (EFIAPI
*EFI_SMM_STARTUP_THIS_AP
) (
132 IN EFI_AP_PROCEDURE Procedure
,
134 IN OUT VOID
*ProcArguments OPTIONAL
137 struct _EFI_SMM_CPU_SAVE_STATE
{
138 UINT8 Reserved1
[248];
142 UINT16 AutoHALTRestart
;
143 UINT8 Reserved2
[164];
169 UINT8 Reserved19
[760]; // FC00
170 UINT32 SMBASE
; // FEF8
171 UINT32 REVID
; // FEFC
172 UINT16 HALT_RESTART
; // FF00
173 UINT16 IO_RESTART
; // FF02
174 UINT32 Reserved17
[22]; // FF58, 54, 50, 4c, 48, 44, 40, 3c, 38, 34, 30, 2c, 28, 24, 20, 1c, 18, 14, 10, 0c, 08, 04
176 UINT32 Reserved16
; // FF60
178 UINT32 Reserved15
; // FF68
180 UINT32 Reserved14
; // FF70
182 UINT32 Reserved13
; // FF78
184 UINT32 Reserved12
; // FF80
186 UINT32 Reserved11
; // FF88
188 UINT32 Reserved9
; // FF90
190 UINT32 Reserved8
; // FF98
191 UINT32 IO_MEM_ADDR
; // FF9C
192 UINT32 Reserved7
; // FFA0
193 UINT32 IO_MISC
; // FFA4
194 UINT32 ES_SEL
; // FFA8
195 UINT32 CS_SEL
; // FFAC
196 UINT32 SS_SEL
; // FFB0
197 UINT32 DS_SEL
; // FFB4
198 UINT32 FS_SEL
; // FFB8
199 UINT32 GS_SEL
; // FFBC
200 UINT32 LDTR_SEL
; // FFC0
201 UINT32 TR_SEL
; // FFC4
203 UINT32 Reserved6
; // FFCC
205 UINT32 Reserved5
; // FFD4
207 UINT32 Reserved4
; // FFDC
209 UINT32 Reserved3
; // FFE4
210 UINT32 EFLAGS
; // FFE8
211 UINT32 Reserved2
; // FFEC
213 UINT32 Reserved1
; // FFF4
215 UINT32 Reserved0
; // FFFC
216 } EFI_SMM_CPU_CT_SAVE_STATE
;
219 UINT8 Reserved26
[464]; // FC00 - FDCF
220 UINT32 GdtrUpperBase
; // FDD0
221 UINT32 LdtrUpperBase
; // FDD4
222 UINT32 IdtrUpperBase
; // FDD8
223 UINT32 Reserved25
; // FDDC - FDDF
224 UINT64 IoRdi
; // FDE0
225 UINT64 IoRip
; // FDE8
226 UINT64 IoRcx
; // FDF0
227 UINT64 IoRsi
; // FDF8
228 UINT8 Reserved24
[64]; // FE00 - FE3F
230 UINT8 Reserved23
[68]; // FE48 - FE8B
231 UINT32 GdtrBase
; // FE8C
232 UINT32 Reserved22
; // FE90
233 UINT32 IdtrBase
; // FE94
234 UINT32 Reserved21
; // FE98
235 UINT32 LdtrBase
; // FE9C
236 UINT32 Reserved20
; // FEA0
237 UINT8 Reserved19
[84]; // FEA4 - FEF7
238 UINT32 Smbase
; // FEF8
239 UINT32 RevId
; // FEFC
240 UINT16 IoRestart
; // FF00
241 UINT16 HaltRestart
; // FF02
242 UINT8 Reserved18
[24]; // FF04 - FF1B
244 UINT32 Reserved17
; // FE20
246 UINT32 Reserved16
; // FE28
248 UINT32 Reserved15
; // FE30
250 UINT32 Reserved14
; // FE38
252 UINT32 Reserved13
; // FE40
254 UINT32 Reserved12
; // FE48
256 UINT32 Reserved11
; // FE50
258 UINT32 Reserved10
; // FE58
260 UINT32 Reserved9
; // FE60
262 UINT32 Reserved8
; // FE68
264 UINT32 Reserved7
; // FE70
266 UINT32 Reserved6
; // FE78
268 UINT32 Reserved5
; // FE80
270 UINT32 Reserved4
; // FE88
272 UINT32 Reserved3
; // FE90
274 UINT32 Reserved2
; // FE98
275 UINT32 IoMemAddr
; // FF9C
276 UINT32 Reserved1
; // FEA0
277 UINT32 IoMiscInfo
; // FFA4
278 UINT32 EsSel
; // FFA8
279 UINT32 CsSel
; // FFAC
280 UINT32 SsSel
; // FFB0
281 UINT32 DsSel
; // FFB4
282 UINT32 FsSel
; // FFB8
283 UINT32 GsSel
; // FFBC
284 UINT32 LdtrSel
; // FFC0
285 UINT32 TrSel
; // FFC4
289 UINT32 Reserved0
; // FFDC
291 UINT64 RFlags
; // FFE8
294 } EFI_SMM_CPU_MEROM_SAVE_STATE
;
298 UINT8 Reserved14
[0x228]; // FC00-FE28
299 UINT32 IO_EIP
; // FE28
300 UINT8 Reserved13
[0x14]; // FE2C-FE40
302 UINT8 Reserved12
[0x48]; // FE44-FE8C
303 UINT32 GDT_BASE
; // FE8C
304 UINT8 Reserved11
[0xC]; // FE90-FE9C
305 UINT32 LDT_BASE
; // FE9C
306 UINT8 Reserved10
[0x58]; // FEA0-FEF8
311 UINT8 Reserved9
[0xA4];
342 } EFI_SMM_CPU_CT_NOT_ENABLED_SAVE_STATE
;
344 struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE
{
355 UINT8 St0Mm0
[10], Rsvd3
[6];
356 UINT8 St0Mm1
[10], Rsvd4
[6];
357 UINT8 St0Mm2
[10], Rsvd5
[6];
358 UINT8 St0Mm3
[10], Rsvd6
[6];
359 UINT8 St0Mm4
[10], Rsvd7
[6];
360 UINT8 St0Mm5
[10], Rsvd8
[6];
361 UINT8 St0Mm6
[10], Rsvd9
[6];
362 UINT8 St0Mm7
[10], Rsvd10
[6];
363 UINT8 Rsvd11
[22 * 16];
366 typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE32
{
377 UINT8 St0Mm0
[10], Rsvd3
[6];
378 UINT8 St1Mm1
[10], Rsvd4
[6];
379 UINT8 St2Mm2
[10], Rsvd5
[6];
380 UINT8 St3Mm3
[10], Rsvd6
[6];
381 UINT8 St4Mm4
[10], Rsvd7
[6];
382 UINT8 St5Mm5
[10], Rsvd8
[6];
383 UINT8 St6Mm6
[10], Rsvd9
[6];
384 UINT8 St7Mm7
[10], Rsvd10
[6];
393 UINT8 Rsvd11
[14 * 16];
394 } EFI_SMM_OPTIONAL_FP_SAVE_STATE32
;
396 typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE64
{
404 UINT8 St0Mm0
[10], Rsvd2
[6];
405 UINT8 St1Mm1
[10], Rsvd3
[6];
406 UINT8 St2Mm2
[10], Rsvd4
[6];
407 UINT8 St3Mm3
[10], Rsvd5
[6];
408 UINT8 St4Mm4
[10], Rsvd6
[6];
409 UINT8 St5Mm5
[10], Rsvd7
[6];
410 UINT8 St6Mm6
[10], Rsvd8
[6];
411 UINT8 St7Mm7
[10], Rsvd9
[6];
428 UINT8 Rsvd10
[6 * 16];
429 } EFI_SMM_OPTIONAL_FP_SAVE_STATE64
;
431 struct _EFI_SMM_SYSTEM_TABLE
;
435 (EFIAPI
*EFI_SMM_INSTALL_CONFIGURATION_TABLE
) (
436 IN EFI_SMM_SYSTEM_TABLE
* SystemTable
,
444 The SmmInstallConfigurationTable() function is used to maintain the list
445 of configuration tables that are stored in the System Management System
446 Table. The list is stored as an array of (GUID, Pointer) pairs. The list
447 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
450 SystemTable - A pointer to the SMM System Table.
451 Guid - A pointer to the GUID for the entry to add, update, or remove.
452 Table - A pointer to the buffer of the table to add.
453 TableSize - The size of the table to install.
456 EFI_SUCCESS - The (Guid, Table) pair was added, updated, or removed.
457 EFI_INVALID_PARAMETER - Guid is not valid.
458 EFI_NOT_FOUND - An attempt was made to delete a non-existent entry.
459 EFI_OUT_OF_RESOURCES - There is not enough memory available to complete the operation.
465 // System Management System Table (SMST)
467 struct _EFI_SMM_SYSTEM_TABLE
{
468 EFI_TABLE_HEADER Hdr
;
470 CHAR16
*SmmFirmwareVendor
;
471 UINT32 SmmFirmwareRevision
;
473 EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable
;
478 EFI_GUID EfiSmmCpuIoGuid
;
479 EFI_SMM_CPU_IO_INTERFACE SmmIo
;
482 // Runtime memory service
484 EFI_SMMCORE_ALLOCATE_POOL SmmAllocatePool
;
485 EFI_SMMCORE_FREE_POOL SmmFreePool
;
486 EFI_SMMCORE_ALLOCATE_PAGES SmmAllocatePages
;
487 EFI_SMMCORE_FREE_PAGES SmmFreePages
;
492 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp
;
495 // CPU information records
497 UINTN CurrentlyExecutingCpu
;
499 EFI_SMM_CPU_SAVE_STATE
*CpuSaveState
;
500 EFI_SMM_OPTIONAL_FP_SAVE_STATE
*CpuOptionalFloatingPointState
;
503 // Extensibility table
505 UINTN NumberOfTableEntries
;
506 EFI_CONFIGURATION_TABLE
*SmmConfigurationTable
;
511 // SMM Handler Definition
513 #define EFI_HANDLER_SUCCESS 0x0000
514 #define EFI_HANDLER_CRITICAL_EXIT 0x0001
515 #define EFI_HANDLER_SOURCE_QUIESCED 0x0002
516 #define EFI_HANDLER_SOURCE_PENDING 0x0003
519 // Structure of Communicate Buffer
525 } EFI_SMM_COMMUNICATE_HEADER
;
529 (EFIAPI
*EFI_SMM_HANDLER_ENTRY_POINT
) (
530 IN EFI_HANDLE SmmImageHandle
,
531 IN OUT VOID
*CommunicationBuffer OPTIONAL
,
532 IN OUT UINTN
*SourceSize OPTIONAL
537 (EFIAPI
*EFI_SMM_CALLBACK_ENTRY_POINT
) (
538 IN EFI_HANDLE SmmImageHandle
,
539 IN OUT VOID
*CommunicationBuffer OPTIONAL
,
540 IN OUT UINTN
*SourceSize OPTIONAL
544 EFI_HANDLE SmmHandler
;
545 EFI_DEVICE_PATH_PROTOCOL
*HandlerDevicePath
;
546 } EFI_HANDLER_DESCRIPTOR
;
549 // SMM Base Protocol Definition
553 (EFIAPI
*EFI_SMM_REGISTER_HANDLER
) (
554 IN EFI_SMM_BASE_PROTOCOL
* This
,
555 IN EFI_DEVICE_PATH_PROTOCOL
* FilePath
,
556 IN VOID
*SourceBuffer OPTIONAL
,
558 OUT EFI_HANDLE
* ImageHandle
,
559 IN BOOLEAN LegacyIA32Binary OPTIONAL
564 Register a given driver into SMRAM. This is the equivalent of performing
565 the LoadImage/StartImage into System Management Mode.
568 This - Protocol instance pointer.
569 SourceBuffer - Optional source buffer in case of the image file
571 SourceSize - Size of the source image file, if in memory.
572 ImageHandle - Pointer to the handle that reflects the driver
574 LegacyIA32Binary - The binary image to load is legacy 16 bit code.
577 EFI_SUCCESS - The operation was successful.
578 EFI_OUT_OF_RESOURCES - There were no additional SMRAM resources to load the handler
579 EFI_UNSUPPORTED - This platform does not support 16-bit handlers.
580 EFI_UNSUPPORTED - In runtime.
581 EFI_INVALID_PARAMETER - The handlers was not the correct image type
588 (EFIAPI
*EFI_SMM_UNREGISTER_HANDLER
) (
589 IN EFI_SMM_BASE_PROTOCOL
* This
,
590 IN EFI_HANDLE ImageHandle
595 Remove a given driver SMRAM. This is the equivalent of performing
596 the UnloadImage System Management Mode.
599 This - Protocol instance pointer.
600 ImageHandle - Pointer to the handle that reflects the driver
604 EFI_SUCCESS - The operation was successful
605 EFI_INVALID_PARAMETER - The handler did not exist
606 EFI_UNSUPPORTED - In runtime.
613 (EFIAPI
*EFI_SMM_COMMUNICATE
) (
614 IN EFI_SMM_BASE_PROTOCOL
* This
,
615 IN EFI_HANDLE ImageHandle
,
616 IN OUT VOID
*CommunicationBuffer
,
617 IN OUT UINTN
*SourceSize
622 The SMM Inter-module Communicate Service Communicate() function
623 provides a services to send/received messages from a registered
624 EFI service. The BASE protocol driver is responsible for doing
625 any of the copies such that the data lives in boot-service accessible RAM.
628 This - Protocol instance pointer.
629 ImageHandle - Pointer to the handle that reflects the driver
631 CommunicationBuffer - Pointer to the buffer to convey into SMRAM.
632 SourceSize - Size of the contents of buffer..
635 EFI_SUCCESS - The message was successfully posted
636 EFI_INVALID_PARAMETER - The buffer was NULL
643 (EFIAPI
*EFI_SMM_CALLBACK_SERVICE
) (
644 IN EFI_SMM_BASE_PROTOCOL
* This
,
645 IN EFI_HANDLE SmmImageHandle
,
646 IN EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress
,
647 IN BOOLEAN MakeLast OPTIONAL
,
648 IN BOOLEAN FloatingPointSave OPTIONAL
653 Register a callback to execute within SMM.
654 This allows receipt of messages created with the Boot Service COMMUNICATE.
657 This - Protocol instance pointer.
658 CallbackAddress - Address of the callback service
659 MakeFirst - If present, will stipulate that the handler is posted
660 to be the first module executed in the dispatch table.
661 MakeLast - If present, will stipulate that the handler is posted
662 to be last executed in the dispatch table.
663 FloatingPointSave - This is an optional parameter which informs the
664 EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save
665 the floating point register state. If any of the handlers
666 require this, then the state will be saved for all of the handlers.
669 EFI_SUCCESS - The operation was successful
670 EFI_OUT_OF_RESOURCES - Not enough space in the dispatch queue
671 EFI_UNSUPPORTED - In runtime.
672 EFI_UNSUPPORTED - Not in SMM.
679 (EFIAPI
*EFI_SMM_ALLOCATE_POOL
) (
680 IN EFI_SMM_BASE_PROTOCOL
* This
,
681 IN EFI_MEMORY_TYPE PoolType
,
688 The SmmAllocatePool() function allocates a memory region of Size bytes from memory of
689 type PoolType and returns the address of the allocated memory in the location referenced
690 by Buffer. This function allocates pages from EFI SMRAM Memory as needed to grow the
691 requested pool type. All allocations are eight-byte aligned.
694 This - Protocol instance pointer.
695 PoolType - The type of pool to allocate.
696 The only supported type is EfiRuntimeServicesData;
697 the interface will internally map this runtime request to SMRAM.
698 Size - The number of bytes to allocate from the pool.
699 Buffer - A pointer to a pointer to the allocated buffer if the call
700 succeeds; undefined otherwise.
703 EFI_SUCCESS - The requested number of bytes was allocated.
704 EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
705 EFI_INVALID_PARAMETER - PoolType was invalid.
706 EFI_UNSUPPORTED - In runtime.
713 (EFIAPI
*EFI_SMM_FREE_POOL
) (
714 IN EFI_SMM_BASE_PROTOCOL
* This
,
720 The SmmFreePool() function returns the memory specified by Buffer to the system.
721 On return, the memory's type is EFI SMRAM Memory. The Buffer that is freed must
722 have been allocated by SmmAllocatePool().
725 This - Protocol instance pointer.
726 Buffer - Pointer to the buffer allocation.
729 EFI_SUCCESS - The memory was returned to the system.
730 EFI_INVALID_PARAMETER - Buffer was invalid.
731 EFI_UNSUPPORTED - In runtime.
738 (EFIAPI
*EFI_SMM_INSIDE_OUT
) (
739 IN EFI_SMM_BASE_PROTOCOL
* This
,
745 This routine tells caller if execution context is SMM or not.
748 This - Protocol instance pointer.
751 EFI_SUCCESS - The operation was successful
758 (EFIAPI
*EFI_SMM_GET_SMST_LOCATION
) (
759 IN EFI_SMM_BASE_PROTOCOL
* This
,
760 IN OUT EFI_SMM_SYSTEM_TABLE
**Smst
765 The GetSmstLocation() function returns the locatin of the System Management
766 Service Table. The use of the API is such that a driver can discover the
767 location of the SMST in its entry point and then cache it in some driver
768 global variable so that the SMST can be invoked in subsequent callbacks.
771 This - Protocol instance pointer.
772 Smst - Pointer to the SMST.
775 EFI_SUCCESS - The operation was successful
776 EFI_INVALID_PARAMETER - Smst was invalid.
777 EFI_UNSUPPORTED - Not in SMM.
782 struct _EFI_SMM_BASE_PROTOCOL
{
783 EFI_SMM_REGISTER_HANDLER Register
;
784 EFI_SMM_UNREGISTER_HANDLER UnRegister
;
785 EFI_SMM_COMMUNICATE Communicate
;
786 EFI_SMM_CALLBACK_SERVICE RegisterCallback
;
787 EFI_SMM_INSIDE_OUT InSmm
;
788 EFI_SMM_ALLOCATE_POOL SmmAllocatePool
;
789 EFI_SMM_FREE_POOL SmmFreePool
;
790 EFI_SMM_GET_SMST_LOCATION GetSmstLocation
;
793 extern EFI_GUID gEfiSmmBaseProtocolGuid
;
794 extern EFI_GUID gEfiSmmCpuIoGuid
;
795 extern EFI_GUID gEfiSmmCommunicateHeaderGuid
;