diff options
author | Boris Shingarov <shingarov@labware.com> | 2015-12-18 15:12:07 -0600 |
---|---|---|
committer | Boris Shingarov <shingarov@labware.com> | 2015-12-18 15:12:07 -0600 |
commit | d765dbf22cb3242c055b19b797b0f4cb39a43aae (patch) | |
tree | 55fade43c664a78e55823cdc43f7bcec1bf663a9 /src/arch/sparc/remote_gdb.hh | |
parent | b5a54eb64ebce9c217c1d44cc93aebb7cb508c6d (diff) | |
download | gem5-d765dbf22cb3242c055b19b797b0f4cb39a43aae.tar.xz |
arm: remote GDB: rationalize structure of register offsets
Currently, the wire format of register values in g- and G-packets is
modelled using a union of uint8/16/32/64 arrays. The offset positions
of each register are expressed as a "register count" scaled according
to the width of the register in question. This results in counter-
intuitive and error-prone "register count arithmetic", and some
formats would even be altogether unrepresentable in such model, e.g.
a 64-bit register following a 32-bit one would have a fractional index
in the regs64 array.
Another difficulty is that the array is allocated before the actual
architecture of the workload is known (and therefore before the correct
size for the array can be calculated).
With this patch I propose a simpler mechanism for expressing the
register set structure. In the new code, GdbRegCache is an abstract
class; its subclasses contain straightforward structs reflecting the
register representation. The determination whether to use e.g. the
AArch32 vs. AArch64 register set (or SPARCv8 vs SPARCv9, etc.) is made
by polymorphically dispatching getregs() to the concrete subclass.
The subclass is not instantiated until it is needed for actual
g-/G-packet processing, when the mode is already known.
This patch is not meant to be merged in on its own, because it changes
the contract between src/base/remote_gdb.* and src/arch/*/remote_gdb.*,
so as it stands right now, it would break the other architectures.
In this patch only the base and the ARM code are provided for review;
once we agree on the structure, I will provide src/arch/*/remote_gdb.*
for the other architectures; those patches could then be merged in
together.
Review Request: http://reviews.gem5.org/r/3207/
Pushed by Joel Hestness <jthestness@gmail.com>
Diffstat (limited to 'src/arch/sparc/remote_gdb.hh')
-rw-r--r-- | src/arch/sparc/remote_gdb.hh | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/src/arch/sparc/remote_gdb.hh b/src/arch/sparc/remote_gdb.hh index 6531e0f61..543683ee8 100644 --- a/src/arch/sparc/remote_gdb.hh +++ b/src/arch/sparc/remote_gdb.hh @@ -1,4 +1,5 @@ /* + * Copyright (c) 2015 LabWare * Copyright (c) 2002-2005 The Regents of The University of Michigan * All rights reserved. * @@ -26,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: Nathan Binkert + * Boris Shingarov */ #ifndef __ARCH_SPARC_REMOTE_GDB_HH__ @@ -33,10 +35,7 @@ #include <map> -#include "arch/sparc/types.hh" -#include "base/pollevent.hh" #include "base/remote_gdb.hh" -#include "cpu/pc_event.hh" class System; class ThreadContext; @@ -47,26 +46,58 @@ namespace SparcISA class RemoteGDB : public BaseRemoteGDB { protected: - enum RegisterConstants + bool acc(Addr addr, size_t len); + + class SPARCGdbRegCache : public BaseGdbRegCache { - RegG0 = 0, RegO0 = 8, RegL0 = 16, RegI0 = 24, - RegF0 = 32, - RegPc = 64, RegNpc, RegState, RegFsr, RegFprs, RegY, - /*RegState contains data in same format as tstate */ - Reg32Y = 64, Reg32Psr, Reg32Pc, Reg32Npc, Reg32Fsr, Reg32Csr, - NumGDBRegs + using BaseGdbRegCache::BaseGdbRegCache; + private: + struct { + uint32_t gpr[32]; + uint32_t hole[32]; + uint32_t y; + uint32_t psr; + uint32_t wim; + uint32_t tbr; + uint32_t pc; + uint32_t npc; + uint32_t fsr; + uint32_t csr; + } r; + public: + char *data() const { return (char *)&r; } + size_t size() const { return sizeof(r); } + void getRegs(ThreadContext*); + void setRegs(ThreadContext*) const; + const std::string name() const { return gdb->name() + ".SPARCGdbRegCache"; } }; - public: - RemoteGDB(System *system, ThreadContext *context); - - bool acc(Addr addr, size_t len); + class SPARC64GdbRegCache : public BaseGdbRegCache + { + using BaseGdbRegCache::BaseGdbRegCache; + private: + struct { + uint64_t gpr[32]; + uint64_t fpr[32]; + uint64_t pc; + uint64_t npc; + uint64_t state; + uint64_t fsr; + uint64_t fprs; + uint64_t y; + } r; + public: + char *data() const { return (char *)&r; } + size_t size() const { return sizeof(r); } + void getRegs(ThreadContext*); + void setRegs(ThreadContext*) const; + const std::string name() const { return gdb->name() + ".SPARC64GdbRegCache"; } + }; - protected: - void getregs(); - void setregs(); + public: + RemoteGDB(System *_system, ThreadContext *tc); + BaseGdbRegCache *gdbRegs(); }; - -} +} // namespace SparcISA #endif /* __ARCH_SPARC_REMOTE_GDB_H__ */ |