bridge.cc (8713:2f1a3e335255) | bridge.cc (8851:7e966326ef5b) |
---|---|
1/* 2 * Copyright (c) 2011 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 41 unchanged lines hidden (view full) --- 50 51#include "base/trace.hh" 52#include "debug/BusBridge.hh" 53#include "mem/bridge.hh" 54#include "params/Bridge.hh" 55 56Bridge::BridgeSlavePort::BridgeSlavePort(const std::string &_name, 57 Bridge* _bridge, | 1/* 2 * Copyright (c) 2011 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 41 unchanged lines hidden (view full) --- 50 51#include "base/trace.hh" 52#include "debug/BusBridge.hh" 53#include "mem/bridge.hh" 54#include "params/Bridge.hh" 55 56Bridge::BridgeSlavePort::BridgeSlavePort(const std::string &_name, 57 Bridge* _bridge, |
58 BridgeMasterPort* _masterPort, | 58 BridgeMasterPort& _masterPort, |
59 int _delay, int _nack_delay, 60 int _resp_limit, 61 std::vector<Range<Addr> > _ranges) 62 : Port(_name, _bridge), bridge(_bridge), masterPort(_masterPort), 63 delay(_delay), nackDelay(_nack_delay), 64 ranges(_ranges.begin(), _ranges.end()), 65 outstandingResponses(0), inRetry(false), | 59 int _delay, int _nack_delay, 60 int _resp_limit, 61 std::vector<Range<Addr> > _ranges) 62 : Port(_name, _bridge), bridge(_bridge), masterPort(_masterPort), 63 delay(_delay), nackDelay(_nack_delay), 64 ranges(_ranges.begin(), _ranges.end()), 65 outstandingResponses(0), inRetry(false), |
66 respQueueLimit(_resp_limit), sendEvent(this) | 66 respQueueLimit(_resp_limit), sendEvent(*this) |
67{ 68} 69 70Bridge::BridgeMasterPort::BridgeMasterPort(const std::string &_name, 71 Bridge* _bridge, | 67{ 68} 69 70Bridge::BridgeMasterPort::BridgeMasterPort(const std::string &_name, 71 Bridge* _bridge, |
72 BridgeSlavePort* _slavePort, | 72 BridgeSlavePort& _slavePort, |
73 int _delay, int _req_limit) 74 : Port(_name, _bridge), bridge(_bridge), slavePort(_slavePort), | 73 int _delay, int _req_limit) 74 : Port(_name, _bridge), bridge(_bridge), slavePort(_slavePort), |
75 delay(_delay), inRetry(false), reqQueueLimit(_req_limit), sendEvent(this) | 75 delay(_delay), inRetry(false), reqQueueLimit(_req_limit), 76 sendEvent(*this) |
76{ 77} 78 79Bridge::Bridge(Params *p) 80 : MemObject(p), | 77{ 78} 79 80Bridge::Bridge(Params *p) 81 : MemObject(p), |
81 slavePort(p->name + "-slave", this, &masterPort, p->delay, | 82 slavePort(p->name + "-slave", this, masterPort, p->delay, |
82 p->nack_delay, p->resp_size, p->ranges), | 83 p->nack_delay, p->resp_size, p->ranges), |
83 masterPort(p->name + "-master", this, &slavePort, p->delay, p->req_size), | 84 masterPort(p->name + "-master", this, slavePort, p->delay, p->req_size), |
84 ackWrites(p->write_ack), _params(p) 85{ 86 if (ackWrites) 87 panic("No support for acknowledging writes\n"); 88} 89 90Port* 91Bridge::getPort(const std::string &if_name, int idx) 92{ | 85 ackWrites(p->write_ack), _params(p) 86{ 87 if (ackWrites) 88 panic("No support for acknowledging writes\n"); 89} 90 91Port* 92Bridge::getPort(const std::string &if_name, int idx) 93{ |
93 Port* port; 94 | |
95 if (if_name == "slave") | 94 if (if_name == "slave") |
96 port = &slavePort; | 95 return &slavePort; |
97 else if (if_name == "master") | 96 else if (if_name == "master") |
98 port = &masterPort; 99 else | 97 return &masterPort; 98 else { 99 panic("Bridge %s has no port named %s\n", name(), if_name); |
100 return NULL; | 100 return NULL; |
101 102 if (port->getPeer() != NULL) 103 panic("bridge side %s already connected to %s.", 104 if_name, port->getPeer()->name()); 105 return port; | 101 } |
106} 107 108 109void 110Bridge::init() 111{ 112 // make sure both sides are connected and have the same block size 113 if (!slavePort.isConnected() || !masterPort.isConnected()) --- 29 unchanged lines hidden (view full) --- 143 // all checks are done when the request is accepted on the slave 144 // side, so we are guaranteed to have space for the response 145 146 DPRINTF(BusBridge, "recvTiming: src %d dest %d addr 0x%x\n", 147 pkt->getSrc(), pkt->getDest(), pkt->getAddr()); 148 149 DPRINTF(BusBridge, "Request queue size: %d\n", requestQueue.size()); 150 | 102} 103 104 105void 106Bridge::init() 107{ 108 // make sure both sides are connected and have the same block size 109 if (!slavePort.isConnected() || !masterPort.isConnected()) --- 29 unchanged lines hidden (view full) --- 139 // all checks are done when the request is accepted on the slave 140 // side, so we are guaranteed to have space for the response 141 142 DPRINTF(BusBridge, "recvTiming: src %d dest %d addr 0x%x\n", 143 pkt->getSrc(), pkt->getDest(), pkt->getAddr()); 144 145 DPRINTF(BusBridge, "Request queue size: %d\n", requestQueue.size()); 146 |
151 slavePort->queueForSendTiming(pkt); | 147 slavePort.queueForSendTiming(pkt); |
152 153 return true; 154} 155 156bool 157Bridge::BridgeSlavePort::recvTiming(PacketPtr pkt) 158{ 159 // should only see requests on the slave side 160 assert(pkt->isRequest()); 161 162 DPRINTF(BusBridge, "recvTiming: src %d dest %d addr 0x%x\n", 163 pkt->getSrc(), pkt->getDest(), pkt->getAddr()); 164 165 DPRINTF(BusBridge, "Response queue size: %d outresp: %d\n", 166 responseQueue.size(), outstandingResponses); 167 | 148 149 return true; 150} 151 152bool 153Bridge::BridgeSlavePort::recvTiming(PacketPtr pkt) 154{ 155 // should only see requests on the slave side 156 assert(pkt->isRequest()); 157 158 DPRINTF(BusBridge, "recvTiming: src %d dest %d addr 0x%x\n", 159 pkt->getSrc(), pkt->getDest(), pkt->getAddr()); 160 161 DPRINTF(BusBridge, "Response queue size: %d outresp: %d\n", 162 responseQueue.size(), outstandingResponses); 163 |
168 if (masterPort->reqQueueFull()) { | 164 if (masterPort.reqQueueFull()) { |
169 DPRINTF(BusBridge, "Request queue full, nacking\n"); 170 nackRequest(pkt); 171 return true; 172 } 173 174 if (pkt->needsResponse()) { 175 if (respQueueFull()) { 176 DPRINTF(BusBridge, --- 5 unchanged lines hidden (view full) --- 182 return true; 183 } else { 184 DPRINTF(BusBridge, "Request Needs response, reserving space\n"); 185 assert(outstandingResponses != respQueueLimit); 186 ++outstandingResponses; 187 } 188 } 189 | 165 DPRINTF(BusBridge, "Request queue full, nacking\n"); 166 nackRequest(pkt); 167 return true; 168 } 169 170 if (pkt->needsResponse()) { 171 if (respQueueFull()) { 172 DPRINTF(BusBridge, --- 5 unchanged lines hidden (view full) --- 178 return true; 179 } else { 180 DPRINTF(BusBridge, "Request Needs response, reserving space\n"); 181 assert(outstandingResponses != respQueueLimit); 182 ++outstandingResponses; 183 } 184 } 185 |
190 masterPort->queueForSendTiming(pkt); | 186 masterPort.queueForSendTiming(pkt); |
191 192 return true; 193} 194 195void 196Bridge::BridgeSlavePort::nackRequest(PacketPtr pkt) 197{ 198 // Nack the packet --- 218 unchanged lines hidden (view full) --- 417 // 418 //panic("Master port on %s got a recvAtomic\n", bridge->name()); 419 return 0; 420} 421 422Tick 423Bridge::BridgeSlavePort::recvAtomic(PacketPtr pkt) 424{ | 187 188 return true; 189} 190 191void 192Bridge::BridgeSlavePort::nackRequest(PacketPtr pkt) 193{ 194 // Nack the packet --- 218 unchanged lines hidden (view full) --- 413 // 414 //panic("Master port on %s got a recvAtomic\n", bridge->name()); 415 return 0; 416} 417 418Tick 419Bridge::BridgeSlavePort::recvAtomic(PacketPtr pkt) 420{ |
425 return delay + masterPort->sendAtomic(pkt); | 421 return delay + masterPort.sendAtomic(pkt); |
426} 427 428void 429Bridge::BridgeMasterPort::recvFunctional(PacketPtr pkt) 430{ 431 // master port should never receive any functional access (panic 432 // only works once the other side, i.e. the busses, respect this) 433 --- 11 unchanged lines hidden (view full) --- 445 for (i = responseQueue.begin(); i != responseQueue.end(); ++i) { 446 if (pkt->checkFunctional((*i)->pkt)) { 447 pkt->makeResponse(); 448 return; 449 } 450 } 451 452 // also check the master port's request queue | 422} 423 424void 425Bridge::BridgeMasterPort::recvFunctional(PacketPtr pkt) 426{ 427 // master port should never receive any functional access (panic 428 // only works once the other side, i.e. the busses, respect this) 429 --- 11 unchanged lines hidden (view full) --- 441 for (i = responseQueue.begin(); i != responseQueue.end(); ++i) { 442 if (pkt->checkFunctional((*i)->pkt)) { 443 pkt->makeResponse(); 444 return; 445 } 446 } 447 448 // also check the master port's request queue |
453 if (masterPort->checkFunctional(pkt)) { | 449 if (masterPort.checkFunctional(pkt)) { |
454 return; 455 } 456 457 pkt->popLabel(); 458 459 // fall through if pkt still not satisfied | 450 return; 451 } 452 453 pkt->popLabel(); 454 455 // fall through if pkt still not satisfied |
460 masterPort->sendFunctional(pkt); | 456 masterPort.sendFunctional(pkt); |
461} 462 463bool 464Bridge::BridgeMasterPort::checkFunctional(PacketPtr pkt) 465{ 466 bool found = false; 467 std::list<PacketBuffer*>::iterator i = requestQueue.begin(); 468 --- 35 unchanged lines hidden --- | 457} 458 459bool 460Bridge::BridgeMasterPort::checkFunctional(PacketPtr pkt) 461{ 462 bool found = false; 463 std::list<PacketBuffer*>::iterator i = requestQueue.begin(); 464 --- 35 unchanged lines hidden --- |