1 /////////////////////////////////////////////////////////////////////////
2 // $Id: pcipnic.h,v 1.8 2007/09/28 19:52:03 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
5 // Copyright (C) 2003 Fen Systems Ltd.
6 // http://www.fensystems.co.uk/
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
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
33 # define BX_PNIC_THIS this->
34 # define BX_PNIC_THIS_PTR this
37 #define PNIC_DATA_SIZE 4096
38 #define PNIC_RECV_RINGS 4
46 Bit16u rCmd
; // Command register
47 Bit16u rStatus
; // Status register
48 Bit16u rLength
; // Length register
49 Bit8u rData
[PNIC_DATA_SIZE
]; // Data register array
54 Bit8u recvRing
[PNIC_RECV_RINGS
][PNIC_DATA_SIZE
]; // Receive buffer
55 Bit16u recvRingLength
[PNIC_RECV_RINGS
];
63 class bx_pcipnic_c
: public bx_ne2k_stub_c
, bx_pci_device_stub_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
);
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
);
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
);