]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/SmmBaseOnSmmBase2Thunk/SmmBaseOnSmmBase2Thunk.h
Per Framework SMM CIS spec, SMM Base Protocol.Communicate() is availabe in runtime...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / SmmBaseOnSmmBase2Thunk / SmmBaseOnSmmBase2Thunk.h
1 /** @file
2 Include file for SMM Base Protocol on SMM Base2 Protocol Thunk driver.
3
4 Copyright (c) 2009 - 2010, 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 **/
14
15 #ifndef _SMM_BASE_ON_SMM_BASE2_THUNK_H_
16 #define _SMM_BASE_ON_SMM_BASE2_THUNK_H_
17
18 #include <PiDxe.h>
19 #include <FrameworkSmm.h>
20 #include <Library/DebugLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/UefiLib.h>
24 #include <Library/UefiRuntimeLib.h>
25 #include <Guid/SmmBaseThunkCommunication.h>
26 #include <Guid/EventGroup.h>
27 #include <Protocol/SmmBase2.h>
28 #include <Protocol/SmmCommunication.h>
29 #include <Protocol/SmmBaseHelperReady.h>
30
31 /**
32 Register a given driver into SMRAM. This is the equivalent of performing
33 the LoadImage/StartImage into System Management Mode.
34
35 @param[in] This Protocol instance pointer.
36 @param[in] FilePath Location of the image to be installed as the handler.
37 @param[in] SourceBuffer Optional source buffer in case the image file
38 is in memory.
39 @param[in] SourceSize Size of the source image file, if in memory.
40 @param[out] ImageHandle The handle that the base driver uses to decode
41 the handler. Unique among SMM handlers only,
42 not unique across DXE/EFI.
43 @param[in] LegacyIA32Binary An optional parameter specifying that the associated
44 file is a real-mode IA-32 binary.
45
46 @retval EFI_SUCCESS The operation was successful.
47 @retval EFI_OUT_OF_RESOURCES There were no additional SMRAM resources to load the handler
48 @retval EFI_UNSUPPORTED This platform does not support 16-bit handlers.
49 @retval EFI_UNSUPPORTED Platform is in runtime.
50 @retval EFI_INVALID_PARAMETER The handlers was not the correct image type
51 **/
52 EFI_STATUS
53 EFIAPI
54 SmmBaseRegister (
55 IN EFI_SMM_BASE_PROTOCOL *This,
56 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
57 IN VOID *SourceBuffer,
58 IN UINTN SourceSize,
59 OUT EFI_HANDLE *ImageHandle,
60 IN BOOLEAN LegacyIA32Binary
61 );
62
63 /**
64 Removes a handler from execution within SMRAM. This is the equivalent of performing
65 the UnloadImage in System Management Mode.
66
67 @param[in] This Protocol instance pointer.
68 @param[in] ImageHandle The handler to be removed.
69
70 @retval EFI_SUCCESS The operation was successful
71 @retval EFI_INVALID_PARAMETER The handler did not exist
72 @retval EFI_UNSUPPORTED Platform is in runtime.
73 **/
74 EFI_STATUS
75 EFIAPI
76 SmmBaseUnregister (
77 IN EFI_SMM_BASE_PROTOCOL *This,
78 IN EFI_HANDLE ImageHandle
79 );
80
81 /**
82 The SMM Inter-module Communicate Service Communicate() function
83 provides a service to send/receive messages from a registered
84 EFI service. The BASE protocol driver is responsible for doing
85 any of the copies such that the data lives in boot-service-accessible RAM.
86
87 @param[in] This Protocol instance pointer.
88 @param[in] ImageHandle The handle of the registered driver.
89 @param[in,out] CommunicationBuffer Pointer to the buffer to convey into SMRAM.
90 @param[in,out] BufferSize The size of the data buffer being passed in.
91 On exit, the size of data being returned.
92 Zero if the handler does not wish to reply with any data.
93
94 @retval EFI_SUCCESS The message was successfully posted
95 @retval EFI_INVALID_PARAMETER The buffer was NULL
96 **/
97 EFI_STATUS
98 EFIAPI
99 SmmBaseCommunicate (
100 IN EFI_SMM_BASE_PROTOCOL *This,
101 IN EFI_HANDLE ImageHandle,
102 IN OUT VOID *CommunicationBuffer,
103 IN OUT UINTN *BufferSize
104 );
105
106 /**
107 Register a callback to execute within SMM.
108 This allows receipt of messages created with EFI_SMM_BASE_PROTOCOL.Communicate().
109
110 @param[in] This Protocol instance pointer.
111 @param[in] SmmImageHandle Handle of the callback service.
112 @param[in] CallbackAddress Address of the callback service.
113 @param[in] MakeLast If present, will stipulate that the handler is posted to
114 be executed last in the dispatch table.
115 @param[in] FloatingPointSave An optional parameter that informs the
116 EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save
117 the floating point register state. If any handler
118 require this, the state will be saved for all handlers.
119
120 @retval EFI_SUCCESS The operation was successful
121 @retval EFI_OUT_OF_RESOURCES Not enough space in the dispatch queue
122 @retval EFI_UNSUPPORTED Platform is in runtime.
123 @retval EFI_UNSUPPORTED The caller is not in SMM.
124 **/
125 EFI_STATUS
126 EFIAPI
127 SmmBaseRegisterCallback (
128 IN EFI_SMM_BASE_PROTOCOL *This,
129 IN EFI_HANDLE SmmImageHandle,
130 IN EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress,
131 IN BOOLEAN MakeLast,
132 IN BOOLEAN FloatingPointSave
133 );
134
135 /**
136 This routine tells caller if execution context is SMM or not.
137
138 @param[in] This Protocol instance pointer.
139 @param[out] InSmm Whether the caller is inside SMM for IA-32
140 or servicing a PMI for the Itanium processor
141 family.
142
143 @retval EFI_SUCCESS The operation was successful
144 @retval EFI_INVALID_PARAMETER InSmm was NULL.
145 **/
146 EFI_STATUS
147 EFIAPI
148 SmmBaseInSmm (
149 IN EFI_SMM_BASE_PROTOCOL *This,
150 OUT BOOLEAN *InSmm
151 );
152
153 /**
154 The SmmAllocatePool() function allocates a memory region of Size bytes from memory of
155 type PoolType and returns the address of the allocated memory in the location referenced
156 by Buffer. This function allocates pages from EFI SMRAM Memory as needed to grow the
157 requested pool type. All allocations are eight-byte aligned.
158
159 @param[in] This Protocol instance pointer.
160 @param[in] PoolType The type of pool to allocate.
161 The only supported type is EfiRuntimeServicesData;
162 the interface will internally map this runtime request to
163 SMRAM for IA-32 and leave as this type for the Itanium
164 processor family. Other types can be ignored.
165 @param[in] Size The number of bytes to allocate from the pool.
166 @param[out] Buffer A pointer to a pointer to the allocated buffer if the call
167 succeeds; undefined otherwise.
168
169 @retval EFI_SUCCESS The requested number of bytes was allocated.
170 @retval EFI_OUT_OF_RESOURCES The pool requested could not be allocated.
171 @retval EFI_UNSUPPORTED Platform is in runtime.
172 **/
173 EFI_STATUS
174 EFIAPI
175 SmmBaseSmmAllocatePool (
176 IN EFI_SMM_BASE_PROTOCOL *This,
177 IN EFI_MEMORY_TYPE PoolType,
178 IN UINTN Size,
179 OUT VOID **Buffer
180 );
181
182 /**
183 The SmmFreePool() function returns the memory specified by Buffer to the system.
184 On return, the memory's type is EFI SMRAM Memory. The Buffer that is freed must
185 have been allocated by SmmAllocatePool().
186
187 @param[in] This Protocol instance pointer.
188 @param[in] Buffer Pointer to the buffer allocation.
189
190 @retval EFI_SUCCESS The memory was returned to the system.
191 @retval EFI_INVALID_PARAMETER Buffer was invalid.
192 @retval EFI_UNSUPPORTED Platform is in runtime.
193 **/
194 EFI_STATUS
195 EFIAPI
196 SmmBaseSmmFreePool (
197 IN EFI_SMM_BASE_PROTOCOL *This,
198 IN VOID *Buffer
199 );
200
201 /**
202 The GetSmstLocation() function returns the location of the System Management
203 Service Table. The use of the API is such that a driver can discover the
204 location of the SMST in its entry point and then cache it in some driver
205 global variable so that the SMST can be invoked in subsequent callbacks.
206
207 @param[in] This Protocol instance pointer.
208 @param[in] Smst Pointer to the SMST.
209
210 @retval EFI_SUCCESS The operation was successful
211 @retval EFI_INVALID_PARAMETER Smst was invalid.
212 @retval EFI_UNSUPPORTED Not in SMM.
213 **/
214 EFI_STATUS
215 EFIAPI
216 SmmBaseGetSmstLocation (
217 IN EFI_SMM_BASE_PROTOCOL *This,
218 OUT EFI_SMM_SYSTEM_TABLE **Smst
219 );
220
221 #endif