git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4735 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2008-02-20 02:42:59 +00:00
parent a3c5f87a01
commit 1d13665edd
16 changed files with 16 additions and 4191 deletions

View File

@ -33,24 +33,24 @@
#
[Sources.common]
receive.c
snp.h
nvdata.c
get_status.c
start.c
snp.c
stop.c
statistics.c
reset.c
shutdown.c
mcast_ip_to_mac.c
transmit.c
Receive.c
Snp.h
Nvdata.c
Get_status.c
Start.c
Snp.c
Stop.c
Statistics.c
Reset.c
Shutdown.c
Mcast_ip_to_mac.c
Transmit.c
WaitForPacket.c
receive_filters.c
initialize.c
Receive_filters.c
Iitialize.c
ComponentName.c
callback.c
station_address.c
Callback.c
Station_address.c
[Packages]

View File

@ -1,190 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
get_status.c
Abstract:
Revision history:
2000-Feb-03 M(f)J Genesis.
**/
#include "Snp.h"
STATIC
/**
this routine calls undi to get the status of the interrupts, get the list of
transmit buffers that completed transmitting!
@param snp pointer to snp driver structure
@param InterruptStatusPtr a non null pointer gets the interrupt status
@param TransmitBufferListPtrs a non null ointer gets the list of pointers of
previously transmitted buffers whose
transmission was completed asynchrnously.
**/
EFI_STATUS
pxe_getstatus (
SNP_DRIVER *snp,
UINT32 *InterruptStatusPtr,
VOID **TransmitBufferListPtr
)
{
PXE_DB_GET_STATUS *db;
UINT16 InterruptFlags;
db = snp->db;
snp->cdb.OpCode = PXE_OPCODE_GET_STATUS;
snp->cdb.OpFlags = 0;
if (TransmitBufferListPtr != NULL) {
snp->cdb.OpFlags |= PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS;
}
if (InterruptStatusPtr != NULL) {
snp->cdb.OpFlags |= PXE_OPFLAGS_GET_INTERRUPT_STATUS;
}
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
//
// size DB for return of one buffer
//
snp->cdb.DBsize = (UINT16) (((UINT16) (sizeof (PXE_DB_GET_STATUS)) - (UINT16) (sizeof db->TxBuffer)) + (UINT16) (sizeof db->TxBuffer[0]));
snp->cdb.DBaddr = (UINT64)(UINTN) db;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.get_status() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != EFI_SUCCESS) {
DEBUG (
(EFI_D_NET,
"\nsnp->undi.get_status() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatFlags)
);
return EFI_DEVICE_ERROR;
}
//
// report the values back..
//
if (InterruptStatusPtr != NULL) {
InterruptFlags = (UINT16) (snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK);
*InterruptStatusPtr = 0;
if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_RECEIVE) {
*InterruptStatusPtr |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;
}
if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_TRANSMIT) {
*InterruptStatusPtr |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
}
if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_COMMAND) {
*InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;
}
if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_SOFTWARE) {
*InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;
}
}
if (TransmitBufferListPtr != NULL) {
*TransmitBufferListPtr =
(
(snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN) ||
(snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY)
) ? 0 : (VOID *) (UINTN) db->TxBuffer[0];
}
return EFI_SUCCESS;
}
/**
This is the SNP interface routine for getting the status
This routine basically retrieves snp structure, checks the SNP state and
calls the pxe_getstatus routine to actually get the undi status
@param this context pointer
@param InterruptStatusPtr a non null pointer gets the interrupt status
@param TransmitBufferListPtrs a non null ointer gets the list of pointers of
previously transmitted buffers whose
transmission was completed asynchrnously.
**/
EFI_STATUS
EFIAPI
snp_undi32_get_status (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
OUT UINT32 *InterruptStatusPtr OPTIONAL,
OUT VOID **TransmitBufferListPtr OPTIONAL
)
{
SNP_DRIVER *snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
if (InterruptStatusPtr == NULL && TransmitBufferListPtr == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (snp == NULL) {
return EFI_DEVICE_ERROR;
}
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
Status = pxe_getstatus (snp, InterruptStatusPtr, TransmitBufferListPtr);
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,245 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
initialize.c
Abstract:
Revision history:
2000-Feb-09 M(f)J Genesis.
**/
#include "Snp.h"
VOID
EFIAPI
SnpWaitForPacketNotify (
IN EFI_EVENT Event,
IN VOID *SnpPtr
);
/**
this routine calls undi to initialize the interface.
@param snp pointer to snp driver structure
@param CableDetectFlag Do/don't detect the cable (depending on what undi
supports)
**/
EFI_STATUS
pxe_init (
SNP_DRIVER *snp,
UINT16 CableDetectFlag
)
{
PXE_CPB_INITIALIZE *cpb;
VOID *addr;
EFI_STATUS Status;
cpb = snp->cpb;
if (snp->tx_rx_bufsize != 0) {
Status = snp->IoFncs->AllocateBuffer (
snp->IoFncs,
AllocateAnyPages,
EfiBootServicesData,
SNP_MEM_PAGES (snp->tx_rx_bufsize),
&addr,
0
);
if (Status != EFI_SUCCESS) {
DEBUG (
(EFI_D_ERROR,
"\nsnp->pxe_init() AllocateBuffer %xh (%r)\n",
Status,
Status)
);
return Status;
}
ASSERT (addr);
snp->tx_rx_buffer = addr;
}
cpb->MemoryAddr = (UINT64)(UINTN) snp->tx_rx_buffer;
cpb->MemoryLength = snp->tx_rx_bufsize;
//
// let UNDI decide/detect these values
//
cpb->LinkSpeed = 0;
cpb->TxBufCnt = 0;
cpb->TxBufSize = 0;
cpb->RxBufCnt = 0;
cpb->RxBufSize = 0;
cpb->DuplexMode = PXE_DUPLEX_DEFAULT;
cpb->LoopBackMode = LOOPBACK_NORMAL;
snp->cdb.OpCode = PXE_OPCODE_INITIALIZE;
snp->cdb.OpFlags = CableDetectFlag;
snp->cdb.CPBsize = sizeof (PXE_CPB_INITIALIZE);
snp->cdb.DBsize = sizeof (PXE_DB_INITIALIZE);
snp->cdb.CPBaddr = (UINT64)(UINTN) snp->cpb;
snp->cdb.DBaddr = (UINT64)(UINTN) snp->db;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
DEBUG ((EFI_D_NET, "\nsnp->undi.initialize() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode == PXE_STATCODE_SUCCESS) {
snp->mode.State = EfiSimpleNetworkInitialized;
Status = EFI_SUCCESS;
} else {
DEBUG (
(EFI_D_WARN,
"\nsnp->undi.initialize() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
if (snp->tx_rx_buffer != NULL) {
snp->IoFncs->FreeBuffer (
snp->IoFncs,
SNP_MEM_PAGES (snp->tx_rx_bufsize),
(VOID *) snp->tx_rx_buffer
);
}
snp->tx_rx_buffer = NULL;
Status = EFI_DEVICE_ERROR;
}
return Status;
}
/**
This is the SNP interface routine for initializing the interface
This routine basically retrieves snp structure, checks the SNP state and
calls the pxe_initialize routine to actually do the undi initialization
@param this context pointer
@param extra_rx_buffer_size optional parameter, indicates extra space for
rx_buffers
@param extra_tx_buffer_size optional parameter, indicates extra space for
tx_buffers
**/
EFI_STATUS
EFIAPI
snp_undi32_initialize (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
IN UINTN extra_rx_buffer_size OPTIONAL,
IN UINTN extra_tx_buffer_size OPTIONAL
)
{
EFI_STATUS EfiStatus;
SNP_DRIVER *snp;
EFI_TPL OldTpl;
//
//
//
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (snp == NULL) {
EfiStatus = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
switch (snp->mode.State) {
case EfiSimpleNetworkStarted:
break;
case EfiSimpleNetworkStopped:
EfiStatus = EFI_NOT_STARTED;
goto ON_EXIT;
default:
EfiStatus = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
EfiStatus = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
&SnpWaitForPacketNotify,
snp,
&snp->snp.WaitForPacket
);
if (EFI_ERROR (EfiStatus)) {
snp->snp.WaitForPacket = NULL;
EfiStatus = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
//
//
//
snp->mode.MCastFilterCount = 0;
snp->mode.ReceiveFilterSetting = 0;
ZeroMem (snp->mode.MCastFilter, sizeof snp->mode.MCastFilter);
CopyMem (
&snp->mode.CurrentAddress,
&snp->mode.PermanentAddress,
sizeof (EFI_MAC_ADDRESS)
);
//
// Compute tx/rx buffer sizes based on UNDI init info and parameters.
//
snp->tx_rx_bufsize = (UINT32) (snp->init_info.MemoryRequired + extra_rx_buffer_size + extra_tx_buffer_size);
if (snp->mode.MediaPresentSupported) {
if (pxe_init (snp, PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) == EFI_SUCCESS) {
snp->mode.MediaPresent = TRUE;
goto ON_EXIT;
}
}
snp->mode.MediaPresent = FALSE;
EfiStatus = pxe_init (snp, PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE);
if (EFI_ERROR (EfiStatus)) {
gBS->CloseEvent (snp->snp.WaitForPacket);
}
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return EfiStatus;
}

View File

@ -1,165 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
mcast_ip_to_mac.c
Abstract:
Revision history:
2000-Feb-17 M(f)J Genesis.
**/
#include "Snp.h"
/**
this routine calls undi to convert an multicast IP address to a MAC address
@param snp pointer to snp driver structure
@param IPv6 flag to indicate if this is an ipv6 address
@param IP multicast IP address
@param MAC pointer to hold the return MAC address
**/
STATIC
EFI_STATUS
pxe_ip2mac (
IN SNP_DRIVER *snp,
IN BOOLEAN IPv6,
IN EFI_IP_ADDRESS *IP,
IN OUT EFI_MAC_ADDRESS *MAC
)
{
PXE_CPB_MCAST_IP_TO_MAC *cpb;
PXE_DB_MCAST_IP_TO_MAC *db;
cpb = snp->cpb;
db = snp->db;
snp->cdb.OpCode = PXE_OPCODE_MCAST_IP_TO_MAC;
snp->cdb.OpFlags = (UINT16) (IPv6 ? PXE_OPFLAGS_MCAST_IPV6_TO_MAC : PXE_OPFLAGS_MCAST_IPV4_TO_MAC);
snp->cdb.CPBsize = sizeof (PXE_CPB_MCAST_IP_TO_MAC);
snp->cdb.DBsize = sizeof (PXE_DB_MCAST_IP_TO_MAC);
snp->cdb.CPBaddr = (UINT64)(UINTN) cpb;
snp->cdb.DBaddr = (UINT64)(UINTN) db;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
CopyMem (&cpb->IP, IP, sizeof (PXE_IP_ADDR));
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.mcast_ip_to_mac() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
switch (snp->cdb.StatCode) {
case PXE_STATCODE_SUCCESS:
break;
case PXE_STATCODE_INVALID_CPB:
return EFI_INVALID_PARAMETER;
case PXE_STATCODE_UNSUPPORTED:
DEBUG (
(EFI_D_NET,
"\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_UNSUPPORTED;
default:
//
// UNDI command failed. Return EFI_DEVICE_ERROR
// to caller.
//
DEBUG (
(EFI_D_NET,
"\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_DEVICE_ERROR;
}
CopyMem (MAC, &db->MAC, sizeof (PXE_MAC_ADDR));
return EFI_SUCCESS;
}
/**
This is the SNP interface routine for converting a multicast IP address to
a MAC address.
This routine basically retrieves snp structure, checks the SNP state and
calls the pxe_ip2mac routine to actually do the conversion
@param this context pointer
@param IPv6 flag to indicate if this is an ipv6 address
@param IP multicast IP address
@param MAC pointer to hold the return MAC address
**/
EFI_STATUS
EFIAPI
snp_undi32_mcast_ip_to_mac (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
IN BOOLEAN IPv6,
IN EFI_IP_ADDRESS *IP,
OUT EFI_MAC_ADDRESS *MAC
)
{
SNP_DRIVER *snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
//
// Get pointer to SNP driver instance for *this.
//
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
if (IP == NULL || MAC == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
Status = pxe_ip2mac (snp, IPv6, IP, MAC);
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,185 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
nvdata.c
Abstract:
Revision history:
2000-Feb-03 M(f)J Genesis.
**/
#include "snp.h"
/**
This routine calls Undi to read the desired number of eeprom bytes.
@param snp pointer to the snp driver structure
@param RegOffset eeprom register value relative to the base address
@param NumBytes number of bytes to read
@param BufferPtr pointer where to read into
**/
STATIC
EFI_STATUS
pxe_nvdata_read (
IN SNP_DRIVER *snp,
IN UINTN RegOffset,
IN UINTN NumBytes,
IN OUT VOID *BufferPtr
)
{
PXE_DB_NVDATA *db;
db = snp->db;
snp->cdb.OpCode = PXE_OPCODE_NVDATA;
snp->cdb.OpFlags = PXE_OPFLAGS_NVDATA_READ;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
snp->cdb.DBsize = sizeof (PXE_DB_NVDATA);
snp->cdb.DBaddr = (UINT64)(UINTN) db;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.nvdata () "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
switch (snp->cdb.StatCode) {
case PXE_STATCODE_SUCCESS:
break;
case PXE_STATCODE_UNSUPPORTED:
DEBUG (
(EFI_D_NET,
"\nsnp->undi.nvdata() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_UNSUPPORTED;
default:
DEBUG (
(EFI_D_NET,
"\nsnp->undi.nvdata() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_DEVICE_ERROR;
}
CopyMem (BufferPtr, db->Data.Byte + RegOffset, NumBytes);
return EFI_SUCCESS;
}
/**
This is an interface call provided by SNP.
It does the basic checking on the input parameters and retrieves snp structure
and then calls the read_nvdata() call which does the actual reading
@param this context pointer
@param ReadOrWrite true for reading and false for writing
@param RegOffset eeprom register relative to the base
@param NumBytes how many bytes to read
@param BufferPtr address of memory to read into
**/
EFI_STATUS
EFIAPI
snp_undi32_nvdata (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
IN BOOLEAN ReadOrWrite,
IN UINTN RegOffset,
IN UINTN NumBytes,
IN OUT VOID *BufferPtr
)
{
SNP_DRIVER *snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
//
// Get pointer to SNP driver instance for *this.
//
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Return error if the SNP is not initialized.
//
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
//
// Return error if non-volatile memory variables are not valid.
//
if (snp->mode.NvRamSize == 0 || snp->mode.NvRamAccessSize == 0) {
Status = EFI_UNSUPPORTED;
goto ON_EXIT;
}
//
// Check for invalid parameter combinations.
//
if ((NumBytes == 0) ||
(BufferPtr == NULL) ||
(RegOffset >= snp->mode.NvRamSize) ||
(RegOffset + NumBytes > snp->mode.NvRamSize) ||
(NumBytes % snp->mode.NvRamAccessSize != 0) ||
(RegOffset % snp->mode.NvRamAccessSize != 0)
) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
//
// check the implementation flags of undi if we can write the nvdata!
//
if (!ReadOrWrite) {
Status = EFI_UNSUPPORTED;
} else {
Status = pxe_nvdata_read (snp, RegOffset, NumBytes, BufferPtr);
}
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,216 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
receive.c
Abstract:
Revision history:
2000-Feb-03 M(f)J Genesis.
**/
#include "Snp.h"
/**
this routine calls undi to receive a packet and fills in the data in the
input pointers!
@param snp pointer to snp driver structure
@param BufferPtr pointer to the memory for the received data
@param BuffSizePtr is a pointer to the length of the buffer on entry and
contains the length of the received data on return
@param HeaderSizePtr pointer to the header portion of the data received.
@param SourceAddrPtr optional parameter, is a pointer to contain the
source ethernet address on return
@param DestinationAddrPtr optional parameter, is a pointer to contain the
destination ethernet address on return
@param ProtocolPtr optional parameter, is a pointer to contain the
protocol type from the ethernet header on return
**/
STATIC
EFI_STATUS
pxe_receive (
SNP_DRIVER *snp,
VOID *BufferPtr,
UINTN *BuffSizePtr,
UINTN *HeaderSizePtr,
EFI_MAC_ADDRESS *SourceAddrPtr,
EFI_MAC_ADDRESS *DestinationAddrPtr,
UINT16 *ProtocolPtr
)
{
PXE_CPB_RECEIVE *cpb;
PXE_DB_RECEIVE *db;
UINTN buf_size;
cpb = snp->cpb;
db = snp->db;
buf_size = *BuffSizePtr;
cpb->BufferAddr = (UINT64)(UINTN) BufferPtr;
cpb->BufferLen = (UINT32) *BuffSizePtr;
cpb->reserved = 0;
snp->cdb.OpCode = PXE_OPCODE_RECEIVE;
snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
snp->cdb.CPBsize = sizeof (PXE_CPB_RECEIVE);
snp->cdb.CPBaddr = (UINT64)(UINTN) cpb;
snp->cdb.DBsize = sizeof (PXE_DB_RECEIVE);
snp->cdb.DBaddr = (UINT64)(UINTN) db;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.receive () "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
switch (snp->cdb.StatCode) {
case PXE_STATCODE_SUCCESS:
break;
case PXE_STATCODE_NO_DATA:
DEBUG (
(EFI_D_NET,
"\nsnp->undi.receive () %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_NOT_READY;
default:
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.receive() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_DEVICE_ERROR;
}
*BuffSizePtr = db->FrameLen;
if (HeaderSizePtr != NULL) {
*HeaderSizePtr = db->MediaHeaderLen;
}
if (SourceAddrPtr != NULL) {
CopyMem (SourceAddrPtr, &db->SrcAddr, snp->mode.HwAddressSize);
}
if (DestinationAddrPtr != NULL) {
CopyMem (DestinationAddrPtr, &db->DestAddr, snp->mode.HwAddressSize);
}
if (ProtocolPtr != NULL) {
*ProtocolPtr = (UINT16) PXE_SWAP_UINT16 (db->Protocol); /* we need to do the byte swapping */
}
return (*BuffSizePtr <= buf_size) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL;
}
/**
This is the SNP interface routine for receiving network data.
This routine basically retrieves snp structure, checks the SNP state and
calls the pxe_receive routine to actually do the receive!
@param this context pointer
@param HeaderSizePtr optional parameter and is a pointer to the header
portion of the data received.
@param BuffSizePtr is a pointer to the length of the buffer on entry and
contains the length of the received data on return
@param BufferPtr pointer to the memory for the received data
@param SourceAddrPtr optional parameter, is a pointer to contain the
source ethernet address on return
@param DestinationAddrPtr optional parameter, is a pointer to contain the
destination ethernet address on return
@param ProtocolPtr optional parameter, is a pointer to contain the
protocol type from the ethernet header on return
**/
EFI_STATUS
EFIAPI
snp_undi32_receive (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
OUT UINTN *HeaderSizePtr OPTIONAL,
IN OUT UINTN *BuffSizePtr,
OUT VOID *BufferPtr,
OUT EFI_MAC_ADDRESS * SourceAddrPtr OPTIONAL,
OUT EFI_MAC_ADDRESS * DestinationAddrPtr OPTIONAL,
OUT UINT16 *ProtocolPtr OPTIONAL
)
{
SNP_DRIVER *snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
if ((BuffSizePtr == NULL) || (BufferPtr == NULL)) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
if (!snp->mode.ReceiveFilterSetting) {
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
Status = pxe_receive (
snp,
BufferPtr,
BuffSizePtr,
HeaderSizePtr,
SourceAddrPtr,
DestinationAddrPtr,
ProtocolPtr
);
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,406 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
receive_filters.c
Abstract:
Revision history:
2000-Feb-17 M(f)J Genesis.
**/
#include "Snp.h"
/**
this routine calls undi to enable the receive filters.
@param snp pointer to snp driver structure
@param EnableFlags bit mask for enabling the receive filters
@param MCastAddressCount multicast address count for a new multicast address
list
@param MCastAddressList list of new multicast addresses
**/
STATIC
EFI_STATUS
pxe_rcvfilter_enable (
SNP_DRIVER *snp,
UINT32 EnableFlags,
UINTN MCastAddressCount,
EFI_MAC_ADDRESS *MCastAddressList
)
{
snp->cdb.OpCode = PXE_OPCODE_RECEIVE_FILTERS;
snp->cdb.OpFlags = PXE_OPFLAGS_RECEIVE_FILTER_ENABLE;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_UNICAST) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_UNICAST;
}
if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST;
}
if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS;
}
if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST;
}
if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST;
}
if (MCastAddressCount != 0) {
snp->cdb.CPBsize = (UINT16) (MCastAddressCount * sizeof (EFI_MAC_ADDRESS));
snp->cdb.CPBaddr = (UINT64)(UINTN) snp->cpb;
CopyMem (snp->cpb, MCastAddressList, snp->cdb.CPBsize);
}
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.receive_filters() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != EFI_SUCCESS) {
//
// UNDI command failed. Return UNDI status to caller.
//
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.receive_filters() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
switch (snp->cdb.StatCode) {
case PXE_STATCODE_INVALID_CDB:
case PXE_STATCODE_INVALID_CPB:
case PXE_STATCODE_INVALID_PARAMETER:
return EFI_INVALID_PARAMETER;
case PXE_STATCODE_UNSUPPORTED:
return EFI_UNSUPPORTED;
}
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
/**
this routine calls undi to disable the receive filters.
@param snp pointer to snp driver structure
@param DisableFlags bit mask for disabling the receive filters
@param ResetMCastList boolean flag to reset/delete the multicast filter list
**/
STATIC
EFI_STATUS
pxe_rcvfilter_disable (
SNP_DRIVER *snp,
UINT32 DisableFlags,
BOOLEAN ResetMCastList
)
{
snp->cdb.OpCode = PXE_OPCODE_RECEIVE_FILTERS;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
snp->cdb.OpFlags = (UINT16) (DisableFlags ? PXE_OPFLAGS_RECEIVE_FILTER_DISABLE : PXE_OPFLAGS_NOT_USED);
if (ResetMCastList) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST;
}
if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_UNICAST) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_UNICAST;
}
if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST;
}
if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS;
}
if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST;
}
if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) {
snp->cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST;
}
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.receive_filters() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != EFI_SUCCESS) {
//
// UNDI command failed. Return UNDI status to caller.
//
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.receive_filters() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
/**
this routine calls undi to read the receive filters.
@param snp pointer to snp driver structure
**/
STATIC
EFI_STATUS
pxe_rcvfilter_read (
SNP_DRIVER *snp
)
{
snp->cdb.OpCode = PXE_OPCODE_RECEIVE_FILTERS;
snp->cdb.OpFlags = PXE_OPFLAGS_RECEIVE_FILTER_READ;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.DBsize = (UINT16) (snp->mode.MaxMCastFilterCount * sizeof (EFI_MAC_ADDRESS));
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
if (snp->cdb.DBsize == 0) {
snp->cdb.DBaddr = (UINT64)(UINTN) NULL;
} else {
snp->cdb.DBaddr = (UINT64)(UINTN) snp->db;
ZeroMem (snp->db, snp->cdb.DBsize);
}
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
DEBUG ((EFI_D_NET, "\nsnp->undi.receive_filters() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != EFI_SUCCESS) {
//
// UNDI command failed. Return UNDI status to caller.
//
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.receive_filters() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_DEVICE_ERROR;
}
//
// Convert UNDI32 StatFlags to EFI SNP filter flags.
//
snp->mode.ReceiveFilterSetting = 0;
if ((snp->cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_UNICAST) != 0) {
snp->mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_UNICAST;
}
if ((snp->cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_BROADCAST) != 0) {
snp->mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;
}
if ((snp->cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_PROMISCUOUS) != 0) {
snp->mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;
}
if ((snp->cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_ALL_MULTICAST) != 0) {
snp->mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;
}
if ((snp->cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST) != 0) {
snp->mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST;
}
CopyMem (snp->mode.MCastFilter, snp->db, snp->cdb.DBsize);
//
// Count number of active entries in multicast filter list.
//
{
EFI_MAC_ADDRESS ZeroMacAddr;
SetMem (&ZeroMacAddr, sizeof ZeroMacAddr, 0);
for (snp->mode.MCastFilterCount = 0;
snp->mode.MCastFilterCount < snp->mode.MaxMCastFilterCount;
snp->mode.MCastFilterCount++
) {
if (CompareMem (
&snp->mode.MCastFilter[snp->mode.MCastFilterCount],
&ZeroMacAddr,
sizeof ZeroMacAddr
) == 0) {
break;
}
}
}
return EFI_SUCCESS;
}
/**
This is the SNP interface routine for reading/enabling/disabling the
receive filters.
This routine basically retrieves snp structure, checks the SNP state and
checks the parameter validity, calls one of the above routines to actually
do the work
@param this context pointer
@param EnableFlags bit mask for enabling the receive filters
@param DisableFlags bit mask for disabling the receive filters
@param ResetMCastList boolean flag to reset/delete the multicast filter list
@param MCastAddressCount multicast address count for a new multicast address
list
@param MCastAddressList list of new multicast addresses
**/
EFI_STATUS
EFIAPI
snp_undi32_receive_filters (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
IN UINT32 EnableFlags,
IN UINT32 DisableFlags,
IN BOOLEAN ResetMCastList,
IN UINTN MCastAddressCount OPTIONAL,
IN EFI_MAC_ADDRESS * MCastAddressList OPTIONAL
)
{
SNP_DRIVER *snp;
EFI_STATUS Status;
EFI_TPL OldTpl;
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
//
// check if we are asked to enable or disable something that the UNDI
// does not even support!
//
if (((EnableFlags &~snp->mode.ReceiveFilterMask) != 0) ||
((DisableFlags &~snp->mode.ReceiveFilterMask) != 0)) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
if (ResetMCastList) {
DisableFlags |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST & snp->mode.ReceiveFilterMask;
MCastAddressCount = 0;
MCastAddressList = NULL;
} else {
if (MCastAddressCount != 0) {
if ((MCastAddressCount > snp->mode.MaxMCastFilterCount) ||
(MCastAddressList == NULL)) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
}
}
if (EnableFlags == 0 && DisableFlags == 0 && !ResetMCastList && MCastAddressCount == 0) {
Status = EFI_SUCCESS;
goto ON_EXIT;
}
if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0 && MCastAddressCount == 0) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
if ((EnableFlags != 0) || (MCastAddressCount != 0)) {
Status = pxe_rcvfilter_enable (
snp,
EnableFlags,
MCastAddressCount,
MCastAddressList
);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
}
if ((DisableFlags != 0) || ResetMCastList) {
Status = pxe_rcvfilter_disable (snp, DisableFlags, ResetMCastList);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
}
Status = pxe_rcvfilter_read (snp);
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,129 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
reset.c
Abstract:
Revision history:
2000-Feb-09 M(f)J Genesis.
**/
#include "Snp.h"
/**
This routine calls undi to reset the nic.
@param snp pointer to the snp driver structure
@return EFI_SUCCESSFUL for a successful completion
@return other for failed calls
**/
STATIC
EFI_STATUS
pxe_reset (
SNP_DRIVER *snp
)
{
snp->cdb.OpCode = PXE_OPCODE_RESET;
snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.reset() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {
DEBUG (
(EFI_D_WARN,
"\nsnp->undi32.reset() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
//
// UNDI could not be reset. Return UNDI error.
//
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
/**
This is the SNP interface routine for resetting the NIC
This routine basically retrieves snp structure, checks the SNP state and
calls the pxe_reset routine to actually do the reset!
@param this context pointer
@param ExtendedVerification not implemented
**/
EFI_STATUS
EFIAPI
snp_undi32_reset (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
IN BOOLEAN ExtendedVerification
)
{
SNP_DRIVER *snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
//
// Resolve Warning 4 unreferenced parameter problem
//
ExtendedVerification = 0;
DEBUG ((EFI_D_WARN, "ExtendedVerification = %d is not implemented!\n", ExtendedVerification));
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
Status = pxe_reset (snp);
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,148 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
shutdown.c
Abstract:
Revision history:
2000-Feb-14 M(f)J Genesis.
**/
#include "Snp.h"
/**
this routine calls undi to shut down the interface.
@param snp pointer to snp driver structure
**/
EFI_STATUS
pxe_shutdown (
IN SNP_DRIVER *snp
)
{
snp->cdb.OpCode = PXE_OPCODE_SHUTDOWN;
snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.shutdown() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {
//
// UNDI could not be shutdown. Return UNDI error.
//
DEBUG ((EFI_D_WARN, "\nsnp->undi.shutdown() %xh:%xh\n", snp->cdb.StatFlags, snp->cdb.StatCode));
return EFI_DEVICE_ERROR;
}
//
// Free allocated memory.
//
if (snp->tx_rx_buffer != NULL) {
snp->IoFncs->FreeBuffer (
snp->IoFncs,
SNP_MEM_PAGES (snp->tx_rx_bufsize),
(VOID *) snp->tx_rx_buffer
);
}
snp->tx_rx_buffer = NULL;
snp->tx_rx_bufsize = 0;
return EFI_SUCCESS;
}
/**
This is the SNP interface routine for shutting down the interface
This routine basically retrieves snp structure, checks the SNP state and
calls the pxe_shutdown routine to actually do the undi shutdown
@param this context pointer
**/
EFI_STATUS
EFIAPI
snp_undi32_shutdown (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this
)
{
SNP_DRIVER *snp;
EFI_STATUS Status;
EFI_TPL OldTpl;
//
//
//
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
//
//
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
//
//
//
Status = pxe_shutdown (snp);
snp->mode.State = EfiSimpleNetworkStarted;
snp->mode.ReceiveFilterSetting = 0;
snp->mode.MCastFilterCount = 0;
snp->mode.ReceiveFilterSetting = 0;
ZeroMem (snp->mode.MCastFilter, sizeof snp->mode.MCastFilter);
CopyMem (
&snp->mode.CurrentAddress,
&snp->mode.PermanentAddress,
sizeof (EFI_MAC_ADDRESS)
);
gBS->CloseEvent (snp->snp.WaitForPacket);
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,433 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
snp.h
Abstract:
Revision history:
**/
#ifndef _SNP_H
#define _SNP_H
#include <PiDxe.h>
#include <Protocol/SimpleNetwork.h>
#include <Protocol/PciIo.h>
#include <Protocol/NetworkInterfaceIdentifier.h>
#include <Protocol/DevicePath.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <IndustryStandard/Pci22.h>
#define FOUR_GIGABYTES (UINT64) 0x100000000ULL
#define SNP_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('s', 'n', 'd', 's')
#define MAX_MAP_LENGTH 100
#define PCI_BAR_IO_MASK 0x00000003
#define PCI_BAR_IO_MODE 0x00000001
#define PCI_BAR_MEM_MASK 0x0000000F
#define PCI_BAR_MEM_MODE 0x00000000
#define PCI_BAR_MEM_64BIT 0x00000004
typedef struct {
UINT32 Signature;
EFI_LOCK lock;
EFI_SIMPLE_NETWORK_PROTOCOL snp;
EFI_SIMPLE_NETWORK_MODE mode;
EFI_HANDLE device_handle;
EFI_DEVICE_PATH_PROTOCOL *device_path;
//
// Local instance data needed by SNP driver
//
// Pointer to S/W UNDI API entry point
// This will be NULL for H/W UNDI
//
EFI_STATUS (*issue_undi32_command) (UINT64 cdb);
BOOLEAN is_swundi;
//
// undi interface number, if one undi manages more nics
//
PXE_IFNUM if_num;
//
// Allocated tx/rx buffer that was passed to UNDI Initialize.
//
UINT32 tx_rx_bufsize;
VOID *tx_rx_buffer;
//
// mappable buffers for receive and fill header for undi3.0
// these will be used if the user buffers are above 4GB limit (instead of
// mapping the user buffers)
//
UINT8 *receive_buf;
VOID *ReceiveBufUnmap;
UINT8 *fill_hdr_buf;
VOID *FillHdrBufUnmap;
EFI_PCI_IO_PROTOCOL *IoFncs;
UINT8 IoBarIndex;
UINT8 MemoryBarIndex;
//
// Buffers for command descriptor block, command parameter block
// and data block.
//
PXE_CDB cdb;
VOID *cpb;
VOID *CpbUnmap;
VOID *db;
//
// UNDI structure, we need to remember the init info for a long time!
//
PXE_DB_GET_INIT_INFO init_info;
VOID *SnpDriverUnmap;
//
// when ever we map an address, we must remember it's address and the un-map
// cookie so that we can unmap later
//
struct s_map_list {
EFI_PHYSICAL_ADDRESS virt;
VOID *map_cookie;
} map_list[MAX_MAP_LENGTH];
}
SNP_DRIVER;
#define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, snp, SNP_DRIVER_SIGNATURE)
//
// Global Variables
//
extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2;
//
// Virtual to physical mapping for all UNDI 3.0s.
//
extern struct s_v2p {
struct s_v2p *next;
VOID *vaddr;
UINTN bsize;
EFI_PHYSICAL_ADDRESS paddr;
VOID *unmap;
}
*_v2p;
EFI_STATUS
add_v2p (
struct s_v2p **v2p,
EFI_PCI_IO_PROTOCOL_OPERATION type,
VOID *vaddr,
UINTN bsize
)
;
EFI_STATUS
find_v2p (
struct s_v2p **v2p,
VOID *vaddr
)
;
EFI_STATUS
del_v2p (
VOID *vaddr
)
;
extern
VOID
snp_undi32_callback_block_30 (
IN UINT32 Enable
)
;
extern
VOID
snp_undi32_callback_delay_30 (
IN UINT64 MicroSeconds
)
;
extern
VOID
snp_undi32_callback_memio_30 (
IN UINT8 ReadOrWrite,
IN UINT8 NumBytes,
IN UINT64 MemOrPortAddress,
IN OUT UINT64 BufferPtr
)
;
extern
VOID
snp_undi32_callback_v2p_30 (
IN UINT64 CpuAddr,
IN OUT UINT64 DeviceAddrPtr
)
;
extern
VOID
snp_undi32_callback_block (
IN UINT64 UniqueId,
IN UINT32 Enable
)
;
extern
VOID
snp_undi32_callback_delay (
IN UINT64 UniqueId,
IN UINT64 MicroSeconds
)
;
extern
VOID
snp_undi32_callback_memio (
IN UINT64 UniqueId,
IN UINT8 ReadOrWrite,
IN UINT8 NumBytes,
IN UINT64 MemOrPortAddr,
IN OUT UINT64 BufferPtr
)
;
extern
VOID
snp_undi32_callback_map (
IN UINT64 UniqueId,
IN UINT64 CpuAddr,
IN UINT32 NumBytes,
IN UINT32 Direction,
IN OUT UINT64 DeviceAddrPtr
)
;
extern
VOID
snp_undi32_callback_unmap (
IN UINT64 UniqueId,
IN UINT64 CpuAddr,
IN UINT32 NumBytes,
IN UINT32 Direction,
IN UINT64 DeviceAddr // not a pointer to device address
)
;
extern
VOID
snp_undi32_callback_sync (
IN UINT64 UniqueId,
IN UINT64 CpuAddr,
IN UINT32 NumBytes,
IN UINT32 Direction,
IN UINT64 DeviceAddr // not a pointer to device address
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_start (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_stop (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_initialize (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
IN UINTN extra_rx_buffer_size OPTIONAL,
IN UINTN extra_tx_buffer_size OPTIONAL
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_reset (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
IN BOOLEAN ExtendedVerification
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_shutdown (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_receive_filters (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
IN UINT32 enable,
IN UINT32 disable,
IN BOOLEAN reset_mcast_filter,
IN UINTN mcast_filter_count OPTIONAL,
IN EFI_MAC_ADDRESS * mcast_filter OPTIONAL
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_station_address (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
IN BOOLEAN reset,
IN EFI_MAC_ADDRESS *new OPTIONAL
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_statistics (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
IN BOOLEAN reset,
IN OUT UINTN *statistics_size OPTIONAL,
IN OUT EFI_NETWORK_STATISTICS * statistics_table OPTIONAL
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_mcast_ip_to_mac (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
IN BOOLEAN IPv6,
IN EFI_IP_ADDRESS *IP,
OUT EFI_MAC_ADDRESS *MAC
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_nvdata (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
IN BOOLEAN read_write,
IN UINTN offset,
IN UINTN buffer_size,
IN OUT VOID *buffer
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_get_status (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
OUT UINT32 *interrupt_status OPTIONAL,
OUT VOID **tx_buffer OPTIONAL
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_transmit (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
IN UINTN header_size,
IN UINTN buffer_size,
IN VOID *buffer,
IN EFI_MAC_ADDRESS * src_addr OPTIONAL,
IN EFI_MAC_ADDRESS * dest_addr OPTIONAL,
IN UINT16 *protocol OPTIONAL
)
;
extern
EFI_STATUS
EFIAPI
snp_undi32_receive (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
OUT UINTN *header_size OPTIONAL,
IN OUT UINTN *buffer_size,
OUT VOID *buffer,
OUT EFI_MAC_ADDRESS * src_addr OPTIONAL,
OUT EFI_MAC_ADDRESS * dest_addr OPTIONAL,
OUT UINT16 *protocol OPTIONAL
)
;
typedef
EFI_STATUS
(*issue_undi32_command) (
UINT64 cdb
);
typedef
VOID
(*ptr) (
VOID
);
/**
Install all the driver protocol
@param ImageHandle Driver image handle
@param SystemTable System services table
@retval EFI_SUCEESS Initialization routine has found UNDI hardware, loaded it's
ROM, and installed a notify event for the Network
Indentifier Interface Protocol successfully.
@retval Other Return value from HandleProtocol for DeviceIoProtocol or
LoadedImageProtocol
**/
EFI_STATUS
EFIAPI
InitializeSnpNiiDriver (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
;
#define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)
#endif /* _SNP_H */

View File

@ -1,175 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
start.c
Abstract:
Revision history:
2000-Feb-07 M(f)J Genesis.
**/
#include "Snp.h"
/**
this routine calls undi to start the interface and changes the snp state!
@param snp pointer to snp driver structure
**/
EFI_STATUS
pxe_start (
SNP_DRIVER *snp
)
{
PXE_CPB_START_31 *cpb_31;
cpb_31 = snp->cpb;
//
// Initialize UNDI Start CDB for H/W UNDI
//
snp->cdb.OpCode = PXE_OPCODE_START;
snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Make changes to H/W UNDI Start CDB if this is
// a S/W UNDI.
//
if (snp->is_swundi) {
snp->cdb.CPBsize = sizeof (PXE_CPB_START_31);
snp->cdb.CPBaddr = (UINT64)(UINTN) cpb_31;
cpb_31->Delay = (UINT64)(UINTN) &snp_undi32_callback_delay;
cpb_31->Block = (UINT64)(UINTN) &snp_undi32_callback_block;
//
// Virtual == Physical. This can be set to zero.
//
cpb_31->Virt2Phys = (UINT64)(UINTN) 0;
cpb_31->Mem_IO = (UINT64)(UINTN) &snp_undi32_callback_memio;
cpb_31->Map_Mem = (UINT64)(UINTN) &snp_undi32_callback_map;
cpb_31->UnMap_Mem = (UINT64)(UINTN) &snp_undi32_callback_unmap;
cpb_31->Sync_Mem = (UINT64)(UINTN) &snp_undi32_callback_sync;
cpb_31->Unique_ID = (UINT64)(UINTN) snp;
}
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.start() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {
//
// UNDI could not be started. Return UNDI error.
//
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.start() %xh:%xh\n",
snp->cdb.StatCode,
snp->cdb.StatFlags)
);
return EFI_DEVICE_ERROR;
}
//
// Set simple network state to Started and return success.
//
snp->mode.State = EfiSimpleNetworkStarted;
return EFI_SUCCESS;
}
/**
This is the SNP interface routine for starting the interface
This routine basically retrieves snp structure, checks the SNP state and
calls the pxe_start routine to actually do start undi interface
@param This context pointer
@retval EFI_INVALID_PARAMETER "This" is Null
@retval No SNP driver can be extracted from "This"
@retval EFI_ALREADY_STARTED The state of SNP is EfiSimpleNetworkStarted or
EfiSimpleNetworkInitialized
@retval EFI_DEVICE_ERROR The state of SNP is other than
EfiSimpleNetworkStarted,
EfiSimpleNetworkInitialized, and
EfiSimpleNetworkStopped
@retval EFI_SUCCESS UNDI interface is succesfully started
@retval Other Error occurs while calling pxe_start function.
**/
EFI_STATUS
EFIAPI
snp_undi32_start (
IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
{
SNP_DRIVER *Snp;
EFI_STATUS Status;
UINTN Index;
EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Snp->mode.State) {
case EfiSimpleNetworkStopped:
break;
case EfiSimpleNetworkStarted:
case EfiSimpleNetworkInitialized:
Status = EFI_ALREADY_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
Status = pxe_start (Snp);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
//
// clear the map_list in SNP structure
//
for (Index = 0; Index < MAX_MAP_LENGTH; Index++) {
Snp->map_list[Index].virt = 0;
Snp->map_list[Index].map_cookie = 0;
}
Snp->mode.MCastFilterCount = 0;
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,237 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
station_address.c
Abstract:
Revision history:
2000-Feb-17 M(f)J Genesis.
**/
#include "Snp.h"
/**
this routine calls undi to read the MAC address of the NIC and updates the
mode structure with the address.
@param snp pointer to snp driver structure
**/
EFI_STATUS
pxe_get_stn_addr (
SNP_DRIVER *snp
)
{
PXE_DB_STATION_ADDRESS *db;
db = snp->db;
snp->cdb.OpCode = PXE_OPCODE_STATION_ADDRESS;
snp->cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_READ;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.DBsize = sizeof (PXE_DB_STATION_ADDRESS);
snp->cdb.DBaddr = (UINT64)(UINTN) db;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.station_addr() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.station_addr() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_DEVICE_ERROR;
}
//
// Set new station address in SNP->Mode structure and return success.
//
CopyMem (
&(snp->mode.CurrentAddress),
&db->StationAddr,
snp->mode.HwAddressSize
);
CopyMem (
&snp->mode.BroadcastAddress,
&db->BroadcastAddr,
snp->mode.HwAddressSize
);
CopyMem (
&snp->mode.PermanentAddress,
&db->PermanentAddr,
snp->mode.HwAddressSize
);
return EFI_SUCCESS;
}
/**
this routine calls undi to set a new MAC address for the NIC,
@param snp pointer to snp driver structure
@param NewMacAddr pointer to a mac address to be set for the nic, if this is
NULL then this routine resets the mac address to the NIC's
original address.
**/
STATIC
EFI_STATUS
pxe_set_stn_addr (
SNP_DRIVER *snp,
EFI_MAC_ADDRESS *NewMacAddr
)
{
PXE_CPB_STATION_ADDRESS *cpb;
PXE_DB_STATION_ADDRESS *db;
cpb = snp->cpb;
db = snp->db;
snp->cdb.OpCode = PXE_OPCODE_STATION_ADDRESS;
if (NewMacAddr == NULL) {
snp->cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_RESET;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
} else {
snp->cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_READ;
//
// even though the OPFLAGS are set to READ, supplying a new address
// in the CPB will make undi change the mac address to the new one.
//
CopyMem (&cpb->StationAddr, NewMacAddr, snp->mode.HwAddressSize);
snp->cdb.CPBsize = sizeof (PXE_CPB_STATION_ADDRESS);
snp->cdb.CPBaddr = (UINT64)(UINTN) cpb;
}
snp->cdb.DBsize = sizeof (PXE_DB_STATION_ADDRESS);
snp->cdb.DBaddr = (UINT64)(UINTN) db;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.station_addr() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.station_addr() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
//
// UNDI command failed. Return UNDI status to caller.
//
return EFI_DEVICE_ERROR;
}
//
// read the changed address and save it in SNP->Mode structure
//
pxe_get_stn_addr (snp);
return EFI_SUCCESS;
}
/**
This is the SNP interface routine for changing the NIC's mac address.
This routine basically retrieves snp structure, checks the SNP state and
calls the above routines to actually do the work
@param this context pointer
@param NewMacAddr pointer to a mac address to be set for the nic, if this is
NULL then this routine resets the mac address to the NIC's
original address.
@param ResetFlag If true, the mac address will change to NIC's original
address
**/
EFI_STATUS
EFIAPI
snp_undi32_station_address (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
IN BOOLEAN ResetFlag,
IN EFI_MAC_ADDRESS * NewMacAddr OPTIONAL
)
{
SNP_DRIVER *snp;
EFI_STATUS Status;
EFI_TPL OldTpl;
//
// Check for invalid parameter combinations.
//
if ((this == NULL) ||
(!ResetFlag && (NewMacAddr == NULL))) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Return error if the SNP is not initialized.
//
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
if (ResetFlag) {
Status = pxe_set_stn_addr (snp, NULL);
} else {
Status = pxe_set_stn_addr (snp, NewMacAddr);
}
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,201 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
statistics.c
Abstract:
Revision history:
2000-Feb-17 M(f)J Genesis.
**/
#include "Snp.h"
/**
This is the SNP interface routine for getting the NIC's statistics.
This routine basically retrieves snp structure, checks the SNP state and
calls the pxe_ routine to actually do the
@param this context pointer
@param ResetFlag true to reset the NIC's statistics counters to zero.
@param StatTableSizePtr pointer to the statistics table size
@param StatTablePtr pointer to the statistics table
**/
EFI_STATUS
EFIAPI
snp_undi32_statistics (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
IN BOOLEAN ResetFlag,
IN OUT UINTN *StatTableSizePtr OPTIONAL,
IN OUT EFI_NETWORK_STATISTICS * StatTablePtr OPTIONAL
)
{
SNP_DRIVER *snp;
PXE_DB_STATISTICS *db;
UINT64 *stp;
UINT64 mask;
UINTN size;
UINTN n;
EFI_TPL OldTpl;
EFI_STATUS Status;
//
// Get pointer to SNP driver instance for *this.
//
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Return error if the SNP is not initialized.
//
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
//
// if we are not resetting the counters, we have to have a valid stat table
// with >0 size. if no reset, no table and no size, return success.
//
if (!ResetFlag && StatTableSizePtr == NULL) {
Status = StatTablePtr ? EFI_INVALID_PARAMETER : EFI_SUCCESS;
goto ON_EXIT;
}
//
// Initialize UNDI Statistics CDB
//
snp->cdb.OpCode = PXE_OPCODE_STATISTICS;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
if (ResetFlag) {
snp->cdb.OpFlags = PXE_OPFLAGS_STATISTICS_RESET;
snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
db = snp->db;
} else {
snp->cdb.OpFlags = PXE_OPFLAGS_STATISTICS_READ;
snp->cdb.DBsize = sizeof (PXE_DB_STATISTICS);
snp->cdb.DBaddr = (UINT64)(UINTN) (db = snp->db);
}
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.statistics() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
switch (snp->cdb.StatCode) {
case PXE_STATCODE_SUCCESS:
break;
case PXE_STATCODE_UNSUPPORTED:
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.statistics() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
Status = EFI_UNSUPPORTED;
goto ON_EXIT;
default:
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.statistics() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
if (ResetFlag) {
Status = EFI_SUCCESS;
goto ON_EXIT;
}
if (StatTablePtr == NULL) {
*StatTableSizePtr = sizeof (EFI_NETWORK_STATISTICS);
Status = EFI_BUFFER_TOO_SMALL;
goto ON_EXIT;
}
//
// Convert the UNDI statistics information to SNP statistics
// information.
//
ZeroMem (StatTablePtr, *StatTableSizePtr);
stp = (UINT64 *) StatTablePtr;
size = 0;
for (n = 0, mask = 1; n < 64; n++, mask = LShiftU64 (mask, 1), stp++) {
//
// There must be room for a full UINT64. Partial
// numbers will not be stored.
//
if ((n + 1) * sizeof (UINT64) > *StatTableSizePtr) {
break;
}
if (db->Supported & mask) {
*stp = db->Data[n];
size = n + 1;
} else {
SetMem (stp, sizeof (UINT64), 0xFF);
}
}
//
// Compute size up to last supported statistic.
//
while (++n < 64) {
if (db->Supported & (mask = LShiftU64 (mask, 1))) {
size = n;
}
}
size *= sizeof (UINT64);
if (*StatTableSizePtr >= size) {
*StatTableSizePtr = size;
Status = EFI_SUCCESS;
} else {
*StatTableSizePtr = size;
Status = EFI_BUFFER_TOO_SMALL;
}
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,118 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
stop.c
Abstract:
Revision history:
2000-Feb-09 M(f)J Genesis.
**/
#include "Snp.h"
/**
this routine calls undi to stop the interface and changes the snp state
@param snp pointer to snp driver structure
**/
EFI_STATUS
pxe_stop (
SNP_DRIVER *snp
)
{
snp->cdb.OpCode = PXE_OPCODE_STOP;
snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command
//
DEBUG ((EFI_D_NET, "\nsnp->undi.stop() "));
(*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);
if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {
DEBUG (
(EFI_D_WARN,
"\nsnp->undi.stop() %xh:%xh\n",
snp->cdb.StatCode,
snp->cdb.StatFlags)
);
return EFI_DEVICE_ERROR;
}
//
// Set simple network state to Started and return success.
//
snp->mode.State = EfiSimpleNetworkStopped;
return EFI_SUCCESS;
}
/**
This is the SNP interface routine for stopping the interface.
This routine basically retrieves snp structure, checks the SNP state and
calls the pxe_stop routine to actually stop the undi interface
@param this context pointer
**/
EFI_STATUS
EFIAPI
snp_undi32_stop (
IN EFI_SIMPLE_NETWORK_PROTOCOL *this
)
{
SNP_DRIVER *snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (snp->mode.State) {
case EfiSimpleNetworkStarted:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
Status = pxe_stop (snp);
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -1,327 +0,0 @@
/** @file
Copyright (c) 2004 - 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:
transmit.c
Abstract:
Revision history:
2000-Feb-03 M(f)J Genesis.
**/
#include "Snp.h"
/**
This routine calls undi to create the meadia header for the given data buffer.
@param snp pointer to SNP driver structure
@param MacHeaderPtr address where the media header will be filled in.
@param MacHeaderSize size of the memory at MacHeaderPtr
@param BufferPtr data buffer pointer
@param BufferLength Size of data in the BufferPtr
@param DestinationAddrPtr address of the destination mac address buffer
@param SourceAddrPtr address of the source mac address buffer
@param ProtocolPtr address of the protocol type
@retval EFI_SUCCESS if successfully completed the undi call
@retval Other error return from undi call.
**/
STATIC
EFI_STATUS
pxe_fillheader (
SNP_DRIVER *snp,
VOID *MacHeaderPtr,
UINTN MacHeaderSize,
VOID *BufferPtr,
UINTN BufferLength,
EFI_MAC_ADDRESS *DestinationAddrPtr,
EFI_MAC_ADDRESS *SourceAddrPtr,
UINT16 *ProtocolPtr
)
{
PXE_CPB_FILL_HEADER_FRAGMENTED *cpb;
cpb = snp->cpb;
if (SourceAddrPtr) {
CopyMem (
(VOID *) cpb->SrcAddr,
(VOID *) SourceAddrPtr,
snp->mode.HwAddressSize
);
} else {
CopyMem (
(VOID *) cpb->SrcAddr,
(VOID *) &(snp->mode.CurrentAddress),
snp->mode.HwAddressSize
);
}
CopyMem (
(VOID *) cpb->DestAddr,
(VOID *) DestinationAddrPtr,
snp->mode.HwAddressSize
);
//
// we need to do the byte swapping
//
cpb->Protocol = (UINT16) PXE_SWAP_UINT16 (*ProtocolPtr);
cpb->PacketLen = (UINT32) (BufferLength);
cpb->MediaHeaderLen = (UINT16) MacHeaderSize;
cpb->FragCnt = 2;
cpb->reserved = 0;
cpb->FragDesc[0].FragAddr = (UINT64)(UINTN) MacHeaderPtr;
cpb->FragDesc[0].FragLen = (UINT32) MacHeaderSize;
cpb->FragDesc[1].FragAddr = (UINT64)(UINTN) BufferPtr;
cpb->FragDesc[1].FragLen = (UINT32) BufferLength;
cpb->FragDesc[0].reserved = cpb->FragDesc[1].reserved = 0;
snp->cdb.OpCode = PXE_OPCODE_FILL_HEADER;
snp->cdb.OpFlags = PXE_OPFLAGS_FILL_HEADER_FRAGMENTED;
snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
snp->cdb.CPBsize = sizeof (PXE_CPB_FILL_HEADER_FRAGMENTED);
snp->cdb.CPBaddr = (UINT64)(UINTN) cpb;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.fill_header() "));
(*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb);
switch (snp->cdb.StatCode) {
case PXE_STATCODE_SUCCESS:
return EFI_SUCCESS;
case PXE_STATCODE_INVALID_PARAMETER:
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.fill_header() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_INVALID_PARAMETER;
default:
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.fill_header() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return EFI_DEVICE_ERROR;
}
}
/**
This routine calls undi to transmit the given data buffer
@param snp pointer to SNP driver structure
@param BufferPtr data buffer pointer
@param BufferLength Size of data in the BufferPtr
@retval EFI_SUCCESS if successfully completed the undi call
@retval Other error return from undi call.
**/
STATIC
EFI_STATUS
pxe_transmit (
SNP_DRIVER *snp,
VOID *BufferPtr,
UINTN BufferLength
)
{
PXE_CPB_TRANSMIT *cpb;
EFI_STATUS Status;
cpb = snp->cpb;
cpb->FrameAddr = (UINT64) (UINTN) BufferPtr;
cpb->DataLen = (UINT32) BufferLength;
cpb->MediaheaderLen = 0;
cpb->reserved = 0;
snp->cdb.OpFlags = PXE_OPFLAGS_TRANSMIT_WHOLE;
snp->cdb.CPBsize = sizeof (PXE_CPB_TRANSMIT);
snp->cdb.CPBaddr = (UINT64)(UINTN) cpb;
snp->cdb.OpCode = PXE_OPCODE_TRANSMIT;
snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
snp->cdb.IFnum = snp->if_num;
snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
//
// Issue UNDI command and check result.
//
DEBUG ((EFI_D_NET, "\nsnp->undi.transmit() "));
DEBUG ((EFI_D_NET, "\nsnp->cdb.OpCode == %x", snp->cdb.OpCode));
DEBUG ((EFI_D_NET, "\nsnp->cdb.CPBaddr == %X", snp->cdb.CPBaddr));
DEBUG ((EFI_D_NET, "\nsnp->cdb.DBaddr == %X", snp->cdb.DBaddr));
DEBUG ((EFI_D_NET, "\ncpb->FrameAddr == %X\n", cpb->FrameAddr));
(*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb);
DEBUG ((EFI_D_NET, "\nexit snp->undi.transmit() "));
DEBUG ((EFI_D_NET, "\nsnp->cdb.StatCode == %r", snp->cdb.StatCode));
//
// we will unmap the buffers in get_status call, not here
//
switch (snp->cdb.StatCode) {
case PXE_STATCODE_SUCCESS:
return EFI_SUCCESS;
case PXE_STATCODE_QUEUE_FULL:
case PXE_STATCODE_BUSY:
Status = EFI_NOT_READY;
break;
default:
Status = EFI_DEVICE_ERROR;
}
DEBUG (
(EFI_D_ERROR,
"\nsnp->undi.transmit() %xh:%xh\n",
snp->cdb.StatFlags,
snp->cdb.StatCode)
);
return Status;
}
/**
This is the snp interface routine for transmitting a packet. this routine
basically retrieves the snp structure, checks the snp state and calls
pxe_fill_header and pxe_transmit calls to complete the transmission.
@param this pointer to SNP driver context
@param MacHeaderSize size of the memory at MacHeaderPtr
@param BufferLength Size of data in the BufferPtr
@param BufferPtr data buffer pointer
@param SourceAddrPtr address of the source mac address buffer
@param DestinationAddrPtr address of the destination mac address buffer
@param ProtocolPtr address of the protocol type
@retval EFI_SUCCESS if successfully completed the undi call
@retval Other error return from undi call.
**/
EFI_STATUS
EFIAPI
snp_undi32_transmit (
IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
IN UINTN MacHeaderSize,
IN UINTN BufferLength,
IN VOID *BufferPtr,
IN EFI_MAC_ADDRESS * SourceAddrPtr OPTIONAL,
IN EFI_MAC_ADDRESS * DestinationAddrPtr OPTIONAL,
IN UINT16 *ProtocolPtr OPTIONAL
)
{
SNP_DRIVER *snp;
EFI_STATUS Status;
EFI_TPL OldTpl;
if (this == NULL) {
return EFI_INVALID_PARAMETER;
}
snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (snp == NULL) {
return EFI_DEVICE_ERROR;
}
switch (snp->mode.State) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
Status = EFI_NOT_STARTED;
goto ON_EXIT;
default:
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
if (BufferPtr == NULL) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
if (BufferLength < snp->mode.MediaHeaderSize) {
Status = EFI_BUFFER_TOO_SMALL;
goto ON_EXIT;
}
//
// if the MacHeaderSize is non-zero, we need to fill up the header and for that
// we need the destination address and the protocol
//
if (MacHeaderSize != 0) {
if (MacHeaderSize != snp->mode.MediaHeaderSize || DestinationAddrPtr == 0 || ProtocolPtr == 0) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
Status = pxe_fillheader (
snp,
BufferPtr,
MacHeaderSize,
(UINT8 *) BufferPtr + MacHeaderSize,
BufferLength - MacHeaderSize,
DestinationAddrPtr,
SourceAddrPtr,
ProtocolPtr
);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
}
Status = pxe_transmit (snp, BufferPtr, BufferLength);
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
}