OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [include/] [GdbServerSC.h] - Blame information for rev 589

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 63 julius
// ----------------------------------------------------------------------------
2
 
3
// SystemC GDB RSP server: definition
4
 
5
// Copyright (C) 2008  Embecosm Limited <info@embecosm.com>
6
 
7
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
// This file is part of the GDB interface to the cycle accurate model of the
10
// OpenRISC 1000 based system-on-chip, ORPSoC, built using Verilator.
11
 
12
// This program is free software: you can redistribute it and/or modify it
13
// under the terms of the GNU Lesser General Public License as published by
14
// the Free Software Foundation, either version 3 of the License, or (at your
15
// option) any later version.
16
 
17
// This program is distributed in the hope that it will be useful, but WITHOUT
18
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
20
// License for more details.
21
 
22
// You should have received a copy of the GNU Lesser General Public License
23
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 
25
// ----------------------------------------------------------------------------
26
 
27
// $Id$
28
 
29
#ifndef GDB_SERVER_SC__H
30
#define GDB_SERVER_SC__H
31
 
32
#include <stdint.h>
33
 
34
#include "systemc"
35
 
36 64 julius
#include "JtagSC_includes.h"
37 63 julius
 
38
#include "OrpsocAccess.h"
39
#include "RspConnection.h"
40
#include "MpHash.h"
41
#include "RspPacket.h"
42
#include "DebugUnitSC.h"
43
 
44
//! Module implementing a GDB RSP server.
45
 
46
//! A thread listens for RSP requests, which are converted to requests to read
47
//! and write registers, memory or control the CPU in the debug unit
48
 
49 462 julius
class GdbServerSC:public sc_core::sc_module {
50 63 julius
public:
51
 
52 462 julius
        // Constructor and destructor
53
        GdbServerSC(sc_core::sc_module_name name,
54
                    uint32_t _flashStart,
55
                    uint32_t _flashEnd,
56
                    int rspPort,
57
                    sc_core::sc_fifo < TapAction * >*tapActionQueue);
58
        ~GdbServerSC();
59 63 julius
 
60
private:
61
 
62 462 julius
        //! Definition of GDB target signals.
63 63 julius
 
64 462 julius
        //! Data taken from the GDB 6.8 source. Only those we use defined here.
65
        enum TargetSignal {
66
                TARGET_SIGNAL_NONE = 0,
67
                TARGET_SIGNAL_INT = 2,
68
                TARGET_SIGNAL_ILL = 4,
69
                TARGET_SIGNAL_TRAP = 5,
70
                TARGET_SIGNAL_FPE = 8,
71
                TARGET_SIGNAL_BUS = 10,
72
                TARGET_SIGNAL_SEGV = 11,
73
                TARGET_SIGNAL_ALRM = 14,
74
                TARGET_SIGNAL_USR2 = 31,
75
                TARGET_SIGNAL_PWR = 32
76
        };
77 63 julius
 
78 462 julius
        // Register numbering. Matches GDB client
79
        static const int MAX_SPRS = 0x10000;    //!< Max number of OR1K SPRs
80
        static const int max_gprs = 32; //!< Max number of OR1K GPRs
81 63 julius
 
82 462 julius
        static const int PPC_REGNUM = max_gprs + 0;      //!< Previous PC
83
        static const int NPC_REGNUM = max_gprs + 1;     //!< Next PC
84
        static const int SR_REGNUM = max_gprs + 2;      //!< Supervision Register
85 63 julius
 
86 462 julius
        static const int NUM_REGS = max_gprs + 3;       //!< Total GDB registers
87 63 julius
 
88 462 julius
        //! Maximum size of a GDB RSP packet
89
        //static const int  RSP_PKT_MAX  = NUM_REGS * 8 + 1;
90
        static const int RSP_PKT_MAX = 1024 * 16;
91 63 julius
 
92 462 julius
        // OpenRISC exception addresses. Only the ones we need to know about
93
        static const uint32_t EXCEPT_NONE = 0x000;      //!< No exception
94
        static const uint32_t EXCEPT_RESET = 0x100;     //!< Reset
95 63 julius
 
96 462 julius
        // SPR numbers
97
        static const uint16_t SPR_NPC = 0x0010; //!< Next program counter
98
        static const uint16_t SPR_SR = 0x0011;  //!< Supervision register
99
        static const uint16_t SPR_PPC = 0x0012; //!< Previous program counter
100
        static const uint16_t SPR_GPR0 = 0x0400;        //!< GPR 0
101 63 julius
 
102 462 julius
        static const uint16_t SPR_DVR0 = 0x3000;        //!< Debug value register 0
103
        static const uint16_t SPR_DVR1 = 0x3001;        //!< Debug value register 1
104
        static const uint16_t SPR_DVR2 = 0x3002;        //!< Debug value register 2
105
        static const uint16_t SPR_DVR3 = 0x3003;        //!< Debug value register 3
106
        static const uint16_t SPR_DVR4 = 0x3004;        //!< Debug value register 4
107
        static const uint16_t SPR_DVR5 = 0x3005;        //!< Debug value register 5
108
        static const uint16_t SPR_DVR6 = 0x3006;        //!< Debug value register 6
109
        static const uint16_t SPR_DVR7 = 0x3007;        //!< Debug value register 7
110 63 julius
 
111 462 julius
        static const uint16_t SPR_DCR0 = 0x3008;        //!< Debug control register 0
112
        static const uint16_t SPR_DCR1 = 0x3009;        //!< Debug control register 1
113
        static const uint16_t SPR_DCR2 = 0x300a;        //!< Debug control register 2
114
        static const uint16_t SPR_DCR3 = 0x300b;        //!< Debug control register 3
115
        static const uint16_t SPR_DCR4 = 0x300c;        //!< Debug control register 4
116
        static const uint16_t SPR_DCR5 = 0x300d;        //!< Debug control register 5
117
        static const uint16_t SPR_DCR6 = 0x300e;        //!< Debug control register 6
118
        static const uint16_t SPR_DCR7 = 0x300f;        //!< Debug control register 7  
119 63 julius
 
120 462 julius
        static const uint16_t SPR_DMR1 = 0x3010;        //!< Debug mode register 1
121
        static const uint16_t SPR_DMR2 = 0x3011;        //!< Debug mode register 2
122
        static const uint16_t SPR_DSR = 0x3014; //!< Debug stop register
123
        static const uint16_t SPR_DRR = 0x3015; //!< Debug reason register
124 63 julius
 
125 462 julius
        // SPR masks and offsets
126
        static const uint32_t SPR_DMR1_ST = 0x00400000; //!< Single-step trace
127
        static const uint32_t SPR_DMR2_WGB = 0x003ff000;        //!< W/pt generating B/pt
128
        static const uint32_t SPR_DMR2_WBS = 0xffc00000;        //!< W/pt B/pt status
129
        static const uint32_t SPR_DSR_TE = 0x00002000;  //!< Trap
130
        static const uint32_t SPR_DCR_DP_MASK = 0x00000001;     //!< Debug Pair Present
131
        static const uint32_t SPR_DCR_CC_MASK = 0x0000000e;     //!< Compare Condition
132
        static const uint32_t SPR_DCR_SC_MASK = 0x00000010;     //!< Signed Comparison
133
        static const uint32_t SPR_DCR_CT_MASK = 0x000000e0;     //!< Compare To
134
        static const uint32_t SPR_DMR2_WGB_SHIFT = 12;  //!< W/pt Generate B/pt
135 63 julius
 
136 462 julius
        // DRR (Debug Reason Register) Bits
137
        static const uint32_t SPR_DRR_RSTE = 0x00000001;        //!< Reset
138
        static const uint32_t SPR_DRR_BUSEE = 0x00000002;       //!< Bus error
139
        static const uint32_t SPR_DRR_DPFE = 0x00000004;        //!< Data page fault
140
        static const uint32_t SPR_DRR_IPFE = 0x00000008;        //!< Insn page fault
141
        static const uint32_t SPR_DRR_TTE = 0x00000010; //!< Tick timer
142
        static const uint32_t SPR_DRR_AE = 0x00000020;  //!< Alignment
143
        static const uint32_t SPR_DRR_IIE = 0x00000040; //!< Illegal instruction
144
        static const uint32_t SPR_DRR_IE = 0x00000080;  //!< Interrupt
145
        static const uint32_t SPR_DRR_DME = 0x00000100; //!< DTLB miss
146
        static const uint32_t SPR_DRR_IME = 0x00000200; //!< ITLB miss
147
        static const uint32_t SPR_DRR_RE = 0x00000400;  //!< Range fault
148
        static const uint32_t SPR_DRR_SCE = 0x00000800; //!< System call
149
        static const uint32_t SPR_DRR_FPE = 0x00001000; //!< Floating point
150
        static const uint32_t SPR_DRR_TE = 0x00002000;  //!< Trap
151 63 julius
 
152 462 julius
        //! RSP Signal valu
153
        uint32_t rsp_sigval;
154 63 julius
 
155 462 julius
        //! Trap instruction for OR32
156
        static const uint32_t OR1K_TRAP_INSTR = 0x21000001;
157 63 julius
 
158 462 julius
        //! Thread ID used by Or1ksim
159
        static const int OR1KSIM_TID = 1;
160 63 julius
 
161 462 julius
        // The bounds of flash memory
162
        uint32_t flashStart;    //<! Start of flash memory
163
        uint32_t flashEnd;      //<! End of flash memory
164 63 julius
 
165 462 julius
        //! Our associated Debug Unit
166
        DebugUnitSC *debugUnit;
167 63 julius
 
168 462 julius
        //! Our associated RSP interface (which we create)
169
        RspConnection *rsp;
170 63 julius
 
171 462 julius
        //! The packet pointer. There is only ever one packet in use at one time, so
172
        //! there is no need to repeatedly allocate and delete it.
173
        RspPacket *pkt;
174 63 julius
 
175 462 julius
        //! Hash table for matchpoints
176
        MpHash *mpHash;
177 63 julius
 
178 462 julius
        //! Is the target stopped
179
        bool targetStopped;
180 63 julius
 
181 462 julius
        // SystemC thread to listen for and service RSP requests
182
        void rspServer();
183 63 julius
 
184 462 julius
        // Main RSP request handler
185
        void rspClientRequest();
186 63 julius
 
187 462 julius
        // Handle the various RSP requests
188
        void rspCheckForException();
189
        void rspReportException();
190
        void rspContinue();
191
        void rspContinue(uint32_t except);
192
        void rspContinue(uint32_t addr, uint32_t except);
193
        void rspInterrupt();
194
        void rspReadAllRegs();
195
        void rspWriteAllRegs();
196
        void rspReadMem();
197
        void rspWriteMem();
198
        void rspReadReg();
199
        void rspWriteReg();
200
        void rspQuery();
201
        void rspCommand();
202
        void rspSet();
203
        void rspRestart();
204
        void rspStep();
205
        void rspStep(uint32_t except);
206
        void rspStep(uint32_t addr, uint32_t except);
207
        void rspVpkt();
208
        void rspWriteMemBin();
209
        void rspRemoveMatchpoint();
210
        void rspInsertMatchpoint();
211 63 julius
 
212 462 julius
        // Convenience wrappers for getting particular registers, which are really
213
        // SPRs.
214
        uint32_t readNpc();
215
        void writeNpc(uint32_t addr);
216 63 julius
 
217 462 julius
        uint32_t readGpr(int regNum);
218
        void writeGpr(int regNum, uint32_t value);
219 63 julius
 
220 462 julius
        // Check if we got a message from the or1200 monitor module telling us
221
        // to stall
222
        bool checkMonitorPipe();
223 63 julius
 
224 462 julius
};                              // GdbServerSC ()
225 63 julius
 
226 462 julius
#endif // GDB_SERVER_SC__H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.