1*f334afcfSToomas Soome /** @file
2*f334afcfSToomas Soome   This protocol provide registering and unregistering services to status code
3*f334afcfSToomas Soome   consumers while in DXE.
4*f334afcfSToomas Soome 
5*f334afcfSToomas Soome   Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6*f334afcfSToomas Soome   SPDX-License-Identifier: BSD-2-Clause-Patent
7*f334afcfSToomas Soome 
8*f334afcfSToomas Soome   @par Revision Reference:
9*f334afcfSToomas Soome   This Protocol was introduced in PI Specification 1.2.
10*f334afcfSToomas Soome 
11*f334afcfSToomas Soome **/
12*f334afcfSToomas Soome 
13*f334afcfSToomas Soome #ifndef __REPORT_STATUS_CODE_HANDLER_PROTOCOL_H__
14*f334afcfSToomas Soome #define __REPORT_STATUS_CODE_HANDLER_PROTOCOL_H__
15*f334afcfSToomas Soome 
16*f334afcfSToomas Soome #define EFI_RSC_HANDLER_PROTOCOL_GUID \
17*f334afcfSToomas Soome   { \
18*f334afcfSToomas Soome     0x86212936, 0xe76, 0x41c8, {0xa0, 0x3a, 0x2a, 0xf2, 0xfc, 0x1c, 0x39, 0xe2} \
19*f334afcfSToomas Soome   }
20*f334afcfSToomas Soome 
21*f334afcfSToomas Soome typedef
22*f334afcfSToomas Soome EFI_STATUS
23*f334afcfSToomas Soome (EFIAPI *EFI_RSC_HANDLER_CALLBACK)(
24*f334afcfSToomas Soome   IN EFI_STATUS_CODE_TYPE   CodeType,
25*f334afcfSToomas Soome   IN EFI_STATUS_CODE_VALUE  Value,
26*f334afcfSToomas Soome   IN UINT32                 Instance,
27*f334afcfSToomas Soome   IN EFI_GUID               *CallerId,
28*f334afcfSToomas Soome   IN EFI_STATUS_CODE_DATA   *Data
29*f334afcfSToomas Soome   );
30*f334afcfSToomas Soome 
31*f334afcfSToomas Soome /**
32*f334afcfSToomas Soome   Register the callback function for ReportStatusCode() notification.
33*f334afcfSToomas Soome 
34*f334afcfSToomas Soome   When this function is called the function pointer is added to an internal list and any future calls to
35*f334afcfSToomas Soome   ReportStatusCode() will be forwarded to the Callback function. During the bootservices,
36*f334afcfSToomas Soome   this is the callback for which this service can be invoked. The report status code router
37*f334afcfSToomas Soome   will create an event such that the callback function is only invoked at the TPL for which it was
38*f334afcfSToomas Soome   registered. The entity that registers for the callback should also register for an event upon
39*f334afcfSToomas Soome   generation of exit boot services and invoke the unregister service.
40*f334afcfSToomas Soome   If the handler does not have a TPL dependency, it should register for a callback at TPL high. The
41*f334afcfSToomas Soome   router infrastructure will support making callbacks at runtime, but the caller for runtime invocation
42*f334afcfSToomas Soome   must meet the following criteria:
43*f334afcfSToomas Soome   1. must be a runtime driver type so that its memory is not reclaimed
44*f334afcfSToomas Soome   2. not unregister at exit boot services so that the router will still have its callback address
45*f334afcfSToomas Soome   3. the caller must be self-contained (eg. Not call out into any boot-service interfaces) and be
46*f334afcfSToomas Soome   runtime safe, in general.
47*f334afcfSToomas Soome 
48*f334afcfSToomas Soome   @param[in] Callback   A pointer to a function of type EFI_RSC_HANDLER_CALLBACK that is called when
49*f334afcfSToomas Soome                         a call to ReportStatusCode() occurs.
50*f334afcfSToomas Soome   @param[in] Tpl        TPL at which callback can be safely invoked.
51*f334afcfSToomas Soome 
52*f334afcfSToomas Soome   @retval  EFI_SUCCESS              Function was successfully registered.
53*f334afcfSToomas Soome   @retval  EFI_INVALID_PARAMETER    The callback function was NULL.
54*f334afcfSToomas Soome   @retval  EFI_OUT_OF_RESOURCES     The internal buffer ran out of space. No more functions can be
55*f334afcfSToomas Soome                                     registered.
56*f334afcfSToomas Soome   @retval  EFI_ALREADY_STARTED      The function was already registered. It can't be registered again.
57*f334afcfSToomas Soome **/
58*f334afcfSToomas Soome typedef
59*f334afcfSToomas Soome EFI_STATUS
60*f334afcfSToomas Soome (EFIAPI *EFI_RSC_HANDLER_REGISTER)(
61*f334afcfSToomas Soome   IN EFI_RSC_HANDLER_CALLBACK   Callback,
62*f334afcfSToomas Soome   IN EFI_TPL                    Tpl
63*f334afcfSToomas Soome   );
64*f334afcfSToomas Soome 
65*f334afcfSToomas Soome /**
66*f334afcfSToomas Soome   Remove a previously registered callback function from the notification list.
67*f334afcfSToomas Soome 
68*f334afcfSToomas Soome   A callback function must be unregistered before it is deallocated. It is important that any registered
69*f334afcfSToomas Soome   callbacks that are not runtime complaint be unregistered when ExitBootServices() is called.
70*f334afcfSToomas Soome 
71*f334afcfSToomas Soome   @param[in]  Callback  A pointer to a function of type EFI_RSC_HANDLER_CALLBACK that is to be
72*f334afcfSToomas Soome                         unregistered.
73*f334afcfSToomas Soome 
74*f334afcfSToomas Soome   @retval EFI_SUCCESS           The function was successfully unregistered.
75*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETER The callback function was NULL.
76*f334afcfSToomas Soome   @retval EFI_NOT_FOUND         The callback function was not found to be unregistered.
77*f334afcfSToomas Soome **/
78*f334afcfSToomas Soome typedef
79*f334afcfSToomas Soome EFI_STATUS
80*f334afcfSToomas Soome (EFIAPI *EFI_RSC_HANDLER_UNREGISTER)(
81*f334afcfSToomas Soome   IN EFI_RSC_HANDLER_CALLBACK Callback
82*f334afcfSToomas Soome   );
83*f334afcfSToomas Soome 
84*f334afcfSToomas Soome typedef struct {
85*f334afcfSToomas Soome   EFI_RSC_HANDLER_REGISTER      Register;
86*f334afcfSToomas Soome   EFI_RSC_HANDLER_UNREGISTER    Unregister;
87*f334afcfSToomas Soome } EFI_RSC_HANDLER_PROTOCOL;
88*f334afcfSToomas Soome 
89*f334afcfSToomas Soome extern EFI_GUID  gEfiRscHandlerProtocolGuid;
90*f334afcfSToomas Soome 
91*f334afcfSToomas Soome #endif // __REPORT_STATUS_CODE_HANDLER_H__
92