From 00be4e8510f587603cf358d615d19d8bbf8ec57e Mon Sep 17 00:00:00 2001 From: Ron Dreslinski Date: Tue, 21 Feb 2006 03:32:42 -0500 Subject: Thanks to Ali, I was able to add chunk generation code in to handle a few cases. Still have some duplicated code we may want to revisit. cpu/simple/cpu.cc: Thanks to Ali I found the chunk generator, although I still seem to be duplicating some code becuase the only difference between readBlob and writeBlob is the command in the packet. Perhaps an access function with the command as a param would help with the duplication (sendBlob that takes a cmd (maybe). mem/translating_port.cc: Using the chunck generator to break it up to be in page size chunks --HG-- extra : convert_revision : cc2e4e60c76098655e469f81c89d2c7438350fdb --- cpu/simple/cpu.cc | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'cpu/simple') diff --git a/cpu/simple/cpu.cc b/cpu/simple/cpu.cc index 02673119a..b7c213edf 100644 --- a/cpu/simple/cpu.cc +++ b/cpu/simple/cpu.cc @@ -36,6 +36,7 @@ #include #include "base/cprintf.hh" +#include "base/chunk_generator.hh" #include "base/inifile.hh" #include "base/loader/symtab.hh" #include "base/misc.hh" @@ -130,19 +131,45 @@ SimpleCPU::CpuPort::recvRetry() void SimpleCPU::CpuPort::writeBlobFunctional(Addr addr, uint8_t *p, int size) { - int blksize = sendBlockSizeQuery(); - //Use Stever's break it inot block size chunk code - //then send functional - blksize |= blksize; + int prevSize = 0; + //Base Packet + for (ChunkGenerator gen(addr, size, sendBlockSizeQuery()); !gen.done(); gen.next()) + { + Packet *blobpkt = new Packet(); + CpuRequest *blobreq = new CpuRequest(); + blobpkt->addr = gen.addr(); + blobpkt->size = gen.size(); + blobpkt->cmd = Write; + blobpkt->req = blobreq; + blobpkt->req->paddr = blobpkt->addr; + blobpkt->req->size = blobpkt->size; + blobpkt->data = p + prevSize; + prevSize += blobpkt->size; + + sendFunctional(*blobpkt); + } } void SimpleCPU::CpuPort::readBlobFunctional(Addr addr, uint8_t *p, int size) { - int blksize = sendBlockSizeQuery(); - //Use Stever's break it inot block size chunk code - //then send functional - blksize |= blksize; + int prevSize = 0; + //Base Packet + for (ChunkGenerator gen(addr, size, sendBlockSizeQuery()); !gen.done(); gen.next()) + { + Packet *blobpkt = new Packet(); + CpuRequest *blobreq = new CpuRequest(); + blobpkt->addr = gen.addr(); + blobpkt->size = gen.size(); + blobpkt->cmd = Write; + blobpkt->req = blobreq; + blobpkt->req->paddr = blobpkt->addr; + blobpkt->req->size = blobpkt->size; + blobpkt->data = p + prevSize; + prevSize += blobpkt->size; + + sendFunctional(*blobpkt); + } } SimpleCPU::SimpleCPU(Params *p) -- cgit v1.2.3