1 /** @file
2 PAL Library Class implementation built upon Extended SAL Procedures.
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/ExtendedSalServiceClasses.h>
18
19 #include <Library/PalLib.h>
20 #include <Library/ExtendedSalLib.h>
21
22 /**
23 Makes a PAL procedure call.
24
25 This is a wrapper function to make a PAL procedure call. Based on the Index value,
26 this API will make static or stacked PAL call. Architected procedures may be designated
27 as required or optional. If a PAL procedure is specified as optional, a unique return
28 code of 0xFFFFFFFFFFFFFFFF is returned in the Status field of the PAL_CALL_RETURN structure.
29 This indicates that the procedure is not present in this PAL implementation. It is the
30 caller's responsibility to check for this return code after calling any optional PAL
31 procedure. No parameter checking is performed on the 4 input parameters, but there are
32 some common rules that the caller should follow when making a PAL call. Any address
33 passed to PAL as buffers for return parameters must be 8-byte aligned. Unaligned addresses
34 may cause undefined results. For those parameters defined as reserved or some fields
35 defined as reserved must be zero filled or the invalid argument return value may be
36 returned or undefined result may occur during the execution of the procedure.
37 This function is only available on IPF.
38
39 @param Index - The PAL procedure Index number.
40 @param Arg2 - The 2nd parameter for PAL procedure calls.
41 @param Arg3 - The 3rd parameter for PAL procedure calls.
42 @param Arg4 - The 4th parameter for PAL procedure calls.
43
44 @return structure returned from the PAL Call procedure, including the status and return value.
45
46 **/
47 PAL_CALL_RETURN
48 EFIAPI
PalCall(IN UINT64 Index,IN UINT64 Arg2,IN UINT64 Arg3,IN UINT64 Arg4)49 PalCall (
50 IN UINT64 Index,
51 IN UINT64 Arg2,
52 IN UINT64 Arg3,
53 IN UINT64 Arg4
54 )
55 {
56 SAL_RETURN_REGS SalReturn;
57 PAL_CALL_RETURN *PalReturn;
58
59 SalReturn = EsalCall (
60 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_LO,
61 EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID_HI,
62 PalProcFunctionId,
63 Index,
64 Arg2,
65 Arg3,
66 Arg4,
67 0,
68 0,
69 0
70 );
71 PalReturn = (PAL_CALL_RETURN *) (UINTN) (&SalReturn);
72 return *PalReturn;
73 }
74