1 |
39 |
julius |
/*$$HEADER*/
|
2 |
|
|
/******************************************************************************/
|
3 |
|
|
/* */
|
4 |
|
|
/* H E A D E R I N F O R M A T I O N */
|
5 |
|
|
/* */
|
6 |
|
|
/******************************************************************************/
|
7 |
|
|
|
8 |
|
|
// Project Name : OpenRISC Debug Proxy
|
9 |
|
|
// File Name : or_debug_proxy.h
|
10 |
|
|
// Prepared By : jb
|
11 |
|
|
// Project Start : 2008-10-01
|
12 |
|
|
|
13 |
|
|
/*$$COPYRIGHT NOTICE*/
|
14 |
|
|
/******************************************************************************/
|
15 |
|
|
/* */
|
16 |
|
|
/* C O P Y R I G H T N O T I C E */
|
17 |
|
|
/* */
|
18 |
|
|
/******************************************************************************/
|
19 |
|
|
/*
|
20 |
|
|
This library is free software; you can redistribute it and/or
|
21 |
|
|
modify it under the terms of the GNU Lesser General Public
|
22 |
|
|
License as published by the Free Software Foundation;
|
23 |
|
|
version 2.1 of the License, a copy of which is available from
|
24 |
|
|
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
|
25 |
|
|
|
26 |
|
|
This library is distributed in the hope that it will be useful,
|
27 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
28 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
29 |
|
|
Lesser General Public License for more details.
|
30 |
|
|
|
31 |
|
|
You should have received a copy of the GNU Lesser General Public
|
32 |
|
|
License along with this library; if not, write to the Free Software
|
33 |
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
34 |
|
|
*/
|
35 |
|
|
|
36 |
|
|
/*$$CHANGE HISTORY*/
|
37 |
|
|
/******************************************************************************/
|
38 |
|
|
/* */
|
39 |
|
|
/* C H A N G E H I S T O R Y */
|
40 |
|
|
/* */
|
41 |
|
|
/******************************************************************************/
|
42 |
|
|
|
43 |
|
|
// Date Version Description
|
44 |
|
|
//------------------------------------------------------------------------
|
45 |
|
|
// 081101 First revision jb
|
46 |
|
|
|
47 |
|
|
#ifndef _OR_DEBUG_PROXY_H_
|
48 |
|
|
#define _OR_DEBUG_PROXY_H_
|
49 |
|
|
|
50 |
|
|
#ifndef DEBUG_CMDS
|
51 |
|
|
#define DEBUG_CMDS 0 // Output the actual commands being sent to the debug unit
|
52 |
|
|
#endif
|
53 |
|
|
|
54 |
|
|
#ifndef DEBUG_USB_DRVR_FUNCS
|
55 |
|
|
#define DEBUG_USB_DRVR_FUNCS 0 // Generate debug output from the USB driver functions
|
56 |
|
|
#endif
|
57 |
|
|
|
58 |
|
|
#ifndef DEBUG_GDB_BLOCK_DATA
|
59 |
|
|
#define DEBUG_GDB_BLOCK_DATA 0 // GDB Socket Block data print out
|
60 |
|
|
#endif
|
61 |
|
|
|
62 |
|
|
// This one is defined sometimes in the makefile, so check first
|
63 |
|
|
#ifndef DEBUG_GDB
|
64 |
|
|
#define DEBUG_GDB 0 // GDB RSP Debugging output enabled
|
65 |
|
|
#endif
|
66 |
|
|
|
67 |
|
|
#ifndef DEBUG_GDB_DUMP_DATA
|
68 |
|
|
#define DEBUG_GDB_DUMP_DATA 0 // GDB Socket Debugging - output all data we return to GDB client
|
69 |
|
|
#endif
|
70 |
|
|
|
71 |
|
|
#define Boolean uint32_t
|
72 |
|
|
#define false 0
|
73 |
|
|
#define true 1
|
74 |
|
|
|
75 |
|
|
/* Selects crc trailer size in bits. Currently supported: 8 */
|
76 |
|
|
#define CRC_SIZE (8)
|
77 |
|
|
|
78 |
|
|
#include <stdint.h>
|
79 |
|
|
|
80 |
|
|
extern int serverPort;
|
81 |
|
|
extern int server_fd;
|
82 |
|
|
|
83 |
|
|
extern int vpi_fd; // should be the descriptor for our connection to the VPI server
|
84 |
|
|
|
85 |
|
|
extern int current_chain;
|
86 |
|
|
extern int dbg_chain;
|
87 |
|
|
|
88 |
|
|
#define DBGCHAIN_SIZE 4 // Renamed from DC_SIZE due to definition clash with something in <windows.h> --jb 090302
|
89 |
|
|
#define DC_STATUS_SIZE 4
|
90 |
|
|
|
91 |
|
|
#define DC_WISHBONE 0
|
92 |
|
|
#define DC_CPU0 1
|
93 |
|
|
#define DC_CPU1 2
|
94 |
|
|
|
95 |
46 |
julius |
// Defining access types for wishbone
|
96 |
|
|
#define DBG_WB_WRITE8 0
|
97 |
|
|
#define DBG_WB_WRITE16 1
|
98 |
|
|
#define DBG_WB_WRITE32 2
|
99 |
|
|
#define DBG_WB_READ8 4
|
100 |
|
|
#define DBG_WB_READ16 5
|
101 |
|
|
#define DBG_WB_READ32 6
|
102 |
|
|
|
103 |
|
|
// Defining access types for wishbone
|
104 |
|
|
#define DBG_CPU_WRITE 2
|
105 |
|
|
#define DBG_CPU_READ 6
|
106 |
|
|
|
107 |
39 |
julius |
// Manually figure the 5-bit reversed values again if they change
|
108 |
|
|
#define DI_GO 0
|
109 |
|
|
#define DI_READ_CMD 1
|
110 |
|
|
#define DI_WRITE_CMD 2
|
111 |
|
|
#define DI_READ_CTRL 3
|
112 |
|
|
#define DI_WRITE_CTRL 4
|
113 |
|
|
|
114 |
|
|
#define DBG_CRC_SIZE 32
|
115 |
|
|
#define DBG_CRC_POLY 0x04c11db7
|
116 |
|
|
|
117 |
|
|
#define DBG_ERR_OK 0
|
118 |
|
|
#define DBG_ERR_INVALID_ENDPOINT 3
|
119 |
|
|
#define DBG_ERR_CRC 8
|
120 |
|
|
|
121 |
|
|
#define NUM_SOFT_RETRIES 3
|
122 |
|
|
#define NUM_HARD_RETRIES 3
|
123 |
|
|
#define NUM_ACCESS_RETRIES 10
|
124 |
|
|
|
125 |
|
|
/* setup connection with the target */
|
126 |
|
|
void dbg_test();
|
127 |
|
|
/* perform a reset of the debug chain (not of system!) */
|
128 |
|
|
int dbg_reset();
|
129 |
|
|
/* set instruction register of JTAG TAP */
|
130 |
|
|
int dbg_set_tap_ir(uint32_t ir);
|
131 |
|
|
/* Set "scan chain" of debug unit (NOT JTAG TAP!) */
|
132 |
|
|
int dbg_set_chain(uint32_t chain);
|
133 |
46 |
julius |
/* read a byte from wishbone */
|
134 |
|
|
int dbg_wb_write8(uint32_t adr, uint8_t data);
|
135 |
39 |
julius |
/* read a word from wishbone */
|
136 |
|
|
int dbg_wb_read32(uint32_t adr, uint32_t *data);
|
137 |
|
|
/* write a word to wishbone */
|
138 |
|
|
int dbg_wb_write32(uint32_t adr, uint32_t data);
|
139 |
|
|
/* read a block from wishbone */
|
140 |
|
|
int dbg_wb_read_block32(uint32_t adr, uint32_t *data, uint32_t len);
|
141 |
|
|
/* write a block to wishbone */
|
142 |
|
|
int dbg_wb_write_block32(uint32_t adr, uint32_t *data, uint32_t len);
|
143 |
|
|
/* read a register from cpu */
|
144 |
|
|
int dbg_cpu0_read(uint32_t adr, uint32_t *data);
|
145 |
|
|
/* read a register from cpu module */
|
146 |
|
|
int dbg_cpu0_read_ctrl(uint32_t adr, unsigned char *data);
|
147 |
|
|
/* write a cpu register */
|
148 |
|
|
int dbg_cpu0_write(uint32_t adr, uint32_t data);
|
149 |
|
|
/* write a cpu module register */
|
150 |
|
|
int dbg_cpu0_write_ctrl(uint32_t adr, unsigned char data);
|
151 |
|
|
|
152 |
|
|
void print_usage(); // Self explanatory
|
153 |
|
|
|
154 |
|
|
void check(char *fn, uint32_t l, uint32_t i);
|
155 |
|
|
|
156 |
|
|
/* Possible errors are listed here. */
|
157 |
|
|
enum enum_errors /* modified <chris@asics.ws> CZ 24/05/01 */
|
158 |
|
|
{
|
159 |
|
|
/* Codes > 0 are for system errors */
|
160 |
|
|
|
161 |
|
|
ERR_NONE = 0,
|
162 |
|
|
ERR_CRC = -1,
|
163 |
|
|
ERR_MEM = -2,
|
164 |
|
|
JTAG_PROXY_INVALID_COMMAND = -3,
|
165 |
|
|
JTAG_PROXY_SERVER_TERMINATED = -4,
|
166 |
|
|
JTAG_PROXY_NO_CONNECTION = -5,
|
167 |
|
|
JTAG_PROXY_PROTOCOL_ERROR = -6,
|
168 |
|
|
JTAG_PROXY_COMMAND_NOT_IMPLEMENTED = -7,
|
169 |
|
|
JTAG_PROXY_INVALID_CHAIN = -8,
|
170 |
|
|
JTAG_PROXY_INVALID_ADDRESS = -9,
|
171 |
|
|
JTAG_PROXY_ACCESS_EXCEPTION = -10, /* Write to ROM */
|
172 |
|
|
JTAG_PROXY_INVALID_LENGTH = -11,
|
173 |
|
|
JTAG_PROXY_OUT_OF_MEMORY = -12,
|
174 |
|
|
};
|
175 |
|
|
|
176 |
|
|
#endif /* _OR_DEBUG_PROXY_H_ */
|
177 |
|
|
|