From 562efe214c35c0d40c810a11e94cc6e08c32dda5 Mon Sep 17 00:00:00 2001 From: Ron Dreslinski Date: Tue, 21 Feb 2006 02:15:02 -0500 Subject: [PATCH] Adding some definitons for read/write blob/string. I need to locate te code stever wrote to break up address ranges into blk/page size chunks. cpu/simple/cpu.cc: cpu/simple/cpu.hh: Add read/write blob definitions, still need to break it up into blk size chunks (where was the code stever wrote for that?) mem/physical.hh: Remove un-needed function (I think) mem/port.hh: Default these virtual functions to panic unimplented mem/translating_port.cc: Again handling read/write string properly. Need the stever code to break things into page size chunks yet mem/translating_port.hh: Having trouble with the const declerator. I will need to read how it works, for now it compiles if I remove it. --HG-- extra : convert_revision : f174e06700daa9967958d18e01798270c90d6dac --- cpu/simple/cpu.cc | 17 ++++++++++++++++- cpu/simple/cpu.hh | 4 ++++ mem/physical.hh | 4 ++-- mem/port.hh | 19 ++++++------------- mem/translating_port.cc | 38 ++++++++++++++++++++++---------------- mem/translating_port.hh | 2 +- 6 files changed, 51 insertions(+), 33 deletions(-) diff --git a/cpu/simple/cpu.cc b/cpu/simple/cpu.cc index 4937e5deb..02673119a 100644 --- a/cpu/simple/cpu.cc +++ b/cpu/simple/cpu.cc @@ -127,8 +127,23 @@ SimpleCPU::CpuPort::recvRetry() return cpu->processRetry(); } +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; +} - +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; +} SimpleCPU::SimpleCPU(Params *p) : BaseCPU(p), icachePort(this), diff --git a/cpu/simple/cpu.hh b/cpu/simple/cpu.hh index 6df553fe2..94f6f190a 100644 --- a/cpu/simple/cpu.hh +++ b/cpu/simple/cpu.hh @@ -88,6 +88,10 @@ class SimpleCPU : public BaseCPU virtual void recvStatusChange(Status status); virtual Packet *recvRetry(); + + virtual void readBlobFunctional(Addr addr, uint8_t *p, int size); + + virtual void writeBlobFunctional(Addr addr, uint8_t *p, int size); }; CpuPort icachePort; diff --git a/mem/physical.hh b/mem/physical.hh index a8ed45115..a98c52212 100644 --- a/mem/physical.hh +++ b/mem/physical.hh @@ -78,14 +78,14 @@ class PhysicalMemory : public Memory virtual void unserialize(Checkpoint *cp, const std::string §ion); }; -uint64_t +/*uint64_t PhysicalMemory::phys_read_qword(Addr addr) const { if (addr + sizeof(uint64_t) > pmem_size) return 0; return *(uint64_t *)(pmem_addr + addr); -} +}*/ #endif //__PHYSICAL_MEMORY_HH__ diff --git a/mem/port.hh b/mem/port.hh index 4e335e17c..2d8be1905 100644 --- a/mem/port.hh +++ b/mem/port.hh @@ -186,14 +186,16 @@ class Port appropriate chunks. The default implementation can use getBlockSize() to determine the block size and go from there. */ - virtual void readBlobFunctional(Addr addr, uint8_t *p, int size); + virtual void readBlobFunctional(Addr addr, uint8_t *p, int size) + { panic("Unimplemented"); } /** This function is a wrapper around sendFunctional() that breaks a larger, arbitrarily aligned access into appropriate chunks. The default implementation can use getBlockSize() to determine the block size and go from there. */ - virtual void writeBlobFunctional(Addr addr, const uint8_t *p, int size); + virtual void writeBlobFunctional(Addr addr, uint8_t *p, int size) + { panic("Unimplemented"); } /** Fill size bytes starting at addr with byte value val. This should not need to be virtual, since it can be implemented in @@ -203,17 +205,8 @@ class Port prot_memset on the old functional memory that's never used), but Nate claims it is. */ - void memsetBlobFunctional(Addr addr, uint8_t val, int size); - - // I believe these two string functions can be defined once and - // for all at the top level by implementing them in terms of - // readBlob and writeBlob. - - /** Write null-terminated string 'str' into memory at 'addr'. */ - void writeStringFunctional(Addr addr, const char *str); - - /** Read null-terminated string from 'addr' into 'str'. */ - void readStringFunctional(std::string &str, Addr addr); + void memsetBlobFunctional(Addr addr, uint8_t val, int size) + { panic("Unimplemented"); } }; #endif //__MEM_PORT_HH__ diff --git a/mem/translating_port.cc b/mem/translating_port.cc index 11004769e..ef4ed83d0 100644 --- a/mem/translating_port.cc +++ b/mem/translating_port.cc @@ -55,7 +55,7 @@ TranslatingPort::readBlobFunctional(Addr addr, uint8_t *p, int size) } Fault -TranslatingPort::writeBlobFunctional(Addr addr, const uint8_t *p, int size) +TranslatingPort::writeBlobFunctional(Addr addr, uint8_t *p, int size) { Addr paddr; @@ -75,6 +75,7 @@ TranslatingPort::memsetBlobFunctional(Addr addr, uint8_t val, int size) Addr paddr; //@todo Break up things larger than a page size + //Use the Stever breakup code pTable->page_check(addr, size); if (!pTable->translate(addr,paddr)) @@ -87,33 +88,38 @@ TranslatingPort::memsetBlobFunctional(Addr addr, uint8_t val, int size) Fault TranslatingPort::writeStringFunctional(Addr addr, const char *str) { - //@todo Break up things larger than a page size - //pTable->page_check(addr, size); - //Need to check string length??? + Addr paddr,vaddr; + uint8_t c; - Addr paddr; + vaddr = addr; - if (!pTable->translate(addr,paddr)) - return Machine_Check_Fault; + do { + c = *str++; + if (!pTable->translate(vaddr++,paddr)) + return Machine_Check_Fault; + + port->writeBlobFunctional(paddr, &c, 1); + } while (c); - port->writeStringFunctional(paddr, str); return No_Fault; } Fault TranslatingPort::readStringFunctional(std::string &str, Addr addr) { - //@todo Break up things larger than a page size - //pTable->page_check(addr, size); - //Need to check string length??? + Addr paddr,vaddr; + uint8_t c; - Addr paddr; + vaddr = addr; - if (!pTable->translate(addr,paddr)) - return Machine_Check_Fault; + do { + if (!pTable->translate(vaddr++,paddr)) + return Machine_Check_Fault; + + port->readBlobFunctional(paddr, &c, 1); + str += c; + } while (c); - //@todo Break this up into readBlobs - port->readStringFunctional(str, paddr); return No_Fault; } diff --git a/mem/translating_port.hh b/mem/translating_port.hh index 20140d26a..c8764bf41 100644 --- a/mem/translating_port.hh +++ b/mem/translating_port.hh @@ -49,7 +49,7 @@ class TranslatingPort public: Fault readBlobFunctional(Addr addr, uint8_t *p, int size); - Fault writeBlobFunctional(Addr addr, const uint8_t *p, int size); + Fault writeBlobFunctional(Addr addr, uint8_t *p, int size); Fault memsetBlobFunctional(Addr addr, uint8_t val, int size); Fault writeStringFunctional(Addr addr, const char *str); Fault readStringFunctional(std::string &str, Addr addr); -- 2.30.2