summaryrefslogtreecommitdiff
path: root/mem
diff options
context:
space:
mode:
authorRon Dreslinski <rdreslin@umich.edu>2006-02-21 02:15:02 -0500
committerRon Dreslinski <rdreslin@umich.edu>2006-02-21 02:15:02 -0500
commit562efe214c35c0d40c810a11e94cc6e08c32dda5 (patch)
treed4789b3ca1b0d24842185fba381c5373e8d7f704 /mem
parent75152fcaf709135d5f9668875234aed51d6334c4 (diff)
downloadgem5-562efe214c35c0d40c810a11e94cc6e08c32dda5.tar.xz
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
Diffstat (limited to 'mem')
-rw-r--r--mem/physical.hh4
-rw-r--r--mem/port.hh19
-rw-r--r--mem/translating_port.cc38
-rw-r--r--mem/translating_port.hh2
4 files changed, 31 insertions, 32 deletions
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 &section);
};
-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);