]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiPalLib/PeiPalLib.c
1.Removed PrintXY from Graphics Library.
[mirror_edk2.git] / MdePkg / Library / PeiPalLib / PeiPalLib.c
CommitLineData
ed8717c5 1/** @file\r
2 PAL Call Services Function.\r
3\r
08a458be 4 Copyright (c) 2006 -2008, Intel Corporation All rights\r
5 reserved. This program and the accompanying materials are\r
6 licensed and made available under the terms and conditions of\r
7 the BSD License which accompanies this distribution. The full\r
8 text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
ed8717c5 10\r
08a458be 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
ed8717c5 13\r
14**/\r
15\r
16\r
17#include <PiPei.h>\r
ed8717c5 18\r
19#include <Ppi/SecPlatformInformation.h>\r
20\r
4d52c1f3 21#include <Library/PalLib.h>\r
ed8717c5 22#include <Library/PeiServicesTablePointerLib.h>\r
23#include <Library/PeiServicesLib.h>\r
24#include <Library/BaseLib.h>\r
25#include <Library/DebugLib.h>\r
26\r
27/**\r
ed8717c5 28 Makes a PAL procedure call.\r
4cb0344e 29\r
ed8717c5 30 This is a wrapper function to make a PAL procedure call. Based on the Index value,\r
31 this API will make static or stacked PAL call. Architected procedures may be designated\r
32 as required or optional. If a PAL procedure is specified as optional, a unique return\r
33 code of 0xFFFFFFFFFFFFFFFF is returned in the Status field of the PAL_CALL_RETURN structure.\r
34 This indicates that the procedure is not present in this PAL implementation. It is the\r
ac644614 35 caller's responsibility to check for this return code after calling any optional PAL\r
ed8717c5 36 procedure. No parameter checking is performed on the 4 input parameters, but there are\r
37 some common rules that the caller should follow when making a PAL call. Any address\r
38 passed to PAL as buffers for return parameters must be 8-byte aligned. Unaligned addresses\r
39 may cause undefined results. For those parameters defined as reserved or some fields\r
40 defined as reserved must be zero filled or the invalid argument return value may be\r
41 returned or undefined result may occur during the execution of the procedure.\r
42 This function is only available on IPF.\r
43\r
4cb0344e 44 @param Index The PAL procedure Index number.\r
45 @param Arg2 The 2nd parameter for PAL procedure calls.\r
46 @param Arg3 The 3rd parameter for PAL procedure calls.\r
47 @param Arg4 The 4th parameter for PAL procedure calls.\r
ed8717c5 48\r
4cb0344e 49 @return Structure returned from the PAL Call procedure, including the status and return value.\r
ed8717c5 50\r
51**/\r
52PAL_CALL_RETURN\r
53EFIAPI\r
54PalCall (\r
55 IN UINT64 Index,\r
56 IN UINT64 Arg2,\r
57 IN UINT64 Arg3,\r
58 IN UINT64 Arg4\r
59 )\r
60{\r
61 UINT64 PalCallAddress;\r
62 PAL_CALL_RETURN ReturnVal;\r
a88c8915 63 CONST EFI_PEI_SERVICES **PeiServices;\r
ed8717c5 64 EFI_STATUS Status;\r
65 EFI_SEC_PLATFORM_INFORMATION_PPI *SecPlatformPpi;\r
66 IPF_HANDOFF_STATUS IpfStatus;\r
67 UINT64 RecordSize;\r
68\r
69 //\r
4cb0344e 70 // Get PEI Service Table Pointer\r
ed8717c5 71 //\r
5240b97c 72 PeiServices = GetPeiServicesTablePointer ();\r
ed8717c5 73\r
74 //\r
4cb0344e 75 // Locate SEC Platform Information PPI\r
ed8717c5 76 //\r
ed8717c5 77 Status = PeiServicesLocatePpi (\r
4cb0344e 78 &gEfiSecPlatformInformationPpiGuid,\r
79 0,\r
80 NULL,\r
81 (VOID **)&SecPlatformPpi\r
82 );\r
ed8717c5 83 ASSERT_EFI_ERROR (Status);\r
84\r
4cb0344e 85 //\r
86 // Retrieve PAL call address from platform information reported by the PPI\r
87 //\r
ed8717c5 88 RecordSize = sizeof (IpfStatus);\r
89 SecPlatformPpi->PlatformInformation (\r
4cb0344e 90 PeiServices,\r
91 &RecordSize,\r
92 (EFI_SEC_PLATFORM_INFORMATION_RECORD *) &IpfStatus\r
93 );\r
ed8717c5 94 PalCallAddress = IpfStatus.PalCallAddress;\r
95\r
96 ReturnVal = AsmPalCall (PalCallAddress, Index, Arg2, Arg3, Arg4);\r
97\r
98 return ReturnVal;\r
99}\r
100\r