xbar.cc revision 2497
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 Port *port = interfaces[id]; 91 AddrRangeList ranges; 92 bool owner; 93 94 port->getPeerAddressRanges(ranges, owner); 95 // not dealing with snooping yet either 96 assert(owner == true); 97 // or multiple ranges 98 assert(ranges.size() == 1); 99 DevMap dm; 100 dm.portId = id; 101 dm.range = ranges.front(); 102 103 portList.push_back(dm); 104} 105 106void 107Bus::BusPort::addressRanges(AddrRangeList &range_list, bool &owner) 108{ 109 panic("I'm not implemented.\n"); 110} 111 112BEGIN_DECLARE_SIM_OBJECT_PARAMS(Bus) 113 114 Param<int> bus_id; 115 116END_DECLARE_SIM_OBJECT_PARAMS(Bus) 117 118BEGIN_INIT_SIM_OBJECT_PARAMS(Bus) 119 INIT_PARAM(bus_id, "junk bus id") 120END_INIT_SIM_OBJECT_PARAMS(PhysicalMemory) 121 122CREATE_SIM_OBJECT(Bus) 123{ 124 return new Bus(getInstanceName()); 125} 126 127REGISTER_SIM_OBJECT("Bus", Bus) 128