remote_gdb.hh revision 12449
15222Sksewell@umich.edu/*
25222Sksewell@umich.edu * Copyright (c) 2017 The University of Virginia
35222Sksewell@umich.edu * Copyright 2015 LabWare
45222Sksewell@umich.edu * Copyright 2014 Google, Inc.
55222Sksewell@umich.edu * Copyright (c) 2007 The Regents of The University of Michigan
65222Sksewell@umich.edu * All rights reserved.
75222Sksewell@umich.edu *
85222Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without
95222Sksewell@umich.edu * modification, are permitted provided that the following conditions are
105222Sksewell@umich.edu * met: redistributions of source code must retain the above copyright
115222Sksewell@umich.edu * notice, this list of conditions and the following disclaimer;
125222Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright
135222Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the
145222Sksewell@umich.edu * documentation and/or other materials provided with the distribution;
155222Sksewell@umich.edu * neither the name of the copyright holders nor the names of its
165222Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
175222Sksewell@umich.edu * this software without specific prior written permission.
185222Sksewell@umich.edu *
195222Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
205222Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
215222Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
225222Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
235222Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
245222Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
255222Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
265222Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
275222Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
285222Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
295222Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
305222Sksewell@umich.edu *
315222Sksewell@umich.edu * Authors: Nathan Binkert
325222Sksewell@umich.edu *          Boris Shingarov
335222Sksewell@umich.edu *          Alec Roelke
345222Sksewell@umich.edu */
355222Sksewell@umich.edu
365222Sksewell@umich.edu#ifndef __ARCH_RISCV_REMOTE_GDB_HH__
375222Sksewell@umich.edu#define __ARCH_RISCV_REMOTE_GDB_HH__
385222Sksewell@umich.edu
395222Sksewell@umich.edu#include <string>
405222Sksewell@umich.edu
415222Sksewell@umich.edu#include "arch/riscv/registers.hh"
425222Sksewell@umich.edu#include "base/remote_gdb.hh"
435222Sksewell@umich.edu
445222Sksewell@umich.educlass System;
455222Sksewell@umich.educlass ThreadContext;
465222Sksewell@umich.edu
475222Sksewell@umich.edunamespace RiscvISA
485222Sksewell@umich.edu{
495222Sksewell@umich.edu
505222Sksewell@umich.educlass RemoteGDB : public BaseRemoteGDB
515222Sksewell@umich.edu{
525222Sksewell@umich.edu  protected:
535222Sksewell@umich.edu    static const int ExplicitCSRs = 4;
545222Sksewell@umich.edu
555222Sksewell@umich.edu    bool acc(Addr addr, size_t len);
565222Sksewell@umich.edu
575222Sksewell@umich.edu    class RiscvGdbRegCache : public BaseGdbRegCache
585222Sksewell@umich.edu    {
595222Sksewell@umich.edu      using BaseGdbRegCache::BaseGdbRegCache;
605222Sksewell@umich.edu      private:
615222Sksewell@umich.edu        struct {
625222Sksewell@umich.edu            IntReg gpr[NumIntArchRegs];
635222Sksewell@umich.edu            IntReg pc;
645222Sksewell@umich.edu            FloatRegBits fpr[NumFloatRegs];
655222Sksewell@umich.edu
665222Sksewell@umich.edu            MiscReg csr_base;
675222Sksewell@umich.edu            uint32_t fflags;
685222Sksewell@umich.edu            uint32_t frm;
695222Sksewell@umich.edu            uint32_t fcsr;
705222Sksewell@umich.edu            MiscReg csr[NumMiscRegs - ExplicitCSRs];
715222Sksewell@umich.edu        } __attribute__((__packed__)) r;
725222Sksewell@umich.edu      public:
735222Sksewell@umich.edu        char *data() const { return (char *)&r; }
745222Sksewell@umich.edu        size_t size() const { return sizeof(r); }
755222Sksewell@umich.edu        void getRegs(ThreadContext*);
765222Sksewell@umich.edu        void setRegs(ThreadContext*) const;
775222Sksewell@umich.edu
785222Sksewell@umich.edu        const std::string
795222Sksewell@umich.edu        name() const
805222Sksewell@umich.edu        {
815222Sksewell@umich.edu            return gdb->name() + ".RiscvGdbRegCache";
825222Sksewell@umich.edu        }
835222Sksewell@umich.edu    };
845222Sksewell@umich.edu
855222Sksewell@umich.edu    RiscvGdbRegCache regCache;
865222Sksewell@umich.edu
875222Sksewell@umich.edu  public:
885222Sksewell@umich.edu    RemoteGDB(System *_system, ThreadContext *tc, int _port);
895222Sksewell@umich.edu    BaseGdbRegCache *gdbRegs();
905222Sksewell@umich.edu};
915222Sksewell@umich.edu
925222Sksewell@umich.edu} // namespace RiscvISA
935222Sksewell@umich.edu
945222Sksewell@umich.edu#endif /* __ARCH_RISCV_REMOTE_GDB_H__ */
955222Sksewell@umich.edu