]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeExtendedSalLib/ExtendedSalLib.c
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Library / DxeExtendedSalLib / ExtendedSalLib.c
CommitLineData
863be5d0 1/** @file\r
2 The library implements the Extended SAL Library Class for boot service only modules.\r
3\r
9095d37b 4 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
863be5d0 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php.\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PiDxe.h>\r
16\r
17#include <Protocol/ExtendedSalBootService.h>\r
18#include <Protocol/ExtendedSalServiceClasses.h>\r
19\r
20#include <Library/ExtendedSalLib.h>\r
21#include <Library/UefiBootServicesTableLib.h>\r
22#include <Library/DebugLib.h>\r
23\r
24/**\r
25 Stores the physical plabel of ESAL entrypoint.\r
26\r
27 This assembly function stores the physical plabel of ESAL entrypoint\r
28 where GetEsalEntryPoint() can easily retrieve.\r
29\r
30 @param EntryPoint Physical address of ESAL entrypoint\r
31 @param Gp Physical GP of ESAL entrypoint\r
32\r
33 @return r8 = EFI_SAL_SUCCESS\r
34\r
35**/\r
36SAL_RETURN_REGS\r
37EFIAPI\r
38SetEsalPhysicalEntryPoint (\r
39 IN UINT64 EntryPoint,\r
40 IN UINT64 Gp\r
41 );\r
42\r
43/**\r
44 Retrieves plabel of ESAL entrypoint.\r
45\r
46 This function retrives plabel of ESAL entrypoint stored by\r
47 SetEsalPhysicalEntryPoint().\r
48\r
49 @return r8 = EFI_SAL_SUCCESS\r
50 r9 = Physical Plabel\r
51 r10 = Virtual Plabel\r
52 r11 = PSR\r
53\r
54**/\r
55SAL_RETURN_REGS\r
56EFIAPI\r
57GetEsalEntryPoint (\r
58 VOID\r
59 );\r
60\r
61EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService = NULL;\r
62EFI_PLABEL mPlabel;\r
63\r
64/**\r
65 Constructor function to get Extended SAL Boot Service Protocol, and initializes\r
66 physical plabel of ESAL entrypoint.\r
9095d37b 67\r
863be5d0 68 This function first locates Extended SAL Boot Service Protocol and caches it in global variable.\r
69 Then it initializes the physical plable of ESAL entrypoint, and stores\r
70 it where GetEsalEntryPoint() can easily retrieve.\r
71\r
72 @param ImageHandle The firmware allocated handle for the EFI image.\r
73 @param SystemTable A pointer to the EFI System Table.\r
74\r
75 @retval EFI_SUCCESS Plable of ESAL entrypoint successfully stored.\r
76\r
77**/\r
78EFI_STATUS\r
79EFIAPI\r
80DxeExtendedSalLibConstruct (\r
81 IN EFI_HANDLE ImageHandle,\r
82 IN EFI_SYSTEM_TABLE *SystemTable\r
83 )\r
84{\r
85 EFI_PLABEL *Plabel;\r
86 EFI_STATUS Status;\r
87\r
88 //\r
89 // The protocol contains a function pointer, which is an indirect procedure call.\r
90 // An indirect procedure call goes through a plabel, and pointer to a function is\r
91 // a pointer to a plabel. To implement indirect procedure calls that can work in\r
92 // both physical and virtual mode, two plabels are required (one physical and one\r
93 // virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it\r
94 // away. We cache it in a module global, so we can register the vitrual version.\r
95 //\r
96 Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, (VOID **) &mEsalBootService);\r
97 ASSERT_EFI_ERROR (Status);\r
98\r
99 Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;\r
100 mPlabel.EntryPoint = Plabel->EntryPoint;\r
101 mPlabel.GP = Plabel->GP;\r
102 //\r
103 // Stores the physical plabel of ESAL entrypoint where GetEsalEntryPoint() can easily retrieve.\r
104 //\r
105 SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r
106\r
107 return EFI_SUCCESS;\r
108}\r
109\r
110/**\r
111 Registers function of ESAL class and it's associated global.\r
9095d37b 112\r
863be5d0 113 This function registers function of ESAL class, together with its associated global.\r
114 It is worker function for RegisterEsalClass().\r
115 It is only for boot time.\r
116\r
117 @param FunctionId ID of function to register\r
118 @param ClassGuidLo GUID of ESAL class, lower 64-bits\r
119 @param ClassGuidHi GUID of ESAL class, upper 64-bits\r
120 @param Function Function to register with ClassGuid/FunctionId pair\r
121 @param ModuleGlobal Module global for the function.\r
122\r
123 @return Status returned by RegisterExtendedSalProc() of Extended SAL Boot Service Protocol\r
124\r
125**/\r
126EFI_STATUS\r
127RegisterEsalFunction (\r
128 IN UINT64 FunctionId,\r
129 IN UINT64 ClassGuidLo,\r
130 IN UINT64 ClassGuidHi,\r
131 IN SAL_INTERNAL_EXTENDED_SAL_PROC Function,\r
132 IN VOID *ModuleGlobal\r
133 )\r
134{\r
135 return mEsalBootService->RegisterExtendedSalProc (\r
136 mEsalBootService,\r
137 ClassGuidLo,\r
138 ClassGuidHi,\r
139 FunctionId,\r
140 Function,\r
141 ModuleGlobal\r
142 );\r
143}\r
144\r
145/**\r
146 Registers ESAL Class and it's associated global.\r
9095d37b 147\r
863be5d0 148 This function registers one or more Extended SAL services in a given\r
149 class along with the associated global context.\r
150 This function is only available prior to ExitBootServices().\r
151\r
152 @param ClassGuidLo GUID of function class, lower 64-bits\r
153 @param ClassGuidHi GUID of function class, upper 64-bits\r
154 @param ModuleGlobal Module global for the class.\r
155 @param ... List of Function/FunctionId pairs, ended by NULL\r
9095d37b 156\r
863be5d0 157 @retval EFI_SUCCESS The Extended SAL services were registered.\r
158 @retval EFI_UNSUPPORTED This function was called after ExitBootServices().\r
159 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to register one or more of the specified services.\r
9095d37b 160 @retval Other ClassGuid could not be installed onto a new handle.\r
863be5d0 161\r
162**/\r
163EFI_STATUS\r
164EFIAPI\r
165RegisterEsalClass (\r
166 IN CONST UINT64 ClassGuidLo,\r
167 IN CONST UINT64 ClassGuidHi,\r
168 IN VOID *ModuleGlobal, OPTIONAL\r
169 ...\r
170 )\r
171{\r
172 VA_LIST Args;\r
173 EFI_STATUS Status;\r
174 SAL_INTERNAL_EXTENDED_SAL_PROC Function;\r
175 UINT64 FunctionId;\r
176 EFI_HANDLE NewHandle;\r
177 EFI_GUID ClassGuid;\r
178\r
179 VA_START (Args, ModuleGlobal);\r
180\r
181 //\r
182 // Register all functions of the class to register.\r
183 //\r
184 Status = EFI_SUCCESS;\r
185 while (!EFI_ERROR (Status)) {\r
186 Function = (SAL_INTERNAL_EXTENDED_SAL_PROC) VA_ARG (Args, SAL_INTERNAL_EXTENDED_SAL_PROC);\r
187 //\r
188 // NULL serves as the end mark of function list\r
189 //\r
190 if (Function == NULL) {\r
191 break;\r
192 }\r
193\r
194 FunctionId = VA_ARG (Args, UINT64);\r
195\r
196 Status = RegisterEsalFunction (FunctionId, ClassGuidLo, ClassGuidHi, Function, ModuleGlobal);\r
197 }\r
198\r
3bbe68a3 199 VA_END (Args);\r
200\r
863be5d0 201 if (EFI_ERROR (Status)) {\r
202 return Status;\r
203 }\r
204\r
205 NewHandle = NULL;\r
206 *((UINT64 *)(&ClassGuid) + 0) = ClassGuidLo;\r
207 *((UINT64 *)(&ClassGuid) + 1) = ClassGuidHi;\r
208 return gBS->InstallProtocolInterface (\r
209 &NewHandle,\r
210 &ClassGuid,\r
211 EFI_NATIVE_INTERFACE,\r
212 NULL\r
213 );\r
214}\r
215\r
216/**\r
217 Calls an Extended SAL Class service that was previously registered with RegisterEsalClass().\r
9095d37b 218\r
863be5d0 219 This function gets the entrypoint of Extended SAL, and calls an Extended SAL Class service\r
220 that was previously registered with RegisterEsalClass() through this entrypoint.\r
221\r
222 @param ClassGuidLo GUID of function, lower 64-bits\r
223 @param ClassGuidHi GUID of function, upper 64-bits\r
224 @param FunctionId Function in ClassGuid to call\r
225 @param Arg2 Argument 2 ClassGuid/FunctionId defined\r
226 @param Arg3 Argument 3 ClassGuid/FunctionId defined\r
227 @param Arg4 Argument 4 ClassGuid/FunctionId defined\r
228 @param Arg5 Argument 5 ClassGuid/FunctionId defined\r
229 @param Arg6 Argument 6 ClassGuid/FunctionId defined\r
230 @param Arg7 Argument 7 ClassGuid/FunctionId defined\r
231 @param Arg8 Argument 8 ClassGuid/FunctionId defined\r
9095d37b 232\r
863be5d0 233 @retval EFI_SAL_SUCCESS ESAL procedure successfully called.\r
234 @retval EFI_SAL_ERROR The address of ExtendedSalProc() can not be correctly\r
235 initialized.\r
236 @retval Other Status returned from ExtendedSalProc() service of\r
9095d37b 237 EXTENDED_SAL_BOOT_SERVICE_PROTOCOL.\r
863be5d0 238\r
239**/\r
240SAL_RETURN_REGS\r
241EFIAPI\r
242EsalCall (\r
243 IN UINT64 ClassGuidLo,\r
244 IN UINT64 ClassGuidHi,\r
245 IN UINT64 FunctionId,\r
246 IN UINT64 Arg2,\r
247 IN UINT64 Arg3,\r
248 IN UINT64 Arg4,\r
249 IN UINT64 Arg5,\r
250 IN UINT64 Arg6,\r
251 IN UINT64 Arg7,\r
252 IN UINT64 Arg8\r
253 )\r
254{\r
255 SAL_RETURN_REGS ReturnReg;\r
256 EXTENDED_SAL_PROC EsalProc;\r
257\r
258 //\r
259 // Get the entrypoint of Extended SAL\r
260 //\r
261 ReturnReg = GetEsalEntryPoint ();\r
262 if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) {\r
263 //\r
264 // The ESAL Entry Point could not be initialized\r
265 //\r
266 ReturnReg.Status = EFI_SAL_ERROR;\r
267 return ReturnReg;\r
268 }\r
269\r
270 //\r
271 // Test PSR.it which is BIT36\r
272 //\r
273 if ((ReturnReg.r11 & BIT36) != 0) {\r
274 //\r
275 // Virtual mode plabel to entry point\r
276 //\r
277 EsalProc = (EXTENDED_SAL_PROC) ReturnReg.r10;\r
278 } else {\r
279 //\r
280 // Physical mode plabel to entry point\r
281 //\r
282 EsalProc = (EXTENDED_SAL_PROC) ReturnReg.r9;\r
283 }\r
284\r
285 return EsalProc (\r
286 ClassGuidLo,\r
287 ClassGuidHi,\r
288 FunctionId,\r
289 Arg2,\r
290 Arg3,\r
291 Arg4,\r
292 Arg5,\r
293 Arg6,\r
294 Arg7,\r
295 Arg8\r
296 );\r
297}\r
298\r
299/**\r
300 Wrapper for the EsalStallFunctionId service of Extended SAL Stall Services Class.\r
9095d37b 301\r
863be5d0 302 This function is a wrapper for the EsalStallFunctionId service of Extended SAL\r
303 Stall Services Class. See EsalStallFunctionId of Extended SAL Specification.\r
304\r
305 @param Microseconds The number of microseconds to delay.\r
306\r
307 @retval EFI_SAL_SUCCESS Call completed without error.\r
308 @retval EFI_SAL_INVALID_ARGUMENT Invalid argument.\r
309 @retval EFI_SAL_VIRTUAL_ADDRESS_ERROR Virtual address not registered\r
310\r
311**/\r
312SAL_RETURN_REGS\r
313EFIAPI\r
314EsalStall (\r
315 IN UINTN Microseconds\r
316 )\r
317{\r
318 return EsalCall (\r
9095d37b
LG
319 EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID_LO,\r
320 EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID_HI,\r
321 StallFunctionId,\r
322 Microseconds,\r
323 0,\r
324 0,\r
325 0,\r
326 0,\r
327 0,\r
863be5d0 328 0\r
329 );\r
330}\r
331\r
332/**\r
333 Wrapper for the EsalSetNewPalEntryFunctionId service of Extended SAL PAL Services Services Class.\r
9095d37b 334\r
863be5d0 335 This function is a wrapper for the EsalSetNewPalEntryFunctionId service of Extended SAL\r
336 PAL Services Services Class. See EsalSetNewPalEntryFunctionId of Extended SAL Specification.\r
337\r
338 @param PhysicalAddress If TRUE, then PalEntryPoint is a physical address.\r
339 If FALSE, then PalEntryPoint is a virtual address.\r
340 @param PalEntryPoint The PAL Entry Point being set.\r
341\r
342 @retval EFI_SAL_SUCCESS The PAL Entry Point was set.\r
343 @retval EFI_SAL_VIRTUAL_ADDRESS_ERROR This function was called in virtual mode before\r
344 virtual mappings for the specified Extended SAL\r
345 Procedure are available.\r
346\r
347**/\r
348SAL_RETURN_REGS\r
349EFIAPI\r
350EsalSetNewPalEntry (\r
351 IN BOOLEAN PhysicalAddress,\r
352 IN UINT64 PalEntryPoint\r
353 )\r
354{\r
355 return EsalCall (\r
9095d37b 356 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_LO,\r
863be5d0 357 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
358 SetNewPalEntryFunctionId,\r
359 PhysicalAddress,\r
360 PalEntryPoint,\r
361 0,\r
362 0,\r
363 0,\r
364 0,\r
863be5d0 365 0\r
366 );\r
367}\r
368\r
369/**\r
370 Wrapper for the EsalGetNewPalEntryFunctionId service of Extended SAL PAL Services Services Class.\r
9095d37b 371\r
863be5d0 372 This function is a wrapper for the EsalGetNewPalEntryFunctionId service of Extended SAL\r
373 PAL Services Services Class. See EsalGetNewPalEntryFunctionId of Extended SAL Specification.\r
374\r
375 @param PhysicalAddress If TRUE, then PalEntryPoint is a physical address.\r
376 If FALSE, then PalEntryPoint is a virtual address.\r
377\r
378 @retval EFI_SAL_SUCCESS The PAL Entry Point was retrieved and returned in\r
379 SAL_RETURN_REGS.r9.\r
380 @retval EFI_SAL_VIRTUAL_ADDRESS_ERROR This function was called in virtual mode before\r
381 virtual mappings for the specified Extended SAL\r
382 Procedure are available.\r
383 @return r9 PAL entry point retrieved.\r
384\r
385**/\r
386SAL_RETURN_REGS\r
387EFIAPI\r
388EsalGetNewPalEntry (\r
389 IN BOOLEAN PhysicalAddress\r
390 )\r
391{\r
392 return EsalCall (\r
393 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_LO,\r
394 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
395 GetNewPalEntryFunctionId,\r
396 PhysicalAddress,\r
397 0,\r
398 0,\r
399 0,\r
400 0,\r
401 0,\r
863be5d0 402 0\r
403 );\r
404}\r
405\r
406/**\r
407 Wrapper for the EsalGetStateBufferFunctionId service of Extended SAL MCA Log Services Class.\r
9095d37b 408\r
863be5d0 409 This function is a wrapper for the EsalGetStateBufferFunctionId service of Extended SAL\r
410 MCA Log Services Class. See EsalGetStateBufferFunctionId of Extended SAL Specification.\r
411\r
412 @param McaType See type parameter of SAL Procedure SAL_GET_STATE_INFO.\r
413 @param McaBuffer A pointer to the base address of the returned buffer.\r
414 Copied from SAL_RETURN_REGS.r9.\r
415 @param BufferSize A pointer to the size, in bytes, of the returned buffer.\r
416 Copied from SAL_RETURN_REGS.r10.\r
417\r
418 @retval EFI_SAL_SUCCESS The memory buffer to store error records was returned in r9 and r10.\r
419 @retval EFI_OUT_OF_RESOURCES A memory buffer for string error records in not available\r
420 @return r9 Base address of the returned buffer\r
421 @return r10 Size of the returned buffer in bytes\r
422\r
423**/\r
424SAL_RETURN_REGS\r
425EFIAPI\r
426EsalGetStateBuffer (\r
427 IN UINT64 McaType,\r
428 OUT UINT8 **McaBuffer,\r
429 OUT UINTN *BufferSize\r
430 )\r
431{\r
432 SAL_RETURN_REGS Regs;\r
433\r
434 Regs = EsalCall (\r
435 EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID_LO,\r
436 EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
437 EsalGetStateBufferFunctionId,\r
438 McaType,\r
439 0,\r
440 0,\r
441 0,\r
442 0,\r
443 0,\r
863be5d0 444 0\r
445 );\r
446\r
447 *McaBuffer = (UINT8 *) Regs.r9;\r
448 *BufferSize = Regs.r10;\r
449\r
450 return Regs;\r
451}\r
452\r
453/**\r
454 Wrapper for the EsalSaveStateBufferFunctionId service of Extended SAL MCA Log Services Class.\r
9095d37b 455\r
863be5d0 456 This function is a wrapper for the EsalSaveStateBufferFunctionId service of Extended SAL\r
457 MCA Log Services Class. See EsalSaveStateBufferFunctionId of Extended SAL Specification.\r
458\r
459 @param McaType See type parameter of SAL Procedure SAL_GET_STATE_INFO.\r
460\r
461 @retval EFI_SUCCESS The memory buffer containing the error record was written to nonvolatile storage.\r
462\r
463**/\r
464SAL_RETURN_REGS\r
465EFIAPI\r
466EsalSaveStateBuffer (\r
467 IN UINT64 McaType\r
468 )\r
469{\r
470 return EsalCall (\r
471 EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID_LO,\r
472 EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
473 EsalSaveStateBufferFunctionId,\r
474 McaType,\r
475 0,\r
476 0,\r
477 0,\r
478 0,\r
479 0,\r
863be5d0 480 0\r
481 );\r
482}\r
483\r
484/**\r
485 Wrapper for the EsalGetVectorsFunctionId service of Extended SAL Base Services Class.\r
9095d37b 486\r
863be5d0 487 This function is a wrapper for the EsalGetVectorsFunctionId service of Extended SAL\r
488 Base Services Class. See EsalGetVectorsFunctionId of Extended SAL Specification.\r
489\r
490 @param VectorType The vector type to retrieve.\r
491 0 - MCA, 1 - BSP INIT, 2 - BOOT_RENDEZ, 3 - AP INIT.\r
492\r
493 @retval EFI_SAL_SUCCESS Call completed without error.\r
494 @retval EFI_SAL_INVALID_ARGUMENT Invalid argument.\r
495 @retval EFI_SAL_NO_INFORMATION The requested vector has not been registered\r
496 with the SAL Procedure SAL_SET_VECTORS.\r
497\r
498**/\r
499SAL_RETURN_REGS\r
500EFIAPI\r
501EsalGetVectors (\r
502 IN UINT64 VectorType\r
503 )\r
504{\r
505 return EsalCall (\r
506 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_LO,\r
507 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
508 EsalGetVectorsFunctionId,\r
509 VectorType,\r
510 0,\r
511 0,\r
512 0,\r
513 0,\r
514 0,\r
863be5d0 515 0\r
516 );\r
517}\r
518\r
519/**\r
520 Wrapper for the EsalMcGetParamsFunctionId service of Extended SAL Base Services Class.\r
9095d37b 521\r
863be5d0 522 This function is a wrapper for the EsalMcGetParamsFunctionId service of Extended SAL\r
523 Base Services Class. See EsalMcGetParamsFunctionId of Extended SAL Specification.\r
524\r
525 @param ParamInfoType The parameter type to retrieve.\r
526 1 - rendezvous interrupt\r
527 2 - wake up\r
528 3 - Corrected Platform Error Vector.\r
529\r
530 @retval EFI_SAL_SUCCESS Call completed without error.\r
531 @retval EFI_SAL_INVALID_ARGUMENT Invalid argument.\r
532 @retval EFI_SAL_NO_INFORMATION The requested vector has not been registered\r
533 with the SAL Procedure SAL_MC_SET_PARAMS.\r
534\r
535**/\r
536SAL_RETURN_REGS\r
537EFIAPI\r
538EsalMcGetParams (\r
539 IN UINT64 ParamInfoType\r
540 )\r
541{\r
542 return EsalCall (\r
543 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_LO,\r
544 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
545 EsalMcGetParamsFunctionId,\r
546 ParamInfoType,\r
547 0,\r
548 0,\r
549 0,\r
550 0,\r
551 0,\r
863be5d0 552 0\r
553 );\r
554}\r
555\r
556/**\r
557 Wrapper for the EsalMcGetParamsFunctionId service of Extended SAL Base Services Class.\r
9095d37b 558\r
863be5d0 559 This function is a wrapper for the EsalMcGetParamsFunctionId service of Extended SAL\r
560 Base Services Class. See EsalMcGetParamsFunctionId of Extended SAL Specification.\r
561\r
562 @retval EFI_SAL_SUCCESS Call completed without error.\r
563 @retval EFI_SAL_NO_INFORMATION The requested vector has not been registered\r
564 with the SAL Procedure SAL_MC_SET_PARAMS.\r
565\r
566**/\r
567SAL_RETURN_REGS\r
568EFIAPI\r
569EsalMcGetMcParams (\r
570 VOID\r
571 )\r
572{\r
573 return EsalCall (\r
574 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_LO,\r
575 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
576 EsalMcGetMcParamsFunctionId,\r
577 0,\r
578 0,\r
579 0,\r
580 0,\r
581 0,\r
582 0,\r
863be5d0 583 0\r
584 );\r
585}\r
586\r
587/**\r
588 Wrapper for the EsalGetMcCheckinFlagsFunctionId service of Extended SAL Base Services Class.\r
9095d37b 589\r
863be5d0 590 This function is a wrapper for the EsalGetMcCheckinFlagsFunctionId service of Extended SAL\r
591 Base Services Class. See EsalGetMcCheckinFlagsFunctionId of Extended SAL Specification.\r
592\r
593 @param CpuIndex The index of the CPU of set of enabled CPUs to check.\r
594\r
595 @retval EFI_SAL_SUCCESS The checkin status of the requested CPU was returned.\r
596\r
597**/\r
598SAL_RETURN_REGS\r
599EFIAPI\r
600EsalGetMcCheckinFlags (\r
601 IN UINT64 CpuIndex\r
602 )\r
603{\r
604 return EsalCall (\r
605 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_LO,\r
606 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
607 EsalGetMcCheckinFlagsFunctionId,\r
608 CpuIndex,\r
609 0,\r
610 0,\r
611 0,\r
612 0,\r
613 0,\r
863be5d0 614 0\r
615 );\r
616}\r
617\r
618/**\r
619 Wrapper for the EsalAddCpuDataFunctionId service of Extended SAL MP Services Class.\r
9095d37b 620\r
863be5d0 621 This function is a wrapper for the EsalAddCpuDataFunctionId service of Extended SAL\r
622 MP Services Class. See EsalAddCpuDataFunctionId of Extended SAL Specification.\r
623\r
624 @param CpuGlobalId The Global ID for the CPU being added.\r
625 @param Enabled The enable flag for the CPU being added.\r
626 TRUE means the CPU is enabled.\r
627 FALSE means the CPU is disabled.\r
628 @param PalCompatibility The PAL Compatibility value for the CPU being added.\r
629\r
630 @retval EFI_SAL_SUCCESS The CPU was added to the database.\r
631 @retval EFI_SAL_NOT_ENOUGH_SCRATCH There are not enough resource available to add the CPU.\r
632\r
633**/\r
634SAL_RETURN_REGS\r
635EFIAPI\r
636EsalAddCpuData (\r
637 IN UINT64 CpuGlobalId,\r
638 IN BOOLEAN Enabled,\r
639 IN UINT64 PalCompatibility\r
640 )\r
641{\r
642 return EsalCall (\r
643 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
644 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
645 AddCpuDataFunctionId,\r
646 CpuGlobalId,\r
647 Enabled,\r
648 PalCompatibility,\r
649 0,\r
650 0,\r
651 0,\r
863be5d0 652 0\r
653 );\r
654}\r
655\r
656/**\r
657 Wrapper for the EsalRemoveCpuDataFunctionId service of Extended SAL MP Services Class.\r
9095d37b 658\r
863be5d0 659 This function is a wrapper for the EsalRemoveCpuDataFunctionId service of Extended SAL\r
660 MP Services Class. See EsalRemoveCpuDataFunctionId of Extended SAL Specification.\r
661\r
662 @param CpuGlobalId The Global ID for the CPU being removed.\r
663\r
664 @retval EFI_SAL_SUCCESS The CPU was removed from the database.\r
665 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
666\r
667**/\r
668SAL_RETURN_REGS\r
669EFIAPI\r
670EsalRemoveCpuData (\r
671 IN UINT64 CpuGlobalId\r
672 )\r
673{\r
674 return EsalCall (\r
675 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
676 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
677 RemoveCpuDataFunctionId,\r
678 CpuGlobalId,\r
679 0,\r
680 0,\r
681 0,\r
682 0,\r
683 0,\r
863be5d0 684 0\r
685 );\r
686}\r
687\r
688/**\r
689 Wrapper for the EsalModifyCpuDataFunctionId service of Extended SAL MP Services Class.\r
9095d37b 690\r
863be5d0 691 This function is a wrapper for the EsalModifyCpuDataFunctionId service of Extended SAL\r
692 MP Services Class. See EsalModifyCpuDataFunctionId of Extended SAL Specification.\r
693\r
694 @param CpuGlobalId The Global ID for the CPU being modified.\r
695 @param Enabled The enable flag for the CPU being modified.\r
696 TRUE means the CPU is enabled.\r
697 FALSE means the CPU is disabled.\r
698 @param PalCompatibility The PAL Compatibility value for the CPU being modified.\r
699\r
700 @retval EFI_SAL_SUCCESS The CPU database was updated.\r
701 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
702\r
703**/\r
704SAL_RETURN_REGS\r
705EFIAPI\r
706EsalModifyCpuData (\r
707 IN UINT64 CpuGlobalId,\r
708 IN BOOLEAN Enabled,\r
709 IN UINT64 PalCompatibility\r
710 )\r
711{\r
712 return EsalCall (\r
713 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
714 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
715 ModifyCpuDataFunctionId,\r
716 CpuGlobalId,\r
717 Enabled,\r
718 PalCompatibility,\r
719 0,\r
720 0,\r
721 0,\r
863be5d0 722 0\r
723 );\r
724}\r
725\r
726/**\r
727 Wrapper for the EsalGetCpuDataByIdFunctionId service of Extended SAL MP Services Class.\r
9095d37b 728\r
863be5d0 729 This function is a wrapper for the EsalGetCpuDataByIdFunctionId service of Extended SAL\r
730 MP Services Class. See EsalGetCpuDataByIdFunctionId of Extended SAL Specification.\r
731\r
732 @param CpuGlobalId The Global ID for the CPU being looked up.\r
733 @param IndexByEnabledCpu If TRUE, then the index of set of enabled CPUs of database is returned.\r
734 If FALSE, then the index of set of all CPUs of database is returned.\r
735\r
736 @retval EFI_SAL_SUCCESS The information on the specified CPU was returned.\r
737 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
738\r
739**/\r
740SAL_RETURN_REGS\r
741EFIAPI\r
742EsalGetCpuDataById (\r
743 IN UINT64 CpuGlobalId,\r
744 IN BOOLEAN IndexByEnabledCpu\r
745 )\r
746{\r
747 return EsalCall (\r
748 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
749 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
750 GetCpuDataByIDFunctionId,\r
751 CpuGlobalId,\r
752 IndexByEnabledCpu,\r
753 0,\r
754 0,\r
755 0,\r
756 0,\r
863be5d0 757 0\r
758 );\r
759}\r
760\r
761/**\r
762 Wrapper for the EsalGetCpuDataByIndexFunctionId service of Extended SAL MP Services Class.\r
9095d37b 763\r
863be5d0 764 This function is a wrapper for the EsalGetCpuDataByIndexFunctionId service of Extended SAL\r
765 MP Services Class. See EsalGetCpuDataByIndexFunctionId of Extended SAL Specification.\r
766\r
767 @param Index The Global ID for the CPU being modified.\r
768 @param IndexByEnabledCpu If TRUE, then the index of set of enabled CPUs of database is returned.\r
769 If FALSE, then the index of set of all CPUs of database is returned.\r
770\r
771 @retval EFI_SAL_SUCCESS The information on the specified CPU was returned.\r
772 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
773\r
774**/\r
775SAL_RETURN_REGS\r
776EFIAPI\r
777EsalGetCpuDataByIndex (\r
778 IN UINT64 Index,\r
779 IN BOOLEAN IndexByEnabledCpu\r
780 )\r
781{\r
782 return EsalCall (\r
783 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
784 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
785 GetCpuDataByIndexFunctionId,\r
786 Index,\r
787 IndexByEnabledCpu,\r
788 0,\r
789 0,\r
790 0,\r
791 0,\r
863be5d0 792 0\r
793 );\r
794}\r
795\r
796/**\r
797 Wrapper for the EsalWhoAmIFunctionId service of Extended SAL MP Services Class.\r
9095d37b 798\r
863be5d0 799 This function is a wrapper for the EsalWhoAmIFunctionId service of Extended SAL\r
800 MP Services Class. See EsalWhoAmIFunctionId of Extended SAL Specification.\r
801\r
802 @param IndexByEnabledCpu If TRUE, then the index of set of enabled CPUs of database is returned.\r
803 If FALSE, then the index of set of all CPUs of database is returned.\r
804\r
805 @retval EFI_SAL_SUCCESS The Global ID for the calling CPU was returned.\r
806 @retval EFI_SAL_NO_INFORMATION The calling CPU is not in the database.\r
807\r
808**/\r
809SAL_RETURN_REGS\r
810EFIAPI\r
811EsalWhoAmI (\r
812 IN BOOLEAN IndexByEnabledCpu\r
813 )\r
814{\r
815 return EsalCall (\r
816 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
817 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
818 CurrentProcInfoFunctionId,\r
819 IndexByEnabledCpu,\r
820 0,\r
821 0,\r
822 0,\r
823 0,\r
824 0,\r
863be5d0 825 0\r
826 );\r
827}\r
828\r
829/**\r
830 Wrapper for the EsalNumProcessors service of Extended SAL MP Services Class.\r
9095d37b 831\r
863be5d0 832 This function is a wrapper for the EsalNumProcessors service of Extended SAL\r
833 MP Services Class. See EsalNumProcessors of Extended SAL Specification.\r
834\r
835 @retval EFI_SAL_SUCCESS The information on the number of CPUs in the platform\r
836 was returned.\r
837\r
838**/\r
839SAL_RETURN_REGS\r
840EFIAPI\r
841EsalNumProcessors (\r
842 VOID\r
843 )\r
844{\r
845 return EsalCall (\r
846 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
847 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
848 NumProcessorsFunctionId,\r
849 0,\r
850 0,\r
851 0,\r
852 0,\r
853 0,\r
854 0,\r
863be5d0 855 0\r
856 );\r
857}\r
858\r
859/**\r
860 Wrapper for the EsalSetMinStateFnctionId service of Extended SAL MP Services Class.\r
9095d37b 861\r
863be5d0 862 This function is a wrapper for the EsalSetMinStateFnctionId service of Extended SAL\r
863 MP Services Class. See EsalSetMinStateFnctionId of Extended SAL Specification.\r
864\r
865 @param CpuGlobalId The Global ID for the CPU whose MINSTATE pointer is being set.\r
866 @param MinStatePointer The physical address of the MINSTATE buffer for the CPU\r
867 specified by CpuGlobalId.\r
868\r
869 @retval EFI_SAL_SUCCESS The MINSTATE pointer was set for the specified CPU.\r
870 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
871\r
872**/\r
873SAL_RETURN_REGS\r
874EFIAPI\r
875EsalSetMinState (\r
876 IN UINT64 CpuGlobalId,\r
877 IN EFI_PHYSICAL_ADDRESS MinStatePointer\r
878 )\r
879{\r
880 return EsalCall (\r
881 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
882 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
883 SetMinStateFunctionId,\r
884 CpuGlobalId,\r
885 MinStatePointer,\r
886 0,\r
887 0,\r
888 0,\r
889 0,\r
863be5d0 890 0\r
891 );\r
892}\r
893\r
894/**\r
895 Wrapper for the EsalGetMinStateFunctionId service of Extended SAL MP Services Class.\r
9095d37b 896\r
863be5d0 897 This function is a wrapper for the EsalGetMinStateFunctionId service of Extended SAL\r
898 MP Services Class. See EsalGetMinStateFunctionId of Extended SAL Specification.\r
899\r
900 @param CpuGlobalId The Global ID for the CPU whose MINSTATE pointer is being retrieved.\r
901\r
902 @retval EFI_SAL_SUCCESS The MINSTATE pointer for the specified CPU was retrieved.\r
903 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
904\r
905**/\r
906SAL_RETURN_REGS\r
907EFIAPI\r
908EsalGetMinState (\r
909 IN UINT64 CpuGlobalId\r
910 )\r
911{\r
912 return EsalCall (\r
913 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
914 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
915 GetMinStateFunctionId,\r
916 CpuGlobalId,\r
917 0,\r
918 0,\r
919 0,\r
920 0,\r
921 0,\r
863be5d0 922 0\r
923 );\r
924}\r
925\r
926/**\r
927 Wrapper for the EsalMcsGetStateInfoFunctionId service of Extended SAL MCA Services Class.\r
9095d37b 928\r
863be5d0 929 This function is a wrapper for the EsalMcsGetStateInfoFunctionId service of Extended SAL\r
930 MCA Services Class. See EsalMcsGetStateInfoFunctionId of Extended SAL Specification.\r
931\r
932 @param CpuGlobalId The Global ID for the CPU whose MCA state buffer is being retrieved.\r
933 @param StateBufferPointer A pointer to the returned MCA state buffer.\r
934 @param RequiredStateBufferSize A pointer to the size, in bytes, of the returned MCA state buffer.\r
935\r
936 @retval EFI_SUCCESS MINSTATE successfully got and size calculated.\r
937 @retval EFI_SAL_NO_INFORMATION Fail to get MINSTATE.\r
938\r
939**/\r
940SAL_RETURN_REGS\r
941EFIAPI\r
942EsalMcaGetStateInfo (\r
943 IN UINT64 CpuGlobalId,\r
944 OUT EFI_PHYSICAL_ADDRESS *StateBufferPointer,\r
945 OUT UINT64 *RequiredStateBufferSize\r
946 )\r
947{\r
948 SAL_RETURN_REGS Regs;\r
949\r
950 Regs = EsalCall (\r
951 EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID_LO,\r
952 EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
953 McaGetStateInfoFunctionId,\r
954 CpuGlobalId,\r
955 0,\r
956 0,\r
957 0,\r
958 0,\r
959 0,\r
863be5d0 960 0\r
961 );\r
962\r
963 *StateBufferPointer = (EFI_PHYSICAL_ADDRESS) Regs.r9;\r
964 *RequiredStateBufferSize = (UINT64) Regs.r10;\r
965\r
966 return Regs;\r
967}\r
968\r
969/**\r
970 Wrapper for the EsalMcaRegisterCpuFunctionId service of Extended SAL MCA Services Class.\r
9095d37b 971\r
863be5d0 972 This function is a wrapper for the EsalMcaRegisterCpuFunctionId service of Extended SAL\r
973 MCA Services Class. See EsalMcaRegisterCpuFunctionId of Extended SAL Specification.\r
974\r
975 @param CpuGlobalId The Global ID for the CPU whose MCA state buffer is being set.\r
976 @param StateBufferPointer A pointer to the MCA state buffer.\r
977\r
978 @retval EFI_SAL_NO_INFORMATION Cannot get the processor info with the CpuId\r
979 @retval EFI_SUCCESS Save the processor's state info successfully\r
980\r
981**/\r
982SAL_RETURN_REGS\r
983EFIAPI\r
984EsalMcaRegisterCpu (\r
985 IN UINT64 CpuGlobalId,\r
986 IN EFI_PHYSICAL_ADDRESS StateBufferPointer\r
987 )\r
988{\r
989 return EsalCall (\r
990 EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID_LO,\r
991 EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID_HI,\r
9095d37b
LG
992 McaRegisterCpuFunctionId,\r
993 CpuGlobalId,\r
994 StateBufferPointer,\r
995 0,\r
996 0,\r
997 0,\r
998 0,\r
863be5d0 999 0\r
1000 );\r
1001}\r