etherbus.hh revision 1762
111247Sradhika.jagtap@ARM.com/* 211247Sradhika.jagtap@ARM.com * Copyright (c) 2002-2005 The Regents of The University of Michigan 311247Sradhika.jagtap@ARM.com * All rights reserved. 411247Sradhika.jagtap@ARM.com * 511247Sradhika.jagtap@ARM.com * Redistribution and use in source and binary forms, with or without 611247Sradhika.jagtap@ARM.com * modification, are permitted provided that the following conditions are 711247Sradhika.jagtap@ARM.com * met: redistributions of source code must retain the above copyright 811247Sradhika.jagtap@ARM.com * notice, this list of conditions and the following disclaimer; 911247Sradhika.jagtap@ARM.com * redistributions in binary form must reproduce the above copyright 1011247Sradhika.jagtap@ARM.com * notice, this list of conditions and the following disclaimer in the 1111247Sradhika.jagtap@ARM.com * documentation and/or other materials provided with the distribution; 1211247Sradhika.jagtap@ARM.com * neither the name of the copyright holders nor the names of its 1311247Sradhika.jagtap@ARM.com * contributors may be used to endorse or promote products derived from 1411247Sradhika.jagtap@ARM.com * this software without specific prior written permission. 1511247Sradhika.jagtap@ARM.com * 1611247Sradhika.jagtap@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1711247Sradhika.jagtap@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1811247Sradhika.jagtap@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1911247Sradhika.jagtap@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2011247Sradhika.jagtap@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2111247Sradhika.jagtap@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2211247Sradhika.jagtap@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2311247Sradhika.jagtap@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2411247Sradhika.jagtap@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2511247Sradhika.jagtap@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2611247Sradhika.jagtap@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2711247Sradhika.jagtap@ARM.com */ 2811247Sradhika.jagtap@ARM.com 2911247Sradhika.jagtap@ARM.com/* @file 3011247Sradhika.jagtap@ARM.com * Device module for modelling an ethernet hub 3111247Sradhika.jagtap@ARM.com */ 3211247Sradhika.jagtap@ARM.com 3311247Sradhika.jagtap@ARM.com#ifndef __ETHERBUS_H__ 3411247Sradhika.jagtap@ARM.com#define __ETHERBUS_H__ 3511247Sradhika.jagtap@ARM.com 3611247Sradhika.jagtap@ARM.com#include "sim/eventq.hh" 3711247Sradhika.jagtap@ARM.com#include "dev/etherpkt.hh" 3811247Sradhika.jagtap@ARM.com#include "sim/sim_object.hh" 3911247Sradhika.jagtap@ARM.com 4011247Sradhika.jagtap@ARM.comclass EtherDump; 4111247Sradhika.jagtap@ARM.comclass EtherInt; 4211247Sradhika.jagtap@ARM.comclass EtherBus : public SimObject 4311247Sradhika.jagtap@ARM.com{ 4411247Sradhika.jagtap@ARM.com protected: 4511247Sradhika.jagtap@ARM.com typedef std::list<EtherInt *> devlist_t; 4611247Sradhika.jagtap@ARM.com devlist_t devlist; 4711247Sradhika.jagtap@ARM.com double ticksPerByte; 4811247Sradhika.jagtap@ARM.com bool loopback; 4911247Sradhika.jagtap@ARM.com 5011247Sradhika.jagtap@ARM.com protected: 5111247Sradhika.jagtap@ARM.com class DoneEvent : public Event 5211247Sradhika.jagtap@ARM.com { 5311247Sradhika.jagtap@ARM.com protected: 5411247Sradhika.jagtap@ARM.com EtherBus *bus; 5511247Sradhika.jagtap@ARM.com 5611247Sradhika.jagtap@ARM.com public: 5711247Sradhika.jagtap@ARM.com DoneEvent(EventQueue *q, EtherBus *b) 5811247Sradhika.jagtap@ARM.com : Event(q), bus(b) {} 5911247Sradhika.jagtap@ARM.com virtual void process() { bus->txDone(); } 6011247Sradhika.jagtap@ARM.com virtual const char *description() { return "ethernet bus completion"; } 6111247Sradhika.jagtap@ARM.com }; 6211247Sradhika.jagtap@ARM.com 6311247Sradhika.jagtap@ARM.com DoneEvent event; 6411247Sradhika.jagtap@ARM.com PacketPtr packet; 6511247Sradhika.jagtap@ARM.com EtherInt *sender; 6611247Sradhika.jagtap@ARM.com EtherDump *dump; 6711247Sradhika.jagtap@ARM.com 6811247Sradhika.jagtap@ARM.com public: 6911247Sradhika.jagtap@ARM.com EtherBus(const std::string &name, double speed, bool loopback, 7011247Sradhika.jagtap@ARM.com EtherDump *dump); 7111247Sradhika.jagtap@ARM.com virtual ~EtherBus() {} 7211247Sradhika.jagtap@ARM.com 7311247Sradhika.jagtap@ARM.com void txDone(); 7411247Sradhika.jagtap@ARM.com void reg(EtherInt *dev); 7511247Sradhika.jagtap@ARM.com bool busy() const { return (bool)packet; } 7611247Sradhika.jagtap@ARM.com bool send(EtherInt *sender, PacketPtr &packet); 7711247Sradhika.jagtap@ARM.com}; 7811247Sradhika.jagtap@ARM.com 7911247Sradhika.jagtap@ARM.com#endif // __ETHERBUS_H__ 8011247Sradhika.jagtap@ARM.com