]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/Include/Protocol/Observable.h
IntelFrameworkModulePkg: Refine casting expression result to bigger size
[mirror_edk2.git] / Vlv2TbltDevicePkg / Include / Protocol / Observable.h
CommitLineData
3cbfba02
DW
1/*++\r
2\r
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
4 \r\r
5 This program and the accompanying materials are licensed and made available under\r\r
6 the terms and conditions of the BSD License that accompanies this distribution. \r\r
7 The full text of the license may be found at \r\r
8 http://opensource.org/licenses/bsd-license.php. \r\r
9 \r\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r\r
12 \r\r
13\r
14\r
15Module Name:\r
16\r
17 Observable.h\r
18\r
19Abstract:\r
20\r
21 Interface and GUID definitions for Observable protocol.\r
22\r
23**/\r
24\r
25#ifndef _OBSERVABLE_PROTOCOL_H_\r
26#define _OBSERVABLE_PROTOCOL_H_\r
27\r
28//\r
29// GUID Definitions\r
30//\r
31#define OBSERVABLE_PROTOCOL_GUID \\r
32 { \\r
33 0xe227c522, 0xd5fe, 0x4a53, 0x87, 0xb1, 0x0f, 0xbe, 0x57, 0x0f, 0x98, 0xe9 \\r
34 }\r
35\r
36extern EFI_GUID gObservableProtocolGuid;\r
37\r
38typedef struct _OBS_OBSERVABLE_PROTOCOL OBS_OBSERVABLE_PROTOCOL;\r
39\r
40//\r
41// Interface Definitions\r
42//\r
43\r
44/**\r
45 Remove all observables.\r
46\r
47 Remove all observable guids and all interfaces subscribed to them.\r
48\r
49 @param VOID No Parameters.\r
50\r
51 @return EFI_SUCCESS Successfully removed all observables and subscribed interfaces.\r
52\r
53**/\r
54typedef\r
55EFI_STATUS\r
56(EFIAPI *OBS_REMOVE_ALL_OBSERVABLES) (\r
57 VOID\r
58 );\r
59\r
60/**\r
61 Interface for notification functions.\r
62\r
63 Functions that are to be used as callbacks must inherit this interface in order to be used properly.\r
64\r
65 @param VOID* Data Parameter context to be passed to the notification function.\r
66\r
67 @return EFI_STATUS Varies depending on implementation.\r
68\r
69**/\r
70typedef\r
71EFI_STATUS\r
72(EFIAPI *OBS_CALLBACK) (\r
73 IN OUT VOID* Data\r
74 );\r
75\r
76/**\r
77 Subscribe an interface with an observable guid.\r
78\r
79 Use this to register a callback function with a guid. The function provided by CallbackInterface will be executed\r
80 whenever the appropriate observable instance specified by ReferenceGuid calls Publish.\r
81\r
82 @param EFI_GUID ReferenceGuid The observable guid that the callback interface will subscribe to.\r
83 OBS_NOTIFY_INTERFACE CallbackInterface A pointer to the function that is subscribing to the observable.\r
84\r
85 @return EFI_SUCCESS Successfully subscribed the interface to the observable guid.\r
86 EFI_NOT_FOUND No match could be found between the provided guid and existing observables.\r
87 EFI_OUT_OF_RESOURCES Could not subscribe to this observer due to resource limitations.\r
88 EFI_INVALID_PARAMETER Interface is already subscribed to this observer.\r
89**/\r
90typedef\r
91EFI_STATUS\r
92(EFIAPI *OBS_SUBSCRIBE) (\r
93 IN EFI_GUID ReferenceGuid,\r
94 IN OBS_CALLBACK CallbackInterface\r
95 );\r
96\r
97/**\r
98 Unsubscribe an interface with an observable guid.\r
99\r
100 Use this to remove an interface from the callback list associated with an observable guid.\r
101\r
102 @param EFI_GUID ReferenceGuid The observable guid to unsubscribe the interface from.\r
103 OBS_NOTIFY_INTERFACE NotifyCallback A pointer to the interface that is being unsubscribed.\r
104\r
105 @return EFI_SUCCESS Successfully unsubscribed the interface from the observable guid.\r
106\r
107**/\r
108typedef\r
109EFI_STATUS\r
110(EFIAPI *OBS_UNSUBSCRIBE) (\r
111 IN EFI_GUID ReferenceGuid,\r
112 IN OBS_CALLBACK CallbackInterface\r
113 );\r
114\r
115/**\r
116 Notify observing functions.\r
117\r
118 Use this to notify all functions who are subscribed to the guid specified by ReferenceGuid.\r
119\r
120 @param EFI_GUID ReferenceGuid The observable guid that contains the the list of interfaces to be notified.\r
121 VOID* Data Parameter context to be passed to the notification function.\r
122\r
123 @return EFI_SUCCESS Successfully notified all observers listening to this guid.\r
124 EFI_NOT_FOUND No match could be found between the provided guid and existing observables.\r
125\r
126**/\r
127typedef\r
128EFI_STATUS\r
129(EFIAPI *OBS_PUBLISH) (\r
130 IN EFI_GUID ReferenceGuid,\r
131 IN OUT VOID* Data\r
132 );\r
133\r
134/**\r
135 Creates a new observable.\r
136\r
137 Create a new observable that can be observed with the use of Subscribe function.\r
138\r
139 @param EFI_GUID ReferenceGuid The observable guid to add.\r
140\r
141 @return EFI_SUCCESS Successfully added observable.\r
142 EFI_INVALID_PARAMETER Observable already exists.\r
143\r
144**/\r
145typedef\r
146EFI_STATUS\r
147(EFIAPI *OBS_ADD_OBSERVABLE) (\r
148 IN EFI_GUID ReferenceGuid\r
149 );\r
150\r
151/**\r
152 Remove an observable.\r
153\r
154 Remove an observable so that it can no longer be subscribed to. In addition, unsubscribe any functions\r
155 that are subscribed to this guid.\r
156\r
157 @param EFI_GUID ReferenceGuid The observable guid to remove.\r
158\r
159 @return EFI_SUCCESS Successfully removed observable.\r
160\r
161**/\r
162typedef\r
163EFI_STATUS\r
164(EFIAPI *OBS_REMOVE_OBSERVABLE) (\r
165 IN EFI_GUID ReferenceGuid\r
166 );\r
167\r
168//\r
169// Protocol Definitions\r
170//\r
171typedef struct _OBS_LEAF {\r
172 OBS_CALLBACK Observer;\r
173 struct _OBS_LEAF* Next;\r
174} OBS_LEAF;\r
175\r
176typedef struct _OBS_TREE {\r
177 EFI_GUID ObservableGuid;\r
178 OBS_LEAF* Leaf;\r
179 struct _OBS_TREE* Next;\r
180} OBS_TREE;\r
181\r
182struct _OBS_OBSERVABLE_PROTOCOL {\r
183 OBS_ADD_OBSERVABLE AddObservable;\r
184 OBS_REMOVE_OBSERVABLE RemoveObservable;\r
185 OBS_SUBSCRIBE Subscribe;\r
186 OBS_UNSUBSCRIBE Unsubscribe;\r
187 OBS_PUBLISH Publish;\r
188 OBS_REMOVE_ALL_OBSERVABLES RemoveAllObservables;\r
189} ;\r
190\r
191#endif\r