CDEC21143 Class Reference

#include <DEC21143.h>

Inheritance diagram for CDEC21143:

Inheritance graph
[legend]
Collaboration diagram for CDEC21143:

Collaboration graph
[legend]

Detailed Description

Emulated DEC 21143 NIC device.

Documentation consulted:

Definition at line 106 of file DEC21143.h.


Public Member Functions

virtual int SaveState (FILE *f)
 Save state to a Virtual Machine State file.
virtual int RestoreState (FILE *f)
 Restore state from a Virtual Machine State file.
void instant_tick ()
virtual void check_state ()
 Check if threads are still running.
virtual void WriteMem_Bar (int func, int bar, u32 address, int dsize, u32 data)
virtual u32 ReadMem_Bar (int func, int bar, u32 address, int dsize)
 CDEC21143 (CConfigurator *confg, class CSystem *c, int pcibus, int pcidev)
 Constructor.
virtual ~CDEC21143 ()
 Destructor.
virtual void ResetPCI ()
 Reset the network interface internals to their condition immediately after power-up, including the PCI configuration.
void ResetNIC ()
 Reset the network interface internals to their condition immediately after power-up.
void SetupFilter ()
void receive_process ()
virtual void run ()
 Thread entry point.
virtual void init ()
 Initialize the network device.
virtual void start_threads ()
virtual void stop_threads ()

Private Member Functions

u32 nic_read (u32 address, int dsize)
 Read from the NIC registers.
void nic_write (u32 address, int dsize, u32 data)
 Write to the NIC registers.
void mii_access (uint32_t oldreg, uint32_t idata)
 This function handles accesses to the MII.
void srom_access (uint32_t oldreg, uint32_t idata)
 This function handles reads from the Ethernet Address ROM.
int dec21143_rx ()
 Receive a packet.
int dec21143_tx ()
 Transmit a packet, if the guest OS has marked a descriptor as containing data to transmit.
void set_tx_state (int tx_state)
void set_rx_state (int rx_state)

Private Attributes

Poco::ThreadmyThread
bool StopThread
CPacketQueuerx_queue
pcap_t * fp
struct bpf_program fcode
bool calc_crc
struct CDEC21143::SNIC_state state

Static Private Attributes

static int nic_num = 0

Data Structures

struct  SNIC_state
 The state structure contains all elements that need to be saved to the statefile. More...

Constructor & Destructor Documentation

CDEC21143::CDEC21143 ( CConfigurator confg,
class CSystem c,
int  pcibus,
int  pcidev 
)

Constructor.

Definition at line 261 of file DEC21143.cpp.

CDEC21143::~CDEC21143 (  )  [virtual]

Destructor.

Definition at line 447 of file DEC21143.cpp.

References fp, rx_queue, and stop_threads().


Member Function Documentation

int CDEC21143::SaveState ( FILE *  f  )  [virtual]

Save state to a Virtual Machine State file.

Reimplemented from CPCIDevice.

Definition at line 1719 of file DEC21143.cpp.

int CDEC21143::RestoreState ( FILE *  f  )  [virtual]

Restore state from a Virtual Machine State file.

Reimplemented from CPCIDevice.

Definition at line 1738 of file DEC21143.cpp.

void CDEC21143::instant_tick (  ) 

void CDEC21143::check_state (  )  [virtual]

Check if threads are still running.

Reimplemented from CSystemComponent.

Definition at line 484 of file DEC21143.cpp.

References FAILURE, Poco::Thread::isRunning(), and myThread.

void CDEC21143::WriteMem_Bar ( int  func,
int  bar,
u32  address,
int  dsize,
u32  data 
) [virtual]

Reimplemented from CPCIDevice.

Definition at line 468 of file DEC21143.cpp.

References endian_bits(), and nic_write().

u32 CDEC21143::ReadMem_Bar ( int  func,
int  bar,
u32  address,
int  dsize 
) [virtual]

Reimplemented from CPCIDevice.

Definition at line 455 of file DEC21143.cpp.

References nic_read().

void CDEC21143::ResetPCI (  )  [virtual]

Reset the network interface internals to their condition immediately after power-up, including the PCI configuration.

Reimplemented from CPCIDevice.

Definition at line 1578 of file DEC21143.cpp.

Referenced by init().

void CDEC21143::ResetNIC (  ) 

Reset the network interface internals to their condition immediately after power-up.

This does not affect the PCI configuration.

Code for computing the SROM checksum is taken from [T64].

Definition at line 1591 of file DEC21143.cpp.

Referenced by nic_write().

void CDEC21143::SetupFilter (  ) 

Definition at line 1479 of file DEC21143.cpp.

void CDEC21143::receive_process (  ) 

void CDEC21143::run ( void   )  [virtual]

void CDEC21143::init (  )  [virtual]

void CDEC21143::start_threads (  )  [virtual]

Reimplemented from CSystemComponent.

Definition at line 421 of file DEC21143.cpp.

References Poco::Thread::getName(), myThread, Poco::Thread::start(), and StopThread.

void CDEC21143::stop_threads (  )  [virtual]

Reimplemented from CSystemComponent.

Definition at line 432 of file DEC21143.cpp.

References Poco::Thread::getName(), Poco::Thread::join(), myThread, and StopThread.

Referenced by ~CDEC21143().

u32 CDEC21143::nic_read ( u32  address,
int  dsize 
) [private]

Read from the NIC registers.

Definition at line 519 of file DEC21143.cpp.

References CDEC21143::SNIC_state::reg, and state.

Referenced by ReadMem_Bar().

void CDEC21143::nic_write ( u32  address,
int  dsize,
u32  data 
) [private]

void CDEC21143::mii_access ( uint32_t  oldreg,
uint32_t  idata 
) [private]

This function handles accesses to the MII.

Data streams seem to be of the following format:

vv---- starting delimiter ... 01 xx yyyyy zzzzz a[a] dddddddddddddddd ^---- I am starting with mii_bit = 0 here

where x = opcode (10 = read, 01 = write) y = PHY address z = register address a = on Reads: ACK bit (returned, should be 0) on Writes: _TWO_ dummy bits (10) d = 16 bits of data (MSB first)

Definition at line 797 of file DEC21143.cpp.

References CDEC21143::SNIC_state::SNIC_mii::bit, CSR_MIIROM, CDEC21143::SNIC_state::mii, MII_COMMAND_READ, MII_COMMAND_WRITE, MII_STATE_A, MII_STATE_D, MII_STATE_IDLE, MII_STATE_READ_OP, MII_STATE_READ_PHYADDR_REGADDR, MII_STATE_RESET, MII_STATE_START_WAIT, MIIROM_BR, MIIROM_MDC, MIIROM_MDI, MIIROM_MDO, MIIROM_MIIDIR, CDEC21143::SNIC_state::SNIC_mii::opcode, CDEC21143::SNIC_state::SNIC_mii::phy_reg, CDEC21143::SNIC_state::SNIC_mii::phyaddr, CDEC21143::SNIC_state::reg, CDEC21143::SNIC_state::SNIC_mii::regaddr, CDEC21143::SNIC_state::SNIC_mii::state, and state.

Referenced by nic_write().

void CDEC21143::srom_access ( uint32_t  oldreg,
uint32_t  idata 
) [private]

This function handles reads from the Ethernet Address ROM.

This is not a 100% correct implementation, as it was reverse-engineered from OpenBSD sources; it seems to work with OpenBSD, NetBSD, and Linux, though.

Each transfer (if I understood this correctly) is of the following format:

1xx yyyyyy zzzzzzzzzzzzzzzz

where 1xx = operation (6 means a Read), yyyyyy = ROM address zz...z = data

y and z are _both_ read and written to at the same time; this enables the operating system to sense the number of bits in y (when reading, all y bits are 1 except the last one).

Definition at line 985 of file DEC21143.cpp.

References CDEC21143::SNIC_state::SNIC_srom::addr, CDEC21143::SNIC_state::SNIC_srom::curbit, CDEC21143::SNIC_state::SNIC_srom::opcode, CDEC21143::SNIC_state::SNIC_srom::opcode_has_started, CDEC21143::SNIC_state::srom, and state.

Referenced by nic_write().

int CDEC21143::dec21143_rx (  )  [private]

Receive a packet.

(If there is no current packet, then check for newly arrived ones. If the current packet couldn't be fully transfered the last time, then continue on that packet.)

Definition at line 1105 of file DEC21143.cpp.

References CPacketQueue::count(), CDEC21143::SNIC_state::SNIC_rx::current, CPacketQueue::get_head(), CDEC21143::SNIC_state::rx, rx_queue, and state.

Referenced by receive_process().

int CDEC21143::dec21143_tx (  )  [private]

Transmit a packet, if the guest OS has marked a descriptor as containing data to transmit.

Definition at line 1271 of file DEC21143.cpp.

Referenced by run().

void CDEC21143::set_tx_state ( int  tx_state  )  [private]

Definition at line 770 of file DEC21143.cpp.

References CSR_STATUS, CDEC21143::SNIC_state::reg, state, and STATUS_TS.

Referenced by nic_write().

void CDEC21143::set_rx_state ( int  rx_state  )  [private]

Definition at line 776 of file DEC21143.cpp.

References CSR_STATUS, CDEC21143::SNIC_state::reg, state, and STATUS_RS.

Referenced by nic_write().


Field Documentation

int CDEC21143::nic_num = 0 [static, private]

Definition at line 130 of file DEC21143.h.

Referenced by init().

Definition at line 132 of file DEC21143.h.

Referenced by check_state(), init(), start_threads(), and stop_threads().

bool CDEC21143::StopThread [private]

Definition at line 133 of file DEC21143.h.

Referenced by run(), start_threads(), and stop_threads().

Definition at line 145 of file DEC21143.h.

Referenced by dec21143_rx(), init(), receive_process(), and ~CDEC21143().

pcap_t* CDEC21143::fp [private]

Definition at line 146 of file DEC21143.h.

Referenced by init(), receive_process(), and ~CDEC21143().

struct bpf_program CDEC21143::fcode [read, private]

Definition at line 147 of file DEC21143.h.

bool CDEC21143::calc_crc [private]

Definition at line 148 of file DEC21143.h.

Referenced by init(), and receive_process().


The documentation for this class was generated from the following files:

SourceForge.net Logo
Project space on SourceForge.net