]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.h
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Universal / ReportStatusCodeRouter / RuntimeDxe / ReportStatusCodeRouterRuntimeDxe.h
1 /** @file
2 Internal include file for Report Status Code Router Driver.
3
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef __REPORT_STATUS_CODE_ROUTER_RUNTIME_DXE_H__
10 #define __REPORT_STATUS_CODE_ROUTER_RUNTIME_DXE_H__
11
12 #include <Protocol/ReportStatusCodeHandler.h>
13 #include <Protocol/StatusCode.h>
14
15 #include <Guid/EventGroup.h>
16
17 #include <Library/BaseLib.h>
18 #include <Library/SynchronizationLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/HobLib.h>
21 #include <Library/UefiDriverEntryPoint.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 #include <Library/MemoryAllocationLib.h>
24 #include <Library/BaseMemoryLib.h>
25 #include <Library/UefiRuntimeLib.h>
26 #include "Library/UefiLib.h"
27
28 #define RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE SIGNATURE_32 ('r', 'h', 'c', 'e')
29
30 typedef struct {
31 UINTN Signature;
32 EFI_RSC_HANDLER_CALLBACK RscHandlerCallback;
33 EFI_TPL Tpl;
34 EFI_EVENT Event;
35 EFI_PHYSICAL_ADDRESS StatusCodeDataBuffer;
36 UINTN BufferSize;
37 EFI_PHYSICAL_ADDRESS EndPointer;
38 LIST_ENTRY Node;
39 } RSC_HANDLER_CALLBACK_ENTRY;
40
41 typedef struct {
42 EFI_STATUS_CODE_TYPE Type;
43 EFI_STATUS_CODE_VALUE Value;
44 UINT32 Instance;
45 UINT32 Reserved;
46 EFI_GUID CallerId;
47 EFI_STATUS_CODE_DATA Data;
48 } RSC_DATA_ENTRY;
49
50 /**
51 Register the callback function for ReportStatusCode() notification.
52
53 When this function is called the function pointer is added to an internal list and any future calls to
54 ReportStatusCode() will be forwarded to the Callback function. During the bootservices,
55 this is the callback for which this service can be invoked. The report status code router
56 will create an event such that the callback function is only invoked at the TPL for which it was
57 registered. The entity that registers for the callback should also register for an event upon
58 generation of exit boot services and invoke the unregister service.
59 If the handler does not have a TPL dependency, it should register for a callback at TPL high. The
60 router infrastructure will support making callbacks at runtime, but the caller for runtime invocation
61 must meet the following criteria:
62 1. must be a runtime driver type so that its memory is not reclaimed
63 2. not unregister at exit boot services so that the router will still have its callback address
64 3. the caller must be self-contained (eg. Not call out into any boot-service interfaces) and be
65 runtime safe, in general.
66
67 @param[in] Callback A pointer to a function of type EFI_RSC_HANDLER_CALLBACK that is called when
68 a call to ReportStatusCode() occurs.
69 @param[in] Tpl TPL at which callback can be safely invoked.
70
71 @retval EFI_SUCCESS Function was successfully registered.
72 @retval EFI_INVALID_PARAMETER The callback function was NULL.
73 @retval EFI_OUT_OF_RESOURCES The internal buffer ran out of space. No more functions can be
74 registered.
75 @retval EFI_ALREADY_STARTED The function was already registered. It can't be registered again.
76
77 **/
78 EFI_STATUS
79 EFIAPI
80 Register (
81 IN EFI_RSC_HANDLER_CALLBACK Callback,
82 IN EFI_TPL Tpl
83 );
84
85 /**
86 Remove a previously registered callback function from the notification list.
87
88 A callback function must be unregistered before it is deallocated. It is important that any registered
89 callbacks that are not runtime complaint be unregistered when ExitBootServices() is called.
90
91 @param[in] Callback A pointer to a function of type EFI_RSC_HANDLER_CALLBACK that is to be
92 unregistered.
93
94 @retval EFI_SUCCESS The function was successfully unregistered.
95 @retval EFI_INVALID_PARAMETER The callback function was NULL.
96 @retval EFI_NOT_FOUND The callback function was not found to be unregistered.
97
98 **/
99 EFI_STATUS
100 EFIAPI
101 Unregister (
102 IN EFI_RSC_HANDLER_CALLBACK Callback
103 );
104
105 /**
106 Provides an interface that a software module can call to report a status code.
107
108 @param Type Indicates the type of status code being reported.
109 @param Value Describes the current status of a hardware or software entity.
110 This included information about the class and subclass that is used to
111 classify the entity as well as an operation.
112 @param Instance The enumeration of a hardware or software entity within
113 the system. Valid instance numbers start with 1.
114 @param CallerId This optional parameter may be used to identify the caller.
115 This parameter allows the status code driver to apply different rules to
116 different callers.
117 @param Data This optional parameter may be used to pass additional data.
118
119 @retval EFI_SUCCESS The function completed successfully
120 @retval EFI_DEVICE_ERROR The function should not be completed due to a device error.
121
122 **/
123 EFI_STATUS
124 EFIAPI
125 ReportDispatcher (
126 IN EFI_STATUS_CODE_TYPE Type,
127 IN EFI_STATUS_CODE_VALUE Value,
128 IN UINT32 Instance,
129 IN EFI_GUID *CallerId OPTIONAL,
130 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
131 );
132
133 #endif