/** @file\r
-\r
-Copyright (c) 2005 - 2007, Intel Corporation\r
+ Network library.\r
+ \r
+Copyright (c) 2005 - 2007, Intel Corporation.<BR>\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
- NetLib.c\r
-\r
-Abstract:\r
-\r
-\r
-\r
**/\r
\r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
\r
#include <Protocol/ServiceBinding.h>\r
#include <Protocol/SimpleNetwork.h>\r
-#include <Protocol/LoadedImage.h>\r
#include <Protocol/NicIp4Config.h>\r
#include <Protocol/ComponentName.h>\r
#include <Protocol/ComponentName2.h>\r
-#include <Protocol/Ip4.h>\r
#include <Protocol/Dpc.h>\r
\r
#include <Library/NetLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/DevicePathLib.h>\r
\r
return the invalid length 33, which is IP4_MASK_NUM.\r
NetMask is in the host byte order.\r
\r
- @param NetMask The netmask to get the length from\r
-\r
- @return The length of the netmask, IP4_MASK_NUM if the mask isn't\r
- @return supported.\r
+ @param[in] NetMask The netmask to get the length from.\r
\r
+ @return The length of the netmask, IP4_MASK_NUM if the mask isn't.\r
+ \r
**/\r
INTN\r
EFIAPI\r
Return the class of the address, such as class a, b, c.\r
Addr is in host byte order.\r
\r
- @param Addr The address to get the class from\r
+ @param[in] Addr The address to get the class from.\r
\r
- @return IP address class, such as IP4_ADDR_CLASSA\r
+ @return IP address class, such as IP4_ADDR_CLASSA.\r
\r
**/\r
INTN\r
the netmask. If NetMask is zero, use the IP address's class to\r
get the default mask.\r
\r
- @param Ip The IP to check againist\r
- @param NetMask The mask of the IP\r
+ @param[in] Ip The IP to check against.\r
+ @param[in] NetMask The mask of the IP.\r
\r
- @return TRUE if IP is a valid unicast address on the network, otherwise FALSE\r
+ @return TRUE if IP is a valid unicast address on the network, otherwise FALSE.\r
\r
**/\r
BOOLEAN\r
/**\r
Initialize a random seed using current time.\r
\r
- None\r
-\r
@return The random seed initialized with current time.\r
\r
**/\r
Extract a UINT32 from a byte stream, then convert it to host\r
byte order. Use this function to avoid alignment error.\r
\r
- @param Buf The buffer to extract the UINT32.\r
+ @param[in] Buf The buffer to extract the UINT32.\r
\r
@return The UINT32 extracted.\r
\r
Put a UINT32 to the byte stream. Convert it from host byte order\r
to network byte order before putting.\r
\r
- @param Buf The buffer to put the UINT32\r
- @param Data The data to put\r
-\r
- @return None\r
-\r
+ @param[in, out] Buf The buffer to put the UINT32.\r
+ @param[in] Data The data to put.\r
+ \r
**/\r
VOID\r
EFIAPI\r
NetPutUint32 (\r
- IN UINT8 *Buf,\r
- IN UINT32 Data\r
+ IN OUT UINT8 *Buf,\r
+ IN UINT32 Data\r
)\r
{\r
Data = HTONL (Data);\r
\r
\r
/**\r
- Remove the first entry on the list\r
+ Remove the first entry on the list.\r
\r
- @param Head The list header\r
+ @param[in, out] Head The list header.\r
\r
@return The entry that is removed from the list, NULL if the list is empty.\r
\r
LIST_ENTRY *\r
EFIAPI\r
NetListRemoveHead (\r
- LIST_ENTRY *Head\r
+ IN OUT LIST_ENTRY *Head\r
)\r
{\r
LIST_ENTRY *First;\r
\r
\r
/**\r
- Remove the last entry on the list\r
+ Remove the last entry on the list.\r
\r
- @param Head The list head\r
+ @param[in, out] Head The list head.\r
\r
@return The entry that is removed from the list, NULL if the list is empty.\r
\r
LIST_ENTRY *\r
EFIAPI\r
NetListRemoveTail (\r
- LIST_ENTRY *Head\r
+ IN OUT LIST_ENTRY *Head\r
)\r
{\r
LIST_ENTRY *Last;\r
\r
\r
/**\r
- Insert the NewEntry after the PrevEntry\r
-\r
- @param PrevEntry The previous entry to insert after\r
- @param NewEntry The new entry to insert\r
+ Insert the NewEntry after the PrevEntry.\r
\r
- @return None\r
+ @param[in, out] PrevEntry The previous entry to insert after.\r
+ @param[in, out] NewEntry The new entry to insert.\r
\r
**/\r
VOID\r
EFIAPI\r
NetListInsertAfter (\r
- IN LIST_ENTRY *PrevEntry,\r
- IN LIST_ENTRY *NewEntry\r
+ IN OUT LIST_ENTRY *PrevEntry,\r
+ IN OUT LIST_ENTRY *NewEntry\r
)\r
{\r
NewEntry->BackLink = PrevEntry;\r
\r
\r
/**\r
- Insert the NewEntry before the PostEntry\r
-\r
- @param PostEntry The entry to insert before\r
- @param NewEntry The new entry to insert\r
+ Insert the NewEntry before the PostEntry.\r
\r
- @return None\r
+ @param[in, out] PostEntry The entry to insert before.\r
+ @param[in, out] NewEntry The new entry to insert.\r
\r
**/\r
VOID\r
EFIAPI\r
NetListInsertBefore (\r
- IN LIST_ENTRY *PostEntry,\r
- IN LIST_ENTRY *NewEntry\r
+ IN OUT LIST_ENTRY *PostEntry,\r
+ IN OUT LIST_ENTRY *NewEntry\r
)\r
{\r
NewEntry->ForwardLink = PostEntry;\r
/**\r
Initialize the netmap. Netmap is a reposity to keep the <Key, Value> pairs.\r
\r
- @param Map The netmap to initialize\r
-\r
- @return None\r
+ @param[in, out] Map The netmap to initialize.\r
\r
**/\r
VOID\r
EFIAPI\r
NetMapInit (\r
- IN NET_MAP *Map\r
+ IN OUT NET_MAP *Map\r
)\r
{\r
ASSERT (Map != NULL);\r
/**\r
To clean up the netmap, that is, release allocated memories.\r
\r
- @param Map The netmap to clean up.\r
-\r
- @return None\r
+ @param[in, out] Map The netmap to clean up.\r
\r
**/\r
VOID\r
EFIAPI\r
NetMapClean (\r
- IN NET_MAP *Map\r
+ IN OUT NET_MAP *Map\r
)\r
{\r
NET_MAP_ITEM *Item;\r
\r
\r
/**\r
- Test whether the netmap is empty\r
+ Test whether the netmap is empty.\r
\r
- @param Map The net map to test\r
+ @param[in] Map The net map to test.\r
\r
@return TRUE if the netmap is empty, otherwise FALSE.\r
\r
/**\r
Return the number of the <Key, Value> pairs in the netmap.\r
\r
- @param Map The netmap to get the entry number\r
+ @param[in] Map The netmap to get the entry number.\r
\r
@return The entry number in the netmap.\r
\r
\r
\r
/**\r
- Allocate an item for the netmap. It will try to allocate\r
+ Allocate an item for the netmap. It will try to allocate.\r
a batch of items and return one.\r
\r
- @param Map The netmap to allocate item for\r
+ @param[in, out] Map The netmap to allocate item for.\r
\r
- @return The allocated item or NULL\r
+ @return The allocated item. If NULL, the\r
+ allocation failed due to resource limit.\r
\r
**/\r
NET_MAP_ITEM *\r
NetMapAllocItem (\r
- IN NET_MAP *Map\r
+ IN OUT NET_MAP *Map\r
)\r
{\r
NET_MAP_ITEM *Item;\r
/**\r
Allocate an item to save the <Key, Value> pair to the head of the netmap.\r
\r
- @param Map The netmap to insert into\r
- @param Key The user's key\r
- @param Value The user's value for the key\r
+ @param[in, out] Map The netmap to insert into.\r
+ @param[in] Key The user's key.\r
+ @param[in] Value The user's value for the key.\r
\r
- @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the item\r
- @retval EFI_SUCCESS The item is inserted to the head\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the item.\r
+ @retval EFI_SUCCESS The item is inserted to the head.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
NetMapInsertHead (\r
- IN NET_MAP *Map,\r
+ IN OUT NET_MAP *Map,\r
IN VOID *Key,\r
IN VOID *Value OPTIONAL\r
)\r
/**\r
Allocate an item to save the <Key, Value> pair to the tail of the netmap.\r
\r
- @param Map The netmap to insert into\r
- @param Key The user's key\r
- @param Value The user's value for the key\r
+ @param[in, out] Map The netmap to insert into.\r
+ @param[in] Key The user's key.\r
+ @param[in] Value The user's value for the key.\r
\r
- @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the item\r
- @retval EFI_SUCCESS The item is inserted to the tail\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the item.\r
+ @retval EFI_SUCCESS The item is inserted to the tail.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
NetMapInsertTail (\r
- IN NET_MAP *Map,\r
+ IN OUT NET_MAP *Map,\r
IN VOID *Key,\r
IN VOID *Value OPTIONAL\r
)\r
\r
\r
/**\r
- Check whther the item is in the Map\r
+ Check whther the item is in the Map.\r
\r
- @param Map The netmap to search within\r
- @param Item The item to search\r
+ @param[in] Map The netmap to search within.\r
+ @param[in] Item The item to search.\r
\r
@return TRUE if the item is in the netmap, otherwise FALSE.\r
\r
\r
\r
/**\r
- Find the key in the netmap\r
+ Find the key in the netmap.\r
\r
- @param Map The netmap to search within\r
- @param Key The key to search\r
+ @param[in] Map The netmap to search within.\r
+ @param[in] Key The key to search.\r
\r
@return The point to the item contains the Key, or NULL if Key isn't in the map.\r
\r
\r
\r
/**\r
- Remove the item from the netmap\r
+ Remove the item from the netmap.\r
\r
- @param Map The netmap to remove the item from\r
- @param Item The item to remove\r
- @param Value The variable to receive the value if not NULL\r
+ @param[in, out] Map The netmap to remove the item from.\r
+ @param[in, out] Item The item to remove.\r
+ @param[out] Value The variable to receive the value if not NULL.\r
\r
- @return The key of the removed item.\r
+ @return The key of the removed item.\r
\r
**/\r
VOID *\r
EFIAPI\r
NetMapRemoveItem (\r
- IN NET_MAP *Map,\r
- IN NET_MAP_ITEM *Item,\r
- OUT VOID **Value OPTIONAL\r
+ IN OUT NET_MAP *Map,\r
+ IN OUT NET_MAP_ITEM *Item,\r
+ OUT VOID **Value OPTIONAL\r
)\r
{\r
ASSERT ((Map != NULL) && (Item != NULL));\r
\r
\r
/**\r
- Remove the first entry on the netmap\r
+ Remove the first entry on the netmap.\r
\r
- @param Map The netmap to remove the head from\r
- @param Value The variable to receive the value if not NULL\r
+ @param[in, out] Map The netmap to remove the head from.\r
+ @param[out] Value The variable to receive the value if not NULL.\r
\r
- @return The key of the item removed\r
+ @return The key of the item removed.\r
\r
**/\r
VOID *\r
EFIAPI\r
NetMapRemoveHead (\r
- IN NET_MAP *Map,\r
+ IN OUT NET_MAP *Map,\r
OUT VOID **Value OPTIONAL\r
)\r
{\r
\r
\r
/**\r
- Remove the last entry on the netmap\r
+ Remove the last entry on the netmap.\r
\r
- @param Map The netmap to remove the tail from\r
- @param Value The variable to receive the value if not NULL\r
+ @param[in, out] Map The netmap to remove the tail from.\r
+ @param[out] Value The variable to receive the value if not NULL.\r
\r
- @return The key of the item removed\r
+ @return The key of the item removed.\r
\r
**/\r
VOID *\r
EFIAPI\r
NetMapRemoveTail (\r
- IN NET_MAP *Map,\r
+ IN OUT NET_MAP *Map,\r
OUT VOID **Value OPTIONAL\r
)\r
{\r
from the loop. It returns the CallBack's last return value. This\r
function is delete safe for the current item.\r
\r
- @param Map The Map to iterate through\r
- @param CallBack The callback function to call for each item.\r
- @param Arg The opaque parameter to the callback\r
+ @param[in] Map The Map to iterate through.\r
+ @param[in] CallBack The callback function to call for each item.\r
+ @param[in] Arg The opaque parameter to the callback.\r
\r
- @return It returns the CallBack's last return value.\r
+ @retval EFI_SUCCESS There is no item in the netmap or CallBack for each item\r
+ return EFI_SUCCESS.\r
+ @retval Others It returns the CallBack's last return value.\r
\r
**/\r
EFI_STATUS\r
/**\r
This is the default unload handle for all the network drivers.\r
\r
- @param ImageHandle The drivers' driver image.\r
+ @param[in] ImageHandle The drivers' driver image.\r
\r
@retval EFI_SUCCESS The image is unloaded.\r
@retval Others Failed to unload the image.\r
/**\r
Create a child of the service that is identified by ServiceBindingGuid.\r
\r
- @param Controller The controller which has the service installed.\r
- @param Image The image handle used to open service.\r
- @param ServiceBindingGuid The service's Guid.\r
- @param ChildHandle The handle to receive the create child\r
+ @param[in] Controller The controller which has the service installed.\r
+ @param[in] Image The image handle used to open service.\r
+ @param[in] ServiceBindingGuid The service's Guid.\r
+ @param[in, out] ChildHandle The handle to receive the create child\r
\r
@retval EFI_SUCCESS The child is successfully created.\r
@retval Others Failed to create the child.\r
IN EFI_HANDLE Controller,\r
IN EFI_HANDLE Image,\r
IN EFI_GUID *ServiceBindingGuid,\r
- OUT EFI_HANDLE *ChildHandle\r
+ IN OUT EFI_HANDLE *ChildHandle\r
)\r
{\r
EFI_STATUS Status;\r
/**\r
Destory a child of the service that is identified by ServiceBindingGuid.\r
\r
- @param Controller The controller which has the service installed.\r
- @param Image The image handle used to open service.\r
- @param ServiceBindingGuid The service's Guid.\r
- @param ChildHandle The child to destory\r
+ @param[in] Controller The controller which has the service installed.\r
+ @param[in] Image The image handle used to open service.\r
+ @param[in] ServiceBindingGuid The service's Guid.\r
+ @param[in] ChildHandle The child to destory\r
\r
@retval EFI_SUCCESS The child is successfully destoried.\r
@retval Others Failed to destory the child.\r
SnpHandle to a unicode string. Callers are responsible for freeing the\r
string storage.\r
\r
- @param SnpHandle The handle where the simple network protocol is\r
- installed on.\r
- @param ImageHandle The image handle used to act as the agent handle to\r
- get the simple network protocol.\r
- @param MacString The pointer to store the address of the string\r
- representation of the mac address.\r
-\r
+ @param[in] SnpHandle The handle where the simple network protocol is\r
+ installed on.\r
+ @param[in] ImageHandle The image handle used to act as the agent handle to\r
+ get the simple network protocol.\r
+ @param[out] MacString The pointer to store the address of the string\r
+ representation of the mac address.\r
+ \r
+ @retval EFI_SUCCESS Convert the mac address a unicode string successfully.\r
@retval EFI_OUT_OF_RESOURCES There are not enough memory resource.\r
- @retval other Failed to open the simple network protocol.\r
+ @retval Others Failed to open the simple network protocol.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
NetLibGetMacString (\r
- IN EFI_HANDLE SnpHandle,\r
- IN EFI_HANDLE ImageHandle,\r
- IN OUT CHAR16 **MacString\r
+ IN EFI_HANDLE SnpHandle,\r
+ IN EFI_HANDLE ImageHandle,\r
+ OUT CHAR16 **MacString\r
)\r
{\r
EFI_STATUS Status;\r
Check the default address used by the IPv4 driver is static or dynamic (acquired\r
from DHCP).\r
\r
- @param Controller The controller handle which has the NIC Ip4 Config Protocol\r
- relative with the default address to judge.\r
+ @param[in] Controller The controller handle which has the NIC Ip4 Config Protocol\r
+ relative with the default address to judge.\r
\r
@retval TRUE If the default address is static.\r
@retval FALSE If the default address is acquired from DHCP.\r
/**\r
Create an IPv4 device path node.\r
\r
- @param Node Pointer to the IPv4 device path node.\r
- @param Controller The handle where the NIC IP4 config protocol resides.\r
- @param LocalIp The local IPv4 address.\r
- @param LocalPort The local port.\r
- @param RemoteIp The remote IPv4 address.\r
- @param RemotePort The remote port.\r
- @param Protocol The protocol type in the IP header.\r
- @param UseDefaultAddress Whether this instance is using default address or not.\r
+ @param[in, out] Node Pointer to the IPv4 device path node.\r
+ @param[in] Controller The handle where the NIC IP4 config protocol resides.\r
+ @param[in] LocalIp The local IPv4 address.\r
+ @param[in] LocalPort The local port.\r
+ @param[in] RemoteIp The remote IPv4 address.\r
+ @param[in] RemotePort The remote port.\r
+ @param[in] Protocol The protocol type in the IP header.\r
+ @param[in] UseDefaultAddress Whether this instance is using default address or not.\r
\r
- @retval None\r
**/\r
VOID\r
EFIAPI\r
IP opens these handle BY_DRIVER, use that info, we can get the\r
UNDI/SNP handle.\r
\r
- @param Controller Then protocol handle to check\r
- @param ProtocolGuid The protocol that is related with the handle.\r
+ @param[in] Controller Then protocol handle to check.\r
+ @param[in] ProtocolGuid The protocol that is related with the handle.\r
\r
- @return The UNDI/SNP handle or NULL.\r
+ @return The UNDI/SNP handle or NULL for errors.\r
\r
**/\r
EFI_HANDLE\r
/**\r
Add a Deferred Procedure Call to the end of the DPC queue.\r
\r
- @DpcTpl The EFI_TPL that the DPC should be invoked.\r
- @DpcProcedure Pointer to the DPC's function.\r
- @DpcContext Pointer to the DPC's context. Passed to DpcProcedure\r
- when DpcProcedure is invoked.\r
+ @param[in] DpcTpl The EFI_TPL that the DPC should be invoked.\r
+ @param[in] DpcProcedure Pointer to the DPC's function.\r
+ @param[in] DpcContext Pointer to the DPC's context. Passed to DpcProcedure\r
+ when DpcProcedure is invoked.\r
\r
@retval EFI_SUCCESS The DPC was queued.\r
- @retval EFI_INVALID_PARAMETER DpcTpl is not a valid EFI_TPL.\r
- DpcProcedure is NULL.\r
+ @retval EFI_INVALID_PARAMETER DpcTpl is not a valid EFI_TPL, or DpcProcedure\r
+ is NULL.\r
@retval EFI_OUT_OF_RESOURCES There are not enough resources available to\r
add the DPC to the queue.\r
\r
}\r
\r
/**\r
- Add a Deferred Procedure Call to the end of the DPC queue.\r
+ Dispatch the queue of DPCs. ALL DPCs that have been queued with a DpcTpl\r
+ value greater than or equal to the current TPL are invoked in the order that\r
+ they were queued. DPCs with higher DpcTpl values are invoked before DPCs with\r
+ lower DpcTpl values.\r
\r
@retval EFI_SUCCESS One or more DPCs were invoked.\r
@retval EFI_NOT_FOUND No DPCs were invoked.\r
return mDpc->DispatchDpc(mDpc);\r
}\r
\r
-\r
/**\r
The constructor function caches the pointer to DPC protocol.\r
\r
The constructor function locates DPC protocol from protocol database.\r
It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
\r
- @param ImageHandle The firmware allocated handle for the EFI image.\r
- @param SystemTable A pointer to the EFI System Table.\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
\r
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
\r