UbixOS  2.0
lnc.c File Reference
#include <pci/lnc.h>
#include <sys/io.h>
#include <sys/types.h>
#include <sys/idt.h>
#include <sys/gdt.h>
#include <lib/kmalloc.h>
#include <lib/kprintf.h>
#include <sys/video.h>
#include <isa/8259.h>
#include <net/net.h>
#include <net/netif.h>
#include <ubixos/spinlock.h>
Include dependency graph for lnc.c:

Go to the source code of this file.

Functions

 asm (".globl lnc_isr \n" "lnc_isr: \n" " pusha \n" " push %ss \n" " push %ds \n" " push %es \n" " push %fs \n" " push %gs \n" " call lnc_INT \n" " mov $0xA0,%dx \n" " mov $0x20,%ax \n" " outb %al,%dx \n" " mov $0x20,%dx \n" " mov $0x20,%ax \n" " outb %al,%dx \n" " pop %gs \n" " pop %fs \n" " pop %es \n" " pop %ds \n" " pop %ss \n" " popa \n" " iret \n")
 
int initLNC ()
 
int lanceProbe (struct lncInfo *lnc)
 
int lnc_driverOwnsRX (struct lncInfo *lnc)
 
int lnc_driverOwnsTX (struct lncInfo *lnc)
 
int lnc_getMode (struct lncInfo *lnc)
 
void lnc_INT ()
 
int lnc_nextRxPtr (struct lncInfo *lnc)
 
int lnc_nextTxPtr (struct lncInfo *lnc)
 
int lnc_probe (struct lncInfo *lnc)
 
uint16_t lnc_readBCR (struct lncInfo *lnc, uint16_t port)
 
uint32_t lnc_readBCR32 (struct lncInfo *lnc, uint32_t port)
 
uint16_t lnc_readCSR (struct lncInfo *lnc, uint16_t port)
 
uint32_t lnc_readCSR32 (struct lncInfo *lnc, uint32_t port)
 
void lnc_reset (struct lncInfo *lnc)
 
void lnc_reset32 (struct lncInfo *lnc)
 
void lnc_rxINT ()
 
int lnc_sendPacket (struct lncInfo *lnc, void *packet, size_t len, uint8_t *dest)
 
int lnc_switchDWord (struct lncInfo *lnc)
 
void lnc_thread ()
 
void lnc_txINT ()
 
void lnc_writeBCR (struct lncInfo *lnc, uint16_t port, uint16_t val)
 
void lnc_writeBCR32 (struct lncInfo *lnc, uint32_t port, uint32_t val)
 
void lnc_writeCSR (struct lncInfo *lnc, uint16_t port, uint16_t val)
 
void lnc_writeCSR32 (struct lncInfo *lnc, uint32_t port, uint32_t val)
 
int lncAttach (struct lncInfo *lnc, int unit)
 
void lncInt ()
 

Variables

struct lncInfolnc = 0x0
 
struct netif lnc_netif
 
struct nicBuffertmpBuf
 

Function Documentation

◆ asm()

asm ( ".globl lnc_isr \n" "lnc_isr: \n" " pusha \n" " push %ss \n" " push %ds \n" " push %es \n" " push %fs \n" " push %gs \n" " call lnc_INT \n" " mov  $0xA0,
%dx \n" " mov  $0x20,
%ax \n" " outb %  al,
%dx \n" " mov  $0x20,
%dx \n" " mov  $0x20,
%ax \n" " outb %  al,
%dx \n" " pop %gs \n" " pop %fs \n" " pop %es \n" " pop %ds \n" " pop %ss \n" " popa \n" " iret \n"   
)

◆ initLNC()

◆ lanceProbe()

int lanceProbe ( struct lncInfo lnc)

Definition at line 231 of file lnc.c.

References C_LANCE, CSR0, CSR0_STOP, CSR3, INEA, inportWord(), lncInfo::ioAddr, LANCE, lnc, lnc_readCSR(), lnc_writeCSR(), RDP, and UNKNOWN.

Referenced by lnc_probe().

Here is the call graph for this function:

◆ lnc_driverOwnsRX()

int lnc_driverOwnsRX ( struct lncInfo lnc)

Definition at line 518 of file lnc.c.

References lnc, hostRingEntry::md, lncInfo::rxPtr, and lncInfo::rxRing.

Referenced by lnc_rxINT(), and lnc_thread().

◆ lnc_driverOwnsTX()

int lnc_driverOwnsTX ( struct lncInfo lnc)

Definition at line 514 of file lnc.c.

References lnc, hostRingEntry::md, lncInfo::txPtr, and lncInfo::txRing.

Referenced by lnc_sendPacket().

◆ lnc_getMode()

int lnc_getMode ( struct lncInfo lnc)

Definition at line 573 of file lnc.c.

References CSR0, CSR0_STOP, lnc, lnc_readCSR(), lnc_readCSR32(), lnc_reset(), lnc_reset32(), MODE_16, MODE_32, and MODE_INVALID.

Referenced by initLNC().

Here is the call graph for this function:

◆ lnc_INT()

void lnc_INT ( )

Definition at line 254 of file lnc.c.

References CSR0, ERR, kprintf(), lnc, lnc_writeCSR32(), RINT, and TINT.

Here is the call graph for this function:

◆ lnc_nextRxPtr()

int lnc_nextRxPtr ( struct lncInfo lnc)

Definition at line 534 of file lnc.c.

References lnc, NDESC, lncInfo::nrdre, and lncInfo::rxPtr.

Referenced by lnc_rxINT(), and lnc_thread().

◆ lnc_nextTxPtr()

int lnc_nextTxPtr ( struct lncInfo lnc)

Definition at line 522 of file lnc.c.

References lnc, NDESC, lncInfo::ntdre, and lncInfo::txPtr.

Referenced by lnc_sendPacket().

◆ lnc_probe()

int lnc_probe ( struct lncInfo lnc)

◆ lnc_readBCR()

uint16_t lnc_readBCR ( struct lncInfo lnc,
uint16_t  port 
)

Definition at line 84 of file lnc.c.

References BDP, inportWord(), lncInfo::ioAddr, lnc, outportWord(), and RAP.

Here is the call graph for this function:

◆ lnc_readBCR32()

uint32_t lnc_readBCR32 ( struct lncInfo lnc,
uint32_t  port 
)

Definition at line 89 of file lnc.c.

References BDP32, inportDWord(), lncInfo::ioAddr, lnc, outportDWord(), and RAP32.

Referenced by initLNC(), and lnc_switchDWord().

Here is the call graph for this function:

◆ lnc_readCSR()

uint16_t lnc_readCSR ( struct lncInfo lnc,
uint16_t  port 
)

Definition at line 64 of file lnc.c.

References inportWord(), lncInfo::ioAddr, lnc, outportWord(), RAP, and RDP.

Referenced by lanceProbe(), lnc_getMode(), and lnc_probe().

Here is the call graph for this function:

◆ lnc_readCSR32()

uint32_t lnc_readCSR32 ( struct lncInfo lnc,
uint32_t  port 
)

Definition at line 69 of file lnc.c.

References inportDWord(), lncInfo::ioAddr, lnc, outportDWord(), RAP32, and RDP32.

Referenced by initLNC(), lnc_getMode(), and lnc_switchDWord().

Here is the call graph for this function:

◆ lnc_reset()

void lnc_reset ( struct lncInfo lnc)

Definition at line 585 of file lnc.c.

References inportWord(), lncInfo::ioAddr, lnc, and RESET.

Referenced by lnc_getMode().

Here is the call graph for this function:

◆ lnc_reset32()

void lnc_reset32 ( struct lncInfo lnc)

Definition at line 589 of file lnc.c.

References inportDWord(), lncInfo::ioAddr, lnc, and RESET32.

Referenced by lnc_getMode().

Here is the call graph for this function:

◆ lnc_rxINT()

void lnc_rxINT ( )

◆ lnc_sendPacket()

int lnc_sendPacket ( struct lncInfo lnc,
void *  packet,
size_t  len,
uint8_t dest 
)

Definition at line 546 of file lnc.c.

References hostRingEntry::bcnt, lncInfo::bufferSize, kpanic(), lnc, lnc_driverOwnsTX(), lnc_nextTxPtr(), hostRingEntry::md, memcpy(), lncInfo::txBuffer, lncInfo::txPtr, and lncInfo::txRing.

Here is the call graph for this function:

◆ lnc_switchDWord()

int lnc_switchDWord ( struct lncInfo lnc)

Definition at line 593 of file lnc.c.

References BCR18, BCR18_DWIO, CSR58, inportDWord(), inportWord(), lncInfo::ioAddr, kprintf(), lnc, lnc_readBCR32(), lnc_readCSR32(), lnc_writeCSR32(), outportDWord(), RDP, RESET, and RESET32.

Referenced by initLNC().

Here is the call graph for this function:

◆ lnc_thread()

void lnc_thread ( )

◆ lnc_txINT()

void lnc_txINT ( )

Definition at line 352 of file lnc.c.

◆ lnc_writeBCR()

void lnc_writeBCR ( struct lncInfo lnc,
uint16_t  port,
uint16_t  val 
)

Definition at line 74 of file lnc.c.

References BDP, lncInfo::ioAddr, lnc, outportWord(), and RAP.

Here is the call graph for this function:

◆ lnc_writeBCR32()

void lnc_writeBCR32 ( struct lncInfo lnc,
uint32_t  port,
uint32_t  val 
)

Definition at line 79 of file lnc.c.

References BDP32, lncInfo::ioAddr, lnc, outportDWord(), and RAP32.

Referenced by initLNC().

Here is the call graph for this function:

◆ lnc_writeCSR()

void lnc_writeCSR ( struct lncInfo lnc,
uint16_t  port,
uint16_t  val 
)

Definition at line 54 of file lnc.c.

References lncInfo::ioAddr, lnc, outportWord(), RAP, and RDP.

Referenced by lanceProbe().

Here is the call graph for this function:

◆ lnc_writeCSR32()

void lnc_writeCSR32 ( struct lncInfo lnc,
uint32_t  port,
uint32_t  val 
)

Definition at line 59 of file lnc.c.

References lncInfo::ioAddr, lnc, outportDWord(), RAP32, and RDP32.

Referenced by initLNC(), lnc_INT(), and lnc_switchDWord().

Here is the call graph for this function:

◆ lncAttach()

◆ lncInt()

void lncInt ( )

Definition at line 368 of file lnc.c.

References ERR, inportWord(), INTR, lncInfo::ioAddr, kprintf(), lnc, outportByte(), outportWord(), RDP, RINT, and TINT.

Here is the call graph for this function:

Variable Documentation

◆ lnc

◆ lnc_netif

struct netif lnc_netif

Definition at line 42 of file lnc.c.

Referenced by lnc_thread().

◆ tmpBuf

struct nicBuffer* tmpBuf

Definition at line 52 of file lnc.c.

Referenced by lnc_rxINT(), lnc_thread(), ne2kAllocBuffer(), and ne2kGetBuffer().