coherent_xbar.cc revision 2548
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 "base/trace.hh" 35#include "mem/bus.hh" 36#include "sim/builder.hh" 37 38/** Function called by the port when the bus is recieving a Timing 39 * transaction.*/ 40bool 41Bus::recvTiming(Packet &pkt, int id) 42{ 43 44 panic("I need to be implemented, but not right now."); 45} 46 47Port * 48Bus::findPort(Addr addr, int id) 49{ 50 /* An interval tree would be a better way to do this. --ali. */ 51 int dest_id = -1; 52 int i = 0; 53 bool found = false; 54 55 while (i < portList.size() && !found) 56 { 57 if (portList[i].range == addr) { 58 dest_id = portList[i].portId; 59 found = true; 60 } 61 i++; 62 } 63 if (dest_id == -1) 64 panic("Unable to find destination for addr: %llx", addr); 65 66 // we shouldn't be sending this back to where it came from 67 assert(dest_id != id); 68 69 return interfaces[dest_id]; 70} 71 72/** Function called by the port when the bus is recieving a Atomic 73 * transaction.*/ 74Tick 75Bus::recvAtomic(Packet &pkt, int id) 76{ 77 return findPort(pkt.addr, id)->sendAtomic(pkt); 78} 79 80/** Function called by the port when the bus is recieving a Functional 81 * transaction.*/ 82void 83Bus::recvFunctional(Packet &pkt, int id) 84{ 85 findPort(pkt.addr, id)->sendFunctional(pkt); 86} 87 88/** Function called by the port when the bus is recieving a status change.*/ 89void 90Bus::recvStatusChange(Port::Status status, int id) 91{ 92 assert(status == Port::RangeChange && 93 "The other statuses need to be implemented."); 94 95 assert(id < interfaces.size() && id >= 0); 96 Port *port = interfaces[id]; 97 AddrRangeList ranges; 98 AddrRangeList snoops; 99 100 port->getPeerAddressRanges(ranges, snoops); 101 102 // not dealing with snooping yet either 103 assert(snoops.size() == 0); 104 // or multiple ranges 105 assert(ranges.size() == 1); 106 107 DevMap dm; 108 dm.portId = id; 109 dm.range = ranges.front(); 110 111 DPRINTF(MMU, "Adding range %llx - %llx for id %d\n", dm.range.start, 112 dm.range.end, id); 113 portList.push_back(dm); 114 DPRINTF(MMU, "port list has %d entries\n", portList.size()); 115} 116 117void 118Bus::BusPort::addressRanges(AddrRangeList &resp, AddrRangeList &snoop) 119{ 120 panic("I'm not implemented.\n"); 121} 122 123BEGIN_DECLARE_SIM_OBJECT_PARAMS(Bus) 124 125 Param<int> bus_id; 126 127END_DECLARE_SIM_OBJECT_PARAMS(Bus) 128 129BEGIN_INIT_SIM_OBJECT_PARAMS(Bus) 130 INIT_PARAM(bus_id, "junk bus id") 131END_INIT_SIM_OBJECT_PARAMS(PhysicalMemory) 132 133CREATE_SIM_OBJECT(Bus) 134{ 135 return new Bus(getInstanceName()); 136} 137 138REGISTER_SIM_OBJECT("Bus", Bus) 139