coherent_xbar.cc revision 2497
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" 352207SN/A#include "sim/builder.hh" 363760Sgblack@eecs.umich.edu 372454SN/A/** Function called by the port when the bus is recieving a Timing 382976Sgblack@eecs.umich.edu * transaction.*/ 392454SN/Abool 402680Sktlim@umich.eduBus::recvTiming(Packet &pkt, int id) 412561SN/A{ 424434Ssaidi@eecs.umich.edu 432561SN/A panic("I need to be implemented, but not right now."); 442474SN/A} 452207SN/A 462458SN/APort * 472474SN/ABus::findPort(Addr addr, int id) 482458SN/A{ 492207SN/A /* An interval tree would be a better way to do this. --ali. */ 502474SN/A int dest_id = -1; 512474SN/A int i = 0; 523114Sgblack@eecs.umich.edu bool found = false; 533669Sbinkertn@umich.edu 543114Sgblack@eecs.umich.edu while (i < portList.size() && !found) 553114Sgblack@eecs.umich.edu { 562474SN/A if (portList[i].range == addr) { 573669Sbinkertn@umich.edu 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); 642474SN/A 652474SN/A return interfaces[dest_id]; 663415Sgblack@eecs.umich.edu} 673415Sgblack@eecs.umich.edu 683415Sgblack@eecs.umich.edu/** Function called by the port when the bus is recieving a Atomic 693415Sgblack@eecs.umich.edu * transaction.*/ 702474SN/ATick 712474SN/ABus::recvAtomic(Packet &pkt, int id) 724111Sgblack@eecs.umich.edu{ 734111Sgblack@eecs.umich.edu return findPort(pkt.addr, id)->sendAtomic(pkt); 744111Sgblack@eecs.umich.edu} 754111Sgblack@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{ 815128Sgblack@eecs.umich.edu findPort(pkt.addr, id)->sendFunctional(pkt); 825128Sgblack@eecs.umich.edu} 834111Sgblack@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 Port *port = interfaces[id]; 915128Sgblack@eecs.umich.edu AddrRangeList ranges; 925128Sgblack@eecs.umich.edu bool owner; 935128Sgblack@eecs.umich.edu 945128Sgblack@eecs.umich.edu port->getPeerAddressRanges(ranges, owner); 955128Sgblack@eecs.umich.edu // not dealing with snooping yet either 965128Sgblack@eecs.umich.edu assert(owner == true); 975128Sgblack@eecs.umich.edu // or multiple ranges 985128Sgblack@eecs.umich.edu assert(ranges.size() == 1); 995128Sgblack@eecs.umich.edu DevMap dm; 1005128Sgblack@eecs.umich.edu dm.portId = id; 1015128Sgblack@eecs.umich.edu dm.range = ranges.front(); 1025128Sgblack@eecs.umich.edu 1035128Sgblack@eecs.umich.edu portList.push_back(dm); 1045128Sgblack@eecs.umich.edu} 1055128Sgblack@eecs.umich.edu 1065128Sgblack@eecs.umich.eduvoid 1075128Sgblack@eecs.umich.eduBus::BusPort::addressRanges(AddrRangeList &range_list, bool &owner) 1085128Sgblack@eecs.umich.edu{ 1094111Sgblack@eecs.umich.edu panic("I'm not implemented.\n"); 1104111Sgblack@eecs.umich.edu} 1114111Sgblack@eecs.umich.edu 1124111Sgblack@eecs.umich.eduBEGIN_DECLARE_SIM_OBJECT_PARAMS(Bus) 1134111Sgblack@eecs.umich.edu 1144111Sgblack@eecs.umich.edu Param<int> bus_id; 1152474SN/A 1164111Sgblack@eecs.umich.eduEND_DECLARE_SIM_OBJECT_PARAMS(Bus) 1174111Sgblack@eecs.umich.edu 1184111Sgblack@eecs.umich.eduBEGIN_INIT_SIM_OBJECT_PARAMS(Bus) 1194111Sgblack@eecs.umich.edu INIT_PARAM(bus_id, "junk bus id") 1204111Sgblack@eecs.umich.eduEND_INIT_SIM_OBJECT_PARAMS(PhysicalMemory) 1214111Sgblack@eecs.umich.edu 1224648Sgblack@eecs.umich.eduCREATE_SIM_OBJECT(Bus) 1234648Sgblack@eecs.umich.edu{ 1244111Sgblack@eecs.umich.edu return new Bus(getInstanceName()); 1254111Sgblack@eecs.umich.edu} 1264172Ssaidi@eecs.umich.edu 1274111Sgblack@eecs.umich.eduREGISTER_SIM_OBJECT("Bus", Bus) 1284172Ssaidi@eecs.umich.edu