📄 dec21143.c
字号:
/****************************************************************************/
/* */
/* Copyright (c) 1999 by Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the subject */
/* matter of this material. All manufacturing, reproduction, use and sales */
/* rights pertaining to this subject matter are governed by the license */
/* agreement. The recipient of this software implicity accepts the terms */
/* of the license. */
/* */
/****************************************************************************/
/****************************************************************************/
/* */
/* FILENAME */
/* */
/* DEC21143.C */
/* */
/* DESCRIPTION */
/* */
/* This file contains all of the source code required to interface with */
/* a DEC21143. It handles PCI card location, initialization, transmit, */
/* receive, and error processing. NOTE: this driver only supports one */
/* PCI bus. */
/* */
/* AUTHOR */
/* */
/* Uriah T. Pollock, Accelerated Technology Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* NU_HISR DEC21143_RX_HISR_CB */
/* NU_HISR DEC21143_TX_HISR_CB */
/* NU_HISR DEC21143_Negotiate_Link_HISR_CB */
/* DV_DEVICE_ENTRY *DEC21143_TX_Device_Buffer[] */
/* INT DEC21143_Read */
/* INT DEC21143_Write */
/* DV_DEVICE_ENTRY *DEC21143_Negotiate_Device_Buffer[] */
/* INT DEC21143_Negotiate_Read */
/* INT DEC21143_Negotiate_Write */
/* Check in file 'dec21143.h' */
/* */
/* FUNCTIONS */
/* */
/* DEC21143_Init */
/* DEC21143_Open */
/* DEC21143_Negotiate_Link */
/* DEC21143_Init_Link */
/* DEC21143_Negotiate_Link_HISR */
/* DEC21143_Get_Address */
/* DEC21143_RX_Packet */
/* DEC21143_RX_HISR */
/* DEC21143_TX_Packet */
/* DEC21143_TX_HISR */
/* DEC21143_LISR */
/* DEC21143_Ioctl */
/* DEC21143_Delay */
/* DEC21143_Allocate_Descriptor */
/* DEC21143_Find_PCI_ID */
/* DEC21143_Write_PCI */
/* DEC21143_Read_PCI */
/* DEC21143_Read_EEPROM */
/* DEC21143_Init_Setup_Frame */
/* DEC21143_Process_Setup_Frame */
/* DEC21143_Update_Setup_Frame */
/* Unknown_Int_Lisr */
/* */
/* DEPENDENCIES */
/* */
/* "dev.h" */
/* "externs.h" */
/* "protocol.h" */
/* "tcp_errs.h" */
/* "snmp.h" */
/* "data.h" */
/* "dec21143.h" */
/* "net.h" */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Uriah T. Pollock 01/12/99 Created initial version 1.0 */
/* */
/****************************************************************************/
#include "plus\nucleus.h"
#include "net\inc\externs.h"
#include "net\inc\protocol.h"
#include "net\inc\tcp_errs.h"
#if (INCLUDE_SNMP == NU_TRUE)
#include "snmp\inc\snmp.h"
#endif
#include "met\inc\data.h"
#include "template\dec21143.h"
#include "net\inc\net.h"
/* Receive, Transmit, and Negotiate HISR Control Blocks. */
NU_HISR DEC21143_RX_HISR_CB;
NU_HISR DEC21143_TX_HISR_CB;
NU_HISR DEC21143_Negotiate_Link_HISR_CB;
/* This ring buffer is used for communication between the LISR and the transmit
HISR. The LISR only writes to the buffer and the HISR only reads from the
buffer. Whenever a transmit complete interrupt occurs and there is another
packet pending transmission the LISR will write a device pointer into the
location pointed to by DEC21143_Write. The LISR will then activate the
transmit HISR. The HISR will retrieve the device pointer from the location
pointed to by ISR_Read, move the read index forward, and transmit the next
packet. Worst case, there will be an active HISR for each device. So there
should be at least one location per DEC21143 device in the ring buffer. The
size of the ring buffer can be optimized by modifying MAX_DEC21143_DEVICES.
*/
#define MAX_DEC21143_DEVICES 5
DV_DEVICE_ENTRY *DEC21143_TX_Device_Buffer[MAX_DEC21143_DEVICES];
INT DEC21143_Read;
INT DEC21143_Write;
DV_DEVICE_ENTRY *DEC21143_Negotiate_Device_Buffer[MAX_DEC21143_DEVICES];
INT DEC21143_Negotiate_Read;
INT DEC21143_Negotiate_Write;
/****************************************************************************/
/* FUNCTION */
/* */
/* DEC21143_Init */
/* */
/* DESCRIPTION */
/* */
/* This function initializes the device structure and calls the device */
/* open function. */
/* */
/* AUTHOR */
/* */
/* Uriah T. Pollock, Accelerated Technology Inc. */
/* */
/* CALLED BY */
/* */
/* DEV_Init_Devices */
/* */
/* CALLS */
/* */
/* DEC21143_Open */
/* NU_Allocate_Memory */
/* UTL_Zero */
/* NU_Tcp_Log_Error */
/* sizeof */
/* */
/* INPUTS */
/* */
/* DV_DEVICE_ENTRY * : Pointer to the device to be initialized. */
/* */
/* OUTPUTS */
/* */
/* NU_SUCCESS or a negative value on failure. */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Uriah T. Pollock 01/12/99 Created initial version 1.0 */
/* */
/****************************************************************************/
STATUS DEC21143_Init(DV_DEVICE_ENTRY *device)
{
VOID *pointer;
/* Initialize the various function pointers. */
device->dev_open = DEC21143_Open;
device->dev_start = DEC21143_TX_Packet;
device->dev_output = NET_Ether_Send;
device->dev_input = NET_Ether_Input;
device->dev_ioctl = DEC21143_Ioctl;
device->dev_type = DVT_ETHER;
/* The IO base address is gotten below in the function
DEC21143_Open.
device->dev_io_addr = ;
*/
device->dev_addrlen = DEC21143_ETHERNET_ADDRESS_SIZE;
device->dev_hdrlen = DEC21143_ETHERNET_HEADER_SIZE;
device->dev_mtu = DEC21143_ETHERNET_MTU;
/* The DEC21143 is a simplex controller. Broadcasts are allowed. */
device->dev_flags |= (DV_BROADCAST | DV_SIMPLEX | DV_MULTICAST);
/* Allocate the memory required for the DEC21143 data. */
if ( NU_Allocate_Memory ( &System_Memory, &pointer, sizeof(DEC21143_XDATA),
NU_NO_SUSPEND ) != NU_SUCCESS)
{
NU_Tcp_Log_Error (TCP_SESS_MEM, TCP_FATAL, __FILE__, __LINE__);
return (-1);
}
/* Clear the data. */
UTL_Zero (pointer, sizeof(DEC21143_XDATA));
/* The device structure includes 4 fields that are unused. Two are reserved
for system use, and two are for reserved for users. We are going to use
one of the fields reserved for users to store a pointer to the data for
this DEC21143 device. */
device->user_defined_1 = (UINT32)pointer;
/* Initialize the device. */
return ( (*(device->dev_open)) (device->dev_mac_addr, device) );
} /* DEC21143_Init */
/****************************************************************************/
/* FUNCTION */
/* */
/* DEC21143_Open */
/* */
/* DESCRIPTION */
/* */
/* This function will handle the initilization of the Ethernet H/W you */
/* are using for communication. This function will also register an */
/* LISR with the kernel. The LISR will service all interrupts generated */
/* by the DEC21143. All steps listed in comments below are taken from */
/* page 4-30 of the DIGITAL Semiconductor 21143 PCI/CardBus 10/100-Mb/s */
/* Ethernet LAN Controller Hardware Reference Manual. */
/* */
/* AUTHOR */
/* */
/* Uriah T. Pollock, Accelerated Technology Inc. */
/* */
/* CALLED BY */
/* */
/* DEC21143_Init */
/* */
/* CALLS */
/* */
/* OUTDW */
/* INDW */
/* NU_Tcp_Log_Error */
/* DEC21143_Find_PCI_ID */
/* DEC21143_Read_PCI */
/* NU_Register_LISR */
/* NU_Allocate_Memory */
/* NU_Create_HISR */
/* DEC21143_Delay */
/* DEC21143_Set_RXCFG */
/* NU_Register_LISR */
/* NU_Create_HISR */
/* DEC21143_Write_PCI */
/* sizeof */
/* DEC21143_Get_Address */
/* DEC21143_Delay */
/* DEC21143_Allocate_Descriptor */
/* DEC21143_Init_Setup_Frame */
/* DEC21143_Process_Setup_Frame */
/* MEM_Buffer_Dequeue */
/* DEC21143_Negotiate_Link */
/* NU_Sleep */
/* */
/* INPUTS */
/* */
/* uchar * : Pointer the the storage area for the MAC address. */
/* DV_DEVICE_ENTRY * : Pointer to the device to be initialized. */
/* */
/* OUTPUTS */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -