1 //==========================================================================
5 // Main definitions for the CygMON ROM monitor
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //==========================================================================
41 //#####DESCRIPTIONBEGIN####
44 // Contributors: gthomas, dmoseley
46 // Purpose: Main definitions for the CygMON ROM monitor
50 //####DESCRIPTIONEND####
52 //=========================================================================
57 #if !defined(__ASSEMBLER__)
65 #include <monitor_cmd.h>
68 #include <cyg/hal/plf_stub.h>
74 #define xprintf bsp_dprintf
75 #define xsprintf bsp_sprintf
76 #define xvprintf bsp_dvprintf
77 #define xputchar bsp_debug_putc
78 #define xgetchar bsp_debug_getc
79 #define xungetchar bsp_debug_ungetc
80 #define __getTty() bsp_set_debug_comm(-1)
81 #define set_pc(x) bsp_set_pc((x), mon_saved_regs)
83 #ifndef USE_ECOS_HAL_SINGLESTEP
84 #define __single_step() bsp_singlestep_setup(mon_saved_regs)
85 #define __clear_single_step() bsp_singlestep_cleanup(mon_saved_regs)
86 #endif /* USE_ECOS_HAL_SINGLESTEP */
88 #ifndef USE_ECOS_HAL_BREAKPOINTS
89 #define breakpoint() bsp_breakpoint()
90 #endif /* USE_ECOS_HAL_BREAKPOINTS */
92 #if defined(__ECOS__) && defined(CYGHWR_HAL_RESET_DEFINED)
93 extern void __reset(void);
94 #else // defined(__ECOS__) && defined(CYGHWR_HAL_RESET_DEFINED)
95 # define __reset bsp_reset
96 #endif // defined(__ECOS__) && defined(CYGHWR_HAL_RESET_DEFINED)
99 extern void xprintf(const char *fmt, ...);
100 extern void xsprintf(char *str, const char *fmt, ...);
101 extern void xvprintf(const char *fmt, va_list ap);
104 #define xputchar putUserChar
105 #define xgetchar getUserChar
107 extern void putDebugChar(int ch);
108 extern int getDebugChar(void);
109 #define xputchar putDebugChar
110 #define xgetchar getDebugChar
112 #define xungetchar ungetDebugChar
116 #ifndef USE_ECOS_HAL_BREAKPOINTS
123 #endif // USE_ECOS_HAL_BREAKPOINTS
130 #if defined(CYGPKG_HAL_ARM) || !defined(__ECOS__)
132 #endif // defined(CYGPKG_HAL_ARM) || !defined(__ECOS__)
134 #ifdef REG_VALID_FIELD_IN_REGSTRUCT
142 #define REGTYPE_INT 1
143 #define REGTYPE_FLOAT 2
144 #define REGTYPE_DOUBLE 3
148 unsigned long i; /* integer register (32/64 bit) */
150 float f; /* float register (32bit) */
153 double d; /* double register (64bit) */
157 typedef union target_reg target_regval_t;
160 /* This is a template for what should be defined in the board specific
161 header file composed, board.h */
162 #if ! defined(MEM_ADDR_DEFINED)
163 #define MEM_ADDR_DEFINED 1
164 typedef struct mem_addr {
169 #if !defined(BP_INST_T_DEFINED)
170 #define BP_INST_T_DEFINED 1
171 typedef unsigned char bp_inst_t ;
174 #if ! defined(MAKE_STD_ADDR)
175 #define MAKE_STD_ADDR(SRC, DST) ((DST)->addr = (SRC))
179 #if ! defined(ADD_OFFSET)
180 #define ADD_OFFSET(SRC,DST,OFFSET) ((DST)->addr = (SRC)->addr + (OFFSET))
183 #if ! defined(ADD_ALIGN)
184 #define ADD_ALIGN(SRC,DST,ALIGN) \
185 ((DST)->addr = (SRC)->addr - ((SRC)->addr % (ALIGN)))
188 #if ! defined(MEM_ADDR_EQ_P)
189 #define MEM_ADDR_EQ_P(A, B) ((A).addr == (B).addr)
192 #if ! defined(MEM_ADDR_DIFF)
193 #define MEM_ADDR_DIFF(A, B) ((A).addr - (B).addr)
196 #if ! defined(MEM_ADDR_ASI)
197 #define MEM_ADDR_ASI(A) -1
200 #endif /* HAVE_BSP */
202 #if defined(NO_MALLOC) && ! defined(MAX_NUM_BP)
203 #define MAX_NUM_BP 64
206 extern struct regstruct regtab[];
208 extern char **argvect;
211 #define VERSION "release 2.0"
213 #define VERSION "release 1.2"
216 #define MAXLINELEN 80
217 #define PROMPT "cygmon> "
218 #if ! defined MAX_HIST_ENTS
219 #define MAX_HIST_ENTS 10
225 extern mem_addr_t last_pc;
226 extern int stub_is_active;
228 extern void *mon_saved_regs;
230 extern int (*user_signal_handler)(int);
233 extern void clear_user_state (void);
234 extern int transfer_to_stub (void);
235 extern void version (void);
236 #ifdef MONITOR_CONTROL_INTERRUPTS
237 /* Enable interrupts within the monitor. */
238 extern void monitor_enable_interrupts (void);
240 /* Disable interrupts within the monitor. */
241 extern void monitor_disable_interrupts (void);
243 /* Returns 1 if interrupts have been enabled within the monitor, 0
245 extern int monitor_interrupt_state (void);
246 #endif /* MONITOR_CONTROL_INTERRUPTS */
252 extern int switch_to_stub_flag;
253 extern int input_char (void);
254 extern target_register_t str2int (char *str, int base);
256 extern double str2double (char *str, int base);
258 extern target_register_t str2intlen (char *str, int base, int len);
259 extern int hex2bytes(char *string, char *dest, int maxsize);
260 extern char *int2str (target_register_t number, int base, int numdigs);
262 extern char *strdup(const char *str);
264 extern target_register_t get_pc(void);
265 extern char *get_register_str (regnames_t which, int detail, int valid);
266 extern void store_register (regnames_t which, char *string);
268 #ifndef USE_ECOS_HAL_BREAKPOINTS
272 extern int add_mon_breakpoint (mem_addr_t location);
273 extern void install_breakpoints (void);
274 extern void clear_breakpoints (void);
275 extern int show_breakpoints (void);
276 extern int clear_mon_breakpoint (mem_addr_t location);
277 #endif /* USE_ECOS_HAL_BREAKPOINTS */
283 extern mem_addr_t do_dis (mem_addr_t *addr);
284 extern void flush_dis (void);
288 * From architecture-mon.c
291 extern void initialize_mon(void);
292 extern target_register_t get_register(regnames_t reg);
293 extern void put_register (regnames_t which, target_register_t value);
299 #define ITIMER_REAL 0