xbar.cc revision 2534
1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/** 30 * @file Definition of a bus object. 31 */ 32 33 34#include "bus.hh" 35#include "sim/builder.hh" 36 37/** Function called by the port when the bus is recieving a Timing 38 * transaction.*/ 39bool 40Bus::recvTiming(Packet &pkt, int id) 41{ 42 43 panic("I need to be implemented, but not right now."); 44} 45 46Port * 47Bus::findPort(Addr addr, int id) 48{ 49 /* An interval tree would be a better way to do this. --ali. */ 50 int dest_id = -1; 51 int i = 0; 52 bool found = false; 53 54 while (i < portList.size() && !found) 55 { 56 if (portList[i].range == addr) { 57 dest_id = portList[i].portId; 58 found = true; 59 } 60 } 61 assert(dest_id != -1 && "Unable to find destination"); 62 // we shouldn't be sending this back to where it came from 63 assert(dest_id != id); 64 65 return interfaces[dest_id]; 66} 67 68/** Function called by the port when the bus is recieving a Atomic 69 * transaction.*/ 70Tick 71Bus::recvAtomic(Packet &pkt, int id) 72{ 73 return findPort(pkt.addr, id)->sendAtomic(pkt); 74} 75 76/** Function called by the port when the bus is recieving a Functional 77 * transaction.*/ 78void 79Bus::recvFunctional(Packet &pkt, int id) 80{ 81 findPort(pkt.addr, id)->sendFunctional(pkt); 82} 83 84/** Function called by the port when the bus is recieving a status change.*/ 85void 86Bus::recvStatusChange(Port::Status status, int id) 87{ 88 assert(status == Port::RangeChange && 89 "The other statuses need to be implemented."); 90 91 assert(id < interfaces.size() && id >= 0); 92 Port *port = interfaces[id]; 93 AddrRangeList ranges; 94 AddrRangeList snoops; 95 96 port->getPeerAddressRanges(ranges, snoops); 97 98 // not dealing with snooping yet either 99 assert(snoops.size() == 0); 100 // or multiple ranges 101 assert(ranges.size() == 1); 102 DevMap dm; 103 dm.portId = id; 104 dm.range = ranges.front(); 105 106 portList.push_back(dm); 107} 108 109void 110Bus::BusPort::addressRanges(AddrRangeList &resp, AddrRangeList &snoop) 111{ 112 panic("I'm not implemented.\n"); 113} 114 115BEGIN_DECLARE_SIM_OBJECT_PARAMS(Bus) 116 117 Param<int> bus_id; 118 119END_DECLARE_SIM_OBJECT_PARAMS(Bus) 120 121BEGIN_INIT_SIM_OBJECT_PARAMS(Bus) 122 INIT_PARAM(bus_id, "junk bus id") 123END_INIT_SIM_OBJECT_PARAMS(PhysicalMemory) 124 125CREATE_SIM_OBJECT(Bus) 126{ 127 return new Bus(getInstanceName()); 128} 129 130REGISTER_SIM_OBJECT("Bus", Bus) 131