]>
Commit | Line | Data |
---|---|---|
23c98c94 | 1 | /** @file\r |
504214c4 LG |
2 | Support functions for managing protocol.\r |
3 | \r | |
cd5ebaa0 HT |
4 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
23c98c94 | 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 | |
28a00297 | 12 | \r |
504214c4 | 13 | **/\r |
28a00297 | 14 | \r |
15 | #ifndef _HAND_H_\r | |
16 | #define _HAND_H_\r | |
17 | \r | |
18 | \r | |
f3f2e05d | 19 | #define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')\r |
ec90508b | 20 | \r |
21 | ///\r | |
22 | /// IHANDLE - contains a list of protocol handles\r | |
23 | ///\r | |
28a00297 | 24 | typedef struct {\r |
25 | UINTN Signature;\r | |
ec90508b | 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 | |
28a00297 | 33 | } IHANDLE;\r |
34 | \r | |
35 | #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)\r | |
36 | \r | |
f3f2e05d | 37 | #define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')\r |
ec90508b | 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 | |
28a00297 | 44 | typedef struct {\r |
45 | UINTN Signature;\r | |
ec90508b | 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 | |
28a00297 | 54 | } PROTOCOL_ENTRY;\r |
55 | \r | |
28a00297 | 56 | \r |
f3f2e05d | 57 | #define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')\r |
ec90508b | 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 | |
28a00297 | 63 | typedef struct {\r |
64 | UINTN Signature;\r | |
ec90508b | 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 | |
022c6d45 | 77 | UINTN OpenListCount;\r |
78 | \r | |
28a00297 | 79 | } PROTOCOL_INTERFACE;\r |
80 | \r | |
f3f2e05d | 81 | #define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')\r |
28a00297 | 82 | \r |
83 | typedef struct {\r | |
84 | UINTN Signature;\r | |
ec90508b | 85 | ///Link on PROTOCOL_INTERFACE.OpenList\r |
86 | LIST_ENTRY Link; \r | |
28a00297 | 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 | |
f3f2e05d | 95 | #define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')\r |
ec90508b | 96 | \r |
97 | ///\r | |
98 | /// PROTOCOL_NOTIFY - used for each register notification for a protocol\r | |
99 | ///\r | |
28a00297 | 100 | typedef struct {\r |
101 | UINTN Signature;\r | |
c79be85e | 102 | PROTOCOL_ENTRY *Protocol;\r |
ec90508b | 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 | |
28a00297 | 109 | } PROTOCOL_NOTIFY;\r |
110 | \r | |
28a00297 | 111 | \r |
28a00297 | 112 | \r |
162ed594 | 113 | /**\r |
28a00297 | 114 | Finds the protocol entry for the requested protocol.\r |
28a00297 | 115 | The gProtocolDatabaseLock must be owned\r |
116 | \r | |
022c6d45 | 117 | @param Protocol The ID of the protocol\r |
118 | @param Create Create a new entry if not found\r | |
162ed594 | 119 | \r |
120 | @return Protocol entry\r | |
28a00297 | 121 | \r |
162ed594 | 122 | **/\r |
123 | PROTOCOL_ENTRY *\r | |
124 | CoreFindProtocolEntry (\r | |
23c98c94 | 125 | IN EFI_GUID *Protocol,\r |
126 | IN BOOLEAN Create\r | |
127 | );\r | |
28a00297 | 128 | \r |
28a00297 | 129 | \r |
162ed594 | 130 | /**\r |
131 | Signal event for every protocol in protocol entry.\r | |
28a00297 | 132 | \r |
162ed594 | 133 | @param ProtEntry Protocol entry\r |
28a00297 | 134 | \r |
162ed594 | 135 | **/\r |
28a00297 | 136 | VOID\r |
137 | CoreNotifyProtocolEntry (\r | |
23c98c94 | 138 | IN PROTOCOL_ENTRY *ProtEntry\r |
139 | );\r | |
28a00297 | 140 | \r |
28a00297 | 141 | \r |
162ed594 | 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 | |
28a00297 | 146 | \r |
022c6d45 | 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 | |
28a00297 | 150 | \r |
162ed594 | 151 | @return Protocol instance (NULL: Not found)\r |
28a00297 | 152 | \r |
162ed594 | 153 | **/\r |
28a00297 | 154 | PROTOCOL_INTERFACE *\r |
155 | CoreFindProtocolInterface (\r | |
23c98c94 | 156 | IN IHANDLE *Handle,\r |
157 | IN EFI_GUID *Protocol,\r | |
158 | IN VOID *Interface\r | |
159 | );\r | |
28a00297 | 160 | \r |
28a00297 | 161 | \r |
162ed594 | 162 | /**\r |
163 | Removes Protocol from the protocol list (but not the handle list).\r | |
28a00297 | 164 | \r |
022c6d45 | 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 | |
28a00297 | 168 | \r |
162ed594 | 169 | @return Protocol Entry\r |
28a00297 | 170 | \r |
162ed594 | 171 | **/\r |
28a00297 | 172 | PROTOCOL_INTERFACE *\r |
173 | CoreRemoveInterfaceFromProtocol (\r | |
23c98c94 | 174 | IN IHANDLE *Handle,\r |
175 | IN EFI_GUID *Protocol,\r | |
176 | IN VOID *Interface\r | |
177 | );\r | |
28a00297 | 178 | \r |
28a00297 | 179 | \r |
e94a9ff7 | 180 | /**\r |
181 | Connects a controller to a driver.\r | |
182 | \r | |
022c6d45 | 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 | |
e94a9ff7 | 198 | ControllerHandle.\r |
199 | \r | |
200 | **/\r | |
022c6d45 | 201 | EFI_STATUS\r |
e94a9ff7 | 202 | CoreConnectSingleController (\r |
203 | IN EFI_HANDLE ControllerHandle,\r | |
204 | IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL,\r | |
022c6d45 | 205 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r |
e94a9ff7 | 206 | );\r |
28a00297 | 207 | \r |
162ed594 | 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 | |
28a00297 | 213 | \r |
022c6d45 | 214 | @param UserHandle The handle on which the protocol is installed\r |
215 | @param Prot The protocol to disconnect drivers from\r | |
28a00297 | 216 | \r |
022c6d45 | 217 | @retval EFI_SUCCESS Drivers using the protocol interface are all\r |
218 | disconnected\r | |
162ed594 | 219 | @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers\r |
28a00297 | 220 | \r |
162ed594 | 221 | **/\r |
28a00297 | 222 | EFI_STATUS\r |
223 | CoreDisconnectControllersUsingProtocolInterface (\r | |
224 | IN EFI_HANDLE UserHandle,\r | |
225 | IN PROTOCOL_INTERFACE *Prot\r | |
23c98c94 | 226 | );\r |
28a00297 | 227 | \r |
28a00297 | 228 | \r |
162ed594 | 229 | /**\r |
230 | Acquire lock on gProtocolDatabaseLock.\r | |
28a00297 | 231 | \r |
162ed594 | 232 | **/\r |
28a00297 | 233 | VOID\r |
234 | CoreAcquireProtocolLock (\r | |
235 | VOID\r | |
23c98c94 | 236 | );\r |
28a00297 | 237 | \r |
28a00297 | 238 | \r |
162ed594 | 239 | /**\r |
240 | Release lock on gProtocolDatabaseLock.\r | |
28a00297 | 241 | \r |
162ed594 | 242 | **/\r |
28a00297 | 243 | VOID\r |
244 | CoreReleaseProtocolLock (\r | |
245 | VOID\r | |
23c98c94 | 246 | );\r |
28a00297 | 247 | \r |
28a00297 | 248 | \r |
162ed594 | 249 | /**\r |
250 | Check whether a handle is a valid EFI_HANDLE\r | |
28a00297 | 251 | \r |
022c6d45 | 252 | @param UserHandle The handle to check\r |
28a00297 | 253 | \r |
022c6d45 | 254 | @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE.\r |
162ed594 | 255 | @retval EFI_SUCCESS The handle is valid EFI_HANDLE.\r |
28a00297 | 256 | \r |
162ed594 | 257 | **/\r |
28a00297 | 258 | EFI_STATUS\r |
259 | CoreValidateHandle (\r | |
260 | IN EFI_HANDLE UserHandle\r | |
23c98c94 | 261 | );\r |
28a00297 | 262 | \r |
263 | //\r | |
264 | // Externs\r | |
265 | //\r | |
28a00297 | 266 | extern EFI_LOCK gProtocolDatabaseLock;\r |
267 | extern LIST_ENTRY gHandleList;\r | |
268 | extern UINT64 gHandleDatabaseKey;\r | |
269 | \r | |
270 | #endif\r |