3 Copyright (c) 2005 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 #include <Protocol/ServiceBinding.h>
25 #include <Protocol/SimpleNetwork.h>
26 #include <Protocol/LoadedImage.h>
27 #include <Protocol/NicIp4Config.h>
28 #include <Protocol/ComponentName.h>
29 #include <Protocol/ComponentName2.h>
30 #include <Protocol/Ip4.h>
31 #include <Protocol/Dpc.h>
33 #include <Library/NetLib.h>
34 #include <Library/BaseLib.h>
35 #include <Library/DebugLib.h>
36 #include <Library/BaseMemoryLib.h>
37 #include <Library/UefiBootServicesTableLib.h>
38 #include <Library/UefiRuntimeServicesTableLib.h>
39 #include <Library/UefiLib.h>
40 #include <Library/MemoryAllocationLib.h>
41 #include <Library/DevicePathLib.h>
43 EFI_DPC_PROTOCOL
*mDpc
= NULL
;
45 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mNetLibHexStr
[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
48 // All the supported IP4 maskes in host byte order.
50 IP4_ADDR gIp4AllMasks
[IP4_MASK_NUM
] = {
89 EFI_IPv4_ADDRESS mZeroIp4Addr
= {{0, 0, 0, 0}};
92 Return the length of the mask. If the mask is invalid,
93 return the invalid length 33, which is IP4_MASK_NUM.
94 NetMask is in the host byte order.
96 @param NetMask The netmask to get the length from
98 @return The length of the netmask, IP4_MASK_NUM if the mask isn't
110 for (Index
= 0; Index
< IP4_MASK_NUM
; Index
++) {
111 if (NetMask
== gIp4AllMasks
[Index
]) {
122 Return the class of the address, such as class a, b, c.
123 Addr is in host byte order.
125 @param Addr The address to get the class from
127 @return IP address class, such as IP4_ADDR_CLASSA
138 ByteOne
= (UINT8
) (Addr
>> 24);
140 if ((ByteOne
& 0x80) == 0) {
141 return IP4_ADDR_CLASSA
;
143 } else if ((ByteOne
& 0xC0) == 0x80) {
144 return IP4_ADDR_CLASSB
;
146 } else if ((ByteOne
& 0xE0) == 0xC0) {
147 return IP4_ADDR_CLASSC
;
149 } else if ((ByteOne
& 0xF0) == 0xE0) {
150 return IP4_ADDR_CLASSD
;
153 return IP4_ADDR_CLASSE
;
160 Check whether the IP is a valid unicast address according to
161 the netmask. If NetMask is zero, use the IP address's class to
162 get the default mask.
164 @param Ip The IP to check againist
165 @param NetMask The mask of the IP
167 @return TRUE if IP is a valid unicast address on the network, otherwise FALSE
179 Class
= NetGetIpClass (Ip
);
181 if ((Ip
== 0) || (Class
>= IP4_ADDR_CLASSD
)) {
186 NetMask
= gIp4AllMasks
[Class
<< 3];
189 if (((Ip
&~NetMask
) == ~NetMask
) || ((Ip
&~NetMask
) == 0)) {
198 Initialize a random seed using current time.
202 @return The random seed initialized with current time.
214 gRT
->GetTime (&Time
, NULL
);
215 Seed
= (~Time
.Hour
<< 24 | Time
.Day
<< 16 | Time
.Minute
<< 8 | Time
.Second
);
216 Seed
^= Time
.Nanosecond
;
217 Seed
^= Time
.Year
<< 7;
224 Extract a UINT32 from a byte stream, then convert it to host
225 byte order. Use this function to avoid alignment error.
227 @param Buf The buffer to extract the UINT32.
229 @return The UINT32 extracted.
240 CopyMem (&Value
, Buf
, sizeof (UINT32
));
241 return NTOHL (Value
);
246 Put a UINT32 to the byte stream. Convert it from host byte order
247 to network byte order before putting.
249 @param Buf The buffer to put the UINT32
250 @param Data The data to put
263 CopyMem (Buf
, &Data
, sizeof (UINT32
));
268 Remove the first entry on the list
270 @param Head The list header
272 @return The entry that is removed from the list, NULL if the list is empty.
283 ASSERT (Head
!= NULL
);
285 if (IsListEmpty (Head
)) {
289 First
= Head
->ForwardLink
;
290 Head
->ForwardLink
= First
->ForwardLink
;
291 First
->ForwardLink
->BackLink
= Head
;
294 First
->ForwardLink
= (LIST_ENTRY
*) NULL
;
295 First
->BackLink
= (LIST_ENTRY
*) NULL
;
303 Remove the last entry on the list
305 @param Head The list head
307 @return The entry that is removed from the list, NULL if the list is empty.
318 ASSERT (Head
!= NULL
);
320 if (IsListEmpty (Head
)) {
324 Last
= Head
->BackLink
;
325 Head
->BackLink
= Last
->BackLink
;
326 Last
->BackLink
->ForwardLink
= Head
;
329 Last
->ForwardLink
= (LIST_ENTRY
*) NULL
;
330 Last
->BackLink
= (LIST_ENTRY
*) NULL
;
338 Insert the NewEntry after the PrevEntry
340 @param PrevEntry The previous entry to insert after
341 @param NewEntry The new entry to insert
349 IN LIST_ENTRY
*PrevEntry
,
350 IN LIST_ENTRY
*NewEntry
353 NewEntry
->BackLink
= PrevEntry
;
354 NewEntry
->ForwardLink
= PrevEntry
->ForwardLink
;
355 PrevEntry
->ForwardLink
->BackLink
= NewEntry
;
356 PrevEntry
->ForwardLink
= NewEntry
;
361 Insert the NewEntry before the PostEntry
363 @param PostEntry The entry to insert before
364 @param NewEntry The new entry to insert
371 NetListInsertBefore (
372 IN LIST_ENTRY
*PostEntry
,
373 IN LIST_ENTRY
*NewEntry
376 NewEntry
->ForwardLink
= PostEntry
;
377 NewEntry
->BackLink
= PostEntry
->BackLink
;
378 PostEntry
->BackLink
->ForwardLink
= NewEntry
;
379 PostEntry
->BackLink
= NewEntry
;
384 Initialize the netmap. Netmap is a reposity to keep the <Key, Value> pairs.
386 @param Map The netmap to initialize
397 ASSERT (Map
!= NULL
);
399 InitializeListHead (&Map
->Used
);
400 InitializeListHead (&Map
->Recycled
);
406 To clean up the netmap, that is, release allocated memories.
408 @param Map The netmap to clean up.
423 ASSERT (Map
!= NULL
);
425 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &Map
->Used
) {
426 Item
= NET_LIST_USER_STRUCT (Entry
, NET_MAP_ITEM
, Link
);
428 RemoveEntryList (&Item
->Link
);
431 gBS
->FreePool (Item
);
434 ASSERT ((Map
->Count
== 0) && IsListEmpty (&Map
->Used
));
436 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &Map
->Recycled
) {
437 Item
= NET_LIST_USER_STRUCT (Entry
, NET_MAP_ITEM
, Link
);
439 RemoveEntryList (&Item
->Link
);
440 gBS
->FreePool (Item
);
443 ASSERT (IsListEmpty (&Map
->Recycled
));
448 Test whether the netmap is empty
450 @param Map The net map to test
452 @return TRUE if the netmap is empty, otherwise FALSE.
461 ASSERT (Map
!= NULL
);
462 return (BOOLEAN
) (Map
->Count
== 0);
467 Return the number of the <Key, Value> pairs in the netmap.
469 @param Map The netmap to get the entry number
471 @return The entry number in the netmap.
485 Allocate an item for the netmap. It will try to allocate
486 a batch of items and return one.
488 @param Map The netmap to allocate item for
490 @return The allocated item or NULL
502 ASSERT (Map
!= NULL
);
504 Head
= &Map
->Recycled
;
506 if (IsListEmpty (Head
)) {
507 for (Index
= 0; Index
< NET_MAP_INCREAMENT
; Index
++) {
508 Item
= AllocatePool (sizeof (NET_MAP_ITEM
));
518 InsertHeadList (Head
, &Item
->Link
);
522 Item
= NET_LIST_HEAD (Head
, NET_MAP_ITEM
, Link
);
523 NetListRemoveHead (Head
);
530 Allocate an item to save the <Key, Value> pair to the head of the netmap.
532 @param Map The netmap to insert into
533 @param Key The user's key
534 @param Value The user's value for the key
536 @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the item
537 @retval EFI_SUCCESS The item is inserted to the head
545 IN VOID
*Value OPTIONAL
550 ASSERT (Map
!= NULL
);
552 Item
= NetMapAllocItem (Map
);
555 return EFI_OUT_OF_RESOURCES
;
560 InsertHeadList (&Map
->Used
, &Item
->Link
);
568 Allocate an item to save the <Key, Value> pair to the tail of the netmap.
570 @param Map The netmap to insert into
571 @param Key The user's key
572 @param Value The user's value for the key
574 @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the item
575 @retval EFI_SUCCESS The item is inserted to the tail
583 IN VOID
*Value OPTIONAL
588 ASSERT (Map
!= NULL
);
590 Item
= NetMapAllocItem (Map
);
593 return EFI_OUT_OF_RESOURCES
;
598 InsertTailList (&Map
->Used
, &Item
->Link
);
607 Check whther the item is in the Map
609 @param Map The netmap to search within
610 @param Item The item to search
612 @return TRUE if the item is in the netmap, otherwise FALSE.
618 IN NET_MAP_ITEM
*Item
621 LIST_ENTRY
*ListEntry
;
623 NET_LIST_FOR_EACH (ListEntry
, &Map
->Used
) {
624 if (ListEntry
== &Item
->Link
) {
634 Find the key in the netmap
636 @param Map The netmap to search within
637 @param Key The key to search
639 @return The point to the item contains the Key, or NULL if Key isn't in the map.
652 ASSERT (Map
!= NULL
);
654 NET_LIST_FOR_EACH (Entry
, &Map
->Used
) {
655 Item
= NET_LIST_USER_STRUCT (Entry
, NET_MAP_ITEM
, Link
);
657 if (Item
->Key
== Key
) {
667 Remove the item from the netmap
669 @param Map The netmap to remove the item from
670 @param Item The item to remove
671 @param Value The variable to receive the value if not NULL
673 @return The key of the removed item.
680 IN NET_MAP_ITEM
*Item
,
681 OUT VOID
**Value OPTIONAL
684 ASSERT ((Map
!= NULL
) && (Item
!= NULL
));
685 ASSERT (NetItemInMap (Map
, Item
));
687 RemoveEntryList (&Item
->Link
);
689 InsertHeadList (&Map
->Recycled
, &Item
->Link
);
692 *Value
= Item
->Value
;
700 Remove the first entry on the netmap
702 @param Map The netmap to remove the head from
703 @param Value The variable to receive the value if not NULL
705 @return The key of the item removed
712 OUT VOID
**Value OPTIONAL
718 // Often, it indicates a programming error to remove
719 // the first entry in an empty list
721 ASSERT (Map
&& !IsListEmpty (&Map
->Used
));
723 Item
= NET_LIST_HEAD (&Map
->Used
, NET_MAP_ITEM
, Link
);
724 RemoveEntryList (&Item
->Link
);
726 InsertHeadList (&Map
->Recycled
, &Item
->Link
);
729 *Value
= Item
->Value
;
737 Remove the last entry on the netmap
739 @param Map The netmap to remove the tail from
740 @param Value The variable to receive the value if not NULL
742 @return The key of the item removed
749 OUT VOID
**Value OPTIONAL
755 // Often, it indicates a programming error to remove
756 // the last entry in an empty list
758 ASSERT (Map
&& !IsListEmpty (&Map
->Used
));
760 Item
= NET_LIST_TAIL (&Map
->Used
, NET_MAP_ITEM
, Link
);
761 RemoveEntryList (&Item
->Link
);
763 InsertHeadList (&Map
->Recycled
, &Item
->Link
);
766 *Value
= Item
->Value
;
774 Iterate through the netmap and call CallBack for each item. It will
775 contiue the traverse if CallBack returns EFI_SUCCESS, otherwise, break
776 from the loop. It returns the CallBack's last return value. This
777 function is delete safe for the current item.
779 @param Map The Map to iterate through
780 @param CallBack The callback function to call for each item.
781 @param Arg The opaque parameter to the callback
783 @return It returns the CallBack's last return value.
790 IN NET_MAP_CALLBACK CallBack
,
801 ASSERT ((Map
!= NULL
) && (CallBack
!= NULL
));
805 if (IsListEmpty (Head
)) {
809 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, Head
) {
810 Item
= NET_LIST_USER_STRUCT (Entry
, NET_MAP_ITEM
, Link
);
811 Result
= CallBack (Map
, Item
, Arg
);
813 if (EFI_ERROR (Result
)) {
823 This is the default unload handle for all the network drivers.
825 @param ImageHandle The drivers' driver image.
827 @retval EFI_SUCCESS The image is unloaded.
828 @retval Others Failed to unload the image.
833 NetLibDefaultUnload (
834 IN EFI_HANDLE ImageHandle
838 EFI_HANDLE
*DeviceHandleBuffer
;
839 UINTN DeviceHandleCount
;
841 EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
;
842 EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
;
843 EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
;
846 // Get the list of all the handles in the handle database.
847 // If there is an error getting the list, then the unload
850 Status
= gBS
->LocateHandleBuffer (
858 if (EFI_ERROR (Status
)) {
863 // Disconnect the driver specified by ImageHandle from all
864 // the devices in the handle database.
866 for (Index
= 0; Index
< DeviceHandleCount
; Index
++) {
867 Status
= gBS
->DisconnectController (
868 DeviceHandleBuffer
[Index
],
875 // Uninstall all the protocols installed in the driver entry point
877 for (Index
= 0; Index
< DeviceHandleCount
; Index
++) {
878 Status
= gBS
->HandleProtocol (
879 DeviceHandleBuffer
[Index
],
880 &gEfiDriverBindingProtocolGuid
,
881 (VOID
**) &DriverBinding
884 if (EFI_ERROR (Status
)) {
888 if (DriverBinding
->ImageHandle
!= ImageHandle
) {
892 gBS
->UninstallProtocolInterface (
894 &gEfiDriverBindingProtocolGuid
,
897 Status
= gBS
->HandleProtocol (
898 DeviceHandleBuffer
[Index
],
899 &gEfiComponentNameProtocolGuid
,
900 (VOID
**) &ComponentName
902 if (!EFI_ERROR (Status
)) {
903 gBS
->UninstallProtocolInterface (
905 &gEfiComponentNameProtocolGuid
,
910 Status
= gBS
->HandleProtocol (
911 DeviceHandleBuffer
[Index
],
912 &gEfiComponentName2ProtocolGuid
,
913 (VOID
**) &ComponentName2
915 if (!EFI_ERROR (Status
)) {
916 gBS
->UninstallProtocolInterface (
918 &gEfiComponentName2ProtocolGuid
,
925 // Free the buffer containing the list of handles from the handle database
927 if (DeviceHandleBuffer
!= NULL
) {
928 gBS
->FreePool (DeviceHandleBuffer
);
937 Create a child of the service that is identified by ServiceBindingGuid.
939 @param Controller The controller which has the service installed.
940 @param Image The image handle used to open service.
941 @param ServiceBindingGuid The service's Guid.
942 @param ChildHandle The handle to receive the create child
944 @retval EFI_SUCCESS The child is successfully created.
945 @retval Others Failed to create the child.
950 NetLibCreateServiceChild (
951 IN EFI_HANDLE Controller
,
953 IN EFI_GUID
*ServiceBindingGuid
,
954 OUT EFI_HANDLE
*ChildHandle
958 EFI_SERVICE_BINDING_PROTOCOL
*Service
;
961 ASSERT ((ServiceBindingGuid
!= NULL
) && (ChildHandle
!= NULL
));
964 // Get the ServiceBinding Protocol
966 Status
= gBS
->OpenProtocol (
972 EFI_OPEN_PROTOCOL_GET_PROTOCOL
975 if (EFI_ERROR (Status
)) {
982 Status
= Service
->CreateChild (Service
, ChildHandle
);
988 Destory a child of the service that is identified by ServiceBindingGuid.
990 @param Controller The controller which has the service installed.
991 @param Image The image handle used to open service.
992 @param ServiceBindingGuid The service's Guid.
993 @param ChildHandle The child to destory
995 @retval EFI_SUCCESS The child is successfully destoried.
996 @retval Others Failed to destory the child.
1001 NetLibDestroyServiceChild (
1002 IN EFI_HANDLE Controller
,
1003 IN EFI_HANDLE Image
,
1004 IN EFI_GUID
*ServiceBindingGuid
,
1005 IN EFI_HANDLE ChildHandle
1009 EFI_SERVICE_BINDING_PROTOCOL
*Service
;
1011 ASSERT (ServiceBindingGuid
!= NULL
);
1014 // Get the ServiceBinding Protocol
1016 Status
= gBS
->OpenProtocol (
1022 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1025 if (EFI_ERROR (Status
)) {
1030 // destory the child
1032 Status
= Service
->DestroyChild (Service
, ChildHandle
);
1038 Convert the mac address of the simple network protocol installed on
1039 SnpHandle to a unicode string. Callers are responsible for freeing the
1042 @param SnpHandle The handle where the simple network protocol is
1044 @param ImageHandle The image handle used to act as the agent handle to
1045 get the simple network protocol.
1046 @param MacString The pointer to store the address of the string
1047 representation of the mac address.
1049 @retval EFI_OUT_OF_RESOURCES There are not enough memory resource.
1050 @retval other Failed to open the simple network protocol.
1055 NetLibGetMacString (
1056 IN EFI_HANDLE SnpHandle
,
1057 IN EFI_HANDLE ImageHandle
,
1058 IN OUT CHAR16
**MacString
1062 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
1063 EFI_SIMPLE_NETWORK_MODE
*Mode
;
1070 // Get the Simple Network protocol from the SnpHandle.
1072 Status
= gBS
->OpenProtocol (
1074 &gEfiSimpleNetworkProtocolGuid
,
1078 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1080 if (EFI_ERROR (Status
)) {
1087 // It takes 2 unicode characters to represent a 1 byte binary buffer.
1088 // Plus one unicode character for the null-terminator.
1090 MacAddress
= AllocatePool ((2 * Mode
->HwAddressSize
+ 1) * sizeof (CHAR16
));
1091 if (MacAddress
== NULL
) {
1092 return EFI_OUT_OF_RESOURCES
;
1096 // Convert the mac address into a unicode string.
1098 for (Index
= 0; Index
< Mode
->HwAddressSize
; Index
++) {
1099 MacAddress
[Index
* 2] = (CHAR16
) mNetLibHexStr
[(Mode
->CurrentAddress
.Addr
[Index
] >> 4) & 0x0F];
1100 MacAddress
[Index
* 2 + 1] = (CHAR16
) mNetLibHexStr
[Mode
->CurrentAddress
.Addr
[Index
] & 0x0F];
1103 MacAddress
[Mode
->HwAddressSize
* 2] = L
'\0';
1105 *MacString
= MacAddress
;
1111 Check the default address used by the IPv4 driver is static or dynamic (acquired
1114 @param Controller The controller handle which has the NIC Ip4 Config Protocol
1115 relative with the default address to judge.
1117 @retval TRUE If the default address is static.
1118 @retval FALSE If the default address is acquired from DHCP.
1122 NetLibDefaultAddressIsStatic (
1123 IN EFI_HANDLE Controller
1127 EFI_NIC_IP4_CONFIG_PROTOCOL
*NicIp4
;
1129 NIC_IP4_CONFIG_INFO
*ConfigInfo
;
1132 Status
= gBS
->HandleProtocol (
1134 &gEfiNicIp4ConfigProtocolGuid
,
1137 if (EFI_ERROR (Status
)) {
1142 Status
= NicIp4
->GetInfo (NicIp4
, &Len
, NULL
);
1143 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
1147 ConfigInfo
= AllocatePool (Len
);
1148 if (ConfigInfo
== NULL
) {
1153 Status
= NicIp4
->GetInfo (NicIp4
, &Len
, ConfigInfo
);
1154 if (EFI_ERROR (Status
)) {
1158 IsStatic
= (BOOLEAN
) (ConfigInfo
->Source
== IP4_CONFIG_SOURCE_STATIC
);
1162 gBS
->FreePool (ConfigInfo
);
1168 Create an IPv4 device path node.
1170 @param Node Pointer to the IPv4 device path node.
1171 @param Controller The handle where the NIC IP4 config protocol resides.
1172 @param LocalIp The local IPv4 address.
1173 @param LocalPort The local port.
1174 @param RemoteIp The remote IPv4 address.
1175 @param RemotePort The remote port.
1176 @param Protocol The protocol type in the IP header.
1177 @param UseDefaultAddress Whether this instance is using default address or not.
1183 NetLibCreateIPv4DPathNode (
1184 IN OUT IPv4_DEVICE_PATH
*Node
,
1185 IN EFI_HANDLE Controller
,
1186 IN IP4_ADDR LocalIp
,
1187 IN UINT16 LocalPort
,
1188 IN IP4_ADDR RemoteIp
,
1189 IN UINT16 RemotePort
,
1191 IN BOOLEAN UseDefaultAddress
1194 Node
->Header
.Type
= MESSAGING_DEVICE_PATH
;
1195 Node
->Header
.SubType
= MSG_IPv4_DP
;
1196 SetDevicePathNodeLength (&Node
->Header
, 19);
1198 CopyMem (&Node
->LocalIpAddress
, &LocalIp
, sizeof (EFI_IPv4_ADDRESS
));
1199 CopyMem (&Node
->RemoteIpAddress
, &RemoteIp
, sizeof (EFI_IPv4_ADDRESS
));
1201 Node
->LocalPort
= LocalPort
;
1202 Node
->RemotePort
= RemotePort
;
1204 Node
->Protocol
= Protocol
;
1206 if (!UseDefaultAddress
) {
1207 Node
->StaticIpAddress
= TRUE
;
1209 Node
->StaticIpAddress
= NetLibDefaultAddressIsStatic (Controller
);
1215 Find the UNDI/SNP handle from controller and protocol GUID.
1216 For example, IP will open a MNP child to transmit/receive
1217 packets, when MNP is stopped, IP should also be stopped. IP
1218 needs to find its own private data which is related the IP's
1219 service binding instance that is install on UNDI/SNP handle.
1220 Now, the controller is either a MNP or ARP child handle. But
1221 IP opens these handle BY_DRIVER, use that info, we can get the
1224 @param Controller Then protocol handle to check
1225 @param ProtocolGuid The protocol that is related with the handle.
1227 @return The UNDI/SNP handle or NULL.
1232 NetLibGetNicHandle (
1233 IN EFI_HANDLE Controller
,
1234 IN EFI_GUID
*ProtocolGuid
1237 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenBuffer
;
1243 Status
= gBS
->OpenProtocolInformation (
1250 if (EFI_ERROR (Status
)) {
1256 for (Index
= 0; Index
< OpenCount
; Index
++) {
1257 if (OpenBuffer
[Index
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) {
1258 Handle
= OpenBuffer
[Index
].ControllerHandle
;
1263 gBS
->FreePool (OpenBuffer
);
1268 Add a Deferred Procedure Call to the end of the DPC queue.
1270 @DpcTpl The EFI_TPL that the DPC should be invoked.
1271 @DpcProcedure Pointer to the DPC's function.
1272 @DpcContext Pointer to the DPC's context. Passed to DpcProcedure
1273 when DpcProcedure is invoked.
1275 @retval EFI_SUCCESS The DPC was queued.
1276 @retval EFI_INVALID_PARAMETER DpcTpl is not a valid EFI_TPL.
1277 DpcProcedure is NULL.
1278 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
1279 add the DPC to the queue.
1286 IN EFI_DPC_PROCEDURE DpcProcedure
,
1287 IN VOID
*DpcContext OPTIONAL
1290 return mDpc
->QueueDpc (mDpc
, DpcTpl
, DpcProcedure
, DpcContext
);
1294 Add a Deferred Procedure Call to the end of the DPC queue.
1296 @retval EFI_SUCCESS One or more DPCs were invoked.
1297 @retval EFI_NOT_FOUND No DPCs were invoked.
1306 return mDpc
->DispatchDpc(mDpc
);
1311 The constructor function caches the pointer to DPC protocol.
1313 The constructor function locates DPC protocol from protocol database.
1314 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
1316 @param ImageHandle The firmware allocated handle for the EFI image.
1317 @param SystemTable A pointer to the EFI System Table.
1319 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
1325 IN EFI_HANDLE ImageHandle
,
1326 IN EFI_SYSTEM_TABLE
*SystemTable
1331 Status
= gBS
->LocateProtocol (&gEfiDpcProtocolGuid
, NULL
, (VOID
**) &mDpc
);
1332 ASSERT_EFI_ERROR (Status
);
1333 ASSERT (mDpc
!= NULL
);