]> git.proxmox.com Git - mirror_edk2.git/commitdiff
InOsEmuPkg: Add the EFI parts of the Simple Network Protocol
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 9 Jun 2011 19:31:56 +0000 (19:31 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 9 Jun 2011 19:31:56 +0000 (19:31 +0000)
This only adds the EFI parts and not the OS specific implementation. Since the EFI parts no longer use system include files this is safe to do. Also fix two minor typos.

Signed-off-by:andrewfish

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11781 6f19259b-4bc3-4df7-8a09-765794883524

InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c
InOsEmuPkg/EmuSnpDxe/ComponentName.c [new file with mode: 0644]
InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.c [new file with mode: 0644]
InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.h [new file with mode: 0644]
InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf [new file with mode: 0644]
InOsEmuPkg/InOsEmuPkg.dec
InOsEmuPkg/Include/Protocol/EmuSnp.h [new file with mode: 0644]
InOsEmuPkg/Unix/UnixX64.dsc
InOsEmuPkg/Unix/UnixX64.fdf

index e8917326f203a4b32dd9f861a579b2ecc7c6c74c..b679d8f72aef4483ddfb2a5ec35b5a2c9c6109f0 100644 (file)
@@ -420,7 +420,7 @@ EmuBlockIoDriverBindingSupported (
   )\r
 {\r
   EFI_STATUS              Status;\r
-  EMU_IO_THUNK_PROTOCOL  *EmuIoThunk;\r
+  EMU_IO_THUNK_PROTOCOL   *EmuIoThunk;\r
 \r
   //\r
   // Open the IO Abstraction(s) needed to perform the supported test\r
@@ -520,9 +520,7 @@ EmuBlockIoDriverBindingStart (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  //\r
-  // Set DiskType\r
-  //\r
+  \r
   if (!CompareGuid (EmuIoThunk->Protocol, &gEmuBlockIoProtocolGuid)) {\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
diff --git a/InOsEmuPkg/EmuSnpDxe/ComponentName.c b/InOsEmuPkg/EmuSnpDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..a7c5124
--- /dev/null
@@ -0,0 +1,318 @@
+/** @file\r
+\r
+ Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
+\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\r
+    http://opensource.org/licenses/bsd-license.php\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
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+-**/\r
+\r
+#include "EmuSnpDxe.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gEmuSnpDriverComponentName = {\r
+  EmuSnpDriverComponentNameGetDriverName,\r
+  EmuSnpDriverComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuSnpDriverComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuSnpDriverComponentNameGetControllerName,\r
+  "en"\r
+};\r
+\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuSnpDriverNameTable[] = {\r
+  {\r
+    "eng;en",\r
+    L"Emu SNP Driver"\r
+  },\r
+  {\r
+    NULL,\r
+    NULL\r
+  }\r
+};\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+{\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           mEmuSnpDriverNameTable,\r
+           DriverName,\r
+           (BOOLEAN)(This == &gEmuSnpDriverComponentName)\r
+           );\r
+}\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.c b/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.c
new file mode 100644 (file)
index 0000000..a83fde8
--- /dev/null
@@ -0,0 +1,957 @@
+/** @file\r
+\r
+ Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
+\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\r
+    http://opensource.org/licenses/bsd-license.php\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
+  EmuSnp.c\r
+\r
+Abstract:\r
+\r
+-**/\r
+\r
+#include "EmuSnpDxe.h"\r
+\r
+\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
+  NULL,                     // WaitForPacket\r
+  NULL                      // Mode\r
+ };\r
+\r
+\r
+\r
+\r
+/**\r
+  Changes the state of a network interface from "stopped" to "started".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStart(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Start (Private->Io);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Changes the state of a network interface from "started" to "stopped".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStop (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Stop (Private->Io);\r
+  return Status;\r
+}\r
+\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
+  of additional transmit and receive buffers.\r
+\r
+  @param  This              Protocol instance pointer.\r
+  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpInitialize (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN UINTN                          ExtraRxBufferSize OPTIONAL,\r
+  IN UINTN                          ExtraTxBufferSize OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Initialize (Private->Io, ExtraRxBufferSize, ExtraTxBufferSize);\r
+  return Status;\r
+}\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
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  ExtendedVerification Indicates that the driver may perform a more\r
+                               exhaustive verification operation of the device\r
+                               during reset.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReset (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        ExtendedVerification\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Reset (Private->Io, ExtendedVerification);\r
+  return Status;\r
+}\r
+\r
+/**\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
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpShutdown (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Shutdown (Private->Io);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Manages the multicast receive filters of a network interface.\r
+\r
+  @param  This               Protocol instance pointer.\r
+  @param  EnableBits         A bit mask of receive filters to enable on the network interface.\r
+  @param  DisableBits        A bit mask of receive filters to disable on the network interface.\r
+  @param  ResetMcastFilter   Set to TRUE to reset the contents of the multicast receive\r
+                             filters on the network interface to their default values.\r
+  @param  McastFilterCount   Number of multicast HW MAC addresses in the new\r
+                             MCastFilter list. This value must be less than or equal to\r
+                             the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r
+                             field is optional if ResetMCastFilter is TRUE.\r
+  @param  McastFilter        A pointer to a list of new multicast receive filter HW MAC\r
+                             addresses. This list will replace any existing multicast\r
+                             HW MAC address list. This field is optional if\r
+                             ResetMCastFilter is TRUE.\r
+\r
+  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceiveFilters (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN UINT32                         EnableBits,\r
+  IN UINT32                         DisableBits,\r
+  IN BOOLEAN                        ResetMcastFilter,\r
+  IN UINTN                          McastFilterCount OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                *McastFilter OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->ReceiveFilters (\r
+                          Private->Io,\r
+                          EnableBits,\r
+                          DisableBits,\r
+                          ResetMcastFilter,\r
+                          McastFilterCount,\r
+                          McastFilter\r
+                          );\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Modifies or resets the current station address, if supported.\r
+\r
+  @param  This         Protocol instance pointer.\r
+  @param  Reset        Flag used to reset the station address to the network interfaces\r
+                       permanent address.\r
+  @param  NewMacAddr   New station address to be used for the network interface.\r
+\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStationAddress (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        Reset,\r
+  IN EFI_MAC_ADDRESS                *NewMacAddr OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->StationAddress (Private->Io, Reset, NewMacAddr);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Resets or collects the statistics on a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
+  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
+                          output the size, in bytes, of the resulting table of\r
+                          statistics.\r
+  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+                          contains the statistics.\r
+\r
+  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStatistics (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        Reset,\r
+  IN OUT UINTN                      *StatisticsSize OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS        *StatisticsTable OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Statistics (Private->Io, Reset, StatisticsSize, StatisticsTable);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Converts a multicast IP address to a multicast HW MAC address.\r
+\r
+  @param  This Protocol instance pointer.\r
+  @param  Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+  @param  Ip   The multicast IP address that is to be converted to a multicast\r
+               HW MAC address.\r
+  @param  Mac  The multicast HW MAC address that is to be generated from IP.\r
+\r
+  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
+                                HW MAC address.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpMcastIptoMac (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        Ipv6,\r
+  IN EFI_IP_ADDRESS                 *Ip,\r
+  OUT EFI_MAC_ADDRESS               *Mac\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->MCastIpToMac (Private->Io, Ipv6, Ip, Mac);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Performs read and write operations on the NVRAM device attached to a \r
+  network interface.\r
+\r
+  @param  This         Protocol instance pointer.\r
+  @param  ReadOrWrite  TRUE for read operations, FALSE for write operations.\r
+  @param  Offset       Byte offset in the NVRAM device at which to start the read or\r
+                       write operation. This must be a multiple of NvRamAccessSize and\r
+                       less than NvRamSize.\r
+  @param  BufferSize   The number of bytes to read or write from the NVRAM device.\r
+                       This must also be a multiple of NvramAccessSize.\r
+  @param  Buffer       A pointer to the data buffer.\r
+\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpNvdata (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        ReadOrWrite,\r
+  IN UINTN                          Offset,\r
+  IN UINTN                          BufferSize,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->NvData (Private->Io, ReadOrWrite, Offset, BufferSize, Buffer);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Reads the current interrupt status and recycled transmit buffer status from \r
+  a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
+                          If this is NULL, the interrupt status will not be read from\r
+                          the device. If this is not NULL, the interrupt status will\r
+                          be read from the device. When the  interrupt status is read,\r
+                          it will also be cleared. Clearing the transmit  interrupt\r
+                          does not empty the recycled transmit buffer array.\r
+  @param  TxBuffer        Recycled transmit buffer address. The network interface will\r
+                          not transmit if its internal recycled transmit buffer array\r
+                          is full. Reading the transmit buffer does not clear the\r
+                          transmit interrupt. If this is NULL, then the transmit buffer\r
+                          status will not be read. If there are no transmit buffers to\r
+                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpGetStatus (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  OUT UINT32                        *InterruptStatus,\r
+  OUT VOID                          **TxBuffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->GetStatus (Private->Io, InterruptStatus, TxBuffer);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Places a packet in the transmit queue of a network interface.\r
+\r
+  @param  This       Protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
+                     the Transmit() function. If HeaderSize is non-zero, then it\r
+                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+                     and Protocol parameters must not be NULL.\r
+  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
+                     data) to be transmitted through the network interface.\r
+  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
+                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
+                     then the media header in Buffer must already be filled in by the\r
+                     caller. If HeaderSize is non-zero, then the media header will be\r
+                     filled in by the Transmit() function.\r
+  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
+                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
+                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
+  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
+                     parameter is ignored.\r
+  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
+                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
+                     examples.\r
+\r
+  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpTransmit (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN UINTN                          HeaderSize,\r
+  IN UINTN                          BufferSize,\r
+  IN VOID*                          Buffer,\r
+  IN EFI_MAC_ADDRESS                *SrcAddr OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                *DestAddr OPTIONAL,\r
+  IN UINT16                         *Protocol OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Transmit (\r
+                          Private->Io,\r
+                          HeaderSize,\r
+                          BufferSize,\r
+                          Buffer,\r
+                          SrcAddr,\r
+                          DestAddr,\r
+                          Protocol\r
+                          );\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Receives a packet from a network interface.\r
+\r
+  @param  This             Protocol instance pointer.\r
+  @param  HeaderSize       The size, in bytes, of the media header received on the network\r
+                           interface. If this parameter is NULL, then the media header size\r
+                           will not be returned.\r
+  @param  BuffSize         On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+                           bytes, of the packet that was received on the network interface.\r
+  @param  Buffer           A pointer to the data buffer to receive both the media header and\r
+                           the data.\r
+  @param  SourceAddr       The source HW MAC address. If this parameter is NULL, the\r
+                           HW MAC source address will not be extracted from the media\r
+                           header.\r
+  @param  DestinationAddr  The destination HW MAC address. If this parameter is NULL,\r
+                           the HW MAC destination address will not be extracted from the\r
+                           media header.\r
+  @param  Protocol         The media header type. If this parameter is NULL, then the\r
+                           protocol will not be extracted from the media header. See\r
+                           RFC 1700 section "Ether Types" for examples.\r
+\r
+  @retval EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
+                                been updated to the number of bytes received.\r
+  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit\r
+                                request.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceive (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  OUT UINTN                         *HeaderSize OPTIONAL,\r
+  IN OUT UINTN                      *BuffSize,\r
+  OUT VOID                          *Buffer,\r
+  OUT EFI_MAC_ADDRESS               *SourceAddr OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS               *DestinationAddr OPTIONAL,\r
+  OUT UINT16                        *Protocol OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Receive (\r
+                          Private->Io,\r
+                          HeaderSize,\r
+                          BuffSize,\r
+                          Buffer,\r
+                          SourceAddr,\r
+                          DestinationAddr,\r
+                          Protocol\r
+                          );\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Test to see if this driver supports ControllerHandle. This service\r
+  is called by the EFI boot service ConnectController(). In\r
+  order to make drivers as small as possible, there are a few calling\r
+  restrictions for this service. ConnectController() must\r
+  follow these calling restrictions. If any other agent wishes to call\r
+  Supported() it must also follow these calling restrictions.\r
+\r
+  @param  This                Protocol instance pointer.\r
+  @param  ControllerHandle    Handle of device to test\r
+  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
+                              device to start.\r
+\r
+  @retval EFI_SUCCESS         This driver supports this device\r
+  @retval EFI_UNSUPPORTED     This driver does not support this device\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EMU_IO_THUNK_PROTOCOL     *EmuIoThunk;\r
+  MAC_ADDR_DEVICE_PATH      *Node;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+\r
+  if (RemainingDevicePath != NULL) {\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      Node = (MAC_ADDR_DEVICE_PATH *)RemainingDevicePath;\r
+      if (Node->Header.Type != MESSAGING_DEVICE_PATH ||\r
+          Node->Header.SubType != MSG_MAC_ADDR_DP) {\r
+        // If the remaining device path does not match we don't support the request\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+    }\r
+  }\r
+  \r
+  \r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    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
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEmuIoThunkProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+        \r
+        \r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Close protocol, don't use device path protocol in the Support() function\r
+  //\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEfiDevicePathProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Start this driver on ControllerHandle. This service is called by the\r
+  EFI boot service ConnectController(). In order to make\r
+  drivers as small as possible, there are a few calling restrictions for\r
+  this service. ConnectController() must follow these\r
+  calling restrictions. If any other agent wishes to call Start() it\r
+  must also follow these calling restrictions.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  ControllerHandle     Handle of device to bind driver to\r
+  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
+                               device to start.\r
+\r
+  @retval EFI_SUCCESS          Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EMU_IO_THUNK_PROTOCOL       *EmuIoThunk;\r
+  EMU_SNP_PRIVATE_DATA        *Private;\r
+  MAC_ADDR_DEVICE_PATH        Node;\r
+  EFI_DEVICE_PATH_PROTOCOL    *ParentDevicePath;\r
+\r
+  //\r
+  // Grab the protocols we need\r
+  //\r
+  \r
+  Status = gBS->OpenProtocol(\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  ( VOID ** ) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status) {\r
+    return Status;\r
+  }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (!CompareGuid (EmuIoThunk->Protocol, &gEmuSnpProtocolGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Status = EmuIoThunk->Open (EmuIoThunk);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  //  Allocate the private data.\r
+  //\r
+  Private = AllocateZeroPool (sizeof (EMU_SNP_PRIVATE_DATA));\r
+  if (Private == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Done;\r
+  }\r
+\r
+  CopyMem (&Private->Snp, &gEmuSnpTemplate, sizeof (EFI_SIMPLE_NETWORK_PROTOCOL));\r
+\r
+  Private->Signature    = EMU_SNP_PRIVATE_DATA_SIGNATURE;\r
+  Private->IoThunk      = EmuIoThunk;\r
+  Private->Io           = EmuIoThunk->Interface;\r
+  Private->EfiHandle    = ControllerHandle;\r
+  Private->DeviceHandle = NULL;\r
+  Private->Snp.Mode     = &Private->Mode;\r
+  Private->ControllerNameTable = NULL;\r
+\r
+  \r
+  Status = Private->Io->CreateMapping (Private->Io, &Private->Mode);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // Build the device path by appending the MAC node to the ParentDevicePath\r
+  // from the EmuIo handle.\r
+  //\r
+  ZeroMem (&Node, sizeof (MAC_ADDR_DEVICE_PATH));\r
+\r
+  Node.Header.Type     = MESSAGING_DEVICE_PATH;\r
+  Node.Header.SubType  = MSG_MAC_ADDR_DP;\r
+  Node.IfType          = Private->Mode.IfType;\r
+\r
+  SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL * )&Node, sizeof (MAC_ADDR_DEVICE_PATH));\r
+\r
+  CopyMem (&Node.MacAddress, &Private->Mode.CurrentAddress, sizeof (EFI_MAC_ADDRESS));\r
+\r
+  //\r
+  // Build the device path by appending the MAC node to the ParentDevicePath from the EmuIo handle.\r
+  //\r
+  Private->DevicePath = AppendDevicePathNode (ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&Node);\r
+  if ( Private->DevicePath == NULL ) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Done;\r
+  }\r
+\r
+  AddUnicodeString2 (\r
+    "eng",\r
+    gEmuSnpDriverComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString,\r
+    TRUE\r
+    );\r
+    \r
+  AddUnicodeString2 (\r
+    "en",\r
+    gEmuSnpDriverComponentName2.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString,\r
+    FALSE\r
+    );\r
+\r
+  //\r
+  // Create Child Handle\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces(\r
+                  &Private->DeviceHandle,\r
+                  &gEfiSimpleNetworkProtocolGuid, &Private->Snp,\r
+                  &gEfiDevicePathProtocolGuid,    Private->DevicePath,\r
+                  NULL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // Open For Child Device\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  Private->DeviceHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                  );\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+    if (Private != NULL) {\r
+      FreePool (Private);\r
+    }\r
+    if (ParentDevicePath != NULL) {\r
+      gBS->CloseProtocol(\r
+            ControllerHandle,\r
+            &gEfiDevicePathProtocolGuid,\r
+            This->DriverBindingHandle,\r
+            ControllerHandle\r
+            );\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Stop this driver on ControllerHandle. This service is called by the\r
+  EFI boot service DisconnectController(). In order to\r
+  make drivers as small as possible, there are a few calling\r
+  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
+  @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
+                            children is zero stop the entire bus driver.\r
+  @param  ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+  @retval EFI_SUCCESS       Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStop (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     ControllerHandle,\r
+  IN UINTN                          NumberOfChildren,\r
+  IN EFI_HANDLE                     *ChildHandleBuffer\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EMU_SNP_PRIVATE_DATA        *Private = NULL;\r
+  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+  EFI_DEVICE_PATH_PROTOCOL    *ParentDevicePath;\r
+\r
+  //\r
+  // Complete all outstanding transactions to Controller.\r
+  // Don't allow any new transaction to Controller to be started.\r
+  //\r
+  if (NumberOfChildren == 0) {\r
+    //\r
+    // Close the bus driver\r
+    //\r
+    Status = gBS->CloseProtocol (\r
+                    ControllerHandle,\r
+                    &gEmuIoThunkProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle\r
+                    );\r
+\r
+    Status = gBS->CloseProtocol (\r
+                    ControllerHandle,\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle\r
+                    );\r
+    return Status;\r
+  }\r
+\r
+  ASSERT (NumberOfChildren == 1);\r
+  \r
+  \r
+  //\r
+  // Get our context back.\r
+  //\r
+  Status = gBS->OpenProtocol(\r
+                  ChildHandleBuffer[0],\r
+                  &gEfiSimpleNetworkProtocolGuid,\r
+                  ( VOID ** ) &Snp,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (Snp);\r
+  Status = Private->IoThunk->Close (Private->IoThunk);\r
+\r
+  Status = gBS->CloseProtocol(\r
+                  ChildHandleBuffer[0],\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  This->DriverBindingHandle,\r
+                  Private->DeviceHandle\r
+                  );\r
+\r
+  Status = gBS->UninstallMultipleProtocolInterfaces(\r
+                  ChildHandleBuffer[0],\r
+                  &gEfiSimpleNetworkProtocolGuid,   &Private->Snp,\r
+                  &gEfiDevicePathProtocolGuid,      Private->DevicePath,\r
+                  NULL\r
+                  );\r
+\r
+  FreePool (Private->DevicePath);\r
+  FreeUnicodeStringTable (Private->ControllerNameTable);\r
+  FreePool (Private);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding = {\r
+  EmuSnpDriverBindingSupported,\r
+  EmuSnpDriverBindingStart,\r
+  EmuSnpDriverBindingStop,\r
+  0xA,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+\r
+/**\r
+  This is the declaration of an EFI image entry point. This entry point is\r
+  the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r
+  both device drivers and bus drivers.\r
+\r
+  @param  ImageHandle           The firmware allocated handle for the UEFI image.\r
+  @param  SystemTable           A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeEmuSnpDriver (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+\r
+  //\r
+  // Install the Driver Protocols\r
+  //\r
+\r
+  Status = EfiLibInstallDriverBindingComponentName2(\r
+              ImageHandle,\r
+              SystemTable,\r
+              &gEmuSnpDriverBinding,\r
+              ImageHandle,\r
+              &gEmuSnpDriverComponentName,\r
+              &gEmuSnpDriverComponentName2\r
+              );\r
+\r
+  return Status;\r
+}\r
diff --git a/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.h b/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.h
new file mode 100644 (file)
index 0000000..21bfc42
--- /dev/null
@@ -0,0 +1,488 @@
+/** @file\r
+\r
+ Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
+\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\r
+    http://opensource.org/licenses/bsd-license.php\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
+  EmuSnp.h\r
+\r
+Abstract:\r
+\r
+-**/\r
+\r
+#ifndef _EMU_SNP_H_\r
+#define _EMU_SNP_H_\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/SimpleNetwork.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+#include <Protocol/EmuSnp.h>\r
+\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/NetLib.h>\r
+\r
+#define NET_ETHER_HEADER_SIZE     14\r
+\r
+//\r
+//  Private data for driver.\r
+//\r
+#define EMU_SNP_PRIVATE_DATA_SIGNATURE SIGNATURE_32( 'U', 'S', 'N', 'P' )\r
+\r
+typedef struct {\r
+  UINTN                       Signature;\r
+  EMU_IO_THUNK_PROTOCOL       *IoThunk;\r
+  EMU_SNP_PROTOCOL            *Io;\r
+  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
+\r
+  EFI_HANDLE                  EfiHandle;\r
+  EFI_HANDLE                  DeviceHandle;\r
+\r
+  EFI_SIMPLE_NETWORK_PROTOCOL Snp;\r
+  EFI_SIMPLE_NETWORK_MODE     Mode;\r
+  \r
+  EFI_UNICODE_STRING_TABLE    *ControllerNameTable;\r
+\r
+} EMU_SNP_PRIVATE_DATA;\r
+\r
+#define EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS(a) \\r
+      CR( a, EMU_SNP_PRIVATE_DATA, Snp, EMU_SNP_PRIVATE_DATA_SIGNATURE )\r
+\r
+extern EFI_DRIVER_BINDING_PROTOCOL    gEmuSnpDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL    gEmuSnpDriverComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL   gEmuSnpDriverComponentName2;\r
+\r
+/**\r
+  Test to see if this driver supports ControllerHandle. This service\r
+  is called by the EFI boot service ConnectController(). In\r
+  order to make drivers as small as possible, there are a few calling\r
+  restrictions for this service. ConnectController() must\r
+  follow these calling restrictions. If any other agent wishes to call\r
+  Supported() it must also follow these calling restrictions.\r
+\r
+  @param  This                Protocol instance pointer.\r
+  @param  ControllerHandle    Handle of device to test\r
+  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
+                              device to start.\r
+\r
+  @retval EFI_SUCCESS         This driver supports this device\r
+  @retval EFI_UNSUPPORTED     This driver does not support this device\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
+  );\r
+\r
+/**\r
+  Start this driver on ControllerHandle. This service is called by the\r
+  EFI boot service ConnectController(). In order to make\r
+  drivers as small as possible, there are a few calling restrictions for\r
+  this service. ConnectController() must follow these\r
+  calling restrictions. If any other agent wishes to call Start() it\r
+  must also follow these calling restrictions.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  ControllerHandle     Handle of device to bind driver to\r
+  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
+                               device to start.\r
+\r
+  @retval EFI_SUCCESS          Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
+  );\r
+\r
+/**\r
+  Stop this driver on ControllerHandle. This service is called by the\r
+  EFI boot service DisconnectController(). In order to\r
+  make drivers as small as possible, there are a few calling\r
+  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
+  @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
+                            children is zero stop the entire bus driver.\r
+  @param  ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+  @retval EFI_SUCCESS       Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  );\r
+\r
+/**\r
+  Changes the state of a network interface from "stopped" to "started".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStart(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This\r
+  );\r
+  \r
+/**\r
+  Changes the state of a network interface from "started" to "stopped".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStop(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This\r
+  );\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
+  of additional transmit and receive buffers.\r
+\r
+  @param  This              Protocol instance pointer.\r
+  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpInitialize(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN UINTN              ExtraRxBufferSize OPTIONAL,\r
+  IN UINTN              ExtraTxBufferSize OPTIONAL\r
+  );\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
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  ExtendedVerification Indicates that the driver may perform a more\r
+                               exhaustive verification operation of the device\r
+                               during reset.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReset(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              ExtendedVerification\r
+  );\r
+\r
+/**\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
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpShutdown(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This\r
+  );\r
+\r
+/**\r
+  Manages the multicast receive filters of a network interface.\r
+\r
+  @param  This               Protocol instance pointer.\r
+  @param  EnableBits         A bit mask of receive filters to enable on the network interface.\r
+  @param  DisableBits        A bit mask of receive filters to disable on the network interface.\r
+  @param  ResetMcastFilter   Set to TRUE to reset the contents of the multicast receive\r
+                             filters on the network interface to their default values.\r
+  @param  McastFilterCount   Number of multicast HW MAC addresses in the new\r
+                             MCastFilter list. This value must be less than or equal to\r
+                             the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r
+                             field is optional if ResetMCastFilter is TRUE.\r
+  @param  McastFilter        A pointer to a list of new multicast receive filter HW MAC\r
+                             addresses. This list will replace any existing multicast\r
+                             HW MAC address list. This field is optional if\r
+                             ResetMCastFilter is TRUE.\r
+\r
+  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceiveFilters(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN UINT32              EnableBits,\r
+  IN UINT32              DisableBits,\r
+  IN BOOLEAN              ResetMcastFilter,\r
+  IN UINTN              McastFilterCount OPTIONAL,\r
+  IN EFI_MAC_ADDRESS*          McastFilter OPTIONAL\r
+  );\r
+\r
+/**\r
+  Modifies or resets the current station address, if supported.\r
+\r
+  @param  This         Protocol instance pointer.\r
+  @param  Reset        Flag used to reset the station address to the network interfaces\r
+                       permanent address.\r
+  @param  NewMacAddr   New station address to be used for the network interface.\r
+\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStationAddress(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              Reset,\r
+  IN EFI_MAC_ADDRESS*          NewMacAddr OPTIONAL\r
+  );\r
+\r
+/**\r
+  Resets or collects the statistics on a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
+  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
+                          output the size, in bytes, of the resulting table of\r
+                          statistics.\r
+  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+                          contains the statistics.\r
+\r
+  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStatistics(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              Reset,\r
+  IN OUT UINTN*            StatisticsSize OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS*      StatisticsTable OPTIONAL\r
+  );\r
+  \r
+/**\r
+  Converts a multicast IP address to a multicast HW MAC address.\r
+  \r
+  @param  This  Protocol instance pointer.\r
+  @param  Ipv6  Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+                to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+  @param  Ip    The multicast IP address that is to be converted to a multicast\r
+                HW MAC address.\r
+  @param  Mac   The multicast HW MAC address that is to be generated from IP.\r
+\r
+  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
+                                HW MAC address.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpMcastIptoMac(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              Ipv6,\r
+  IN EFI_IP_ADDRESS*          Ip,\r
+  OUT EFI_MAC_ADDRESS*        Mac\r
+  );\r
+\r
+/**\r
+  Performs read and write operations on the NVRAM device attached to a \r
+  network interface.\r
+\r
+  @param  This         Protocol instance pointer.\r
+  @param  ReadOrWrite  TRUE for read operations, FALSE for write operations.\r
+  @param  Offset       Byte offset in the NVRAM device at which to start the read or\r
+                       write operation. This must be a multiple of NvRamAccessSize and\r
+                       less than NvRamSize.\r
+  @param  BufferSize   The number of bytes to read or write from the NVRAM device.\r
+                       This must also be a multiple of NvramAccessSize.\r
+  @param  Buffer       A pointer to the data buffer.\r
+\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpNvdata(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              ReadOrWrite,\r
+  IN UINTN              Offset,\r
+  IN UINTN              BufferSize,\r
+  IN OUT VOID*            Buffer\r
+  );\r
+\r
+/**\r
+  Reads the current interrupt status and recycled transmit buffer status from \r
+  a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
+                          If this is NULL, the interrupt status will not be read from\r
+                          the device. If this is not NULL, the interrupt status will\r
+                          be read from the device. When the  interrupt status is read,\r
+                          it will also be cleared. Clearing the transmit  interrupt\r
+                          does not empty the recycled transmit buffer array.\r
+  @param  TxBuffer        Recycled transmit buffer address. The network interface will\r
+                          not transmit if its internal recycled transmit buffer array\r
+                          is full. Reading the transmit buffer does not clear the\r
+                          transmit interrupt. If this is NULL, then the transmit buffer\r
+                          status will not be read. If there are no transmit buffers to\r
+                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpGetStatus(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  OUT UINT32*              InterruptStatus,\r
+  OUT VOID**              TxBuffer\r
+  );\r
+\r
+/**\r
+  Places a packet in the transmit queue of a network interface.\r
+\r
+  @param  This       Protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
+                     the Transmit() function. If HeaderSize is non-zero, then it\r
+                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+                     and Protocol parameters must not be NULL.\r
+  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
+                     data) to be transmitted through the network interface.\r
+  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
+                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
+                     then the media header in Buffer must already be filled in by the\r
+                     caller. If HeaderSize is non-zero, then the media header will be\r
+                     filled in by the Transmit() function.\r
+  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
+                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
+                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
+  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
+                     parameter is ignored.\r
+  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
+                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
+                     examples.\r
+\r
+  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_ACCESS_DENIED     Error acquire global lock for operation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpTransmit(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN UINTN              HeaderSize,\r
+  IN UINTN              BufferSize,\r
+  IN VOID*              Buffer,\r
+  IN EFI_MAC_ADDRESS*          SrcAddr OPTIONAL,\r
+  IN EFI_MAC_ADDRESS*          DestAddr OPTIONAL,\r
+  IN UINT16*              Protocol OPTIONAL\r
+  );\r
+\r
+/**\r
+  Receives a packet from a network interface.\r
+\r
+  @param  This             Protocol instance pointer.\r
+  @param  HeaderSize       The size, in bytes, of the media header received on the network\r
+                           interface. If this parameter is NULL, then the media header size\r
+                           will not be returned.\r
+  @param  BuffSize         On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+                           bytes, of the packet that was received on the network interface.\r
+  @param  Buffer           A pointer to the data buffer to receive both the media header and\r
+                           the data.\r
+  @param  SourceAddr       The source HW MAC address. If this parameter is NULL, the\r
+                           HW MAC source address will not be extracted from the media\r
+                           header.\r
+  @param  DestinationAddr  The destination HW MAC address. If this parameter is NULL,\r
+                           the HW MAC destination address will not be extracted from the\r
+                           media header.\r
+  @param  Protocol         The media header type. If this parameter is NULL, then the\r
+                           protocol will not be extracted from the media header. See\r
+                           RFC 1700 section "Ether Types" for examples.\r
+\r
+  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
+                                 been updated to the number of bytes received.\r
+  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
+                                 request.\r
+  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval  EFI_ACCESS_DENIED     Error acquire global lock for operation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceive(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  OUT UINTN*              HeaderSize OPTIONAL,\r
+  IN OUT UINTN*            BuffSize,\r
+  OUT VOID*              Buffer,\r
+  OUT EFI_MAC_ADDRESS*        SourceAddr OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS*        DestinationAddr OPTIONAL,\r
+  OUT UINT16*              Protocol OPTIONAL\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+EmuSnpWaitForPacketNotify(\r
+  IN EFI_EVENT            Event,\r
+  IN VOID*              Private\r
+  );\r
+\r
+#endif  // _EMU_SNP_H_\r
diff --git a/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf b/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf
new file mode 100644 (file)
index 0000000..a9e9230
--- /dev/null
@@ -0,0 +1,57 @@
+#/** @file\r
+# Component name for module EmuSnpDxe\r
+#\r
+# Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
+#\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\r
+#    http://opensource.org/licenses/bsd-license.php\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
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuSnpDxe\r
+  FILE_GUID                      = 22597239-6107-DF44-AD3F-5F053E92222E\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = InitializeEmuSnpDriver\r
+#  UNLOAD_IMAGE                   = EmuSnpUnload\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  ComponentName.c\r
+  EmuSnpDxe.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  InOsEmuPkg/InOsEmuPkg.dec\r
+\r
+[LibraryClasses]\r
+  DevicePathLib\r
+  UefiLib\r
+  UefiBootServicesTableLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  UefiDriverEntryPoint\r
+  NetLib\r
+\r
+[Protocols]\r
+  gEfiSimpleNetworkProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED\r
+  gEmuSnpProtocolGuid\r
+  gEmuIoThunkProtocolGuid\r
+\r
+\r
index 14983ecbdac03990e7d7c0ad9586730fd124fc31..7b1bb38c3698cc505947ac08db2722052b38507d 100644 (file)
@@ -37,6 +37,7 @@
   gEmuGraphicsWindowProtocolGuid = { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }\r
   gEmuThreadThunkProtocolGuid    = { 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }\r
   gEmuBlockIoProtocolGuid        = { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }\r
+  gEmuSnpProtocolGuid            = { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }\r
 \r
 [Ppis]\r
   gEmuThunkPpiGuid               = { 0xE113F896, 0x75CF, 0xF640, { 0x81, 0x7F, 0xC8, 0x5A, 0x79, 0xE8, 0xAE, 0x67 } }\r
diff --git a/InOsEmuPkg/Include/Protocol/EmuSnp.h b/InOsEmuPkg/Include/Protocol/EmuSnp.h
new file mode 100644 (file)
index 0000000..2659c50
--- /dev/null
@@ -0,0 +1,458 @@
+/** @file\r
+  The EMU_SNP_PROTOCOL provides services to initialize a network interface, \r
+  transmit packets, receive packets, and close a network interface.\r
+\r
+\r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Portitions copyright (c) 2011, Apple Inc. All rights reserved. \r
+This program and the accompanying materials are licensed and made available under \r
+the terms and conditions of the BSD License that accompanies this distribution.  \r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.                                          \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
+**/\r
+\r
+#ifndef __EMU_SNP_H__\r
+#define __EMU_SNP_H__\r
+\r
+#define EMU_SNP_PROTOCOL_GUID \\r
+ { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }\r
+\r
+typedef struct _EMU_SNP_PROTOCOL  EMU_SNP_PROTOCOL;\r
+\r
+\r
+/**\r
+  Changes the state of a network interface from "stopped" to "started".\r
+\r
+  @param  This Protocol instance pointer.\r
+  @param  Mode SimpleNetworkProtocol Mode structure passed into driver.\r
+\r
+  @retval EFI_SUCCESS           The network interface was started.\r
+  @retval EFI_ALREADY_STARTED   The network interface is already mapped.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_CREATE_MAPPING)(\r
+  IN EMU_SNP_PROTOCOL         *This,\r
+  IN EFI_SIMPLE_NETWORK_MODE  *Mode\r
+  );\r
+\r
+\r
+/**\r
+  Changes the state of a network interface from "stopped" to "started".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was started.\r
+  @retval EFI_ALREADY_STARTED   The network interface is already in the started state.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_START)(\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  );\r
+\r
+/**\r
+  Changes the state of a network interface from "started" to "stopped".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was stopped.\r
+  @retval EFI_ALREADY_STARTED   The network interface is already in the stopped state.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_STOP)(\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  );\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
+  of additional transmit and receive buffers.\r
+\r
+  @param  This              The protocol instance pointer.\r
+  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+\r
+  @retval EFI_SUCCESS           The network interface was initialized.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough memory for the transmit and\r
+                                receive buffers.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_INITIALIZE)(\r
+  IN EMU_SNP_PROTOCOL                    *This,\r
+  IN UINTN                                          ExtraRxBufferSize  OPTIONAL,\r
+  IN UINTN                                          ExtraTxBufferSize  OPTIONAL\r
+  );\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
+\r
+  @param  This                 The protocol instance pointer.\r
+  @param  ExtendedVerification Indicates that the driver may perform a more\r
+                               exhaustive verification operation of the device\r
+                               during reset.\r
+\r
+  @retval EFI_SUCCESS           The network interface was reset.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_RESET)(\r
+  IN EMU_SNP_PROTOCOL   *This,\r
+  IN BOOLEAN                       ExtendedVerification\r
+  );\r
+\r
+/**\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
+\r
+  @retval EFI_SUCCESS           The network interface was shutdown.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_SHUTDOWN)(\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  );\r
+\r
+/**\r
+  Manages the multicast receive filters of a network interface.\r
+\r
+  @param  This             The protocol instance pointer.\r
+  @param  Enable           A bit mask of receive filters to enable on the network interface.\r
+  @param  Disable          A bit mask of receive filters to disable on the network interface.\r
+  @param  ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r
+                           filters on the network interface to their default values.\r
+  @param  McastFilterCnt   Number of multicast HW MAC addresses in the new\r
+                           MCastFilter list. This value must be less than or equal to\r
+                           the MCastFilterCnt field of EMU_SNP_MODE. This\r
+                           field is optional if ResetMCastFilter is TRUE.\r
+  @param  MCastFilter      A pointer to a list of new multicast receive filter HW MAC\r
+                           addresses. This list will replace any existing multicast\r
+                           HW MAC address list. This field is optional if\r
+                           ResetMCastFilter is TRUE.\r
+\r
+  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_RECEIVE_FILTERS)(\r
+  IN EMU_SNP_PROTOCOL                             *This,\r
+  IN UINT32                                                  Enable,\r
+  IN UINT32                                                  Disable,\r
+  IN BOOLEAN                                                 ResetMCastFilter,\r
+  IN UINTN                                                   MCastFilterCnt     OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                                         *MCastFilter OPTIONAL\r
+  );\r
+\r
+/**\r
+  Modifies or resets the current station address, if supported.\r
+\r
+  @param  This  The protocol instance pointer.\r
+  @param  Reset Flag used to reset the station address to the network interfaces\r
+                permanent address.\r
+  @param  New   The new station address to be used for the network interface.\r
+\r
+  @retval EFI_SUCCESS           The network interfaces station address was updated.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_STATION_ADDRESS)(\r
+  IN EMU_SNP_PROTOCOL            *This,\r
+  IN BOOLEAN                                Reset,\r
+  IN EFI_MAC_ADDRESS                        *New OPTIONAL\r
+  );\r
+\r
+/**\r
+  Resets or collects the statistics on a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
+  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
+                          output the size, in bytes, of the resulting table of\r
+                          statistics.\r
+  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+                          contains the statistics.\r
+\r
+  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_STATISTICS)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              Reset,\r
+  IN OUT UINTN                            *StatisticsSize   OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Converts a multicast IP address to a multicast HW MAC address.\r
+\r
+  @param  This The protocol instance pointer.\r
+  @param  IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+  @param  IP   The multicast IP address that is to be converted to a multicast\r
+               HW MAC address.\r
+  @param  MAC  The multicast HW MAC address that is to be generated from IP.\r
+\r
+  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
+                                HW MAC address.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_MCAST_IP_TO_MAC)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              IPv6,\r
+  IN EFI_IP_ADDRESS                       *IP,\r
+  OUT EFI_MAC_ADDRESS                     *MAC\r
+  );\r
+\r
+/**\r
+  Performs read and write operations on the NVRAM device attached to a \r
+  network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  ReadWrite  TRUE for read operations, FALSE for write operations.\r
+  @param  Offset     Byte offset in the NVRAM device at which to start the read or\r
+                     write operation. This must be a multiple of NvRamAccessSize and\r
+                     less than NvRamSize.\r
+  @param  BufferSize The number of bytes to read or write from the NVRAM device.\r
+                     This must also be a multiple of NvramAccessSize.\r
+  @param  Buffer     A pointer to the data buffer.\r
+\r
+  @retval EFI_SUCCESS           The NVRAM access was performed.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_NVDATA)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              ReadWrite,\r
+  IN UINTN                                Offset,\r
+  IN UINTN                                BufferSize,\r
+  IN OUT VOID                             *Buffer\r
+  );\r
+\r
+/**\r
+  Reads the current interrupt status and recycled transmit buffer status from \r
+  a network interface.\r
+\r
+  @param  This            The protocol instance pointer.\r
+  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
+                          If this is NULL, the interrupt status will not be read from\r
+                          the device. If this is not NULL, the interrupt status will\r
+                          be read from the device. When the  interrupt status is read,\r
+                          it will also be cleared. Clearing the transmit  interrupt\r
+                          does not empty the recycled transmit buffer array.\r
+  @param  TxBuf           Recycled transmit buffer address. The network interface will\r
+                          not transmit if its internal recycled transmit buffer array\r
+                          is full. Reading the transmit buffer does not clear the\r
+                          transmit interrupt. If this is NULL, then the transmit buffer\r
+                          status will not be read. If there are no transmit buffers to\r
+                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+  @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_GET_STATUS)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINT32                              *InterruptStatus OPTIONAL,\r
+  OUT VOID                                **TxBuf OPTIONAL\r
+  );\r
+\r
+/**\r
+  Places a packet in the transmit queue of a network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
+                     the Transmit() function. If HeaderSize is non-zero, then it\r
+                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+                     and Protocol parameters must not be NULL.\r
+  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
+                     data) to be transmitted through the network interface.\r
+  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
+                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
+                     then the media header in Buffer must already be filled in by the\r
+                     caller. If HeaderSize is non-zero, then the media header will be\r
+                     filled in by the Transmit() function.\r
+  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
+                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
+                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
+  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
+                     parameter is ignored.\r
+  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
+                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
+                     examples.\r
+\r
+  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.                      \r
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_TRANSMIT)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN UINTN                                HeaderSize,\r
+  IN UINTN                                BufferSize,\r
+  IN VOID                                 *Buffer,\r
+  IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,\r
+  IN UINT16                               *Protocol OPTIONAL\r
+  );\r
+\r
+/**\r
+  Receives a packet from a network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header received on the network\r
+                     interface. If this parameter is NULL, then the media header size\r
+                     will not be returned.\r
+  @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+                     bytes, of the packet that was received on the network interface.\r
+  @param  Buffer     A pointer to the data buffer to receive both the media header and\r
+                     the data.\r
+  @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the\r
+                     HW MAC source address will not be extracted from the media\r
+                     header.\r
+  @param  DestAddr   The destination HW MAC address. If this parameter is NULL,\r
+                     the HW MAC destination address will not be extracted from the\r
+                     media header.\r
+  @param  Protocol   The media header type. If this parameter is NULL, then the\r
+                     protocol will not be extracted from the media header. See\r
+                     RFC 1700 section "Ether Types" for examples.\r
+\r
+  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
+                                 been updated to the number of bytes received.\r
+  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
+                                 request.\r
+  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_RECEIVE)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINTN                               *HeaderSize OPTIONAL,\r
+  IN OUT UINTN                            *BufferSize,\r
+  OUT VOID                                *Buffer,\r
+  OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,\r
+  OUT UINT16                              *Protocol   OPTIONAL\r
+  );\r
+\r
+#define EMU_SNP_PROTOCOL_REVISION  0x00010000\r
+\r
+//\r
+// Revision defined in EFI1.1\r
+// \r
+#define EMU_SNP_INTERFACE_REVISION   EMU_SNP_PROTOCOL_REVISION\r
+\r
+///\r
+/// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices \r
+/// from the EFI driver that produces EFI Simple Network Protocol.\r
+///\r
+struct _EMU_SNP_PROTOCOL {\r
+  EMU_SNP_CREATE_MAPPING   CreateMapping;\r
+  EMU_SNP_START            Start;\r
+  EMU_SNP_STOP             Stop;\r
+  EMU_SNP_INITIALIZE       Initialize;\r
+  EMU_SNP_RESET            Reset;\r
+  EMU_SNP_SHUTDOWN         Shutdown;\r
+  EMU_SNP_RECEIVE_FILTERS  ReceiveFilters;\r
+  EMU_SNP_STATION_ADDRESS  StationAddress;\r
+  EMU_SNP_STATISTICS       Statistics;\r
+  EMU_SNP_MCAST_IP_TO_MAC  MCastIpToMac;\r
+  EMU_SNP_NVDATA           NvData;\r
+  EMU_SNP_GET_STATUS       GetStatus;\r
+  EMU_SNP_TRANSMIT         Transmit;\r
+  EMU_SNP_RECEIVE          Receive;\r
+};\r
+\r
+extern EFI_GUID gEmuSnpProtocolGuid;\r
+\r
+#endif\r
index ce9b088f2aff50676e965356a9c3e9480724b52e..af3e25973b616047937a546257c8e333edf428c0 100644 (file)
   PpiListLib|InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
   PeiServicesLib|InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf\r
 \r
-#  PeCoffExtraActionLib|InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf\r
-\r
 \r
 [LibraryClasses.common.PEIM, LibraryClasses.common.PEI_CORE]\r
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
   InOsEmuPkg/EmuGopDxe/EmuGopDxe.inf\r
   InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf\r
   InOsEmuPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf\r
+  InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf\r
 \r
   MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
 \r
   #\r
   # Network stack drivers\r
   #\r
-!if $(NETWORK_SUPPORT) \r
-  InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf\r
-!endif\r
   MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf\r
   MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf\r
   MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf\r
index 4058815ee5e1c93090c094e10ea1f80b37170afc..1f2fe7e633dbcaa0bcdf3ccadc58fc313e72415d 100644 (file)
@@ -224,6 +224,7 @@ INF  InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf
 INF  InOsEmuPkg/EmuGopDxe/EmuGopDxe.inf\r
 INF  InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf\r
 INF  InOsEmuPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf\r
+INF  InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf\r
 \r
 INF  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
 INF  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r