Update to support to produce Component Name and & Component Name 2 protocol based on Feature flag PcdComponentNameDisable & PcdComponentName2Disable.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4006 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2007-09-30 03:08:02 +00:00
parent 5bca971e54
commit 83cbd279b6
68 changed files with 11129 additions and 9421 deletions

View File

@@ -24,6 +24,45 @@ Abstract:
//
// EFI Component Name Functions
//
/**
Retrieves a Unicode string that is the user readable name of the driver.
This function retrieves the user readable name of a driver in the form of a
Unicode string. If the driver specified by This has a user readable name in
the language specified by Language, then a pointer to the driver name is
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name 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. Language is specified
in RFC 3066 or ISO 639-2 language code format.
@param DriverName[out] 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.
@retval EFI_SUCCESS The Unicode string for the Driver specified by
This and the language specified by Language was
returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
MnpComponentNameGetDriverName (
@@ -32,6 +71,75 @@ MnpComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
This function retrieves the user readable name of the controller specified by
ControllerHandle and ChildHandle in the form of a Unicode string. If the
driver specified by This has a user readable name in the language specified by
Language, then a pointer to the controller name is returned in ControllerName,
and EFI_SUCCESS is returned. If the driver specified by This is not currently
managing the controller specified by ControllerHandle and ChildHandle,
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle[in] The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param ChildHandle[in] 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.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name 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. Language is specified in
RFC 3066 or ISO 639-2 language code format.
@param ControllerName[out] 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.
@retval 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.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently
managing the controller specified by
ControllerHandle and ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
MnpComponentNameGetControllerName (
@@ -42,18 +150,29 @@ MnpComponentNameGetControllerName (
OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName = {
EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName = {
MnpComponentNameGetDriverName,
MnpComponentNameGetControllerName,
"eng"
};
};
//
// EFI Component Name 2 Protocol
//
EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) MnpComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) MnpComponentNameGetControllerName,
"en"
};
STATIC EFI_UNICODE_STRING_TABLE mMnpDriverNameTable[] = {
{
"eng",
"eng;en",
L"MNP Network Service Driver"
},
{
@@ -62,6 +181,45 @@ STATIC EFI_UNICODE_STRING_TABLE mMnpDriverNameTable[] = {
}
};
/**
Retrieves a Unicode string that is the user readable name of the driver.
This function retrieves the user readable name of a driver in the form of a
Unicode string. If the driver specified by This has a user readable name in
the language specified by Language, then a pointer to the driver name is
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name 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. Language is specified
in RFC 3066 or ISO 639-2 language code format.
@param DriverName[out] 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.
@retval EFI_SUCCESS The Unicode string for the Driver specified by
This and the language specified by Language was
returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
MnpComponentNameGetDriverName (
@@ -69,41 +227,84 @@ MnpComponentNameGetDriverName (
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
);
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mMnpDriverNameTable,
DriverName,
(BOOLEAN)(This == &gMnpComponentName)
);
}
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
This function retrieves the user readable name of the controller specified by
ControllerHandle and ChildHandle in the form of a Unicode string. If the
driver specified by This has a user readable name in the language specified by
Language, then a pointer to the controller name is returned in ControllerName,
and EFI_SUCCESS is returned. If the driver specified by This is not currently
managing the controller specified by ControllerHandle and ChildHandle,
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle[in] The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param ChildHandle[in] 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.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name 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. Language is specified in
RFC 3066 or ISO 639-2 language code format.
@param ControllerName[out] 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.
@retval 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.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently
managing the controller specified by
ControllerHandle and ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
MnpComponentNameGetControllerName (
@@ -113,50 +314,6 @@ MnpComponentNameGetControllerName (
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;
}

View File

@@ -1,28 +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
/** @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

View File

@@ -547,13 +547,12 @@ Returns:
--*/
{
return EfiLibInstallAllDriverProtocols (
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gMnpDriverBinding,
ImageHandle,
&gMnpComponentName,
NULL,
NULL
&gMnpComponentName2
);
}

View File

@@ -1,137 +1,138 @@
/** @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_
/** @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/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/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;
UINT32 PaddingSize;
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
#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;
extern EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2;
#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;
UINT32 PaddingSize;
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

View File

@@ -1,274 +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
/** @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