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