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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [config/] [or1k/] [tm-or1k.h] - Blame information for rev 146

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

Line No. Rev Author Line
1 106 markom
/* Definitions to target GDB to or1k targets.
2
   Copyright 2001 Free Software Foundation, Inc.
3
 
4
   This file is part of GDB.
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 2 of the License, or
9
   (at your option) any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program; if not, write to the Free Software
18
   Foundation, Inc., 59 Temple Place - Suite 330,
19
   Boston, MA 02111-1307, USA.  */
20
 
21
#ifndef TM_OR1K_H
22
#define TM_OR1K_H
23
 
24
#ifndef TARGET_OR1K
25
#define TARGET_OR1K
26
#endif
27
 
28 122 markom
#include "defs.h"
29 126 chris
#include <inttypes.h>  /* CZ */
30 122 markom
 
31 106 markom
struct value;
32
 
33
struct struct_or1k_implementation
34
  {
35
    /* Implementation version.  */
36
    unsigned int VR;
37
    /* Units present.  */
38
    unsigned int UPR;
39
    /* Number of total available matchpoints in this implementation.  */
40
    unsigned int num_matchpoints;
41 113 markom
    /* Number of currently used matchpoints.  */
42
    unsigned int num_used_matchpoints;
43 115 markom
    /* Has watchpoint driven counters.  */
44
    int has_counters;
45 106 markom
    /* Number of registers.  */
46
    unsigned int num_gpr_regs;
47 115 markom
    unsigned int num_vfpr_regs;
48
    /* Is there any vf support?  */
49 106 markom
    int vf_present;
50
 };
51
 
52
struct or1k_target_ops
53
  {
54
    /* Name this target type.  */
55
    char *to_shortname;
56
 
57
    /* Init target.  */
58
    void (*to_init) PARAMS ((char *args));
59
    /* Destruct target.  */
60
    void (*to_done) PARAMS ((void));
61
 
62 113 markom
    /* Read register.
63
       Does not fail, places error no. in err instead or call error(), if fatal.  */
64 122 markom
    ULONGEST (*to_read_reg) PARAMS ((unsigned int regno));
65 113 markom
    /* Write register.
66
       Does not fail, places error no. in err instead or call error(), if fatal.  */
67 122 markom
    void (*to_write_reg) PARAMS ((unsigned int regno, ULONGEST value));
68 106 markom
 
69 146 chris
    /* Read a block...possibly more efficient than several isolated
70
       call to read_reg...worst case the same efficiency. Returns 0
71
       on success or errno if a failure occurred. */
72
    int (*to_read_block) PARAMS ((unsigned int regno, void* block, int nRegisters));
73
 
74
    /* Write a block...possibly more efficient than several isolated
75
       call to write_reg...worst case the same efficiency. Returns 0
76
       on success or errno if a failure occurred. */
77
    int (*to_write_block) PARAMS ((unsigned int regno, void* block, int nRegisters));
78
 
79 113 markom
    /* Selects scan chain.  All register accesses are related to current scan chain.
80
       Does not fail, places error no. in err instead or call error(), if fatal.
81
       See jtag_chains enum.  */
82
    void (*to_set_chain) PARAMS ((int chain));
83 106 markom
 
84
    /* Executes extended command on the target.  */
85
    void (*to_exec_command) PARAMS ((char *args, int from_tty));
86
 
87
    /* Associated target_ops.  */
88
    struct target_ops *gdb_ops;
89
    /* Should be OPS_MAGIC. */
90
    int to_magic;
91
  };
92
 
93
 
94
#define DEFAULT_PROMPT "(or1k) "
95
 
96 113 markom
/* Context stuff. */
97
#define CURRENT_CID (0)
98
#define MAX_CID     (15)
99
 
100
 
101
/* Instruction definitions. */
102
#define BRK_INSTR_STRUCT {0x21, 0x00, 0x00, 0x00}
103
#define NOP_INSTR (0x15000000)
104
 
105 106 markom
/* Special purpose regisers.  */
106 113 markom
#define SPR_GROUP_SIZE_BITS (11)
107 106 markom
#define SPR_GROUP_SIZE (1 << SPR_GROUP_SIZE_BITS)
108
#define SPR_SYSTEM_GROUP (0)
109
#define SPR_DEBUG_GROUP (6)
110 115 markom
#define SPR_GPR_START  (1024)
111
#define SPR_VFPR_START ((MAX_CID + 1) * MAX_GPR_REGS + SPR_GPR_START)
112
#define OR1K_NUM_SPR_GROUPS (12)
113 106 markom
 
114
/* Define register values.  */
115
#define SPR_REG(group, index) (((group) << SPR_GROUP_SIZE_BITS) + (index))
116
 
117 115 markom
#define VR_SPRNUM SPR_REG(SPR_SYSTEM_GROUP, 0)
118
#define UPR_SPRNUM SPR_REG(SPR_SYSTEM_GROUP, 1)
119
#define CPUCFGR_SPRNUM SPR_REG(SPR_SYSTEM_GROUP, 2)
120
#define DCFGR_SPRNUM SPR_REG(SPR_SYSTEM_GROUP, 7)
121
#define PC_SPRNUM SPR_REG(SPR_SYSTEM_GROUP, 16)
122
#define SR_SPRNUM SPR_REG(SPR_SYSTEM_GROUP, 17)
123 113 markom
#define CCR_SPRNUM(cid) SPR_REG(SPR_SYSTEM_GROUP, 4 + (cid))
124 115 markom
#define DVR0_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 32)
125
#define DCR0_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 40)
126
#define DMR1_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 48)
127
#define DMR2_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 49)
128
#define DCWR0_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 50)
129
#define DCWR1_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 51)
130
#define DSR_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 52)
131
#define DRR_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 53)
132
#define DIR_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 54)
133 106 markom
#define ZERO_REGNUM (0)
134
#define SP_REGNUM (1)
135
#define FP_REGNUM (2)
136
#define A0_REGNUM (3)
137
#define A5_REGNUM (8)
138
#define LR_REGNUM (9)
139
#define RV_REGNUM (11)
140 113 markom
#define VFA0_REGNUM (MAX_GPR_REGS + 0)
141
#define VFA5_REGNUM (MAX_GPR_REGS + 5)
142
#define VFRV_REGNUM (MAX_GPR_REGS + 6)
143
#define PC_REGNUM (MAX_GPR_REGS + MAX_VF_REGS + 0)
144
#define PS_REGNUM (MAX_GPR_REGS + MAX_VF_REGS + 1)
145
#define CCR_REGNUM (MAX_GPR_REGS + MAX_VF_REGS + 2)
146 106 markom
 
147
extern int or1k_regnum_to_sprnum PARAMS ((int regno));
148
#define REGNUM_TO_SPRNUM(regno) (or1k_regnum_to_sprnum(regno))
149
 
150
/* Defines for SPR bits.  */
151
#define DMR1_ST    (0x00400000)
152
 
153 136 chris
/* Changed by CZ 21/06/01 */
154
#define DRR_BE     (0x00001000)
155
#define DRR_SCE    (0x00000800)
156
#define DRR_RE     (0x00000400)
157
#define DRR_IME    (0x00000200)
158
#define DRR_DME    (0x00000100)
159
#define DRR_HPINTE (0x00000080)
160 106 markom
#define DRR_IIE    (0x00000040)
161 136 chris
#define DRR_AE     (0x00000020)
162
#define DRR_LPINTE (0x00000010)
163
#define DRR_IPFE   (0x00000008)
164
#define DRR_DPFE   (0x00000004)
165
#define DRR_BUSEE  (0x00000002)
166
#define DRR_RSTE   (0x00000001)
167 106 markom
 
168
/* Number of matchpoints */
169
#define NUM_MATCHPOINTS (or1k_implementation.num_matchpoints)
170 118 markom
#define MAX_MATCHPOINTS (8)
171 106 markom
 
172
/* Number of machine GPR registers */
173
#define NUM_GPR_REGS (or1k_implementation.num_gpr_regs)
174
#define MAX_GPR_REGS (32)
175
 
176
/* Number of machine VF registers */
177 116 markom
#define NUM_VF_REGS (or1k_implementation.num_vfpr_regs)
178 106 markom
#define MAX_VF_REGS (32)
179
 
180
/* gdb mapping of registers */
181
#ifndef NUM_REGS
182
#define NUM_REGS (MAX_GPR_REGS+MAX_VF_REGS+3)
183
#endif
184
 
185
/* Can act like a little or big endian.  */
186
#if !defined (TARGET_BYTE_ORDER_DEFAULT)
187
#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN
188
#define TARGET_BYTE_ORDER_SELECTABLE_P (1)
189
#endif
190
 
191
/* Size (in bytes) of registers.  */
192
#define OR1K_SPR_REGSIZE (4)
193
#define OR1K_VF_REGSIZE (8)
194
#define OR1K_GPR_REGSIZE ((OR1K_64BIT_IMPLEMENTATION)?(8):(4))
195 113 markom
#define OR1K_VF_DOUBLE (0)
196 106 markom
 
197 113 markom
#define OR1K_IS_GPR(N) ((N) >= 0 && (N) < MAX_GPR_REGS)
198
#define OR1K_IS_VF(N) ((N) >= MAX_GPR_REGS && (N) < MAX_GPR_REGS + MAX_VF_REGS)
199 106 markom
 
200
/* Register representation is the same as in memory.  */
201
#define REGISTER_CONVERTIBLE(N) (0)
202
 
203
/* Given the register index, return the name of the corresponding
204
   register. */
205
extern char *or1k_register_name PARAMS ((int regno));
206
#define REGISTER_NAME(regno) or1k_register_name (regno)
207
 
208
/* Is this implementation 64 or 32 bit.
209
   WARNING: gdb or1k port is not yet prepared for 64b implementations!  */
210
#define OR1K_64BIT_IMPLEMENTATION 0
211
 
212
/* Number of bytes of storage in the actual machine representation for
213
   register N.  NOTE: This indirectly defines the register size
214
   transfered by the GDB protocol.  If we have 64bit processor
215
   implementation, GPR register raw size is 8B, otherwise 4B.  */
216
#define REGISTER_RAW_SIZE(N) ((OR1K_IS_GPR(N)?((OR1K_64BIT_IMPLEMENTATION)?\
217
(8):(4)):(OR1K_SPR_REGSIZE)))
218
 
219
/* Number of bytes of storage in the program's representation
220
   for register N. Same as RAW_SIZE.  */
221
#define REGISTER_VIRTUAL_SIZE(N) TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (N))
222
 
223
/* Return the GDB type object for the "standard" data type of data in
224
   register N.  */
225
#define REGISTER_VIRTUAL_TYPE(N) ((OR1K_IS_GPR(N))?(\
226 113 markom
(OR1K_64BIT_IMPLEMENTATION)?builtin_type_int64:builtin_type_int\
227
):(OR1K_IS_VF(N) ? builtin_type_float : builtin_type_uint32))
228 106 markom
 
229
/* Largest value REGISTER_RAW_SIZE can have.  */
230
#define MAX_REGISTER_RAW_SIZE ((OR1K_64BIT_IMPLEMENTATION)?(8):(4))
231
 
232
/* Largest value REGISTER_VIRTUAL_SIZE can have.  */
233
#define MAX_REGISTER_VIRTUAL_SIZE ((OR1K_64BIT_IMPLEMENTATION)?(8):(4))
234
 
235
#define REGISTER_SIZE (MAX_REGISTER_VIRTUAL_SIZE)
236
 
237
/* ABI uses R3 through R8 for args.  */
238
#define OR1K_LAST_ARG_REGNUM (A5_REGNUM)
239
#define OR1K_NUM_ARG_REGS (6)
240 118 markom
 
241 106 markom
/* ABI uses VFR0 through VFR5 for float args.  */
242
#define OR1K_LAST_FP_ARG_REGNUM (VFA5_REGNUM)
243
#define OR1K_NUM_FP_ARG_REGS (6)
244
 
245
/* Should not store into R0.  */
246
#define CANNOT_STORE_REGISTER(N) ((N) == 0)
247
 
248
/* Index within `registers' of the first byte of the space for
249
   register N.  */
250
#define REGISTER_BYTE(N) ((N) * OR1K_SPR_REGSIZE)
251
 
252
/* Total amount of space needed to store our copies of the machine's
253
   register state, the array `registers'.  */
254
#define REGISTER_BYTES (NUM_REGS * OR1K_SPR_REGSIZE)
255
 
256 113 markom
extern void or1k_do_registers_info PARAMS ((int, int));
257
#define DO_REGISTERS_INFO(regnum, fp) or1k_do_registers_info(regnum, fp)
258
 
259
 
260
 
261 106 markom
/* BREAKPOINT_FROM_PC uses the program counter value to determine whether a
262
   16- or 32-bit breakpoint should be used.  It returns a pointer
263
   to a string of bytes that encode a breakpoint instruction, stores
264
   the length of the string to *lenptr, and adjusts the pc (if necessary) to
265
   point to the actual memory location where the breakpoint should be
266
   inserted.  */
267
extern unsigned char *or1k_breakpoint_from_pc PARAMS ((CORE_ADDR *bp_addr, int *bp_size));
268
#define BREAKPOINT_FROM_PC(pcptr, lenptr) or1k_breakpoint_from_pc (pcptr, lenptr)
269
 
270
/* Amount PC must be decremented by after a breakpoint.
271
   This is often the number of bytes in BREAKPOINT
272
   but not always.  */
273
#define DECR_PC_AFTER_BREAK 0
274
 
275
/* Amount PC must be decremented by after a breakpoint.
276
   This is often the number of bytes in BREAKPOINT
277
   but not always.  */
278
#define DECR_PC_AFTER_BREAK 0
279
 
280 113 markom
extern int or1k_insert_breakpoint (CORE_ADDR addr, char *contents_cache);
281
#define target_insert_hw_breakpoint(addr, cache) or1k_insert_breakpoint (addr, cache)
282
 
283
extern int or1k_remove_breakpoint (CORE_ADDR addr, char *contents_cache);
284
#define target_remove_hw_breakpoint(addr, cache) or1k_remove_breakpoint (addr, cache)
285
 
286
/* Watchpoint support.  */
287
#define TARGET_HAS_HARDWARE_WATCHPOINTS
288
 
289
/* Use these macros for watchpoint insertion/deletion.  */
290
/* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */
291
extern int or1k_insert_watchpoint PARAMS ((CORE_ADDR addr, int len, int type));
292
#define target_insert_watchpoint(addr, len, type) \
293
        or1k_insert_watchpoint (addr, len, type)
294
 
295
extern int or1k_insert_watchpoint PARAMS ((CORE_ADDR addr, int len, int type));
296
#define target_remove_watchpoint(addr, len, type) \
297
        or1k_remove_watchpoint (addr, len, type)
298
 
299
/* We need to remove watchpoints when stepping, else we hit them again! */
300
#define HAVE_NONSTEPPABLE_WATCHPOINT
301
 
302
extern int or1k_stopped_by_watchpoint PARAMS ((void));
303
#define STOPPED_BY_WATCHPOINT(w) or1k_stopped_by_watchpoint ()
304
 
305
typedef enum bptype;
306
extern int or1k_can_use_hardware_watchpoint PARAMS ((enum bptype, int));
307
#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(bp_type, cnt, ot) \
308
  or1k_can_use_hardware_watchpoint(bp_type, cnt)
309
 
310
 
311
/* Catchpoint support.  */
312
/* HACK: how do we hook to signal namings otherwise? */
313
#include "target.h"
314
extern char *target_signal_to_string PARAMS ((enum target_signal));
315 118 markom
 
316 113 markom
/* Return the name (SIGHUP, etc.) for a signal.  */
317
extern char *or1k_signal_to_name PARAMS ((enum target_signal));
318 118 markom
 
319 113 markom
/* Given a name (SIGHUP, etc.), return its signal.  */
320
extern enum target_signal or1k_signal_from_name PARAMS ((char *));
321
 
322
#define NUM_OR1K_SIGNALS (10)
323
 
324 106 markom
/* Extract from an array REGBUF containing the (raw) register state
325
   a function return value of type TYPE, and copy that, in virtual format,
326
   into VALBUF.  */
327
extern void or1k_extract_return_value PARAMS ((struct type *, char[], char *));
328
#define EXTRACT_RETURN_VALUE(TYPE, REGBUF, VALBUF) \
329
  or1k_extract_return_value (TYPE, REGBUF, VALBUF)
330
 
331
/* Write into appropriate registers a function return value
332
   of type TYPE, given in virtual format.  */
333
#define STORE_RETURN_VALUE(TYPE,VALBUF) \
334
  {\
335
    if (TYPE_CODE (TYPE) == TYPE_CODE_FLT)\
336
      write_register_bytes (REGISTER_BYTE (VFRV_REGNUM), VALBUF, TYPE_LENGTH (TYPE));\
337
    else\
338
      write_register_bytes (REGISTER_BYTE (RV_REGNUM), VALBUF, TYPE_LENGTH (TYPE));\
339
  }
340
 
341
/* Extract from an array REGBUF containing the (raw) register state
342
   the address in which a function should return its structure value,
343
   as a CORE_ADDR (or an expression that can be used as one).  */
344
/* The address is passed in a0 upon entry to the function, but when
345
   the function exits, the compiler has copied the value to v0.  This
346
   convention is specified by the System V ABI, so I think we can rely
347
   on it.  */
348
#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
349
  (extract_address (REGBUF + REGISTER_BYTE (RV_REGNUM), \
350
                    REGISTER_RAW_SIZE (RV_REGNUM)))
351
 
352
#define EXTRACT_STRUCT_VALUE_ADDRESS_P 1
353
 
354
/* Advance PC across any function entry prologue instructions
355
   to reach some "real" code.  */
356
extern CORE_ADDR or1k_skip_prologue PARAMS ((CORE_ADDR addr));
357
#define SKIP_PROLOGUE(pc) (or1k_skip_prologue (pc))
358
 
359
/* FRAMES */
360
#define FRAME_ARGS_ADDRESS(fi)  (fi)->frame
361
 
362
#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame
363
 
364
/* FRAME_CHAIN takes a frame's nominal address
365
   and produces the frame's chain-pointer. */
366
#define FRAME_CHAIN(thisframe) (CORE_ADDR) or1k_frame_chain (thisframe)
367
extern CORE_ADDR or1k_frame_chain PARAMS ((struct frame_info *));
368
 
369
/* Discard from the stack the innermost frame, restoring all registers.  */
370
extern void or1k_pop_frame PARAMS ((void));
371
#define POP_FRAME or1k_pop_frame()
372
 
373
 
374
/* Return number of args passed to a frame.
375
   Can return -1, meaning no way to tell.  */
376
#define FRAME_NUM_ARGS(fi)      (-1)
377
 
378
/* Return number of bytes at start of arglist that are not really args.  */
379
#define FRAME_ARGS_SKIP 0
380
 
381
/* Put here the code to store, into a struct frame_saved_regs,
382
   the addresses of the saved registers of frame described by FRAME_INFO.
383
   This includes special registers such as pc and fp saved in special
384
   ways in the stack frame.  sp is even more special:
385
   the address we return for it IS the sp for the next frame.  */
386
extern void or1k_init_saved_regs PARAMS ((struct frame_info *));
387
#define FRAME_INIT_SAVED_REGS(frame_info) or1k_init_saved_regs (frame_info);
388
 
389
/* Saved Pc.  */
390
extern CORE_ADDR or1k_frame_saved_pc PARAMS ((struct frame_info *));
391
#define FRAME_SAVED_PC(FRAME) (or1k_frame_saved_pc(FRAME))
392
 
393
/* Set the return address register to point to the entry
394
   point of the program, where a breakpoint lies in wait.  */
395
extern CORE_ADDR or1k_push_return_address PARAMS ((CORE_ADDR pc, CORE_ADDR sp));
396
#define PUSH_RETURN_ADDRESS(PC, SP) (or1k_push_return_address ((PC), (SP)))
397
 
398
/* Immediately after a function call, return the saved pc.
399
   Can't always go through the frames for this because on some machines
400
   the new frame is not set up until the new function executes
401
   some instructions.  */
402
#define SAVED_PC_AFTER_CALL(frame)      read_register(LR_REGNUM)
403
 
404
/* Offset from address of function to start of its code.
405
   Zero on most machines.  */
406
#define FUNCTION_START_OFFSET (0)
407
 
408
/* Floating point is IEEE compliant */
409
#define IEEE_FLOAT
410
 
411
/* Is floating/vector unit present.  */
412
#define OR1K_VF_PRESENT (or1k_implementation.vf_present)
413
 
414
#define INIT_FRAME_PC           /* Not necessary */
415
 
416
/* Stack grows downward.  */
417
#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
418
 
419
/* Size of stack entry - in bytes.  */
420
#define OR1K_STACK_ALIGN (8)
421 118 markom
 
422 106 markom
/* Maximum struct size, that is still stored onto stack.  */
423
#define OR1K_STRUCT_CONV_SIZE (8)
424
#define STACK_ALIGN(addr) OR1K_STACK_ALIGN
425
 
426
#define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > OR1K_STRUCT_CONV_SIZE)
427
 
428
/* Stack must be aligned on 32-bit boundaries when synthesizing
429
   function calls. PUSH_ARGUMENTS will handle it. */
430
extern CORE_ADDR or1k_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR));
431
#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
432
(or1k_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
433
 
434
/* Return non-zero if PC points to an instruction which will cause a step
435
   to execute both the instruction at PC and an instruction at PC+4.  */
436
extern int or1k_step_skips_delay PARAMS ((CORE_ADDR));
437
#define STEP_SKIPS_DELAY_P (1)
438
#define STEP_SKIPS_DELAY(pc) (or1k_step_skips_delay (pc))
439
 
440
/* DUMMY CALLS */
441
#define USE_GENERIC_DUMMY_FRAMES 1
442
#define CALL_DUMMY                   {0}
443
#define CALL_DUMMY_START_OFFSET      (0)
444
#define CALL_DUMMY_BREAKPOINT_OFFSET (0)
445
#define SIZEOF_CALL_DUMMY_WORDS      (0)
446
#define CALL_DUMMY_LOCATION          AT_ENTRY_POINT
447
#define FIX_CALL_DUMMY(DUMMY, START, FUNADDR, NARGS, ARGS, TYPE, GCCP) 
448
 
449
/* Return a location where we can set a breakpoint that will be hit
450
   when an inferior function call returns.  This is normally the
451
   program's entry point.  */
452
#define CALL_DUMMY_ADDRESS()         entry_point_address ()
453
#define SAVE_DUMMY_FRAME_TOS(SP)     generic_save_dummy_frame_tos (SP)
454
#define PC_IN_CALL_DUMMY(PC, SP, FP) generic_pc_in_call_dummy (PC, SP, FP)
455
#define PUSH_DUMMY_FRAME             generic_push_dummy_frame ()
456
 
457
/* Definitions and declarations used by or1k dependent files.  */
458
#define OR1K_INSTLEN 4          /* Length of an instruction */
459
typedef unsigned long t_inst;   /* Integer big enough to hold an instruction */
460
 
461
 
462
 
463
/* Defined in remote-or1k.c */
464
 
465
/* Target state names.  */
466
extern const char *status_name[];
467 118 markom
 
468 106 markom
/* Target state.  */
469
enum target_status
470
  {
471
    TARGET_UNDEFINED,
472
    TARGET_CONNECTING,
473
    TARGET_DISCONNECTING,
474
    TARGET_RUNNING,
475
    TARGET_STOPPED
476
  };
477
 
478
#define REG_SPACE 0x00000000
479
#define REG_SPACE_END 0x7FFFFFFF
480
#define MEM_SPACE 0x80000000
481
#define MEM_SPACE_END 0xFFFFFFFF
482
 
483
/* Compare conditions for DCRx registers.  */
484
enum enum_compare_condition
485
  {
486 118 markom
    CC_MASKED, CC_EQUAL, CC_LESS, CC_LESSE, CC_GREAT, CC_GREATE, CC_NEQUAL
487 106 markom
  };
488
 
489
/* Compare operand to compare DVRx to.  */
490
enum enum_compare_to
491
  {
492 119 markom
    CT_DISABLED, CT_FETCH, CT_LEA, CT_SEA, CT_LDATA, CT_SDATA, CT_AEA, CT_ADATA
493 106 markom
  };
494
 
495 118 markom
/* Matchpoint chaining types.  */
496
enum enum_chaining
497
  {
498
    CHAINING_NONE, CHAINING_AND, CHAINING_OR
499
  };
500 106 markom
 
501 118 markom
/* Names for cts.  */
502
#define NUM_CT_NAMES 8
503
extern const char *compare_to_names[NUM_CT_NAMES];
504
 
505 106 markom
/* DRCx struct */
506
struct dcr_struct
507
  {
508 113 markom
    enum enum_compare_to ct:3;
509
    unsigned int sc:1;
510 106 markom
    enum enum_compare_condition cc:3;
511 113 markom
    unsigned int dp:1;
512 106 markom
  };
513
 
514 118 markom
/* All data needed for a matchpoint.  */
515
struct matchpoint
516
  {
517
    struct dcr_struct dcr;
518
    unsigned int dvr;
519
    unsigned int chain_type;
520
    unsigned int cause_breakpoint;
521
  };
522
 
523
/* Trace related structures and data.  */
524
#define TRACE_FILENAME_SIZE (128)
525
extern char trace_filename[TRACE_FILENAME_SIZE];
526
#define TRACE_FILENAME (&trace_filename[0])
527
#define TRACE_DATA_SIZE (sizeof(struct htrace_data_struct))
528
 
529
struct htrace_data_struct
530
  {
531
    unsigned int unused:24;
532
    unsigned int data:32;
533
    unsigned int type:4;
534
    unsigned int reserved:3;
535
    unsigned int valid:1;
536
  };
537
 
538
enum enum_operation
539
  {
540
    TRIGOP_ANY, TRIGOP_OR, TRIGOP_AND
541
  };
542
 
543
struct htrace_event_struct
544
  {
545
    enum enum_operation operation:2;
546
    unsigned int reserved1:6;
547
    unsigned int is_valid:1;
548
    unsigned int is_trig:2;
549
    unsigned int ls_valid:1;
550
    unsigned int ls_trig:4;
551
    unsigned int reserved2:2;
552
    unsigned int bp_valid:1;
553
    unsigned int bp_trig:1;
554
    unsigned int wp_valid:1;
555
    unsigned int wp_trig:11;
556
  };
557
 
558
struct htrace_record_struct
559
  {
560
    unsigned int reserved:25;
561
    unsigned int rec:7;
562
  };
563
 
564
struct htrace_moder_struct
565
  {
566
    unsigned int reserved:29;
567
    unsigned int rec_sel_dep:1;
568
    unsigned int trace_enable:1;
569
    unsigned int contin:1;
570
  };
571
 
572
/* Number of records as defined in TAP.  */
573
#define NUM_RECORDS (8)
574
 
575
struct htrace_struct
576
  {
577
    /* Local copy of HW regs for trace.  */
578
    struct htrace_event_struct trig, qual, stop;
579
    struct htrace_record_struct recwp[MAX_MATCHPOINTS], recbp;
580
    struct htrace_moder_struct moder;
581
    /* Which matchpoints does record use?  Bitmask.  */
582
    unsigned int wp_record_uses[MAX_MATCHPOINTS];
583
  };
584
 
585
extern struct htrace_struct or1k_htrace;
586
extern int trace_size;
587
 
588
#define MAX_RECORD_NAMES 7
589
extern const char *or1k_record_names[MAX_RECORD_NAMES];
590
#define MAX_IS_NAMES 4
591
extern const char *or1k_is_names[MAX_IS_NAMES];
592
#define MAX_LS_NAMES 16
593
extern const char *or1k_ls_names[MAX_LS_NAMES];
594
 
595
/* Stuff for HW watches.  */
596
#define MAX_HW_WATCHES MAX_MATCHPOINTS
597
 
598
struct hwatch_struct
599
  {
600
    int matchpoint_start;
601
  };
602
 
603
extern int num_hw_watches;
604
extern struct hwatch_struct or1k_hwatch[MAX_HW_WATCHES];
605
 
606 106 markom
/* Possible errors are listed here.  */
607 126 chris
enum enum_errors  /* modified <chris@asics.ws> CZ 24/05/01 */
608
{
609
  /* Codes > 0 are for system errors */
610 106 markom
 
611 126 chris
  ERR_NONE = 0,
612
  ERR_CRC = -1,
613 146 chris
  ERR_MEM = -2,
614
  JTAG_PROXY_INVALID_COMMAND = -3,
615
  JTAG_PROXY_SERVER_TERMINATED = -4,
616
  JTAG_PROXY_NO_CONNECTION = -5,
617
  JTAG_PROXY_PROTOCOL_ERROR = -6,
618
  JTAG_PROXY_COMMAND_NOT_IMPLEMENTED = -7,
619
  JTAG_PROXY_INVALID_CHAIN = -8,
620
  JTAG_PROXY_INVALID_ADDRESS = -9,
621
  JTAG_PROXY_ACCESS_EXCEPTION = -10, /* Write to ROM */
622
  JTAG_PROXY_INVALID_LENGTH = -11,
623
  JTAG_PROXY_OUT_OF_MEMORY = -12,
624 126 chris
};
625
 
626 118 markom
/* All JTAG chains.  */
627 113 markom
enum jtag_chains
628
  {
629
    SC_GLOBAL,      /* 0 Global BS Chain */
630
    SC_RISC_DEBUG,  /* 1 RISC Debug Interface chain */
631
    SC_RISC_TEST,   /* 2 RISC Test Chain */
632
    SC_TRACE,       /* 3 Trace Chain */
633
    SC_REGISTER,    /* Register Chain */
634
    SC_BLOCK,       /* Block Chains */
635
  };
636
 
637 118 markom
/* See JTAG documentation about these.  */
638
#define JI_SIZE (4)
639
enum jtag_instr
640
  {
641
    JI_EXTEST,
642
    JI_SAMPLE_PRELOAD,
643
    JI_IDCODE,
644
    JI_CHAIN_SELECT,
645
    JI_INTEST,
646
    JI_CLAMP,
647
    JI_CLAMPZ,
648
    JI_HIGHZ,
649
    JI_DEBUG,
650
    JI_BYPASS = 0xF
651
  };
652
 
653 113 markom
/* JTAG registers.  */
654 118 markom
#define JTAG_MODER  (0x0)
655
#define JTAG_TSEL   (0x1)
656
#define JTAG_QSEL   (0x2)
657
#define JTAG_SSEL   (0x3)
658 113 markom
#define JTAG_RISCOP (0x9)
659 118 markom
#define JTAG_RECWP0 (0x10)
660
#define JTAG_RECBP0 (0x1b)
661 113 markom
 
662 118 markom
 
663
/* Current register values.  */
664
extern unsigned int dmr1;
665
extern unsigned int dmr2;
666
extern unsigned int dsr;
667
extern unsigned int drr;
668
 
669
extern int matchpoint_user_count[MAX_MATCHPOINTS];
670
 
671
/* Current watchpoints.  */
672
extern unsigned int dvr[MAX_MATCHPOINTS];
673
extern struct dcr_struct dcr[MAX_MATCHPOINTS];
674
extern int debug_regs_changed;
675
 
676
/* Returns error name.  */
677 106 markom
extern const char *or1k_err_name PARAMS ((int e));
678
 
679 118 markom
/* Last error number.  */
680
extern int err;
681
 
682 106 markom
extern struct struct_or1k_implementation or1k_implementation;
683
extern unsigned int or1k_fetch_instruction PARAMS ((CORE_ADDR addr));
684
extern void or1k_fetch_registers PARAMS ((int regno));
685
 
686
/* Sets register/memory regno to data.  */
687 113 markom
extern void or1k_write_spr_reg PARAMS ((unsigned int regno, unsigned int data));
688 106 markom
 
689
/* Sets register/memory regno to data.  */
690 113 markom
extern unsigned int or1k_read_spr_reg PARAMS ((unsigned int regno));
691 106 markom
 
692 118 markom
/* Flushes or1k's pipeline.  */
693 113 markom
extern void or1k_flush_pipeline PARAMS ((void));
694
 
695 118 markom
/* Sifts unused matchpoints to higher indexses.  */
696
extern void sift_matchpoints ();
697
 
698 126 chris
 
699
/* Added by Chris Ziomkowski <chris@asics.ws> 24/05/01 */
700
typedef enum {
701
  JTAG_COMMAND_READ = 1,
702
  JTAG_COMMAND_WRITE = 2,
703 146 chris
  JTAG_COMMAND_BLOCK_READ = 3,
704
  JTAG_COMMAND_BLOCK_WRITE = 4,
705
  JTAG_COMMAND_CHAIN = 5,
706 126 chris
} JTAG_proxy_protocol_commands;
707
 
708
/* Each transmit structure must begin with an integer
709
   which specifies the type of command. Information
710
   after this is variable. Make sure to have all information
711
   aligned properly. If we stick with 32 bit integers, it
712
   should be portable onto every platform. These structures
713
   will be transmitted across the network in network byte
714
   order.
715
*/
716
 
717
typedef struct {
718
  uint32_t command;
719
  uint32_t length;
720
  uint32_t address;
721
  uint32_t data_H;
722
  uint32_t data_L;
723
} JTAGProxyWriteMessage;
724
 
725
typedef struct {
726
  uint32_t command;
727
  uint32_t length;
728
  uint32_t address;
729
} JTAGProxyReadMessage;
730
 
731
typedef struct {
732
  uint32_t command;
733
  uint32_t length;
734 146 chris
  uint32_t address;
735
  int32_t  nRegisters;
736
  uint32_t data[1];
737
} JTAGProxyBlockWriteMessage;
738
 
739
typedef struct {
740
  uint32_t command;
741
  uint32_t length;
742
  uint32_t address;
743
  int32_t  nRegisters;
744
} JTAGProxyBlockReadMessage;
745
 
746
typedef struct {
747
  uint32_t command;
748
  uint32_t length;
749 126 chris
  uint32_t chain;
750
} JTAGProxyChainMessage;
751
 
752
/* The responses are messages specific, however convention
753
   states the first word should be an error code. Again,
754
   sticking with 32 bit integers should provide maximum
755
   portability. */
756
 
757
typedef struct {
758
  int32_t status;
759
} JTAGProxyWriteResponse;
760
 
761
typedef struct {
762
  int32_t status;
763
  uint32_t data_H;
764
  uint32_t data_L;
765
} JTAGProxyReadResponse;
766
 
767
typedef struct {
768
  int32_t status;
769 146 chris
} JTAGProxyBlockWriteResponse;
770
 
771
typedef struct {
772
  int32_t status;
773
  int32_t nRegisters;
774
  uint32_t data[1];
775
  /* uint32_t data[nRegisters-1] still unread */
776
} JTAGProxyBlockReadResponse;
777
 
778
typedef struct {
779
  int32_t status;
780 126 chris
} JTAGProxyChainResponse;
781
 
782 146 chris
 
783 106 markom
#endif /* TM_OR1K_H */

powered by: WebSVN 2.1.0

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