]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
SourceLevelDebugPkg/SecPeiDebugAgentLib: Restore CPU interrupt state
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / Ip4Config.h
index c685fc7443cd8ddbf5234603290199781623e982..cbe8ec5fcfde864b06d1a2ef3af0a5fdf30f1355 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Header file for IP4Config driver.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+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<BR>\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -23,8 +23,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/HiiConfigAccess.h>\r
 #include <Protocol/HiiDatabase.h>\r
 #include <Protocol/HiiConfigRouting.h>\r
+#include <Protocol/ServiceBinding.h>\r
 \r
 #include <Guid/MdeModuleHii.h>\r
+#include <Guid/NicIp4ConfigNvData.h>\r
 \r
 #include <Library/DevicePathLib.h>\r
 #include <Library/DebugLib.h>\r
@@ -37,35 +39,30 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/PrintLib.h>\r
+#include <Library/DpcLib.h>\r
+#include <Library/UefiHiiServicesLib.h>\r
 \r
-#include "NicIp4Variable.h"\r
-\r
-typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE;\r
 \r
 //\r
 // Global variables\r
 //\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gIp4ConfigDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gIp4ConfigComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gIp4ConfigComponentName2;\r
+extern EFI_DRIVER_BINDING_PROTOCOL     gIp4ConfigDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL     gIp4ConfigComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL    gIp4ConfigComponentName2;\r
 \r
-extern IP4_CONFIG_INSTANCE           *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];\r
-extern EFI_IP4_CONFIG_PROTOCOL       mIp4ConfigProtocolTemplate;\r
+extern EFI_IP4_CONFIG_PROTOCOL         mIp4ConfigProtocolTemplate;\r
 \r
 #define IP4_PROTO_ICMP                 0x01\r
 #define IP4_CONFIG_INSTANCE_SIGNATURE  SIGNATURE_32 ('I', 'P', '4', 'C')\r
 \r
-typedef enum {\r
-  IP4_CONFIG_STATE_IDLE         = 0,\r
-  IP4_CONFIG_STATE_STARTED,\r
-  IP4_CONFIG_STATE_CONFIGURED\r
-} IP4_CONFIG_STATE;\r
+#define IP4_CONFIG_STATE_IDLE          0\r
+#define IP4_CONFIG_STATE_STARTED       1\r
+#define IP4_CONFIG_STATE_CONFIGURED    2\r
+\r
+#define DHCP_TAG_PARA_LIST             55\r
+#define DHCP_TAG_NETMASK               1\r
+#define DHCP_TAG_ROUTER                3\r
 \r
-typedef enum {\r
-  DHCP_TAG_PARA_LIST            = 55,\r
-  DHCP_TAG_NETMASK              = 1,\r
-  DHCP_TAG_ROUTER               = 3\r
-} DHCP_TAGS;\r
 \r
 //\r
 // Configure the DHCP to request the routers and netmask\r
@@ -78,116 +75,104 @@ typedef struct {
 } IP4_CONFIG_DHCP4_OPTION;\r
 #pragma pack()\r
 \r
+typedef struct _IP4CONFIG_CALLBACK_INFO {\r
+  BOOLEAN                          Configured;\r
+  BOOLEAN                          DhcpEnabled;\r
+  EFI_IPv4_ADDRESS                 LocalIp;\r
+  EFI_IPv4_ADDRESS                 SubnetMask;\r
+  EFI_IPv4_ADDRESS                 Gateway;\r
+} IP4_SETTING_INFO;\r
 \r
-typedef struct {\r
-  UINTN             DeviceNum;\r
-  BOOLEAN           Enabled;\r
-  EFI_IPv4_ADDRESS  LocalIp;\r
-  EFI_IPv4_ADDRESS  SubnetMask;\r
-  EFI_IPv4_ADDRESS  Gateway;\r
-} IP4_CONFIG_SESSION_DATA;\r
-\r
-typedef struct _IP4_CONFIG_FORM_ENTRY {\r
-  LIST_ENTRY                    Link;\r
-  IP4_CONFIG_INSTANCE           *Ip4ConfigInstance;\r
-  EFI_HANDLE                    Controller;\r
-  CHAR16                        MacString[95];\r
-  EFI_STRING_ID                 PortTitleToken;\r
-  EFI_STRING_ID                 PortTitleHelpToken;\r
-  IP4_CONFIG_SESSION_DATA       SessionConfigData;\r
-} IP4CONFIG_FORM_ENTRY;\r
-\r
-#define IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE  SIGNATURE_32 ('I', 'P', '4', 'C')\r
-\r
-typedef struct _IP4_FORM_CALLBACK_INFO_INSTANCE {\r
-  UINTN                            Signature;\r
-  EFI_HANDLE                       DriverHandle;\r
-  EFI_HII_CONFIG_ACCESS_PROTOCOL   ConfigAccess;\r
-  EFI_HII_DATABASE_PROTOCOL        *HiiDatabase;\r
-  EFI_HII_CONFIG_ROUTING_PROTOCOL  *ConfigRouting;\r
-  EFI_HII_HANDLE                   RegisteredHandle;\r
-  IP4CONFIG_FORM_ENTRY             *Current;\r
-} IP4_FORM_CALLBACK_INFO;\r
-\r
-#define IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK(Callback) \\r
-  CR ( \\r
-  Callback, \\r
-  IP4_FORM_CALLBACK_INFO, \\r
-  ConfigAccess, \\r
-  IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE \\r
-  )\r
-\r
-struct _IP4_CONFIG_INSTANCE {\r
-  UINT32                        Signature;\r
-  EFI_HANDLE                    Controller;\r
-  EFI_HANDLE                    Image;\r
-\r
-  EFI_IP4_CONFIG_PROTOCOL       Ip4ConfigProtocol;\r
-\r
-  IP4_FORM_CALLBACK_INFO        Ip4FormCallbackInfo;\r
+typedef struct _IP4_CONFIG_INSTANCE {\r
+  UINT32                          Signature;\r
+  EFI_HANDLE                      Controller;\r
+  EFI_HANDLE                      Image;\r
+  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
+\r
+  EFI_IP4_CONFIG_PROTOCOL         Ip4ConfigProtocol;\r
+\r
+  EFI_HII_CONFIG_ACCESS_PROTOCOL  HiiConfigAccessProtocol;\r
+  EFI_HANDLE                      ChildHandle;\r
+  EFI_DEVICE_PATH_PROTOCOL        *HiiVendorDevicePath;\r
+  EFI_HII_HANDLE                  RegisteredHandle;\r
+  IP4_SETTING_INFO                Ip4ConfigCallbackInfo;\r
 \r
   //\r
   // NicConfig's state, such as IP4_CONFIG_STATE_IDLE\r
   //\r
-  INTN                          State;\r
+  INTN                            State;\r
 \r
   //\r
   // Mnp child to keep the connection with MNP.\r
   //\r
-  EFI_MANAGED_NETWORK_PROTOCOL  *Mnp;\r
-  EFI_HANDLE                    MnpHandle;\r
+  EFI_MANAGED_NETWORK_PROTOCOL    *Mnp;\r
+  EFI_HANDLE                      MnpHandle;\r
 \r
   //\r
   // User's requests data\r
   //\r
-  EFI_EVENT                     DoneEvent;\r
-  EFI_EVENT                     ReconfigEvent;\r
-  EFI_STATUS                    Result;\r
+  EFI_EVENT                       DoneEvent;\r
+  EFI_EVENT                       ReconfigEvent;\r
+  EFI_STATUS                      Result;\r
 \r
   //\r
   // Identity of this interface and some configuration info.\r
   //\r
-  NIC_ADDR                      NicAddr;\r
-  UINT16                        NicName[IP4_NIC_NAME_LENGTH];\r
-  UINT32                        NicIndex;\r
-  NIC_IP4_CONFIG_INFO           *NicConfig;\r
+  NIC_ADDR                        NicAddr;\r
+  CHAR16                          *MacString;\r
+  NIC_IP4_CONFIG_INFO             *NicConfig;\r
 \r
   //\r
   // DHCP handles to access DHCP\r
   //\r
-  EFI_DHCP4_PROTOCOL            *Dhcp4;\r
-  EFI_HANDLE                    Dhcp4Handle;\r
-  EFI_EVENT                     Dhcp4Event;\r
-};\r
+  EFI_DHCP4_PROTOCOL              *Dhcp4;\r
+  EFI_HANDLE                      Dhcp4Handle;\r
+  EFI_EVENT                       Dhcp4Event;\r
+\r
+  //\r
+  // A dedicated timer is used to poll underlying media status\r
+  //\r
+  EFI_EVENT                       Timer;\r
+\r
+  //\r
+  // Underlying media present status. \r
+  //\r
+  BOOLEAN                         MediaPresent;\r
+\r
+  //\r
+  // A flag to indicate EfiIp4ConfigStart should not run\r
+  //\r
+  BOOLEAN                         DoNotStart;\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
 \r
-#define IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO(this) \\r
-  CR (this, IP4_CONFIG_INSTANCE, Ip4FormCallbackInfo, IP4_CONFIG_INSTANCE_SIGNATURE)\r
+#define IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS(this) \\r
+  CR (this, IP4_CONFIG_INSTANCE, HiiConfigAccessProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)\r
 \r
 \r
 /**\r
-  Set the IP configure parameters for this NIC. \r
+  Set the IP configure parameters for this NIC.\r
 \r
-  If Reconfig is TRUE, the IP driver will be informed to discard current \r
-  auto configure parameter and restart the auto configuration process. \r
+  If Reconfig is TRUE, the IP driver will be informed to discard current\r
+  auto configure parameter and restart the auto configuration process.\r
   If current there is a pending auto configuration, EFI_ALREADY_STARTED is\r
   returned. You can only change the configure setting when either\r
   the configure has finished or not started yet. If NicConfig, the\r
   NIC's configure parameter is removed from the variable.\r
 \r
   @param  Instance               The IP4 CONFIG instance.\r
-  @param  NicConfig              The new NIC IP4 configure parameter\r
+  @param  NicConfig              The new NIC IP4 configure parameter.\r
   @param  Reconfig               Inform the IP4 driver to restart the auto\r
-                                 configuration\r
-                                 \r
-  @retval EFI_SUCCESS            The configure parameter for this NIC was \r
-                                 set successfully .\r
+                                 configuration.\r
+\r
+  @retval EFI_SUCCESS            The configure parameter for this NIC was\r
+                                 set successfully.\r
   @retval EFI_INVALID_PARAMETER  This is NULL or the configure parameter is\r
                                  invalid.\r
   @retval EFI_ALREADY_STARTED    There is a pending auto configuration.\r
-  @retval EFI_NOT_FOUND          No auto configure parameter is found\r
+  @retval EFI_NOT_FOUND          No auto configure parameter is found.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -199,28 +184,18 @@ EfiNicIp4ConfigSetInfo (
   );\r
 \r
 /**\r
-  Get the configure parameter for this NIC.\r
+  Get the NIC's configure information from the IP4 configure variable.\r
+  It will remove the invalid variable.\r
 \r
-  @param  Instance               The IP4 CONFIG Instance.\r
-  @param  ConfigLen              The length of the NicConfig buffer.\r
-  @param  NicConfig              The buffer to receive the NIC's configure\r
-                                 parameter.\r
+  @param  Instance               The IP4 CONFIG instance.\r
 \r
-  @retval EFI_SUCCESS            The configure parameter for this NIC was \r
-                                 obtained successfully .\r
-  @retval EFI_INVALID_PARAMETER  This or ConfigLen is NULL.\r
-  @retval EFI_NOT_FOUND          There is no configure parameter for the NIC in\r
-                                 NVRam.\r
-  @retval EFI_BUFFER_TOO_SMALL   The ConfigLen is too small or the NicConfig is \r
-                                 NULL.\r
+  @return NULL if no configure for the NIC in the variable, or it is invalid.\r
+          Otherwise the pointer to the NIC's IP configure parameter will be returned.\r
 \r
 **/\r
-EFI_STATUS\r
-EFIAPI\r
+NIC_IP4_CONFIG_INFO *\r
 EfiNicIp4ConfigGetInfo (\r
-  IN  IP4_CONFIG_INSTANCE         *Instance,\r
-  IN OUT  UINTN                   *ConfigLen,\r
-  OUT NIC_IP4_CONFIG_INFO         *NicConfig\r
+  IN  IP4_CONFIG_INSTANCE   *Instance\r
   );\r
 \r
 /**\r
@@ -341,7 +316,7 @@ Ip4ConfigComponentNameGetDriverName (
                                 the language specified by Language for the\r
                                 driver specified by This was returned in\r
                                 DriverName.\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
                                 EFI_HANDLE.\r
   @retval EFI_INVALID_PARAMETER Language is NULL.\r
@@ -427,4 +402,132 @@ 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
+/**\r
+  A dedicated timer is used to poll underlying media status. In case of\r
+  cable swap, a new round auto configuration will be initiated. The timer \r
+  will signal the IP4 to run the auto configuration again. IP4 driver will free\r
+  old IP address related resource, such as route table and Interface, then\r
+  initiate a DHCP round by IP4Config->Start to acquire new IP, eventually\r
+  create route table for new IP address.\r
+\r
+  @param[in]  Event                  The IP4 service instance's heart beat timer.\r
+  @param[in]  Context                The IP4 service instance.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+MediaChangeDetect (\r
+  IN EFI_EVENT              Event,\r
+  IN VOID                   *Context\r
+  );\r
+\r
 #endif\r