coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ne2k.c File Reference
#include <arch/io.h>
#include <console/ne2k.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ops.h>
#include <ip_checksum.h>
#include "ns8390.h"
Include dependency graph for ne2k.c:

Go to the source code of this file.

Macros

#define ETH_ALEN   6 /* Size of Ethernet address */
 
#define ETH_HLEN   14 /* Size of ethernet header */
 
#define ETH_ZLEN   60 /* Minimum packet */
 
#define ETH_FRAME_LEN   1514 /* Maximum packet */
 
#define ETH_DATA_ALIGN   2 /* Amount needed to align the data after an ethernet header */
 
#define ETH_MAX_MTU   (ETH_FRAME_LEN-ETH_HLEN)
 
#define MEM_SIZE   MEM_32768
 
#define TX_START   64
 
#define RX_START   (64 + D8390_TXBUF_SIZE)
 

Functions

static unsigned int get_count (unsigned int eth_nic_base)
 
static void set_count (unsigned int eth_nic_base, unsigned int what)
 
static void eth_pio_write (unsigned char *src, unsigned int dst, unsigned int cnt, unsigned int eth_nic_base)
 
void ne2k_append_data (unsigned char *d, int len, unsigned int base)
 
static void str2ip (const char *str, unsigned char *ip)
 
static void str2mac (const char *str, unsigned char *mac)
 
static void ns8390_tx_header (unsigned int eth_nic_base, int pktlen)
 
void ne2k_transmit (unsigned int eth_nic_base)
 
static void ns8390_reset (unsigned int eth_nic_base)
 
int ne2k_init (unsigned int eth_nic_base)
 
static void read_resources (struct device *dev)
 

Variables

static struct device_operations ne2k_ops
 
static const struct pci_driver ne2k_driver __pci_driver
 

Macro Definition Documentation

◆ ETH_ALEN

#define ETH_ALEN   6 /* Size of Ethernet address */

Definition at line 39 of file ne2k.c.

◆ ETH_DATA_ALIGN

#define ETH_DATA_ALIGN   2 /* Amount needed to align the data after an ethernet header */

Definition at line 43 of file ne2k.c.

◆ ETH_FRAME_LEN

#define ETH_FRAME_LEN   1514 /* Maximum packet */

Definition at line 42 of file ne2k.c.

◆ ETH_HLEN

#define ETH_HLEN   14 /* Size of ethernet header */

Definition at line 40 of file ne2k.c.

◆ ETH_MAX_MTU

#define ETH_MAX_MTU   (ETH_FRAME_LEN-ETH_HLEN)

Definition at line 44 of file ne2k.c.

◆ ETH_ZLEN

#define ETH_ZLEN   60 /* Minimum packet */

Definition at line 41 of file ne2k.c.

◆ MEM_SIZE

#define MEM_SIZE   MEM_32768

Definition at line 46 of file ne2k.c.

◆ RX_START

#define RX_START   (64 + D8390_TXBUF_SIZE)

Definition at line 48 of file ne2k.c.

◆ TX_START

#define TX_START   64

Definition at line 47 of file ne2k.c.

Function Documentation

◆ eth_pio_write()

static void eth_pio_write ( unsigned char *  src,
unsigned int  dst,
unsigned int  cnt,
unsigned int  eth_nic_base 
)
static

Definition at line 75 of file ne2k.c.

References D8390_COMMAND_RD1, D8390_COMMAND_RD2, D8390_COMMAND_STA, D8390_ISR_RDC, D8390_P0_COMMAND, D8390_P0_ISR, D8390_P0_RBCR0, D8390_P0_RBCR1, D8390_P0_RSAR0, D8390_P0_RSAR1, inb(), NE_ASIC_OFFSET, NE_DATA, and outb().

Referenced by ne2k_append_data(), and ns8390_tx_header().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_count()

static unsigned int get_count ( unsigned int  eth_nic_base)
static

Definition at line 50 of file ne2k.c.

References D8390_COMMAND_PS0, D8390_COMMAND_PS1, D8390_COMMAND_RD2, D8390_P0_COMMAND, inb(), and outb().

Referenced by ne2k_append_data(), and ne2k_transmit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ne2k_append_data()

void ne2k_append_data ( unsigned char *  d,
int  len,
unsigned int  base 
)

Definition at line 97 of file ne2k.c.

References base, eth_pio_write(), get_count(), set_count(), and TX_START.

Here is the call graph for this function:

◆ ne2k_init()

◆ ne2k_transmit()

void ne2k_transmit ( unsigned int  eth_nic_base)

◆ ns8390_reset()

static void ns8390_reset ( unsigned int  eth_nic_base)
static

◆ ns8390_tx_header()

static void ns8390_tx_header ( unsigned int  eth_nic_base,
int  pktlen 
)
static

Definition at line 147 of file ne2k.c.

References compute_ip_checksum(), eth_pio_write(), str2ip(), str2mac(), and TX_START.

Referenced by ne2k_transmit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_resources()

static void read_resources ( struct device dev)
static

Definition at line 298 of file ne2k.c.

◆ set_count()

static void set_count ( unsigned int  eth_nic_base,
unsigned int  what 
)
static

Definition at line 63 of file ne2k.c.

References D8390_COMMAND_PS0, D8390_COMMAND_PS1, D8390_COMMAND_RD2, D8390_P0_COMMAND, and outb().

Referenced by ne2k_append_data(), ne2k_transmit(), and ns8390_reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str2ip()

static void str2ip ( const char *  str,
unsigned char *  ip 
)
static

Definition at line 103 of file ne2k.c.

References c.

Referenced by ns8390_tx_header().

Here is the caller graph for this function:

◆ str2mac()

static void str2mac ( const char *  str,
unsigned char *  mac 
)
static

Definition at line 121 of file ne2k.c.

References c.

Referenced by ns8390_tx_header().

Here is the caller graph for this function:

Variable Documentation

◆ __pci_driver

const struct pci_driver ne2k_driver __pci_driver
static
Initial value:
= {
.ops = &ne2k_ops,
.vendor = 0x10ec,
.device = 0x8029,
}
static struct device_operations ne2k_ops
Definition: ne2k.c:312

Definition at line 298 of file ne2k.c.

◆ ne2k_ops

struct device_operations ne2k_ops
static
Initial value:
= {
.read_resources = read_resources,
.set_resources = pci_dev_set_resources,
.enable_resources = pci_dev_enable_resources,
}
static void read_resources(struct device *dev)
Definition: ne2k.c:298
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691

Definition at line 298 of file ne2k.c.