DEC21143.h

Go to the documentation of this file.
00001 /* ES40 emulator.
00002  * Copyright (C) 2007-2008 by the ES40 Emulator Project
00003  *
00004  * WWW    : http://sourceforge.net/projects/es40
00005  * E-mail : camiel@camicom.com
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020  * 
00021  * Although this is not required, the author would appreciate being notified of, 
00022  * and receiving any modifications you may make to the source code that might serve
00023  * the general public.
00024  *
00025  * Parts of this file based upon GXemul, which is Copyright (C) 2004-2007  
00026  * Anders Gavare.  All rights reserved.
00027  */
00028 
00086 #if !defined(INCLUDED_DEC21143_H_)
00087 #define INCLUDED_DEC21143_H
00088 
00089 #include "PCIDevice.h"
00090 #include "DEC21143_mii.h"
00091 #include "DEC21143_tulipreg.h"
00092 #if defined(WIN32)
00093 #define HAVE_REMOTE
00094 #endif
00095 #include <pcap.h>
00096 #include "Ethernet.h"
00097 
00106 class CDEC21143 : public CPCIDevice, public Poco::Runnable
00107 {
00108   public:
00109     virtual int   SaveState(FILE* f);
00110     virtual int   RestoreState(FILE* f);
00111     void          instant_tick();
00112 
00113     //    void interrupt(int number);
00114     virtual void  check_state();
00115     virtual void  WriteMem_Bar(int func, int bar, u32 address, int dsize,
00116                                u32 data);
00117     virtual u32   ReadMem_Bar(int func, int bar, u32 address, int dsize);
00118 
00119     CDEC21143(CConfigurator* confg, class CSystem* c, int pcibus, int pcidev);
00120     virtual       ~CDEC21143();
00121     virtual void  ResetPCI();
00122     void          ResetNIC();
00123     void          SetupFilter();
00124     void          receive_process();
00125     virtual void  run();
00126     virtual void  init();
00127     virtual void  start_threads();
00128     virtual void  stop_threads();
00129   private:
00130     static int  nic_num;
00131 
00132     Poco::Thread * myThread;
00133     bool                StopThread;
00134 
00135     u32                 nic_read(u32 address, int dsize);
00136     void                nic_write(u32 address, int dsize, u32 data);
00137     void                mii_access(uint32_t oldreg, uint32_t idata);
00138     void                srom_access(uint32_t oldreg, uint32_t idata);
00139 
00140     int                 dec21143_rx();
00141     int                 dec21143_tx();
00142     void                set_tx_state(int tx_state);
00143     void                set_rx_state(int rx_state);
00144 
00145     CPacketQueue*       rx_queue;
00146     pcap_t*             fp;
00147     struct bpf_program  fcode;
00148     bool                calc_crc;
00149 
00151     struct SNIC_state
00152     {
00153       bool  irq_was_asserted;   
00155       u8    mac[6];             
00156       u8    setup_filter[192];  
00157       int   descr_skip;         // Descriptor Skip Length [DSL] (in bytes)
00158       
00160       struct SNIC_srom
00161       {
00162         u8  data[1 << (7)];
00163         int curbit;
00164         int opcode;
00165         int opcode_has_started;
00166         int addr;
00167       } srom;
00168 
00170       struct SNIC_mii
00171       {
00172         u16 phy_reg[MII_NPHY * 32];
00173         int state;
00174         int bit;
00175         int opcode;
00176         int phyaddr;
00177         int regaddr;
00178       } mii;
00179 
00180       u32 reg[32];  
00182 
00183       struct SNIC_tx
00184       {
00185         u32             cur_addr;
00186         unsigned char*  cur_buf;
00187         int             cur_buf_len;
00188         int             idling;
00189         int             idling_threshold;
00190         bool            suspend;
00191       } tx;
00192 
00194       struct SNIC_rx
00195       {
00196         u32             cur_addr;
00197         unsigned char*  cur_buf;
00198         int             cur_buf_len;
00199         int             cur_offset;
00200         eth_packet      current;
00201       } rx;
00202     } state;
00203 };
00204 #endif // !defined(INCLUDED_DEC21143_H)

SourceForge.net Logo
Project space on SourceForge.net