]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Support functions for managing protocol.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _HAND_H_\r | |
16 | #define _HAND_H_\r | |
17 | \r | |
18 | \r | |
19 | //\r | |
20 | // IHANDLE - contains a list of protocol handles\r | |
21 | //\r | |
22 | \r | |
23 | #define EFI_HANDLE_SIGNATURE EFI_SIGNATURE_32('h','n','d','l')\r | |
24 | typedef struct {\r | |
25 | UINTN Signature;\r | |
26 | LIST_ENTRY AllHandles; // All handles list of IHANDLE\r | |
27 | LIST_ENTRY Protocols; // List of PROTOCOL_INTERFACE's for this handle\r | |
28 | UINTN LocateRequest; // \r | |
29 | UINT64 Key; // The Handle Database Key value when this handle was last created or modified\r | |
30 | } IHANDLE;\r | |
31 | \r | |
32 | #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)\r | |
33 | \r | |
34 | \r | |
35 | //\r | |
36 | // PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol \r | |
37 | // database. Each handler that supports this protocol is listed, along\r | |
38 | // with a list of registered notifies.\r | |
39 | //\r | |
40 | \r | |
41 | #define PROTOCOL_ENTRY_SIGNATURE EFI_SIGNATURE_32('p','r','t','e')\r | |
42 | typedef struct {\r | |
43 | UINTN Signature;\r | |
44 | LIST_ENTRY AllEntries; // All entries\r | |
45 | EFI_GUID ProtocolID; // ID of the protocol\r | |
46 | LIST_ENTRY Protocols; // All protocol interfaces\r | |
47 | LIST_ENTRY Notify; // Registerd notification handlers\r | |
48 | } PROTOCOL_ENTRY;\r | |
49 | \r | |
50 | //\r | |
51 | // PROTOCOL_INTERFACE - each protocol installed on a handle is tracked\r | |
52 | // with a protocol interface structure\r | |
53 | //\r | |
54 | \r | |
55 | #define PROTOCOL_INTERFACE_SIGNATURE EFI_SIGNATURE_32('p','i','f','c')\r | |
56 | typedef struct {\r | |
57 | UINTN Signature;\r | |
58 | EFI_HANDLE Handle; // Back pointer\r | |
59 | LIST_ENTRY Link; // Link on IHANDLE.Protocols\r | |
60 | LIST_ENTRY ByProtocol; // Link on PROTOCOL_ENTRY.Protocols\r | |
61 | PROTOCOL_ENTRY *Protocol; // The protocol ID\r | |
62 | VOID *Interface; // The interface value\r | |
63 | \r | |
64 | LIST_ENTRY OpenList; // OPEN_PROTOCOL_DATA list.\r | |
65 | UINTN OpenListCount; \r | |
66 | \r | |
67 | EFI_HANDLE ControllerHandle;\r | |
68 | \r | |
69 | } PROTOCOL_INTERFACE;\r | |
70 | \r | |
71 | #define OPEN_PROTOCOL_DATA_SIGNATURE EFI_SIGNATURE_32('p','o','d','l')\r | |
72 | \r | |
73 | typedef struct {\r | |
74 | UINTN Signature;\r | |
75 | LIST_ENTRY Link;\r | |
76 | \r | |
77 | EFI_HANDLE AgentHandle;\r | |
78 | EFI_HANDLE ControllerHandle;\r | |
79 | UINT32 Attributes;\r | |
80 | UINT32 OpenCount;\r | |
81 | } OPEN_PROTOCOL_DATA;\r | |
82 | \r | |
83 | \r | |
84 | //\r | |
85 | // PROTOCOL_NOTIFY - used for each register notification for a protocol\r | |
86 | //\r | |
87 | \r | |
88 | #define PROTOCOL_NOTIFY_SIGNATURE EFI_SIGNATURE_32('p','r','t','n')\r | |
89 | typedef struct {\r | |
90 | UINTN Signature;\r | |
91 | PROTOCOL_ENTRY *Protocol;\r | |
92 | LIST_ENTRY Link; // All notifications for this protocol\r | |
93 | EFI_EVENT Event; // Event to notify\r | |
94 | LIST_ENTRY *Position; // Last position notified\r | |
95 | } PROTOCOL_NOTIFY;\r | |
96 | \r | |
97 | //\r | |
98 | // Internal prototypes\r | |
99 | //\r | |
100 | \r | |
101 | \r | |
102 | \r | |
103 | /**\r | |
104 | Finds the protocol entry for the requested protocol.\r | |
105 | The gProtocolDatabaseLock must be owned\r | |
106 | \r | |
107 | @param Protocol The ID of the protocol \r | |
108 | @param Create Create a new entry if not found \r | |
109 | \r | |
110 | @return Protocol entry\r | |
111 | \r | |
112 | **/\r | |
113 | PROTOCOL_ENTRY *\r | |
114 | CoreFindProtocolEntry (\r | |
115 | IN EFI_GUID *Protocol,\r | |
116 | IN BOOLEAN Create\r | |
117 | );\r | |
118 | \r | |
119 | \r | |
120 | /**\r | |
121 | Signal event for every protocol in protocol entry.\r | |
122 | \r | |
123 | @param ProtEntry Protocol entry\r | |
124 | \r | |
125 | **/\r | |
126 | VOID\r | |
127 | CoreNotifyProtocolEntry (\r | |
128 | IN PROTOCOL_ENTRY *ProtEntry\r | |
129 | );\r | |
130 | \r | |
131 | \r | |
132 | /**\r | |
133 | Finds the protocol instance for the requested handle and protocol.\r | |
134 | Note: This function doesn't do parameters checking, it's caller's responsibility\r | |
135 | to pass in valid parameters.\r | |
136 | \r | |
137 | @param Handle The handle to search the protocol on \r | |
138 | @param Protocol GUID of the protocol \r | |
139 | @param Interface The interface for the protocol being searched \r | |
140 | \r | |
141 | @return Protocol instance (NULL: Not found)\r | |
142 | \r | |
143 | **/\r | |
144 | PROTOCOL_INTERFACE *\r | |
145 | CoreFindProtocolInterface (\r | |
146 | IN IHANDLE *Handle,\r | |
147 | IN EFI_GUID *Protocol,\r | |
148 | IN VOID *Interface\r | |
149 | );\r | |
150 | \r | |
151 | \r | |
152 | /**\r | |
153 | Removes Protocol from the protocol list (but not the handle list).\r | |
154 | \r | |
155 | @param Handle The handle to remove protocol on. \r | |
156 | @param Protocol GUID of the protocol to be moved \r | |
157 | @param Interface The interface of the protocol \r | |
158 | \r | |
159 | @return Protocol Entry\r | |
160 | \r | |
161 | **/\r | |
162 | PROTOCOL_INTERFACE *\r | |
163 | CoreRemoveInterfaceFromProtocol (\r | |
164 | IN IHANDLE *Handle,\r | |
165 | IN EFI_GUID *Protocol,\r | |
166 | IN VOID *Interface\r | |
167 | );\r | |
168 | \r | |
169 | \r | |
170 | /**\r | |
171 | Removes all the events in the protocol database that match Event.\r | |
172 | \r | |
173 | @param Event The event to search for in the protocol \r | |
174 | database. \r | |
175 | \r | |
176 | @return EFI_SUCCESS when done searching the entire database.\r | |
177 | \r | |
178 | **/\r | |
179 | EFI_STATUS\r | |
180 | CoreUnregisterProtocolNotify (\r | |
181 | IN EFI_EVENT Event\r | |
182 | );\r | |
183 | \r | |
184 | \r | |
185 | /**\r | |
186 | Attempts to disconnect all drivers that are using the protocol interface being queried.\r | |
187 | If failed, reconnect all drivers disconnected.\r | |
188 | Note: This function doesn't do parameters checking, it's caller's responsibility\r | |
189 | to pass in valid parameters.\r | |
190 | \r | |
191 | @param UserHandle The handle on which the protocol is installed \r | |
192 | @param Prot The protocol to disconnect drivers from \r | |
193 | \r | |
194 | @retval EFI_SUCCESS Drivers using the protocol interface are all \r | |
195 | disconnected \r | |
196 | @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers\r | |
197 | \r | |
198 | **/\r | |
199 | EFI_STATUS\r | |
200 | CoreDisconnectControllersUsingProtocolInterface (\r | |
201 | IN EFI_HANDLE UserHandle,\r | |
202 | IN PROTOCOL_INTERFACE *Prot\r | |
203 | );\r | |
204 | \r | |
205 | \r | |
206 | /**\r | |
207 | Acquire lock on gProtocolDatabaseLock.\r | |
208 | \r | |
209 | **/\r | |
210 | VOID\r | |
211 | CoreAcquireProtocolLock (\r | |
212 | VOID\r | |
213 | );\r | |
214 | \r | |
215 | \r | |
216 | /**\r | |
217 | Release lock on gProtocolDatabaseLock.\r | |
218 | \r | |
219 | **/\r | |
220 | VOID\r | |
221 | CoreReleaseProtocolLock (\r | |
222 | VOID\r | |
223 | );\r | |
224 | \r | |
225 | \r | |
226 | /**\r | |
227 | Check whether a handle is a valid EFI_HANDLE\r | |
228 | \r | |
229 | @param UserHandle The handle to check \r | |
230 | \r | |
231 | @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE. \r | |
232 | @retval EFI_SUCCESS The handle is valid EFI_HANDLE.\r | |
233 | \r | |
234 | **/\r | |
235 | EFI_STATUS\r | |
236 | CoreValidateHandle (\r | |
237 | IN EFI_HANDLE UserHandle\r | |
238 | );\r | |
239 | \r | |
240 | //\r | |
241 | // Externs\r | |
242 | //\r | |
243 | \r | |
244 | extern EFI_LOCK gProtocolDatabaseLock;\r | |
245 | extern LIST_ENTRY gHandleList;\r | |
246 | extern UINT64 gHandleDatabaseKey;\r | |
247 | \r | |
248 | #endif\r |