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