# ne2k.c File Reference

`#include <isa/ne2k.h>`
`#include <isa/8259.h>`
`#include <sys/device.old.h>`
`#include <sys/io.h>`
`#include <sys/idt.h>`
`#include <lib/kmalloc.h>`
`#include <lib/kprintf.h>`
`#include <string.h>`
`#include <ubixos/kpanic.h>`
`#include <ubixos/vitals.h>`
`#include <ubixos/spinlock.h>`
`#include <assert.h>`

Include dependency graph for ne2k.c:

Go to the source code of this file.

## Functions

| asm (".globl ne2kISR \n""ne2kISR: \n"" pusha \n"" call ne2kHandler \n"" popa \n"" iret \n")
static int | dp_pkt2user (struct device *dev, int page, int length)
static int | dp_recv (struct device *)
static void | getblock (struct device *dev, int page, size_t offset, size_t size, void *dst)
int | ne2k_init ()
nicBuffer * | ne2kAllocBuffer (int length)
void | ne2kFreeBuffer (struct nicBuffer *buf)
nicBuffer * | ne2kGetBuffer ()
void | ne2kHandler ()
int | NICtoPC (struct device *dev, void *packet, int length, int nic_addr)
int | PCtoNIC (struct device *dev, void *packet, int length)

## Variables

static struct device * | mDev = 0x0
static spinLock_t | ne2k_spinLock = SPIN_LOCK_INITIALIZER
static struct nicBuffer * | ne2kBuffer = 0x0

## Function Documentation

asm | ( | ".globl ne2kISR \n""ne2kISR: \n"" pusha \n"" call ne2kHandler \n"" popa \n"" iret \n" |  | ) |

static int dp_pkt2user | ( | struct device * | dev,
|  | int | page,
|  | int | length |
| ) |  |  | `[static]`

Definition at line 297 of file ne2k.c.

References nicBuffer::buffer, DP_PAGESIZE, kprintf(), ne2kAllocBuffer(), NICtoPC(), OK, and stopPage.

Referenced by dp_recv().

Here is the call graph for this function:

static int dp_recv | ( | struct device * |  | ) | `[static]`

Definition at line 223 of file ne2k.c.

References dp_pkt2user(), getblock(), inportByte(), device::ioAddr, kpanic(), kprintf(), NE_BNRY, NE_CMD, NE_CURRENT, OK, outportByte(), RSR_FO, RSR_PRX, startPage, and stopPage.

Referenced by ne2kHandler().

Here is the call graph for this function:

static void getblock | ( | struct device * | dev,
|  | int | page,
|  | size_t | offset,
|  | size_t | size,
|  | void * | dst |
| ) |  |  | `[static]`

Definition at line 279 of file ne2k.c.

References DP_PAGESIZE, E8390_RREAD, E8390_START, EN0_ISR, EN0_RSARHI, EN0_RSARLO, inportWord(), device::ioAddr, NE_CMD, NE_DATAPORT, NE_RBCR0, NE_RBCR1, and outportByte().

Referenced by dp_recv().

Here is the call graph for this function:

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 | length | ) |

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:

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

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:

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:

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

struct device* mDev = 0x0`[static]`

Definition at line 51 of file ne2k.c.

Referenced by ne2k_init(), and ne2kHandler().

spinLock_t ne2k_spinLock = SPIN_LOCK_INITIALIZER`[static]`

Definition at line 44 of file ne2k.c.

Referenced by ne2kAllocBuffer(), and ne2kGetBuffer().

struct nicBuffer* ne2kBuffer = 0x0`[static]`

Definition at line 50 of file ne2k.c.

Referenced by ne2kAllocBuffer(), and ne2kGetBuffer().