1/** @file
2  Internal Header file of Report Status Code Library.
3
4  Copyright (c) 2009 - 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#ifndef __REPORT_STATUS_CODE_LIB_INTERNAL_H__
15#define __REPORT_STATUS_CODE_LIB_INTERNAL_H__
16
17#include <Library/ReportStatusCodeLib.h>
18#include <Library/DebugLib.h>
19#include <Library/UefiBootServicesTableLib.h>
20#include <Library/BaseLib.h>
21#include <Library/BaseMemoryLib.h>
22#include <Library/PcdLib.h>
23#include <Library/DevicePathLib.h>
24#include <Library/HobLib.h>
25
26#include <Guid/StatusCodeDataTypeId.h>
27#include <Guid/StatusCodeDataTypeDebug.h>
28#include <Protocol/StatusCode.h>
29
30/**
31  Internal worker function that reports a status code through the Status Code Protocol
32
33  This function checks to see if a Status Code Protocol is present in the handle
34  database.  If a Status Code Protocol is not present, then EFI_UNSUPPORTED is
35  returned.  If a Status Code Protocol is present, then it is cached in gStatusCode,
36  and the ReportStatusCode() service of the Status Code Protocol is called passing in
37  Type, Value, Instance, CallerId, and Data.  The result of this call is returned.
38
39  @param  Type              Status code type.
40  @param  Value             Status code value.
41  @param  Instance          Status code instance number.
42  @param  CallerId          Pointer to a GUID that identifies the caller of this
43                            function.  This is an optional parameter that may be
44                            NULL.
45  @param  Data              Pointer to the extended data buffer.  This is an
46                            optional parameter that may be NULL.
47
48  @retval  EFI_SUCCESS           The status code was reported.
49  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to report the status code.
50  @retval  EFI_UNSUPPORTED       Status Code Protocol is not available.
51
52**/
53EFI_STATUS
54InternalReportStatusCode (
55  IN EFI_STATUS_CODE_TYPE     Type,
56  IN EFI_STATUS_CODE_VALUE    Value,
57  IN UINT32                   Instance,
58  IN CONST EFI_GUID           *CallerId OPTIONAL,
59  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL
60  );
61
62/**
63  Reports a status code with full parameters.
64
65  The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize
66  is 0, then an extended data buffer is not reported.  If ExtendedData is not
67  NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
68  ExtendedData is assumed not have the standard status code header, so this function
69  is responsible for allocating a buffer large enough for the standard header and
70  the extended data passed into this function.  The standard header is filled in
71  with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a
72  GUID of gEfiStatusCodeSpecificDatauid is used.  The status code is reported with
73  an instance specified by Instance and a caller ID specified by CallerId.  If
74  CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
75
76  ReportStatusCodeEx()must actively prevent recursion.  If ReportStatusCodeEx()
77  is called while processing another any other Report Status Code Library function,
78  then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
79
80  If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
81  If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
82
83  @param  Type              Status code type.
84  @param  Value             Status code value.
85  @param  Instance          Status code instance number.
86  @param  CallerId          Pointer to a GUID that identifies the caller of this
87                            function.  If this parameter is NULL, then a caller
88                            ID of gEfiCallerIdGuid is used.
89  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.
90                            If this parameter is NULL, then a the status code
91                            standard header is filled in with
92                            gEfiStatusCodeSpecificDataGuid.
93  @param  ExtendedData      Pointer to the extended data buffer.  This is an
94                            optional parameter that may be NULL.
95  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.
96
97  @retval  EFI_SUCCESS           The status code was reported.
98  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate
99                                 the extended data section if it was specified.
100  @retval  EFI_UNSUPPORTED       Report status code is not supported
101
102**/
103EFI_STATUS
104EFIAPI
105InternalReportStatusCodeEx (
106  IN EFI_STATUS_CODE_TYPE   Type,
107  IN EFI_STATUS_CODE_VALUE  Value,
108  IN UINT32                 Instance,
109  IN CONST EFI_GUID         *CallerId          OPTIONAL,
110  IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,
111  IN CONST VOID             *ExtendedData      OPTIONAL,
112  IN UINTN                  ExtendedDataSize
113  );
114
115extern EFI_STATUS_CODE_PROTOCOL mStatusProtocol;
116
117#endif // __REPORT_STATUS_CODE_LIB_INTERNAL__H
118
119