]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/Handle.h
Don't align image address for TeImage, because TeImage section alignment is undefined.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Handle.h
CommitLineData
23c98c94 1/** @file\r
504214c4
LG
2 Support functions for managing protocol.\r
3\r
23c98c94 4Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT 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
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
24typedef 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
022c6d45 28 UINTN LocateRequest; //\r
28a00297 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
022c6d45 36// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol\r
28a00297 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
42typedef struct {\r
43 UINTN Signature;\r
6c857d66 44 LIST_ENTRY AllEntries; // Link Entry inserted to mProtocolDatabase\r
28a00297 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
56typedef struct {\r
57 UINTN Signature;\r
28a00297 58 LIST_ENTRY Link; // Link on IHANDLE.Protocols\r
6c857d66 59 IHANDLE *Handle; // Back pointer\r
28a00297 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
022c6d45 63\r
28a00297 64 LIST_ENTRY OpenList; // OPEN_PROTOCOL_DATA list.\r
022c6d45 65 UINTN OpenListCount;\r
66\r
28a00297 67} PROTOCOL_INTERFACE;\r
68\r
69#define OPEN_PROTOCOL_DATA_SIGNATURE EFI_SIGNATURE_32('p','o','d','l')\r
70\r
71typedef struct {\r
72 UINTN Signature;\r
6c857d66 73 LIST_ENTRY Link; //Link on PROTOCOL_INTERFACE.OpenList\r
28a00297 74\r
75 EFI_HANDLE AgentHandle;\r
76 EFI_HANDLE ControllerHandle;\r
77 UINT32 Attributes;\r
78 UINT32 OpenCount;\r
79} OPEN_PROTOCOL_DATA;\r
80\r
81\r
82//\r
83// PROTOCOL_NOTIFY - used for each register notification for a protocol\r
84//\r
85\r
86#define PROTOCOL_NOTIFY_SIGNATURE EFI_SIGNATURE_32('p','r','t','n')\r
87typedef struct {\r
88 UINTN Signature;\r
c79be85e 89 PROTOCOL_ENTRY *Protocol;\r
130f1602 90 LIST_ENTRY Link; // All notifications for this protocol\r
91 EFI_EVENT Event; // Event to notify\r
28a00297 92 LIST_ENTRY *Position; // Last position notified\r
93} PROTOCOL_NOTIFY;\r
94\r
95//\r
96// Internal prototypes\r
97//\r
98\r
99\r
28a00297 100\r
162ed594 101/**\r
28a00297 102 Finds the protocol entry for the requested protocol.\r
28a00297 103 The gProtocolDatabaseLock must be owned\r
104\r
022c6d45 105 @param Protocol The ID of the protocol\r
106 @param Create Create a new entry if not found\r
162ed594 107\r
108 @return Protocol entry\r
28a00297 109\r
162ed594 110**/\r
111PROTOCOL_ENTRY *\r
112CoreFindProtocolEntry (\r
23c98c94 113 IN EFI_GUID *Protocol,\r
114 IN BOOLEAN Create\r
115 );\r
28a00297 116\r
28a00297 117\r
162ed594 118/**\r
119 Signal event for every protocol in protocol entry.\r
28a00297 120\r
162ed594 121 @param ProtEntry Protocol entry\r
28a00297 122\r
162ed594 123**/\r
28a00297 124VOID\r
125CoreNotifyProtocolEntry (\r
23c98c94 126 IN PROTOCOL_ENTRY *ProtEntry\r
127 );\r
28a00297 128\r
28a00297 129\r
162ed594 130/**\r
131 Finds the protocol instance for the requested handle and protocol.\r
132 Note: This function doesn't do parameters checking, it's caller's responsibility\r
133 to pass in valid parameters.\r
28a00297 134\r
022c6d45 135 @param Handle The handle to search the protocol on\r
136 @param Protocol GUID of the protocol\r
137 @param Interface The interface for the protocol being searched\r
28a00297 138\r
162ed594 139 @return Protocol instance (NULL: Not found)\r
28a00297 140\r
162ed594 141**/\r
28a00297 142PROTOCOL_INTERFACE *\r
143CoreFindProtocolInterface (\r
23c98c94 144 IN IHANDLE *Handle,\r
145 IN EFI_GUID *Protocol,\r
146 IN VOID *Interface\r
147 );\r
28a00297 148\r
28a00297 149\r
162ed594 150/**\r
151 Removes Protocol from the protocol list (but not the handle list).\r
28a00297 152\r
022c6d45 153 @param Handle The handle to remove protocol on.\r
154 @param Protocol GUID of the protocol to be moved\r
155 @param Interface The interface of the protocol\r
28a00297 156\r
162ed594 157 @return Protocol Entry\r
28a00297 158\r
162ed594 159**/\r
28a00297 160PROTOCOL_INTERFACE *\r
161CoreRemoveInterfaceFromProtocol (\r
23c98c94 162 IN IHANDLE *Handle,\r
163 IN EFI_GUID *Protocol,\r
164 IN VOID *Interface\r
165 );\r
28a00297 166\r
28a00297 167\r
162ed594 168/**\r
169 Removes all the events in the protocol database that match Event.\r
28a00297 170\r
022c6d45 171 @param Event The event to search for in the protocol\r
172 database.\r
28a00297 173\r
162ed594 174 @return EFI_SUCCESS when done searching the entire database.\r
28a00297 175\r
162ed594 176**/\r
28a00297 177EFI_STATUS\r
178CoreUnregisterProtocolNotify (\r
23c98c94 179 IN EFI_EVENT Event\r
180 );\r
28a00297 181\r
e94a9ff7 182/**\r
183 Connects a controller to a driver.\r
184\r
022c6d45 185 @param ControllerHandle Handle of the controller to be\r
186 connected.\r
187 @param ContextDriverImageHandles DriverImageHandle A pointer to an\r
188 ordered list of driver image\r
189 handles.\r
190 @param RemainingDevicePath RemainingDevicePath A pointer to\r
191 the device path that specifies a\r
192 child of the controller\r
193 specified by ControllerHandle.\r
194\r
195 @retval EFI_SUCCESS One or more drivers were\r
196 connected to ControllerHandle.\r
197 @retval EFI_OUT_OF_RESOURCES No enough system resources to\r
198 complete the request.\r
199 @retval EFI_NOT_FOUND No drivers were connected to\r
e94a9ff7 200 ControllerHandle.\r
201\r
202**/\r
022c6d45 203EFI_STATUS\r
e94a9ff7 204CoreConnectSingleController (\r
205 IN EFI_HANDLE ControllerHandle,\r
206 IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL,\r
022c6d45 207 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
e94a9ff7 208 );\r
28a00297 209\r
162ed594 210/**\r
211 Attempts to disconnect all drivers that are using the protocol interface being queried.\r
212 If failed, reconnect all drivers disconnected.\r
213 Note: This function doesn't do parameters checking, it's caller's responsibility\r
214 to pass in valid parameters.\r
28a00297 215\r
022c6d45 216 @param UserHandle The handle on which the protocol is installed\r
217 @param Prot The protocol to disconnect drivers from\r
28a00297 218\r
022c6d45 219 @retval EFI_SUCCESS Drivers using the protocol interface are all\r
220 disconnected\r
162ed594 221 @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers\r
28a00297 222\r
162ed594 223**/\r
28a00297 224EFI_STATUS\r
225CoreDisconnectControllersUsingProtocolInterface (\r
226 IN EFI_HANDLE UserHandle,\r
227 IN PROTOCOL_INTERFACE *Prot\r
23c98c94 228 );\r
28a00297 229\r
28a00297 230\r
162ed594 231/**\r
232 Acquire lock on gProtocolDatabaseLock.\r
28a00297 233\r
162ed594 234**/\r
28a00297 235VOID\r
236CoreAcquireProtocolLock (\r
237 VOID\r
23c98c94 238 );\r
28a00297 239\r
28a00297 240\r
162ed594 241/**\r
242 Release lock on gProtocolDatabaseLock.\r
28a00297 243\r
162ed594 244**/\r
28a00297 245VOID\r
246CoreReleaseProtocolLock (\r
247 VOID\r
23c98c94 248 );\r
28a00297 249\r
28a00297 250\r
162ed594 251/**\r
252 Check whether a handle is a valid EFI_HANDLE\r
28a00297 253\r
022c6d45 254 @param UserHandle The handle to check\r
28a00297 255\r
022c6d45 256 @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE.\r
162ed594 257 @retval EFI_SUCCESS The handle is valid EFI_HANDLE.\r
28a00297 258\r
162ed594 259**/\r
28a00297 260EFI_STATUS\r
261CoreValidateHandle (\r
262 IN EFI_HANDLE UserHandle\r
23c98c94 263 );\r
28a00297 264\r
265//\r
266// Externs\r
267//\r
268\r
269extern EFI_LOCK gProtocolDatabaseLock;\r
270extern LIST_ENTRY gHandleList;\r
271extern UINT64 gHandleDatabaseKey;\r
272\r
273#endif\r