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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [gdb-5.0/] [gdb/] [config/] [or1k/] [tm-or1k.h] - Blame information for rev 1778

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
struct value;
29
 
30
struct struct_or1k_implementation
31
  {
32
    /* Implementation version.  */
33
    unsigned int VR;
34
    /* Units present.  */
35
    unsigned int UPR;
36
    /* Number of total available matchpoints in this implementation.  */
37
    unsigned int num_matchpoints;
38
    /* Number of registers.  */
39
    unsigned int num_gpr_regs;
40
    unsigned int num_vf_regs;
41
    int vf_present;
42
 };
43
 
44
struct or1k_target_ops
45
  {
46
    /* Name this target type.  */
47
    char *to_shortname;
48
 
49
    /* Init target.  */
50
    void (*to_init) PARAMS ((char *args));
51
    /* Destruct target.  */
52
    void (*to_done) PARAMS ((void));
53
 
54
    /* Read SPR register.
55
       Does not fail, places error no. in err instead or call error().  */
56
    unsigned int (*to_read_spr_reg) PARAMS ((unsigned int regno));
57
    /* Write SPR register.
58
       Does not fail, places error no. in err instead or call error().  */
59
    void (*to_write_spr_reg) PARAMS ((unsigned int regno, unsigned int value));
60
 
61
    /* Read TAP register.
62
       Does not fail, places error no. in err instead or call error().  */
63
    unsigned int (*to_read_tap_reg) PARAMS ((unsigned int regno));
64
    /* Write TAP register.
65
       Does not fail, places error no. in err instead or call error().  */
66
    void (*to_write_tap_reg) PARAMS ((unsigned int regno, unsigned int value));
67
 
68
    /* Executes extended command on the target.  */
69
    void (*to_exec_command) PARAMS ((char *args, int from_tty));
70
 
71
    /* Associated target_ops.  */
72
    struct target_ops *gdb_ops;
73
    /* Should be OPS_MAGIC. */
74
    int to_magic;
75
  };
76
 
77
 
78
#define DEFAULT_PROMPT "(or1k) "
79
 
80
/* Special purpose regisers.  */
81
#define SPR_GROUP_SIZE_BITS (16)
82
#define SPR_GROUP_SIZE (1 << SPR_GROUP_SIZE_BITS)
83
#define SPR_SYSTEM_GROUP (0)
84
#define SPR_DEBUG_GROUP (6)
85
#define SPR_GPR  (24)
86
#define SPR_VFPR (24+32)
87
#define OR1K_NUM_SPR_GROUPS 11
88
 
89
/* Define register values.  */
90
#define SPR_REG(group, index) (((group) << SPR_GROUP_SIZE_BITS) + (index))
91
 
92
#define VR_SPRNUM SPR_REG(SPR_SYSTEM_GROUP, 1)
93
#define UPR_SPRNUM SPR_REG(SPR_SYSTEM_GROUP, 2)
94
#define SR_SPRNUM SPR_REG(SPR_SYSTEM_GROUP, 3)
95
#define CCR_SPRNUM(cid) SPR_REG(SPR_SYSTEM_GROUP, 4+cid)
96
#define DVR0_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 0)
97
#define DCR0_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 8)
98
#define DMR1_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 16)
99
#define DMR2_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 17)
100
#define DCWR0_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 18)
101
#define DCWR1_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 19)
102
#define DSR_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 20)
103
#define DRR_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 21)
104
#define PC_SPRNUM SPR_REG(SPR_DEBUG_GROUP, 22)
105
#define ZERO_REGNUM (0)
106
#define SP_REGNUM (1)
107
#define FP_REGNUM (2)
108
#define A0_REGNUM (3)
109
#define A5_REGNUM (8)
110
#define LR_REGNUM (9)
111
#define RV_REGNUM (11)
112
#define VFA0_REGNUM (32+0)
113
#define VFA5_REGNUM (32+5)
114
#define VFRV_REGNUM (32+6)
115
#define PC_REGNUM (64+0)
116
#define PS_REGNUM (64+1)
117
#define CCR_REGNUM (64+2)
118
 
119
extern int or1k_regnum_to_sprnum PARAMS ((int regno));
120
#define REGNUM_TO_SPRNUM(regno) (or1k_regnum_to_sprnum(regno))
121
 
122
/* Defines for SPR bits.  */
123
#define DMR1_ST    (0x00400000)
124
 
125
#define DRR_BE     (0x00000001)
126
#define DRR_SCE    (0x00000002)
127
#define DRR_RE     (0x00000004)
128
#define DRR_IME    (0x00000008)
129
#define DRR_DME    (0x00000010)
130
#define DRR_HPINTE (0x00000020)
131
#define DRR_IIE    (0x00000040)
132
#define DRR_AE     (0x00000080)
133
#define DRR_LPINTE (0x00000100)
134
#define DRR_IPFE   (0x00000200)
135
#define DRR_DPFE   (0x00000400)
136
#define DRR_BUSEE  (0x00000800)
137
#define DRR_RSTE   (0x00001000)
138
 
139
/* Number of matchpoints */
140
 
141
#define NUM_MATCHPOINTS (or1k_implementation.num_matchpoints)
142
 
143
/* Number of machine GPR registers */
144
 
145
#define NUM_GPR_REGS (or1k_implementation.num_gpr_regs)
146
#define MAX_GPR_REGS (32)
147
 
148
/* Number of machine VF registers */
149
 
150
#define NUM_VF_REGS (or1k_implementation.num_vf_regs)
151
#define MAX_VF_REGS (32)
152
 
153
/* gdb mapping of registers */
154
#ifndef NUM_REGS
155
#define NUM_REGS (MAX_GPR_REGS+MAX_VF_REGS+3)
156
#endif
157
 
158
/* Can act like a little or big endian.  */
159
 
160
#if !defined (TARGET_BYTE_ORDER_DEFAULT)
161
#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN
162
#define TARGET_BYTE_ORDER_SELECTABLE_P (1)
163
#endif
164
 
165
/* Size (in bytes) of registers.  */
166
 
167
#define OR1K_SPR_REGSIZE (4)
168
#define OR1K_VF_REGSIZE (8)
169
#define OR1K_GPR_REGSIZE ((OR1K_64BIT_IMPLEMENTATION)?(8):(4))
170
 
171
#define OR1K_IS_GPR(N) ((N) >= 0 && (N) < NUM_GPR_REGS)
172
#define OR1K_IS_VF(N) ((N) >= NUM_GPR_REGS && (N) < NUM_GPR_REGS + NUM_VF_REGS)
173
 
174
/* Register representation is the same as in memory.  */
175
 
176
#define REGISTER_CONVERTIBLE(N) (0)
177
 
178
/* Given the register index, return the name of the corresponding
179
   register. */
180
 
181
extern char *or1k_register_name PARAMS ((int regno));
182
#define REGISTER_NAME(regno) or1k_register_name (regno)
183
 
184
/* Is this implementation 64 or 32 bit.
185
   WARNING: gdb or1k port is not yet prepared for 64b implementations!  */
186
#define OR1K_64BIT_IMPLEMENTATION 0
187
 
188
/* Number of bytes of storage in the actual machine representation for
189
   register N.  NOTE: This indirectly defines the register size
190
   transfered by the GDB protocol.  If we have 64bit processor
191
   implementation, GPR register raw size is 8B, otherwise 4B.  */
192
#define REGISTER_RAW_SIZE(N) ((OR1K_IS_GPR(N)?((OR1K_64BIT_IMPLEMENTATION)?\
193
(8):(4)):(OR1K_SPR_REGSIZE)))
194
 
195
/* Number of bytes of storage in the program's representation
196
   for register N. Same as RAW_SIZE.  */
197
 
198
#define REGISTER_VIRTUAL_SIZE(N) TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (N))
199
 
200
/* Return the GDB type object for the "standard" data type of data in
201
   register N.  */
202
 
203
#ifndef REGISTER_VIRTUAL_TYPE
204
#define REGISTER_VIRTUAL_TYPE(N) ((OR1K_IS_GPR(N))?(\
205
(OR1K_64BIT_IMPLEMENTATION)?(builtin_type_int64):(builtin_type_int)\
206
):(builtin_type_uint32))
207
#endif
208
 
209
 
210
/* Largest value REGISTER_RAW_SIZE can have.  */
211
 
212
#define MAX_REGISTER_RAW_SIZE ((OR1K_64BIT_IMPLEMENTATION)?(8):(4))
213
 
214
/* Largest value REGISTER_VIRTUAL_SIZE can have.  */
215
 
216
#define MAX_REGISTER_VIRTUAL_SIZE ((OR1K_64BIT_IMPLEMENTATION)?(8):(4))
217
 
218
#define REGISTER_SIZE (MAX_REGISTER_VIRTUAL_SIZE)
219
 
220
/* ABI uses R3 through R8 for args.  */
221
#define OR1K_LAST_ARG_REGNUM (A5_REGNUM)
222
#define OR1K_NUM_ARG_REGS (6)
223
/* ABI uses VFR0 through VFR5 for float args.  */
224
#define OR1K_LAST_FP_ARG_REGNUM (VFA5_REGNUM)
225
#define OR1K_NUM_FP_ARG_REGS (6)
226
 
227
/* Should not store into R0.  */
228
 
229
#define CANNOT_STORE_REGISTER(N) ((N) == 0)
230
 
231
/* Index within `registers' of the first byte of the space for
232
   register N.  */
233
 
234
#define REGISTER_BYTE(N) ((N) * OR1K_SPR_REGSIZE)
235
 
236
/* Total amount of space needed to store our copies of the machine's
237
   register state, the array `registers'.  */
238
 
239
#define REGISTER_BYTES (NUM_REGS * OR1K_SPR_REGSIZE)
240
 
241
/* BREAKPOINT_FROM_PC uses the program counter value to determine whether a
242
   16- or 32-bit breakpoint should be used.  It returns a pointer
243
   to a string of bytes that encode a breakpoint instruction, stores
244
   the length of the string to *lenptr, and adjusts the pc (if necessary) to
245
   point to the actual memory location where the breakpoint should be
246
   inserted.  */
247
extern unsigned char *or1k_breakpoint_from_pc PARAMS ((CORE_ADDR *bp_addr, int *bp_size));
248
#define BREAKPOINT_FROM_PC(pcptr, lenptr) or1k_breakpoint_from_pc (pcptr, lenptr)
249
 
250
/* Amount PC must be decremented by after a breakpoint.
251
   This is often the number of bytes in BREAKPOINT
252
   but not always.  */
253
 
254
#define DECR_PC_AFTER_BREAK 0
255
 
256
/* Amount PC must be decremented by after a breakpoint.
257
   This is often the number of bytes in BREAKPOINT
258
   but not always.  */
259
 
260
#define DECR_PC_AFTER_BREAK 0
261
 
262
/* Extract from an array REGBUF containing the (raw) register state
263
   a function return value of type TYPE, and copy that, in virtual format,
264
   into VALBUF.  */
265
 
266
extern void or1k_extract_return_value PARAMS ((struct type *, char[], char *));
267
#define EXTRACT_RETURN_VALUE(TYPE, REGBUF, VALBUF) \
268
  or1k_extract_return_value (TYPE, REGBUF, VALBUF)
269
 
270
/* Write into appropriate registers a function return value
271
   of type TYPE, given in virtual format.  */
272
 
273
#define STORE_RETURN_VALUE(TYPE,VALBUF) \
274
  {\
275
    if (TYPE_CODE (TYPE) == TYPE_CODE_FLT)\
276
      write_register_bytes (REGISTER_BYTE (VFRV_REGNUM), VALBUF, TYPE_LENGTH (TYPE));\
277
    else\
278
      write_register_bytes (REGISTER_BYTE (RV_REGNUM), VALBUF, TYPE_LENGTH (TYPE));\
279
  }
280
 
281
/* Extract from an array REGBUF containing the (raw) register state
282
   the address in which a function should return its structure value,
283
   as a CORE_ADDR (or an expression that can be used as one).  */
284
/* The address is passed in a0 upon entry to the function, but when
285
   the function exits, the compiler has copied the value to v0.  This
286
   convention is specified by the System V ABI, so I think we can rely
287
   on it.  */
288
 
289
#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
290
  (extract_address (REGBUF + REGISTER_BYTE (RV_REGNUM), \
291
                    REGISTER_RAW_SIZE (RV_REGNUM)))
292
 
293
#define EXTRACT_STRUCT_VALUE_ADDRESS_P 1
294
 
295
/* Advance PC across any function entry prologue instructions
296
   to reach some "real" code.  */
297
extern CORE_ADDR or1k_skip_prologue PARAMS ((CORE_ADDR addr));
298
#define SKIP_PROLOGUE(pc) (or1k_skip_prologue (pc))
299
 
300
/* FRAMES */
301
 
302
#define FRAME_ARGS_ADDRESS(fi)  (fi)->frame
303
 
304
#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame
305
 
306
/* FRAME_CHAIN takes a frame's nominal address
307
   and produces the frame's chain-pointer. */
308
 
309
#define FRAME_CHAIN(thisframe) (CORE_ADDR) or1k_frame_chain (thisframe)
310
extern CORE_ADDR or1k_frame_chain PARAMS ((struct frame_info *));
311
 
312
/* Discard from the stack the innermost frame, restoring all registers.  */
313
 
314
extern void or1k_pop_frame PARAMS ((void));
315
#define POP_FRAME or1k_pop_frame()
316
 
317
 
318
/* Return number of args passed to a frame.
319
   Can return -1, meaning no way to tell.  */
320
 
321
#define FRAME_NUM_ARGS(fi)      (-1)
322
 
323
/* Return number of bytes at start of arglist that are not really args.  */
324
 
325
#define FRAME_ARGS_SKIP 0
326
 
327
/* Put here the code to store, into a struct frame_saved_regs,
328
   the addresses of the saved registers of frame described by FRAME_INFO.
329
   This includes special registers such as pc and fp saved in special
330
   ways in the stack frame.  sp is even more special:
331
   the address we return for it IS the sp for the next frame.  */
332
 
333
extern void or1k_init_saved_regs PARAMS ((struct frame_info *));
334
#define FRAME_INIT_SAVED_REGS(frame_info) or1k_init_saved_regs (frame_info);
335
 
336
/* Saved Pc.  */
337
 
338
extern CORE_ADDR or1k_frame_saved_pc PARAMS ((struct frame_info *));
339
#define FRAME_SAVED_PC(FRAME) (or1k_frame_saved_pc(FRAME))
340
 
341
/* Set the return address register to point to the entry
342
   point of the program, where a breakpoint lies in wait.  */
343
 
344
extern CORE_ADDR or1k_push_return_address PARAMS ((CORE_ADDR pc, CORE_ADDR sp));
345
#define PUSH_RETURN_ADDRESS(PC, SP) (or1k_push_return_address ((PC), (SP)))
346
 
347
/* Immediately after a function call, return the saved pc.
348
   Can't always go through the frames for this because on some machines
349
   the new frame is not set up until the new function executes
350
   some instructions.  */
351
 
352
#define SAVED_PC_AFTER_CALL(frame)      read_register(LR_REGNUM)
353
 
354
/* Offset from address of function to start of its code.
355
   Zero on most machines.  */
356
 
357
#define FUNCTION_START_OFFSET (0)
358
 
359
/* Floating point is IEEE compliant */
360
#define IEEE_FLOAT
361
 
362
/* Is floating/vector unit present.  */
363
#define OR1K_VF_PRESENT (or1k_implementation.vf_present)
364
 
365
#define INIT_FRAME_PC           /* Not necessary */
366
 
367
/* Stack grows downward.  */
368
#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
369
 
370
/* Size of stack entry - in bytes.  */
371
#define OR1K_STACK_ALIGN (8)
372
/* Maximum struct size, that is still stored onto stack.  */
373
#define OR1K_STRUCT_CONV_SIZE (8)
374
#define STACK_ALIGN(addr) OR1K_STACK_ALIGN
375
 
376
#define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > OR1K_STRUCT_CONV_SIZE)
377
 
378
/* Stack must be aligned on 32-bit boundaries when synthesizing
379
   function calls. PUSH_ARGUMENTS will handle it. */
380
extern CORE_ADDR or1k_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR));
381
#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
382
(or1k_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
383
 
384
/* Return non-zero if PC points to an instruction which will cause a step
385
   to execute both the instruction at PC and an instruction at PC+4.  */
386
extern int or1k_step_skips_delay PARAMS ((CORE_ADDR));
387
#define STEP_SKIPS_DELAY_P (1)
388
#define STEP_SKIPS_DELAY(pc) (or1k_step_skips_delay (pc))
389
 
390
/* DUMMY CALLS */
391
#define USE_GENERIC_DUMMY_FRAMES 1
392
#define CALL_DUMMY                   {0}
393
#define CALL_DUMMY_START_OFFSET      (0)
394
#define CALL_DUMMY_BREAKPOINT_OFFSET (0)
395
#define SIZEOF_CALL_DUMMY_WORDS      (0)
396
#define CALL_DUMMY_LOCATION          AT_ENTRY_POINT
397
#define FIX_CALL_DUMMY(DUMMY, START, FUNADDR, NARGS, ARGS, TYPE, GCCP) 
398
 
399
/* Return a location where we can set a breakpoint that will be hit
400
   when an inferior function call returns.  This is normally the
401
   program's entry point.  */
402
#define CALL_DUMMY_ADDRESS()         entry_point_address ()
403
#define SAVE_DUMMY_FRAME_TOS(SP)     generic_save_dummy_frame_tos (SP)
404
#define PC_IN_CALL_DUMMY(PC, SP, FP) generic_pc_in_call_dummy (PC, SP, FP)
405
#define PUSH_DUMMY_FRAME             generic_push_dummy_frame ()
406
 
407
/* Definitions and declarations used by or1k dependent files.  */
408
#define OR1K_INSTLEN 4          /* Length of an instruction */
409
typedef unsigned long t_inst;   /* Integer big enough to hold an instruction */
410
 
411
 
412
 
413
/* Defined in remote-or1k.c */
414
 
415
/* Target state names.  */
416
extern const char *status_name[];
417
/* Target state.  */
418
enum target_status
419
  {
420
    TARGET_UNDEFINED,
421
    TARGET_CONNECTING,
422
    TARGET_DISCONNECTING,
423
    TARGET_RUNNING,
424
    TARGET_STOPPED
425
  };
426
 
427
#define REG_SPACE 0x00000000
428
#define REG_SPACE_END 0x7FFFFFFF
429
#define MEM_SPACE 0x80000000
430
#define MEM_SPACE_END 0xFFFFFFFF
431
 
432
/* Compare conditions for DCRx registers.  */
433
 
434
enum enum_compare_condition
435
  {
436
    CC_MASKED, CC_EQUAL, CC_LESS, CC_LESSE, CC_GREATE, CC_NEQUAL
437
  };
438
 
439
/* Compare operand to compare DVRx to.  */
440
 
441
enum enum_compare_to
442
  {
443
    CT_DISABLED, CT_FETCH, CT_LEA, CT_SEA, CT_LDATA, CT_SDATA
444
  };
445
 
446
 
447
/* DRCx struct */
448
struct dcr_struct
449
  {
450
    int dp:1;
451
    enum enum_compare_condition cc:3;
452
    int sc:1;
453
    enum enum_compare_to ct:3;
454
  };
455
 
456
/* Possible errors are listed here.  */
457
 
458
enum enum_errors
459
  {
460
    ERR_NONE, ERR_CRC
461
  };
462
 
463
extern const char *or1k_err_name PARAMS ((int e));
464
 
465
extern struct struct_or1k_implementation or1k_implementation;
466
extern unsigned int or1k_fetch_instruction PARAMS ((CORE_ADDR addr));
467
extern void or1k_fetch_registers PARAMS ((int regno));
468
 
469
/* Sets register/memory regno to data.  */
470
extern void or1k_write_reg PARAMS ((unsigned int regno, unsigned int data));
471
 
472
/* Sets register/memory regno to data.  */
473
extern unsigned int or1k_read_reg PARAMS ((unsigned int regno));
474
extern int err;
475
 
476
#endif /* TM_OR1K_H */

powered by: WebSVN 2.1.0

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