summaryrefslogtreecommitdiff
path: root/ecos/packages/cygmon/current/misc/monitor.h
blob: fe1a6192a5d1f736ad32d70e367895c582fac1db (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
//==========================================================================
//
//      monitor.h
//
//      Main definitions for the CygMON ROM monitor
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos 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 2 or (at your option) any later version.
//
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s):    
// Contributors: gthomas, dmoseley
// Date:         1999-10-20
// Purpose:      Main definitions for the CygMON ROM monitor
// Description:  
//               
//
//####DESCRIPTIONEND####
//
//=========================================================================

#ifndef MONITOR_H
#define MONITOR_H

#if !defined(__ASSEMBLER__)
#include <stdarg.h>
#endif

#include <board.h>
#ifdef HAVE_BSP
#include "cpu_info.h"
#endif
#include <monitor_cmd.h>

#ifdef __ECOS__
#include <cyg/hal/plf_stub.h>
#endif

#ifndef ASM

#ifdef HAVE_BSP
#define xprintf    bsp_dprintf
#define xsprintf   bsp_sprintf
#define xvprintf   bsp_dvprintf
#define xputchar   bsp_debug_putc
#define xgetchar   bsp_debug_getc
#define xungetchar bsp_debug_ungetc
#define __getTty() bsp_set_debug_comm(-1)
#define set_pc(x)  bsp_set_pc((x), mon_saved_regs)

#ifndef USE_ECOS_HAL_SINGLESTEP
#define __single_step()            bsp_singlestep_setup(mon_saved_regs)
#define __clear_single_step()      bsp_singlestep_cleanup(mon_saved_regs)
#endif /* USE_ECOS_HAL_SINGLESTEP */

#ifndef USE_ECOS_HAL_BREAKPOINTS
#define breakpoint() bsp_breakpoint()
#endif /* USE_ECOS_HAL_BREAKPOINTS */

#if defined(__ECOS__) && defined(CYGHWR_HAL_RESET_DEFINED)
   extern void __reset(void);
#else // defined(__ECOS__) && defined(CYGHWR_HAL_RESET_DEFINED)
#  define __reset    bsp_reset
#endif // defined(__ECOS__) && defined(CYGHWR_HAL_RESET_DEFINED)

#else
extern void xprintf(const char *fmt, ...);
extern void xsprintf(char *str, const char *fmt, ...);
extern void xvprintf(const char *fmt, va_list ap);

#ifdef HAS_USER_IO
#define xputchar   putUserChar
#define xgetchar   getUserChar
#else
extern void putDebugChar(int ch);
extern int  getDebugChar(void);
#define xputchar   putDebugChar
#define xgetchar   getDebugChar
#endif
#define xungetchar ungetDebugChar
#endif


#ifndef USE_ECOS_HAL_BREAKPOINTS
struct bp {
  mem_addr_t address;
  bp_inst_t  old_inst;
  char       in_memory;
  struct bp  *next;
};
#endif // USE_ECOS_HAL_BREAKPOINTS

struct regstruct
{
  char *registername;
  int  registernumber;
#ifdef HAVE_BSP
#if defined(CYGPKG_HAL_ARM) || !defined(__ECOS__)
  int  registertype;
#endif // defined(CYGPKG_HAL_ARM) || !defined(__ECOS__)
#endif
#ifdef REG_VALID_FIELD_IN_REGSTRUCT
  int registervalid;
#endif
};



#ifdef HAVE_BSP
#define REGTYPE_INT    1
#define REGTYPE_FLOAT  2
#define REGTYPE_DOUBLE 3

union target_reg
{
    unsigned long  i;	/* integer register (32/64 bit) */
#if HAVE_FLOAT_REGS
    float          f;	/* float register (32bit)       */
#endif
#if HAVE_DOUBLE_REGS
    double         d;	/* double register (64bit)      */
#endif
};

typedef union target_reg target_regval_t;


/* This is a template for what should be defined in  the board specific
   header file composed, board.h */
#if ! defined(MEM_ADDR_DEFINED)
#define MEM_ADDR_DEFINED 1
typedef struct mem_addr {
  unsigned long addr;
} mem_addr_t;
#endif

#if !defined(BP_INST_T_DEFINED)
#define BP_INST_T_DEFINED 1
typedef unsigned char bp_inst_t ;
#endif

#if ! defined(MAKE_STD_ADDR)
#define MAKE_STD_ADDR(SRC, DST) ((DST)->addr = (SRC))
#endif


#if ! defined(ADD_OFFSET)
#define ADD_OFFSET(SRC,DST,OFFSET) ((DST)->addr = (SRC)->addr + (OFFSET))
#endif

#if ! defined(ADD_ALIGN)
#define ADD_ALIGN(SRC,DST,ALIGN) \
              ((DST)->addr = (SRC)->addr - ((SRC)->addr % (ALIGN)))
#endif

#if ! defined(MEM_ADDR_EQ_P)
#define MEM_ADDR_EQ_P(A, B) ((A).addr == (B).addr)     
#endif

#if ! defined(MEM_ADDR_DIFF)
#define MEM_ADDR_DIFF(A, B) ((A).addr - (B).addr)
#endif

#if ! defined(MEM_ADDR_ASI)
#define MEM_ADDR_ASI(A) -1
#endif

#endif  /* HAVE_BSP */

#if defined(NO_MALLOC) && ! defined(MAX_NUM_BP)
#define MAX_NUM_BP 64
#endif

extern struct regstruct regtab[];

extern char **argvect;

#ifdef HAVE_BSP
#define VERSION "release 2.0"
#else
#define VERSION "release 1.2"
#endif

#define MAXLINELEN 80
#define PROMPT "cygmon> "
#if ! defined MAX_HIST_ENTS
#define MAX_HIST_ENTS 10
#endif

/*
 * From monitor.c
 */
extern mem_addr_t last_pc;
extern int        stub_is_active;
#ifdef HAVE_BSP
extern void *mon_saved_regs;
#else
extern int (*user_signal_handler)(int);
#endif

extern void clear_user_state (void);
extern int  transfer_to_stub (void);
extern void version (void);
#ifdef MONITOR_CONTROL_INTERRUPTS
/* Enable interrupts within the monitor. */
extern void monitor_enable_interrupts (void);

/* Disable interrupts within the monitor. */
extern void monitor_disable_interrupts (void);

/* Returns 1 if interrupts have been enabled within the monitor, 0
   otherwise. */
extern int monitor_interrupt_state (void);
#endif /* MONITOR_CONTROL_INTERRUPTS */


/*
 * From utils.c
 */
extern int switch_to_stub_flag;
extern int input_char (void);
extern target_register_t str2int (char *str, int base);
#if HAVE_DOUBLE_REGS
extern double str2double (char *str, int base);
#endif
extern target_register_t str2intlen (char *str, int base, int len);
extern int hex2bytes(char *string, char *dest, int maxsize);
extern char *int2str (target_register_t number, int base, int numdigs);
#ifndef NO_MALLOC
extern char *strdup(const char *str);
#endif
extern target_register_t get_pc(void);
extern char *get_register_str (regnames_t which, int detail, int valid);
extern void store_register (regnames_t which, char *string);

#ifndef USE_ECOS_HAL_BREAKPOINTS
/*
 * From breakpoints.c
 */
extern int add_mon_breakpoint (mem_addr_t location);
extern void install_breakpoints (void);
extern void clear_breakpoints (void);
extern int  show_breakpoints (void);
extern int clear_mon_breakpoint (mem_addr_t location);
#endif /* USE_ECOS_HAL_BREAKPOINTS */


/*
 * From do-dis.c
 */
extern mem_addr_t do_dis (mem_addr_t *addr);
extern void flush_dis (void);


/*
 * From architecture-mon.c
 */
#ifdef HAVE_BSP
extern void initialize_mon(void);
extern target_register_t get_register(regnames_t reg);
extern void put_register (regnames_t which, target_register_t value);
#endif


/* Lame. */
#ifndef ITIMER_REAL
#define ITIMER_REAL 0
#endif

#endif /* ASM */
#endif