Home | History | Annotate | Download | only in MonoStatusCode
      1 /** @file
      2 
      3   Copyright (c) 2004  - 2014, Intel Corporation. All rights reserved.<BR>
      4 
      5   This program and the accompanying materials are licensed and made available under
      7   the terms and conditions of the BSD License that accompanies this distribution.
      9   The full text of the license may be found at
     11   http://opensource.org/licenses/bsd-license.php.
     13 
     15   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     17   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     19 
     21 
     23 Module Name:
     24 
     25 
     26   MonoStatusCode.c
     27 
     28 Abstract:
     29 
     30   PEIM to provide the status code functionality, to aid in system debug.
     31   It includes output to 0x80 port and/or to serial port.
     32   This PEIM is monolithic. Different platform should provide different library.
     33 
     34 --*/
     35 
     36 #include "MonoStatusCode.h"
     37 #include "PlatformStatusCode.h"
     38 #define CMOS_EFI_DEBUG              0x14
     39 
     40 //
     41 // Module globals
     42 //
     43 EFI_PEI_PROGRESS_CODE_PPI     mStatusCodePpi = { PlatformReportStatusCode };
     44 
     45 EFI_PEI_PPI_DESCRIPTOR  mPpiListStatusCode = {
     46   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
     47   &gEfiPeiStatusCodePpiGuid,
     48   &mStatusCodePpi
     49 };
     50 
     51 //
     52 // Function implemenations
     53 //
     54 
     55 /**
     56   Translate from a DXE status code interface into a PEI-callable
     57   interface, making the PEI the least common denominator..
     58 
     59   Same as DXE ReportStatusCode RT service
     60 
     61 
     62 **/
     63 EFI_STATUS
     64 EFIAPI
     65 TranslateDxeStatusCodeToPeiStatusCode (
     66   IN EFI_STATUS_CODE_TYPE     CodeType,
     67   IN EFI_STATUS_CODE_VALUE    Value,
     68   IN UINT32                   Instance,
     69   IN EFI_GUID                 * CallerId,
     70   IN EFI_STATUS_CODE_DATA     * Data OPTIONAL
     71   )
     72 {
     73   return PlatformReportStatusCode (NULL, CodeType, Value, Instance, CallerId, Data);
     74 }
     75 
     76 /**
     77   Build a hob describing the status code listener that has been installed.
     78   This will be used by DXE code until a runtime status code listener is
     79   installed.
     80 
     81   @param PeiServices      General purpose services available to every PEIM.
     82 
     83   @retval Status          EFI_SUCCESS if the interface could be successfully
     84                           installed
     85 
     86 **/
     87 EFI_STATUS
     88 EFIAPI
     89 InitializeDxeReportStatusCode (
     90   IN const EFI_PEI_SERVICES       **PeiServices
     91   )
     92 {
     93   EFI_STATUS  Status = EFI_UNSUPPORTED;
     94 
     95   VOID        *Instance;
     96 
     97   VOID        *Result;
     98 
     99   Instance = (VOID *) (UINTN) TranslateDxeStatusCodeToPeiStatusCode;
    100 
    101   Result = BuildGuidDataHob (
    102              &gEfiStatusCodeRuntimeProtocolGuid,
    103              &Instance,
    104              sizeof (VOID *)
    105              );
    106   if (Result != NULL) {
    107     Status = EFI_SUCCESS;
    108   }
    109   return Status;
    110 }
    111 
    112 /**
    113   Initialize the platform status codes and publish the platform status code
    114   PPI.
    115 
    116   @param  FfsHeader      FV this PEIM was loaded from.
    117   @param  PeiServices    General purpose services available to every PEIM.
    118 
    119   @retval Status         EFI_SUCCESS
    120 
    121 **/
    122 VOID
    123 EFIAPI
    124 InitializeMonoStatusCode (
    125   IN EFI_FFS_FILE_HEADER       *FfsHeader,
    126   IN CONST EFI_PEI_SERVICES          **PeiServices
    127   )
    128 {
    129   EFI_STATUS  Status;
    130 
    131   //
    132   // Initialize status code listeners.
    133   //
    134   PlatformInitializeStatusCode (FfsHeader, PeiServices);
    135 
    136   //
    137   // Publish the status code capability to other modules
    138   //
    139   Status = (*PeiServices)->InstallPpi (PeiServices, &mPpiListStatusCode);
    140 
    141   ASSERT_EFI_ERROR (Status);
    142 
    143   DEBUG ((DEBUG_ERROR, "\nMono Status Code PEIM Loaded\n"));
    144 
    145   return ;
    146 }
    147