/** @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 initializing a network adapter.\r
+\r
+Copyright (c) 2004 - 2008, Intel Corporation. <BR> \r
+All rights reserved. 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
- initialize.c\r
-\r
-Abstract:\r
-\r
-Revision history:\r
- 2000-Feb-09 M(f)J Genesis.\r
-\r
**/\r
\r
\r
#include "Snp.h"\r
\r
-VOID\r
-EFIAPI\r
-SnpWaitForPacketNotify (\r
- IN EFI_EVENT Event,\r
- IN VOID *SnpPtr\r
- );\r
-\r
-\r
/**\r
- this routine calls undi to initialize the interface.\r
-\r
- @param snp pointer to snp driver structure\r
- @param CableDetectFlag Do/don't detect the cable (depending on what undi\r
- supports)\r
+ Call UNDI to initialize the interface.\r
\r
+ @param Snp Pointer to snp driver structure.\r
+ @param CableDetectFlag Do/don't detect the cable (depending on what \r
+ undi supports).\r
+ \r
+ @retval EFI_SUCCESS UNDI is initialized successfully.\r
+ @retval EFI_DEVICE_ERROR UNDI could not be initialized.\r
+ @retval Other Other errors as indicated.\r
\r
**/\r
EFI_STATUS\r
-pxe_init (\r
- SNP_DRIVER *snp,\r
+PxeInit (\r
+ SNP_DRIVER *Snp,\r
UINT16 CableDetectFlag\r
)\r
{\r
- PXE_CPB_INITIALIZE *cpb;\r
- VOID *addr;\r
+ PXE_CPB_INITIALIZE *Cpb;\r
+ VOID *Addr;\r
EFI_STATUS Status;\r
\r
- cpb = snp->cpb;\r
- if (snp->tx_rx_bufsize != 0) {\r
- Status = snp->IoFncs->AllocateBuffer (\r
- snp->IoFncs,\r
- AllocateAnyPages,\r
- EfiBootServicesData,\r
- SNP_MEM_PAGES (snp->tx_rx_bufsize),\r
- &addr,\r
- 0\r
- );\r
+ Cpb = Snp->Cpb;\r
+ if (Snp->TxRxBufferSize != 0) {\r
+ Status = Snp->PciIo->AllocateBuffer (\r
+ Snp->PciIo,\r
+ AllocateAnyPages,\r
+ EfiBootServicesData,\r
+ SNP_MEM_PAGES (Snp->TxRxBufferSize),\r
+ &Addr,\r
+ 0\r
+ );\r
\r
if (Status != EFI_SUCCESS) {\r
DEBUG (\r
(EFI_D_ERROR,\r
- "\nsnp->pxe_init() AllocateBuffer %xh (%r)\n",\r
+ "\nSnp->PxeInit() AllocateBuffer %xh (%r)\n",\r
Status,\r
Status)\r
);\r
return Status;\r
}\r
\r
- ASSERT (addr);\r
+ ASSERT (Addr);\r
\r
- snp->tx_rx_buffer = addr;\r
+ Snp->TxRxBuffer = Addr;\r
}\r
\r
- cpb->MemoryAddr = (UINT64)(UINTN) snp->tx_rx_buffer;\r
+ Cpb->MemoryAddr = (UINT64)(UINTN) Snp->TxRxBuffer;\r
\r
- cpb->MemoryLength = snp->tx_rx_bufsize;\r
+ Cpb->MemoryLength = Snp->TxRxBufferSize;\r
\r
//\r
// let UNDI decide/detect these values\r
//\r
- cpb->LinkSpeed = 0;\r
- cpb->TxBufCnt = 0;\r
- cpb->TxBufSize = 0;\r
- cpb->RxBufCnt = 0;\r
- cpb->RxBufSize = 0;\r
+ Cpb->LinkSpeed = 0;\r
+ Cpb->TxBufCnt = 0;\r
+ Cpb->TxBufSize = 0;\r
+ Cpb->RxBufCnt = 0;\r
+ Cpb->RxBufSize = 0;\r
\r
- cpb->DuplexMode = PXE_DUPLEX_DEFAULT;\r
+ Cpb->DuplexMode = PXE_DUPLEX_DEFAULT;\r
\r
- cpb->LoopBackMode = LOOPBACK_NORMAL;\r
+ Cpb->LoopBackMode = LOOPBACK_NORMAL;\r
\r
- snp->cdb.OpCode = PXE_OPCODE_INITIALIZE;\r
- snp->cdb.OpFlags = CableDetectFlag;\r
+ Snp->Cdb.OpCode = PXE_OPCODE_INITIALIZE;\r
+ Snp->Cdb.OpFlags = CableDetectFlag;\r
\r
- snp->cdb.CPBsize = sizeof (PXE_CPB_INITIALIZE);\r
- snp->cdb.DBsize = sizeof (PXE_DB_INITIALIZE);\r
+ Snp->Cdb.CPBsize = sizeof (PXE_CPB_INITIALIZE);\r
+ Snp->Cdb.DBsize = sizeof (PXE_DB_INITIALIZE);\r
\r
- snp->cdb.CPBaddr = (UINT64)(UINTN) snp->cpb;\r
- snp->cdb.DBaddr = (UINT64)(UINTN) snp->db;\r
+ Snp->Cdb.CPBaddr = (UINT64)(UINTN) Snp->Cpb;\r
+ Snp->Cdb.DBaddr = (UINT64)(UINTN) Snp->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
- DEBUG ((EFI_D_NET, "\nsnp->undi.initialize() "));\r
+ DEBUG ((EFI_D_NET, "\nSnp->undi.initialize() "));\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
- snp->mode.State = EfiSimpleNetworkInitialized;\r
+ if (Snp->Cdb.StatCode == PXE_STATCODE_SUCCESS) {\r
+ Snp->Mode.State = EfiSimpleNetworkInitialized;\r
\r
Status = EFI_SUCCESS;\r
} else {\r
DEBUG (\r
(EFI_D_WARN,\r
- "\nsnp->undi.initialize() %xh:%xh\n",\r
- snp->cdb.StatFlags,\r
- snp->cdb.StatCode)\r
+ "\nSnp->undi.initialize() %xh:%xh\n",\r
+ Snp->Cdb.StatFlags,\r
+ Snp->Cdb.StatCode)\r
);\r
\r
- if (snp->tx_rx_buffer != NULL) {\r
- snp->IoFncs->FreeBuffer (\r
- snp->IoFncs,\r
- SNP_MEM_PAGES (snp->tx_rx_bufsize),\r
- (VOID *) snp->tx_rx_buffer\r
+ if (Snp->TxRxBuffer != NULL) {\r
+ Snp->PciIo->FreeBuffer (\r
+ Snp->PciIo,\r
+ SNP_MEM_PAGES (Snp->TxRxBufferSize),\r
+ (VOID *) Snp->TxRxBuffer\r
);\r
}\r
\r
- snp->tx_rx_buffer = NULL;\r
+ Snp->TxRxBuffer = NULL;\r
\r
- Status = EFI_DEVICE_ERROR;\r
+ Status = EFI_DEVICE_ERROR;\r
}\r
\r
return Status;\r
\r
\r
/**\r
- This is the SNP interface routine for initializing the interface\r
- This routine basically retrieves snp structure, checks the SNP state and\r
- calls the pxe_initialize routine to actually do the undi initialization\r
-\r
- @param this context pointer\r
- @param extra_rx_buffer_size optional parameter, indicates extra space for\r
- rx_buffers\r
- @param extra_tx_buffer_size optional parameter, indicates extra space for\r
- tx_buffers\r
-\r
+ Resets a network adapter and allocates the transmit and receive buffers \r
+ required by the network interface; optionally, also requests allocation of \r
+ additional transmit and receive buffers.\r
+\r
+ This function allocates the transmit and receive buffers required by the network\r
+ interface. If this allocation fails, then EFI_OUT_OF_RESOURCES is returned.\r
+ If the allocation succeeds and the network interface is successfully initialized,\r
+ then EFI_SUCCESS will be returned.\r
+\r
+ @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
+\r
+ @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+ that the driver should allocate for the network interface.\r
+ Some network interfaces will not be able to use the \r
+ extra buffer, and the caller will not know if it is \r
+ actually being used.\r
+ @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+ that the driver should allocate for the network interface.\r
+ Some network interfaces will not be able to use the\r
+ extra buffer, and the caller will not know if it is\r
+ actually being used.\r
+\r
+ @retval EFI_SUCCESS The network interface was initialized.\r
+ @retval EFI_NOT_STARTED The network interface has not been started.\r
+ @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and\r
+ receive buffers.\r
+ @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
+ EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
+ @retval EFI_UNSUPPORTED The increased buffer size feature is not supported.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
-snp_undi32_initialize (\r
- IN EFI_SIMPLE_NETWORK_PROTOCOL *this,\r
- IN UINTN extra_rx_buffer_size OPTIONAL,\r
- IN UINTN extra_tx_buffer_size OPTIONAL\r
+SnpUndi32Initialize (\r
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
+ IN UINTN ExtraRxBufferSize OPTIONAL,\r
+ IN UINTN ExtraTxBufferSize OPTIONAL\r
)\r
{\r
EFI_STATUS EfiStatus;\r
- SNP_DRIVER *snp;\r
+ SNP_DRIVER *Snp;\r
EFI_TPL OldTpl;\r
\r
- //\r
- //\r
- //\r
- if (this == NULL) {\r
+ if (This == 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
- if (snp == NULL) {\r
+ if (Snp == NULL) {\r
EfiStatus = EFI_INVALID_PARAMETER;\r
goto ON_EXIT;\r
}\r
\r
- switch (snp->mode.State) {\r
+ switch (Snp->Mode.State) {\r
case EfiSimpleNetworkStarted:\r
break;\r
\r
EVT_NOTIFY_WAIT,\r
TPL_NOTIFY,\r
&SnpWaitForPacketNotify,\r
- snp,\r
- &snp->snp.WaitForPacket\r
+ Snp,\r
+ &Snp->Snp.WaitForPacket\r
);\r
\r
if (EFI_ERROR (EfiStatus)) {\r
- snp->snp.WaitForPacket = NULL;\r
+ Snp->Snp.WaitForPacket = NULL;\r
EfiStatus = EFI_DEVICE_ERROR;\r
goto ON_EXIT;\r
}\r
//\r
//\r
//\r
- snp->mode.MCastFilterCount = 0;\r
- snp->mode.ReceiveFilterSetting = 0;\r
- ZeroMem (snp->mode.MCastFilter, sizeof snp->mode.MCastFilter);\r
+ Snp->Mode.MCastFilterCount = 0;\r
+ Snp->Mode.ReceiveFilterSetting = 0;\r
+ ZeroMem (Snp->Mode.MCastFilter, sizeof Snp->Mode.MCastFilter);\r
CopyMem (\r
- &snp->mode.CurrentAddress,\r
- &snp->mode.PermanentAddress,\r
+ &Snp->Mode.CurrentAddress,\r
+ &Snp->Mode.PermanentAddress,\r
sizeof (EFI_MAC_ADDRESS)\r
);\r
\r
//\r
// Compute tx/rx buffer sizes based on UNDI init info and parameters.\r
//\r
- snp->tx_rx_bufsize = (UINT32) (snp->init_info.MemoryRequired + extra_rx_buffer_size + extra_tx_buffer_size);\r
+ Snp->TxRxBufferSize = (UINT32) (Snp->InitInfo.MemoryRequired + ExtraRxBufferSize + ExtraTxBufferSize);\r
\r
- if (snp->mode.MediaPresentSupported) {\r
- if (pxe_init (snp, PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) == EFI_SUCCESS) {\r
- snp->mode.MediaPresent = TRUE;\r
+ if (Snp->Mode.MediaPresentSupported) {\r
+ if (PxeInit (Snp, PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) == EFI_SUCCESS) {\r
+ Snp->Mode.MediaPresent = TRUE;\r
goto ON_EXIT;\r
}\r
}\r
\r
- snp->mode.MediaPresent = FALSE;\r
+ Snp->Mode.MediaPresent = FALSE;\r
\r
- EfiStatus = pxe_init (snp, PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE);\r
+ EfiStatus = PxeInit (Snp, PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE);\r
\r
if (EFI_ERROR (EfiStatus)) {\r
- gBS->CloseEvent (snp->snp.WaitForPacket);\r
+ gBS->CloseEvent (Snp->Snp.WaitForPacket);\r
}\r
\r
ON_EXIT:\r