2004-01-13 22:21:21 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2004-01-13 22:21:21 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 Fen Systems Ltd.
|
|
|
|
// http://www.fensystems.co.uk/
|
2017-03-24 22:57:25 +03:00
|
|
|
// Copyright (C) 2003-2017 The Bochs Project
|
2004-01-13 22:21:21 +03:00
|
|
|
//
|
|
|
|
// 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 {
|
|
|
|
|
|
|
|
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
|
|
|
|
2011-12-28 15:51:42 +04:00
|
|
|
int statusbar_id;
|
2004-01-13 22:21:21 +03:00
|
|
|
} bx_pnic_t;
|
|
|
|
|
|
|
|
|
2017-03-26 11:09:28 +03:00
|
|
|
class bx_pcipnic_c : public bx_pci_device_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 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);
|
|
|
|
|
2011-12-19 00:26:14 +04:00
|
|
|
BX_PNIC_SMF bx_bool mem_read_handler(bx_phy_address addr, unsigned len, void *data, void *param);
|
|
|
|
|
2004-01-13 22:21:21 +03:00
|
|
|
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);
|
2011-12-17 12:22:33 +04:00
|
|
|
|
|
|
|
static Bit32u rx_status_handler(void *arg);
|
|
|
|
BX_PNIC_SMF Bit32u rx_status(void);
|
2004-01-13 22:21:21 +03:00
|
|
|
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
|