xbar.hh revision 2568
17735SN/A/* 27735SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 37735SN/A * All rights reserved. 48835SAli.Saidi@ARM.com * 57935SN/A * Redistribution and use in source and binary forms, with or without 67935SN/A * modification, are permitted provided that the following conditions are 77935SN/A * met: redistributions of source code must retain the above copyright 87735SN/A * notice, this list of conditions and the following disclaimer; 97735SN/A * redistributions in binary form must reproduce the above copyright 107735SN/A * notice, this list of conditions and the following disclaimer in the 118891SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution; 128891SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its 139265SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from 148528SN/A * this software without specific prior written permission. 159265SAli.Saidi@ARM.com * 169265SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179055Ssaidi@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 188528SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 198528SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 207735SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219265SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 227735SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 237735SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 247735SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259134Ssaidi@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 268528SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279079SAli.Saidi@ARM.com */ 288721SN/A 297735SN/A/** 307735SN/A * @file Decleration of a bus object. 317935SN/A */ 327935SN/A 337935SN/A#ifndef __MEM_BUS_HH__ 347935SN/A#define __MEM_BUS_HH__ 357935SN/A 367935SN/A#include <string> 377935SN/A#include <list> 388891SAli.Saidi@ARM.com#include <inttypes.h> 397735SN/A 407735SN/A#include "base/range.hh" 417735SN/A#include "mem/mem_object.hh" 429265SAli.Saidi@ARM.com#include "mem/packet.hh" 437735SN/A#include "mem/port.hh" 448891SAli.Saidi@ARM.com#include "mem/request.hh" 458721SN/A 468721SN/Aclass Bus : public MemObject 478891SAli.Saidi@ARM.com{ 488891SAli.Saidi@ARM.com /** a globally unique id for this bus. */ 497735SN/A int busId; 508528SN/A 518528SN/A struct DevMap { 528528SN/A int portId; 538528SN/A Range<Addr> range; 548528SN/A }; 558528SN/A std::vector<DevMap> portList; 568528SN/A 578528SN/A 588528SN/A /** Function called by the port when the bus is recieving a Timing 598528SN/A transaction.*/ 608528SN/A bool recvTiming(Packet &pkt, int id); 618528SN/A 628528SN/A /** Function called by the port when the bus is recieving a Atomic 638528SN/A transaction.*/ 648528SN/A Tick recvAtomic(Packet &pkt, int id); 658528SN/A 668528SN/A /** Function called by the port when the bus is recieving a Functional 679265SAli.Saidi@ARM.com transaction.*/ 688528SN/A void recvFunctional(Packet &pkt, int id); 698528SN/A 707735SN/A /** Function called by the port when the bus is recieving a status change.*/ 717735SN/A void recvStatusChange(Port::Status status, int id); 727735SN/A 737735SN/A /** Find which port connected to this bus (if any) should be given a packet 747735SN/A * with this address. 757735SN/A * @param addr Address to find port for. 767735SN/A * @param id Id of the port this packet was received from (to prevent 777735SN/A * loops) 787735SN/A * @return pointer to port that the packet should be sent out of. 797735SN/A */ 807735SN/A Port * 817735SN/A Bus::findPort(Addr addr, int id); 827735SN/A 837735SN/A /** Process address range request. 847735SN/A * @param resp addresses that we can respond to 857735SN/A * @param snoop addresses that we would like to snoop 867735SN/A * @param id ide of the busport that made the request. 877735SN/A */ 887735SN/A void addressRanges(AddrRangeList &resp, AddrRangeList &snoop, int id); 897735SN/A 907735SN/A 917735SN/A /** Decleration of the buses port type, one will be instantiated for each 927735SN/A of the interfaces connecting to the bus. */ 937735SN/A class BusPort : public Port 948835SAli.Saidi@ARM.com { 957735SN/A /** A pointer to the bus to which this port belongs. */ 967735SN/A Bus *bus; 977735SN/A 987735SN/A /** A id to keep track of the intercafe ID this port is connected to. */ 997735SN/A int id; 1008891SAli.Saidi@ARM.com 1017735SN/A public: 1027735SN/A 1039265SAli.Saidi@ARM.com /** Constructor for the BusPort.*/ 1047735SN/A BusPort(Bus *_bus, int _id) 1057735SN/A : bus(_bus), id(_id) 1069265SAli.Saidi@ARM.com { } 1078150SN/A 1087735SN/A protected: 1097735SN/A 1107735SN/A /** When reciving a timing request from the peer port (at id), 1118835SAli.Saidi@ARM.com pass it to the bus. */ 1127735SN/A virtual bool recvTiming(Packet &pkt) 1137735SN/A { return bus->recvTiming(pkt, id); } 1149265SAli.Saidi@ARM.com 1157735SN/A /** When reciving a Atomic requestfrom the peer port (at id), 1167735SN/A pass it to the bus. */ 1178835SAli.Saidi@ARM.com virtual Tick recvAtomic(Packet &pkt) 1187735SN/A { return bus->recvAtomic(pkt, id); } 1197735SN/A 1207735SN/A /** When reciving a Functional requestfrom the peer port (at id), 1217735SN/A pass it to the bus. */ 1227735SN/A virtual void recvFunctional(Packet &pkt) 1238891SAli.Saidi@ARM.com { bus->recvFunctional(pkt, id); } 1247735SN/A 1257735SN/A /** When reciving a status changefrom the peer port (at id), 1267735SN/A pass it to the bus. */ 1277735SN/A virtual void recvStatusChange(Status status) 1287735SN/A { bus->recvStatusChange(status, id); } 1297735SN/A 1307735SN/A // This should return all the 'owned' addresses that are 1317735SN/A // downstream from this bus, yes? That is, the union of all 1327735SN/A // the 'owned' address ranges of all the other interfaces on 1339265SAli.Saidi@ARM.com // this bus... 1349265SAli.Saidi@ARM.com virtual void getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop) 1357735SN/A { bus->addressRanges(resp, snoop, id); } 1368891SAli.Saidi@ARM.com 1377735SN/A // Hack to make translating port work without changes 1387735SN/A virtual int deviceBlockSize() { return 32; } 1397735SN/A 1408891SAli.Saidi@ARM.com }; 1417735SN/A 1427735SN/A /** An array of pointers to the peer port interfaces 1439265SAli.Saidi@ARM.com connected to this bus.*/ 1447735SN/A std::vector<Port*> interfaces; 1457735SN/A 1469265SAli.Saidi@ARM.com public: 1478150SN/A 1487735SN/A /** A function used to return the port associated with this bus object. */ 1497735SN/A virtual Port *getPort(const std::string &if_name) 1507735SN/A { 1518835SAli.Saidi@ARM.com // if_name ignored? forced to be empty? 1527735SN/A int id = interfaces.size(); 1537735SN/A interfaces.push_back(new BusPort(this, id)); 1549265SAli.Saidi@ARM.com return interfaces.back(); 1557735SN/A } 1567735SN/A 1578835SAli.Saidi@ARM.com virtual void init(); 1587735SN/A 1597735SN/A Bus(const std::string &n, int bus_id) 1607735SN/A : MemObject(n), busId(bus_id) {} 1617735SN/A 1627735SN/A}; 1638891SAli.Saidi@ARM.com 1647735SN/A#endif //__MEM_BUS_HH__ 1657735SN/A