i8254xGBe.hh revision 3318
16691Stjones1@inf.ed.ac.uk/*
26691Stjones1@inf.ed.ac.uk * Copyright (c) 2006 The Regents of The University of Michigan
36691Stjones1@inf.ed.ac.uk * All rights reserved.
46691Stjones1@inf.ed.ac.uk *
56691Stjones1@inf.ed.ac.uk * Redistribution and use in source and binary forms, with or without
66691Stjones1@inf.ed.ac.uk * modification, are permitted provided that the following conditions are
76691Stjones1@inf.ed.ac.uk * met: redistributions of source code must retain the above copyright
86691Stjones1@inf.ed.ac.uk * notice, this list of conditions and the following disclaimer;
96691Stjones1@inf.ed.ac.uk * redistributions in binary form must reproduce the above copyright
106691Stjones1@inf.ed.ac.uk * notice, this list of conditions and the following disclaimer in the
116691Stjones1@inf.ed.ac.uk * documentation and/or other materials provided with the distribution;
126691Stjones1@inf.ed.ac.uk * neither the name of the copyright holders nor the names of its
136691Stjones1@inf.ed.ac.uk * contributors may be used to endorse or promote products derived from
146691Stjones1@inf.ed.ac.uk * this software without specific prior written permission.
156691Stjones1@inf.ed.ac.uk *
166691Stjones1@inf.ed.ac.uk * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176691Stjones1@inf.ed.ac.uk * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186691Stjones1@inf.ed.ac.uk * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196691Stjones1@inf.ed.ac.uk * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206691Stjones1@inf.ed.ac.uk * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216691Stjones1@inf.ed.ac.uk * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226691Stjones1@inf.ed.ac.uk * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236691Stjones1@inf.ed.ac.uk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246691Stjones1@inf.ed.ac.uk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256691Stjones1@inf.ed.ac.uk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266691Stjones1@inf.ed.ac.uk * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276691Stjones1@inf.ed.ac.uk *
286691Stjones1@inf.ed.ac.uk * Authors: Ali Saidi
296691Stjones1@inf.ed.ac.uk */
306691Stjones1@inf.ed.ac.uk
316691Stjones1@inf.ed.ac.uk/* @file
326691Stjones1@inf.ed.ac.uk * Device model for Intel's 8254x line of gigabit ethernet controllers.
336691Stjones1@inf.ed.ac.uk */
3413610Sgiacomo.gabrielli@arm.com
3512109SRekai.GonzalezAlberquilla@arm.com#ifndef __DEV_I8254XGBE_HH__
368961Sgblack@eecs.umich.edu#define __DEV_I8254XGBE_HH__
376691Stjones1@inf.ed.ac.uk
3813556Sgabeblack@google.com#include "base/inet.hh"
396691Stjones1@inf.ed.ac.uk#include "base/statistics.hh"
406691Stjones1@inf.ed.ac.uk#include "dev/etherint.hh"
416691Stjones1@inf.ed.ac.uk#include "dev/etherpkt.hh"
426691Stjones1@inf.ed.ac.uk#include "dev/i8254xGBe_defs.hh"
436691Stjones1@inf.ed.ac.uk#include "dev/pcidev.hh"
449065Sandreas.hansson@arm.com#include "dev/pktfifo.hh"
459065Sandreas.hansson@arm.com#include "sim/eventq.hh"
469065Sandreas.hansson@arm.com
479065Sandreas.hansson@arm.comclass IGbEInt;
486691Stjones1@inf.ed.ac.uk
4913610Sgiacomo.gabrielli@arm.comclass IGbE : public PciDev
5013610Sgiacomo.gabrielli@arm.com{
5113610Sgiacomo.gabrielli@arm.com  private:
5213610Sgiacomo.gabrielli@arm.com    IGbEInt *etherInt;
5313610Sgiacomo.gabrielli@arm.com    iGbReg::Regs regs;
5413610Sgiacomo.gabrielli@arm.com    int eeOpBits, eeAddrBits, eeDataBits;
5513610Sgiacomo.gabrielli@arm.com    uint8_t eeOpcode, eeAddr;
5613610Sgiacomo.gabrielli@arm.com
5713610Sgiacomo.gabrielli@arm.com    uint16_t flash[iGbReg::EEPROM_SIZE];
5813610Sgiacomo.gabrielli@arm.com
5913610Sgiacomo.gabrielli@arm.com
6013610Sgiacomo.gabrielli@arm.com  public:
6113610Sgiacomo.gabrielli@arm.com    struct Params : public PciDev::Params
6213610Sgiacomo.gabrielli@arm.com    {
6312109SRekai.GonzalezAlberquilla@arm.com        ;
646691Stjones1@inf.ed.ac.uk    };
656691Stjones1@inf.ed.ac.uk
666691Stjones1@inf.ed.ac.uk    IGbE(Params *params);
676691Stjones1@inf.ed.ac.uk    ~IGbE() {;}
686691Stjones1@inf.ed.ac.uk
696691Stjones1@inf.ed.ac.uk    virtual Tick read(Packet *pkt);
706691Stjones1@inf.ed.ac.uk    virtual Tick write(Packet *pkt);
716691Stjones1@inf.ed.ac.uk
726691Stjones1@inf.ed.ac.uk    virtual Tick writeConfig(Packet *pkt);
736691Stjones1@inf.ed.ac.uk
746691Stjones1@inf.ed.ac.uk    bool ethRxPkt(EthPacketPtr packet);
756691Stjones1@inf.ed.ac.uk    void ethTxDone();
7613610Sgiacomo.gabrielli@arm.com
7713610Sgiacomo.gabrielli@arm.com    void setEthInt(IGbEInt *i) { assert(!etherInt); etherInt = i; }
7813610Sgiacomo.gabrielli@arm.com
7913610Sgiacomo.gabrielli@arm.com    const Params *params() const {return (const Params *)_params; }
809920Syasuko.eckert@amd.com
816691Stjones1@inf.ed.ac.uk    virtual void serialize(std::ostream &os);
826691Stjones1@inf.ed.ac.uk    virtual void unserialize(Checkpoint *cp, const std::string &section);
836691Stjones1@inf.ed.ac.uk
846691Stjones1@inf.ed.ac.uk
856691Stjones1@inf.ed.ac.uk};
866691Stjones1@inf.ed.ac.uk
876691Stjones1@inf.ed.ac.ukclass IGbEInt : public EtherInt
886691Stjones1@inf.ed.ac.uk{
896691Stjones1@inf.ed.ac.uk  private:
906691Stjones1@inf.ed.ac.uk    IGbE *dev;
916691Stjones1@inf.ed.ac.uk
926691Stjones1@inf.ed.ac.uk  public:
936691Stjones1@inf.ed.ac.uk    IGbEInt(const std::string &name, IGbE *d)
946691Stjones1@inf.ed.ac.uk        : EtherInt(name), dev(d)
956691Stjones1@inf.ed.ac.uk        { dev->setEthInt(this); }
966691Stjones1@inf.ed.ac.uk
976691Stjones1@inf.ed.ac.uk    virtual bool recvPacket(EthPacketPtr pkt) { return dev->ethRxPkt(pkt); }
986691Stjones1@inf.ed.ac.uk    virtual void sendDone() { dev->ethTxDone(); }
996691Stjones1@inf.ed.ac.uk};
1006691Stjones1@inf.ed.ac.uk
1016691Stjones1@inf.ed.ac.uk
1026691Stjones1@inf.ed.ac.uk
1036691Stjones1@inf.ed.ac.uk
1046691Stjones1@inf.ed.ac.uk
1056691Stjones1@inf.ed.ac.uk#endif //__DEV_I8254XGBE_HH__
1066691Stjones1@inf.ed.ac.uk
1076691Stjones1@inf.ed.ac.uk