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>
43 EFI_DPC_PROTOCOL
*mDpc
= NULL
;
46 // All the supported IP4 maskes in host byte order.
48 IP4_ADDR gIp4AllMasks
[IP4_MASK_NUM
] = {
87 EFI_IPv4_ADDRESS mZeroIp4Addr
= {{0, 0, 0, 0}};
90 Return the length of the mask. If the mask is invalid,
91 return the invalid length 33, which is IP4_MASK_NUM.
92 NetMask is in the host byte order.
94 @param NetMask The netmask to get the length from
96 @return The length of the netmask, IP4_MASK_NUM if the mask isn't
108 for (Index
= 0; Index
< IP4_MASK_NUM
; Index
++) {
109 if (NetMask
== gIp4AllMasks
[Index
]) {
120 Return the class of the address, such as class a, b, c.
121 Addr is in host byte order.
123 @param Addr The address to get the class from
125 @return IP address class, such as IP4_ADDR_CLASSA
136 ByteOne
= (UINT8
) (Addr
>> 24);
138 if ((ByteOne
& 0x80) == 0) {
139 return IP4_ADDR_CLASSA
;
141 } else if ((ByteOne
& 0xC0) == 0x80) {
142 return IP4_ADDR_CLASSB
;
144 } else if ((ByteOne
& 0xE0) == 0xC0) {
145 return IP4_ADDR_CLASSC
;
147 } else if ((ByteOne
& 0xF0) == 0xE0) {
148 return IP4_ADDR_CLASSD
;
151 return IP4_ADDR_CLASSE
;
158 Check whether the IP is a valid unicast address according to
159 the netmask. If NetMask is zero, use the IP address's class to
160 get the default mask.
162 @param Ip The IP to check againist
163 @param NetMask The mask of the IP
165 @return TRUE if IP is a valid unicast address on the network, otherwise FALSE
177 Class
= NetGetIpClass (Ip
);
179 if ((Ip
== 0) || (Class
>= IP4_ADDR_CLASSD
)) {
184 NetMask
= gIp4AllMasks
[Class
<< 3];
187 if (((Ip
&~NetMask
) == ~NetMask
) || ((Ip
&~NetMask
) == 0)) {
196 Initialize a random seed using current time.
200 @return The random seed initialized with current time.
212 gRT
->GetTime (&Time
, NULL
);
213 Seed
= (~Time
.Hour
<< 24 | Time
.Day
<< 16 | Time
.Minute
<< 8 | Time
.Second
);
214 Seed
^= Time
.Nanosecond
;
215 Seed
^= Time
.Year
<< 7;
222 Extract a UINT32 from a byte stream, then convert it to host
223 byte order. Use this function to avoid alignment error.
225 @param Buf The buffer to extract the UINT32.
227 @return The UINT32 extracted.
238 CopyMem (&Value
, Buf
, sizeof (UINT32
));
239 return NTOHL (Value
);
244 Put a UINT32 to the byte stream. Convert it from host byte order
245 to network byte order before putting.
247 @param Buf The buffer to put the UINT32
248 @param Data The data to put
261 CopyMem (Buf
, &Data
, sizeof (UINT32
));
266 Remove the first entry on the list
268 @param Head The list header
270 @return The entry that is removed from the list, NULL if the list is empty.
281 ASSERT (Head
!= NULL
);
283 if (IsListEmpty (Head
)) {
287 First
= Head
->ForwardLink
;
288 Head
->ForwardLink
= First
->ForwardLink
;
289 First
->ForwardLink
->BackLink
= Head
;
292 First
->ForwardLink
= (LIST_ENTRY
*) NULL
;
293 First
->BackLink
= (LIST_ENTRY
*) NULL
;
301 Remove the last entry on the list
303 @param Head The list head
305 @return The entry that is removed from the list, NULL if the list is empty.
316 ASSERT (Head
!= NULL
);
318 if (IsListEmpty (Head
)) {
322 Last
= Head
->BackLink
;
323 Head
->BackLink
= Last
->BackLink
;
324 Last
->BackLink
->ForwardLink
= Head
;
327 Last
->ForwardLink
= (LIST_ENTRY
*) NULL
;
328 Last
->BackLink
= (LIST_ENTRY
*) NULL
;
336 Insert the NewEntry after the PrevEntry
338 @param PrevEntry The previous entry to insert after
339 @param NewEntry The new entry to insert
347 IN LIST_ENTRY
*PrevEntry
,
348 IN LIST_ENTRY
*NewEntry
351 NewEntry
->BackLink
= PrevEntry
;
352 NewEntry
->ForwardLink
= PrevEntry
->ForwardLink
;
353 PrevEntry
->ForwardLink
->BackLink
= NewEntry
;
354 PrevEntry
->ForwardLink
= NewEntry
;
359 Insert the NewEntry before the PostEntry
361 @param PostEntry The entry to insert before
362 @param NewEntry The new entry to insert
369 NetListInsertBefore (
370 IN LIST_ENTRY
*PostEntry
,
371 IN LIST_ENTRY
*NewEntry
374 NewEntry
->ForwardLink
= PostEntry
;
375 NewEntry
->BackLink
= PostEntry
->BackLink
;
376 PostEntry
->BackLink
->ForwardLink
= NewEntry
;
377 PostEntry
->BackLink
= NewEntry
;
382 Initialize the netmap. Netmap is a reposity to keep the <Key, Value> pairs.
384 @param Map The netmap to initialize
395 ASSERT (Map
!= NULL
);
397 InitializeListHead (&Map
->Used
);
398 InitializeListHead (&Map
->Recycled
);
404 To clean up the netmap, that is, release allocated memories.
406 @param Map The netmap to clean up.
421 ASSERT (Map
!= NULL
);
423 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &Map
->Used
) {
424 Item
= NET_LIST_USER_STRUCT (Entry
, NET_MAP_ITEM
, Link
);
426 RemoveEntryList (&Item
->Link
);
429 gBS
->FreePool (Item
);
432 ASSERT ((Map
->Count
== 0) && IsListEmpty (&Map
->Used
));
434 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &Map
->Recycled
) {
435 Item
= NET_LIST_USER_STRUCT (Entry
, NET_MAP_ITEM
, Link
);
437 RemoveEntryList (&Item
->Link
);
438 gBS
->FreePool (Item
);
441 ASSERT (IsListEmpty (&Map
->Recycled
));
446 Test whether the netmap is empty
448 @param Map The net map to test
450 @return TRUE if the netmap is empty, otherwise FALSE.
459 ASSERT (Map
!= NULL
);
460 return (BOOLEAN
) (Map
->Count
== 0);
465 Return the number of the <Key, Value> pairs in the netmap.
467 @param Map The netmap to get the entry number
469 @return The entry number in the netmap.
483 Allocate an item for the netmap. It will try to allocate
484 a batch of items and return one.
486 @param Map The netmap to allocate item for
488 @return The allocated item or NULL
500 ASSERT (Map
!= NULL
);
502 Head
= &Map
->Recycled
;
504 if (IsListEmpty (Head
)) {
505 for (Index
= 0; Index
< NET_MAP_INCREAMENT
; Index
++) {
506 Item
= AllocatePool (sizeof (NET_MAP_ITEM
));
516 InsertHeadList (Head
, &Item
->Link
);
520 Item
= NET_LIST_HEAD (Head
, NET_MAP_ITEM
, Link
);
521 NetListRemoveHead (Head
);
528 Allocate an item to save the <Key, Value> pair to the head of the netmap.
530 @param Map The netmap to insert into
531 @param Key The user's key
532 @param Value The user's value for the key
534 @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the item
535 @retval EFI_SUCCESS The item is inserted to the head
543 IN VOID
*Value OPTIONAL
548 ASSERT (Map
!= NULL
);
550 Item
= NetMapAllocItem (Map
);
553 return EFI_OUT_OF_RESOURCES
;
558 InsertHeadList (&Map
->Used
, &Item
->Link
);
566 Allocate an item to save the <Key, Value> pair to the tail of the netmap.
568 @param Map The netmap to insert into
569 @param Key The user's key
570 @param Value The user's value for the key
572 @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the item
573 @retval EFI_SUCCESS The item is inserted to the tail
581 IN VOID
*Value OPTIONAL
586 ASSERT (Map
!= NULL
);
588 Item
= NetMapAllocItem (Map
);
591 return EFI_OUT_OF_RESOURCES
;
596 InsertTailList (&Map
->Used
, &Item
->Link
);
605 Check whther the item is in the Map
607 @param Map The netmap to search within
608 @param Item The item to search
610 @return TRUE if the item is in the netmap, otherwise FALSE.
616 IN NET_MAP_ITEM
*Item
619 LIST_ENTRY
*ListEntry
;
621 NET_LIST_FOR_EACH (ListEntry
, &Map
->Used
) {
622 if (ListEntry
== &Item
->Link
) {
632 Find the key in the netmap
634 @param Map The netmap to search within
635 @param Key The key to search
637 @return The point to the item contains the Key, or NULL if Key isn't in the map.
650 ASSERT (Map
!= NULL
);
652 NET_LIST_FOR_EACH (Entry
, &Map
->Used
) {
653 Item
= NET_LIST_USER_STRUCT (Entry
, NET_MAP_ITEM
, Link
);
655 if (Item
->Key
== Key
) {
665 Remove the item from the netmap
667 @param Map The netmap to remove the item from
668 @param Item The item to remove
669 @param Value The variable to receive the value if not NULL
671 @return The key of the removed item.
678 IN NET_MAP_ITEM
*Item
,
679 OUT VOID
**Value OPTIONAL
682 ASSERT ((Map
!= NULL
) && (Item
!= NULL
));
683 ASSERT (NetItemInMap (Map
, Item
));
685 RemoveEntryList (&Item
->Link
);
687 InsertHeadList (&Map
->Recycled
, &Item
->Link
);
690 *Value
= Item
->Value
;
698 Remove the first entry on the netmap
700 @param Map The netmap to remove the head from
701 @param Value The variable to receive the value if not NULL
703 @return The key of the item removed
710 OUT VOID
**Value OPTIONAL
716 // Often, it indicates a programming error to remove
717 // the first entry in an empty list
719 ASSERT (Map
&& !IsListEmpty (&Map
->Used
));
721 Item
= NET_LIST_HEAD (&Map
->Used
, NET_MAP_ITEM
, Link
);
722 RemoveEntryList (&Item
->Link
);
724 InsertHeadList (&Map
->Recycled
, &Item
->Link
);
727 *Value
= Item
->Value
;
735 Remove the last entry on the netmap
737 @param Map The netmap to remove the tail from
738 @param Value The variable to receive the value if not NULL
740 @return The key of the item removed
747 OUT VOID
**Value OPTIONAL
753 // Often, it indicates a programming error to remove
754 // the last entry in an empty list
756 ASSERT (Map
&& !IsListEmpty (&Map
->Used
));
758 Item
= NET_LIST_TAIL (&Map
->Used
, NET_MAP_ITEM
, Link
);
759 RemoveEntryList (&Item
->Link
);
761 InsertHeadList (&Map
->Recycled
, &Item
->Link
);
764 *Value
= Item
->Value
;
772 Iterate through the netmap and call CallBack for each item. It will
773 contiue the traverse if CallBack returns EFI_SUCCESS, otherwise, break
774 from the loop. It returns the CallBack's last return value. This
775 function is delete safe for the current item.
777 @param Map The Map to iterate through
778 @param CallBack The callback function to call for each item.
779 @param Arg The opaque parameter to the callback
781 @return It returns the CallBack's last return value.
788 IN NET_MAP_CALLBACK CallBack
,
799 ASSERT ((Map
!= NULL
) && (CallBack
!= NULL
));
803 if (IsListEmpty (Head
)) {
807 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, Head
) {
808 Item
= NET_LIST_USER_STRUCT (Entry
, NET_MAP_ITEM
, Link
);
809 Result
= CallBack (Map
, Item
, Arg
);
811 if (EFI_ERROR (Result
)) {
821 This is the default unload handle for all the network drivers.
823 @param ImageHandle The drivers' driver image.
825 @retval EFI_SUCCESS The image is unloaded.
826 @retval Others Failed to unload the image.
831 NetLibDefaultUnload (
832 IN EFI_HANDLE ImageHandle
836 EFI_HANDLE
*DeviceHandleBuffer
;
837 UINTN DeviceHandleCount
;
839 EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
;
840 EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
;
841 EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
;
844 // Get the list of all the handles in the handle database.
845 // If there is an error getting the list, then the unload
848 Status
= gBS
->LocateHandleBuffer (
856 if (EFI_ERROR (Status
)) {
861 // Disconnect the driver specified by ImageHandle from all
862 // the devices in the handle database.
864 for (Index
= 0; Index
< DeviceHandleCount
; Index
++) {
865 Status
= gBS
->DisconnectController (
866 DeviceHandleBuffer
[Index
],
873 // Uninstall all the protocols installed in the driver entry point
875 for (Index
= 0; Index
< DeviceHandleCount
; Index
++) {
876 Status
= gBS
->HandleProtocol (
877 DeviceHandleBuffer
[Index
],
878 &gEfiDriverBindingProtocolGuid
,
879 (VOID
**) &DriverBinding
882 if (EFI_ERROR (Status
)) {
886 if (DriverBinding
->ImageHandle
!= ImageHandle
) {
890 gBS
->UninstallProtocolInterface (
892 &gEfiDriverBindingProtocolGuid
,
895 Status
= gBS
->HandleProtocol (
896 DeviceHandleBuffer
[Index
],
897 &gEfiComponentNameProtocolGuid
,
898 (VOID
**) &ComponentName
900 if (!EFI_ERROR (Status
)) {
901 gBS
->UninstallProtocolInterface (
903 &gEfiComponentNameProtocolGuid
,
908 Status
= gBS
->HandleProtocol (
909 DeviceHandleBuffer
[Index
],
910 &gEfiComponentName2ProtocolGuid
,
911 (VOID
**) &ComponentName2
913 if (!EFI_ERROR (Status
)) {
914 gBS
->UninstallProtocolInterface (
916 &gEfiComponentName2ProtocolGuid
,
923 // Free the buffer containing the list of handles from the handle database
925 if (DeviceHandleBuffer
!= NULL
) {
926 gBS
->FreePool (DeviceHandleBuffer
);
935 Create a child of the service that is identified by ServiceBindingGuid.
937 @param Controller The controller which has the service installed.
938 @param Image The image handle used to open service.
939 @param ServiceBindingGuid The service's Guid.
940 @param ChildHandle The handle to receive the create child
942 @retval EFI_SUCCESS The child is successfully created.
943 @retval Others Failed to create the child.
948 NetLibCreateServiceChild (
949 IN EFI_HANDLE Controller
,
951 IN EFI_GUID
*ServiceBindingGuid
,
952 OUT EFI_HANDLE
*ChildHandle
956 EFI_SERVICE_BINDING_PROTOCOL
*Service
;
959 ASSERT ((ServiceBindingGuid
!= NULL
) && (ChildHandle
!= NULL
));
962 // Get the ServiceBinding Protocol
964 Status
= gBS
->OpenProtocol (
970 EFI_OPEN_PROTOCOL_GET_PROTOCOL
973 if (EFI_ERROR (Status
)) {
980 Status
= Service
->CreateChild (Service
, ChildHandle
);
986 Destory a child of the service that is identified by ServiceBindingGuid.
988 @param Controller The controller which has the service installed.
989 @param Image The image handle used to open service.
990 @param ServiceBindingGuid The service's Guid.
991 @param ChildHandle The child to destory
993 @retval EFI_SUCCESS The child is successfully destoried.
994 @retval Others Failed to destory the child.
999 NetLibDestroyServiceChild (
1000 IN EFI_HANDLE Controller
,
1001 IN EFI_HANDLE Image
,
1002 IN EFI_GUID
*ServiceBindingGuid
,
1003 IN EFI_HANDLE ChildHandle
1007 EFI_SERVICE_BINDING_PROTOCOL
*Service
;
1009 ASSERT (ServiceBindingGuid
!= NULL
);
1012 // Get the ServiceBinding Protocol
1014 Status
= gBS
->OpenProtocol (
1020 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1023 if (EFI_ERROR (Status
)) {
1028 // destory the child
1030 Status
= Service
->DestroyChild (Service
, ChildHandle
);
1036 Convert the mac address of the simple network protocol installed on
1037 SnpHandle to a unicode string. Callers are responsible for freeing the
1040 @param SnpHandle The handle where the simple network protocol is
1042 @param ImageHandle The image handle used to act as the agent handle to
1043 get the simple network protocol.
1044 @param MacString The pointer to store the address of the string
1045 representation of the mac address.
1047 @retval EFI_OUT_OF_RESOURCES There are not enough memory resource.
1048 @retval other Failed to open the simple network protocol.
1053 NetLibGetMacString (
1054 IN EFI_HANDLE SnpHandle
,
1055 IN EFI_HANDLE ImageHandle
,
1056 IN OUT CHAR16
**MacString
1060 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
1061 EFI_SIMPLE_NETWORK_MODE
*Mode
;
1068 // Get the Simple Network protocol from the SnpHandle.
1070 Status
= gBS
->OpenProtocol (
1072 &gEfiSimpleNetworkProtocolGuid
,
1076 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1078 if (EFI_ERROR (Status
)) {
1085 // It takes 2 unicode characters to represent a 1 byte binary buffer.
1086 // Plus one unicode character for the null-terminator.
1088 MacAddress
= AllocatePool ((2 * Mode
->HwAddressSize
+ 1) * sizeof (CHAR16
));
1089 if (MacAddress
== NULL
) {
1090 return EFI_OUT_OF_RESOURCES
;
1094 // Convert the mac address into a unicode string.
1096 for (Index
= 0; Index
< Mode
->HwAddressSize
; Index
++) {
1097 MacAddress
[Index
* 2] = NibbleToHexChar ((UINT8
) (Mode
->CurrentAddress
.Addr
[Index
] >> 4));
1098 MacAddress
[Index
* 2 + 1] = NibbleToHexChar (Mode
->CurrentAddress
.Addr
[Index
]);
1101 MacAddress
[Mode
->HwAddressSize
* 2] = L
'\0';
1103 *MacString
= MacAddress
;
1109 Check the default address used by the IPv4 driver is static or dynamic (acquired
1112 @param Controller The controller handle which has the NIC Ip4 Config Protocol
1113 relative with the default address to judge.
1115 @retval TRUE If the default address is static.
1116 @retval FALSE If the default address is acquired from DHCP.
1120 NetLibDefaultAddressIsStatic (
1121 IN EFI_HANDLE Controller
1125 EFI_NIC_IP4_CONFIG_PROTOCOL
*NicIp4
;
1127 NIC_IP4_CONFIG_INFO
*ConfigInfo
;
1130 Status
= gBS
->HandleProtocol (
1132 &gEfiNicIp4ConfigProtocolGuid
,
1135 if (EFI_ERROR (Status
)) {
1140 Status
= NicIp4
->GetInfo (NicIp4
, &Len
, NULL
);
1141 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
1145 ConfigInfo
= AllocatePool (Len
);
1146 if (ConfigInfo
== NULL
) {
1151 Status
= NicIp4
->GetInfo (NicIp4
, &Len
, ConfigInfo
);
1152 if (EFI_ERROR (Status
)) {
1156 IsStatic
= (BOOLEAN
) (ConfigInfo
->Source
== IP4_CONFIG_SOURCE_STATIC
);
1160 gBS
->FreePool (ConfigInfo
);
1166 Create an IPv4 device path node.
1168 @param Node Pointer to the IPv4 device path node.
1169 @param Controller The handle where the NIC IP4 config protocol resides.
1170 @param LocalIp The local IPv4 address.
1171 @param LocalPort The local port.
1172 @param RemoteIp The remote IPv4 address.
1173 @param RemotePort The remote port.
1174 @param Protocol The protocol type in the IP header.
1175 @param UseDefaultAddress Whether this instance is using default address or not.
1181 NetLibCreateIPv4DPathNode (
1182 IN OUT IPv4_DEVICE_PATH
*Node
,
1183 IN EFI_HANDLE Controller
,
1184 IN IP4_ADDR LocalIp
,
1185 IN UINT16 LocalPort
,
1186 IN IP4_ADDR RemoteIp
,
1187 IN UINT16 RemotePort
,
1189 IN BOOLEAN UseDefaultAddress
1192 Node
->Header
.Type
= MESSAGING_DEVICE_PATH
;
1193 Node
->Header
.SubType
= MSG_IPv4_DP
;
1194 SetDevicePathNodeLength (&Node
->Header
, 19);
1196 CopyMem (&Node
->LocalIpAddress
, &LocalIp
, sizeof (EFI_IPv4_ADDRESS
));
1197 CopyMem (&Node
->RemoteIpAddress
, &RemoteIp
, sizeof (EFI_IPv4_ADDRESS
));
1199 Node
->LocalPort
= LocalPort
;
1200 Node
->RemotePort
= RemotePort
;
1202 Node
->Protocol
= Protocol
;
1204 if (!UseDefaultAddress
) {
1205 Node
->StaticIpAddress
= TRUE
;
1207 Node
->StaticIpAddress
= NetLibDefaultAddressIsStatic (Controller
);
1213 Find the UNDI/SNP handle from controller and protocol GUID.
1214 For example, IP will open a MNP child to transmit/receive
1215 packets, when MNP is stopped, IP should also be stopped. IP
1216 needs to find its own private data which is related the IP's
1217 service binding instance that is install on UNDI/SNP handle.
1218 Now, the controller is either a MNP or ARP child handle. But
1219 IP opens these handle BY_DRIVER, use that info, we can get the
1222 @param Controller Then protocol handle to check
1223 @param ProtocolGuid The protocol that is related with the handle.
1225 @return The UNDI/SNP handle or NULL.
1230 NetLibGetNicHandle (
1231 IN EFI_HANDLE Controller
,
1232 IN EFI_GUID
*ProtocolGuid
1235 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenBuffer
;
1241 Status
= gBS
->OpenProtocolInformation (
1248 if (EFI_ERROR (Status
)) {
1254 for (Index
= 0; Index
< OpenCount
; Index
++) {
1255 if (OpenBuffer
[Index
].Attributes
& EFI_OPEN_PROTOCOL_BY_DRIVER
) {
1256 Handle
= OpenBuffer
[Index
].ControllerHandle
;
1261 gBS
->FreePool (OpenBuffer
);
1266 Add a Deferred Procedure Call to the end of the DPC queue.
1268 @DpcTpl The EFI_TPL that the DPC should be invoked.
1269 @DpcProcedure Pointer to the DPC's function.
1270 @DpcContext Pointer to the DPC's context. Passed to DpcProcedure
1271 when DpcProcedure is invoked.
1273 @retval EFI_SUCCESS The DPC was queued.
1274 @retval EFI_INVALID_PARAMETER DpcTpl is not a valid EFI_TPL.
1275 DpcProcedure is NULL.
1276 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
1277 add the DPC to the queue.
1284 IN EFI_DPC_PROCEDURE DpcProcedure
,
1285 IN VOID
*DpcContext OPTIONAL
1288 return mDpc
->QueueDpc (mDpc
, DpcTpl
, DpcProcedure
, DpcContext
);
1292 Add a Deferred Procedure Call to the end of the DPC queue.
1294 @retval EFI_SUCCESS One or more DPCs were invoked.
1295 @retval EFI_NOT_FOUND No DPCs were invoked.
1304 return mDpc
->DispatchDpc(mDpc
);
1309 The constructor function caches the pointer to DPC protocol.
1311 The constructor function locates DPC protocol from protocol database.
1312 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
1314 @param ImageHandle The firmware allocated handle for the EFI image.
1315 @param SystemTable A pointer to the EFI System Table.
1317 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
1323 IN EFI_HANDLE ImageHandle
,
1324 IN EFI_SYSTEM_TABLE
*SystemTable
1329 Status
= gBS
->LocateProtocol (&gEfiDpcProtocolGuid
, NULL
, (VOID
**) &mDpc
);
1330 ASSERT_EFI_ERROR (Status
);
1331 ASSERT (mDpc
!= NULL
);