]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | EsalServiceLib.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | --*/\r | |
19 | \r | |
20 | #include <Ipf/IpfDefines.h>\r | |
21 | \r | |
22 | \r | |
23 | STATIC EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService;\r | |
c25aaa00 | 24 | STATIC EFI_PLABEL mPlabel;\r |
878ddf1f | 25 | \r |
26 | EFI_STATUS\r | |
27 | EFIAPI\r | |
28 | DxeSalLibConstruct (\r | |
29 | IN EFI_HANDLE ImageHandle,\r | |
30 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
31 | )\r | |
32 | {\r | |
c25aaa00 | 33 | EFI_PLABEL *Plabel;\r |
34 | EFI_STATUS Status;\r | |
878ddf1f | 35 | \r |
c25aaa00 | 36 | //\r |
37 | // The protocol contains a function pointer, which is an indirect procedure call.\r | |
38 | // An indirect procedure call goes through a plabel, and pointer to a function is\r | |
39 | // a pointer to a plabel. To implement indirect procedure calls that can work in\r | |
40 | // both physical and virtual mode, two plabels are required (one physical and one\r | |
41 | // virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it\r | |
42 | // away. We cache it in a module global, so we can register the vitrual version.\r | |
43 | //\r | |
44 | Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);\r | |
878ddf1f | 45 | ASSERT_EFI_ERROR (Status);\r |
46 | \r | |
c25aaa00 | 47 | Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;\r |
48 | \r | |
49 | mPlabel.EntryPoint = Plabel->EntryPoint;\r | |
50 | mPlabel.GP = Plabel->GP;\r | |
51 | SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r | |
52 | \r | |
878ddf1f | 53 | return Status;\r |
54 | }\r | |
55 | \r | |
c25aaa00 | 56 | VOID\r |
57 | EFIAPI\r | |
58 | DxeSalVirtualNotifyEvent (\r | |
59 | IN EFI_EVENT Event,\r | |
60 | IN VOID *Context\r | |
61 | )\r | |
62 | /*++\r | |
63 | \r | |
64 | Routine Description:\r | |
65 | \r | |
66 | Fixup virtual address pointer of label.\r | |
67 | \r | |
68 | Arguments:\r | |
69 | \r | |
70 | Event - The Event that is being processed\r | |
71 | \r | |
72 | Context - Event Context\r | |
73 | \r | |
74 | Returns: \r | |
75 | \r | |
76 | None\r | |
77 | \r | |
78 | --*/\r | |
79 | {\r | |
80 | EfiConvertPointer (0x0, (VOID **) &mPlabel.EntryPoint);\r | |
81 | EfiConvertPointer (EFI_IPF_GP_POINTER, (VOID **) &mPlabel.GP);\r | |
82 | \r | |
83 | SetEsalVirtualEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r | |
84 | }\r | |
85 | \r | |
878ddf1f | 86 | EFI_STATUS\r |
56836fe9 | 87 | EFIAPI\r |
878ddf1f | 88 | RegisterEsalFunction (\r |
89 | IN UINT64 FunctionId,\r | |
90 | IN EFI_GUID *ClassGuid,\r | |
91 | IN SAL_INTERNAL_EXTENDED_SAL_PROC Function,\r | |
92 | IN VOID *ModuleGlobal\r | |
93 | )\r | |
94 | /*++\r | |
95 | \r | |
96 | Routine Description:\r | |
97 | \r | |
98 | Register ESAL Class Function and it's asociated global.\r | |
99 | This function is boot service only!\r | |
100 | \r | |
101 | Arguments:\r | |
102 | FunctionId - ID of function to register\r | |
103 | ClassGuid - GUID of function class \r | |
104 | Function - Function to register under ClassGuid/FunctionId pair\r | |
105 | ModuleGlobal - Module global for Function.\r | |
106 | \r | |
107 | Returns: \r | |
108 | EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.\r | |
109 | \r | |
110 | --*/\r | |
111 | {\r | |
112 | return mEsalBootService->AddExtendedSalProc (\r | |
113 | mEsalBootService,\r | |
114 | ClassGuid,\r | |
115 | FunctionId,\r | |
116 | Function,\r | |
117 | ModuleGlobal\r | |
118 | );\r | |
119 | }\r | |
120 | \r | |
121 | EFI_STATUS\r | |
56836fe9 | 122 | EFIAPI\r |
878ddf1f | 123 | RegisterEsalClass (\r |
124 | IN EFI_GUID *ClassGuid,\r | |
125 | IN VOID *ModuleGlobal,\r | |
126 | ...\r | |
127 | )\r | |
128 | /*++\r | |
129 | \r | |
130 | Routine Description:\r | |
131 | \r | |
132 | Register ESAL Class and it's asociated global.\r | |
133 | This function is boot service only!\r | |
134 | \r | |
135 | Arguments:\r | |
136 | ClassGuid - GUID of function class \r | |
137 | ModuleGlobal - Module global for Function.\r | |
138 | ... - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL \r | |
139 | indicates the end of the list.\r | |
140 | \r | |
141 | Returns: \r | |
142 | EFI_SUCCESS - All members of ClassGuid registered\r | |
143 | \r | |
144 | --*/\r | |
145 | {\r | |
146 | VA_LIST Args;\r | |
147 | EFI_STATUS Status;\r | |
148 | SAL_INTERNAL_EXTENDED_SAL_PROC Function;\r | |
149 | UINT64 FunctionId;\r | |
150 | EFI_HANDLE NewHandle;\r | |
151 | \r | |
152 | VA_START (Args, ModuleGlobal);\r | |
153 | \r | |
154 | Status = EFI_SUCCESS;\r | |
155 | while (!EFI_ERROR (Status)) {\r | |
156 | Function = (SAL_INTERNAL_EXTENDED_SAL_PROC) VA_ARG (Args, SAL_INTERNAL_EXTENDED_SAL_PROC);\r | |
157 | if (Function == NULL) {\r | |
158 | break;\r | |
159 | }\r | |
160 | \r | |
161 | FunctionId = VA_ARG (Args, UINT64);\r | |
162 | \r | |
163 | Status = RegisterEsalFunction (FunctionId, ClassGuid, Function, ModuleGlobal);\r | |
164 | }\r | |
165 | \r | |
166 | if (EFI_ERROR (Status)) {\r | |
167 | return Status;\r | |
168 | }\r | |
169 | \r | |
170 | NewHandle = NULL;\r | |
171 | return gBS->InstallProtocolInterface (\r | |
172 | &NewHandle,\r | |
173 | ClassGuid,\r | |
174 | EFI_NATIVE_INTERFACE,\r | |
175 | NULL\r | |
176 | );\r | |
177 | }\r | |
178 | \r | |
179 | SAL_RETURN_REGS\r | |
56836fe9 | 180 | EFIAPI\r |
878ddf1f | 181 | EfiCallEsalService (\r |
182 | IN EFI_GUID *ClassGuid,\r | |
183 | IN UINT64 FunctionId,\r | |
184 | IN UINT64 Arg2,\r | |
185 | IN UINT64 Arg3,\r | |
186 | IN UINT64 Arg4,\r | |
187 | IN UINT64 Arg5,\r | |
188 | IN UINT64 Arg6,\r | |
189 | IN UINT64 Arg7,\r | |
190 | IN UINT64 Arg8\r | |
191 | )\r | |
192 | /*++\r | |
193 | \r | |
194 | Routine Description:\r | |
195 | \r | |
196 | Call module that is not linked direclty to this module. This code is IP \r | |
197 | relative and hides the binding issues of virtual or physical calling. The\r | |
198 | function that gets dispatched has extra arguments that include the registered\r | |
199 | module global and a boolean flag to indicate if the system is in virutal mode.\r | |
200 | \r | |
201 | Arguments:\r | |
202 | ClassGuid - GUID of function\r | |
203 | FunctionId - Function in ClassGuid to call\r | |
204 | Arg2 - Argument 2 ClassGuid/FunctionId defined\r | |
205 | Arg3 - Argument 3 ClassGuid/FunctionId defined\r | |
206 | Arg4 - Argument 4 ClassGuid/FunctionId defined\r | |
207 | Arg5 - Argument 5 ClassGuid/FunctionId defined\r | |
208 | Arg6 - Argument 6 ClassGuid/FunctionId defined\r | |
209 | Arg7 - Argument 7 ClassGuid/FunctionId defined\r | |
210 | Arg8 - Argument 8 ClassGuid/FunctionId defined\r | |
211 | \r | |
212 | Returns: \r | |
213 | Status of ClassGuid/FuncitonId\r | |
214 | \r | |
215 | --*/\r | |
216 | {\r | |
217 | SAL_RETURN_REGS ReturnReg;\r | |
218 | SAL_EXTENDED_SAL_PROC EsalProc;\r | |
219 | \r | |
220 | ReturnReg = GetEsalEntryPoint ();\r | |
221 | if (ReturnReg.Status != EFI_SAL_SUCCESS) {\r | |
222 | return ReturnReg;\r | |
223 | }\r | |
224 | \r | |
225 | if (ReturnReg.r11 & PSR_IT_MASK) {\r | |
226 | //\r | |
227 | // Virtual mode plabel to entry point\r | |
228 | //\r | |
229 | EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r10;\r | |
230 | } else {\r | |
231 | //\r | |
232 | // Physical mode plabel to entry point\r | |
233 | //\r | |
234 | EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r9;\r | |
235 | }\r | |
236 | \r | |
237 | return EsalProc (\r | |
238 | ClassGuid,\r | |
239 | FunctionId,\r | |
240 | Arg2,\r | |
241 | Arg3,\r | |
242 | Arg4,\r | |
243 | Arg5,\r | |
244 | Arg6,\r | |
245 | Arg7,\r | |
246 | Arg8\r | |
247 | );\r | |
248 | }\r |