- DPRINTF(Bus, "recvAtomic: packet src %d dest %d addr 0x%x cmd %s\n",
- pkt->getSrc(), pkt->getDest(), pkt->getAddr(), pkt->cmdString());
- assert(pkt->getDest() == Packet::Broadcast);
- assert(pkt->isRequest());
-
- // Variables for recording original command and snoop response (if
- // any)... if a snooper respondes, we will need to restore
- // original command so that additional snoops can take place
- // properly
- MemCmd orig_cmd = pkt->cmd;
- MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
- Tick snoop_response_latency = 0;
- int orig_src = pkt->getSrc();
-
- int target_port_id = findPort(pkt->getAddr());
- Port *target_port = interfaces[target_port_id];
-
- SnoopIter s_end = snoopPorts.end();
- for (SnoopIter s_iter = snoopPorts.begin(); s_iter != s_end; s_iter++) {
- BusPort *p = *s_iter;
- // same port should not have both target addresses and snooping
- assert(p != target_port);
- if (p->getId() != pkt->getSrc()) {
- Tick latency = p->sendAtomic(pkt);
- if (pkt->isResponse()) {
- // response from snoop agent
- assert(pkt->cmd != orig_cmd);
- assert(pkt->memInhibitAsserted());
- // should only happen once
- assert(snoop_response_cmd == MemCmd::InvalidCmd);
- // save response state
- snoop_response_cmd = pkt->cmd;
- snoop_response_latency = latency;
- // restore original packet state for remaining snoopers
- pkt->cmd = orig_cmd;
- pkt->setSrc(orig_src);
- pkt->setDest(Packet::Broadcast);
- }
- }
- }
-
- Tick response_latency = 0;
-
- // we can get requests sent up from the memory side of the bus for
- // snooping... don't send them back down!
- if (target_port_id != pkt->getSrc()) {
- response_latency = target_port->sendAtomic(pkt);
+ // we should never see any address lookups before we've got the
+ // ranges of all connected slave modules
+ assert(gotAllAddrRanges);
+
+ // Check the cache
+ PortID dest_id = checkPortCache(addr);
+ if (dest_id != InvalidPortID)
+ return dest_id;
+
+ // Check the address map interval tree
+ PortMapConstIter i = portMap.find(addr);
+ if (i != portMap.end()) {
+ dest_id = i->second;
+ updatePortCache(dest_id, i->first);
+ return dest_id;