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