Home | History | Annotate | Download | only in AmdStyxLib
      1 /** @file
      2 *
      3 *  Copyright (c) 2011-2013, ARM Limited. All rights reserved.<BR>
      4 *  Copyright (c) 2014 - 2016, AMD Inc. All rights reserved.<BR>
      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   Derived from:
     17    ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c
     18 
     19 **/
     20 
     21 //
     22 // The package level header files this module uses
     23 //
     24 #include <PiPei.h>
     25 
     26 //
     27 // The protocols, PPI and GUID defintions for this module
     28 //
     29 #include <Ppi/ArmMpCoreInfo.h>
     30 #include <Guid/ArmMpCoreInfo.h>
     31 
     32 //
     33 // The Library classes this module consumes
     34 //
     35 #include <Library/PeimEntryPoint.h>
     36 #include <Library/PeiServicesLib.h>
     37 #include <Library/DebugLib.h>
     38 #include <Library/PcdLib.h>
     39 #include <Library/HobLib.h>
     40 #include <Library/ArmLib.h>
     41 #include <Library/ArmPlatformLib.h>
     42 #include <Library/BaseMemoryLib.h>
     43 
     44 
     45 extern EFI_GUID gAmdStyxMpCoreInfoGuid;
     46 
     47 
     48 UINTN
     49 ArmGetCpuCountPerCluster (
     50   VOID
     51   );
     52 
     53 
     54 /**
     55   Return the current Boot Mode
     56 
     57   This function returns the boot reason on the platform
     58 
     59   @return   Return the current Boot Mode of the platform
     60 
     61 **/
     62 EFI_BOOT_MODE
     63 ArmPlatformGetBootMode (
     64   VOID
     65   )
     66 {
     67   return BOOT_WITH_FULL_CONFIGURATION;
     68 }
     69 
     70 
     71 /**
     72   Initialize controllers that must setup in the normal world
     73 
     74   This function is called by the ArmPlatformPkg/Pei or ArmPlatformPkg/Pei/PlatformPeim
     75   in the PEI phase.
     76 
     77 **/
     78 RETURN_STATUS
     79 ArmPlatformInitialize (
     80   IN  UINTN                     MpId
     81   )
     82 {
     83   if (!ArmPlatformIsPrimaryCore (MpId)) {
     84     return RETURN_SUCCESS;
     85   }
     86 
     87   // XXX Place holder XXX ...
     88 
     89   return RETURN_SUCCESS;
     90 }
     91 
     92 
     93 /**
     94   Initialize the system (or sometimes called permanent) memory
     95 
     96   This memory is generally represented by the DRAM.
     97 
     98 **/
     99 VOID
    100 ArmPlatformInitializeSystemMemory (
    101   VOID
    102   )
    103 {
    104   // Nothing to do here
    105 }
    106 
    107 
    108 //
    109 // Return list of cores in the system
    110 //
    111 EFI_STATUS
    112 PrePeiCoreGetMpCoreInfo (
    113   OUT UINTN                   *ArmCoreCount,
    114   OUT ARM_CORE_INFO           **ArmCoreInfoTable
    115   )
    116 {
    117   EFI_PEI_HOB_POINTERS    Hob;
    118 
    119   if (ArmIsMpCore()) {
    120     // Iterate through the HOBs and find if there is ARM PROCESSOR ENTRY HOB
    121     for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
    122       // Check for Correct HOB type
    123       if ((GET_HOB_TYPE (Hob)) == EFI_HOB_TYPE_GUID_EXTENSION) {
    124         // Check for correct GUID type
    125         if (CompareGuid(&(Hob.Guid->Name), &gAmdStyxMpCoreInfoGuid)) {
    126           *ArmCoreInfoTable = (ARM_CORE_INFO *) GET_GUID_HOB_DATA(Hob);
    127           *ArmCoreCount = GET_GUID_HOB_DATA_SIZE(Hob)/sizeof(ARM_CORE_INFO);
    128           return EFI_SUCCESS;
    129         }
    130       }
    131     }
    132   }
    133 
    134   return EFI_UNSUPPORTED;
    135 }
    136 
    137 
    138 ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = { PrePeiCoreGetMpCoreInfo };
    139 
    140 EFI_PEI_PPI_DESCRIPTOR      gPlatformPpiTable[] = {
    141   {
    142     EFI_PEI_PPI_DESCRIPTOR_PPI,
    143     &gArmMpCoreInfoPpiGuid,
    144     &mMpCoreInfoPpi
    145   }
    146 };
    147 
    148 
    149 VOID
    150 ArmPlatformGetPlatformPpiList (
    151   OUT UINTN                   *PpiListSize,
    152   OUT EFI_PEI_PPI_DESCRIPTOR  **PpiList
    153   )
    154 {
    155   if (ArmIsMpCore()) {
    156     *PpiListSize = sizeof(gPlatformPpiTable);
    157     *PpiList = gPlatformPpiTable;
    158   } else {
    159     *PpiListSize = 0;
    160     *PpiList = NULL;
    161   }
    162 }
    163 
    164 
    165