{
if (!slavePort.isConnected() || !masterPort.isConnected())
fatal("Address mapper is not connected on both sides.\n");
-
- if ((slavePort.peerBlockSize() != masterPort.peerBlockSize()) &&
- slavePort.peerBlockSize() && masterPort.peerBlockSize())
- fatal("Slave port size %d, master port size %d \n "
- "don't have the same block size... Not supported.\n",
- slavePort.peerBlockSize(), masterPort.peerBlockSize());
}
-MasterPort&
-AddrMapper::getMasterPort(const std::string& if_name, int idx)
+BaseMasterPort&
+AddrMapper::getMasterPort(const std::string& if_name, PortID idx)
{
if (if_name == "master") {
return masterPort;
}
}
-SlavePort&
-AddrMapper::getSlavePort(const std::string& if_name, int idx)
+BaseSlavePort&
+AddrMapper::getSlavePort(const std::string& if_name, PortID idx)
{
if (if_name == "slave") {
return slavePort;
Addr orig_addr = pkt->getAddr();
bool needsResponse = pkt->needsResponse();
bool memInhibitAsserted = pkt->memInhibitAsserted();
- Packet::SenderState* senderState = pkt->senderState;
if (needsResponse && !memInhibitAsserted) {
- pkt->senderState = new AddrMapperSenderState(senderState, orig_addr);
+ pkt->pushSenderState(new AddrMapperSenderState(orig_addr));
}
pkt->setAddr(remapAddr(orig_addr));
// packets)
bool successful = masterPort.sendTimingReq(pkt);
- // If not successful, restore the sender state
- if (!successful && needsResponse) {
- delete pkt->senderState;
- pkt->senderState = senderState;
+ // If not successful, restore the address and sender state
+ if (!successful) {
+ pkt->setAddr(orig_addr);
+
+ if (needsResponse) {
+ delete pkt->popSenderState();
+ }
}
return successful;
Addr remapped_addr = pkt->getAddr();
// Restore the state and address
- pkt->senderState = receivedState->origSenderState;
+ pkt->senderState = receivedState->predecessor;
pkt->setAddr(receivedState->origAddr);
// Attempt to send the packet
bool
AddrMapper::isSnooping() const
{
- if (slavePort.getMasterPort().isSnooping())
+ if (slavePort.isSnooping())
fatal("AddrMapper doesn't support remapping of snooping requests\n");
return false;
}
-unsigned
-AddrMapper::deviceBlockSizeMaster()
-{
- return slavePort.peerBlockSize();
-}
-
-unsigned
-AddrMapper::deviceBlockSizeSlave()
-{
- return masterPort.peerBlockSize();
-}
-
void
-AddrMapper::recvRetryMaster()
+AddrMapper::recvReqRetry()
{
- slavePort.sendRetry();
+ slavePort.sendRetryReq();
}
void
-AddrMapper::recvRetrySlave()
+AddrMapper::recvRespRetry()
{
- masterPort.sendRetry();
+ masterPort.sendRetryResp();
}
void
RangeAddrMapper::remapAddr(Addr addr) const
{
for (int i = 0; i < originalRanges.size(); ++i) {
- if (originalRanges[i] == addr) {
- Addr offset = addr - originalRanges[i].start;
- return offset + remappedRanges[i].start;
+ if (originalRanges[i].contains(addr)) {
+ Addr offset = addr - originalRanges[i].start();
+ return offset + remappedRanges[i].start();
}
}
AddrRangeList
RangeAddrMapper::getAddrRanges() const
{
- AddrRangeList ranges;
- AddrRangeList actualRanges = masterPort.getSlavePort().getAddrRanges();
-
- for (AddrRangeIter r = actualRanges.begin(); r != actualRanges.end(); ++r) {
- AddrRange range = *r;
-
- for (int j = 0; j < originalRanges.size(); ++j) {
- if (range.intersects(originalRanges[j]))
- fatal("Cannot remap range that intersects the original"
- " ranges but are not a subset.\n");
- if (range.isSubset(originalRanges[j])) {
- // range is a subset
- Addr offset = range.start - originalRanges[j].start;
- range.start -= offset;
- range.end -= offset;
- }
- ranges.push_back(range);
- }
- }
-
+ // Simply return the original ranges as given by the parameters
+ AddrRangeList ranges(originalRanges.begin(), originalRanges.end());
return ranges;
}