]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Support functions for managing protocol.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r | |
5 | 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 | #define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')\r | |
20 | \r | |
21 | ///\r | |
22 | /// IHANDLE - contains a list of protocol handles\r | |
23 | ///\r | |
24 | typedef struct {\r | |
25 | UINTN Signature;\r | |
26 | /// All handles list of IHANDLE\r | |
27 | LIST_ENTRY AllHandles;\r | |
28 | /// List of PROTOCOL_INTERFACE's for this handle\r | |
29 | LIST_ENTRY Protocols; \r | |
30 | UINTN LocateRequest;\r | |
31 | /// The Handle Database Key value when this handle was last created or modified\r | |
32 | UINT64 Key;\r | |
33 | } IHANDLE;\r | |
34 | \r | |
35 | #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)\r | |
36 | \r | |
37 | #define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')\r | |
38 | \r | |
39 | ///\r | |
40 | /// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol\r | |
41 | /// database. Each handler that supports this protocol is listed, along\r | |
42 | /// with a list of registered notifies.\r | |
43 | ///\r | |
44 | typedef struct {\r | |
45 | UINTN Signature;\r | |
46 | /// Link Entry inserted to mProtocolDatabase\r | |
47 | LIST_ENTRY AllEntries; \r | |
48 | /// ID of the protocol\r | |
49 | EFI_GUID ProtocolID; \r | |
50 | /// All protocol interfaces\r | |
51 | LIST_ENTRY Protocols; \r | |
52 | /// Registerd notification handlers\r | |
53 | LIST_ENTRY Notify; \r | |
54 | } PROTOCOL_ENTRY;\r | |
55 | \r | |
56 | \r | |
57 | #define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')\r | |
58 | \r | |
59 | ///\r | |
60 | /// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked\r | |
61 | /// with a protocol interface structure\r | |
62 | ///\r | |
63 | typedef struct {\r | |
64 | UINTN Signature;\r | |
65 | /// Link on IHANDLE.Protocols\r | |
66 | LIST_ENTRY Link; \r | |
67 | /// Back pointer\r | |
68 | IHANDLE *Handle; \r | |
69 | /// Link on PROTOCOL_ENTRY.Protocols\r | |
70 | LIST_ENTRY ByProtocol; \r | |
71 | /// The protocol ID\r | |
72 | PROTOCOL_ENTRY *Protocol; \r | |
73 | /// The interface value\r | |
74 | VOID *Interface; \r | |
75 | /// OPEN_PROTOCOL_DATA list\r | |
76 | LIST_ENTRY OpenList; \r | |
77 | UINTN OpenListCount;\r | |
78 | \r | |
79 | } PROTOCOL_INTERFACE;\r | |
80 | \r | |
81 | #define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')\r | |
82 | \r | |
83 | typedef struct {\r | |
84 | UINTN Signature;\r | |
85 | ///Link on PROTOCOL_INTERFACE.OpenList\r | |
86 | LIST_ENTRY Link; \r | |
87 | \r | |
88 | EFI_HANDLE AgentHandle;\r | |
89 | EFI_HANDLE ControllerHandle;\r | |
90 | UINT32 Attributes;\r | |
91 | UINT32 OpenCount;\r | |
92 | } OPEN_PROTOCOL_DATA;\r | |
93 | \r | |
94 | \r | |
95 | #define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')\r | |
96 | \r | |
97 | ///\r | |
98 | /// PROTOCOL_NOTIFY - used for each register notification for a protocol\r | |
99 | ///\r | |
100 | typedef struct {\r | |
101 | UINTN Signature;\r | |
102 | PROTOCOL_ENTRY *Protocol;\r | |
103 | /// All notifications for this protocol\r | |
104 | LIST_ENTRY Link; \r | |
105 | /// Event to notify\r | |
106 | EFI_EVENT Event; \r | |
107 | /// Last position notified\r | |
108 | LIST_ENTRY *Position; \r | |
109 | } PROTOCOL_NOTIFY;\r | |
110 | \r | |
111 | \r | |
112 | \r | |
113 | /**\r | |
114 | Finds the protocol entry for the requested protocol.\r | |
115 | The gProtocolDatabaseLock must be owned\r | |
116 | \r | |
117 | @param Protocol The ID of the protocol\r | |
118 | @param Create Create a new entry if not found\r | |
119 | \r | |
120 | @return Protocol entry\r | |
121 | \r | |
122 | **/\r | |
123 | PROTOCOL_ENTRY *\r | |
124 | CoreFindProtocolEntry (\r | |
125 | IN EFI_GUID *Protocol,\r | |
126 | IN BOOLEAN Create\r | |
127 | );\r | |
128 | \r | |
129 | \r | |
130 | /**\r | |
131 | Signal event for every protocol in protocol entry.\r | |
132 | \r | |
133 | @param ProtEntry Protocol entry\r | |
134 | \r | |
135 | **/\r | |
136 | VOID\r | |
137 | CoreNotifyProtocolEntry (\r | |
138 | IN PROTOCOL_ENTRY *ProtEntry\r | |
139 | );\r | |
140 | \r | |
141 | \r | |
142 | /**\r | |
143 | Finds the protocol instance for the requested handle and protocol.\r | |
144 | Note: This function doesn't do parameters checking, it's caller's responsibility\r | |
145 | to pass in valid parameters.\r | |
146 | \r | |
147 | @param Handle The handle to search the protocol on\r | |
148 | @param Protocol GUID of the protocol\r | |
149 | @param Interface The interface for the protocol being searched\r | |
150 | \r | |
151 | @return Protocol instance (NULL: Not found)\r | |
152 | \r | |
153 | **/\r | |
154 | PROTOCOL_INTERFACE *\r | |
155 | CoreFindProtocolInterface (\r | |
156 | IN IHANDLE *Handle,\r | |
157 | IN EFI_GUID *Protocol,\r | |
158 | IN VOID *Interface\r | |
159 | );\r | |
160 | \r | |
161 | \r | |
162 | /**\r | |
163 | Removes Protocol from the protocol list (but not the handle list).\r | |
164 | \r | |
165 | @param Handle The handle to remove protocol on.\r | |
166 | @param Protocol GUID of the protocol to be moved\r | |
167 | @param Interface The interface of the protocol\r | |
168 | \r | |
169 | @return Protocol Entry\r | |
170 | \r | |
171 | **/\r | |
172 | PROTOCOL_INTERFACE *\r | |
173 | CoreRemoveInterfaceFromProtocol (\r | |
174 | IN IHANDLE *Handle,\r | |
175 | IN EFI_GUID *Protocol,\r | |
176 | IN VOID *Interface\r | |
177 | );\r | |
178 | \r | |
179 | \r | |
180 | /**\r | |
181 | Connects a controller to a driver.\r | |
182 | \r | |
183 | @param ControllerHandle Handle of the controller to be\r | |
184 | connected.\r | |
185 | @param ContextDriverImageHandles DriverImageHandle A pointer to an\r | |
186 | ordered list of driver image\r | |
187 | handles.\r | |
188 | @param RemainingDevicePath RemainingDevicePath A pointer to\r | |
189 | the device path that specifies a\r | |
190 | child of the controller\r | |
191 | specified by ControllerHandle.\r | |
192 | \r | |
193 | @retval EFI_SUCCESS One or more drivers were\r | |
194 | connected to ControllerHandle.\r | |
195 | @retval EFI_OUT_OF_RESOURCES No enough system resources to\r | |
196 | complete the request.\r | |
197 | @retval EFI_NOT_FOUND No drivers were connected to\r | |
198 | ControllerHandle.\r | |
199 | \r | |
200 | **/\r | |
201 | EFI_STATUS\r | |
202 | CoreConnectSingleController (\r | |
203 | IN EFI_HANDLE ControllerHandle,\r | |
204 | IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL,\r | |
205 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
206 | );\r | |
207 | \r | |
208 | /**\r | |
209 | Attempts to disconnect all drivers that are using the protocol interface being queried.\r | |
210 | If failed, reconnect all drivers disconnected.\r | |
211 | Note: This function doesn't do parameters checking, it's caller's responsibility\r | |
212 | to pass in valid parameters.\r | |
213 | \r | |
214 | @param UserHandle The handle on which the protocol is installed\r | |
215 | @param Prot The protocol to disconnect drivers from\r | |
216 | \r | |
217 | @retval EFI_SUCCESS Drivers using the protocol interface are all\r | |
218 | disconnected\r | |
219 | @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers\r | |
220 | \r | |
221 | **/\r | |
222 | EFI_STATUS\r | |
223 | CoreDisconnectControllersUsingProtocolInterface (\r | |
224 | IN EFI_HANDLE UserHandle,\r | |
225 | IN PROTOCOL_INTERFACE *Prot\r | |
226 | );\r | |
227 | \r | |
228 | \r | |
229 | /**\r | |
230 | Acquire lock on gProtocolDatabaseLock.\r | |
231 | \r | |
232 | **/\r | |
233 | VOID\r | |
234 | CoreAcquireProtocolLock (\r | |
235 | VOID\r | |
236 | );\r | |
237 | \r | |
238 | \r | |
239 | /**\r | |
240 | Release lock on gProtocolDatabaseLock.\r | |
241 | \r | |
242 | **/\r | |
243 | VOID\r | |
244 | CoreReleaseProtocolLock (\r | |
245 | VOID\r | |
246 | );\r | |
247 | \r | |
248 | \r | |
249 | /**\r | |
250 | Check whether a handle is a valid EFI_HANDLE\r | |
251 | \r | |
252 | @param UserHandle The handle to check\r | |
253 | \r | |
254 | @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE.\r | |
255 | @retval EFI_SUCCESS The handle is valid EFI_HANDLE.\r | |
256 | \r | |
257 | **/\r | |
258 | EFI_STATUS\r | |
259 | CoreValidateHandle (\r | |
260 | IN EFI_HANDLE UserHandle\r | |
261 | );\r | |
262 | \r | |
263 | //\r | |
264 | // Externs\r | |
265 | //\r | |
266 | extern EFI_LOCK gProtocolDatabaseLock;\r | |
267 | extern LIST_ENTRY gHandleList;\r | |
268 | extern UINT64 gHandleDatabaseKey;\r | |
269 | \r | |
270 | #endif\r |