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