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