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