NetworkPkg: Move Network library and drivers from MdeModulePkg to NetworkPkg
Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Siyuan Fu <siyuan.fu@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
This commit is contained in:
164
NetworkPkg/VlanConfigDxe/ComponentName.c
Normal file
164
NetworkPkg/VlanConfigDxe/ComponentName.c
Normal file
@@ -0,0 +1,164 @@
|
||||
/** @file
|
||||
UEFI Component Name(2) protocol implementation for VlanConfigDxe driver.
|
||||
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include "VlanConfigImpl.h"
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gVlanConfigComponentName = {
|
||||
VlanConfigComponentNameGetDriverName,
|
||||
VlanConfigComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gVlanConfigComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) VlanConfigComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) VlanConfigComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVlanConfigDriverNameTable[] = {
|
||||
{
|
||||
"eng;en",
|
||||
L"VLAN Configuration Driver"
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// 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 4646 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
|
||||
VlanConfigComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
{
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
mVlanConfigDriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN)(This == &gVlanConfigComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
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 4646 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 NULL.
|
||||
@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
|
||||
VlanConfigComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
72
NetworkPkg/VlanConfigDxe/VlanConfig.vfr
Normal file
72
NetworkPkg/VlanConfigDxe/VlanConfig.vfr
Normal file
@@ -0,0 +1,72 @@
|
||||
///** @file
|
||||
// VLAN configuration formset.
|
||||
//
|
||||
// Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
//**/
|
||||
|
||||
#include "VlanConfigNvData.h"
|
||||
|
||||
formset
|
||||
guid = VLAN_CONFIG_FORM_SET_GUID,
|
||||
title = STRING_TOKEN(STR_VLAN_FORM_SET_TITLE),
|
||||
help = STRING_TOKEN(STR_VLAN_FORM_SET_TITLE_HELP),
|
||||
classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
|
||||
|
||||
varstore VLAN_CONFIGURATION,
|
||||
varid = VLAN_CONFIGURATION_VARSTORE_ID,
|
||||
name = VlanNvData,
|
||||
guid = VLAN_CONFIG_FORM_SET_GUID;
|
||||
|
||||
form formid = VLAN_HEAD_FORM_ID,
|
||||
title = STRING_TOKEN(STR_VLAN_FORM_TITLE);
|
||||
|
||||
goto VLAN_CONFIGURATION_FORM_ID,
|
||||
prompt = STRING_TOKEN (STR_GET_CURRENT_SETTING),
|
||||
help = STRING_TOKEN (STR_GET_CURRENT_SETTING_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = VLAN_UPDATE_QUESTION_ID;
|
||||
|
||||
endform;
|
||||
|
||||
form formid = VLAN_CONFIGURATION_FORM_ID,
|
||||
title = STRING_TOKEN(STR_VLAN_FORM_TITLE);
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_VLAN_CREATE_VLAN);
|
||||
|
||||
numeric varid = VlanNvData.VlanId,
|
||||
prompt = STRING_TOKEN(STR_VLAN_VID_PROMPT),
|
||||
help = STRING_TOKEN(STR_VLAN_VID_HELP),
|
||||
minimum = 0,
|
||||
maximum = 4094,
|
||||
endnumeric;
|
||||
|
||||
numeric varid = VlanNvData.Priority,
|
||||
prompt = STRING_TOKEN(STR_VLAN_PRIORITY_PROMPT),
|
||||
help = STRING_TOKEN(STR_VLAN_PRIORITY_HELP),
|
||||
minimum = 0,
|
||||
maximum = 7,
|
||||
endnumeric;
|
||||
|
||||
text
|
||||
help = STRING_TOKEN(STR_VLAN_ADD_VLAN_HELP),
|
||||
text = STRING_TOKEN(STR_VLAN_ADD_VLAN_PROMPT),
|
||||
flags = INTERACTIVE,
|
||||
key = VLAN_ADD_QUESTION_ID;
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_VLAN_NULL_STRING);
|
||||
subtitle text = STRING_TOKEN(STR_VLAN_VLAN_LIST);
|
||||
|
||||
label LABEL_VLAN_LIST;
|
||||
label LABEL_END;
|
||||
|
||||
text
|
||||
help = STRING_TOKEN(STR_VLAN_REMOVE_VLAN_HELP),
|
||||
text = STRING_TOKEN(STR_VLAN_REMOVE_VLAN_PROMPT),
|
||||
flags = INTERACTIVE,
|
||||
key = VLAN_REMOVE_QUESTION_ID;
|
||||
|
||||
endform;
|
||||
|
||||
endformset;
|
299
NetworkPkg/VlanConfigDxe/VlanConfigDriver.c
Normal file
299
NetworkPkg/VlanConfigDxe/VlanConfigDriver.c
Normal file
@@ -0,0 +1,299 @@
|
||||
/** @file
|
||||
The driver binding for VLAN configuration module.
|
||||
|
||||
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include "VlanConfigImpl.h"
|
||||
|
||||
EFI_DRIVER_BINDING_PROTOCOL gVlanConfigDriverBinding = {
|
||||
VlanConfigDriverBindingSupported,
|
||||
VlanConfigDriverBindingStart,
|
||||
VlanConfigDriverBindingStop,
|
||||
0xa,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
/**
|
||||
The entry point for IP4 config driver which install the driver
|
||||
binding and component name protocol on its image.
|
||||
|
||||
@param[in] ImageHandle The image handle of the driver.
|
||||
@param[in] SystemTable The system table.
|
||||
|
||||
@retval EFI_SUCCES All the related protocols are installed on the driver.
|
||||
@retval Others Failed to install protocols.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanConfigDriverEntryPoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
return EfiLibInstallDriverBindingComponentName2 (
|
||||
ImageHandle,
|
||||
SystemTable,
|
||||
&gVlanConfigDriverBinding,
|
||||
ImageHandle,
|
||||
&gVlanConfigComponentName,
|
||||
&gVlanConfigComponentName2
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to test
|
||||
@param[in] 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
|
||||
VlanConfigDriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
(VOID **) &VlanConfig,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the VlanConfig protocol opened for supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to bind driver to
|
||||
@param[in] 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
|
||||
VlanConfigDriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
VLAN_CONFIG_PRIVATE_DATA *PrivateData;
|
||||
|
||||
//
|
||||
// Check for multiple start
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &PrivateData,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Open VlanConfig protocol by driver
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
(VOID **) &VlanConfig,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get parent device path
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &DevicePath,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Create a private data for this network device
|
||||
//
|
||||
PrivateData = AllocateCopyPool (sizeof (VLAN_CONFIG_PRIVATE_DATA), &mVlanConfigPrivateDateTemplate);
|
||||
if (PrivateData == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
PrivateData->ImageHandle = This->DriverBindingHandle;
|
||||
PrivateData->ControllerHandle = ControllerHandle;
|
||||
PrivateData->VlanConfig = VlanConfig;
|
||||
PrivateData->ParentDevicePath = DevicePath;
|
||||
|
||||
//
|
||||
// Install VLAN configuration form
|
||||
//
|
||||
Status = InstallVlanConfigForm (PrivateData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Install private GUID
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&ControllerHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
PrivateData,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ErrorExit;
|
||||
}
|
||||
return Status;
|
||||
|
||||
ErrorExit:
|
||||
gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
||||
gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
||||
if (PrivateData != NULL) {
|
||||
UninstallVlanConfigForm (PrivateData);
|
||||
FreePool (PrivateData);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to stop driver on
|
||||
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number
|
||||
of children is zero stop the entire bus driver.
|
||||
@param[in] 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
|
||||
VlanConfigDriverBindingStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VLAN_CONFIG_PRIVATE_DATA *PrivateData;
|
||||
|
||||
//
|
||||
// Retrieve the PrivateData from ControllerHandle
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &PrivateData,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
ASSERT (PrivateData->Signature == VLAN_CONFIG_PRIVATE_DATA_SIGNATURE);
|
||||
|
||||
if (NumberOfChildren != 0) {
|
||||
if (NumberOfChildren != 1 || ChildHandleBuffer[0] != PrivateData->DriverHandle) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return UninstallVlanConfigForm (PrivateData);
|
||||
}
|
||||
|
||||
//
|
||||
// Uninstall the private GUID
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ControllerHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
PrivateData,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
return Status;
|
||||
}
|
66
NetworkPkg/VlanConfigDxe/VlanConfigDxe.inf
Normal file
66
NetworkPkg/VlanConfigDxe/VlanConfigDxe.inf
Normal file
@@ -0,0 +1,66 @@
|
||||
## @file
|
||||
# This module provides one way to configurate VALN setting.
|
||||
#
|
||||
# This module produces EFI HII Configuration Access Protocol to provide one way to
|
||||
# configurate VALN setting
|
||||
#
|
||||
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = VlanConfigDxe
|
||||
MODULE_UNI_FILE = VlanConfigDxe.uni
|
||||
FILE_GUID = E4F61863-FE2C-4b56-A8F4-08519BC439DF
|
||||
MODULE_TYPE = UEFI_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
ENTRY_POINT = VlanConfigDriverEntryPoint
|
||||
UNLOAD_IMAGE = NetLibDefaultUnload
|
||||
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
ComponentName.c
|
||||
VlanConfigDriver.c
|
||||
VlanConfigImpl.c
|
||||
VlanConfigImpl.h
|
||||
VlanConfig.vfr
|
||||
VlanConfigStrings.uni
|
||||
VlanConfigNvData.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
MemoryAllocationLib
|
||||
UefiLib
|
||||
UefiBootServicesTableLib
|
||||
UefiDriverEntryPoint
|
||||
DebugLib
|
||||
NetLib
|
||||
HiiLib
|
||||
|
||||
[Guids]
|
||||
gEfiIfrTianoGuid ## SOMETIMES_PRODUCES ## UNDEFINED
|
||||
## SOMETIMES_CONSUMES ## UNDEFINED # HiiIsConfigHdrMatch mVlanStorageName
|
||||
## SOMETIMES_PRODUCES ## UNDEFINED # HiiConstructConfigHdr mVlanStorageName
|
||||
## SOMETIMES_PRODUCES ## UNDEFINED # HiiGetBrowserData mVlanStorageName
|
||||
## SOMETIMES_CONSUMES ## UNDEFINED # HiiSetBrowserData mVlanStorageName
|
||||
## SOMETIMES_CONSUMES ## HII
|
||||
gVlanConfigFormSetGuid
|
||||
|
||||
[Protocols]
|
||||
gEfiHiiConfigAccessProtocolGuid ## BY_START
|
||||
gEfiHiiConfigRoutingProtocolGuid ## CONSUMES
|
||||
gEfiVlanConfigProtocolGuid ## TO_START
|
||||
|
||||
[UserExtensions.TianoCore."ExtraFiles"]
|
||||
VlanConfigDxeExtra.uni
|
17
NetworkPkg/VlanConfigDxe/VlanConfigDxe.uni
Normal file
17
NetworkPkg/VlanConfigDxe/VlanConfigDxe.uni
Normal file
@@ -0,0 +1,17 @@
|
||||
// /** @file
|
||||
// This module provides one way to configurate VALN setting.
|
||||
//
|
||||
// This module produces EFI HII Configuration Access Protocol to provide one way to
|
||||
// configurate VALN setting
|
||||
//
|
||||
// Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// **/
|
||||
|
||||
|
||||
#string STR_MODULE_ABSTRACT #language en-US "Provides a way to configure VLAN settings"
|
||||
|
||||
#string STR_MODULE_DESCRIPTION #language en-US "This module produces EFI HII Configuration Access Protocol to provide a way to configure VLAN settings."
|
||||
|
14
NetworkPkg/VlanConfigDxe/VlanConfigDxeExtra.uni
Normal file
14
NetworkPkg/VlanConfigDxe/VlanConfigDxeExtra.uni
Normal file
@@ -0,0 +1,14 @@
|
||||
// /** @file
|
||||
// VlanConfigDxe Localized Strings and Content
|
||||
//
|
||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// **/
|
||||
|
||||
#string STR_PROPERTIES_MODULE_NAME
|
||||
#language en-US
|
||||
"VLAN Configuration DXE Driver"
|
||||
|
||||
|
664
NetworkPkg/VlanConfigDxe/VlanConfigImpl.c
Normal file
664
NetworkPkg/VlanConfigDxe/VlanConfigImpl.c
Normal file
@@ -0,0 +1,664 @@
|
||||
/** @file
|
||||
HII Config Access protocol implementation of VLAN configuration module.
|
||||
|
||||
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include "VlanConfigImpl.h"
|
||||
|
||||
CHAR16 mVlanStorageName[] = L"VlanNvData";
|
||||
EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting = NULL;
|
||||
|
||||
VLAN_CONFIG_PRIVATE_DATA mVlanConfigPrivateDateTemplate = {
|
||||
VLAN_CONFIG_PRIVATE_DATA_SIGNATURE,
|
||||
{
|
||||
VlanExtractConfig,
|
||||
VlanRouteConfig,
|
||||
VlanCallback
|
||||
}
|
||||
};
|
||||
|
||||
VENDOR_DEVICE_PATH mHiiVendorDevicePathNode = {
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
VLAN_CONFIG_FORM_SET_GUID
|
||||
};
|
||||
|
||||
/**
|
||||
This function allows a caller to extract the current configuration for one
|
||||
or more named elements from the target driver.
|
||||
|
||||
@param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
||||
@param[in] Request A null-terminated Unicode string in
|
||||
<ConfigRequest> format.
|
||||
@param[out] Progress On return, points to a character in the Request
|
||||
string. Points to the string's null terminator if
|
||||
request was successful. Points to the most recent
|
||||
'&' before the first failing name/value pair (or
|
||||
the beginning of the string if the failure is in
|
||||
the first name/value pair) if the request was not
|
||||
successful.
|
||||
@param[out] Results A null-terminated Unicode string in
|
||||
<ConfigAltResp> format which has all values filled
|
||||
in for the names in the Request string. String to
|
||||
be allocated by the called function.
|
||||
|
||||
@retval EFI_SUCCESS The Results is filled with the requested values.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
|
||||
@retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
|
||||
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this
|
||||
driver.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanExtractConfig (
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN CONST EFI_STRING Request,
|
||||
OUT EFI_STRING *Progress,
|
||||
OUT EFI_STRING *Results
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
VLAN_CONFIGURATION Configuration;
|
||||
VLAN_CONFIG_PRIVATE_DATA *PrivateData;
|
||||
EFI_STRING ConfigRequestHdr;
|
||||
EFI_STRING ConfigRequest;
|
||||
BOOLEAN AllocatedRequest;
|
||||
UINTN Size;
|
||||
|
||||
if (Progress == NULL || Results == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Progress = Request;
|
||||
if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gVlanConfigFormSetGuid, mVlanStorageName)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
ConfigRequestHdr = NULL;
|
||||
ConfigRequest = NULL;
|
||||
AllocatedRequest = FALSE;
|
||||
Size = 0;
|
||||
|
||||
//
|
||||
// Retrieve the pointer to the UEFI HII Config Routing Protocol
|
||||
//
|
||||
if (mHiiConfigRouting == NULL) {
|
||||
gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &mHiiConfigRouting);
|
||||
}
|
||||
ASSERT (mHiiConfigRouting != NULL);
|
||||
|
||||
//
|
||||
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
|
||||
//
|
||||
PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This);
|
||||
ZeroMem (&Configuration, sizeof (VLAN_CONFIGURATION));
|
||||
BufferSize = sizeof (Configuration);
|
||||
ConfigRequest = Request;
|
||||
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
|
||||
//
|
||||
// Request has no request element, construct full request string.
|
||||
// Allocate and fill a buffer large enough to hold the <ConfigHdr> template
|
||||
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
|
||||
//
|
||||
ConfigRequestHdr = HiiConstructConfigHdr (&gVlanConfigFormSetGuid, mVlanStorageName, PrivateData->DriverHandle);
|
||||
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
||||
ConfigRequest = AllocateZeroPool (Size);
|
||||
ASSERT (ConfigRequest != NULL);
|
||||
AllocatedRequest = TRUE;
|
||||
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
||||
FreePool (ConfigRequestHdr);
|
||||
}
|
||||
|
||||
Status = mHiiConfigRouting->BlockToConfig (
|
||||
mHiiConfigRouting,
|
||||
ConfigRequest,
|
||||
(UINT8 *) &Configuration,
|
||||
BufferSize,
|
||||
Results,
|
||||
Progress
|
||||
);
|
||||
//
|
||||
// Free the allocated config request string.
|
||||
//
|
||||
if (AllocatedRequest) {
|
||||
FreePool (ConfigRequest);
|
||||
ConfigRequest = NULL;
|
||||
}
|
||||
//
|
||||
// Set Progress string to the original request string.
|
||||
//
|
||||
if (Request == NULL) {
|
||||
*Progress = NULL;
|
||||
} else if (StrStr (Request, L"OFFSET") == NULL) {
|
||||
*Progress = Request + StrLen (Request);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function processes the results of changes in configuration.
|
||||
|
||||
@param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
||||
@param[in] Configuration A null-terminated Unicode string in <ConfigResp>
|
||||
format.
|
||||
@param[out] Progress A pointer to a string filled in with the offset of
|
||||
the most recent '&' before the first failing
|
||||
name/value pair (or the beginning of the string if
|
||||
the failure is in the first name/value pair) or
|
||||
the terminating NULL if all was successful.
|
||||
|
||||
@retval EFI_SUCCESS The Results is processed successfully.
|
||||
@retval EFI_INVALID_PARAMETER Configuration is NULL.
|
||||
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this
|
||||
driver.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanRouteConfig (
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN CONST EFI_STRING Configuration,
|
||||
OUT EFI_STRING *Progress
|
||||
)
|
||||
{
|
||||
if (Configuration == NULL || Progress == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Progress = Configuration;
|
||||
if (!HiiIsConfigHdrMatch (Configuration, &gVlanConfigFormSetGuid, mVlanStorageName)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
*Progress = Configuration + StrLen (Configuration);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This function processes the results of changes in configuration.
|
||||
|
||||
@param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
||||
@param[in] Action Specifies the type of action taken by the browser.
|
||||
@param[in] QuestionId A unique value which is sent to the original
|
||||
exporting driver so that it can identify the type
|
||||
of data to expect.
|
||||
@param[in] Type The type of value for the question.
|
||||
@param[in] Value A pointer to the data being sent to the original
|
||||
exporting driver.
|
||||
@param[out] ActionRequest On return, points to the action requested by the
|
||||
callback function.
|
||||
|
||||
@retval EFI_SUCCESS The callback successfully handled the action.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
|
||||
variable and its data.
|
||||
@retval EFI_DEVICE_ERROR The variable could not be saved.
|
||||
@retval EFI_UNSUPPORTED The specified Action is not supported by the
|
||||
callback.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanCallback (
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN EFI_BROWSER_ACTION Action,
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN UINT8 Type,
|
||||
IN EFI_IFR_TYPE_VALUE *Value,
|
||||
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
|
||||
)
|
||||
{
|
||||
VLAN_CONFIG_PRIVATE_DATA *PrivateData;
|
||||
VLAN_CONFIGURATION *Configuration;
|
||||
EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
|
||||
UINTN Index;
|
||||
EFI_HANDLE VlanHandle;
|
||||
|
||||
PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if ((Action != EFI_BROWSER_ACTION_CHANGED) && (Action != EFI_BROWSER_ACTION_CHANGING)) {
|
||||
//
|
||||
// All other action return unsupported.
|
||||
//
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Browser data
|
||||
//
|
||||
Configuration = AllocateZeroPool (sizeof (VLAN_CONFIGURATION));
|
||||
ASSERT (Configuration != NULL);
|
||||
HiiGetBrowserData (&gVlanConfigFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *) Configuration);
|
||||
|
||||
VlanConfig = PrivateData->VlanConfig;
|
||||
|
||||
if (Action == EFI_BROWSER_ACTION_CHANGED) {
|
||||
switch (QuestionId) {
|
||||
case VLAN_ADD_QUESTION_ID:
|
||||
//
|
||||
// Add a VLAN
|
||||
//
|
||||
VlanConfig->Set (VlanConfig, Configuration->VlanId, Configuration->Priority);
|
||||
VlanUpdateForm (PrivateData);
|
||||
|
||||
//
|
||||
// Connect the newly created VLAN device
|
||||
//
|
||||
VlanHandle = NetLibGetVlanHandle (PrivateData->ControllerHandle, Configuration->VlanId);
|
||||
if (VlanHandle == NULL) {
|
||||
//
|
||||
// There may be no child handle created for VLAN ID 0, connect the parent handle
|
||||
//
|
||||
VlanHandle = PrivateData->ControllerHandle;
|
||||
}
|
||||
gBS->ConnectController (VlanHandle, NULL, NULL, TRUE);
|
||||
|
||||
//
|
||||
// Clear UI data
|
||||
//
|
||||
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
|
||||
Configuration->VlanId = 0;
|
||||
Configuration->Priority = 0;
|
||||
break;
|
||||
|
||||
case VLAN_REMOVE_QUESTION_ID:
|
||||
//
|
||||
// Remove VLAN
|
||||
//
|
||||
ASSERT (PrivateData->NumberOfVlan <= MAX_VLAN_NUMBER);
|
||||
for (Index = 0; Index < PrivateData->NumberOfVlan; Index++) {
|
||||
if (Configuration->VlanList[Index] != 0) {
|
||||
//
|
||||
// Checkbox is selected, need remove this VLAN
|
||||
//
|
||||
VlanConfig->Remove (VlanConfig, PrivateData->VlanId[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
VlanUpdateForm (PrivateData);
|
||||
if (PrivateData->NumberOfVlan == 0) {
|
||||
//
|
||||
// No VLAN device now, connect the physical NIC handle.
|
||||
// Note: PrivateData->NumberOfVlan has been updated by VlanUpdateForm()
|
||||
//
|
||||
gBS->ConnectController (PrivateData->ControllerHandle, NULL, NULL, TRUE);
|
||||
}
|
||||
|
||||
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
|
||||
ZeroMem (Configuration->VlanList, MAX_VLAN_NUMBER);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (Action == EFI_BROWSER_ACTION_CHANGING) {
|
||||
switch (QuestionId) {
|
||||
case VLAN_UPDATE_QUESTION_ID:
|
||||
//
|
||||
// Update current VLAN list into Form.
|
||||
//
|
||||
VlanUpdateForm (PrivateData);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HiiSetBrowserData (&gVlanConfigFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *) Configuration, NULL);
|
||||
FreePool (Configuration);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function update VLAN list in the VLAN configuration Form.
|
||||
|
||||
@param[in, out] PrivateData Points to VLAN configuration private data.
|
||||
|
||||
**/
|
||||
VOID
|
||||
VlanUpdateForm (
|
||||
IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
|
||||
)
|
||||
{
|
||||
EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
|
||||
UINT16 NumberOfVlan;
|
||||
UINTN Index;
|
||||
EFI_VLAN_FIND_DATA *VlanData;
|
||||
VOID *StartOpCodeHandle;
|
||||
EFI_IFR_GUID_LABEL *StartLabel;
|
||||
VOID *EndOpCodeHandle;
|
||||
EFI_IFR_GUID_LABEL *EndLabel;
|
||||
CHAR16 *String;
|
||||
CHAR16 VlanStr[30];
|
||||
CHAR16 VlanIdStr[6];
|
||||
UINTN DigitalCount;
|
||||
EFI_STRING_ID StringId;
|
||||
|
||||
//
|
||||
// Find current VLAN configuration
|
||||
//
|
||||
VlanData = NULL;
|
||||
NumberOfVlan = 0;
|
||||
VlanConfig = PrivateData->VlanConfig;
|
||||
VlanConfig->Find (VlanConfig, NULL, &NumberOfVlan, &VlanData);
|
||||
|
||||
//
|
||||
// Update VLAN configuration in PrivateData
|
||||
//
|
||||
if (NumberOfVlan > MAX_VLAN_NUMBER) {
|
||||
NumberOfVlan = MAX_VLAN_NUMBER;
|
||||
}
|
||||
PrivateData->NumberOfVlan = NumberOfVlan;
|
||||
|
||||
//
|
||||
// Init OpCode Handle
|
||||
//
|
||||
StartOpCodeHandle = HiiAllocateOpCodeHandle ();
|
||||
ASSERT (StartOpCodeHandle != NULL);
|
||||
|
||||
EndOpCodeHandle = HiiAllocateOpCodeHandle ();
|
||||
ASSERT (EndOpCodeHandle != NULL);
|
||||
|
||||
//
|
||||
// Create Hii Extend Label OpCode as the start opcode
|
||||
//
|
||||
StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
|
||||
StartOpCodeHandle,
|
||||
&gEfiIfrTianoGuid,
|
||||
NULL,
|
||||
sizeof (EFI_IFR_GUID_LABEL)
|
||||
);
|
||||
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
|
||||
StartLabel->Number = LABEL_VLAN_LIST;
|
||||
|
||||
//
|
||||
// Create Hii Extend Label OpCode as the end opcode
|
||||
//
|
||||
EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
|
||||
EndOpCodeHandle,
|
||||
&gEfiIfrTianoGuid,
|
||||
NULL,
|
||||
sizeof (EFI_IFR_GUID_LABEL)
|
||||
);
|
||||
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
|
||||
EndLabel->Number = LABEL_END;
|
||||
|
||||
ZeroMem (PrivateData->VlanId, MAX_VLAN_NUMBER);
|
||||
for (Index = 0; Index < NumberOfVlan; Index++) {
|
||||
String = VlanStr;
|
||||
|
||||
StrCpyS (String, (sizeof (VlanStr) /sizeof (CHAR16)), L" VLAN ID:");
|
||||
String += 10;
|
||||
//
|
||||
// Pad VlanId string up to 4 characters with space
|
||||
//
|
||||
UnicodeValueToStringS (VlanIdStr, sizeof (VlanIdStr), 0, VlanData[Index].VlanId, 5);
|
||||
DigitalCount = StrnLenS (VlanIdStr, ARRAY_SIZE (VlanIdStr));
|
||||
SetMem16 (String, (4 - DigitalCount) * sizeof (CHAR16), L' ');
|
||||
StrCpyS (String + 4 - DigitalCount, (sizeof (VlanStr) /sizeof (CHAR16)) - 10 - (4 - DigitalCount), VlanIdStr);
|
||||
String += 4;
|
||||
|
||||
StrCpyS (String, (sizeof (VlanStr) /sizeof (CHAR16)) - 10 - (4 - DigitalCount) - 4, L", Priority:");
|
||||
String += 11;
|
||||
UnicodeValueToStringS (
|
||||
String,
|
||||
sizeof (VlanStr) - ((UINTN)String - (UINTN)VlanStr),
|
||||
0,
|
||||
VlanData[Index].Priority,
|
||||
4
|
||||
);
|
||||
String += StrnLenS (String, ARRAY_SIZE (VlanStr) - ((UINTN)String - (UINTN)VlanStr) / sizeof (CHAR16));
|
||||
*String = 0;
|
||||
|
||||
StringId = HiiSetString (PrivateData->HiiHandle, 0, VlanStr, NULL);
|
||||
ASSERT (StringId != 0);
|
||||
|
||||
HiiCreateCheckBoxOpCode (
|
||||
StartOpCodeHandle,
|
||||
(EFI_QUESTION_ID) (VLAN_LIST_VAR_OFFSET + Index),
|
||||
VLAN_CONFIGURATION_VARSTORE_ID,
|
||||
(UINT16) (VLAN_LIST_VAR_OFFSET + Index),
|
||||
StringId,
|
||||
STRING_TOKEN (STR_VLAN_VLAN_LIST_HELP),
|
||||
0,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
//
|
||||
// Save VLAN id to private data
|
||||
//
|
||||
PrivateData->VlanId[Index] = VlanData[Index].VlanId;
|
||||
}
|
||||
|
||||
HiiUpdateForm (
|
||||
PrivateData->HiiHandle, // HII handle
|
||||
&gVlanConfigFormSetGuid, // Formset GUID
|
||||
VLAN_CONFIGURATION_FORM_ID, // Form ID
|
||||
StartOpCodeHandle, // Label for where to insert opcodes
|
||||
EndOpCodeHandle // Replace data
|
||||
);
|
||||
|
||||
HiiFreeOpCodeHandle (StartOpCodeHandle);
|
||||
HiiFreeOpCodeHandle (EndOpCodeHandle);
|
||||
|
||||
if (VlanData != NULL) {
|
||||
FreePool (VlanData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function publish the VLAN configuration Form for a network device. The
|
||||
HII Config Access protocol will be installed on a child handle of the network
|
||||
device.
|
||||
|
||||
@param[in, out] PrivateData Points to VLAN configuration private data.
|
||||
|
||||
@retval EFI_SUCCESS HII Form is installed for this network device.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.
|
||||
@retval Others Other errors as indicated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
InstallVlanConfigForm (
|
||||
IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HII_HANDLE HiiHandle;
|
||||
EFI_HANDLE DriverHandle;
|
||||
CHAR16 Str[26 + sizeof (EFI_MAC_ADDRESS) * 2 + 1];
|
||||
CHAR16 *MacString;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;
|
||||
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
|
||||
EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
|
||||
|
||||
//
|
||||
// Create child handle and install HII Config Access Protocol
|
||||
//
|
||||
ChildDevicePath = AppendDevicePathNode (
|
||||
PrivateData->ParentDevicePath,
|
||||
(CONST EFI_DEVICE_PATH_PROTOCOL *) &mHiiVendorDevicePathNode
|
||||
);
|
||||
if (ChildDevicePath == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
PrivateData->ChildDevicePath = ChildDevicePath;
|
||||
|
||||
DriverHandle = NULL;
|
||||
ConfigAccess = &PrivateData->ConfigAccess;
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&DriverHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
ChildDevicePath,
|
||||
&gEfiHiiConfigAccessProtocolGuid,
|
||||
ConfigAccess,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
PrivateData->DriverHandle = DriverHandle;
|
||||
|
||||
//
|
||||
// Establish the parent-child relationship between the new created
|
||||
// child handle and the ControllerHandle.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
PrivateData->ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
(VOID **)&VlanConfig,
|
||||
PrivateData->ImageHandle,
|
||||
PrivateData->DriverHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Publish the HII package list
|
||||
//
|
||||
HiiHandle = HiiAddPackages (
|
||||
&gVlanConfigFormSetGuid,
|
||||
DriverHandle,
|
||||
VlanConfigDxeStrings,
|
||||
VlanConfigBin,
|
||||
NULL
|
||||
);
|
||||
if (HiiHandle == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
PrivateData->HiiHandle = HiiHandle;
|
||||
|
||||
//
|
||||
// Update formset title help string.
|
||||
//
|
||||
MacString = NULL;
|
||||
Status = NetLibGetMacString (PrivateData->ControllerHandle, PrivateData->ImageHandle, &MacString);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
PrivateData->MacString = MacString;
|
||||
|
||||
StrCpyS (Str, sizeof (Str) / sizeof (CHAR16), L"VLAN Configuration (MAC:");
|
||||
StrCatS (Str, sizeof (Str) / sizeof (CHAR16), MacString);
|
||||
StrCatS (Str, sizeof (Str) / sizeof (CHAR16), L")");
|
||||
HiiSetString (
|
||||
HiiHandle,
|
||||
STRING_TOKEN (STR_VLAN_FORM_SET_TITLE_HELP),
|
||||
Str,
|
||||
NULL
|
||||
);
|
||||
|
||||
//
|
||||
// Update form title help string.
|
||||
//
|
||||
HiiSetString (
|
||||
HiiHandle,
|
||||
STRING_TOKEN (STR_VLAN_FORM_HELP),
|
||||
Str,
|
||||
NULL
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This function remove the VLAN configuration Form for a network device. The
|
||||
child handle for HII Config Access protocol will be destroyed.
|
||||
|
||||
@param[in, out] PrivateData Points to VLAN configuration private data.
|
||||
|
||||
@retval EFI_SUCCESS HII Form has been uninstalled successfully.
|
||||
@retval Others Other errors as indicated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
UninstallVlanConfigForm (
|
||||
IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
|
||||
|
||||
//
|
||||
// End the parent-child relationship.
|
||||
//
|
||||
Status = gBS->CloseProtocol (
|
||||
PrivateData->ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
PrivateData->ImageHandle,
|
||||
PrivateData->DriverHandle
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Uninstall HII Config Access Protocol
|
||||
//
|
||||
if (PrivateData->DriverHandle != NULL) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
PrivateData->DriverHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
PrivateData->ChildDevicePath,
|
||||
&gEfiHiiConfigAccessProtocolGuid,
|
||||
&PrivateData->ConfigAccess,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->OpenProtocol (
|
||||
PrivateData->ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
(VOID **)&VlanConfig,
|
||||
PrivateData->ImageHandle,
|
||||
PrivateData->DriverHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
PrivateData->DriverHandle = NULL;
|
||||
|
||||
if (PrivateData->ChildDevicePath != NULL) {
|
||||
FreePool (PrivateData->ChildDevicePath);
|
||||
PrivateData->ChildDevicePath = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Free MAC string
|
||||
//
|
||||
if (PrivateData->MacString != NULL) {
|
||||
FreePool (PrivateData->MacString);
|
||||
PrivateData->MacString = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Uninstall HII package list
|
||||
//
|
||||
if (PrivateData->HiiHandle != NULL) {
|
||||
HiiRemovePackages (PrivateData->HiiHandle);
|
||||
PrivateData->HiiHandle = NULL;
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
}
|
381
NetworkPkg/VlanConfigDxe/VlanConfigImpl.h
Normal file
381
NetworkPkg/VlanConfigDxe/VlanConfigImpl.h
Normal file
@@ -0,0 +1,381 @@
|
||||
/** @file
|
||||
Header file for driver binding protocol and HII config access protocol.
|
||||
|
||||
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __VLAN_CONFIG_IMPL_H__
|
||||
#define __VLAN_CONFIG_IMPL_H__
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/ComponentName.h>
|
||||
#include <Protocol/ComponentName2.h>
|
||||
#include <Protocol/HiiConfigAccess.h>
|
||||
#include <Protocol/HiiConfigRouting.h>
|
||||
#include <Protocol/VlanConfig.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/NetLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
|
||||
#include <Guid/MdeModuleHii.h>
|
||||
|
||||
#include "VlanConfigNvData.h"
|
||||
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gVlanConfigComponentName2;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gVlanConfigComponentName;
|
||||
|
||||
//
|
||||
// Tool generated IFR binary data and String package data
|
||||
//
|
||||
extern UINT8 VlanConfigBin[];
|
||||
extern UINT8 VlanConfigDxeStrings[];
|
||||
|
||||
#define VLAN_LIST_VAR_OFFSET ((UINT16) OFFSET_OF (VLAN_CONFIGURATION, VlanList))
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
|
||||
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
|
||||
EFI_HII_HANDLE HiiHandle;
|
||||
EFI_HANDLE DriverHandle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;
|
||||
|
||||
EFI_HANDLE ControllerHandle;
|
||||
EFI_HANDLE ImageHandle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
|
||||
CHAR16 *MacString;
|
||||
|
||||
UINT16 NumberOfVlan;
|
||||
UINT16 VlanId[MAX_VLAN_NUMBER];
|
||||
} VLAN_CONFIG_PRIVATE_DATA;
|
||||
|
||||
#define VLAN_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('V', 'C', 'P', 'D')
|
||||
#define VLAN_CONFIG_PRIVATE_DATA_FROM_THIS(a) CR (a, VLAN_CONFIG_PRIVATE_DATA, ConfigAccess, VLAN_CONFIG_PRIVATE_DATA_SIGNATURE)
|
||||
|
||||
extern VLAN_CONFIG_PRIVATE_DATA mVlanConfigPrivateDateTemplate;
|
||||
|
||||
|
||||
/**
|
||||
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 4646 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
|
||||
VlanConfigComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
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 4646 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 NULL.
|
||||
@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
|
||||
VlanConfigComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to test
|
||||
@param[in] 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
|
||||
VlanConfigDriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to bind driver to
|
||||
@param[in] 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
|
||||
VlanConfigDriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to stop driver on
|
||||
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number
|
||||
of children is zero stop the entire bus driver.
|
||||
@param[in] 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
|
||||
VlanConfigDriverBindingStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
);
|
||||
|
||||
/**
|
||||
This function update VLAN list in the VLAN configuration Form.
|
||||
|
||||
@param[in, out] PrivateData Points to VLAN configuration private data.
|
||||
|
||||
**/
|
||||
VOID
|
||||
VlanUpdateForm (
|
||||
IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
|
||||
);
|
||||
|
||||
/**
|
||||
This function publish the VLAN configuration Form for a network device. The
|
||||
HII Config Access protocol will be installed on a child handle of the network
|
||||
device.
|
||||
|
||||
@param[in, out] PrivateData Points to VLAN configuration private data.
|
||||
|
||||
@retval EFI_SUCCESS HII Form is installed for this network device.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.
|
||||
@retval Others Other errors as indicated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
InstallVlanConfigForm (
|
||||
IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
|
||||
);
|
||||
|
||||
/**
|
||||
This function remove the VLAN configuration Form for a network device. The
|
||||
child handle for HII Config Access protocol will be destroyed.
|
||||
|
||||
@param[in, out] PrivateData Points to VLAN configuration private data.
|
||||
|
||||
@retval EFI_SUCCESS HII Form has been uninstalled successfully.
|
||||
@retval Others Other errors as indicated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
UninstallVlanConfigForm (
|
||||
IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
|
||||
);
|
||||
|
||||
/**
|
||||
This function allows a caller to extract the current configuration for one
|
||||
or more named elements from the target driver.
|
||||
|
||||
@param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
||||
@param[in] Request A null-terminated Unicode string in
|
||||
<ConfigRequest> format.
|
||||
@param[out] Progress On return, points to a character in the Request
|
||||
string. Points to the string's null terminator if
|
||||
request was successful. Points to the most recent
|
||||
'&' before the first failing name/value pair (or
|
||||
the beginning of the string if the failure is in
|
||||
the first name/value pair) if the request was not
|
||||
successful.
|
||||
@param[out] Results A null-terminated Unicode string in
|
||||
<ConfigAltResp> format which has all values filled
|
||||
in for the names in the Request string. String to
|
||||
be allocated by the called function.
|
||||
|
||||
@retval EFI_SUCCESS The Results is filled with the requested values.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
|
||||
@retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
|
||||
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this
|
||||
driver.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanExtractConfig (
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN CONST EFI_STRING Request,
|
||||
OUT EFI_STRING *Progress,
|
||||
OUT EFI_STRING *Results
|
||||
);
|
||||
|
||||
/**
|
||||
This function processes the results of changes in configuration.
|
||||
|
||||
@param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
||||
@param[in] Configuration A null-terminated Unicode string in <ConfigResp>
|
||||
format.
|
||||
@param[out] Progress A pointer to a string filled in with the offset of
|
||||
the most recent '&' before the first failing
|
||||
name/value pair (or the beginning of the string if
|
||||
the failure is in the first name/value pair) or
|
||||
the terminating NULL if all was successful.
|
||||
|
||||
@retval EFI_SUCCESS The Results is processed successfully.
|
||||
@retval EFI_INVALID_PARAMETER Configuration is NULL.
|
||||
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this
|
||||
driver.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanRouteConfig (
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN CONST EFI_STRING Configuration,
|
||||
OUT EFI_STRING *Progress
|
||||
);
|
||||
|
||||
/**
|
||||
This function processes the results of changes in configuration.
|
||||
|
||||
@param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
||||
@param[in] Action Specifies the type of action taken by the browser.
|
||||
@param[in] QuestionId A unique value which is sent to the original
|
||||
exporting driver so that it can identify the type
|
||||
of data to expect.
|
||||
@param[in] Type The type of value for the question.
|
||||
@param[in] Value A pointer to the data being sent to the original
|
||||
exporting driver.
|
||||
@param[out] ActionRequest On return, points to the action requested by the
|
||||
callback function.
|
||||
|
||||
@retval EFI_SUCCESS The callback successfully handled the action.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
|
||||
variable and its data.
|
||||
@retval EFI_DEVICE_ERROR The variable could not be saved.
|
||||
@retval EFI_UNSUPPORTED The specified Action is not supported by the
|
||||
callback.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanCallback (
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN EFI_BROWSER_ACTION Action,
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN UINT8 Type,
|
||||
IN EFI_IFR_TYPE_VALUE *Value,
|
||||
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
|
||||
);
|
||||
|
||||
#endif
|
40
NetworkPkg/VlanConfigDxe/VlanConfigNvData.h
Normal file
40
NetworkPkg/VlanConfigDxe/VlanConfigNvData.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/** @file
|
||||
Header file for NV data structure definition.
|
||||
|
||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __VLAN_CONFIG_NV_DATA_H__
|
||||
#define __VLAN_CONFIG_NV_DATA_H__
|
||||
|
||||
#include <Guid/HiiPlatformSetupFormset.h>
|
||||
#include <Guid/VlanConfigHii.h>
|
||||
|
||||
#define VLAN_CONFIGURATION_VARSTORE_ID 0x0001
|
||||
#define VLAN_CONFIGURATION_FORM_ID 0x0001
|
||||
#define VLAN_HEAD_FORM_ID 0x0002
|
||||
|
||||
#define VLAN_ADD_QUESTION_ID 0x1000
|
||||
#define VLAN_REMOVE_QUESTION_ID 0x2000
|
||||
#define VLAN_UPDATE_QUESTION_ID 0x3000
|
||||
|
||||
#define LABEL_VLAN_LIST 0x0001
|
||||
#define LABEL_END 0xffff
|
||||
|
||||
//
|
||||
// The maximum number of VLAN that will be displayed on the menu
|
||||
//
|
||||
#define MAX_VLAN_NUMBER 100
|
||||
|
||||
//
|
||||
// Nv Data structure referenced by IFR
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 VlanId;
|
||||
UINT8 Priority;
|
||||
UINT8 VlanList[MAX_VLAN_NUMBER];
|
||||
} VLAN_CONFIGURATION;
|
||||
|
||||
#endif
|
31
NetworkPkg/VlanConfigDxe/VlanConfigStrings.uni
Normal file
31
NetworkPkg/VlanConfigDxe/VlanConfigStrings.uni
Normal file
@@ -0,0 +1,31 @@
|
||||
///** @file
|
||||
// String definitions for VLAN Configuration Form.
|
||||
//
|
||||
// Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
//**/
|
||||
|
||||
/=#
|
||||
|
||||
#langdef en-US "English"
|
||||
|
||||
#string STR_VLAN_FORM_SET_TITLE #language en-US "VLAN Configuration"
|
||||
#string STR_VLAN_FORM_SET_TITLE_HELP #language en-US "VLAN configuration for this network device"
|
||||
#string STR_VLAN_FORM_TITLE #language en-US "VLAN Configuration"
|
||||
#string STR_VLAN_FORM_HELP #language en-US "VLAN Configuration Help"
|
||||
#string STR_VLAN_CREATE_VLAN #language en-US "Create new VLAN"
|
||||
|
||||
#string STR_VLAN_VID_PROMPT #language en-US " VLAN ID"
|
||||
#string STR_VLAN_VID_HELP #language en-US "VLAN ID of new VLAN or existing VLAN, valid value is 0~4094"
|
||||
#string STR_VLAN_PRIORITY_PROMPT #language en-US " Priority"
|
||||
#string STR_VLAN_PRIORITY_HELP #language en-US "802.1Q Priority, valid value is 0~7"
|
||||
#string STR_VLAN_ADD_VLAN_PROMPT #language en-US "Add VLAN"
|
||||
#string STR_VLAN_ADD_VLAN_HELP #language en-US "Create a new VLAN or update existing VLAN"
|
||||
#string STR_VLAN_VLAN_LIST #language en-US "Configured VLAN List"
|
||||
#string STR_VLAN_VLAN_LIST_HELP #language en-US "Select for remove"
|
||||
#string STR_VLAN_REMOVE_VLAN_PROMPT #language en-US "Remove VLAN"
|
||||
#string STR_VLAN_REMOVE_VLAN_HELP #language en-US "Remove selected VLANs"
|
||||
#string STR_VLAN_NULL_STRING #language en-US ""
|
||||
#string STR_GET_CURRENT_SETTING #language en-US "Enter Configuration Menu"
|
||||
#string STR_GET_CURRENT_SETTING_HELP #language en-US "Press ENTER to enter configuration menu for VLAN configuration."
|
Reference in New Issue
Block a user