#include <DEC21143.h>


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::Thread * | myThread |
| bool | StopThread |
| CPacketQueue * | rx_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... | |
| CDEC21143::CDEC21143 | ( | CConfigurator * | confg, | |
| class CSystem * | c, | |||
| int | pcibus, | |||
| int | pcidev | |||
| ) |
| CDEC21143::~CDEC21143 | ( | ) | [virtual] |
Destructor.
Definition at line 447 of file DEC21143.cpp.
References fp, rx_queue, and stop_threads().
| 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.
Reimplemented from CPCIDevice.
Definition at line 468 of file DEC21143.cpp.
References endian_bits(), and nic_write().
| 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 | ( | ) |
Definition at line 490 of file DEC21143.cpp.
References CPacketQueue::add_tail(), calc_crc, CSR_OPMODE, CSR_SIASTAT, dec21143_rx(), fp, OPMODE_OM_INTLOOP, OPMODE_SR, CDEC21143::SNIC_state::reg, rx_queue, SIASTAT_TRA, and state.
Referenced by run().
| void CDEC21143::run | ( | void | ) | [virtual] |
Thread entry point.
Implements Poco::Runnable.
Definition at line 170 of file DEC21143.cpp.
References CSR_INTEN, CSR_OPMODE, CSR_STATUS, dec21143_tx(), Poco::Exception::displayText(), CPCIDevice::do_pci_interrupt(), CDEC21143::SNIC_state::irq_was_asserted, OPMODE_ST, receive_process(), CDEC21143::SNIC_state::reg, Poco::Thread::sleep(), state, STATUS_AIS, STATUS_NIS, and StopThread.
| void CDEC21143::init | ( | ) | [virtual] |
Initialize the network device.
Reimplemented from CSystemComponent.
Definition at line 267 of file DEC21143.cpp.
References CPCIDevice::add_function(), calc_crc, CDEC21143::SNIC_state::SNIC_tx::cur_buf, CDEC21143::SNIC_state::SNIC_rx::cur_buf, dec21143_cfg_data, dec21143_cfg_mask, CSystemComponent::devid_string, FAILURE, FAILURE_1, fp, CConfigurator::get_bool_value(), CConfigurator::get_num_value(), CConfigurator::get_text_value(), CDEC21143::SNIC_state::SNIC_tx::idling, CDEC21143::SNIC_state::irq_was_asserted, CDEC21143::SNIC_state::mac, CSystemComponent::myCfg, myThread, nic_num, ResetPCI(), CDEC21143::SNIC_state::rx, rx_queue, state, and CDEC21143::SNIC_state::tx.
| 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().
Read from the NIC registers.
Definition at line 519 of file DEC21143.cpp.
References CDEC21143::SNIC_state::reg, and state.
Referenced by ReadMem_Bar().
Write to the NIC registers.
Definition at line 541 of file DEC21143.cpp.
References BUSMODE_DSL, BUSMODE_SWR, CSR_BUSMODE, CSR_INTEN, CSR_MIIROM, CSR_MISSED, CSR_OPMODE, CSR_RXLIST, CSR_RXPOLL, CSR_SIACONN, CSR_SIAGEN, CSR_SIASTAT, CSR_SIATXRX, CSR_STATUS, CSR_TXLIST, CSR_TXPOLL, CDEC21143::SNIC_state::SNIC_tx::cur_addr, CDEC21143::SNIC_state::SNIC_rx::cur_addr, CDEC21143::SNIC_state::descr_skip, CDEC21143::SNIC_state::SNIC_tx::idling, CDEC21143::SNIC_state::SNIC_tx::idling_threshold, mii_access(), MIIROM_MDC, OPMODE_FD, OPMODE_HBD, OPMODE_OM, OPMODE_PCS, OPMODE_PS, OPMODE_SCR, OPMODE_SF, OPMODE_SR, OPMODE_ST, OPMODE_TR, OPMODE_TTM, CDEC21143::SNIC_state::reg, ResetNIC(), CDEC21143::SNIC_state::rx, set_rx_state(), set_tx_state(), SIACONN_SRL, SIASTAT_ANS, SIASTAT_ANS_FLPGOOD, SIASTAT_ANS_START, SIASTAT_LPC, SIASTAT_LPN, SIATXRX_ANE, SIATXRX_T4, SIATXRX_TH, SIATXRX_THX, SIATXRX_TXF, srom_access(), state, STATUS_LNPANC, STATUS_RS_STOPPED, STATUS_RS_WAIT, STATUS_TS_STOPPED, STATUS_TS_SUSPENDED, STATUS_TU, CDEC21143::SNIC_state::SNIC_tx::suspend, and CDEC21143::SNIC_state::tx.
Referenced by WriteMem_Bar().
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().
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().
int CDEC21143::nic_num = 0 [static, private] |
Poco::Thread* CDEC21143::myThread [private] |
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().
CPacketQueue* CDEC21143::rx_queue [private] |
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] |
struct CDEC21143::SNIC_state CDEC21143::state [private] |
Referenced by dec21143_rx(), init(), mii_access(), nic_read(), nic_write(), receive_process(), run(), set_rx_state(), set_tx_state(), and srom_access().