# ne2k.h File Reference

`#include <ubixos/types.h>`
`#include <sys/device.old.h>`

Include dependency graph for ne2k.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | dp_rcvhdr
union | etheraddr
struct | nicBuffer

## Defines

#define | DEF_ENABLED 0x200
#define | DP_CNTR0 0xD
#define | DP_CNTR1 0xE
#define | DP_CNTR2 0xF
#define | DP_CURR 0x7
#define | DP_MAR0 0x8
#define | DP_MAR1 0x9
#define | DP_MAR2 0xA
#define | DP_MAR3 0xB
#define | DP_MAR4 0xC
#define | DP_MAR5 0xD
#define | DP_MAR6 0xE
#define | DP_MAR7 0xF
#define | DP_PAGESIZE 256
#define | E8390_CMD 0x00
#define | E8390_NODMA 0x20
#define | E8390_PAGE0 0x00
#define | E8390_PAGE1 0x40
#define | E8390_RREAD 0x08
#define | E8390_RWRITE 0x10
#define | E8390_RXCONFIG 0x04
#define | E8390_RXOFF 0x20
#define | E8390_START 0x02
#define | E8390_STOP 0x01
#define | E8390_TXCONFIG 0x00
#define | E8390_TXOFF 0x00
#define | EN0_BOUNDARY 0x03
#define | EN0_COUNTER0 0x0d
#define | EN0_DCFG 0x0e
#define | EN0_IMR 0x0f
#define | EN0_ISR 0x07
#define | EN0_RCNTHI 0x0b
#define | EN0_RCNTLO 0x0a
#define | EN0_RSARHI 0x09
#define | EN0_RSARLO 0x08
#define | EN0_RXCR 0x0c
#define | EN0_STARTPG 0x01
#define | EN0_STOPPG 0x02
#define | EN0_TPSR 0x04
#define | EN0_TXCR 0x0D
#define | EN1_CURPAG 0x07
#define | EN1_MULT 0x08
#define | EN1_PHYS 0x01
#define | ENDCFG_WTS 0x01
#define | ENISR_ALL 0x3f
#define | ether_addr ether_addr_t
#define | NE1SM_START_PG 0x20
#define | NE1SM_STOP_PG 0x40
#define | NE_BNRY 0x03
#define | NE_CMD 0x00
#define | NE_CURRENT 0x07
#define | NE_DATAPORT 0x10
#define | NE_DCR 0x0E
#define | NE_DCR_AR 0x10
#define | NE_DCR_FT0 0x20
#define | NE_DCR_FT1 0x40
#define | NE_DCR_LS 0x08
#define | NE_DCR_WTS 0x01
#define | NE_IMR 0x0F
#define | NE_ISR 0x07
#define | NE_PSTART 0x01
#define | NE_PSTOP 0x02
#define | NE_RBCR0 0x0A
#define | NE_RBCR1 0x0B
#define | NE_RCR 0x0C
#define | NE_TCR 0x0D
#define | NE_TPSR 0x04
#define | NESM_START_PG 0x40
#define | NESM_STOP_PG 0x80
#define | OK 0
#define | RSR_FO 0x08
#define | RSR_PRX 0x01
#define | startPage 0x4C
#define | stopPage 0x80
#define | TX_1X_PAGES 6
#define | TX_2X_PAGES 12
#define | TX_PAGES (dev->priv->pingPong ? TX_2X_PAGES : TX_1X_PAGES)

## Typedefs

typedef dp_rcvhdr | dp_rcvhdr_t
typedef etheraddr | ether_addr_t

## Functions

int | ne2k_init ()
nicBuffer * | ne2kAllocBuffer (int)
int | ne2kDevInit (struct device *)
void | ne2kFreeBuffer (struct nicBuffer *)
nicBuffer * | ne2kGetBuffer ()
void | ne2kHandler ()
void | ne2kISR ()
int | ne2kProbe (int, struct device *)
int | NICtoPC (struct device *dev, void *packet, int length, int nic_addr)
void | NS8390_init (struct device *dev, int startp)
int | PCtoNIC (struct device *dev, void *packet, int length)

## Variables

char * | nicPacket
uInt32 | packetLength

## Define Documentation

#define DEF_ENABLED 0x200

Definition at line 59 of file ne2k.h.

#define DP_CNTR0 0xD

Definition at line 149 of file ne2k.h.

Referenced by ne2k_init().

#define DP_CNTR1 0xE

Definition at line 150 of file ne2k.h.

Referenced by ne2k_init().

#define DP_CNTR2 0xF

Definition at line 151 of file ne2k.h.

Referenced by ne2k_init().

#define DP_CURR 0x7

Definition at line 139 of file ne2k.h.

Referenced by ne2k_init().

#define DP_MAR0 0x8

Definition at line 140 of file ne2k.h.

Referenced by ne2k_init().

#define DP_MAR1 0x9

Definition at line 141 of file ne2k.h.

Referenced by ne2k_init().

#define DP_MAR2 0xA

Definition at line 142 of file ne2k.h.

Referenced by ne2k_init().

#define DP_MAR3 0xB

Definition at line 143 of file ne2k.h.

Referenced by ne2k_init().

#define DP_MAR4 0xC

Definition at line 144 of file ne2k.h.

Referenced by ne2k_init().

#define DP_MAR5 0xD

Definition at line 145 of file ne2k.h.

Referenced by ne2k_init().

#define DP_MAR6 0xE

Definition at line 146 of file ne2k.h.

Referenced by ne2k_init().

#define DP_MAR7 0xF

Definition at line 147 of file ne2k.h.

Referenced by ne2k_init().

#define DP_PAGESIZE 256

Definition at line 154 of file ne2k.h.

Referenced by dp_pkt2user(), and getblock().

#define E8390_CMD 0x00

Definition at line 95 of file ne2k.h.

#define E8390_NODMA 0x20

Definition at line 92 of file ne2k.h.

#define E8390_PAGE0 0x00

Definition at line 93 of file ne2k.h.

#define E8390_PAGE1 0x40

Definition at line 94 of file ne2k.h.

#define E8390_RREAD 0x08

Definition at line 97 of file ne2k.h.

Referenced by getblock().

#define E8390_RWRITE 0x10

Definition at line 98 of file ne2k.h.

Referenced by PCtoNIC().

#define E8390_RXCONFIG 0x04

Definition at line 101 of file ne2k.h.

#define E8390_RXOFF 0x20

Definition at line 99 of file ne2k.h.

#define E8390_START 0x02

Definition at line 96 of file ne2k.h.

Referenced by getblock(), and PCtoNIC().

#define E8390_STOP 0x01

Definition at line 91 of file ne2k.h.

#define E8390_TXCONFIG 0x00

Definition at line 102 of file ne2k.h.

#define E8390_TXOFF 0x00

Definition at line 100 of file ne2k.h.

#define EN0_BOUNDARY 0x03

Definition at line 117 of file ne2k.h.

#define EN0_COUNTER0 0x0d

Definition at line 104 of file ne2k.h.

#define EN0_DCFG 0x0e

Definition at line 105 of file ne2k.h.

#define EN0_IMR 0x0f

Definition at line 109 of file ne2k.h.

#define EN0_ISR 0x07

Definition at line 108 of file ne2k.h.

Referenced by getblock(), NICtoPC(), and PCtoNIC().

#define EN0_RCNTHI 0x0b

Definition at line 107 of file ne2k.h.

Referenced by NICtoPC(), and PCtoNIC().

#define EN0_RCNTLO 0x0a

Definition at line 106 of file ne2k.h.

Referenced by NICtoPC(), and PCtoNIC().

#define EN0_RSARHI 0x09

Definition at line 111 of file ne2k.h.

Referenced by getblock(), NICtoPC(), and PCtoNIC().

#define EN0_RSARLO 0x08

Definition at line 110 of file ne2k.h.

Referenced by getblock(), NICtoPC(), and PCtoNIC().

#define EN0_RXCR 0x0c

Definition at line 113 of file ne2k.h.

#define EN0_STARTPG 0x01

Definition at line 115 of file ne2k.h.

#define EN0_STOPPG 0x02

Definition at line 116 of file ne2k.h.

#define EN0_TPSR 0x04

Definition at line 112 of file ne2k.h.

#define EN0_TXCR 0x0D

Definition at line 114 of file ne2k.h.

#define EN1_CURPAG 0x07

Definition at line 120 of file ne2k.h.

#define EN1_MULT 0x08

Definition at line 121 of file ne2k.h.

#define EN1_PHYS 0x01

Definition at line 119 of file ne2k.h.

#define ENDCFG_WTS 0x01

Definition at line 130 of file ne2k.h.

#define ENISR_ALL 0x3f

Definition at line 128 of file ne2k.h.

#define ether_addr ether_addr_t

Definition at line 36 of file ne2k.h.

#define NE1SM_START_PG 0x20

Definition at line 123 of file ne2k.h.

#define NE1SM_STOP_PG 0x40

Definition at line 124 of file ne2k.h.

#define NE_BNRY 0x03

Definition at line 71 of file ne2k.h.

Referenced by dp_recv(), and ne2k_init().

#define NE_CMD 0x00

Definition at line 68 of file ne2k.h.

Referenced by dp_recv(), getblock(), and ne2k_init().

#define NE_CURRENT 0x07

Definition at line 74 of file ne2k.h.

Referenced by dp_recv().

#define NE_DATAPORT 0x10

Definition at line 132 of file ne2k.h.

Referenced by getblock(), NICtoPC(), and PCtoNIC().

#define NE_DCR 0x0E

Definition at line 79 of file ne2k.h.

Referenced by ne2k_init().

#define NE_DCR_AR 0x10

Definition at line 85 of file ne2k.h.

#define NE_DCR_FT0 0x20

Definition at line 87 of file ne2k.h.

#define NE_DCR_FT1 0x40

Definition at line 86 of file ne2k.h.

#define NE_DCR_LS 0x08

Definition at line 84 of file ne2k.h.

#define NE_DCR_WTS 0x01

Definition at line 83 of file ne2k.h.

#define NE_IMR 0x0F

Definition at line 80 of file ne2k.h.

Referenced by ne2k_init(), and ne2kHandler().

#define NE_ISR 0x07

Definition at line 73 of file ne2k.h.

Referenced by ne2k_init(), and ne2kHandler().

#define NE_PSTART 0x01

Definition at line 69 of file ne2k.h.

Referenced by ne2k_init().

#define NE_PSTOP 0x02

Definition at line 70 of file ne2k.h.

Referenced by ne2k_init().

#define NE_RBCR0 0x0A

Definition at line 75 of file ne2k.h.

Referenced by getblock(), and ne2k_init().

#define NE_RBCR1 0x0B

Definition at line 76 of file ne2k.h.

Referenced by getblock(), and ne2k_init().

#define NE_RCR 0x0C

Definition at line 77 of file ne2k.h.

Referenced by ne2k_init().

#define NE_TCR 0x0D

Definition at line 78 of file ne2k.h.

Referenced by ne2k_init().

#define NE_TPSR 0x04

Definition at line 72 of file ne2k.h.

Referenced by ne2kHandler().

#define NESM_START_PG 0x40

Definition at line 125 of file ne2k.h.

#define NESM_STOP_PG 0x80

Definition at line 126 of file ne2k.h.

#define OK 0

Definition at line 61 of file ne2k.h.

Referenced by dp_pkt2user(), and dp_recv().

#define RSR_FO 0x08

Definition at line 57 of file ne2k.h.

Referenced by dp_recv().

#define RSR_PRX 0x01

Definition at line 58 of file ne2k.h.

Referenced by dp_recv().

#define startPage 0x4C

Definition at line 64 of file ne2k.h.

Referenced by dp_recv(), and ne2k_init().

#define stopPage 0x80

Definition at line 65 of file ne2k.h.

Referenced by dp_pkt2user(), dp_recv(), and ne2k_init().

#define TX_1X_PAGES 6

Definition at line 135 of file ne2k.h.

#define TX_2X_PAGES 12

Definition at line 134 of file ne2k.h.

#define TX_PAGES (dev->priv->pingPong ? TX_2X_PAGES : TX_1X_PAGES)

Definition at line 136 of file ne2k.h.

## Typedef Documentation

typedef struct dp_rcvhdr dp_rcvhdr_t

typedef union etheraddr ether_addr_t

## Function Documentation

int ne2k_init | ( |  | ) |

Definition at line 70 of file ne2k.c.

References dDpl0, dInt, DP_CNTR0, DP_CNTR1, DP_CNTR2, DP_CURR, DP_MAR0, DP_MAR1, DP_MAR2, DP_MAR3, DP_MAR4, DP_MAR5, DP_MAR6, DP_MAR7, dPresent, inportByte(), device::ioAddr, device::irq, irqEnable(), kmalloc(), kprintf(), mDev, mVec, ne2kISR(), NE_BNRY, NE_CMD, NE_DCR, NE_IMR, NE_ISR, NE_PSTART, NE_PSTOP, NE_RBCR0, NE_RBCR1, NE_RCR, NE_TCR, outportByte(), setVector(), startPage, stopPage, and x20.

Here is the call graph for this function:

struct nicBuffer* ne2kAllocBuffer | ( | int |  | ) |

Definition at line 313 of file ne2k.c.

References nicBuffer::buffer, kmalloc(), nicBuffer::length, ne2k_spinLock, ne2kBuffer, nicBuffer::next, spinLock(), and spinUnlock().

Referenced by dp_pkt2user().

Here is the call graph for this function:

int ne2kDevInit | ( | struct device * |  | ) |

void ne2kFreeBuffer | ( | struct nicBuffer * |  | ) |

Definition at line 353 of file ne2k.c.

References nicBuffer::buffer, and kfree().

Here is the call graph for this function:

struct nicBuffer* ne2kGetBuffer | ( |  | ) |

Definition at line 341 of file ne2k.c.

References ne2k_spinLock, ne2kBuffer, nicBuffer::next, and x1.

void ne2kHandler | ( |  | ) |

Definition at line 191 of file ne2k.c.

References dp_recv(), eoi, inportByte(), device::ioAddr, irqDisable(), irqEnable(), kprintf(), mDev, mPic, NE_IMR, NE_ISR, NE_TPSR, outportByte(), sPic, and status.

Here is the call graph for this function:

void ne2kISR | ( |  | ) |

Referenced by ne2k_init().

int ne2kProbe | ( | int | ,
|  | struct device * |  |
| ) |  |  |

int NICtoPC | ( | struct device * | dev,
|  | void * | packet,
|  | int | length,
|  | int | nic_addr |
| ) |  |  |

Definition at line 164 of file ne2k.c.

References assert, EN0_ISR, EN0_RCNTHI, EN0_RCNTLO, EN0_RSARHI, EN0_RSARLO, inportWord(), device::ioAddr, NE_DATAPORT, and outportByte().

Referenced by dp_pkt2user().

Here is the call graph for this function:

void NS8390_init | ( | struct device * | dev,
|  | int | startp |
| ) |  |  |

int PCtoNIC | ( | struct device * | dev,
|  | void * | packet,
|  | int | length |
| ) |  |  |

Definition at line 115 of file ne2k.c.

References assert, E8390_RWRITE, E8390_START, EN0_ISR, EN0_RCNTHI, EN0_RCNTLO, EN0_RSARHI, EN0_RSARLO, inportByte(), device::ioAddr, kpanic(), NE_DATAPORT, outportByte(), and outportWord().

Here is the call graph for this function:

## Variable Documentation

char* nicPacket

uInt32 packetLength