1 /** @file
2   This protocol provides registering and unregistering services to status code consumers while in DXE MM.
3 
4   Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5   SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7   @par Revision Reference:
8   This Protocol was introduced in PI Specification 1.1.
9 
10 **/
11 
12 #ifndef __MM_REPORT_STATUS_CODE_HANDLER_PROTOCOL_H__
13 #define __MM_REPORT_STATUS_CODE_HANDLER_PROTOCOL_H__
14 
15 #define EFI_MM_RSC_HANDLER_PROTOCOL_GUID \
16   { \
17     0x2ff29fa7, 0x5e80, 0x4ed9, {0xb3, 0x80, 0x1, 0x7d, 0x3c, 0x55, 0x4f, 0xf4} \
18   }
19 
20 typedef
21 EFI_STATUS
22 (EFIAPI *EFI_MM_RSC_HANDLER_CALLBACK)(
23   IN EFI_STATUS_CODE_TYPE   CodeType,
24   IN EFI_STATUS_CODE_VALUE  Value,
25   IN UINT32                 Instance,
26   IN EFI_GUID               *CallerId,
27   IN EFI_STATUS_CODE_DATA   *Data
28 );
29 
30 /**
31   Register the callback function for ReportStatusCode() notification.
32 
33   When this function is called the function pointer is added to an internal list and any future calls to
34   ReportStatusCode() will be forwarded to the Callback function.
35 
36   @param[in] Callback               A pointer to a function of type EFI_MM_RSC_HANDLER_CALLBACK that is
37                                     called when a call to ReportStatusCode() occurs.
38 
39   @retval EFI_SUCCESS               Function was successfully registered.
40   @retval EFI_INVALID_PARAMETER     The callback function was NULL.
41   @retval EFI_OUT_OF_RESOURCES      The internal buffer ran out of space. No more functions can be
42                                     registered.
43   @retval EFI_ALREADY_STARTED       The function was already registered. It can't be registered again.
44 **/
45 typedef
46 EFI_STATUS
47 (EFIAPI *EFI_MM_RSC_HANDLER_REGISTER)(
48   IN EFI_MM_RSC_HANDLER_CALLBACK Callback
49 );
50 
51 /**
52   Remove a previously registered callback function from the notification list.
53 
54   A callback function must be unregistered before it is deallocated. It is important that any registered
55   callbacks that are not runtime complaint be unregistered when ExitBootServices() is called.
56 
57   @param[in] Callback           A pointer to a function of type EFI_MM_RSC_HANDLER_CALLBACK that is to be
58                                 unregistered.
59 
60   @retval EFI_SUCCESS           The function was successfully unregistered.
61   @retval EFI_INVALID_PARAMETER The callback function was NULL.
62   @retval EFI_NOT_FOUND         The callback function was not found to be unregistered.
63 
64 **/
65 typedef
66 EFI_STATUS
67 (EFIAPI *EFI_MM_RSC_HANDLER_UNREGISTER)(
68   IN EFI_MM_RSC_HANDLER_CALLBACK Callback
69 );
70 
71 typedef struct _EFI_MM_RSC_HANDLER_PROTOCOL {
72   EFI_MM_RSC_HANDLER_REGISTER      Register;
73   EFI_MM_RSC_HANDLER_UNREGISTER    Unregister;
74 } EFI_MM_RSC_HANDLER_PROTOCOL;
75 
76 extern EFI_GUID gEfiMmRscHandlerProtocolGuid;
77 
78 #endif
79