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