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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 27 unneback
//========================================================================
2
//
3
//      generic-stub.h
4
//
5
//      Definitions for the generic GDB remote stub
6
//
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.
12
//
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.
16
//
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
20
// for more details.
21
//
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.
25
//
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.
32
//
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.
35
//
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####
42
//
43
// Author(s):     Red Hat, nickg
44
// Contributors:  Red Hat, nickg, dmoseley
45
// Date:          1998-06-08
46
// Purpose:       
47
// Description:   Definitions for the generic GDB remote stub
48
// Usage:         This header is not to be included by user code, and is
49
//                only placed in a publically accessible directory so
50
//                that platform stub packages are able to include it
51
//                if required.
52
//
53
//####DESCRIPTIONEND####
54
//
55
//========================================================================
56
 
57
 
58
#ifndef GENERIC_STUB_H
59
#define GENERIC_STUB_H
60
 
61
#ifdef __cplusplus
62
extern "C" {
63
#endif
64
 
65
/* Three typedefs must be provided before including this file.
66
   target_register_t should correspond to the largest register value on
67
   this target processor.
68
   regnames_t corresponds to a type representing a register number.
69
   uint32 must correspond to at least a 32-bit unsigned integer type
70
   (it may be larger). */
71
 
72
#ifndef ASM
73
 
74
#ifndef __ECOS__
75
#include "dbg-serial.h"
76
#endif // __ECOS__
77
 
78
struct gdb_packet
79
{
80
  /* The checksum calculated so far. */
81
  uint32 checksum;
82
  /* The checksum we've received from the remote side. */
83
  uint32 xmitcsum;
84
  /* Contents of the accumulated packet. */
85
  char *contents;
86
  /* Number of characters received. */
87
  uint32 length;
88
  /*
89
   * state is the current state:
90
   *  0 = looking for start of packet
91
   *  1 = got start of packet, looking for # terminator
92
   *  2 = looking for first byte of checksum
93
   *  3 = looking for second byte of checksum (indicating end of packet)
94
   */
95
  char state;
96
  char err;  // This is set if the packet should be tossed because of overflow
97
};
98
 
99
/* Return the currently-saved value corresponding to register REG. */
100
extern target_register_t get_register (regnames_t reg);
101
 
102
/* Write the contents of register WHICH into VALUE as raw bytes */
103
extern int get_register_as_bytes (regnames_t which, char *value);
104
 
105
#ifdef CYGHWR_REGISTER_VALIDITY_CHECKING
106
// Return the validity of register REG.
107
extern int get_register_valid (regnames_t reg);
108
#endif
109
 
110
/* Store VALUE in the register corresponding to WHICH. */
111
extern void put_register (regnames_t which, target_register_t value);
112
 
113
extern int put_register_as_bytes (regnames_t which, char *value);
114
 
115
/* Set the next instruction to be executed when the user program resumes
116
   execution to PC. */
117
#if !defined(SET_PC_PROTOTYPE_EXISTS) && !defined(set_pc)
118
#define SET_PC_PROTOTYPE_EXISTS
119
extern void set_pc (target_register_t pc);
120
#endif
121
 
122
/* Set the return value of the currently-pending syscall to VALUE. */
123
extern void set_syscall_value (target_register_t value);
124
 
125
/* Return the Nth argument to the currently-pending syscall (starting from
126
   0). */
127
extern target_register_t get_syscall_arg (int n);
128
 
129
/* Initialize the stub. This will also install any trap handlers needed by
130
   the stub. */
131
extern void initialize_stub (void);
132
 
133
/* Initialize the hardware. */
134
extern void initHardware (void);
135
 
136
/* Skip the current instruction. */
137
extern void __skipinst (void);
138
 
139
/* If the address in the PC register corresponds to the breakpoint()
140
   instruction, return a non-zero value. */
141
#ifndef __is_breakpoint_function
142
extern int __is_breakpoint_function (void);
143
#endif
144
 
145
/* Execute a breakpoint instruction. Restarting will cause the instruction
146
   to be skipped. */
147
#ifndef breakpoint
148
extern void breakpoint (void);
149
#endif
150
 
151
/* Return the syscall # corresponding to this system call. */
152
extern int __get_syscall_num (void);
153
 
154
/* Transfer exception event processing to the stub. */
155
extern void __switch_to_stub (void);
156
 
157
/* Send an exit packet containing the specified status. */
158
extern void __send_exit_status (int status);
159
 
160
/* Copy COUNT bytes of memory from ADDR to BUF.
161
   ADDR is assumed to live in the user program's space.
162
   Returns number of bytes successfully read
163
   (caller must check to see if less than requested).  */
164
extern int __read_mem_safe (void *buf,
165
                            void *addr,
166
                            int count);
167
 
168
extern int __read_progmem_safe (void *buf,
169
                                void *addr,
170
                                int count);
171
 
172
/* Copy COUNT bytes of memory from BUF to ADDR.
173
   ADDR is assumed to live in the user program's space.
174
   Returns number of bytes successfully read
175
   (caller must check to see if less than requested).  */
176
#ifndef __write_mem_safe
177
extern int __write_mem_safe (void *buf,
178
                             void *addr,
179
                             int count);
180
#endif
181
 
182
extern int __write_progmem_safe (void *buf,
183
                                 void *addr,
184
                                 int count);
185
 
186
/* Set to a non-zero value if a memory fault occurs while
187
   __set_mem_fault_trap () is running. */
188
extern volatile int __mem_fault;
189
 
190
#ifndef __ECOS__
191
#if 1
192
#include "stub-tservice.h"  /* target dependent stub services */
193
#else
194
/* Flush the instruction cache. */
195
extern void flush_i_cache (void);
196
 
197
/* Flush the data cache. */
198
extern void __flush_d_cache (void);
199
 
200
typedef enum {
201
  CACHE_NOOP, CACHE_ENABLE, CACHE_DISABLE, CACHE_FLUSH
202
} cache_control_t;
203
 
204
/* Perform the specified operation on the instruction cache.
205
   Returns 1 if the cache is enabled, 0 otherwise. */
206
extern int __instruction_cache (cache_control_t request);
207
/* Perform the specified operation on the data cache.
208
   Returns 1 if the cache is enabled, 0 otherwise. */
209
extern int __data_cache (cache_control_t request);
210
#endif
211
#endif // __ECOS__
212
 
213
/* Write the 'T' packet in BUFFER. SIGVAL is the signal the program
214
   received. */
215
extern void __build_t_packet (int sigval, char *buffer);
216
 
217
/* Return 1 when a complete packet has been received, 0 if the packet
218
   is not yet complete, or -1 if an erroneous packet was NAKed. */
219
int __add_char_to_packet (unsigned character, struct gdb_packet *packet);
220
 
221
typedef int (*__PFI)(int);
222
typedef void (*__PFV)(void);
223
 
224
/* When an exception occurs, __process_exception_vec will be invoked with
225
   the signal number corresponding to the trap/exception. The function
226
   should return zero if it wishes execution to resume from the saved
227
   register values; a non-zero value indicates that the exception handler
228
   should be reinvoked. */
229
#if !defined(PROCESS_EXCEPTION_VEC_PROTOTYPE_EXISTS)
230
#define PROCESS_EXCEPTION_VEC_PROTOTYPE_EXISTS
231
extern volatile __PFI __process_exception_vec;
232
#endif
233
 
234
/* __process_exit_vec is invoked when a 'k' kill packet is received
235
   from GDB. */
236
extern volatile __PFV __process_exit_vec;
237
 
238
/* If SIGSYSCALL is defined, and such a signal value is returned from
239
   __computeSignal (), the function pointed to by this vector will
240
   be invoked.
241
 
242
   If the return value is negative, the user program is assumed to
243
   have received the corresponding positive signal value, and an
244
   exception will be processed.  Otherwise, the user program is
245
   restarted from the next instruction. */
246
extern volatile __PFI __process_syscall_vec;
247
 
248
/* A continue packet was received from GDB with a signal value. The function
249
   pointed to by __process_signal_vec will be invoked with this signal
250
   value.
251
 
252
   If a zero value is returned, we will ignore the signal, and proceed
253
   with the continue request. Otherwise, the program will be killed
254
   with the signal. */
255
extern volatile __PFI __process_signal_vec;
256
 
257
/* If non-NULL, __init_vec is called right before the user program is
258
   resumed. */
259
extern volatile __PFV __init_vec;
260
/* if non-NULL, __cleanup_vec is called after the user program takes
261
   an exception. */
262
extern volatile __PFV __cleanup_vec;
263
 
264
/* Send an 'O' packet to GDB containing STR. */
265
extern int __output_gdb_string (target_register_t addr, int string_len);
266
 
267
/* Request MAXLEN bytes of input from GDB to be stored in DEST. If BLOCK
268
   is set, GDB should block until MAXLEN bytes are available to be
269
   read; otherwise, it will return immediately with whatever data is
270
   available.
271
   The return value is the number of bytes written into DEST. */
272
extern int __get_gdb_input (target_register_t dest, int maxlen, int block);
273
 
274
/* Return the ASCII equivalent of C (C>=0 && C<=15). The result will be
275
   lower-case. */
276
extern char __tohex (int c);
277
 
278
/* Convert COUNT bytes of the memory region in MEM to a hexadecimal
279
   string in DEST.
280
   The resulting string will contain 2*COUNT characters.
281
   If MAY_FAULT is non-zero, memory faults are trapped; if a fault occurs,
282
   a NULL value will be returned.
283
   The value returned is one byte past the end of the string written. */
284
extern char *__mem2hex (char *mem, char *dest, int count, int may_fault);
285
 
286
/* Given a hexadecimal string in MEM, write the equivalent bytes to DEST.
287
   The string is assumed to contain 2*COUNT characters.
288
   If MAY_FAULT is non-zero, memory faults are trapped; if a fault occurs,
289
   a NULL value will be returned.
290
   Otherwise, the value returned is one byte past the last byte written. */
291
extern char *__hex2mem (char *buf, char *mem, int count, int may_fault);
292
 
293
/* Set the program arguments passed into the user program's main */
294
extern void __set_program_args (int argc, char **argv);
295
 
296
/* Return the user program arguments passed in from GDB (via an 'A'
297
   packet). argcPtr is a pointer into the user program, which will hold
298
   the number of arguments; the strings are returned. */
299
extern char **__get_program_args (target_register_t argcPtr);
300
 
301
/* Encode PACKET as a remote protocol packet and send it to GDB; this takes
302
   care of sending the initial '$' character, as well as the trailing '#'
303
   and checksum, and also waits for an ACK from the remote side, resending
304
   as necessary. */
305
extern void __putpacket (char *packet);
306
 
307
/* Retrieve the next remote protocol packet from GDB, taking care of verifying
308
   the checksum and sending an ACK when necessary. */
309
extern void __getpacket (char *buffer);
310
 
311
/* Convert the hexadecimal string pointed to by *PTR into an integer,
312
   and store it in the value pointed to by INTVALUE. The number of
313
   characters read from *PTR will be returned; *PTR will point to the first
314
   non-hexadecmial character encountered. */
315
extern unsigned int __hexToInt (char **ptr, target_register_t *intValue);
316
 
317
/* Convert the value in INTVALUE into a string of hexadecimal
318
   characters stored in PTR. NUMBITS are the number of bits to use
319
   in INTVALUE. The number of characters written to PTR will be returned. */
320
extern unsigned int __intToHex (char *ptr,
321
                                target_register_t intValue,
322
                                int numBits);
323
 
324
/* Handle an exception, usually some sort of hardware or software trap.
325
   This is responsible for communicating the exception to GDB. */
326
extern void __handle_exception (void);
327
 
328
/* Send a 'X' packet with signal SIGVAL to GDB. */
329
extern void __kill_program (int sigval);
330
 
331
/* Given a packet pointed to by PACKETCONTENTS, decode it and respond to
332
   GDB appropriately. */
333
extern int __process_packet (char *packetContents);
334
 
335
/* Write the C-style string pointed to by STR to the GDB comm port.
336
   Used for printing debug messages. */
337
extern void __putDebugStr (char *str);
338
 
339
#if defined(NO_MALLOC) && !defined(MAX_BP_NUM)
340
#define MAX_BP_NUM 64 /* Maximum allowed # of breakpoints */
341
#endif
342
 
343
extern int hal_syscall_handler(void);
344
extern int __is_bsp_syscall(void);
345
 
346
extern void __install_breakpoint_list (void);
347
extern void __clear_breakpoint_list (void);
348
extern int __display_breakpoint_list (void (*print_func)(target_register_t));
349
 
350
/* 'Z' packet types */
351
#define ZTYPE_SW_BREAKPOINT        0
352
#define ZTYPE_HW_BREAKPOINT        1
353
#define ZTYPE_HW_WATCHPOINT_WRITE  2
354
#define ZTYPE_HW_WATCHPOINT_READ   3
355
#define ZTYPE_HW_WATCHPOINT_ACCESS 4
356
 
357
#endif /* ASM */
358
 
359
#ifdef __cplusplus
360
} /* extern "C" */
361
#endif
362
 
363
#endif /* GENERIC_STUB_H */

powered by: WebSVN 2.1.0

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