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 362

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