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