/** @file\r
-Copyright (c) 2004 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
+ Implementation of reading the MAC address of a network adapter.\r
+ \r
+Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed \r
+and made available under the terms and conditions of the BSD License which \r
+accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module name:\r
- station_address.c\r
-\r
-Abstract:\r
-\r
-Revision history:\r
- 2000-Feb-17 M(f)J Genesis.\r
-\r
**/\r
\r
#include "Snp.h"\r
\r
\r
/**\r
- this routine calls undi to read the MAC address of the NIC and updates the\r
- mode structure with the address.\r
-\r
- @param snp pointer to snp driver structure\r
+ Call UNDI to read the MAC address of the NIC and update the mode structure \r
+ with the address. \r
\r
+ @param Snp Pointer to snp driver structure.\r
+ \r
+ @retval EFI_SUCCESS The MAC address of the NIC is read successfully.\r
+ @retval EFI_DEVICE_ERROR Failed to read the MAC address of the NIC.\r
\r
**/\r
EFI_STATUS\r
-pxe_get_stn_addr (\r
- SNP_DRIVER *snp\r
+PxeGetStnAddr (\r
+ SNP_DRIVER *Snp\r
)\r
{\r
- PXE_DB_STATION_ADDRESS *db;\r
+ PXE_DB_STATION_ADDRESS *Db;\r
\r
- db = snp->db;\r
- snp->cdb.OpCode = PXE_OPCODE_STATION_ADDRESS;\r
- snp->cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_READ;\r
+ Db = Snp->Db;\r
+ Snp->Cdb.OpCode = PXE_OPCODE_STATION_ADDRESS;\r
+ Snp->Cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_READ;\r
\r
- snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
- snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
+ Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
+ Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
\r
- snp->cdb.DBsize = sizeof (PXE_DB_STATION_ADDRESS);\r
- snp->cdb.DBaddr = (UINT64)(UINTN) db;\r
+ Snp->Cdb.DBsize = (UINT16) sizeof (PXE_DB_STATION_ADDRESS);\r
+ Snp->Cdb.DBaddr = (UINT64)(UINTN) Db;\r
\r
- snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
- snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
- snp->cdb.IFnum = snp->if_num;\r
- snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
+ Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
+ Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
+ Snp->Cdb.IFnum = Snp->IfNum;\r
+ Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
\r
//\r
// Issue UNDI command and check result.\r
//\r
DEBUG ((EFI_D_NET, "\nsnp->undi.station_addr() "));\r
\r
- (*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);\r
+ (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
\r
- if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
+ if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
DEBUG (\r
(EFI_D_ERROR,\r
"\nsnp->undi.station_addr() %xh:%xh\n",\r
- snp->cdb.StatFlags,\r
- snp->cdb.StatCode)\r
+ Snp->Cdb.StatFlags,\r
+ Snp->Cdb.StatCode)\r
);\r
\r
return EFI_DEVICE_ERROR;\r
// Set new station address in SNP->Mode structure and return success.\r
//\r
CopyMem (\r
- &(snp->mode.CurrentAddress),\r
- &db->StationAddr,\r
- snp->mode.HwAddressSize\r
+ &(Snp->Mode.CurrentAddress),\r
+ &Db->StationAddr,\r
+ Snp->Mode.HwAddressSize\r
);\r
\r
CopyMem (\r
- &snp->mode.BroadcastAddress,\r
- &db->BroadcastAddr,\r
- snp->mode.HwAddressSize\r
+ &Snp->Mode.BroadcastAddress,\r
+ &Db->BroadcastAddr,\r
+ Snp->Mode.HwAddressSize\r
);\r
\r
CopyMem (\r
- &snp->mode.PermanentAddress,\r
- &db->PermanentAddr,\r
- snp->mode.HwAddressSize\r
+ &Snp->Mode.PermanentAddress,\r
+ &Db->PermanentAddr,\r
+ Snp->Mode.HwAddressSize\r
);\r
\r
return EFI_SUCCESS;\r
\r
\r
/**\r
- this routine calls undi to set a new MAC address for the NIC,\r
+ Call UNDI to set a new MAC address for the NIC.\r
\r
- @param snp pointer to snp driver structure\r
- @param NewMacAddr pointer to a mac address to be set for the nic, if this is\r
+ @param Snp Pointer to Snp driver structure.\r
+ @param NewMacAddr Pointer to a MAC address to be set for the NIC, if this is\r
NULL then this routine resets the mac address to the NIC's\r
original address.\r
\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
-pxe_set_stn_addr (\r
- SNP_DRIVER *snp,\r
+PxeSetStnAddr (\r
+ SNP_DRIVER *Snp,\r
EFI_MAC_ADDRESS *NewMacAddr\r
)\r
{\r
- PXE_CPB_STATION_ADDRESS *cpb;\r
- PXE_DB_STATION_ADDRESS *db;\r
+ PXE_CPB_STATION_ADDRESS *Cpb;\r
+ PXE_DB_STATION_ADDRESS *Db;\r
\r
- cpb = snp->cpb;\r
- db = snp->db;\r
- snp->cdb.OpCode = PXE_OPCODE_STATION_ADDRESS;\r
+ Cpb = Snp->Cpb;\r
+ Db = Snp->Db;\r
+ Snp->Cdb.OpCode = PXE_OPCODE_STATION_ADDRESS;\r
\r
if (NewMacAddr == NULL) {\r
- snp->cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_RESET;\r
- snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
- snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
+ Snp->Cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_RESET;\r
+ Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
+ Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
} else {\r
- snp->cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_READ;\r
+ Snp->Cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_READ;\r
//\r
// even though the OPFLAGS are set to READ, supplying a new address\r
// in the CPB will make undi change the mac address to the new one.\r
//\r
- CopyMem (&cpb->StationAddr, NewMacAddr, snp->mode.HwAddressSize);\r
+ CopyMem (&Cpb->StationAddr, NewMacAddr, Snp->Mode.HwAddressSize);\r
\r
- snp->cdb.CPBsize = sizeof (PXE_CPB_STATION_ADDRESS);\r
- snp->cdb.CPBaddr = (UINT64)(UINTN) cpb;\r
+ Snp->Cdb.CPBsize = (UINT16) sizeof (PXE_CPB_STATION_ADDRESS);\r
+ Snp->Cdb.CPBaddr = (UINT64)(UINTN) Cpb;\r
}\r
\r
- snp->cdb.DBsize = sizeof (PXE_DB_STATION_ADDRESS);\r
- snp->cdb.DBaddr = (UINT64)(UINTN) db;\r
+ Snp->Cdb.DBsize = (UINT16) sizeof (PXE_DB_STATION_ADDRESS);\r
+ Snp->Cdb.DBaddr = (UINT64)(UINTN) Db;\r
\r
- snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
- snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
- snp->cdb.IFnum = snp->if_num;\r
- snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
+ Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
+ Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
+ Snp->Cdb.IFnum = Snp->IfNum;\r
+ Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
\r
//\r
// Issue UNDI command and check result.\r
//\r
DEBUG ((EFI_D_NET, "\nsnp->undi.station_addr() "));\r
\r
- (*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);\r
+ (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
\r
- if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
+ if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
DEBUG (\r
(EFI_D_ERROR,\r
"\nsnp->undi.station_addr() %xh:%xh\n",\r
- snp->cdb.StatFlags,\r
- snp->cdb.StatCode)\r
+ Snp->Cdb.StatFlags,\r
+ Snp->Cdb.StatCode)\r
);\r
\r
//\r
//\r
// read the changed address and save it in SNP->Mode structure\r
//\r
- pxe_get_stn_addr (snp);\r
+ PxeGetStnAddr (Snp);\r
\r
return EFI_SUCCESS;\r
}\r
\r
\r
/**\r
- This is the SNP interface routine for changing the NIC's mac address.\r
- This routine basically retrieves snp structure, checks the SNP state and\r
- calls the above routines to actually do the work\r
-\r
- @param this context pointer\r
- @param NewMacAddr pointer to a mac address to be set for the nic, if this is\r
- NULL then this routine resets the mac address to the NIC's\r
- original address.\r
- @param ResetFlag If true, the mac address will change to NIC's original\r
- address\r
-\r
+ Modifies or resets the current station address, if supported.\r
+ \r
+ This function modifies or resets the current station address of a network \r
+ interface, if supported. If Reset is TRUE, then the current station address is\r
+ set to the network interface's permanent address. If Reset is FALSE, and the \r
+ network interface allows its station address to be modified, then the current \r
+ station address is changed to the address specified by New. If the network \r
+ interface does not allow its station address to be modified, then \r
+ EFI_INVALID_PARAMETER will be returned. If the station address is successfully\r
+ updated on the network interface, EFI_SUCCESS will be returned. If the driver\r
+ has not been initialized, EFI_DEVICE_ERROR will be returned.\r
+\r
+ @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
+ @param Reset Flag used to reset the station address to the network interface's \r
+ permanent address.\r
+ @param New New station address to be used for the network interface.\r
+\r
+\r
+ @retval EFI_SUCCESS The network interface's station address was updated.\r
+ @retval EFI_NOT_STARTED The Simple Network Protocol interface has not been \r
+ started by calling Start().\r
+ @retval EFI_INVALID_PARAMETER The New station address was not accepted by the NIC.\r
+ @retval EFI_INVALID_PARAMETER Reset is FALSE and New is NULL.\r
+ @retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not \r
+ been initialized by calling Initialize().\r
+ @retval EFI_DEVICE_ERROR An error occurred attempting to set the new \r
+ station address.\r
+ @retval EFI_UNSUPPORTED The NIC does not support changing the network \r
+ interface's station address.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
-snp_undi32_station_address (\r
- IN EFI_SIMPLE_NETWORK_PROTOCOL * this,\r
- IN BOOLEAN ResetFlag,\r
- IN EFI_MAC_ADDRESS * NewMacAddr OPTIONAL\r
+SnpUndi32StationAddress (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
+ IN BOOLEAN Reset,\r
+ IN EFI_MAC_ADDRESS *New OPTIONAL\r
)\r
{\r
- SNP_DRIVER *snp;\r
+ SNP_DRIVER *Snp;\r
EFI_STATUS Status;\r
EFI_TPL OldTpl;\r
\r
//\r
// Check for invalid parameter combinations.\r
//\r
- if ((this == NULL) ||\r
- (!ResetFlag && (NewMacAddr == NULL))) {\r
+ if ((This == NULL) ||\r
+ (!Reset && (New == NULL))) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);\r
+ Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
\r
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
//\r
// Return error if the SNP is not initialized.\r
//\r
- switch (snp->mode.State) {\r
+ switch (Snp->Mode.State) {\r
case EfiSimpleNetworkInitialized:\r
break;\r
\r
goto ON_EXIT;\r
}\r
\r
- if (ResetFlag) {\r
- Status = pxe_set_stn_addr (snp, NULL);\r
+ if (Reset) {\r
+ Status = PxeSetStnAddr (Snp, NULL);\r
} else {\r
- Status = pxe_set_stn_addr (snp, NewMacAddr);\r
+ Status = PxeSetStnAddr (Snp, New);\r
}\r
\r
ON_EXIT:\r