xbar.cc revision 2534
12207SN/A/* 22207SN/A * Copyright (c) 2006 The Regents of The University of Michigan 32207SN/A * All rights reserved. 42207SN/A * 52207SN/A * Redistribution and use in source and binary forms, with or without 62207SN/A * modification, are permitted provided that the following conditions are 72207SN/A * met: redistributions of source code must retain the above copyright 82207SN/A * notice, this list of conditions and the following disclaimer; 92207SN/A * redistributions in binary form must reproduce the above copyright 102207SN/A * notice, this list of conditions and the following disclaimer in the 112207SN/A * documentation and/or other materials provided with the distribution; 122207SN/A * neither the name of the copyright holders nor the names of its 132207SN/A * contributors may be used to endorse or promote products derived from 142207SN/A * this software without specific prior written permission. 152207SN/A * 162207SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172207SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182207SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192207SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202207SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212207SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222207SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232207SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242207SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252207SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262207SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu */ 282665Ssaidi@eecs.umich.edu 292665Ssaidi@eecs.umich.edu/** 302207SN/A * @file Definition of a bus object. 312207SN/A */ 323589Sgblack@eecs.umich.edu 334111Sgblack@eecs.umich.edu 342474SN/A#include "bus.hh" 356335Sgblack@eecs.umich.edu#include "sim/builder.hh" 362207SN/A 373760Sgblack@eecs.umich.edu/** Function called by the port when the bus is recieving a Timing 382454SN/A * transaction.*/ 392976Sgblack@eecs.umich.edubool 402454SN/ABus::recvTiming(Packet &pkt, int id) 412680Sktlim@umich.edu{ 422561SN/A 434434Ssaidi@eecs.umich.edu panic("I need to be implemented, but not right now."); 442561SN/A} 452474SN/A 462207SN/APort * 472458SN/ABus::findPort(Addr addr, int id) 482474SN/A{ 492458SN/A /* An interval tree would be a better way to do this. --ali. */ 505958Sgblack@eecs.umich.edu int dest_id = -1; 515958Sgblack@eecs.umich.edu int i = 0; 522207SN/A bool found = false; 535154Sgblack@eecs.umich.edu 545285Sgblack@eecs.umich.edu while (i < portList.size() && !found) 555285Sgblack@eecs.umich.edu { 562474SN/A if (portList[i].range == addr) { 572474SN/A dest_id = portList[i].portId; 582474SN/A found = true; 592474SN/A } 602474SN/A } 612474SN/A assert(dest_id != -1 && "Unable to find destination"); 622474SN/A // we shouldn't be sending this back to where it came from 632474SN/A assert(dest_id != id); 643415Sgblack@eecs.umich.edu 653415Sgblack@eecs.umich.edu return interfaces[dest_id]; 663415Sgblack@eecs.umich.edu} 673415Sgblack@eecs.umich.edu 682474SN/A/** Function called by the port when the bus is recieving a Atomic 692474SN/A * transaction.*/ 704111Sgblack@eecs.umich.eduTick 714111Sgblack@eecs.umich.eduBus::recvAtomic(Packet &pkt, int id) 724111Sgblack@eecs.umich.edu{ 734111Sgblack@eecs.umich.edu return findPort(pkt.addr, id)->sendAtomic(pkt); 745128Sgblack@eecs.umich.edu} 755128Sgblack@eecs.umich.edu 765128Sgblack@eecs.umich.edu/** Function called by the port when the bus is recieving a Functional 775128Sgblack@eecs.umich.edu * transaction.*/ 785128Sgblack@eecs.umich.eduvoid 795128Sgblack@eecs.umich.eduBus::recvFunctional(Packet &pkt, int id) 805128Sgblack@eecs.umich.edu{ 814111Sgblack@eecs.umich.edu findPort(pkt.addr, id)->sendFunctional(pkt); 825128Sgblack@eecs.umich.edu} 835128Sgblack@eecs.umich.edu 845128Sgblack@eecs.umich.edu/** Function called by the port when the bus is recieving a status change.*/ 855128Sgblack@eecs.umich.eduvoid 865128Sgblack@eecs.umich.eduBus::recvStatusChange(Port::Status status, int id) 875128Sgblack@eecs.umich.edu{ 885128Sgblack@eecs.umich.edu assert(status == Port::RangeChange && 895128Sgblack@eecs.umich.edu "The other statuses need to be implemented."); 905128Sgblack@eecs.umich.edu 915128Sgblack@eecs.umich.edu assert(id < interfaces.size() && id >= 0); 925128Sgblack@eecs.umich.edu Port *port = interfaces[id]; 935128Sgblack@eecs.umich.edu AddrRangeList ranges; 945128Sgblack@eecs.umich.edu AddrRangeList snoops; 955128Sgblack@eecs.umich.edu 965128Sgblack@eecs.umich.edu port->getPeerAddressRanges(ranges, snoops); 975128Sgblack@eecs.umich.edu 985128Sgblack@eecs.umich.edu // not dealing with snooping yet either 995128Sgblack@eecs.umich.edu assert(snoops.size() == 0); 1005128Sgblack@eecs.umich.edu // or multiple ranges 1015128Sgblack@eecs.umich.edu assert(ranges.size() == 1); 1025128Sgblack@eecs.umich.edu DevMap dm; 1035128Sgblack@eecs.umich.edu dm.portId = id; 1045128Sgblack@eecs.umich.edu dm.range = ranges.front(); 1055128Sgblack@eecs.umich.edu 1065128Sgblack@eecs.umich.edu portList.push_back(dm); 1074111Sgblack@eecs.umich.edu} 1084111Sgblack@eecs.umich.edu 1094111Sgblack@eecs.umich.eduvoid 1104111Sgblack@eecs.umich.eduBus::BusPort::addressRanges(AddrRangeList &resp, AddrRangeList &snoop) 1114111Sgblack@eecs.umich.edu{ 1124111Sgblack@eecs.umich.edu panic("I'm not implemented.\n"); 1132474SN/A} 1145285Sgblack@eecs.umich.edu 1154111Sgblack@eecs.umich.eduBEGIN_DECLARE_SIM_OBJECT_PARAMS(Bus) 1165285Sgblack@eecs.umich.edu 1174111Sgblack@eecs.umich.edu Param<int> bus_id; 1185713Shsul@eecs.umich.edu 1194111Sgblack@eecs.umich.eduEND_DECLARE_SIM_OBJECT_PARAMS(Bus) 1204111Sgblack@eecs.umich.edu 1212646Ssaidi@eecs.umich.eduBEGIN_INIT_SIM_OBJECT_PARAMS(Bus) 1225713Shsul@eecs.umich.edu INIT_PARAM(bus_id, "junk bus id") 1232646Ssaidi@eecs.umich.eduEND_INIT_SIM_OBJECT_PARAMS(PhysicalMemory) 1245713Shsul@eecs.umich.edu 1254997Sgblack@eecs.umich.eduCREATE_SIM_OBJECT(Bus) 1262561SN/A{ 1272561SN/A return new Bus(getInstanceName()); 1282561SN/A} 1292561SN/A 1302561SN/AREGISTER_SIM_OBJECT("Bus", Bus) 1315713Shsul@eecs.umich.edu