Home | History | Annotate | Download | only in Library
      1 /** @file
      2   Helper Library for ACPI
      3 
      4   Copyright (c) 2014-2016, ARM Ltd. All rights reserved.
      5 
      6   This program and the accompanying materials
      7   are licensed and made available under the terms and conditions of the BSD License
      8   which accompanies this distribution.  The full text of the license may be found at
      9   http://opensource.org/licenses/bsd-license.php
     10 
     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.
     13 
     14 **/
     15 
     16 #ifndef __ACPI_LIB_H__
     17 #define __ACPI_LIB_H__
     18 
     19 #include <Uefi.h>
     20 
     21 #include <IndustryStandard/Acpi10.h>
     22 
     23 //
     24 // Macros for the Generic Address Space
     25 //
     26 #define NULL_GAS               { EFI_ACPI_5_0_SYSTEM_MEMORY,  0, 0, EFI_ACPI_5_0_UNDEFINED, 0L }
     27 #define ARM_GAS8(Address)      { EFI_ACPI_5_0_SYSTEM_MEMORY,  8, 0, EFI_ACPI_5_0_BYTE,      Address }
     28 #define ARM_GAS16(Address)     { EFI_ACPI_5_0_SYSTEM_MEMORY, 16, 0, EFI_ACPI_5_0_WORD,      Address }
     29 #define ARM_GAS32(Address)     { EFI_ACPI_5_0_SYSTEM_MEMORY, 32, 0, EFI_ACPI_5_0_DWORD,     Address }
     30 #define ARM_GASN(Address)      { EFI_ACPI_5_0_SYSTEM_MEMORY,  0, 0, EFI_ACPI_5_0_DWORD,     Address }
     31 
     32 //
     33 // Macros for the Multiple APIC Description Table (MADT)
     34 //
     35 #define EFI_ACPI_5_0_GIC_DISTRIBUTOR_INIT(GicDistHwId, GicDistBase, GicDistVector) \
     36   { \
     37     EFI_ACPI_5_0_GICD, sizeof (EFI_ACPI_5_0_GIC_DISTRIBUTOR_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
     38     GicDistHwId, GicDistBase, GicDistVector, EFI_ACPI_RESERVED_DWORD \
     39   }
     40 
     41 #define EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT(GicDistHwId, GicDistBase, GicDistVector, GicVersion) \
     42   { \
     43     EFI_ACPI_6_0_GICD, sizeof (EFI_ACPI_6_0_GIC_DISTRIBUTOR_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
     44     GicDistHwId, GicDistBase, GicDistVector, GicVersion, \
     45     {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE} \
     46   }
     47 
     48 // Note the parking protocol is configured by UEFI if required
     49 #define EFI_ACPI_5_0_GIC_STRUCTURE_INIT(GicId, AcpiCpuId, Flags, PmuIrq, GicBase) \
     50   { \
     51     EFI_ACPI_5_0_GIC, sizeof (EFI_ACPI_5_0_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
     52     GicId, AcpiCpuId, Flags, 0, PmuIrq, 0, GicBase \
     53   }
     54 
     55 // Note the parking protocol is configured by UEFI if required
     56 #define EFI_ACPI_5_1_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags, PmuIrq,    \
     57     GicBase, GicVBase, GicHBase, GsivId, GicRBase)                                   \
     58   {                                                                                  \
     59     EFI_ACPI_5_1_GIC, sizeof (EFI_ACPI_5_1_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD,   \
     60     GicId, AcpiCpuUid, Flags, 0, PmuIrq, 0, GicBase, GicVBase, GicHBase,             \
     61     GsivId, GicRBase, Mpidr                                                          \
     62   }
     63 
     64 #define EFI_ACPI_6_0_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags, PmuIrq,    \
     65     GicBase, GicVBase, GicHBase, GsivId, GicRBase, Efficiency)                       \
     66   {                                                                                  \
     67     EFI_ACPI_6_0_GIC, sizeof (EFI_ACPI_6_0_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD,   \
     68     GicId, AcpiCpuUid, Flags, 0, PmuIrq, 0, GicBase, GicVBase, GicHBase,             \
     69     GsivId, GicRBase, Mpidr, Efficiency,                                             \
     70     {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}         \
     71   }
     72 
     73 #define EFI_ACPI_6_0_GIC_MSI_FRAME_INIT(GicMsiFrameId, PhysicalBaseAddress, Flags, SPICount, SPIBase) \
     74   { \
     75     EFI_ACPI_6_0_GIC_MSI_FRAME, sizeof (EFI_ACPI_6_0_GIC_MSI_FRAME_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
     76     GicMsiFrameId, PhysicalBaseAddress, Flags, SPICount, SPIBase \
     77   }
     78 
     79 //
     80 // SBSA Generic Watchdog
     81 //
     82 #define EFI_ACPI_5_1_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT(RefreshFramePhysicalAddress,                  \
     83     ControlFramePhysicalAddress, WatchdogTimerGSIV, WatchdogTimerFlags)                                 \
     84   {                                                                                                     \
     85     EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG, sizeof(EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE), \
     86     EFI_ACPI_RESERVED_BYTE, RefreshFramePhysicalAddress, ControlFramePhysicalAddress,                   \
     87     WatchdogTimerGSIV, WatchdogTimerFlags                                                               \
     88   }
     89 
     90 typedef
     91 BOOLEAN
     92 (EFIAPI *EFI_LOCATE_ACPI_CHECK) (
     93   IN  EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader
     94   );
     95 
     96 /**
     97   Locate and Install the ACPI tables from the Firmware Volume if it verifies
     98   the function condition.
     99 
    100   @param  AcpiFile                Guid of the ACPI file into the Firmware Volume
    101   @param  CheckAcpiTableFunction  Function that checks if the ACPI table should be installed
    102 
    103   @return EFI_SUCCESS             The function completed successfully.
    104   @return EFI_NOT_FOUND           The protocol could not be located.
    105   @return EFI_OUT_OF_RESOURCES    There are not enough resources to find the protocol.
    106 
    107 **/
    108 EFI_STATUS
    109 LocateAndInstallAcpiFromFvConditional (
    110   IN CONST EFI_GUID*        AcpiFile,
    111   IN EFI_LOCATE_ACPI_CHECK  CheckAcpiTableFunction
    112   );
    113 
    114 /**
    115   Locate and Install the ACPI tables from the Firmware Volume
    116 
    117   @param  AcpiFile              Guid of the ACPI file into the Firmware Volume
    118 
    119   @return EFI_SUCCESS           The function completed successfully.
    120   @return EFI_NOT_FOUND         The protocol could not be located.
    121   @return EFI_OUT_OF_RESOURCES  There are not enough resources to find the protocol.
    122 
    123 **/
    124 EFI_STATUS
    125 LocateAndInstallAcpiFromFv (
    126   IN CONST EFI_GUID* AcpiFile
    127   );
    128 
    129 #endif // __ACPI_LIB_H__
    130