Newer
Older
AMI-Aptio-BIOS-Reversed / VlanConfigDxe / VlanConfigDxe.md
@Ajax Dong Ajax Dong 2 days ago 9 KB Init

VlanConfigDxe

Function Table

Address Name Description
VlanConfigInitPrivateData
VlanConfigCleanupPrivateData
VlanConfigValidateConfigHeader
VlanConfigCompareConfigStrings
VlanConfigUpdateForm
VlanConfigFreePool
VlanConfigDxeEntryPoint
VlanConfigDriverBindingSupported
VlanConfigDriverBindingStart
VlanConfigDriverBindingStop
VlanConfigDxeUnload
VlanConfigSet
VlanConfigFind
VlanConfigRemove
VlanConfigExtractConfig
VlanConfigRouteConfig
VlanConfigCallback
VlanConfigComponentName2GetDriverName
VlanConfigComponentName2GetControllerName
GUID Definitions
VLAN Config Protocol GUID: { B3276D32-41FC-4260-7469-D90FAA23DC4C }
Matches the data at 0x7208 in .rdata
EFI_GUID gEfiVlanConfigProtocolGuid = {
Managed Network Protocol GUID: { C1539892-9836-5822-AB31-A01843B41A4D }
EFI_GUID gEfiManagedNetworkProtocolGuid = {
Device Path Protocol GUID: { 09576E91-6D3F-11D2-8E39-00A0C969723B }
EFI_GUID gEfiDevicePathProtocolGuid = {
Simple Network Protocol GUID: { A19832B9-AC25-11D3-9A2D-0090273FC14D }
EFI_GUID gEfiSimpleNetworkProtocolGuid = {
HII Protocol GUIDS (standard UEFI)
EFI_GUID gEfiHiiStringProtocolGuid = {
Global Variables
Image handle (global)
EFI_HANDLE gImageHandle = NULL;
HII Config Routing Protocol handle
EFI_HII_CONFIG_ROUTING_PROTOCOL *gHiiConfigRouting = NULL;
HII Database Protocol handle
EFI_HII_DATABASE_PROTOCOL *gHiiDatabase = NULL;
HII String Protocol handle
EFI_HII_STRING_PROTOCOL *gHiiString = NULL;
HII Config Access Protocol handle (lazy init)
EFI_HII_CONFIG_ACCESS_PROTOCOL *gHiiConfigAccess = NULL;
Default zero MAC address (6 bytes)
UINT8 mZeroMacAddress[6] = { 0, 0, 0, 0, 0, 0 };
Driver Binding Protocol instance
EFI_DRIVER_BINDING_PROTOCOL gVlanConfigDriverBinding = {
Version NULL, // ImageHandle (filled at entry)
DriverBindingHandle (filled at entry)
Component Name 2 Protocol table
EFI_COMPONENT_NAME2_PROTOCOL gVlanConfigComponentName2 = {
HII Config Access Protocol instance
EFI_HII_CONFIG_ACCESS_PROTOCOL gVlanConfigHiiConfigAccess = {
VFR binary and string package references (defined in auto-generated files)
extern UINT8 mVlanConfigVfrBin[];
Function Prototypes for Local Functions
EFI_STATUS VlanConfigInitPrivateData (
Library Wrappers
Module Entry Point
Initialize global service pointer tables
gImageHandle = ImageHandle;
Locate HII protocol interfaces (LocateProtocol with 0 registration)
Status = gBS->LocateProtocol (
Locate HII Config Access Protocol (for NV data storage, optional)
Set up driver binding protocol handles
Install the Driver Binding and Component Name 2 protocols
Status = gBS->InstallMultipleProtocolInterfaces (
Driver Binding Protocol
Check if VLAN Config Protocol already exists on this controller.
If so, report ACCESS_DENIED to avoid duplicate binding.
Status = gBS->OpenProtocol (
The controller must have Managed Network Protocol
Check if VLAN Config Protocol already exists on this controller
Open Simple Network Protocol on the controller (GET_PROTOCOL)
Open Managed Network Protocol on the controller (BY_DRIVER)
Open Device Path Protocol on the controller (BY_DRIVER)
Allocate and initialize private data structure (0x130 bytes)
Private = (VLAN_CONFIG_PRIVATE_DATA *)VlanConfigAllocateZeroPool (sizeof (VLAN_CONFIG_PRIVATE_DATA));
Initialize private data fields
Initialize VLAN Config Protocol interface
Initialize the driver instance and create HII resources
Status = VlanConfigInitPrivateData (Private);
Install the VLAN Config Protocol on the controller handle
Status = gBS->InstallProtocolInterface (
Validate signature and get the private data
Clean up HII resources
VlanConfigCleanupPrivateData (Private);
Uninstall the VLAN Config Protocol
Status = gBS->UninstallProtocolInterface (
Close protocols opened by this driver
Driver Unload / Image Unload Handler
Locate all handles with VLAN Config Protocol
Status = gBS->LocateHandleBuffer (
Stop the driver on each controller
for (Index = 0; Index < HandleCount; Index++) {
Uninstall the driver binding and component name protocols
Status = gBS->UninstallMultipleProtocolInterfaces (
Private Data Initialization and Cleanup
Extract current MAC address from SNP's mode data
MacSize = sizeof (EFI_MAC_ADDRESS);
Register the formset with HII database
Install the HII Config Access Protocol on the controller handle
Build the form title: "VLAN Configuration (MAC:...)"
if (MacStr != NULL) {
Populate the VLAN list on the form
Status = VlanConfigUpdateForm (Private);
Remove HII Config Access Protocol from the controller
if (Private->ControllerHandle != NULL) {
Remove HII packages (strings and forms)
if (Private->HiiHandle != NULL) {
VLAN Config Protocol Implementation
HII Form Population
Query VLAN list from Managed Network
Get current VLAN count and list
VlanListCount = 0;
Create op-code handles for the form
StartOpCodeHandle = HiiAllocateOpCodeHandle ();
Create start label
StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
Create end label
Cap VLAN count for form display (max 100)
VlanCount = PrivateData->NumberOfVlan;
Build form entries for each existing VLAN
if (VlanCount > 0) {
Build string: " VLAN ID: %d"
UnicodeSPrint (
Pad to align priority text
PaddingLen = 2 * (4 - (StrLen (VlanString) - 6));
spaces //
Build priority sub-string
Priority not stored per-VLAN in min implementation
Create new string in HII database
StringId = HiiSetString (PrivateData->HiiHandle, 0, VlanString, NULL);
Create the text op-code for this VLAN entry
Update the form
Clean up op-code handles
if (StartOpCodeHandle != NULL) {
HII Config Access Protocol
Validate the config request string if provided
if (Request != NULL && !VlanConfigValidateConfigHeader (Request)) {
If no request string, build a complete request for VLAN_CONFIGURATION_SIZE
if **(Request == NULL !StrStr (Request, L"OFFSET")) {**
Ensure HII Config Routing protocol is loaded
if (gHiiConfigRouting == NULL) {
Extract configuration via ConfigRouting
Private = CR (This, VLAN_CONFIG_PRIVATE_DATA, VlanConfigProtocol
Validate the config header
if (!VlanConfigValidateConfigHeader (Configuration)) {
Route to end for progress reporting
Refresh data for the form
if **((QuestionId == 0) (Action - 3 <= 1)) {**
Process the form submission
Configuration = (VLAN_CONFIGURATION *)Private->VlanConfigProtocol;
Add a new VLAN - Value contains VLAN ID (u16) and Priority (u8 at +2)
if (Value != NULL) {
Clear the form's VLAN ID/Priority fields
ZeroMem (&Configuration->VlanId, 4);
Reset the network interface to apply the change
Delete VLANs that are marked (checkbox set)
VlanCount = Private->NumberOfVlan;
Delete VLAN by ID
Config String Helpers
Check GUID= section (between start and L"&NAME=")
Result = VlanConfigCompareConfigStrings (
Check &NAME= section (between L"&NAME=" and L"&PATH=")
Build the config string header components:
Walk the device path to calculate its total size
if (Private != NULL && Private->DevicePath != NULL) {
Allocate the maximum possible header size:
GUID (32 hex) + &NAME= + VlanNvData (8 chars as hex) + &PATH= + device path hex
BufferSize = 2 (32 + 8 + 2 + 2 DevicePathSize) + 66;
Build the GUID= portion from the protocol GUID
Append "&NAME="
StrCpyS (ConfigString, (BufferSize - (ConfigString - Buffer)) / 2, L"&NAME=");
Append "VlanNvData" as hex chars
for (Index = 0; Index < sizeof (L"VlanNvData") / 2 - 1; Index++) {
Append "&PATH="
StrCpyS (ConfigString, (BufferSize - (ConfigString - Buffer)) / 2, L"&PATH=");
Append PATH as hex bytes of device path (or empty if none)
Convert uppercase hex to lowercase in PATH/NAME sections
InValue = FALSE;
Component Name Protocol

Generated by HR650X BIOS Decompilation Project