]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Refine code.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 Jul 2010 05:07:35 +0000 (05:07 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 Jul 2010 05:07:35 +0000 (05:07 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10648 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c

index cc3f6fb97f80e9728fdf2e05677f273b2be9fb0d..2c74a80308827bb246652ec1e9ff5653177275c9 100644 (file)
@@ -15,6 +15,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Ip4Config.h"\r
 #include "NicIp4Variable.h"\r
 \r
+//\r
+// Ip4 Config Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_IP4_CONFIG_PROTOCOL     mIp4ConfigProtocolTemplate = {\r
+  EfiIp4ConfigStart,\r
+  EfiIp4ConfigStop,\r
+  EfiIp4ConfigGetData\r
+};\r
 \r
 /**\r
   Get the NIC's configure information from the IP4 configure variable.\r
@@ -651,9 +659,3 @@ Ip4ConfigCleanConfig (
   Ip4ConfigCleanDhcp4 (Instance);\r
 }\r
 \r
-EFI_IP4_CONFIG_PROTOCOL     mIp4ConfigProtocolTemplate = {\r
-  EfiIp4ConfigStart,\r
-  EfiIp4ConfigStop,\r
-  EfiIp4ConfigGetData\r
-};\r
-\r
index 87bc25c2f15c1a05410d6bd69612ba9b4d845399..eacd89389065a932d21722adeef23a49f2400935 100644 (file)
@@ -42,7 +42,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DpcLib.h>\r
 #include <Library/UefiHiiServicesLib.h>\r
 \r
-typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE;\r
 \r
 //\r
 // Global variables\r
@@ -84,7 +83,7 @@ typedef struct _IP4CONFIG_CALLBACK_INFO {
   EFI_IPv4_ADDRESS                 Gateway;\r
 } IP4_SETTING_INFO;\r
 \r
-struct _IP4_CONFIG_INSTANCE {\r
+typedef struct _IP4_CONFIG_INSTANCE {\r
   UINT32                          Signature;\r
   EFI_HANDLE                      Controller;\r
   EFI_HANDLE                      Image;\r
@@ -129,7 +128,7 @@ struct _IP4_CONFIG_INSTANCE {
   EFI_DHCP4_PROTOCOL              *Dhcp4;\r
   EFI_HANDLE                      Dhcp4Handle;\r
   EFI_EVENT                       Dhcp4Event;\r
-};\r
+} IP4_CONFIG_INSTANCE;\r
 \r
 #define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \\r
   CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)\r
@@ -388,4 +387,113 @@ Ip4ConfigDriverBindingStop (
   IN EFI_HANDLE                   *ChildHandleBuffer\r
   );\r
 \r
+/**\r
+  Starts running the configuration policy for the EFI IPv4 Protocol driver.\r
+\r
+  The Start() function is called to determine and to begin the platform\r
+  configuration policy by the EFI IPv4 Protocol driver. This determination may\r
+  be as simple as returning EFI_UNSUPPORTED if there is no EFI IPv4 Protocol\r
+  driver configuration policy. It may be as involved as loading some defaults\r
+  from nonvolatile storage, downloading dynamic data from a DHCP server, and\r
+  checking permissions with a site policy server.\r
+  Starting the configuration policy is just the beginning. It may finish almost\r
+  instantly or it may take several minutes before it fails to retrieve configuration\r
+  information from one or more servers. Once the policy is started, drivers\r
+  should use the DoneEvent parameter to determine when the configuration policy\r
+  has completed. EFI_IP4_CONFIG_PROTOCOL.GetData() must then be called to\r
+  determine if the configuration succeeded or failed.\r
+  Until the configuration completes successfully, EFI IPv4 Protocol driver instances\r
+  that are attempting to use default configurations must return EFI_NO_MAPPING.\r
+  Once the configuration is complete, the EFI IPv4 Configuration Protocol driver\r
+  signals DoneEvent. The configuration may need to be updated in the future,\r
+  however; in this case, the EFI IPv4 Configuration Protocol driver must signal\r
+  ReconfigEvent, and all EFI IPv4 Protocol driver instances that are using default\r
+  configurations must return EFI_NO_MAPPING until the configuration policy has\r
+  been rerun.\r
+\r
+  @param  This                   Pointer to the EFI_IP4_CONFIG_PROTOCOL instance.\r
+  @param  DoneEvent              Event that will be signaled when the EFI IPv4\r
+                                 Protocol driver configuration policy completes\r
+                                 execution. This event must be of type EVT_NOTIFY_SIGNAL.\r
+  @param  ReconfigEvent          Event that will be signaled when the EFI IPv4\r
+                                 Protocol driver configuration needs to be updated.\r
+                                 This event must be of type EVT_NOTIFY_SIGNAL.\r
+\r
+  @retval EFI_SUCCESS            The configuration policy for the EFI IPv4 Protocol\r
+                                 driver is now running.\r
+  @retval EFI_INVALID_PARAMETER  One or more of the following parameters is NULL:\r
+                                  This\r
+                                  DoneEvent\r
+                                  ReconfigEvent\r
+  @retval EFI_OUT_OF_RESOURCES   Required system resources could not be allocated.\r
+  @retval EFI_ALREADY_STARTED    The configuration policy for the EFI IPv4 Protocol\r
+                                 driver was already started.\r
+  @retval EFI_DEVICE_ERROR       An unexpected system error or network error occurred.\r
+  @retval EFI_UNSUPPORTED        This interface does not support the EFI IPv4 Protocol\r
+                                 driver configuration.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp4ConfigStart (\r
+  IN EFI_IP4_CONFIG_PROTOCOL  *This,\r
+  IN EFI_EVENT                DoneEvent,\r
+  IN EFI_EVENT                ReconfigEvent\r
+  );\r
+\r
+/**\r
+  Stops running the configuration policy for the EFI IPv4 Protocol driver.\r
+\r
+  The Stop() function stops the configuration policy for the EFI IPv4 Protocol driver.\r
+  All configuration data will be lost after calling Stop().\r
+\r
+  @param  This                   Pointer to the EFI_IP4_CONFIG_PROTOCOL instance.\r
+\r
+  @retval EFI_SUCCESS            The configuration policy for the EFI IPv4 Protocol\r
+                                 driver has been stopped.\r
+  @retval EFI_INVALID_PARAMETER  This is NULL.\r
+  @retval EFI_NOT_STARTED        The configuration policy for the EFI IPv4 Protocol\r
+                                 driver was not started.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp4ConfigStop (\r
+  IN EFI_IP4_CONFIG_PROTOCOL  *This\r
+  );\r
+\r
+/**\r
+  Returns the default configuration data (if any) for the EFI IPv4 Protocol driver.\r
+\r
+  The GetData() function returns the current configuration data for the EFI IPv4\r
+  Protocol driver after the configuration policy has completed.\r
+\r
+  @param  This                   Pointer to the EFI_IP4_CONFIG_PROTOCOL instance.\r
+  @param  ConfigDataSize         On input, the size of the ConfigData buffer.\r
+                                 On output, the count of bytes that were written\r
+                                 into the ConfigData buffer.\r
+  @param  ConfigData             Pointer to the EFI IPv4 Configuration Protocol\r
+                                 driver configuration data structure.\r
+                                 Type EFI_IP4_IPCONFIG_DATA is defined in\r
+                                 "Related Definitions" below.\r
+\r
+  @retval EFI_SUCCESS            The EFI IPv4 Protocol driver configuration has been returned.\r
+  @retval EFI_INVALID_PARAMETER  This is NULL.\r
+  @retval EFI_NOT_STARTED        The configuration policy for the EFI IPv4 Protocol\r
+                                 driver is not running.\r
+  @retval EFI_NOT_READY          EFI IPv4 Protocol driver configuration is still running.\r
+  @retval EFI_ABORTED            EFI IPv4 Protocol driver configuration could not complete.\r
+                                 Currently not implemented.\r
+  @retval EFI_BUFFER_TOO_SMALL   *ConfigDataSize is smaller than the configuration\r
+                                 data buffer or ConfigData is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp4ConfigGetData (\r
+  IN  EFI_IP4_CONFIG_PROTOCOL *This,\r
+  IN  OUT  UINTN              *ConfigDataSize,\r
+  OUT EFI_IP4_IPCONFIG_DATA   *ConfigData           OPTIONAL\r
+  );\r
+\r
 #endif\r
index dfa4cdcd8f9911c5adfd1207d27a4d1c7b47319d..c620abd70b4141f19bbb506a869fba74b15cfb93 100644 (file)
@@ -26,6 +26,60 @@ EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding = {
   NULL\r
 };\r
 \r
+//\r
+// The intance of template of IP4 Config private data\r
+//\r
+IP4_CONFIG_INSTANCE        mIp4ConfigTemplate = {\r
+  IP4_CONFIG_INSTANCE_SIGNATURE,\r
+  NULL,\r
+  NULL,\r
+  (EFI_DEVICE_PATH_PROTOCOL *) NULL,\r
+  {\r
+    NULL,\r
+    NULL,\r
+    NULL\r
+  },\r
+  {\r
+    NULL,\r
+    NULL,\r
+    NULL\r
+  },\r
+  NULL,\r
+  (EFI_DEVICE_PATH_PROTOCOL *) NULL,\r
+  NULL,\r
+  {\r
+    FALSE,\r
+    FALSE,\r
+    {\r
+      0\r
+    },\r
+    {\r
+      0\r
+    },\r
+    {\r
+      0\r
+    }\r
+  },\r
+  0,\r
+  (EFI_MANAGED_NETWORK_PROTOCOL *) NULL,\r
+  NULL,\r
+  NULL,\r
+  NULL,\r
+  EFI_NOT_READY,\r
+  {\r
+    0,\r
+    0,\r
+    {\r
+      0\r
+    }\r
+  },\r
+  (CHAR16 *) NULL,\r
+  (NIC_IP4_CONFIG_INFO *) NULL,\r
+  (EFI_DHCP4_PROTOCOL *) NULL,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
 /**\r
   The entry point for IP4 config driver which install the driver\r
   binding and component name protocol on its image.\r
@@ -180,14 +234,13 @@ Ip4ConfigDriverBindingStart (
   //\r
   // Allocate an instance then initialize it\r
   //\r
-  Instance = AllocateZeroPool (sizeof (IP4_CONFIG_INSTANCE));\r
+  Instance = AllocateCopyPool (sizeof (IP4_CONFIG_INSTANCE), &mIp4ConfigTemplate);\r
 \r
   if (Instance == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto ON_ERROR;\r
   }\r
 \r
-  Instance->Signature         = IP4_CONFIG_INSTANCE_SIGNATURE;\r
   Instance->Controller        = ControllerHandle;\r
   Instance->Image             = This->DriverBindingHandle;\r
   Instance->ParentDevicePath  = ParentDevicePath;\r
@@ -198,15 +251,6 @@ Ip4ConfigDriverBindingStart (
   Instance->Mnp               = Mnp;\r
   Instance->MnpHandle         = MnpHandle;\r
 \r
-  Instance->DoneEvent         = NULL;\r
-  Instance->ReconfigEvent     = NULL;\r
-  Instance->Result            = EFI_NOT_READY;\r
-  Instance->NicConfig         = NULL;\r
-\r
-  Instance->Dhcp4             = NULL;\r
-  Instance->Dhcp4Handle       = NULL;\r
-  Instance->Dhcp4Event        = NULL;\r
-\r
   Status = Mnp->GetModeData (Mnp, NULL, &SnpMode);\r
 \r
   if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {\r
index fa78678adea2845cf856d08e61e746a497f2b579..ca03a80239c44348ae6b41e00a55633d0eda320f 100644 (file)
@@ -37,7 +37,7 @@ GetSubnetMaskPrefixLength (
   //\r
   // The SubnetMask is in network byte order.\r
   //\r
-  ReverseMask = (SubnetMask->Addr[0] << 24) | (SubnetMask->Addr[1] << 16) | (SubnetMask->Addr[2] << 8) | (SubnetMask->Addr[3]);\r
+  ReverseMask = SwapBytes32 (*(UINT32 *)&SubnetMask[0]);\r
 \r
   //\r
   // Reverse it.\r