diff options
Diffstat (limited to 'src/sim')
-rw-r--r-- | src/sim/byteswap.hh | 56 | ||||
-rw-r--r-- | src/sim/host.hh | 4 | ||||
-rw-r--r-- | src/sim/param.cc | 24 | ||||
-rw-r--r-- | src/sim/param.hh | 1 | ||||
-rw-r--r-- | src/sim/process.cc | 8 | ||||
-rw-r--r-- | src/sim/process.hh | 10 | ||||
-rw-r--r-- | src/sim/serialize.cc | 12 | ||||
-rw-r--r-- | src/sim/serialize.hh | 7 | ||||
-rw-r--r-- | src/sim/syscallreturn.hh | 70 | ||||
-rw-r--r-- | src/sim/system.cc | 17 | ||||
-rw-r--r-- | src/sim/system.hh | 6 |
11 files changed, 165 insertions, 50 deletions
diff --git a/src/sim/byteswap.hh b/src/sim/byteswap.hh index 4ac1ee711..cbc0b5088 100644 --- a/src/sim/byteswap.hh +++ b/src/sim/byteswap.hh @@ -47,7 +47,7 @@ // If one doesn't exist, we pretty much get what is listed below, so it all // works out #include <byteswap.h> -#elif defined (__sun__) +#elif defined (__sun) #include <sys/isa_defs.h> #else #include <machine/endian.h> @@ -57,6 +57,8 @@ #include <libkern/OSByteOrder.h> #endif +enum ByteOrder {BigEndianByteOrder, LittleEndianByteOrder}; + //These functions actually perform the swapping for parameters //of various bit lengths static inline uint64_t @@ -131,11 +133,13 @@ template <typename T> static inline T letobe(T value) {return swap_byte(value);} //For conversions not involving the guest system, we can define the functions //conditionally based on the BYTE_ORDER macro and outside of the namespaces #if defined(_BIG_ENDIAN) || !defined(_LITTLE_ENDIAN) && BYTE_ORDER == BIG_ENDIAN +const ByteOrder HostByteOrder = BigEndianByteOrder; template <typename T> static inline T htole(T value) {return swap_byte(value);} template <typename T> static inline T letoh(T value) {return swap_byte(value);} template <typename T> static inline T htobe(T value) {return value;} template <typename T> static inline T betoh(T value) {return value;} #elif defined(_LITTLE_ENDIAN) || BYTE_ORDER == LITTLE_ENDIAN +const ByteOrder HostByteOrder = LittleEndianByteOrder; template <typename T> static inline T htole(T value) {return value;} template <typename T> static inline T letoh(T value) {return value;} template <typename T> static inline T htobe(T value) {return swap_byte(value);} @@ -146,33 +150,35 @@ template <typename T> static inline T betoh(T value) {return swap_byte(value);} namespace BigEndianGuest { - template <typename T> - static inline T gtole(T value) {return betole(value);} - template <typename T> - static inline T letog(T value) {return letobe(value);} - template <typename T> - static inline T gtobe(T value) {return value;} - template <typename T> - static inline T betog(T value) {return value;} - template <typename T> - static inline T htog(T value) {return htobe(value);} - template <typename T> - static inline T gtoh(T value) {return betoh(value);} + const bool ByteOrderDiffers = (HostByteOrder != BigEndianByteOrder); + template <typename T> + static inline T gtole(T value) {return betole(value);} + template <typename T> + static inline T letog(T value) {return letobe(value);} + template <typename T> + static inline T gtobe(T value) {return value;} + template <typename T> + static inline T betog(T value) {return value;} + template <typename T> + static inline T htog(T value) {return htobe(value);} + template <typename T> + static inline T gtoh(T value) {return betoh(value);} } namespace LittleEndianGuest { - template <typename T> - static inline T gtole(T value) {return value;} - template <typename T> - static inline T letog(T value) {return value;} - template <typename T> - static inline T gtobe(T value) {return letobe(value);} - template <typename T> - static inline T betog(T value) {return betole(value);} - template <typename T> - static inline T htog(T value) {return htole(value);} - template <typename T> - static inline T gtoh(T value) {return letoh(value);} + const bool ByteOrderDiffers = (HostByteOrder != LittleEndianByteOrder); + template <typename T> + static inline T gtole(T value) {return value;} + template <typename T> + static inline T letog(T value) {return value;} + template <typename T> + static inline T gtobe(T value) {return letobe(value);} + template <typename T> + static inline T betog(T value) {return betole(value);} + template <typename T> + static inline T htog(T value) {return htole(value);} + template <typename T> + static inline T gtoh(T value) {return letoh(value);} } #endif // __SIM_BYTE_SWAP_HH__ diff --git a/src/sim/host.hh b/src/sim/host.hh index 8b1ddbfe7..93a5fe7f2 100644 --- a/src/sim/host.hh +++ b/src/sim/host.hh @@ -38,6 +38,8 @@ #define __HOST_HH__ #include <inttypes.h> +#include <limits> + /** uint64_t constant */ #define ULL(N) ((uint64_t)N##ULL) @@ -56,7 +58,7 @@ typedef int64_t Counter; */ typedef int64_t Tick; -const Tick MaxTick = (1LL << 63) - 1; +const Tick MaxTick = std::numeric_limits<Tick>::max(); /** * Address type diff --git a/src/sim/param.cc b/src/sim/param.cc index b1c50946b..5cc69b161 100644 --- a/src/sim/param.cc +++ b/src/sim/param.cc @@ -777,3 +777,27 @@ ParamContext::describeAllContexts(ostream &os) os << endl; } } + +void +parseTime(const std::vector<int> &time, struct tm *tm) +{ + memset(tm, 0, sizeof(struct tm)); + + // UNIX is years since 1900 + tm->tm_year = time[0] - 1900; + + // Python starts at 1, UNIX starts at 0 + tm->tm_mon = time[1] - 1; + tm->tm_mday = time[2]; + tm->tm_hour = time[3]; + tm->tm_min = time[4]; + tm->tm_sec = time[5]; + + // Python has 0 as Monday, UNIX is 0 as sunday + tm->tm_wday = time[6] + 1; + if (tm->tm_wday > 6) + tm->tm_wday -= 7; + + // Python starts at 1, Unix starts at 0 + tm->tm_yday = time[7] - 1; +} diff --git a/src/sim/param.hh b/src/sim/param.hh index 2aa0456da..8a4670e27 100644 --- a/src/sim/param.hh +++ b/src/sim/param.hh @@ -781,4 +781,5 @@ SimObjectVectorParam<OBJ_CLASS *>::showType(std::ostream &os) const \ template <class T> bool parseParam(const std::string &str, T &data); template <class T> void showParam(std::ostream &os, const T &data); +void parseTime(const std::vector<int> &time, struct tm *tm); #endif // _SIM_PARAM_HH_ diff --git a/src/sim/process.cc b/src/sim/process.cc index 63ff33969..e5d868115 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -35,6 +35,7 @@ #include <string> +#include "arch/remote_gdb.hh" #include "base/intmath.hh" #include "base/loader/object_file.hh" #include "base/loader/symtab.hh" @@ -154,6 +155,13 @@ Process::registerThreadContext(ThreadContext *tc) int myIndex = threadContexts.size(); threadContexts.push_back(tc); + RemoteGDB *rgdb = new RemoteGDB(system, tc); + GDBListener *gdbl = new GDBListener(rgdb, 7000 + myIndex); + gdbl->listen(); + //gdbl->accept(); + + remoteGDB.push_back(rgdb); + // return CPU number to caller return myIndex; } diff --git a/src/sim/process.hh b/src/sim/process.hh index 616c02c00..bf65c6e06 100644 --- a/src/sim/process.hh +++ b/src/sim/process.hh @@ -51,6 +51,11 @@ class SyscallDesc; class PageTable; class TranslatingPort; class System; +class GDBListener; +namespace TheISA +{ + class RemoteGDB; +} void copyStringArray(std::vector<std::string> &strings, Addr array_ptr, @@ -72,6 +77,11 @@ class Process : public SimObject // thread contexts associated with this process std::vector<ThreadContext *> threadContexts; + // remote gdb objects + std::vector<TheISA::RemoteGDB *> remoteGDB; + std::vector<GDBListener *> gdbListen; + bool breakpoint(); + // number of CPUs (esxec contexts, really) assigned to this process. unsigned int numCpus() { return threadContexts.size(); } diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc index 941f0b1c6..1ff16976d 100644 --- a/src/sim/serialize.cc +++ b/src/sim/serialize.cc @@ -57,6 +57,8 @@ using namespace std; +extern SimObject *resolveSimObject(const string &); + int Serializable::ckptMaxCount = 0; int Serializable::ckptCount = 0; int Serializable::ckptPrevCount = -1; @@ -158,7 +160,7 @@ arrayParamIn(Checkpoint *cp, const std::string §ion, void objParamIn(Checkpoint *cp, const std::string §ion, - const std::string &name, Serializable * ¶m) + const std::string &name, SimObject * ¶m) { if (!cp->findObj(section, name, param)) { fatal("Can't unserialize '%s:%s'\n", section, name); @@ -388,17 +390,15 @@ Checkpoint::find(const std::string §ion, const std::string &entry, bool Checkpoint::findObj(const std::string §ion, const std::string &entry, - Serializable *&value) + SimObject *&value) { string path; if (!db->find(section, entry, path)) return false; - if ((value = objMap[path]) != NULL) - return true; - - return false; + value = resolveSimObject(path); + return true; } diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh index 880fb0785..43cd4ecf4 100644 --- a/src/sim/serialize.hh +++ b/src/sim/serialize.hh @@ -47,6 +47,7 @@ class IniFile; class Serializable; class Checkpoint; +class SimObject; template <class T> void paramOut(std::ostream &os, const std::string &name, const T ¶m); @@ -65,7 +66,7 @@ void arrayParamIn(Checkpoint *cp, const std::string §ion, void objParamIn(Checkpoint *cp, const std::string §ion, - const std::string &name, Serializable * ¶m); + const std::string &name, SimObject * ¶m); // @@ -96,7 +97,7 @@ objParamIn(Checkpoint *cp, const std::string §ion, #define UNSERIALIZE_OBJPTR(objptr) \ do { \ - Serializable *sptr; \ + SimObject *sptr; \ objParamIn(cp, section, #objptr, sptr); \ objptr = dynamic_cast<typeof(objptr)>(sptr); \ } while (0) @@ -225,7 +226,7 @@ class Checkpoint std::string &value); bool findObj(const std::string §ion, const std::string &entry, - Serializable *&value); + SimObject *&value); bool sectionExists(const std::string §ion); diff --git a/src/sim/syscallreturn.hh b/src/sim/syscallreturn.hh new file mode 100644 index 000000000..d1c43f584 --- /dev/null +++ b/src/sim/syscallreturn.hh @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2003-2005 The Regents of The University of Michigan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SIM_SYSCALLRETURN_HH__ +#define __SIM_SYSCALLRETURN_HH__ + +#include <inttypes.h> + +class SyscallReturn +{ + public: + template <class T> + SyscallReturn(T v, bool s) + { + retval = (uint64_t)v; + success = s; + } + + template <class T> + SyscallReturn(T v) + { + success = (v >= 0); + retval = (uint64_t)v; + } + + ~SyscallReturn() {} + + SyscallReturn& operator=(const SyscallReturn& s) + { + retval = s.retval; + success = s.success; + return *this; + } + + bool successful() { return success; } + uint64_t value() { return retval; } + + private: + uint64_t retval; + bool success; +}; + +#endif diff --git a/src/sim/system.cc b/src/sim/system.cc index b3ba1b8f1..f6febe4b1 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -32,6 +32,7 @@ */ #include "arch/isa_traits.hh" +#include "arch/remote_gdb.hh" #include "base/loader/object_file.hh" #include "base/loader/symtab.hh" #include "base/trace.hh" @@ -43,7 +44,6 @@ #include "sim/system.hh" #if FULL_SYSTEM #include "arch/vtophys.hh" -#include "arch/remote_gdb.hh" #include "kern/kernel_stats.hh" #endif @@ -141,14 +141,8 @@ System::~System() #endif // FULL_SYSTEM} } -#if FULL_SYSTEM - - int rgdb_wait = -1; -#endif // FULL_SYSTEM - - void System::setMemoryMode(MemoryMode mode) { @@ -156,6 +150,11 @@ System::setMemoryMode(MemoryMode mode) memoryMode = mode; } +bool System::breakpoint() +{ + return remoteGDB[0]->breakpoint(); +} + int System::registerThreadContext(ThreadContext *tc, int id) { @@ -175,7 +174,6 @@ System::registerThreadContext(ThreadContext *tc, int id) threadContexts[id] = tc; numcpus++; -#if FULL_SYSTEM RemoteGDB *rgdb = new RemoteGDB(this, tc); GDBListener *gdbl = new GDBListener(rgdb, 7000 + id); gdbl->listen(); @@ -191,7 +189,6 @@ System::registerThreadContext(ThreadContext *tc, int id) } remoteGDB[id] = rgdb; -#endif // FULL_SYSTEM return id; } @@ -213,9 +210,7 @@ System::replaceThreadContext(ThreadContext *tc, int id) } threadContexts[id] = tc; -#if FULL_SYSTEM remoteGDB[id]->replaceThreadContext(tc); -#endif // FULL_SYSTEM } #if !FULL_SYSTEM diff --git a/src/sim/system.hh b/src/sim/system.hh index b3a67bf7a..758da709e 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -55,12 +55,12 @@ class PhysicalMemory; #if FULL_SYSTEM class Platform; +#endif class GDBListener; namespace TheISA { class RemoteGDB; } -#endif class System : public SimObject { @@ -159,11 +159,9 @@ class System : public SimObject #endif public: -#if FULL_SYSTEM std::vector<TheISA::RemoteGDB *> remoteGDB; std::vector<GDBListener *> gdbListen; - virtual bool breakpoint() = 0; -#endif // FULL_SYSTEM + bool breakpoint(); public: struct Params |