summaryrefslogtreecommitdiff
path: root/gdb/arc-support.h
blob: 76ff0bfea360d9960e9c23efe5a8dac064e7c53a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* Target dependent code for ARC processor family, for GDB, the GNU debugger.

   Copyright 2008, 2009 Free Software Foundation, Inc.

   Contributed by ARC International (www.arc.com)

   Authors:
      Richard Stuckey <richard.stuckey@arc.com>

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/******************************************************************************/
/*                                                                            */
/* Outline:                                                                   */
/*     This header file defines some useful types and constants, and macros   */
/*     for use in debugging.                                                  */
/*                                                                            */
/******************************************************************************/

#ifndef ARC_SUPPORT_H
#define ARC_SUPPORT_H


#define ARC_DEBUG 1

#ifdef ARC_DEBUG
#define DEBUG(...)              if (arc_debug_target) fprintf_unfiltered(gdb_stdlog, __VA_ARGS__)
#define ENTERMSG                DEBUG("--- entered %s:%s()\n",        __FILE__, __FUNCTION__)
#define ENTERARGS(fmt, args...) DEBUG("--- entered %s:%s(" fmt ")\n", __FILE__, __FUNCTION__, args)
#define LEAVEMSG                DEBUG("--- exited  %s:%s()\n",        __FILE__, __FUNCTION__)
#else
#define DEBUG(...)
#define ENTERMSG
#define ENTERARGS(fmt, args...)
#define LEAVEMSG
#endif


/* N.B. it must be possible to build some ARC modules without the rest of gdb so
        that they can be exercised by stand-alone test drivers.  */
#ifdef STANDALONE_TEST
#define error(...)                    { printf(__VA_ARGS__); printf("\n"); }
#define warning(...)                  { printf(__VA_ARGS__); printf("\n"); }
#define printf_filtered(...)            printf(__VA_ARGS__)
#define printf_unfiltered(...)          printf(__VA_ARGS__)
#define fprintf_unfiltered(STR, ...)    printf(__VA_ARGS__)
#define internal_error(...)             abort()
#endif


/* Useful Boolean type and constants.  */
typedef int Boolean;

#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif


/* Useful types for machine-related quantities.

   N.B. the type ARC_RegisterNumber does not denote gdb register numbers;
        instead, it denotes ARC processor hardware numbers, which are not
        the same.  */

typedef unsigned int           ARC_RegisterNumber;
typedef unsigned int           ARC_RegisterContents;
typedef unsigned int           ARC_Address;
typedef unsigned long long int ARC_Doubleword;
typedef unsigned int           ARC_Word;
typedef unsigned short int     ARC_Halfword;
typedef unsigned char          ARC_Byte;


/* Types for machine-access functions.  */
typedef Boolean (*ReadRegisterFunction)(ARC_RegisterNumber    hw_regno,
                                        ARC_RegisterContents *contents,
                                        Boolean               warn_on_failure);

typedef Boolean (*WriteRegisterFunction)(ARC_RegisterNumber   hw_regno,
                                         ARC_RegisterContents contents,
                                         Boolean              warn_on_failure);


typedef unsigned int (*MemoryTransferFunction)(ARC_Address  address,
                                               ARC_Byte    *data,    /* May be not word-aligned.  */
                                               unsigned int amount);

typedef unsigned int (*MemoryFillFunction)    (ARC_Address  address,
                                               ARC_Word     pattern,
                                               unsigned int amount);

typedef struct
{
    ReadRegisterFunction   read_core_register;
    WriteRegisterFunction  write_core_register;
    ReadRegisterFunction   read_auxiliary_register;
    WriteRegisterFunction  write_auxiliary_register;
    MemoryTransferFunction read_memory;
    MemoryTransferFunction write_memory;
    MemoryFillFunction     fill_memory;
} TargetOperations;


/* Sizes of machine quantities.  */
#define BYTES_IN_WORD              4
#define BYTES_IN_REGISTER          4
#define BITS_IN_BYTE               8
#define BITS_IN_WORD              32
#define BITS_IN_ADDRESS           32
#define BITS_IN_REGISTER          32


/* Useful macros.  */
#define ELEMENTS_IN_ARRAY(arr)           (unsigned int) (sizeof(arr) / sizeof(arr[0]))

#define IS_WORD_ALIGNED(addr)  ((addr) % BYTES_IN_WORD == 0)


#endif /* ARC_SUPPORT_H */
/******************************************************************************/