Import SnpDxe, Tcp4Dxe, Udp4Dxe and MnpDxe.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3416 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
162
MdeModulePkg/Universal/Network/MnpDxe/ComponentName.c
Normal file
162
MdeModulePkg/Universal/Network/MnpDxe/ComponentName.c
Normal file
@@ -0,0 +1,162 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2005 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
ComponentName.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "MnpDriver.h"
|
||||
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName = {
|
||||
MnpComponentNameGetDriverName,
|
||||
MnpComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
STATIC EFI_UNICODE_STRING_TABLE mMnpDriverNameTable[] = {
|
||||
{
|
||||
"eng",
|
||||
L"MNP Network Service Driver"
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Retrieves a Unicode string that is the user readable name of the EFI Driver.
|
||||
|
||||
Arguments:
|
||||
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
Language - A pointer to a three character ISO 639-2 language identifier.
|
||||
This is the language of the driver name that that the caller
|
||||
is requesting, and it must match one of the languages specified
|
||||
in SupportedLanguages. The number of languages supported by a
|
||||
driver is up to the driver writer.
|
||||
DriverName - A pointer to the Unicode string to return. This Unicode string
|
||||
is the name of the driver specified by This in the language
|
||||
specified by Language.
|
||||
|
||||
Returns:
|
||||
EFI_SUCCES - The Unicode string for the Driver specified by This
|
||||
and the language specified by Language was returned
|
||||
in DriverName.
|
||||
EFI_INVALID_PARAMETER - Language is NULL.
|
||||
EFI_INVALID_PARAMETER - DriverName is NULL.
|
||||
EFI_UNSUPPORTED - The driver specified by This does not support the
|
||||
language specified by Language.
|
||||
|
||||
--*/
|
||||
{
|
||||
return LookupUnicodeString (
|
||||
Language,
|
||||
gMnpComponentName.SupportedLanguages,
|
||||
mMnpDriverNameTable,
|
||||
DriverName
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by an EFI Driver.
|
||||
|
||||
Arguments:
|
||||
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
ControllerHandle - The handle of a controller that the driver specified by
|
||||
This is managing. This handle specifies the controller
|
||||
whose name is to be returned.
|
||||
ChildHandle - The handle of the child controller to retrieve the name
|
||||
of. This is an optional parameter that may be NULL. It
|
||||
will be NULL for device drivers. It will also be NULL
|
||||
for a bus drivers that wish to retrieve the name of the
|
||||
bus controller. It will not be NULL for a bus driver
|
||||
that wishes to retrieve the name of a child controller.
|
||||
Language - A pointer to a three character ISO 639-2 language
|
||||
identifier. This is the language of the controller name
|
||||
that that the caller is requesting, and it must match one
|
||||
of the languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up to the
|
||||
driver writer.
|
||||
ControllerName - A pointer to the Unicode string to return. This Unicode
|
||||
string is the name of the controller specified by
|
||||
ControllerHandle and ChildHandle in the language specified
|
||||
by Language from the point of view of the driver specified
|
||||
by This.
|
||||
|
||||
Returns:
|
||||
EFI_SUCCESS - The Unicode string for the user readable name in the
|
||||
language specified by Language for the driver
|
||||
specified by This was returned in DriverName.
|
||||
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
|
||||
EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
|
||||
EFI_INVALID_PARAMETER - Language is NULL.
|
||||
EFI_INVALID_PARAMETER - ControllerName is NULL.
|
||||
EFI_UNSUPPORTED - The driver specified by This is not currently managing
|
||||
the controller specified by ControllerHandle and
|
||||
ChildHandle.
|
||||
EFI_UNSUPPORTED - The driver specified by This does not support the
|
||||
language specified by Language.
|
||||
|
||||
--*/
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
1466
MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c
Normal file
1466
MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c
Normal file
File diff suppressed because it is too large
Load Diff
28
MdeModulePkg/Universal/Network/MnpDxe/MnpDebug.h
Normal file
28
MdeModulePkg/Universal/Network/MnpDxe/MnpDebug.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2005 - 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
MnpDebug.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _MNP_DEBUG_H_
|
||||
#define _MNP_DEBUG_H_
|
||||
|
||||
#define MNP_DEBUG_TRACE(PrintArg) NET_DEBUG_TRACE ("Mnp", PrintArg)
|
||||
#define MNP_DEBUG_WARN(PrintArg) NET_DEBUG_WARNING ("Mnp", PrintArg)
|
||||
#define MNP_DEBUG_ERROR(PrintArg) NET_DEBUG_ERROR ("Mnp", PrintArg)
|
||||
|
||||
#endif
|
560
MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c
Normal file
560
MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c
Normal file
@@ -0,0 +1,560 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2005 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
MnpDriver.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "MnpDriver.h"
|
||||
#include "MnpDebug.h"
|
||||
#include "MnpImpl.h"
|
||||
|
||||
|
||||
EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
|
||||
MnpDriverBindingSupported,
|
||||
MnpDriverBindingStart,
|
||||
MnpDriverBindingStop,
|
||||
0xa,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to test.
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
||||
device to start.
|
||||
|
||||
@retval EFI_SUCCES This driver supports this device.
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on this device.
|
||||
@retval other This driver does not support this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpDriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Test to see if MNP is already installed.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
NULL,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Test to see if SNP is installed.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
NULL,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to bind driver to.
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
||||
device to start.
|
||||
|
||||
@retval EFI_SUCCES This driver is added to ControllerHandle.
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on
|
||||
ControllerHandle.
|
||||
@retval other This driver does not support this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpDriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
BOOLEAN MnpInitialized;
|
||||
|
||||
MnpInitialized = FALSE;
|
||||
|
||||
MnpServiceData = NetAllocateZeroPool (sizeof (MNP_SERVICE_DATA));
|
||||
if (MnpServiceData == NULL) {
|
||||
MNP_DEBUG_ERROR (("MnpDriverBindingStart(): Failed to allocate the "
|
||||
L"Mnp Service Data.\n"));
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the Mnp Service Data.
|
||||
//
|
||||
Status = MnpInitializeServiceData (MnpServiceData, This->DriverBindingHandle, ControllerHandle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
MNP_DEBUG_ERROR (("MnpDriverBindingStart: MnpInitializeServiceData "
|
||||
L"failed, %r.\n",Status));
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
MnpInitialized = TRUE;
|
||||
|
||||
//
|
||||
// Install the MNP Service Binding Protocol.
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&ControllerHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
&MnpServiceData->ServiceBinding,
|
||||
NULL
|
||||
);
|
||||
|
||||
ErrorExit:
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
if (MnpInitialized) {
|
||||
//
|
||||
// Flush the Mnp Service Data.
|
||||
//
|
||||
MnpFlushServiceData (MnpServiceData);
|
||||
}
|
||||
|
||||
//
|
||||
// Close the Simple Network Protocol.
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
||||
NetFreePool (MnpServiceData);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to stop driver on.
|
||||
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number
|
||||
of children is zero stop the entire bus driver.
|
||||
@param ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCES This driver is removed ControllerHandle.
|
||||
@retval other This driver was not removed from this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpDriverBindingStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
|
||||
//
|
||||
// Retrieve the MNP service binding protocol from the ControllerHandle.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
MNP_DEBUG_ERROR (
|
||||
("MnpDriverBindingStop: Locate MNP Service Binding Protocol failed, %r.\n",
|
||||
Status)
|
||||
);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_THIS (ServiceBinding);
|
||||
|
||||
while (!NetListIsEmpty (&MnpServiceData->ChildrenList)) {
|
||||
//
|
||||
// Don't use NetListRemoveHead here, the remove opreration will be done
|
||||
// in ServiceBindingDestroyChild.
|
||||
//
|
||||
Instance = NET_LIST_HEAD (
|
||||
&MnpServiceData->ChildrenList,
|
||||
MNP_INSTANCE_DATA,
|
||||
InstEntry
|
||||
);
|
||||
|
||||
ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
|
||||
}
|
||||
|
||||
//
|
||||
// Uninstall the MNP Service Binding Protocol.
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ControllerHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
ServiceBinding,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
MNP_DEBUG_ERROR (("MnpDriverBindingStop: Uninstall MNP Service Binding Protocol failed, %r.\n"));
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the openned Snp protocol.
|
||||
//
|
||||
Status = gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
MNP_DEBUG_ERROR (("MnpDriverBindingStop: Close SNP Protocol failed, %r.\n", Status));
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Flush the Mnp service data.
|
||||
//
|
||||
MnpFlushServiceData (MnpServiceData);
|
||||
|
||||
NetFreePool (MnpServiceData);
|
||||
|
||||
EXIT:
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Creates a child handle with a set of I/O services.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ChildHandle Pointer to the handle of the child to create. If
|
||||
it is NULL, then a new handle is created. If it is
|
||||
not NULL, then the I/O services are added to the
|
||||
existing child handle.
|
||||
|
||||
@retval EFI_SUCCES The child handle was created with the I/O
|
||||
services.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
|
||||
the child.
|
||||
@retval other The child handle was not created.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpServiceBindingCreateChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE *ChildHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
VOID *Snp;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (ChildHandle == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_THIS (This);
|
||||
|
||||
//
|
||||
// Allocate buffer for the new instance.
|
||||
//
|
||||
Instance = NetAllocateZeroPool (sizeof (MNP_INSTANCE_DATA));
|
||||
if (Instance == NULL) {
|
||||
|
||||
MNP_DEBUG_ERROR (("MnpServiceBindingCreateChild: Faild to allocate memory for the new instance.\n"));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Init the instance data.
|
||||
//
|
||||
MnpInitializeInstanceData (MnpServiceData, Instance);
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
ChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
&Instance->ManagedNetwork,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
MNP_DEBUG_ERROR (
|
||||
("MnpServiceBindingCreateChild: Failed to install the MNP protocol, %r.\n",
|
||||
Status)
|
||||
);
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Save the instance's childhandle.
|
||||
//
|
||||
Instance->Handle = *ChildHandle;
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
MnpServiceData->ControllerHandle,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
(VOID **) &Snp,
|
||||
gMnpDriverBinding.DriverBindingHandle,
|
||||
Instance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Add the child instance into ChildrenList.
|
||||
//
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
NetListInsertTail (&MnpServiceData->ChildrenList, &Instance->InstEntry);
|
||||
MnpServiceData->ChildrenNumber++;
|
||||
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
ErrorExit:
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
if (Instance->Handle != NULL) {
|
||||
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
&Instance->ManagedNetwork,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
NetFreePool (Instance);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroys a child handle with a set of I/O services.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ChildHandle Handle of the child to destroy.
|
||||
|
||||
@retval EFI_SUCCES The I/O services were removed from the child
|
||||
handle.
|
||||
@retval EFI_UNSUPPORTED The child handle does not support the I/O services
|
||||
that are being removed.
|
||||
@retval EFI_INVALID_PARAMETER Child handle is not a valid EFI Handle.
|
||||
@retval EFI_ACCESS_DENIED The child handle could not be destroyed because
|
||||
its I/O services are being used.
|
||||
@retval other The child handle was not destroyed.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *ManagedNetwork;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (ChildHandle == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_THIS (This);
|
||||
|
||||
//
|
||||
// Try to retrieve ManagedNetwork Protocol from ChildHandle.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
(VOID **) &ManagedNetwork,
|
||||
gMnpDriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (ManagedNetwork);
|
||||
|
||||
//
|
||||
// MnpServiceBindingDestroyChild may be called twice: first called by
|
||||
// MnpServiceBindingStop, second called by uninstalling the MNP protocol
|
||||
// in this ChildHandle. Use destroyed to make sure the resource clean code
|
||||
// will only excecute once.
|
||||
//
|
||||
if (Instance->Destroyed) {
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Instance->Destroyed = TRUE;
|
||||
|
||||
//
|
||||
// Close the Simple Network protocol.
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
MnpServiceData->ControllerHandle,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
gMnpDriverBinding.DriverBindingHandle,
|
||||
ChildHandle
|
||||
);
|
||||
|
||||
//
|
||||
// Uninstall the ManagedNetwork protocol.
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
&Instance->ManagedNetwork,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
MNP_DEBUG_ERROR (
|
||||
("MnpServiceBindingDestroyChild: Failed to uninstall the ManagedNetwork protocol, %r.\n",
|
||||
Status)
|
||||
);
|
||||
|
||||
Instance->Destroyed = FALSE;
|
||||
return Status;
|
||||
}
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
//
|
||||
// Reset the configuration.
|
||||
//
|
||||
ManagedNetwork->Configure (ManagedNetwork, NULL);
|
||||
|
||||
//
|
||||
// Try to flush the RcvdPacketQueue.
|
||||
//
|
||||
MnpFlushRcvdDataQueue (Instance);
|
||||
|
||||
//
|
||||
// Clean the RxTokenMap.
|
||||
//
|
||||
NetMapClean (&Instance->RxTokenMap);
|
||||
|
||||
//
|
||||
// Remove this instance from the ChildrenList.
|
||||
//
|
||||
NetListRemoveEntry (&Instance->InstEntry);
|
||||
MnpServiceData->ChildrenNumber--;
|
||||
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
NetFreePool (Instance);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
//@MT: EFI_DRIVER_ENTRY_POINT (MnpDriverEntryPoint)
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpDriverEntryPoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
The entry point for Mnp driver which installs the driver binding and component name
|
||||
protocol on its ImageHandle.
|
||||
|
||||
Arguments:
|
||||
|
||||
ImageHandle - The image handle of the driver.
|
||||
SystemTable - The system table.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - If the driver binding and component name protocols are successfully
|
||||
installed, otherwise if failed.
|
||||
|
||||
--*/
|
||||
{
|
||||
return NetLibInstallAllDriverProtocols (
|
||||
ImageHandle,
|
||||
SystemTable,
|
||||
&gMnpDriverBinding,
|
||||
ImageHandle,
|
||||
&gMnpComponentName,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
136
MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
Normal file
136
MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2005 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
MnpDriver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _MNP_DRIVER_H_
|
||||
#define _MNP_DRIVER_H_
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Protocol/ManagedNetwork.h>
|
||||
#include <Protocol/SimpleNetwork.h>
|
||||
#include <Protocol/ServiceBinding.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/NetLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
||||
#include "MnpDebug.h"
|
||||
|
||||
//
|
||||
// Required Global Variables
|
||||
//
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName;
|
||||
|
||||
#define MNP_SERVICE_DATA_SIGNATURE EFI_SIGNATURE_32 ('M', 'n', 'p', 'S')
|
||||
|
||||
typedef struct _MNP_SERVICE_DATA {
|
||||
UINT32 Signature;
|
||||
|
||||
EFI_HANDLE ControllerHandle;
|
||||
|
||||
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||
|
||||
UINT32 Mtu;
|
||||
|
||||
NET_LIST_ENTRY ChildrenList;
|
||||
UINTN ChildrenNumber;
|
||||
UINTN ConfiguredChildrenNumber;
|
||||
|
||||
NET_LIST_ENTRY GroupAddressList;
|
||||
UINT32 GroupAddressCount;
|
||||
|
||||
EFI_EVENT TxTimeoutEvent;
|
||||
|
||||
NET_BUF_QUEUE FreeNbufQue;
|
||||
INTN NbufCnt;
|
||||
|
||||
EFI_EVENT PollTimer;
|
||||
BOOLEAN EnableSystemPoll;
|
||||
|
||||
EFI_EVENT TimeoutCheckTimer;
|
||||
|
||||
UINT32 UnicastCount;
|
||||
UINT32 BroadcastCount;
|
||||
UINT32 MulticastCount;
|
||||
UINT32 PromiscuousCount;
|
||||
|
||||
//
|
||||
// The size of the data buffer in the MNP_PACKET_BUFFER used to
|
||||
// store a packet.
|
||||
//
|
||||
UINT32 BufferLength;
|
||||
NET_BUF *RxNbufCache;
|
||||
UINT8 *TxBuf;
|
||||
} MNP_SERVICE_DATA;
|
||||
|
||||
#define MNP_SERVICE_DATA_FROM_THIS(a) \
|
||||
CR ( \
|
||||
(a), \
|
||||
MNP_SERVICE_DATA, \
|
||||
ServiceBinding, \
|
||||
MNP_SERVICE_DATA_SIGNATURE \
|
||||
)
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpDriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL * This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpDriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL * This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpDriverBindingStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpServiceBindingCreateChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE *ChildHandle
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
#endif
|
63
MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
Normal file
63
MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
Normal file
@@ -0,0 +1,63 @@
|
||||
#/** @file
|
||||
# Component name for module Mnp
|
||||
#
|
||||
# FIX ME!
|
||||
# Copyright (c) 2006, Intel Corporation. All right reserved.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = MnpDxe
|
||||
FILE_GUID = 025BBFC7-E6A9-4b8b-82AD-6815A1AEAF4A
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
ENTRY_POINT = MnpDriverEntryPoint
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
MnpDebug.h
|
||||
MnpMain.c
|
||||
MnpIo.c
|
||||
MnpDriver.h
|
||||
ComponentName.c
|
||||
MnpDriver.c
|
||||
MnpConfig.c
|
||||
MnpImpl.h
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
UefiLib
|
||||
UefiBootServicesTableLib
|
||||
UefiDriverEntryPoint
|
||||
DebugLib
|
||||
NetLib
|
||||
|
||||
|
||||
[Protocols]
|
||||
gEfiManagedNetworkServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiManagedNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
|
70
MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.msa
Normal file
70
MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.msa
Normal file
@@ -0,0 +1,70 @@
|
||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>MnpDxe</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>025BBFC7-E6A9-4b8b-82AD-6815A1AEAF4A</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component name for module Mnp</Abstract>
|
||||
<Description>FIX ME!</Description>
|
||||
<Copyright>Copyright (c) 2006, Intel Corporation. All right reserved.</Copyright>
|
||||
<License>All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>MnpDxe</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiDriverEntryPoint</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>MnpImpl.h</Filename>
|
||||
<Filename>MnpConfig.c</Filename>
|
||||
<Filename>MnpDriver.c</Filename>
|
||||
<Filename>ComponentName.c</Filename>
|
||||
<Filename>MnpDriver.h</Filename>
|
||||
<Filename>MnpIo.c</Filename>
|
||||
<Filename>MnpMain.c</Filename>
|
||||
<Filename>MnpDebug.h</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Protocols>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiManagedNetworkProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiSimpleNetworkProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiManagedNetworkServiceBindingProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
</Protocols>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
<Extern>
|
||||
<ModuleEntryPoint>MnpDriverEntryPoint</ModuleEntryPoint>
|
||||
</Extern>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
274
MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h
Normal file
274
MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h
Normal file
@@ -0,0 +1,274 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2005 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
MnpImpl.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _MNP_IMPL_H_
|
||||
#define _MNP_IMPL_H_
|
||||
|
||||
#include "MnpDriver.h"
|
||||
#include "MnpDebug.h"
|
||||
|
||||
#define NET_ETHER_FCS_SIZE 4
|
||||
|
||||
#define MNP_SYS_POLL_INTERVAL (2 * TICKS_PER_MS) // 2 milliseconds
|
||||
#define MNP_TIMEOUT_CHECK_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds
|
||||
#define MNP_TX_TIMEOUT_TIME (500 * TICKS_PER_MS) // 500 milliseconds
|
||||
#define MNP_INIT_NET_BUFFER_NUM 512
|
||||
#define MNP_NET_BUFFER_INCREASEMENT 64
|
||||
#define MNP_MAX_NET_BUFFER_NUM 65536
|
||||
|
||||
#define MNP_MAX_RCVD_PACKET_QUE_SIZE 256
|
||||
|
||||
#define MNP_RECEIVE_UNICAST 0x01
|
||||
#define MNP_RECEIVE_BROADCAST 0x02
|
||||
|
||||
#define UNICAST_PACKET MNP_RECEIVE_UNICAST
|
||||
#define BROADCAST_PACKET MNP_RECEIVE_BROADCAST
|
||||
|
||||
#define MNP_INSTANCE_DATA_SIGNATURE EFI_SIGNATURE_32 ('M', 'n', 'p', 'I')
|
||||
|
||||
#define MNP_INSTANCE_DATA_FROM_THIS(a) \
|
||||
CR ( \
|
||||
(a), \
|
||||
MNP_INSTANCE_DATA, \
|
||||
ManagedNetwork, \
|
||||
MNP_INSTANCE_DATA_SIGNATURE \
|
||||
)
|
||||
|
||||
typedef struct _MNP_INSTANCE_DATA {
|
||||
UINT32 Signature;
|
||||
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
|
||||
EFI_HANDLE Handle;
|
||||
|
||||
NET_LIST_ENTRY InstEntry;
|
||||
|
||||
EFI_MANAGED_NETWORK_PROTOCOL ManagedNetwork;
|
||||
|
||||
BOOLEAN Configured;
|
||||
BOOLEAN Destroyed;
|
||||
|
||||
NET_LIST_ENTRY GroupCtrlBlkList;
|
||||
|
||||
NET_MAP RxTokenMap;
|
||||
|
||||
NET_LIST_ENTRY RxDeliveredPacketQueue;
|
||||
NET_LIST_ENTRY RcvdPacketQueue;
|
||||
UINTN RcvdPacketQueueSize;
|
||||
|
||||
EFI_MANAGED_NETWORK_CONFIG_DATA ConfigData;
|
||||
|
||||
UINT8 ReceiveFilter;
|
||||
} MNP_INSTANCE_DATA;
|
||||
|
||||
typedef struct _MNP_GROUP_ADDRESS {
|
||||
NET_LIST_ENTRY AddrEntry;
|
||||
EFI_MAC_ADDRESS Address;
|
||||
INTN RefCnt;
|
||||
} MNP_GROUP_ADDRESS;
|
||||
|
||||
typedef struct _MNP_GROUP_CONTROL_BLOCK {
|
||||
NET_LIST_ENTRY CtrlBlkEntry;
|
||||
MNP_GROUP_ADDRESS *GroupAddress;
|
||||
} MNP_GROUP_CONTROL_BLOCK;
|
||||
|
||||
typedef struct _MNP_RXDATA_WRAP {
|
||||
NET_LIST_ENTRY WrapEntry;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
EFI_MANAGED_NETWORK_RECEIVE_DATA RxData;
|
||||
NET_BUF *Nbuf;
|
||||
UINT64 TimeoutTick;
|
||||
} MNP_RXDATA_WRAP;
|
||||
|
||||
EFI_STATUS
|
||||
MnpInitializeServiceData (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData,
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_HANDLE ControllerHandle
|
||||
);
|
||||
|
||||
VOID
|
||||
MnpFlushServiceData (
|
||||
MNP_SERVICE_DATA *MnpServiceData
|
||||
);
|
||||
|
||||
VOID
|
||||
MnpInitializeInstanceData (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData,
|
||||
IN MNP_INSTANCE_DATA *Instance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
MnpTokenExist (
|
||||
IN NET_MAP *Map,
|
||||
IN NET_MAP_ITEM *Item,
|
||||
IN VOID *Arg
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
MnpCancelTokens (
|
||||
IN NET_MAP *Map,
|
||||
IN NET_MAP_ITEM *Item,
|
||||
IN VOID *Arg
|
||||
);
|
||||
|
||||
VOID
|
||||
MnpFlushRcvdDataQueue (
|
||||
IN MNP_INSTANCE_DATA *Instance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
MnpConfigureInstance (
|
||||
IN MNP_INSTANCE_DATA *Instance,
|
||||
IN EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
MnpGroupOp (
|
||||
IN MNP_INSTANCE_DATA *Instance,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_MAC_ADDRESS *MacAddr OPTIONAL,
|
||||
IN MNP_GROUP_CONTROL_BLOCK *CtrlBlk OPTIONAL
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
MnpIsValidTxToken (
|
||||
IN MNP_INSTANCE_DATA *Instance,
|
||||
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
VOID
|
||||
MnpBuildTxPacket (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData,
|
||||
IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
|
||||
OUT UINT8 **PktBuf,
|
||||
OUT UINT32 *PktLen
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
MnpSyncSendPacket (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData,
|
||||
IN UINT8 *Packet,
|
||||
IN UINT32 Length,
|
||||
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
MnpInstanceDeliverPacket (
|
||||
IN MNP_INSTANCE_DATA *Instance
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
MnpRecycleRxData (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
MnpReceivePacket (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData
|
||||
);
|
||||
|
||||
NET_BUF *
|
||||
MnpAllocNbuf (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData
|
||||
);
|
||||
|
||||
VOID
|
||||
MnpFreeNbuf (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData,
|
||||
IN NET_BUF *Nbuf
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
MnpCheckPacketTimeout (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
MnpSystemPoll (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpGetModeData (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
|
||||
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpConfigure (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpMcastIpToMac (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN BOOLEAN Ipv6Flag,
|
||||
IN EFI_IP_ADDRESS *IpAddress,
|
||||
OUT EFI_MAC_ADDRESS *MacAddress
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpGroups (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpTransmit (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpCancel (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpReceive (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpPoll (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This
|
||||
);
|
||||
|
||||
#endif
|
1087
MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c
Normal file
1087
MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c
Normal file
File diff suppressed because it is too large
Load Diff
655
MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c
Normal file
655
MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c
Normal file
@@ -0,0 +1,655 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2005 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
MnpMain.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Implementation of Managed Network Protocol public services.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
|
||||
#include "MnpImpl.h"
|
||||
|
||||
|
||||
/**
|
||||
Get configuration data of this instance.
|
||||
|
||||
@param This Pointer to the Managed Network Protocol.
|
||||
@param MnpConfigData Pointer to strorage for MNP operational
|
||||
parameters.
|
||||
@param SnpModeData Pointer to strorage for SNP operational
|
||||
parameters.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL.
|
||||
@retval EFI_NOT_STARTED This MNP child driver instance has not been
|
||||
configured The default values are returned in
|
||||
MnpConfigData if it is not NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpGetModeData (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
|
||||
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
|
||||
)
|
||||
{
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (This == NULL) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
if (MnpConfigData != NULL) {
|
||||
//
|
||||
// Copy the instance configuration data.
|
||||
//
|
||||
*MnpConfigData = Instance->ConfigData;
|
||||
}
|
||||
|
||||
if (SnpModeData != NULL) {
|
||||
//
|
||||
// Copy the underlayer Snp mode data.
|
||||
//
|
||||
Snp = Instance->MnpServiceData->Snp;
|
||||
*SnpModeData = *(Snp->Mode);
|
||||
}
|
||||
|
||||
if (!Instance->Configured) {
|
||||
Status = EFI_NOT_STARTED;
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set or clear the operational parameters for the MNP child driver.
|
||||
|
||||
@param This Pointer to the Managed Network Protocol.
|
||||
@param MnpConfigData Pointer to the configuration data that will be
|
||||
assigned to the MNP child driver instance. If
|
||||
NULL, the MNP child driver instance is reset to
|
||||
startup defaults and all pending transmit and
|
||||
receive requests are flushed.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_INVALID_PARAMETER One or more parameter is invalid.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources (usually memory) could
|
||||
not be allocated.
|
||||
@retval EFI_UNSUPPORTED EnableReceiveTimestamps is TRUE, this
|
||||
implementation doesn't support it.
|
||||
@retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
|
||||
@retval Other The MNP child driver instance has been reset to
|
||||
startup defaults.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpConfigure (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL
|
||||
)
|
||||
{
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ((This == NULL) ||
|
||||
((MnpConfigData != NULL) &&
|
||||
(MnpConfigData->ProtocolTypeFilter > 0) &&
|
||||
(MnpConfigData->ProtocolTypeFilter <= 1500))) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
if ((MnpConfigData == NULL) && (!Instance->Configured)) {
|
||||
//
|
||||
// If the instance is not configured and a reset is requested, just return.
|
||||
//
|
||||
Status = EFI_SUCCESS;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Configure the instance.
|
||||
//
|
||||
Status = MnpConfigureInstance (Instance, MnpConfigData);
|
||||
|
||||
ON_EXIT:
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Translate a multicast IP address to a multicast hardware (MAC) address.
|
||||
|
||||
@param This Pointer to the Managed Network Protocol.
|
||||
@param Ipv6Flag Set to TRUE if IpAddress is an IPv6 multicast
|
||||
address. Set to FALSE if IpAddress is an IPv4
|
||||
multicast address.
|
||||
@param IpAddress Pointer to the multicast IP address to convert.
|
||||
@param MacAddress Pointer to the resulting multicast MAC address.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_INVALID_PARAMETER One or more parameter is invalid.
|
||||
@retval EFI_NOT_STARTED This MNP child driver instance has not been
|
||||
configured.
|
||||
@retval EFI_UNSUPPORTED Ipv6Flag is TRUE, this implementation doesn't
|
||||
supported it.
|
||||
@retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
|
||||
@retval Other The address could not be converted.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpMcastIpToMac (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN BOOLEAN Ipv6Flag,
|
||||
IN EFI_IP_ADDRESS *IpAddress,
|
||||
OUT EFI_MAC_ADDRESS *MacAddress
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (IpAddress == NULL) || (MacAddress == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Ipv6Flag) {
|
||||
//
|
||||
// Currently IPv6 isn't supported.
|
||||
//
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (!IP4_IS_MULTICAST (EFI_NTOHL (*IpAddress))) {
|
||||
//
|
||||
// The IPv4 address passed in is not a multicast address.
|
||||
//
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
if (!Instance->Configured) {
|
||||
|
||||
Status = EFI_NOT_STARTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Snp = Instance->MnpServiceData->Snp;
|
||||
ASSERT (Snp != NULL);
|
||||
|
||||
if (Snp->Mode->IfType == NET_IFTYPE_ETHERNET) {
|
||||
//
|
||||
// Translate the IPv4 address into a multicast MAC address if the NIC is an
|
||||
// ethernet NIC.
|
||||
//
|
||||
MacAddress->Addr[0] = 0x01;
|
||||
MacAddress->Addr[1] = 0x00;
|
||||
MacAddress->Addr[2] = 0x5E;
|
||||
MacAddress->Addr[3] = IpAddress->v4.Addr[1] & 0x7F;
|
||||
MacAddress->Addr[4] = IpAddress->v4.Addr[2];
|
||||
MacAddress->Addr[5] = IpAddress->v4.Addr[3];
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
} else {
|
||||
//
|
||||
// Invoke Snp to translate the multicast IP address.
|
||||
//
|
||||
Status = Snp->MCastIpToMac (
|
||||
Snp,
|
||||
Ipv6Flag,
|
||||
IpAddress,
|
||||
MacAddress
|
||||
);
|
||||
}
|
||||
|
||||
ON_EXIT:
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enable or disable receie filters for multicast address.
|
||||
|
||||
@param This Pointer to the Managed Network Protocol.
|
||||
@param JoinFlag Set to TRUE to join this multicast group. Set to
|
||||
FALSE to leave this multicast group.
|
||||
@param MacAddress Pointer to the multicast MAC group (address) to
|
||||
join or leave.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_INVALID_PARAMETER One or more parameter is invalid
|
||||
@retval EFI_NOT_STARTED This MNP child driver instance has not been
|
||||
configured.
|
||||
@retval EFI_ALREADY_STARTED The supplied multicast group is already joined.
|
||||
@retval EFI_NOT_FOUND The supplied multicast group is not joined.
|
||||
@retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
|
||||
@retval Other The requested operation could not be completed.
|
||||
The MNP multicast group settings are unchanged.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpGroups (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL
|
||||
)
|
||||
{
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
EFI_SIMPLE_NETWORK_MODE *SnpMode;
|
||||
MNP_GROUP_CONTROL_BLOCK *GroupCtrlBlk;
|
||||
MNP_GROUP_ADDRESS *GroupAddress;
|
||||
NET_LIST_ENTRY *ListEntry;
|
||||
BOOLEAN AddressExist;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (This == NULL || (JoinFlag && (MacAddress == NULL))) {
|
||||
//
|
||||
// This is NULL, or it's a join operation but MacAddress is NULL.
|
||||
//
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
|
||||
SnpMode = Instance->MnpServiceData->Snp->Mode;
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
if (!Instance->Configured) {
|
||||
|
||||
Status = EFI_NOT_STARTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if ((!Instance->ConfigData.EnableMulticastReceive) ||
|
||||
((MacAddress != NULL) && !NET_MAC_IS_MULTICAST (MacAddress, &SnpMode->BroadcastAddress, SnpMode->HwAddressSize))) {
|
||||
//
|
||||
// The instance isn't configured to do mulitcast receive. OR
|
||||
// the passed in MacAddress is not a mutlticast mac address.
|
||||
//
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
AddressExist = FALSE;
|
||||
GroupCtrlBlk = NULL;
|
||||
|
||||
if (MacAddress != NULL) {
|
||||
//
|
||||
// Search the instance's GroupCtrlBlkList to find the specific address.
|
||||
//
|
||||
NET_LIST_FOR_EACH (ListEntry, &Instance->GroupCtrlBlkList) {
|
||||
|
||||
GroupCtrlBlk = NET_LIST_USER_STRUCT (
|
||||
ListEntry,
|
||||
MNP_GROUP_CONTROL_BLOCK,
|
||||
CtrlBlkEntry
|
||||
);
|
||||
GroupAddress = GroupCtrlBlk->GroupAddress;
|
||||
if (0 == NetCompareMem (
|
||||
MacAddress,
|
||||
&GroupAddress->Address,
|
||||
SnpMode->HwAddressSize
|
||||
)) {
|
||||
//
|
||||
// There is already the same multicast mac address configured.
|
||||
//
|
||||
AddressExist = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (JoinFlag && AddressExist) {
|
||||
//
|
||||
// The multicast mac address to join already exists.
|
||||
//
|
||||
Status = EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
if (!JoinFlag && !AddressExist) {
|
||||
//
|
||||
// The multicast mac address to leave doesn't exist in this instance.
|
||||
//
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
} else if (NetListIsEmpty (&Instance->GroupCtrlBlkList)) {
|
||||
//
|
||||
// The MacAddress is NULL and there is no configured multicast mac address,
|
||||
// just return.
|
||||
//
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// OK, it is time to take action.
|
||||
//
|
||||
Status = MnpGroupOp (Instance, JoinFlag, MacAddress, GroupCtrlBlk);
|
||||
|
||||
ON_EXIT:
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Place an outgoing packet into the transmit queue.
|
||||
|
||||
@param This Pointer to the Managed Network Protocol.
|
||||
@param Token Pointer to a token associated with the transmit
|
||||
data descriptor.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_INVALID_PARAMETER One or more parameter is invalid
|
||||
@retval EFI_NOT_STARTED This MNP child driver instance has not been
|
||||
configured.
|
||||
@retval EFI_ACCESS_DENIED The transmit completion token is already in the
|
||||
transmit queue.
|
||||
@retval EFI_OUT_OF_RESOURCES The transmit data could not be queued due to a
|
||||
lack of system resources (usually memory).
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
The MNP child driver instance has been reset to
|
||||
startup defaults.
|
||||
@retval EFI_NOT_READY The transmit request could not be queued because
|
||||
the transmit queue is full.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpTransmit (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
UINT8 *PktBuf;
|
||||
UINT32 PktLen;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (Token == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
if (!Instance->Configured) {
|
||||
|
||||
Status = EFI_NOT_STARTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if (!MnpIsValidTxToken (Instance, Token)) {
|
||||
//
|
||||
// The Token is invalid.
|
||||
//
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
MnpServiceData = Instance->MnpServiceData;
|
||||
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
|
||||
|
||||
//
|
||||
// Build the tx packet
|
||||
//
|
||||
MnpBuildTxPacket (MnpServiceData, Token->Packet.TxData, &PktBuf, &PktLen);
|
||||
|
||||
//
|
||||
// OK, send the packet synchronously.
|
||||
//
|
||||
Status = MnpSyncSendPacket (MnpServiceData, PktBuf, PktLen, Token);
|
||||
|
||||
ON_EXIT:
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Place an asynchronous receiving request into the receiving queue.
|
||||
|
||||
@param This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL
|
||||
instance.
|
||||
@param Token Pointer to a token associated with the receive
|
||||
data descriptor.
|
||||
|
||||
@retval EFI_SUCCESS The receive completion token was cached.
|
||||
@retval EFI_NOT_STARTED This MNP child driver instance has not been
|
||||
configured.
|
||||
@retval EFI_INVALID_PARAMETER One or more parameter is invalid.
|
||||
@retval EFI_OUT_OF_RESOURCES The transmit data could not be queued due to a
|
||||
lack of system resources (usually memory).
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
The MNP child driver instance has been reset to
|
||||
startup defaults.
|
||||
@retval EFI_ACCESS_DENIED The receive completion token was already in the
|
||||
receive queue.
|
||||
@retval EFI_NOT_READY The receive request could not be queued because
|
||||
the receive queue is full.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpReceive (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (Token == NULL) || (Token->Event == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
if (!Instance->Configured) {
|
||||
|
||||
Status = EFI_NOT_STARTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether this token(event) is already in the rx token queue.
|
||||
//
|
||||
Status = NetMapIterate (&Instance->RxTokenMap, MnpTokenExist, (VOID *) Token);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Insert the Token into the RxTokenMap.
|
||||
//
|
||||
Status = NetMapInsertTail (&Instance->RxTokenMap, (VOID *) Token, NULL);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// Try to deliver any buffered packets.
|
||||
//
|
||||
Status = MnpInstanceDeliverPacket (Instance);
|
||||
}
|
||||
|
||||
ON_EXIT:
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Abort a pending transmit or receive request.
|
||||
|
||||
@param This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL
|
||||
instance.
|
||||
@param Token Pointer to a token that has been issued by
|
||||
EFI_MANAGED_NETWORK_PROTOCOL.Transmit() or
|
||||
EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL,
|
||||
all pending tokens are aborted.
|
||||
|
||||
@retval EFI_SUCCESS The asynchronous I/O request was aborted and
|
||||
Token->Event was signaled.
|
||||
@retval EFI_NOT_STARTED This MNP child driver instance has not been
|
||||
configured.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL.
|
||||
@retval EFI_NOT_FOUND The asynchronous I/O request was not found in the
|
||||
transmit or receive queue. It has either completed
|
||||
or was not issued by Transmit() and Receive().
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpCancel (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
|
||||
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if (This == NULL) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
if (!Instance->Configured) {
|
||||
|
||||
Status = EFI_NOT_STARTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Iterate the RxTokenMap to cancel the specified Token.
|
||||
//
|
||||
Status = NetMapIterate (&Instance->RxTokenMap, MnpCancelTokens, (VOID *) Token);
|
||||
|
||||
if (Token != NULL) {
|
||||
|
||||
Status = (Status == EFI_ABORTED) ? EFI_SUCCESS : EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
ON_EXIT:
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Poll the network interface to do transmit/receive work.
|
||||
|
||||
@param This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL
|
||||
instance.
|
||||
|
||||
@retval EFI_SUCCESS Incoming or outgoing data was processed.
|
||||
@retval EFI_NOT_STARTED This MNP child driver instance has not been
|
||||
configured.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
The MNP child driver instance has been reset to
|
||||
startup defaults.
|
||||
@retval EFI_NOT_READY No incoming or outgoing data was processed.
|
||||
@retval EFI_TIMEOUT Data was dropped out of the transmit and/or
|
||||
receive queue.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpPoll (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if (This == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
|
||||
|
||||
if (!Instance->Configured) {
|
||||
Status = EFI_NOT_STARTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to receive packets.
|
||||
//
|
||||
Status = MnpReceivePacket (Instance->MnpServiceData);
|
||||
|
||||
ON_EXIT:
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
}
|
Reference in New Issue
Block a user