noncoherent_xbar.hh revision 2381
12568SN/A/*
22568SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
32568SN/A * All rights reserved.
42568SN/A *
52568SN/A * Redistribution and use in source and binary forms, with or without
62568SN/A * modification, are permitted provided that the following conditions are
72568SN/A * met: redistributions of source code must retain the above copyright
82568SN/A * notice, this list of conditions and the following disclaimer;
92568SN/A * redistributions in binary form must reproduce the above copyright
102568SN/A * notice, this list of conditions and the following disclaimer in the
112568SN/A * documentation and/or other materials provided with the distribution;
122568SN/A * neither the name of the copyright holders nor the names of its
132568SN/A * contributors may be used to endorse or promote products derived from
142568SN/A * this software without specific prior written permission.
152568SN/A *
162568SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172568SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182568SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192568SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202568SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212568SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222568SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232568SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242568SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252568SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262568SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272568SN/A */
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.edu/**
302665Ssaidi@eecs.umich.edu * @file Decleration of a bus object.
312568SN/A */
322568SN/A
332568SN/A#ifndef __MEM_BUS_HH__
342982Sstever@eecs.umich.edu#define __MEM_BUS_HH__
352982Sstever@eecs.umich.edu
362568SN/A#include <string>
372568SN/A#include <list>
382643Sstever@eecs.umich.edu#include <inttypes.h>
392568SN/A
404965Ssaidi@eecs.umich.edu#include "base/range.hh"
412568SN/A#include "mem/mem_object.hh"
428232Snate@binkert.org#include "mem/packet.hh"
432568SN/A
444762Snate@binkert.orgclass Bus : public MemObject
452568SN/A{
462643Sstever@eecs.umich.edu    /** Function called by the port when the bus is recieving a Timing
472643Sstever@eecs.umich.edu        transaction.*/
484435Ssaidi@eecs.umich.edu    SendResult recvTiming(Packet &pkt, int id);
494965Ssaidi@eecs.umich.edu
504965Ssaidi@eecs.umich.edu    /** Function called by the port when the bus is recieving a Atomic
515606Snate@binkert.org        transaction.*/
524965Ssaidi@eecs.umich.edu    SendResult recvAtomic(Packet &pkt, int id);
534435Ssaidi@eecs.umich.edu
544435Ssaidi@eecs.umich.edu    /** Function called by the port when the bus is recieving a Functional
552643Sstever@eecs.umich.edu        transaction.*/
562643Sstever@eecs.umich.edu    SendResult recvFunctional(Packet &pkt, int id);
572643Sstever@eecs.umich.edu
584435Ssaidi@eecs.umich.edu    /** Function called by the port when the bus is recieving a status change.*/
595034Smilesck@eecs.umich.edu    void recvStatusChange(Port::Status status, int id);
604435Ssaidi@eecs.umich.edu
614965Ssaidi@eecs.umich.edu    /** Decleration of the buses port type, one will be instantiated for each
624435Ssaidi@eecs.umich.edu        of the interfaces connecting to the bus. */
634965Ssaidi@eecs.umich.edu    class BusPort : public Port
644435Ssaidi@eecs.umich.edu    {
652643Sstever@eecs.umich.edu        /** A pointer to the bus to which this port belongs. */
664432Ssaidi@eecs.umich.edu        Bus *bus;
674432Ssaidi@eecs.umich.edu
682643Sstever@eecs.umich.edu        /** A id to keep track of the intercafe ID this port is connected to. */
692643Sstever@eecs.umich.edu        int id;
702643Sstever@eecs.umich.edu
712738Sstever@eecs.umich.edu      public:
722643Sstever@eecs.umich.edu
732643Sstever@eecs.umich.edu        /** Constructor for the BusPort.*/
742643Sstever@eecs.umich.edu        BusPort(Bus *_bus, int _id)
752643Sstever@eecs.umich.edu            : bus(_bus), id(_id)
762643Sstever@eecs.umich.edu        { }
772643Sstever@eecs.umich.edu
782643Sstever@eecs.umich.edu      protected:
792643Sstever@eecs.umich.edu
802643Sstever@eecs.umich.edu        /** When reciving a timing request from the peer port (at id),
812643Sstever@eecs.umich.edu            pass it to the bus. */
825283Sgblack@eecs.umich.edu        virtual SendResult recvTiming(Packet &pkt)
835283Sgblack@eecs.umich.edu        { return bus->recvTiming(pkt, id); }
845283Sgblack@eecs.umich.edu
852643Sstever@eecs.umich.edu        /** When reciving a Atomic requestfrom the peer port (at id),
862643Sstever@eecs.umich.edu            pass it to the bus. */
872643Sstever@eecs.umich.edu        virtual SendResult recvAtomic(Packet &pkt)
882643Sstever@eecs.umich.edu        { return bus->recvAtomic(pkt, id); }
892568SN/A
902568SN/A        /** When reciving a Functional requestfrom the peer port (at id),
912568SN/A            pass it to the bus. */
922568SN/A        virtual SendResult recvFunctional(Packet &pkt)
935476Snate@binkert.org        { return bus->recvFunctional(pkt, id); }
944432Ssaidi@eecs.umich.edu
954432Ssaidi@eecs.umich.edu        /** When reciving a status changefrom the peer port (at id),
964432Ssaidi@eecs.umich.edu            pass it to the bus. */
976764SBrad.Beckmann@amd.com        virtual void recvStatusChange(Status status)
986764SBrad.Beckmann@amd.com        { bus->recvStatusChange(status, id); }
996764SBrad.Beckmann@amd.com
1002568SN/A        // This should return all the 'owned' addresses that are
1012568SN/A        // downstream from this bus, yes?  That is, the union of all
1024433Ssaidi@eecs.umich.edu        // the 'owned' address ranges of all the other interfaces on
1034435Ssaidi@eecs.umich.edu        // this bus...
1044433Ssaidi@eecs.umich.edu        virtual void addressRanges(std::list<Range<Addr> > &range_list,
1054435Ssaidi@eecs.umich.edu                                   bool &owner);
1064435Ssaidi@eecs.umich.edu    };
1074435Ssaidi@eecs.umich.edu
1084435Ssaidi@eecs.umich.edu    /** A count of the number of interfaces connected to this bus. */
1094435Ssaidi@eecs.umich.edu    int num_interfaces;
1104435Ssaidi@eecs.umich.edu
1114435Ssaidi@eecs.umich.edu    /** An array of pointers to the peer port interfaces
1124435Ssaidi@eecs.umich.edu        connected to this bus.*/
1134435Ssaidi@eecs.umich.edu    Port *interfaces[];
1144433Ssaidi@eecs.umich.edu
1152568SN/A  public:
1162643Sstever@eecs.umich.edu
1172568SN/A    /** A function used to return the port associated with this bus object. */
1182568SN/A    virtual Port *getPort(const char *if_name)
1193349Sbinkertn@umich.edu    {
1202568SN/A        // if_name ignored?  forced to be empty?
1214433Ssaidi@eecs.umich.edu        int id = num_interfaces++;
1223662Srdreslin@umich.edu        interfaces[id] = new BusPort(this, id);
1232643Sstever@eecs.umich.edu        return interfaces[id];
1244450Ssaidi@eecs.umich.edu    }
1254450Ssaidi@eecs.umich.edu};
1264986Ssaidi@eecs.umich.edu
1274450Ssaidi@eecs.umich.edu#endif //__MEM_BUS_HH__
1284450Ssaidi@eecs.umich.edu