- added instructions how to update the online documentation
[bochs-mirror.git] / iodev / pcipnic.h
blob84fac706b90dc385bd4d839d4dc3e1df9a318a35
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: pcipnic.h,v 1.8 2007/09/28 19:52:03 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2003 Fen Systems Ltd.
6 // http://www.fensystems.co.uk/
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef BX_IODEV_PCIPNIC_H
23 #define BX_IODEV_PCIPNIC_H
25 #include "pnic_api.h"
27 #if BX_USE_PCIPNIC_SMF
28 # define BX_PNIC_SMF static
29 # define BX_PNIC_THIS thePNICDevice->
30 # define BX_PNIC_THIS_PTR thePNICDevice
31 #else
32 # define BX_PNIC_SMF
33 # define BX_PNIC_THIS this->
34 # define BX_PNIC_THIS_PTR this
35 #endif
37 #define PNIC_DATA_SIZE 4096
38 #define PNIC_RECV_RINGS 4
40 typedef struct {
42 Bit32u base_ioaddr;
43 Bit8u macaddr[6];
44 Bit8u irqEnabled;
46 Bit16u rCmd; // Command register
47 Bit16u rStatus; // Status register
48 Bit16u rLength; // Length register
49 Bit8u rData[PNIC_DATA_SIZE]; // Data register array
50 Bit16u rDataCursor;
52 int recvIndex;
53 int recvQueueLength;
54 Bit8u recvRing[PNIC_RECV_RINGS][PNIC_DATA_SIZE]; // Receive buffer
55 Bit16u recvRingLength[PNIC_RECV_RINGS];
57 Bit8u devfunc;
58 Bit8u pci_conf[256];
60 } bx_pnic_t;
63 class bx_pcipnic_c : public bx_ne2k_stub_c, bx_pci_device_stub_c {
64 public:
65 bx_pcipnic_c();
66 virtual ~bx_pcipnic_c();
67 virtual void init(void);
68 virtual void reset(unsigned type);
69 virtual void register_state(void);
70 virtual void after_restore_state(void);
72 virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len);
73 virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len);
75 private:
76 bx_pnic_t s;
78 static void set_irq_level(bx_bool level);
80 static void pnic_timer_handler(void *);
81 void pnic_timer(void);
83 static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
84 static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
85 #if !BX_USE_PCIPNIC_SMF
86 Bit32u read(Bit32u address, unsigned io_len);
87 void write(Bit32u address, Bit32u value, unsigned io_len);
88 #endif
90 eth_pktmover_c *ethdev;
91 static void exec_command(void);
92 static void rx_handler(void *arg, const void *buf, unsigned len);
93 BX_PNIC_SMF void rx_frame(const void *buf, unsigned io_len);
96 #endif