Use my range_map to speed up findPort() in the bus. The snoop code could still use some work.
--HG-- extra : convert_revision : ba0a68bd378d68e4ebd80a101b965d36c8be1db9
This commit is contained in:
parent
5e70511bff
commit
4943d58272
2 changed files with 33 additions and 40 deletions
|
@ -260,19 +260,12 @@ Bus::findPort(Addr addr, int id)
|
||||||
{
|
{
|
||||||
/* An interval tree would be a better way to do this. --ali. */
|
/* An interval tree would be a better way to do this. --ali. */
|
||||||
int dest_id = -1;
|
int dest_id = -1;
|
||||||
int i = 0;
|
|
||||||
bool found = false;
|
|
||||||
AddrRangeIter iter;
|
AddrRangeIter iter;
|
||||||
|
range_map<Addr,int>::iterator i;
|
||||||
|
|
||||||
while (i < portList.size() && !found)
|
i = portMap.find(RangeSize(addr,1));
|
||||||
{
|
if (i != portMap.end())
|
||||||
if (portList[i].range == addr) {
|
dest_id = i->second;
|
||||||
dest_id = portList[i].portId;
|
|
||||||
found = true;
|
|
||||||
DPRINTF(Bus, " found addr %#llx on device %d\n", addr, dest_id);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this matches the default range
|
// Check if this matches the default range
|
||||||
if (dest_id == -1) {
|
if (dest_id == -1) {
|
||||||
|
@ -463,13 +456,13 @@ Bus::recvStatusChange(Port::Status status, int id)
|
||||||
|
|
||||||
assert((id < interfaces.size() && id >= 0) || id == defaultId);
|
assert((id < interfaces.size() && id >= 0) || id == defaultId);
|
||||||
Port *port = interfaces[id];
|
Port *port = interfaces[id];
|
||||||
std::vector<DevMap>::iterator portIter;
|
range_map<Addr,int>::iterator portIter;
|
||||||
std::vector<DevMap>::iterator snoopIter;
|
std::vector<DevMap>::iterator snoopIter;
|
||||||
|
|
||||||
// Clean out any previously existent ids
|
// Clean out any previously existent ids
|
||||||
for (portIter = portList.begin(); portIter != portList.end(); ) {
|
for (portIter = portMap.begin(); portIter != portMap.end(); ) {
|
||||||
if (portIter->portId == id)
|
if (portIter->second == id)
|
||||||
portIter = portList.erase(portIter);
|
portMap.erase(portIter++);
|
||||||
else
|
else
|
||||||
portIter++;
|
portIter++;
|
||||||
}
|
}
|
||||||
|
@ -495,16 +488,14 @@ Bus::recvStatusChange(Port::Status status, int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
for(iter = ranges.begin(); iter != ranges.end(); iter++) {
|
for(iter = ranges.begin(); iter != ranges.end(); iter++) {
|
||||||
DevMap dm;
|
|
||||||
dm.portId = id;
|
|
||||||
dm.range = *iter;
|
|
||||||
|
|
||||||
DPRINTF(BusAddrRanges, "Adding range %#llx - %#llx for id %d\n",
|
DPRINTF(BusAddrRanges, "Adding range %#llx - %#llx for id %d\n",
|
||||||
dm.range.start, dm.range.end, id);
|
iter->start, iter->end, id);
|
||||||
portList.push_back(dm);
|
if (portMap.insert(*iter, id) == portMap.end())
|
||||||
|
panic("Two devices with same range\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DPRINTF(MMU, "port list has %d entries\n", portList.size());
|
DPRINTF(MMU, "port list has %d entries\n", portMap.size());
|
||||||
|
|
||||||
// tell all our peers that our address range has changed.
|
// tell all our peers that our address range has changed.
|
||||||
// Don't tell the device that caused this change, it already knows
|
// Don't tell the device that caused this change, it already knows
|
||||||
|
@ -519,7 +510,8 @@ Bus::recvStatusChange(Port::Status status, int id)
|
||||||
void
|
void
|
||||||
Bus::addressRanges(AddrRangeList &resp, AddrRangeList &snoop, int id)
|
Bus::addressRanges(AddrRangeList &resp, AddrRangeList &snoop, int id)
|
||||||
{
|
{
|
||||||
std::vector<DevMap>::iterator portIter;
|
std::vector<DevMap>::iterator snoopIter;
|
||||||
|
range_map<Addr,int>::iterator portIter;
|
||||||
AddrRangeIter dflt_iter;
|
AddrRangeIter dflt_iter;
|
||||||
bool subset;
|
bool subset;
|
||||||
|
|
||||||
|
@ -534,37 +526,37 @@ Bus::addressRanges(AddrRangeList &resp, AddrRangeList &snoop, int id)
|
||||||
DPRINTF(BusAddrRanges, " -- Dflt: %#llx : %#llx\n",dflt_iter->start,
|
DPRINTF(BusAddrRanges, " -- Dflt: %#llx : %#llx\n",dflt_iter->start,
|
||||||
dflt_iter->end);
|
dflt_iter->end);
|
||||||
}
|
}
|
||||||
for (portIter = portList.begin(); portIter != portList.end(); portIter++) {
|
for (portIter = portMap.begin(); portIter != portMap.end(); portIter++) {
|
||||||
subset = false;
|
subset = false;
|
||||||
for (dflt_iter = defaultRange.begin(); dflt_iter != defaultRange.end();
|
for (dflt_iter = defaultRange.begin(); dflt_iter != defaultRange.end();
|
||||||
dflt_iter++) {
|
dflt_iter++) {
|
||||||
if ((portIter->range.start < dflt_iter->start &&
|
if ((portIter->first.start < dflt_iter->start &&
|
||||||
portIter->range.end >= dflt_iter->start) ||
|
portIter->first.end >= dflt_iter->start) ||
|
||||||
(portIter->range.start < dflt_iter->end &&
|
(portIter->first.start < dflt_iter->end &&
|
||||||
portIter->range.end >= dflt_iter->end))
|
portIter->first.end >= dflt_iter->end))
|
||||||
fatal("Devices can not set ranges that itersect the default set\
|
fatal("Devices can not set ranges that itersect the default set\
|
||||||
but are not a subset of the default set.\n");
|
but are not a subset of the default set.\n");
|
||||||
if (portIter->range.start >= dflt_iter->start &&
|
if (portIter->first.start >= dflt_iter->start &&
|
||||||
portIter->range.end <= dflt_iter->end) {
|
portIter->first.end <= dflt_iter->end) {
|
||||||
subset = true;
|
subset = true;
|
||||||
DPRINTF(BusAddrRanges, " -- %#llx : %#llx is a SUBSET\n",
|
DPRINTF(BusAddrRanges, " -- %#llx : %#llx is a SUBSET\n",
|
||||||
portIter->range.start, portIter->range.end);
|
portIter->first.start, portIter->first.end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (portIter->portId != id && !subset) {
|
if (portIter->second != id && !subset) {
|
||||||
resp.push_back(portIter->range);
|
resp.push_back(portIter->first);
|
||||||
DPRINTF(BusAddrRanges, " -- %#llx : %#llx\n",
|
DPRINTF(BusAddrRanges, " -- %#llx : %#llx\n",
|
||||||
portIter->range.start, portIter->range.end);
|
portIter->first.start, portIter->first.end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (portIter = portSnoopList.begin();
|
for (snoopIter = portSnoopList.begin();
|
||||||
portIter != portSnoopList.end(); portIter++)
|
snoopIter != portSnoopList.end(); snoopIter++)
|
||||||
{
|
{
|
||||||
if (portIter->portId != id) {
|
if (snoopIter->portId != id) {
|
||||||
snoop.push_back(portIter->range);
|
snoop.push_back(snoopIter->range);
|
||||||
DPRINTF(BusAddrRanges, " -- Snoop: %#llx : %#llx\n",
|
DPRINTF(BusAddrRanges, " -- Snoop: %#llx : %#llx\n",
|
||||||
portIter->range.start, portIter->range.end);
|
snoopIter->range.start, snoopIter->range.end);
|
||||||
//@todo We need to properly insert snoop ranges
|
//@todo We need to properly insert snoop ranges
|
||||||
//not overlapping the ranges (multiple)
|
//not overlapping the ranges (multiple)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "base/range.hh"
|
#include "base/range.hh"
|
||||||
|
#include "base/range_map.hh"
|
||||||
#include "mem/mem_object.hh"
|
#include "mem/mem_object.hh"
|
||||||
#include "mem/packet.hh"
|
#include "mem/packet.hh"
|
||||||
#include "mem/port.hh"
|
#include "mem/port.hh"
|
||||||
|
@ -67,7 +68,7 @@ class Bus : public MemObject
|
||||||
int portId;
|
int portId;
|
||||||
Range<Addr> range;
|
Range<Addr> range;
|
||||||
};
|
};
|
||||||
std::vector<DevMap> portList;
|
range_map<Addr, int> portMap;
|
||||||
AddrRangeList defaultRange;
|
AddrRangeList defaultRange;
|
||||||
std::vector<DevMap> portSnoopList;
|
std::vector<DevMap> portSnoopList;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue