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