diff options
Diffstat (limited to 'src/sim')
-rw-r--r-- | src/sim/core.hh | 2 | ||||
-rw-r--r-- | src/sim/process.cc | 4 | ||||
-rw-r--r-- | src/sim/process.hh | 4 | ||||
-rw-r--r-- | src/sim/process_impl.hh | 2 | ||||
-rw-r--r-- | src/sim/pseudo_inst.cc | 45 | ||||
-rw-r--r-- | src/sim/pseudo_inst.hh | 2 | ||||
-rw-r--r-- | src/sim/serialize.cc | 7 | ||||
-rw-r--r-- | src/sim/sim_object.cc | 2 | ||||
-rw-r--r-- | src/sim/sim_object.hh | 3 | ||||
-rw-r--r-- | src/sim/syscall_emul.hh | 56 |
10 files changed, 86 insertions, 41 deletions
diff --git a/src/sim/core.hh b/src/sim/core.hh index a529ff17b..4f842ab48 100644 --- a/src/sim/core.hh +++ b/src/sim/core.hh @@ -95,7 +95,7 @@ void setClockFrequency(Tick ticksPerSecond); void setOutputDir(const std::string &dir); -struct Callback; +class Callback; void registerExitCallback(Callback *callback); void doExitCleanup(); diff --git a/src/sim/process.cc b/src/sim/process.cc index 45362fe1b..8f3b3be79 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -86,8 +86,8 @@ AuxVector<IntType>::AuxVector(IntType type, IntType val) a_val = TheISA::htog(val); } -template class AuxVector<uint32_t>; -template class AuxVector<uint64_t>; +template struct AuxVector<uint32_t>; +template struct AuxVector<uint64_t>; Process::Process(ProcessParams * params) : SimObject(params), system(params->system), diff --git a/src/sim/process.hh b/src/sim/process.hh index 3896492b7..17b530ab8 100644 --- a/src/sim/process.hh +++ b/src/sim/process.hh @@ -43,8 +43,8 @@ #include "sim/syscallreturn.hh" class PageTable; -class ProcessParams; -class LiveProcessParams; +struct ProcessParams; +struct LiveProcessParams; class SyscallDesc; class System; class ThreadContext; diff --git a/src/sim/process_impl.hh b/src/sim/process_impl.hh index 401e16f52..0fb827498 100644 --- a/src/sim/process_impl.hh +++ b/src/sim/process_impl.hh @@ -47,7 +47,7 @@ copyStringArray(std::vector<std::string> &strings, { AddrType data_ptr_swap; for (std::vector<std::string>::size_type i = 0; i < strings.size(); ++i) { - data_ptr_swap = htog(data_ptr); + data_ptr_swap = TheISA::htog(data_ptr); memProxy->writeBlob(array_ptr, (uint8_t*)&data_ptr_swap, sizeof(AddrType)); memProxy->writeString(data_ptr, strings[i].c_str()); diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc index b72fdca4a..8a7f0c469 100644 --- a/src/sim/pseudo_inst.cc +++ b/src/sim/pseudo_inst.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 ARM Limited + * Copyright (c) 2010-2011 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -51,6 +51,7 @@ #include "arch/kernel_stats.hh" #include "arch/vtophys.hh" #include "base/debug.hh" +#include "base/output.hh" #include "config/the_isa.hh" #include "cpu/base.hh" #include "cpu/quiesce_event.hh" @@ -387,6 +388,48 @@ readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset) return result; } +uint64_t +writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, + Addr filename_addr) +{ + ostream *os; + + // copy out target filename + char fn[100]; + std::string filename; + CopyStringOut(tc, fn, filename_addr, 100); + filename = std::string(fn); + + if (offset == 0) { + // create a new file (truncate) + os = simout.create(filename, true); + } else { + // do not truncate file if offset is non-zero + // (ios::in flag is required as well to keep the existing data + // intact, otherwise existing data will be zeroed out.) + os = simout.openFile(simout.directory() + filename, + ios::in | ios::out | ios::binary); + } + if (!os) + panic("could not open file %s\n", filename); + + // seek to offset + os->seekp(offset); + + // copy out data and write to file + char *buf = new char[len]; + CopyOut(tc, buf, vaddr, len); + os->write(buf, len); + if (os->fail() || os->bad()) + panic("Error while doing writefile!\n"); + + simout.close(os); + + delete [] buf; + + return len; +} + void debugbreak(ThreadContext *tc) { diff --git a/src/sim/pseudo_inst.hh b/src/sim/pseudo_inst.hh index 399c88a4f..27d3b19d4 100644 --- a/src/sim/pseudo_inst.hh +++ b/src/sim/pseudo_inst.hh @@ -53,6 +53,8 @@ void quiesceCycles(ThreadContext *tc, uint64_t cycles); uint64_t quiesceTime(ThreadContext *tc); uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset); +uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len, + uint64_t offset, Addr filenameAddr); void loadsymbol(ThreadContext *xc); void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr); uint64_t initParam(ThreadContext *xc); diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc index 03f900837..30655e692 100644 --- a/src/sim/serialize.cc +++ b/src/sim/serialize.cc @@ -438,7 +438,7 @@ class Globals : public Serializable public: const string name() const; void serialize(ostream &os); - void unserialize(Checkpoint *cp); + void unserialize(Checkpoint *cp, const std::string §ion); }; /// The one and only instance of the Globals class. @@ -461,9 +461,8 @@ Globals::serialize(ostream &os) } void -Globals::unserialize(Checkpoint *cp) +Globals::unserialize(Checkpoint *cp, const std::string §ion) { - const string §ion = name(); Tick tick; paramIn(cp, section, "curTick", tick); curTick(tick); @@ -510,7 +509,7 @@ Serializable::serializeAll(const string &cpt_dir) void Serializable::unserializeGlobals(Checkpoint *cp) { - globals.unserialize(cp); + globals.unserialize(cp, globals.name()); } void diff --git a/src/sim/sim_object.cc b/src/sim/sim_object.cc index 9ac0b7fff..95bc6bf84 100644 --- a/src/sim/sim_object.cc +++ b/src/sim/sim_object.cc @@ -169,7 +169,7 @@ SimObject::resume() } void -SimObject::setMemoryMode(State new_mode) +SimObject::setMemoryMode(Enums::MemoryMode new_mode) { panic("setMemoryMode() should only be called on systems"); } diff --git a/src/sim/sim_object.hh b/src/sim/sim_object.hh index 995431845..4388ff584 100644 --- a/src/sim/sim_object.hh +++ b/src/sim/sim_object.hh @@ -43,6 +43,7 @@ #include <string> #include <vector> +#include "enums/MemoryMode.hh" #include "params/SimObject.hh" #include "sim/eventq.hh" #include "sim/serialize.hh" @@ -146,7 +147,7 @@ class SimObject : public EventManager, public Serializable // before the object will be done draining. Normally this should be 1 virtual unsigned int drain(Event *drain_event); virtual void resume(); - virtual void setMemoryMode(State new_mode); + virtual void setMemoryMode(Enums::MemoryMode new_mode); virtual void switchOut(); virtual void takeOverFrom(BaseCPU *cpu); diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 45c87f0ab..ad00f6e3d 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -401,41 +401,41 @@ convertStatBuf(target_stat &tgt, host_stat *host, bool fakeTTY = false) tgt->st_dev = 0xA; else tgt->st_dev = host->st_dev; - tgt->st_dev = htog(tgt->st_dev); + tgt->st_dev = TheISA::htog(tgt->st_dev); tgt->st_ino = host->st_ino; - tgt->st_ino = htog(tgt->st_ino); + tgt->st_ino = TheISA::htog(tgt->st_ino); tgt->st_mode = host->st_mode; if (fakeTTY) { // Claim to be a character device tgt->st_mode &= ~S_IFMT; // Clear S_IFMT tgt->st_mode |= S_IFCHR; // Set S_IFCHR } - tgt->st_mode = htog(tgt->st_mode); + tgt->st_mode = TheISA::htog(tgt->st_mode); tgt->st_nlink = host->st_nlink; - tgt->st_nlink = htog(tgt->st_nlink); + tgt->st_nlink = TheISA::htog(tgt->st_nlink); tgt->st_uid = host->st_uid; - tgt->st_uid = htog(tgt->st_uid); + tgt->st_uid = TheISA::htog(tgt->st_uid); tgt->st_gid = host->st_gid; - tgt->st_gid = htog(tgt->st_gid); + tgt->st_gid = TheISA::htog(tgt->st_gid); if (fakeTTY) tgt->st_rdev = 0x880d; else tgt->st_rdev = host->st_rdev; - tgt->st_rdev = htog(tgt->st_rdev); + tgt->st_rdev = TheISA::htog(tgt->st_rdev); tgt->st_size = host->st_size; - tgt->st_size = htog(tgt->st_size); + tgt->st_size = TheISA::htog(tgt->st_size); tgt->st_atimeX = host->st_atime; - tgt->st_atimeX = htog(tgt->st_atimeX); + tgt->st_atimeX = TheISA::htog(tgt->st_atimeX); tgt->st_mtimeX = host->st_mtime; - tgt->st_mtimeX = htog(tgt->st_mtimeX); + tgt->st_mtimeX = TheISA::htog(tgt->st_mtimeX); tgt->st_ctimeX = host->st_ctime; - tgt->st_ctimeX = htog(tgt->st_ctimeX); + tgt->st_ctimeX = TheISA::htog(tgt->st_ctimeX); // Force the block size to be 8k. This helps to ensure buffered io works // consistently across different hosts. tgt->st_blksize = 0x2000; - tgt->st_blksize = htog(tgt->st_blksize); + tgt->st_blksize = TheISA::htog(tgt->st_blksize); tgt->st_blocks = host->st_blocks; - tgt->st_blocks = htog(tgt->st_blocks); + tgt->st_blocks = TheISA::htog(tgt->st_blocks); } // Same for stat64 @@ -449,11 +449,11 @@ convertStat64Buf(target_stat &tgt, host_stat64 *host, bool fakeTTY = false) convertStatBuf<target_stat, host_stat64>(tgt, host, fakeTTY); #if defined(STAT_HAVE_NSEC) tgt->st_atime_nsec = host->st_atime_nsec; - tgt->st_atime_nsec = htog(tgt->st_atime_nsec); + tgt->st_atime_nsec = TheISA::htog(tgt->st_atime_nsec); tgt->st_mtime_nsec = host->st_mtime_nsec; - tgt->st_mtime_nsec = htog(tgt->st_mtime_nsec); + tgt->st_mtime_nsec = TheISA::htog(tgt->st_mtime_nsec); tgt->st_ctime_nsec = host->st_ctime_nsec; - tgt->st_ctime_nsec = htog(tgt->st_ctime_nsec); + tgt->st_ctime_nsec = TheISA::htog(tgt->st_ctime_nsec); #else tgt->st_atime_nsec = 0; tgt->st_mtime_nsec = 0; @@ -967,9 +967,9 @@ writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process, p->readBlob(tiov_base + i*sizeof(typename OS::tgt_iovec), (uint8_t*)&tiov, sizeof(typename OS::tgt_iovec)); - hiov[i].iov_len = gtoh(tiov.iov_len); + hiov[i].iov_len = TheISA::gtoh(tiov.iov_len); hiov[i].iov_base = new char [hiov[i].iov_len]; - p->readBlob(gtoh(tiov.iov_base), (uint8_t *)hiov[i].iov_base, + p->readBlob(TheISA::gtoh(tiov.iov_base), (uint8_t *)hiov[i].iov_base, hiov[i].iov_len); } @@ -1085,15 +1085,15 @@ getrlimitFunc(SyscallDesc *desc, int callnum, LiveProcess *process, case OS::TGT_RLIMIT_STACK: // max stack size in bytes: make up a number (8MB for now) rlp->rlim_cur = rlp->rlim_max = 8 * 1024 * 1024; - rlp->rlim_cur = htog(rlp->rlim_cur); - rlp->rlim_max = htog(rlp->rlim_max); + rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); + rlp->rlim_max = TheISA::htog(rlp->rlim_max); break; case OS::TGT_RLIMIT_DATA: // max data segment size in bytes: make up a number rlp->rlim_cur = rlp->rlim_max = 256 * 1024 * 1024; - rlp->rlim_cur = htog(rlp->rlim_cur); - rlp->rlim_max = htog(rlp->rlim_max); + rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); + rlp->rlim_max = TheISA::htog(rlp->rlim_max); break; default: @@ -1148,8 +1148,8 @@ utimesFunc(SyscallDesc *desc, int callnum, LiveProcess *process, struct timeval hostTimeval[2]; for (int i = 0; i < 2; ++i) { - hostTimeval[i].tv_sec = gtoh((*tp)[i].tv_sec); - hostTimeval[i].tv_usec = gtoh((*tp)[i].tv_usec); + hostTimeval[i].tv_sec = TheISA::gtoh((*tp)[i].tv_sec); + hostTimeval[i].tv_usec = TheISA::gtoh((*tp)[i].tv_usec); } // Adjust path for current working directory @@ -1194,8 +1194,8 @@ getrusageFunc(SyscallDesc *desc, int callnum, LiveProcess *process, switch (who) { case OS::TGT_RUSAGE_SELF: getElapsedTime(rup->ru_utime.tv_sec, rup->ru_utime.tv_usec); - rup->ru_utime.tv_sec = htog(rup->ru_utime.tv_sec); - rup->ru_utime.tv_usec = htog(rup->ru_utime.tv_usec); + rup->ru_utime.tv_sec = TheISA::htog(rup->ru_utime.tv_sec); + rup->ru_utime.tv_usec = TheISA::htog(rup->ru_utime.tv_usec); break; case OS::TGT_RUSAGE_CHILDREN: @@ -1231,7 +1231,7 @@ timesFunc(SyscallDesc *desc, int callnum, LiveProcess *process, bufp->tms_cstime = 0; // Convert to host endianness - bufp->tms_utime = htog(bufp->tms_utime); + bufp->tms_utime = TheISA::htog(bufp->tms_utime); // Write back bufp.copyOut(tc->getMemProxy()); @@ -1254,7 +1254,7 @@ timeFunc(SyscallDesc *desc, int callnum, LiveProcess *process, Addr taddr = (Addr)process->getSyscallArg(tc, index); if(taddr != 0) { typename OS::time_t t = sec; - t = htog(t); + t = TheISA::htog(t); SETranslatingPortProxy *p = tc->getMemProxy(); p->writeBlob(taddr, (uint8_t*)&t, (int)sizeof(typename OS::time_t)); } |