]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeRuntimeExtendedSalLib/ExtendedSalLib.c
Add Missing invocations to VA_END() for VA_START().
[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
3bbe68a3 4 Copyright (c) 2006 - 2012, 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#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
3bbe68a3 322 VA_END (Args);\r
323\r
863be5d0 324 if (EFI_ERROR (Status)) {\r
325 return Status;\r
326 }\r
327\r
328 NewHandle = NULL;\r
329 *((UINT64 *)(&ClassGuid) + 0) = ClassGuidLo;\r
330 *((UINT64 *)(&ClassGuid) + 1) = ClassGuidHi;\r
331 return gBS->InstallProtocolInterface (\r
332 &NewHandle,\r
333 &ClassGuid,\r
334 EFI_NATIVE_INTERFACE,\r
335 NULL\r
336 );\r
337}\r
338\r
339/**\r
340 Calls an Extended SAL Class service that was previously registered with RegisterEsalClass().\r
341 \r
342 This function gets the entrypoint of Extended SAL, and calls an Extended SAL Class service\r
343 that was previously registered with RegisterEsalClass() through this entrypoint.\r
344\r
345 @param ClassGuidLo GUID of function, lower 64-bits\r
346 @param ClassGuidHi GUID of function, upper 64-bits\r
347 @param FunctionId Function in ClassGuid to call\r
348 @param Arg2 Argument 2 ClassGuid/FunctionId defined\r
349 @param Arg3 Argument 3 ClassGuid/FunctionId defined\r
350 @param Arg4 Argument 4 ClassGuid/FunctionId defined\r
351 @param Arg5 Argument 5 ClassGuid/FunctionId defined\r
352 @param Arg6 Argument 6 ClassGuid/FunctionId defined\r
353 @param Arg7 Argument 7 ClassGuid/FunctionId defined\r
354 @param Arg8 Argument 8 ClassGuid/FunctionId defined\r
355 \r
356 @retval EFI_SAL_SUCCESS ESAL procedure successfully called.\r
357 @retval EFI_SAL_ERROR The address of ExtendedSalProc() can not be correctly\r
358 initialized.\r
359 @retval Other Status returned from ExtendedSalProc() service of\r
360 EXTENDED_SAL_BOOT_SERVICE_PROTOCOL. \r
361\r
362**/\r
363SAL_RETURN_REGS\r
364EFIAPI\r
365EsalCall (\r
366 IN UINT64 ClassGuidLo,\r
367 IN UINT64 ClassGuidHi,\r
368 IN UINT64 FunctionId,\r
369 IN UINT64 Arg2,\r
370 IN UINT64 Arg3,\r
371 IN UINT64 Arg4,\r
372 IN UINT64 Arg5,\r
373 IN UINT64 Arg6,\r
374 IN UINT64 Arg7,\r
375 IN UINT64 Arg8\r
376 )\r
377{\r
378 SAL_RETURN_REGS ReturnReg;\r
379 EXTENDED_SAL_PROC EsalProc;\r
380\r
381 //\r
382 // Get the entrypoint of Extended SAL\r
383 //\r
384 ReturnReg = GetEsalEntryPoint ();\r
385 if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) {\r
386 //\r
387 // The ESAL Entry Point could not be initialized\r
388 //\r
389 ReturnReg.Status = EFI_SAL_ERROR;\r
390 return ReturnReg;\r
391 }\r
392\r
393 //\r
394 // Test PSR.it which is BIT36\r
395 //\r
396 if ((ReturnReg.r11 & BIT36) != 0) {\r
397 //\r
398 // Virtual mode plabel to entry point\r
399 //\r
400 EsalProc = (EXTENDED_SAL_PROC) ReturnReg.r10;\r
401 } else {\r
402 //\r
403 // Physical mode plabel to entry point\r
404 //\r
405 EsalProc = (EXTENDED_SAL_PROC) ReturnReg.r9;\r
406 }\r
407\r
408 return EsalProc (\r
409 ClassGuidLo,\r
410 ClassGuidHi,\r
411 FunctionId,\r
412 Arg2,\r
413 Arg3,\r
414 Arg4,\r
415 Arg5,\r
416 Arg6,\r
417 Arg7,\r
418 Arg8\r
419 );\r
420}\r
421\r
422/**\r
423 Wrapper for the EsalStallFunctionId service of Extended SAL Stall Services Class.\r
424 \r
425 This function is a wrapper for the EsalStallFunctionId service of Extended SAL\r
426 Stall Services Class. See EsalStallFunctionId of Extended SAL Specification.\r
427\r
428 @param Microseconds The number of microseconds to delay.\r
429\r
430 @retval EFI_SAL_SUCCESS Call completed without error.\r
431 @retval EFI_SAL_INVALID_ARGUMENT Invalid argument.\r
432 @retval EFI_SAL_VIRTUAL_ADDRESS_ERROR Virtual address not registered\r
433\r
434**/\r
435SAL_RETURN_REGS\r
436EFIAPI\r
437EsalStall (\r
438 IN UINTN Microseconds\r
439 )\r
440{\r
441 return EsalCall (\r
442 EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID_LO, \r
443 EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID_HI, \r
444 StallFunctionId, \r
445 Microseconds, \r
446 0, \r
447 0, \r
448 0, \r
449 0, \r
450 0, \r
451 0\r
452 );\r
453}\r
454\r
455/**\r
456 Wrapper for the EsalSetNewPalEntryFunctionId service of Extended SAL PAL Services Services Class.\r
457 \r
458 This function is a wrapper for the EsalSetNewPalEntryFunctionId service of Extended SAL\r
459 PAL Services Services Class. See EsalSetNewPalEntryFunctionId of Extended SAL Specification.\r
460\r
461 @param PhysicalAddress If TRUE, then PalEntryPoint is a physical address.\r
462 If FALSE, then PalEntryPoint is a virtual address.\r
463 @param PalEntryPoint The PAL Entry Point being set.\r
464\r
465 @retval EFI_SAL_SUCCESS The PAL Entry Point was set.\r
466 @retval EFI_SAL_VIRTUAL_ADDRESS_ERROR This function was called in virtual mode before\r
467 virtual mappings for the specified Extended SAL\r
468 Procedure are available.\r
469\r
470**/\r
471SAL_RETURN_REGS\r
472EFIAPI\r
473EsalSetNewPalEntry (\r
474 IN BOOLEAN PhysicalAddress,\r
475 IN UINT64 PalEntryPoint\r
476 )\r
477{\r
478 return EsalCall (\r
479 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_LO, \r
480 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_HI,\r
481 SetNewPalEntryFunctionId, \r
482 PhysicalAddress, \r
483 PalEntryPoint, \r
484 0, \r
485 0, \r
486 0, \r
487 0, \r
488 0\r
489 );\r
490}\r
491\r
492/**\r
493 Wrapper for the EsalGetNewPalEntryFunctionId service of Extended SAL PAL Services Services Class.\r
494 \r
495 This function is a wrapper for the EsalGetNewPalEntryFunctionId service of Extended SAL\r
496 PAL Services Services Class. See EsalGetNewPalEntryFunctionId of Extended SAL Specification.\r
497\r
498 @param PhysicalAddress If TRUE, then PalEntryPoint is a physical address.\r
499 If FALSE, then PalEntryPoint is a virtual address.\r
500\r
501 @retval EFI_SAL_SUCCESS The PAL Entry Point was retrieved and returned in\r
502 SAL_RETURN_REGS.r9.\r
503 @retval EFI_SAL_VIRTUAL_ADDRESS_ERROR This function was called in virtual mode before\r
504 virtual mappings for the specified Extended SAL\r
505 Procedure are available.\r
506 @return r9 PAL entry point retrieved.\r
507\r
508**/\r
509SAL_RETURN_REGS\r
510EFIAPI\r
511EsalGetNewPalEntry (\r
512 IN BOOLEAN PhysicalAddress\r
513 )\r
514{\r
515 return EsalCall (\r
516 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_LO,\r
517 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_HI,\r
518 GetNewPalEntryFunctionId, \r
519 PhysicalAddress, \r
520 0, \r
521 0, \r
522 0, \r
523 0, \r
524 0, \r
525 0\r
526 );\r
527}\r
528\r
529/**\r
530 Wrapper for the EsalGetStateBufferFunctionId service of Extended SAL MCA Log Services Class.\r
531 \r
532 This function is a wrapper for the EsalGetStateBufferFunctionId service of Extended SAL\r
533 MCA Log Services Class. See EsalGetStateBufferFunctionId of Extended SAL Specification.\r
534\r
535 @param McaType See type parameter of SAL Procedure SAL_GET_STATE_INFO.\r
536 @param McaBuffer A pointer to the base address of the returned buffer.\r
537 Copied from SAL_RETURN_REGS.r9.\r
538 @param BufferSize A pointer to the size, in bytes, of the returned buffer.\r
539 Copied from SAL_RETURN_REGS.r10.\r
540\r
541 @retval EFI_SAL_SUCCESS The memory buffer to store error records was returned in r9 and r10.\r
542 @retval EFI_OUT_OF_RESOURCES A memory buffer for string error records in not available\r
543 @return r9 Base address of the returned buffer\r
544 @return r10 Size of the returned buffer in bytes\r
545\r
546**/\r
547SAL_RETURN_REGS\r
548EFIAPI\r
549EsalGetStateBuffer (\r
550 IN UINT64 McaType,\r
551 OUT UINT8 **McaBuffer,\r
552 OUT UINTN *BufferSize\r
553 )\r
554{\r
555 SAL_RETURN_REGS Regs;\r
556\r
557 Regs = EsalCall (\r
558 EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID_LO,\r
559 EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID_HI,\r
560 EsalGetStateBufferFunctionId, \r
561 McaType, \r
562 0, \r
563 0, \r
564 0, \r
565 0, \r
566 0, \r
567 0\r
568 );\r
569\r
570 *McaBuffer = (UINT8 *) Regs.r9;\r
571 *BufferSize = Regs.r10;\r
572\r
573 return Regs;\r
574}\r
575\r
576/**\r
577 Wrapper for the EsalSaveStateBufferFunctionId service of Extended SAL MCA Log Services Class.\r
578 \r
579 This function is a wrapper for the EsalSaveStateBufferFunctionId service of Extended SAL\r
580 MCA Log Services Class. See EsalSaveStateBufferFunctionId of Extended SAL Specification.\r
581 \r
582 @param McaType See type parameter of SAL Procedure SAL_GET_STATE_INFO.\r
583\r
584 @retval EFI_SUCCESS The memory buffer containing the error record was written to nonvolatile storage.\r
585\r
586**/\r
587SAL_RETURN_REGS\r
588EFIAPI\r
589EsalSaveStateBuffer (\r
590 IN UINT64 McaType\r
591 )\r
592{\r
593 return EsalCall (\r
594 EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID_LO,\r
595 EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID_HI,\r
596 EsalSaveStateBufferFunctionId, \r
597 McaType, \r
598 0, \r
599 0, \r
600 0, \r
601 0, \r
602 0, \r
603 0\r
604 );\r
605}\r
606\r
607/**\r
608 Wrapper for the EsalGetVectorsFunctionId service of Extended SAL Base Services Class.\r
609 \r
610 This function is a wrapper for the EsalGetVectorsFunctionId service of Extended SAL\r
611 Base Services Class. See EsalGetVectorsFunctionId of Extended SAL Specification.\r
612\r
613 @param VectorType The vector type to retrieve.\r
614 0 - MCA, 1 - BSP INIT, 2 - BOOT_RENDEZ, 3 - AP INIT.\r
615\r
616 @retval EFI_SAL_SUCCESS Call completed without error.\r
617 @retval EFI_SAL_INVALID_ARGUMENT Invalid argument.\r
618 @retval EFI_SAL_NO_INFORMATION The requested vector has not been registered\r
619 with the SAL Procedure SAL_SET_VECTORS.\r
620\r
621**/\r
622SAL_RETURN_REGS\r
623EFIAPI\r
624EsalGetVectors (\r
625 IN UINT64 VectorType\r
626 )\r
627{\r
628 return EsalCall (\r
629 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_LO,\r
630 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_HI,\r
631 EsalGetVectorsFunctionId, \r
632 VectorType, \r
633 0, \r
634 0, \r
635 0, \r
636 0, \r
637 0, \r
638 0\r
639 );\r
640}\r
641\r
642/**\r
643 Wrapper for the EsalMcGetParamsFunctionId service of Extended SAL Base Services Class.\r
644 \r
645 This function is a wrapper for the EsalMcGetParamsFunctionId service of Extended SAL\r
646 Base Services Class. See EsalMcGetParamsFunctionId of Extended SAL Specification.\r
647\r
648 @param ParamInfoType The parameter type to retrieve.\r
649 1 - rendezvous interrupt\r
650 2 - wake up\r
651 3 - Corrected Platform Error Vector.\r
652\r
653 @retval EFI_SAL_SUCCESS Call completed without error.\r
654 @retval EFI_SAL_INVALID_ARGUMENT Invalid argument.\r
655 @retval EFI_SAL_NO_INFORMATION The requested vector has not been registered\r
656 with the SAL Procedure SAL_MC_SET_PARAMS.\r
657\r
658**/\r
659SAL_RETURN_REGS\r
660EFIAPI\r
661EsalMcGetParams (\r
662 IN UINT64 ParamInfoType\r
663 )\r
664{\r
665 return EsalCall (\r
666 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_LO,\r
667 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_HI,\r
668 EsalMcGetParamsFunctionId, \r
669 ParamInfoType, \r
670 0, \r
671 0, \r
672 0, \r
673 0, \r
674 0, \r
675 0\r
676 );\r
677}\r
678\r
679/**\r
680 Wrapper for the EsalMcGetParamsFunctionId service of Extended SAL Base Services Class.\r
681 \r
682 This function is a wrapper for the EsalMcGetParamsFunctionId service of Extended SAL\r
683 Base Services Class. See EsalMcGetParamsFunctionId of Extended SAL Specification.\r
684 \r
685 @retval EFI_SAL_SUCCESS Call completed without error.\r
686 @retval EFI_SAL_NO_INFORMATION The requested vector has not been registered\r
687 with the SAL Procedure SAL_MC_SET_PARAMS.\r
688\r
689**/\r
690SAL_RETURN_REGS\r
691EFIAPI\r
692EsalMcGetMcParams (\r
693 VOID\r
694 )\r
695{\r
696 return EsalCall (\r
697 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_LO,\r
698 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_HI,\r
699 EsalMcGetMcParamsFunctionId, \r
700 0, \r
701 0, \r
702 0, \r
703 0, \r
704 0, \r
705 0, \r
706 0\r
707 );\r
708}\r
709\r
710/**\r
711 Wrapper for the EsalGetMcCheckinFlagsFunctionId service of Extended SAL Base Services Class.\r
712 \r
713 This function is a wrapper for the EsalGetMcCheckinFlagsFunctionId service of Extended SAL\r
714 Base Services Class. See EsalGetMcCheckinFlagsFunctionId of Extended SAL Specification.\r
715\r
716 @param CpuIndex The index of the CPU of set of enabled CPUs to check.\r
717\r
718 @retval EFI_SAL_SUCCESS The checkin status of the requested CPU was returned.\r
719\r
720**/\r
721SAL_RETURN_REGS\r
722EFIAPI\r
723EsalGetMcCheckinFlags (\r
724 IN UINT64 CpuIndex\r
725 )\r
726{\r
727 return EsalCall (\r
728 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_LO,\r
729 EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID_HI,\r
730 EsalGetMcCheckinFlagsFunctionId, \r
731 CpuIndex, \r
732 0, \r
733 0, \r
734 0, \r
735 0, \r
736 0, \r
737 0\r
738 );\r
739}\r
740\r
741/**\r
742 Wrapper for the EsalAddCpuDataFunctionId service of Extended SAL MP Services Class.\r
743 \r
744 This function is a wrapper for the EsalAddCpuDataFunctionId service of Extended SAL\r
745 MP Services Class. See EsalAddCpuDataFunctionId of Extended SAL Specification.\r
746\r
747 @param CpuGlobalId The Global ID for the CPU being added.\r
748 @param Enabled The enable flag for the CPU being added.\r
749 TRUE means the CPU is enabled.\r
750 FALSE means the CPU is disabled.\r
751 @param PalCompatibility The PAL Compatibility value for the CPU being added.\r
752\r
753 @retval EFI_SAL_SUCCESS The CPU was added to the database.\r
754 @retval EFI_SAL_NOT_ENOUGH_SCRATCH There are not enough resource available to add the CPU.\r
755\r
756**/\r
757SAL_RETURN_REGS\r
758EFIAPI\r
759EsalAddCpuData (\r
760 IN UINT64 CpuGlobalId,\r
761 IN BOOLEAN Enabled,\r
762 IN UINT64 PalCompatibility\r
763 )\r
764{\r
765 return EsalCall (\r
766 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
767 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
768 AddCpuDataFunctionId, \r
769 CpuGlobalId, \r
770 Enabled, \r
771 PalCompatibility, \r
772 0, \r
773 0, \r
774 0, \r
775 0\r
776 );\r
777}\r
778\r
779/**\r
780 Wrapper for the EsalRemoveCpuDataFunctionId service of Extended SAL MP Services Class.\r
781 \r
782 This function is a wrapper for the EsalRemoveCpuDataFunctionId service of Extended SAL\r
783 MP Services Class. See EsalRemoveCpuDataFunctionId of Extended SAL Specification.\r
784\r
785 @param CpuGlobalId The Global ID for the CPU being removed.\r
786\r
787 @retval EFI_SAL_SUCCESS The CPU was removed from the database.\r
788 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
789\r
790**/\r
791SAL_RETURN_REGS\r
792EFIAPI\r
793EsalRemoveCpuData (\r
794 IN UINT64 CpuGlobalId\r
795 )\r
796{\r
797 return EsalCall (\r
798 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
799 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
800 RemoveCpuDataFunctionId, \r
801 CpuGlobalId, \r
802 0, \r
803 0, \r
804 0, \r
805 0, \r
806 0, \r
807 0\r
808 );\r
809}\r
810\r
811/**\r
812 Wrapper for the EsalModifyCpuDataFunctionId service of Extended SAL MP Services Class.\r
813 \r
814 This function is a wrapper for the EsalModifyCpuDataFunctionId service of Extended SAL\r
815 MP Services Class. See EsalModifyCpuDataFunctionId of Extended SAL Specification.\r
816\r
817 @param CpuGlobalId The Global ID for the CPU being modified.\r
818 @param Enabled The enable flag for the CPU being modified.\r
819 TRUE means the CPU is enabled.\r
820 FALSE means the CPU is disabled.\r
821 @param PalCompatibility The PAL Compatibility value for the CPU being modified.\r
822\r
823 @retval EFI_SAL_SUCCESS The CPU database was updated.\r
824 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
825\r
826**/\r
827SAL_RETURN_REGS\r
828EFIAPI\r
829EsalModifyCpuData (\r
830 IN UINT64 CpuGlobalId,\r
831 IN BOOLEAN Enabled,\r
832 IN UINT64 PalCompatibility\r
833 )\r
834{\r
835 return EsalCall (\r
836 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
837 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
838 ModifyCpuDataFunctionId, \r
839 CpuGlobalId, \r
840 Enabled, \r
841 PalCompatibility, \r
842 0, \r
843 0, \r
844 0, \r
845 0\r
846 );\r
847}\r
848\r
849/**\r
850 Wrapper for the EsalGetCpuDataByIdFunctionId service of Extended SAL MP Services Class.\r
851 \r
852 This function is a wrapper for the EsalGetCpuDataByIdFunctionId service of Extended SAL\r
853 MP Services Class. See EsalGetCpuDataByIdFunctionId of Extended SAL Specification.\r
854\r
855 @param CpuGlobalId The Global ID for the CPU being looked up.\r
856 @param IndexByEnabledCpu If TRUE, then the index of set of enabled CPUs of database is returned.\r
857 If FALSE, then the index of set of all CPUs of database is returned.\r
858\r
859 @retval EFI_SAL_SUCCESS The information on the specified CPU was returned.\r
860 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
861\r
862**/\r
863SAL_RETURN_REGS\r
864EFIAPI\r
865EsalGetCpuDataById (\r
866 IN UINT64 CpuGlobalId,\r
867 IN BOOLEAN IndexByEnabledCpu\r
868 )\r
869{\r
870 return EsalCall (\r
871 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
872 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
873 GetCpuDataByIDFunctionId, \r
874 CpuGlobalId, \r
875 IndexByEnabledCpu, \r
876 0, \r
877 0, \r
878 0, \r
879 0, \r
880 0\r
881 );\r
882}\r
883\r
884/**\r
885 Wrapper for the EsalGetCpuDataByIndexFunctionId service of Extended SAL MP Services Class.\r
886 \r
887 This function is a wrapper for the EsalGetCpuDataByIndexFunctionId service of Extended SAL\r
888 MP Services Class. See EsalGetCpuDataByIndexFunctionId of Extended SAL Specification.\r
889\r
890 @param Index The Global ID for the CPU being modified.\r
891 @param IndexByEnabledCpu If TRUE, then the index of set of enabled CPUs of database is returned.\r
892 If FALSE, then the index of set of all CPUs of database is returned.\r
893\r
894 @retval EFI_SAL_SUCCESS The information on the specified CPU was returned.\r
895 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
896\r
897**/\r
898SAL_RETURN_REGS\r
899EFIAPI\r
900EsalGetCpuDataByIndex (\r
901 IN UINT64 Index,\r
902 IN BOOLEAN IndexByEnabledCpu\r
903 )\r
904{\r
905 return EsalCall (\r
906 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
907 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
908 GetCpuDataByIndexFunctionId, \r
909 Index, \r
910 IndexByEnabledCpu, \r
911 0, \r
912 0, \r
913 0, \r
914 0, \r
915 0\r
916 );\r
917}\r
918\r
919/**\r
920 Wrapper for the EsalWhoAmIFunctionId service of Extended SAL MP Services Class.\r
921 \r
922 This function is a wrapper for the EsalWhoAmIFunctionId service of Extended SAL\r
923 MP Services Class. See EsalWhoAmIFunctionId of Extended SAL Specification.\r
924\r
925 @param IndexByEnabledCpu If TRUE, then the index of set of enabled CPUs of database is returned.\r
926 If FALSE, then the index of set of all CPUs of database is returned.\r
927\r
928 @retval EFI_SAL_SUCCESS The Global ID for the calling CPU was returned.\r
929 @retval EFI_SAL_NO_INFORMATION The calling CPU is not in the database.\r
930\r
931**/\r
932SAL_RETURN_REGS\r
933EFIAPI\r
934EsalWhoAmI (\r
935 IN BOOLEAN IndexByEnabledCpu\r
936 )\r
937{\r
938 return EsalCall (\r
939 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
940 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
941 CurrentProcInfoFunctionId, \r
942 IndexByEnabledCpu, \r
943 0, \r
944 0, \r
945 0, \r
946 0, \r
947 0, \r
948 0\r
949 );\r
950}\r
951\r
952/**\r
953 Wrapper for the EsalNumProcessors service of Extended SAL MP Services Class.\r
954 \r
955 This function is a wrapper for the EsalNumProcessors service of Extended SAL\r
956 MP Services Class. See EsalNumProcessors of Extended SAL Specification.\r
957\r
958 @retval EFI_SAL_SUCCESS The information on the number of CPUs in the platform\r
959 was returned.\r
960\r
961**/\r
962SAL_RETURN_REGS\r
963EFIAPI\r
964EsalNumProcessors (\r
965 VOID\r
966 )\r
967{\r
968 return EsalCall (\r
969 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
970 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
971 NumProcessorsFunctionId, \r
972 0, \r
973 0, \r
974 0, \r
975 0, \r
976 0, \r
977 0, \r
978 0\r
979 );\r
980}\r
981\r
982/**\r
983 Wrapper for the EsalSetMinStateFnctionId service of Extended SAL MP Services Class.\r
984 \r
985 This function is a wrapper for the EsalSetMinStateFnctionId service of Extended SAL\r
986 MP Services Class. See EsalSetMinStateFnctionId of Extended SAL Specification.\r
987\r
988 @param CpuGlobalId The Global ID for the CPU whose MINSTATE pointer is being set.\r
989 @param MinStatePointer The physical address of the MINSTATE buffer for the CPU\r
990 specified by CpuGlobalId.\r
991\r
992 @retval EFI_SAL_SUCCESS The MINSTATE pointer was set for the specified CPU.\r
993 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
994\r
995**/\r
996SAL_RETURN_REGS\r
997EFIAPI\r
998EsalSetMinState (\r
999 IN UINT64 CpuGlobalId,\r
1000 IN EFI_PHYSICAL_ADDRESS MinStatePointer\r
1001 )\r
1002{\r
1003 return EsalCall (\r
1004 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
1005 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
1006 SetMinStateFunctionId, \r
1007 CpuGlobalId, \r
1008 MinStatePointer, \r
1009 0, \r
1010 0, \r
1011 0, \r
1012 0, \r
1013 0\r
1014 );\r
1015}\r
1016\r
1017/**\r
1018 Wrapper for the EsalGetMinStateFunctionId service of Extended SAL MP Services Class.\r
1019 \r
1020 This function is a wrapper for the EsalGetMinStateFunctionId service of Extended SAL\r
1021 MP Services Class. See EsalGetMinStateFunctionId of Extended SAL Specification.\r
1022\r
1023 @param CpuGlobalId The Global ID for the CPU whose MINSTATE pointer is being retrieved.\r
1024\r
1025 @retval EFI_SAL_SUCCESS The MINSTATE pointer for the specified CPU was retrieved.\r
1026 @retval EFI_SAL_NO_INFORMATION The specified CPU is not in the database.\r
1027\r
1028**/\r
1029SAL_RETURN_REGS\r
1030EFIAPI\r
1031EsalGetMinState (\r
1032 IN UINT64 CpuGlobalId\r
1033 )\r
1034{\r
1035 return EsalCall (\r
1036 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_LO,\r
1037 EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID_HI,\r
1038 GetMinStateFunctionId, \r
1039 CpuGlobalId, \r
1040 0, \r
1041 0, \r
1042 0, \r
1043 0, \r
1044 0, \r
1045 0\r
1046 );\r
1047}\r
1048\r
1049/**\r
1050 Wrapper for the EsalMcsGetStateInfoFunctionId service of Extended SAL MCA Services Class.\r
1051 \r
1052 This function is a wrapper for the EsalMcsGetStateInfoFunctionId service of Extended SAL\r
1053 MCA Services Class. See EsalMcsGetStateInfoFunctionId of Extended SAL Specification.\r
1054\r
1055 @param CpuGlobalId The Global ID for the CPU whose MCA state buffer is being retrieved.\r
1056 @param StateBufferPointer A pointer to the returned MCA state buffer.\r
1057 @param RequiredStateBufferSize A pointer to the size, in bytes, of the returned MCA state buffer.\r
1058\r
1059 @retval EFI_SUCCESS MINSTATE successfully got and size calculated.\r
1060 @retval EFI_SAL_NO_INFORMATION Fail to get MINSTATE.\r
1061\r
1062**/\r
1063SAL_RETURN_REGS\r
1064EFIAPI\r
1065EsalMcaGetStateInfo (\r
1066 IN UINT64 CpuGlobalId,\r
1067 OUT EFI_PHYSICAL_ADDRESS *StateBufferPointer,\r
1068 OUT UINT64 *RequiredStateBufferSize\r
1069 )\r
1070{\r
1071 SAL_RETURN_REGS Regs;\r
1072\r
1073 Regs = EsalCall (\r
1074 EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID_LO,\r
1075 EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID_HI,\r
1076 McaGetStateInfoFunctionId, \r
1077 CpuGlobalId, \r
1078 0, \r
1079 0, \r
1080 0, \r
1081 0, \r
1082 0, \r
1083 0\r
1084 );\r
1085\r
1086 *StateBufferPointer = (EFI_PHYSICAL_ADDRESS) Regs.r9;\r
1087 *RequiredStateBufferSize = (UINT64) Regs.r10;\r
1088\r
1089 return Regs;\r
1090}\r
1091\r
1092/**\r
1093 Wrapper for the EsalMcaRegisterCpuFunctionId service of Extended SAL MCA Services Class.\r
1094 \r
1095 This function is a wrapper for the EsalMcaRegisterCpuFunctionId service of Extended SAL\r
1096 MCA Services Class. See EsalMcaRegisterCpuFunctionId of Extended SAL Specification.\r
1097\r
1098 @param CpuGlobalId The Global ID for the CPU whose MCA state buffer is being set.\r
1099 @param StateBufferPointer A pointer to the MCA state buffer.\r
1100\r
1101 @retval EFI_SAL_NO_INFORMATION Cannot get the processor info with the CpuId\r
1102 @retval EFI_SUCCESS Save the processor's state info successfully\r
1103\r
1104**/\r
1105SAL_RETURN_REGS\r
1106EFIAPI\r
1107EsalMcaRegisterCpu (\r
1108 IN UINT64 CpuGlobalId,\r
1109 IN EFI_PHYSICAL_ADDRESS StateBufferPointer\r
1110 )\r
1111{\r
1112 return EsalCall (\r
1113 EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID_LO,\r
1114 EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID_HI,\r
1115 McaRegisterCpuFunctionId, \r
1116 CpuGlobalId, \r
1117 StateBufferPointer, \r
1118 0, \r
1119 0, \r
1120 0, \r
1121 0, \r
1122 0\r
1123 );\r
1124}\r