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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [config/] [or1k/] [tm-or1k.h] - Blame information for rev 207

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