Home | History | Annotate | Download | only in Pei
      1 /** @file
      2   Status code PEIM which produces Status Code PPI.
      3 
      4   Copyright (c) 2006 - 2009, 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 "StatusCodePei.h"
     16 
     17 EFI_PEI_PROGRESS_CODE_PPI     mStatusCodePpi = {
     18   ReportDispatcher
     19   };
     20 
     21 EFI_PEI_PPI_DESCRIPTOR        mStatusCodePpiDescriptor = {
     22   EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
     23   &gEfiPeiStatusCodePpiGuid,
     24   &mStatusCodePpi
     25   };
     26 
     27 /**
     28   Publishes an interface that allows PEIMs to report status codes.
     29 
     30   This function implements EFI_PEI_PROGRESS_CODE_PPI.ReportStatusCode().
     31   It publishes an interface that allows PEIMs to report status codes.
     32 
     33   @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
     34   @param  CodeType         Indicates the type of status code being reported.
     35   @param  Value            Describes the current status of a hardware or
     36                            software entity. This includes information about the class and
     37                            subclass that is used to classify the entity as well as an operation.
     38                            For progress codes, the operation is the current activity.
     39                            For error codes, it is the exception.For debug codes,it is not defined at this time.
     40   @param  Instance         The enumeration of a hardware or software entity within
     41                            the system. A system may contain multiple entities that match a class/subclass
     42                            pairing. The instance differentiates between them. An instance of 0 indicates
     43                            that instance information is unavailable, not meaningful, or not relevant.
     44                            Valid instance numbers start with 1.
     45   @param  CallerId         This optional parameter may be used to identify the caller.
     46                            This parameter allows the status code driver to apply different rules to
     47                            different callers.
     48   @param  Data             This optional parameter may be used to pass additional data.
     49 
     50   @retval EFI_SUCCESS      The function completed successfully.
     51 
     52 **/
     53 EFI_STATUS
     54 EFIAPI
     55 ReportDispatcher (
     56   IN CONST EFI_PEI_SERVICES         **PeiServices,
     57   IN EFI_STATUS_CODE_TYPE           CodeType,
     58   IN EFI_STATUS_CODE_VALUE          Value,
     59   IN UINT32                         Instance,
     60   IN CONST EFI_GUID                 *CallerId OPTIONAL,
     61   IN CONST EFI_STATUS_CODE_DATA     *Data OPTIONAL
     62   )
     63 {
     64   if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
     65     SerialStatusCodeReportWorker (
     66       CodeType,
     67       Value,
     68       Instance,
     69       CallerId,
     70       Data
     71       );
     72   }
     73   if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
     74     MemoryStatusCodeReportWorker (
     75       CodeType,
     76       Value,
     77       Instance
     78       );
     79   }
     80   if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
     81     //
     82     // Call OEM hook status code library API to report status code to OEM device
     83     //
     84     OemHookStatusCodeReport (
     85       CodeType,
     86       Value,
     87       Instance,
     88       (EFI_GUID *)CallerId,
     89       (EFI_STATUS_CODE_DATA *)Data
     90       );
     91   }
     92 
     93   return EFI_SUCCESS;
     94 }
     95 
     96 /**
     97   Entry point of Status Code PEIM.
     98 
     99   This function is the entry point of this Status Code PEIM.
    100   It initializes supported status code devices according to PCD settings,
    101   and installs Status Code PPI.
    102 
    103   @param  FileHandle  Handle of the file being invoked.
    104   @param  PeiServices Describes the list of possible PEI Services.
    105 
    106   @retval EFI_SUCESS  The entry point of DXE IPL PEIM executes successfully.
    107 
    108 **/
    109 EFI_STATUS
    110 EFIAPI
    111 PeiStatusCodeDriverEntry (
    112   IN       EFI_PEI_FILE_HANDLE  FileHandle,
    113   IN CONST EFI_PEI_SERVICES     **PeiServices
    114   )
    115 {
    116   EFI_STATUS                  Status;
    117 
    118   //
    119   // Dispatch initialization request to sub-statuscode-devices.
    120   // If enable UseSerial, then initialize serial port.
    121   // if enable UseMemory, then initialize memory status code worker.
    122   // if enable UseOEM, then initialize Oem status code.
    123   //
    124   if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
    125     Status = SerialPortInitialize();
    126     ASSERT_EFI_ERROR (Status);
    127   }
    128   if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
    129     Status = MemoryStatusCodeInitializeWorker ();
    130     ASSERT_EFI_ERROR  (Status);
    131   }
    132   if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
    133     Status = OemHookStatusCodeInitialize ();
    134     ASSERT_EFI_ERROR  (Status);
    135   }
    136 
    137   //
    138   // Install Status Code PPI.
    139   // It serves the PEI Service ReportStatusCode.
    140   //
    141   Status = PeiServicesInstallPpi (&mStatusCodePpiDescriptor);
    142   ASSERT_EFI_ERROR (Status);
    143 
    144   return EFI_SUCCESS;
    145 }
    146 
    147