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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [common/] [v2_0/] [include/] [hal_stub.h] - Blame information for rev 346

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_HAL_STUB_H
2
#define CYGONCE_HAL_HAL_STUB_H
3
 
4
//=============================================================================
5
//
6
//      hal_stub.h
7
//
8
//      HAL header for GDB stub support.
9
//
10
//=============================================================================
11
//####ECOSGPLCOPYRIGHTBEGIN####
12
// -------------------------------------------
13
// This file is part of eCos, the Embedded Configurable Operating System.
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under
17
// the terms of the GNU General Public License as published by the Free
18
// Software Foundation; either version 2 or (at your option) any later version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//=============================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):   jskov
47
// Contributors:jskov
48
// Date:        1999-02-12
49
// Purpose:     Generic HAL stub header.
50
// Usage:       #include <cyg/hal/hal_stub.h>
51
// Description: This header is included by generic-stub.c to provide an
52
//              interface to the eCos-specific stub implementation. It is
53
//              not to be included by user code, and is only placed in a
54
//              publically accessible directory so that platform stub packages
55
//              are able to include it if required.
56
//                           
57
//####DESCRIPTIONEND####
58
//
59
//=============================================================================
60
 
61
#include <pkgconf/hal.h>
62
 
63
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
64
#define USE_GDBSTUB_PROTOTYPES 0        // avoid stub-tservice.h atm
65
#ifndef __ECOS__
66
#define __ECOS__                        // use to mark eCos hacks
67
#endif
68
 
69
#include <cyg/hal/basetype.h>           // HAL_LABEL_NAME
70
#include <cyg/hal/hal_arch.h>           // HAL header
71
#include <cyg/infra/cyg_type.h>         // cyg_uint32 and CYG_BYTEORDER
72
 
73
#ifndef __CYGMON_TYPES
74
#define __CYGMON_TYPES
75
typedef cyg_uint32 uint32;
76
typedef cyg_int32  int32;
77
#endif // __CYGMON_TYPES
78
 
79
#ifdef CYGBLD_HAL_PLATFORM_STUB_H
80
#include CYGBLD_HAL_PLATFORM_STUB_H
81
#else
82
#include <cyg/hal/plf_stub.h>
83
#endif
84
#include <cyg/hal/generic-stub.h>
85
 
86
#ifdef __cplusplus
87
extern "C" {
88
#endif
89
#if 0
90
} // to make below format correctly.
91
#endif
92
 
93
//-----------------------------------------------------------------------------
94
// Definitions for generic-stub.c
95
 
96
#define __set_mem_fault_trap(x) ({__mem_fault = 0; x(); __mem_fault;})
97
 
98
#if (CYG_BYTEORDER==CYG_LSBFIRST)
99
# if !defined(__LITTLE_ENDIAN__)
100
#  define __LITTLE_ENDIAN__
101
# endif
102
# if !defined(_LITTLE_ENDIAN)
103
#  define _LITTLE_ENDIAN
104
# endif
105
#endif
106
 
107
//-----------------------------------------------------------------------------
108
// Dummy definitions for harvard memory support for princeton memory systems.
109
#ifndef TARGET_HAS_HARVARD_MEMORY
110
typedef target_register_t target_addr_t;
111
#define TARGET_ADDR_IS_PROGMEM(x) 0
112
#define TARGET_ADDR_TO_PTR(x)     ((char *) (x))
113
#endif
114
 
115
//----------------------------------------------------------------------------
116
// Signal definitions to avoid 'signal.h'/
117
#define SIGHUP  1       /* hangup */
118
#define SIGINT  2       /* interrupt */
119
#define SIGQUIT 3       /* quit */
120
#define SIGILL  4       /* illegal instruction (not reset when caught) */
121
#define SIGTRAP 5       /* trace trap (not reset when caught) */
122
#define SIGIOT  6       /* IOT instruction */
123
#define SIGABRT 6       /* used by abort, replace SIGIOT in the future */
124
#define SIGEMT  7       /* EMT instruction */
125
#define SIGFPE  8       /* floating point exception */
126
#define SIGKILL 9       /* kill (cannot be caught or ignored) */
127
#define SIGBUS  10      /* bus error */
128
#define SIGSEGV 11      /* segmentation violation */
129
#define SIGSYS  12      /* bad argument to system call */
130
#define SIGPIPE 13      /* write on a pipe with no one to read it */
131
#define SIGALRM 14      /* alarm clock */
132
#define SIGTERM 15      /* software termination signal from kill */
133
 
134
//----------------------------------------------------------------------------
135
// Thread support. This setting is used in thread-pkts.h
136
#ifdef CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
137
#define DEBUG_THREADS 1
138
#else
139
#define DEBUG_THREADS 0
140
#endif
141
 
142
// The function stub_copy_registers() is statically defined in
143
// thread-packets.c, but in eCos this external stub is defined as it
144
// is used in dbg_gdb.cxx.
145
externC void __stub_copy_registers(target_register_t *dest,
146
                                   target_register_t *src);
147
 
148
//----------------------------------------------------------------------------
149
// Hardware Watch/Breakpoint support. These are the possible return values
150
// of HAL_STUB_IS_STOPPED_BY_HARDWARE().
151
#define HAL_STUB_HW_STOP_NONE   0   // target did not stop for hw watch/break
152
#define HAL_STUB_HW_STOP_BREAK  1   // target stopped for hw breakpoint
153
#define HAL_STUB_HW_STOP_WATCH  2   // target stopped for write-only watchpoint
154
#define HAL_STUB_HW_STOP_RWATCH 3   // target stopped for read-only watchpoint
155
#define HAL_STUB_HW_STOP_AWATCH 4   // target stopped for access watchpoint
156
 
157
//----------------------------------------------------------------------------
158
// Memory accessor functions.
159
#define TARGET_HAS_OWN_MEM_FUNCS
160
 
161
//----------------------------------------------------------------------------
162
// Memory access checks. 
163
 
164
#ifndef CYG_HAL_STUB_PERMIT_DATA_READ
165
#define CYG_HAL_STUB_PERMIT_DATA_READ(_addr_, __count_) (1)
166
#endif
167
 
168
#ifndef CYG_HAL_STUB_PERMIT_DATA_WRITE
169
#define CYG_HAL_STUB_PERMIT_DATA_WRITE(_addr_, __count_) (1)
170
#endif
171
 
172
#ifdef TARGET_HAS_HARVARD_MEMORY
173
 
174
#ifndef CYG_HAL_STUB_PERMIT_CODE_READ
175
#define CYG_HAL_STUB_PERMIT_CODE_READ(_addr_, __count_) (1)
176
#endif
177
 
178
#ifndef CYG_HAL_STUB_PERMIT_CODE_WRITE
179
#define CYG_HAL_STUB_PERMIT_CODE_WRITE(_addr_, __count_) (1)
180
#endif
181
 
182
#endif
183
 
184
//----------------------------------------------------------------------------
185
// Target extras?!
186
extern int __process_target_query(char * pkt, char * out, int maxOut);
187
extern int __process_target_set(char * pkt, char * out, int maxout);
188
extern int __process_target_packet(char * pkt, char * out, int maxout);
189
 
190
//---------------------------------------------------------------------------
191
// Declarations to avoid compiler warnings.
192
 
193
// Set the baud rate for the current serial port.
194
extern void __set_baud_rate (int baud);
195
 
196
// Write C to the current serial port.
197
extern void putDebugChar (int c);
198
 
199
// Read one character from the current serial port.
200
extern int getDebugChar (void);
201
 
202
// Push CH back onto the debug stream.
203
extern void ungetDebugChar (int ch);
204
 
205
// Reset the board.
206
extern void __reset (void);
207
 
208
// Multi-bp support.
209
#ifndef __set_breakpoint
210
extern int __set_breakpoint (target_register_t addr, target_register_t len);
211
#endif
212
#ifndef __remove_breakpoint
213
extern int __remove_breakpoint (target_register_t addr, target_register_t len);
214
#endif
215
#ifndef __set_hw_breakpoint
216
extern int __set_hw_breakpoint (target_register_t addr, target_register_t len);
217
#endif
218
#ifndef __remove_hw_breakpoint
219
extern int __remove_hw_breakpoint (target_register_t addr, target_register_t len);
220
#endif
221
#ifndef __set_hw_watchpoint
222
extern int __set_hw_watchpoint (target_register_t addr, target_register_t len, int ztype);
223
#endif
224
#ifndef __remove_hw_watchpoint
225
extern int __remove_hw_watchpoint (target_register_t addr, target_register_t len, int ztype);
226
#endif
227
 
228
/* Install the standard set of trap handlers for the stub. */
229
extern void __install_traps (void);
230
 
231
/* Address in text section of a breakpoint instruction.  */
232
 
233
#ifndef BREAKINST_DEFINED
234
#define BREAKINST_DEFINED
235
extern void _breakinst (void);
236
#endif
237
 
238
/* The opcode for a breakpoint instruction.  */
239
 
240
extern unsigned long __break_opcode (void);
241
 
242
/* Function to flush output buffers */
243
extern void hal_flush_output(void);
244
 
245
#ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
246
// This one may assume a valid saved interrupt context on some platforms
247
extern void cyg_hal_gdb_interrupt    (target_register_t pc);
248
// This one does not; use from CRITICAL_IO_REGION macros below.
249
extern void cyg_hal_gdb_place_break  (target_register_t pc);
250
// Remove a break from either above - or not if cyg_hal_gdb_running_step
251
extern int  cyg_hal_gdb_remove_break (target_register_t pc);
252
// Bool: is such a breakpoint set?
253
extern int  cyg_hal_gdb_break_is_set (void);
254
 
255
/* This is used so that the generic stub can tell
256
 * cyg_hal_gdb_remove_break() not to bother when we are avoiding stepping
257
 * through a critical region ie. hal_diag_write_char() usually - that
258
 * shares the GDB IO device.
259
 */
260
extern volatile int cyg_hal_gdb_running_step;
261
 
262
// Use these in hal_diag.c when about to write a whole $O packet to GDB.
263
// NB they require __builtin_return_address() to work: if your platform
264
// does not support this, use HAL_DISABLE_INTERRUPTS &c instead.
265
 
266
#if 1 // Can use the address of a label: this is more portable
267
 
268
// This macro may already have been defined by the architecture HAL
269
#ifndef CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION
270
#define CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION( _old_ )                        \
271
do {                                                                         \
272
    HAL_DISABLE_INTERRUPTS(_old_);                                           \
273
    cyg_hal_gdb_place_break( (target_register_t)&&cyg_hal_gdb_break_place ); \
274
} while ( 0 )
275
#endif
276
 
277
// This macro may already have been defined by the architecture HAL
278
// Notice the trick to *use* the label - sometimes the tools want to
279
// move the label if unused, which is bad.
280
#ifndef CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION
281
#define CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION( _old_ )                         \
282
do {                                                                          \
283
    cyg_hal_gdb_remove_break( (target_register_t)&&cyg_hal_gdb_break_place ); \
284
    HAL_RESTORE_INTERRUPTS(_old_);                                            \
285
    _old_ = 1; /* actually use the label as a label... */                     \
286
cyg_hal_gdb_break_place:;                                                     \
287
    if ( (_old_)-- > 0 ) /* ...or the compiler might move it! */              \
288
        goto cyg_hal_gdb_break_place;                                         \
289
} while ( 0 )
290
#endif
291
 
292
#else // use __builtin_return_address instead.
293
 
294
#define CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION( _old_ )                        \
295
do {                                                                         \
296
    HAL_DISABLE_INTERRUPTS(_old_);                                           \
297
    cyg_hal_gdb_place_break((target_register_t)__builtin_return_address(0)); \
298
} while ( 0 )
299
 
300
#define CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION( _old_ )                         \
301
do {                                                                          \
302
    cyg_hal_gdb_remove_break((target_register_t)__builtin_return_address(0)); \
303
    HAL_RESTORE_INTERRUPTS(_old_);                                            \
304
} while ( 0 )
305
 
306
#endif
307
 
308
#else // NO debug_gdb_break_support
309
 
310
// so define these just to do interrupts:
311
#define CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION( _old_ )   \
312
do {                                                    \
313
    HAL_DISABLE_INTERRUPTS(_old_);                      \
314
} while (0);
315
 
316
#define CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION( _old_ )   \
317
do {                                                    \
318
    HAL_RESTORE_INTERRUPTS(_old_);                      \
319
} while (0);
320
 
321
#endif
322
 
323
//----------------------------------------------------------------------------
324
// eCos extensions to the stub
325
 
326
extern void hal_output_gdb_string(target_register_t str, int string_len);
327
 
328
extern target_register_t registers[];   // The current saved registers.
329
extern target_register_t * _registers ;
330
extern HAL_SavedRegisters *_hal_registers;
331
 
332
extern int cyg_hal_gdb_break;
333
 
334
#ifdef CYGPKG_ISOINFRA
335
# include <pkgconf/isoinfra.h>
336
#endif
337
#ifdef CYGINT_ISO_STRING_STRFUNCS
338
# include <string.h>
339
#else
340
//-----------------------------------------------------------------------------
341
// String helpers. These really should come from ISOINFRA
342
static inline char *strcpy( char *s, const char *t)
343
{
344
    char *r = s;
345
 
346
    while( *t ) *s++ = *t++;
347
 
348
    // Terminate the copied string.
349
    *s = 0;
350
 
351
    return r;
352
}
353
 
354
static inline size_t strlen( const char *s )
355
{
356
    int r = 0;
357
    while( *s++ ) r++;
358
    return r;
359
}
360
#endif
361
 
362
//-----------------------------------------------------------------------------
363
// Repeat the cache definitions here to avoid too much hackery in 
364
// generic-stub.h
365
/* Flush the instruction cache. */
366
extern void flush_i_cache (void);
367
 
368
/* Flush the data cache. */
369
extern void __flush_d_cache (void);
370
 
371
typedef enum {
372
  CACHE_NOOP, CACHE_ENABLE, CACHE_DISABLE, CACHE_FLUSH
373
} cache_control_t;
374
 
375
/* Perform the specified operation on the instruction cache.
376
   Returns 1 if the cache is enabled, 0 otherwise. */
377
extern int __instruction_cache (cache_control_t request);
378
/* Perform the specified operation on the data cache.
379
   Returns 1 if the cache is enabled, 0 otherwise. */
380
extern int __data_cache (cache_control_t request);
381
 
382
#ifdef __cplusplus
383
} // extern "C"
384
#endif
385
 
386
#endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
387
 
388
//-----------------------------------------------------------------------------
389
#endif // CYGONCE_HAL_HAL_STUB_H
390
// End of hal_stub.h

powered by: WebSVN 2.1.0

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