Home | History | Annotate | Download | only in PeiPalLib
      1 /** @file
      2   PAL Call Services Function.
      3 
      4   Copyright (c) 2006 - 2010, 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 
     16 #include <PiPei.h>
     17 
     18 #include <Ppi/SecPlatformInformation.h>
     19 
     20 #include <Library/PalLib.h>
     21 #include <Library/PeiServicesTablePointerLib.h>
     22 #include <Library/PeiServicesLib.h>
     23 #include <Library/BaseLib.h>
     24 #include <Library/DebugLib.h>
     25 
     26 /**
     27   Makes a PAL procedure call.
     28 
     29   This is a wrapper function to make a PAL procedure call.  Based on the Index value,
     30   this API will make static or stacked PAL call. Architected procedures may be designated
     31   as required or optional.  If a PAL procedure is specified as optional, a unique return
     32   code of 0xFFFFFFFFFFFFFFFF is returned in the Status field of the PAL_CALL_RETURN structure.
     33   This indicates that the procedure is not present in this PAL implementation.  It is the
     34   caller's responsibility to check for this return code after calling any optional PAL
     35   procedure. No parameter checking is performed on the 4 input parameters, but there are
     36   some common rules that the caller should follow when making a PAL call.  Any address
     37   passed to PAL as buffers for return parameters must be 8-byte aligned.  Unaligned addresses
     38   may cause undefined results.  For those parameters defined as reserved or some fields
     39   defined as reserved must be zero filled or the invalid argument return value may be
     40   returned or undefined result may occur during the execution of the procedure.
     41   This function is only available on IPF.
     42 
     43   @param Index  The PAL procedure Index number.
     44   @param Arg2   The 2nd parameter for PAL procedure calls.
     45   @param Arg3   The 3rd parameter for PAL procedure calls.
     46   @param Arg4   The 4th parameter for PAL procedure calls.
     47 
     48   @return Structure returned from the PAL Call procedure, including the status and return value.
     49 
     50 **/
     51 PAL_CALL_RETURN
     52 EFIAPI
     53 PalCall (
     54   IN UINT64                  Index,
     55   IN UINT64                  Arg2,
     56   IN UINT64                  Arg3,
     57   IN UINT64                  Arg4
     58   )
     59 {
     60   UINT64                              PalCallAddress;
     61   PAL_CALL_RETURN                     ReturnVal;
     62   CONST EFI_PEI_SERVICES              **PeiServices;
     63   EFI_STATUS                          Status;
     64   EFI_SEC_PLATFORM_INFORMATION_PPI    *SecPlatformPpi;
     65   EFI_SEC_PLATFORM_INFORMATION_RECORD SecPlatformInfoRecord;
     66   UINT64                              RecordSize;
     67 
     68   //
     69   // Get PEI Service Table Pointer
     70   //
     71   PeiServices = GetPeiServicesTablePointer ();
     72 
     73   //
     74   // Locate SEC Platform Information PPI
     75   //
     76   Status = PeiServicesLocatePpi (
     77              &gEfiSecPlatformInformationPpiGuid,
     78              0,
     79              NULL,
     80              (VOID **)&SecPlatformPpi
     81              );
     82   ASSERT_EFI_ERROR (Status);
     83 
     84   //
     85   // Retrieve PAL call address from platform information reported by the PPI
     86   //
     87   RecordSize = sizeof (SecPlatformInfoRecord);
     88   SecPlatformPpi->PlatformInformation (
     89                     PeiServices,
     90                     &RecordSize,
     91                     &SecPlatformInfoRecord
     92                     );
     93   PalCallAddress = SecPlatformInfoRecord.ItaniumHealthFlags.PalCallAddress;
     94 
     95   ReturnVal = AsmPalCall (PalCallAddress, Index, Arg2, Arg3, Arg4);
     96 
     97   return ReturnVal;
     98 }
     99 
    100