2004-01-13 22:21:21 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-02-08 12:05:52 +03:00
|
|
|
// $Id: pcipnic.h,v 1.10 2009-02-08 09:05:52 vruppert Exp $
|
2004-01-13 22:21:21 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 Fen Systems Ltd.
|
|
|
|
// http://www.fensystems.co.uk/
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-02-08 12:05:52 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-01-13 22:21:21 +03:00
|
|
|
|
2006-03-07 21:16:41 +03:00
|
|
|
#ifndef BX_IODEV_PCIPNIC_H
|
|
|
|
#define BX_IODEV_PCIPNIC_H
|
|
|
|
|
2004-01-13 22:21:21 +03:00
|
|
|
#include "pnic_api.h"
|
|
|
|
|
|
|
|
#if BX_USE_PCIPNIC_SMF
|
|
|
|
# define BX_PNIC_SMF static
|
|
|
|
# define BX_PNIC_THIS thePNICDevice->
|
2004-07-13 21:45:34 +04:00
|
|
|
# define BX_PNIC_THIS_PTR thePNICDevice
|
2004-01-13 22:21:21 +03:00
|
|
|
#else
|
|
|
|
# define BX_PNIC_SMF
|
|
|
|
# define BX_PNIC_THIS this->
|
2004-07-13 21:45:34 +04:00
|
|
|
# define BX_PNIC_THIS_PTR this
|
2004-01-13 22:21:21 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PNIC_DATA_SIZE 4096
|
|
|
|
#define PNIC_RECV_RINGS 4
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
2004-07-13 21:45:34 +04:00
|
|
|
Bit32u base_ioaddr;
|
2004-01-13 22:21:21 +03:00
|
|
|
Bit8u macaddr[6];
|
2004-03-26 06:22:46 +03:00
|
|
|
Bit8u irqEnabled;
|
2004-01-13 22:21:21 +03:00
|
|
|
|
|
|
|
Bit16u rCmd; // Command register
|
|
|
|
Bit16u rStatus; // Status register
|
|
|
|
Bit16u rLength; // Length register
|
|
|
|
Bit8u rData[PNIC_DATA_SIZE]; // Data register array
|
|
|
|
Bit16u rDataCursor;
|
|
|
|
|
|
|
|
int recvIndex;
|
|
|
|
int recvQueueLength;
|
|
|
|
Bit8u recvRing[PNIC_RECV_RINGS][PNIC_DATA_SIZE]; // Receive buffer
|
|
|
|
Bit16u recvRingLength[PNIC_RECV_RINGS];
|
|
|
|
|
2004-07-13 21:45:34 +04:00
|
|
|
Bit8u devfunc;
|
2004-01-13 22:21:21 +03:00
|
|
|
Bit8u pci_conf[256];
|
|
|
|
|
|
|
|
} bx_pnic_t;
|
|
|
|
|
|
|
|
|
2006-04-26 04:04:49 +04:00
|
|
|
class bx_pcipnic_c : public bx_ne2k_stub_c, bx_pci_device_stub_c {
|
2004-01-13 22:21:21 +03:00
|
|
|
public:
|
2006-03-07 21:16:41 +03:00
|
|
|
bx_pcipnic_c();
|
2006-03-08 00:11:20 +03:00
|
|
|
virtual ~bx_pcipnic_c();
|
2006-03-07 21:16:41 +03:00
|
|
|
virtual void init(void);
|
|
|
|
virtual void reset(unsigned type);
|
2006-05-27 19:54:49 +04:00
|
|
|
virtual void register_state(void);
|
|
|
|
virtual void after_restore_state(void);
|
2004-01-13 22:21:21 +03:00
|
|
|
|
2006-03-08 00:11:20 +03:00
|
|
|
virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len);
|
|
|
|
virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len);
|
|
|
|
|
2004-01-13 22:21:21 +03:00
|
|
|
private:
|
|
|
|
bx_pnic_t s;
|
|
|
|
|
2004-07-13 21:45:34 +04:00
|
|
|
static void set_irq_level(bx_bool level);
|
|
|
|
|
2004-01-13 22:21:21 +03:00
|
|
|
static void pnic_timer_handler(void *);
|
|
|
|
void pnic_timer(void);
|
|
|
|
|
|
|
|
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
|
|
|
|
static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
|
|
|
|
#if !BX_USE_PCIPNIC_SMF
|
|
|
|
Bit32u read(Bit32u address, unsigned io_len);
|
|
|
|
void write(Bit32u address, Bit32u value, unsigned io_len);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
eth_pktmover_c *ethdev;
|
|
|
|
static void exec_command(void);
|
|
|
|
static void rx_handler(void *arg, const void *buf, unsigned len);
|
|
|
|
BX_PNIC_SMF void rx_frame(const void *buf, unsigned io_len);
|
|
|
|
};
|
2006-03-07 21:16:41 +03:00
|
|
|
|
|
|
|
#endif
|