]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiPalCallLib/PalCallLib.c
Refine code for BasePalCallLibNull & PeiPalCallLib.
[mirror_edk2.git] / MdePkg / Library / PeiPalCallLib / PalCallLib.c
1 /** @file
2 PAL Call Services Function.
3
4 Copyright (c) 2006 - 2008 Intel Corporation. All rights reserved
5 This software and associated documentation (if any) is furnished
6 under a license and may only be used or copied in accordance
7 with the terms of the license. Except as permitted by such
8 license, no part of this software or documentation may be
9 reproduced, stored in a retrieval system, or transmitted in any
10 form or by any means without the express written consent of
11 Intel Corporation.
12
13 Module Name: PalCallLib.c
14
15 **/
16
17
18 #include <PiPei.h>
19
20 #include <Ppi/SecPlatformInformation.h>
21
22 #include <Library/PalCallLib.h>
23 #include <Library/PeiServicesTablePointerLib.h>
24 #include <Library/PeiServicesLib.h>
25 #include <Library/BaseLib.h>
26 #include <Library/DebugLib.h>
27
28 /**
29 Makes a PAL procedure call.
30
31 This is a wrapper function to make a PAL procedure call. Based on the Index value,
32 this API will make static or stacked PAL call. Architected procedures may be designated
33 as required or optional. If a PAL procedure is specified as optional, a unique return
34 code of 0xFFFFFFFFFFFFFFFF is returned in the Status field of the PAL_CALL_RETURN structure.
35 This indicates that the procedure is not present in this PAL implementation. It is the
36 caller's responsibility to check for this return code after calling any optional PAL
37 procedure. No parameter checking is performed on the 4 input parameters, but there are
38 some common rules that the caller should follow when making a PAL call. Any address
39 passed to PAL as buffers for return parameters must be 8-byte aligned. Unaligned addresses
40 may cause undefined results. For those parameters defined as reserved or some fields
41 defined as reserved must be zero filled or the invalid argument return value may be
42 returned or undefined result may occur during the execution of the procedure.
43 This function is only available on IPF.
44
45 @param Index The PAL procedure Index number.
46 @param Arg2 The 2nd parameter for PAL procedure calls.
47 @param Arg3 The 3rd parameter for PAL procedure calls.
48 @param Arg4 The 4th parameter for PAL procedure calls.
49
50 @return Structure returned from the PAL Call procedure, including the status and return value.
51
52 **/
53 PAL_CALL_RETURN
54 EFIAPI
55 PalCall (
56 IN UINT64 Index,
57 IN UINT64 Arg2,
58 IN UINT64 Arg3,
59 IN UINT64 Arg4
60 )
61 {
62 UINT64 PalCallAddress;
63 PAL_CALL_RETURN ReturnVal;
64 CONST EFI_PEI_SERVICES **PeiServices;
65 EFI_STATUS Status;
66 EFI_SEC_PLATFORM_INFORMATION_PPI *SecPlatformPpi;
67 IPF_HANDOFF_STATUS IpfStatus;
68 UINT64 RecordSize;
69
70 //
71 // Get PEI Service Table Pointer
72 //
73 PeiServices = (CONST EFI_PEI_SERVICES **) GetPeiServicesTablePointer ();
74
75 //
76 // Locate SEC Platform Information PPI
77 //
78 Status = PeiServicesLocatePpi (
79 &gEfiSecPlatformInformationPpiGuid,
80 0,
81 NULL,
82 (VOID **)&SecPlatformPpi
83 );
84 ASSERT_EFI_ERROR (Status);
85
86 //
87 // Retrieve PAL call address from platform information reported by the PPI
88 //
89 RecordSize = sizeof (IpfStatus);
90 SecPlatformPpi->PlatformInformation (
91 PeiServices,
92 &RecordSize,
93 (EFI_SEC_PLATFORM_INFORMATION_RECORD *) &IpfStatus
94 );
95 PalCallAddress = IpfStatus.PalCallAddress;
96
97 ReturnVal = AsmPalCall (PalCallAddress, Index, Arg2, Arg3, Arg4);
98
99 return ReturnVal;
100 }
101