]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c
OvmfPkg: simplify SecurityStubDxe.inf inclusion
[mirror_edk2.git] / EmulatorPkg / EmuSnpDxe / EmuSnpDxe.c
index 4432218b511e0500ba3773ac82c89af3341d2d46..09d16fd8b664ded35274db4c41798cbf8590c1e0 100644 (file)
@@ -24,25 +24,53 @@ Abstract:
 \r
 \r
 EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate = {\r
-  EFI_SIMPLE_NETWORK_PROTOCOL_REVISION,  \r
-  EmuSnpStart,             \r
-  EmuSnpStop,              \r
-  EmuSnpInitialize,       \r
-  EmuSnpReset,              \r
-  EmuSnpShutdown,            \r
-  EmuSnpReceiveFilters,          \r
-  EmuSnpStationAddress,          \r
-  EmuSnpStatistics,            \r
-  EmuSnpMcastIptoMac,          \r
-  EmuSnpNvdata,              \r
-  EmuSnpGetStatus,            \r
-  EmuSnpTransmit,            \r
-  EmuSnpReceive,              \r
+  EFI_SIMPLE_NETWORK_PROTOCOL_REVISION,\r
+  EmuSnpStart,\r
+  EmuSnpStop,\r
+  EmuSnpInitialize,\r
+  EmuSnpReset,\r
+  EmuSnpShutdown,\r
+  EmuSnpReceiveFilters,\r
+  EmuSnpStationAddress,\r
+  EmuSnpStatistics,\r
+  EmuSnpMcastIptoMac,\r
+  EmuSnpNvdata,\r
+  EmuSnpGetStatus,\r
+  EmuSnpTransmit,\r
+  EmuSnpReceive,\r
   NULL,                     // WaitForPacket\r
   NULL                      // Mode\r
  };\r
 \r
-\r
+EFI_SIMPLE_NETWORK_MODE gEmuSnpModeTemplate = {                 \r
+  EfiSimpleNetworkStopped,      //  State\r
+  NET_ETHER_ADDR_LEN,           //  HwAddressSize\r
+  NET_ETHER_HEADER_SIZE,        //  MediaHeaderSize\r
+  1500,                         //  MaxPacketSize\r
+  0,                            //  NvRamSize\r
+  0,                            //  NvRamAccessSize\r
+  0,                            //  ReceiveFilterMask\r
+  0,                            //  ReceiveFilterSetting\r
+  MAX_MCAST_FILTER_CNT,         //  MaxMCastFilterCount\r
+  0,                            //  MCastFilterCount\r
+  {\r
+    { { 0 } }\r
+  },                            //  MCastFilter\r
+  {\r
+    { 0 }\r
+  },                            //  CurrentAddress\r
+  {\r
+    { 0 }\r
+  },                            //  BroadcastAddress\r
+  {\r
+    { 0 }\r
+  },                            //  PermanentAddress\r
+  NET_IFTYPE_ETHERNET,          //  IfType\r
+  FALSE,                        //  MacAddressChangeable\r
+  FALSE,                        //  MultipleTxSupported\r
+  FALSE,                        //  MediaPresentSupported\r
+  TRUE                          //  MediaPresent\r
+};\r
 \r
 \r
 /**\r
@@ -94,8 +122,8 @@ EmuSnpStop (
 \r
 \r
 /**\r
-  Resets a network adapter and allocates the transmit and receive buffers \r
-  required by the network interface; optionally, also requests allocation \r
+  Resets a network adapter and allocates the transmit and receive buffers\r
+  required by the network interface; optionally, also requests allocation\r
   of additional transmit and receive buffers.\r
 \r
   @param  This              Protocol instance pointer.\r
@@ -131,8 +159,8 @@ EmuSnpInitialize (
 }\r
 \r
 /**\r
-  Resets a network adapter and re-initializes it with the parameters that were \r
-  provided in the previous call to Initialize().  \r
+  Resets a network adapter and re-initializes it with the parameters that were\r
+  provided in the previous call to Initialize().\r
 \r
   @param  This                 Protocol instance pointer.\r
   @param  ExtendedVerification Indicates that the driver may perform a more\r
@@ -159,7 +187,7 @@ EmuSnpReset (
 }\r
 \r
 /**\r
-  Resets a network adapter and leaves it in a state that is safe for \r
+  Resets a network adapter and leaves it in a state that is safe for\r
   another driver to initialize.\r
 \r
   @param  This Protocol instance pointer.\r
@@ -334,7 +362,7 @@ EmuSnpMcastIptoMac (
 \r
 \r
 /**\r
-  Performs read and write operations on the NVRAM device attached to a \r
+  Performs read and write operations on the NVRAM device attached to a\r
   network interface.\r
 \r
   @param  This         Protocol instance pointer.\r
@@ -370,7 +398,7 @@ EmuSnpNvdata (
 \r
 \r
 /**\r
-  Reads the current interrupt status and recycled transmit buffer status from \r
+  Reads the current interrupt status and recycled transmit buffer status from\r
   a network interface.\r
 \r
   @param  This            Protocol instance pointer.\r
@@ -568,8 +596,8 @@ EmuSnpDriverBindingSupported (
       }\r
     }\r
   }\r
-  \r
-  \r
+\r
+\r
   //\r
   // Open the IO Abstraction(s) needed to perform the supported test\r
   //\r
@@ -585,14 +613,6 @@ EmuSnpDriverBindingSupported (
     return Status;\r
   }\r
 \r
-  //\r
-  // Make sure GUID is for a File System handle.\r
-  //\r
-  Status = EFI_UNSUPPORTED;\r
-  if (CompareGuid (EmuIoThunk->Protocol, &gEmuSnpProtocolGuid)) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-\r
   //\r
   // Close the I/O Abstraction(s) used to perform the supported test\r
   //\r
@@ -602,8 +622,8 @@ EmuSnpDriverBindingSupported (
         This->DriverBindingHandle,\r
         ControllerHandle\r
         );\r
-        \r
-        \r
+\r
+\r
   //\r
   // Open the EFI Device Path protocol needed to perform the supported test\r
   //\r
@@ -623,6 +643,14 @@ EmuSnpDriverBindingSupported (
     return Status;\r
   }\r
 \r
+  //\r
+  // Make sure GUID is for a SNP handle.\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (CompareGuid (EmuIoThunk->Protocol, &gEmuSnpProtocolGuid)) {\r
+    Status = EFI_SUCCESS;\r
+  }\r
+\r
   //\r
   // Close protocol, don't use device path protocol in the Support() function\r
   //\r
@@ -715,6 +743,7 @@ EmuSnpDriverBindingStart (
   }\r
 \r
   CopyMem (&Private->Snp, &gEmuSnpTemplate, sizeof (EFI_SIMPLE_NETWORK_PROTOCOL));\r
+  CopyMem (&Private->Mode, &gEmuSnpModeTemplate, sizeof (EFI_SIMPLE_NETWORK_MODE));\r
 \r
   Private->Signature    = EMU_SNP_PRIVATE_DATA_SIGNATURE;\r
   Private->IoThunk      = EmuIoThunk;\r
@@ -724,7 +753,7 @@ EmuSnpDriverBindingStart (
   Private->Snp.Mode     = &Private->Mode;\r
   Private->ControllerNameTable = NULL;\r
 \r
-  \r
+\r
   Status = Private->Io->CreateMapping (Private->Io, &Private->Mode);\r
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
@@ -760,7 +789,7 @@ EmuSnpDriverBindingStart (
     EmuIoThunk->ConfigString,\r
     TRUE\r
     );\r
-    \r
+\r
   AddUnicodeString2 (\r
     "en",\r
     gEmuSnpDriverComponentName2.SupportedLanguages,\r
@@ -819,7 +848,7 @@ Done:
   restrictions for this service. DisconnectController()\r
   must follow these calling restrictions. If any other agent wishes\r
   to call Stop() it must also follow these calling restrictions.\r
-  \r
+\r
   @param  This              Protocol instance pointer.\r
   @param  ControllerHandle  Handle of device to stop driver on\r
   @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
@@ -867,8 +896,8 @@ EmuSnpDriverBindingStop (
   }\r
 \r
   ASSERT (NumberOfChildren == 1);\r
-  \r
-  \r
+\r
+\r
   //\r
   // Get our context back.\r
   //\r
@@ -944,7 +973,6 @@ InitializeEmuSnpDriver (
   //\r
   // Install the Driver Protocols\r
   //\r
-\r
   Status = EfiLibInstallDriverBindingComponentName2(\r
               ImageHandle,\r
               SystemTable,\r