2 PAL Library implementation built upon UEFI.
4 Copyright (c) 2007 - 2008, Intel Corporation All rights
5 reserved. This program and the accompanying materials are
6 licensed and made available under the terms and conditions of
7 the BSD License which accompanies this distribution. The full
8 text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <IndustryStandard/Sal.h>
19 #include <Library/UefiLib.h>
20 #include <Library/BaseLib.h>
21 #include <Library/DebugLib.h>
23 #include <Guid/SalSystemTable.h>
28 Makes a PAL procedure call.
30 This is a wrapper function to make a PAL procedure call. Based on the Index value,
31 this API will make static or stacked PAL call. Architected procedures may be designated
32 as required or optional. If a PAL procedure is specified as optional, a unique return
33 code of 0xFFFFFFFFFFFFFFFF is returned in the Status field of the PAL_CALL_RETURN structure.
34 This indicates that the procedure is not present in this PAL implementation. It is the
35 caller's responsibility to check for this return code after calling any optional PAL
36 procedure. No parameter checking is performed on the 4 input parameters, but there are
37 some common rules that the caller should follow when making a PAL call. Any address
38 passed to PAL as buffers for return parameters must be 8-byte aligned. Unaligned addresses
39 may cause undefined results. For those parameters defined as reserved or some fields
40 defined as reserved must be zero filled or the invalid argument return value may be
41 returned or undefined result may occur during the execution of the procedure.
42 This function is only available on IPF.
44 @param Index - The PAL procedure Index number.
45 @param Arg2 - The 2nd parameter for PAL procedure calls.
46 @param Arg3 - The 3rd parameter for PAL procedure calls.
47 @param Arg4 - The 4th parameter for PAL procedure calls.
49 @return structure returned from the PAL Call procedure, including the status and return value.
62 // mPalProcEntry is initialized in library constructor as PAL entry.
75 The constructor function of UEFI Pal Lib.
77 The constructor function looks up the SAL System Table in the EFI System Configuration
78 Table. Once the SAL System Table is found, the PAL Entry Point in the SAL System Table
79 will be derived and stored inot a global variable for library usage.
80 It will ASSERT() if the SAL System Table cannot be found or the data in the SAL System
81 Table is not the valid data.
83 @param ImageHandle The firmware allocated handle for the EFI image.
84 @param SystemTable A pointer to the EFI System Table.
86 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
91 UefiPalLibConstructor (
92 IN EFI_HANDLE ImageHandle
,
93 IN EFI_SYSTEM_TABLE
*SystemTable
97 SAL_ST_ENTRY_POINT_DESCRIPTOR
*SalStEntryDes
;
98 SAL_SYSTEM_TABLE_HEADER
*SalSystemTable
;
100 Status
= EfiGetSystemConfigurationTable (
101 &gEfiSalSystemTableGuid
,
102 (VOID
**) &SalSystemTable
105 ASSERT_EFI_ERROR (Status
);
108 // Move the SAL System Table point to the first Entry
109 // Due to the SAL Entry is in ascending order with the Entry type,
110 // the type 0 Entry should be the first if exist.
112 SalStEntryDes
= (SAL_ST_ENTRY_POINT_DESCRIPTOR
*)(SalSystemTable
+ 1);
115 // Assure the SAL ENTRY Type is 0
117 ASSERT (SalStEntryDes
->Type
== EFI_SAL_ST_ENTRY_POINT
);
119 mPalProcEntry
= SalStEntryDes
->PalProcEntry
;
121 // Make sure the PalCallAddress has the valid value
123 ASSERT (mPalProcEntry
!= 0);