Mercurial > flash_v2
annotate packages/hal/common/current/include/generic-stub.h @ 76:435cced73e2f ecos-v1_3_1-release
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 14:10:45 +0000 |
| parents | bf00f99aec69 |
| children | 02ea4320376c |
| rev | line source |
|---|---|
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
1 //======================================================================== |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
2 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
3 // generic-stub.h |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
4 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
5 // Definitions for the generic GDB remote stub |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
6 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
7 //======================================================================== |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
8 //####COPYRIGHTBEGIN#### |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
9 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
10 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
11 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
12 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
13 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
14 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
15 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
18 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
19 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
20 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
21 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
22 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
24 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
25 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
27 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
28 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
29 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
30 //####COPYRIGHTEND#### |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
31 //======================================================================== |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
32 //#####DESCRIPTIONBEGIN#### |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
33 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
34 // Author(s): Red Hat, nickg |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
35 // Contributors: Red Hat, nickg |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
36 // Date: 1998-06-08 |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
37 // Purpose: |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
38 // Description: Definitions for the generic GDB remote stub |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
39 // Usage: This header is not to be included by user code, and is |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
40 // only placed in a publically accessible directory so |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
41 // that platform stub packages are able to include it |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
42 // if required. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
43 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
44 //####DESCRIPTIONEND#### |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
45 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
54
diff
changeset
|
46 //======================================================================== |
|
54
f10165814f1e
Merge from eCos master repository on 1999-11-19-22:24:39-GMT
jlarmour
parents:
34
diff
changeset
|
47 |
|
f10165814f1e
Merge from eCos master repository on 1999-11-19-22:24:39-GMT
jlarmour
parents:
34
diff
changeset
|
48 |
| 0 | 49 #ifndef GENERIC_STUB_H |
| 50 #define GENERIC_STUB_H | |
| 51 | |
|
76
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
52 #ifdef __cplusplus |
|
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
53 extern "C" { |
|
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
54 #endif |
|
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
55 |
| 2 | 56 /* Three typedefs must be provided before including this file. |
| 0 | 57 target_register_t should correspond to the largest register value on |
| 58 this target processor. | |
| 2 | 59 regnames_t corresponds to a type representing a register number. |
| 60 uint32 must correspond to at least a 32-bit unsigned integer type | |
| 61 (it may be larger). */ | |
| 0 | 62 |
| 63 #ifndef ASM | |
| 64 | |
| 2 | 65 #ifndef __ECOS__ |
| 66 #include "dbg-serial.h" | |
| 67 #endif // __ECOS__ | |
| 0 | 68 |
| 2 | 69 struct gdb_packet |
| 70 { | |
| 71 /* The checksum calculated so far. */ | |
| 72 uint32 checksum; | |
| 73 /* The checksum we've received from the remote side. */ | |
| 74 uint32 xmitcsum; | |
| 75 /* Contents of the accumulated packet. */ | |
| 76 char *contents; | |
| 77 /* Number of characters received. */ | |
| 78 uint32 length; | |
| 79 /* | |
| 80 * state is the current state: | |
| 81 * 0 = looking for start of packet | |
| 82 * 1 = got start of packet, looking for # terminator | |
| 83 * 2 = looking for first byte of checksum | |
| 84 * 3 = looking for second byte of checksum (indicating end of packet) | |
| 85 */ | |
| 86 char state; | |
| 87 }; | |
| 0 | 88 |
| 89 /* Return the currently-saved value corresponding to register REG. */ | |
| 90 extern target_register_t get_register (regnames_t reg); | |
| 91 | |
| 92 /* Store VALUE in the register corresponding to WHICH. */ | |
| 93 extern void put_register (regnames_t which, target_register_t value); | |
| 94 | |
| 95 /* Set the next instruction to be executed when the user program resumes | |
| 96 execution to PC. */ | |
| 97 extern void set_pc (target_register_t pc); | |
| 98 | |
| 99 /* Set the return value of the currently-pending syscall to VALUE. */ | |
| 100 extern void set_syscall_value (target_register_t value); | |
| 101 | |
| 102 /* Return the Nth argument to the currently-pending syscall (starting from | |
| 103 0). */ | |
| 104 extern target_register_t get_syscall_arg (int n); | |
| 105 | |
| 106 /* Initialize the stub. This will also install any trap handlers needed by | |
| 107 the stub. */ | |
| 108 extern void initialize_stub (void); | |
| 109 | |
| 110 /* Initialize the hardware. */ | |
| 111 extern void initHardware (void); | |
| 112 | |
| 113 /* Skip the current instruction. */ | |
| 114 extern void __skipinst (void); | |
| 115 | |
| 2 | 116 /* If the address in the PC register corresponds to the breakpoint() |
| 117 instruction, return a non-zero value. */ | |
| 0 | 118 extern int __is_breakpoint_function (void); |
| 119 | |
| 120 /* Execute a breakpoint instruction. Restarting will cause the instruction | |
| 121 to be skipped. */ | |
| 122 extern void breakpoint (void); | |
| 123 | |
| 124 /* Return the syscall # corresponding to this system call. */ | |
| 125 extern int __get_syscall_num (void); | |
| 126 | |
| 127 /* Transfer exception event processing to the stub. */ | |
| 128 extern void __switch_to_stub (void); | |
| 129 | |
| 130 /* Send an exit packet containing the specified status. */ | |
| 131 extern void __send_exit_status (int status); | |
| 132 | |
| 2 | 133 /* Copy COUNT bytes of memory from ADDR to BUF. |
| 134 ADDR is assumed to live in the user program's space. | |
| 135 Returns number of bytes successfully read | |
| 136 (caller must check to see if less than requested). */ | |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
2
diff
changeset
|
137 extern int __read_mem_safe (void *buf, |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
2
diff
changeset
|
138 void *addr, |
| 2 | 139 int count); |
| 0 | 140 |
| 2 | 141 /* Copy COUNT bytes of memory from BUF to ADDR. |
| 142 ADDR is assumed to live in the user program's space. | |
| 143 Returns number of bytes successfully read | |
| 144 (caller must check to see if less than requested). */ | |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
2
diff
changeset
|
145 extern int __write_mem_safe (void *buf, |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
2
diff
changeset
|
146 void *addr, |
| 2 | 147 int count); |
| 0 | 148 |
| 2 | 149 /* Set to a non-zero value if a memory fault occurs while |
| 150 __set_mem_fault_trap () is running. */ | |
| 151 extern volatile int __mem_fault; | |
| 152 | |
| 153 #ifndef __ECOS__ | |
| 154 #if 1 | |
| 155 #include "stub-tservice.h" /* target dependent stub services */ | |
| 156 #else | |
| 0 | 157 /* Flush the instruction cache. */ |
| 158 extern void flush_i_cache (void); | |
| 159 | |
| 160 /* Flush the data cache. */ | |
| 161 extern void __flush_d_cache (void); | |
| 162 | |
| 163 typedef enum { | |
| 164 CACHE_NOOP, CACHE_ENABLE, CACHE_DISABLE, CACHE_FLUSH | |
| 165 } cache_control_t; | |
| 166 | |
| 167 /* Perform the specified operation on the instruction cache. | |
| 168 Returns 1 if the cache is enabled, 0 otherwise. */ | |
| 169 extern int __instruction_cache (cache_control_t request); | |
| 170 /* Perform the specified operation on the data cache. | |
| 171 Returns 1 if the cache is enabled, 0 otherwise. */ | |
| 172 extern int __data_cache (cache_control_t request); | |
| 2 | 173 #endif |
| 174 #endif // __ECOS__ | |
| 0 | 175 |
| 176 /* Write the 'T' packet in BUFFER. SIGVAL is the signal the program | |
| 177 received. */ | |
| 178 extern void __build_t_packet (int sigval, char *buffer); | |
| 179 | |
| 180 /* Return 1 when a complete packet has been received, 0 if the packet | |
| 181 is not yet complete, or -1 if an erroneous packet was NAKed. */ | |
| 2 | 182 int __add_char_to_packet (unsigned character, struct gdb_packet *packet); |
| 0 | 183 |
| 184 typedef int (*__PFI)(int); | |
| 185 typedef void (*__PFV)(void); | |
| 186 | |
| 187 /* When an exception occurs, __process_exception_vec will be invoked with | |
| 188 the signal number corresponding to the trap/exception. The function | |
| 189 should return zero if it wishes execution to resume from the saved | |
| 190 register values; a non-zero value indicates that the exception handler | |
| 191 should be reinvoked. */ | |
| 192 extern volatile __PFI __process_exception_vec; | |
| 2 | 193 |
| 194 /* __process_exit_vec is invoked when a 'k' kill packet is received | |
| 195 from GDB. */ | |
| 0 | 196 extern volatile __PFV __process_exit_vec; |
| 2 | 197 |
| 198 /* If SIGSYSCALL is defined, and such a signal value is returned from | |
| 199 __computeSignal (), the function pointed to by this vector will | |
| 200 be invoked. | |
| 201 | |
| 202 If the return value is negative, the user program is assumed to | |
| 203 have received the corresponding positive signal value, and an | |
| 204 exception will be processed. Otherwise, the user program is | |
| 205 restarted from the next instruction. */ | |
| 0 | 206 extern volatile __PFI __process_syscall_vec; |
| 2 | 207 |
| 208 /* A continue packet was received from GDB with a signal value. The function | |
| 209 pointed to by __process_signal_vec will be invoked with this signal | |
| 210 value. | |
| 211 | |
| 212 If a zero value is returned, we will ignore the signal, and proceed | |
| 213 with the continue request. Otherwise, the program will be killed | |
| 214 with the signal. */ | |
| 0 | 215 extern volatile __PFI __process_signal_vec; |
| 2 | 216 |
| 217 /* If non-NULL, __init_vec is called right before the user program is | |
| 218 resumed. */ | |
| 219 extern volatile __PFV __init_vec; | |
| 220 /* if non-NULL, __cleanup_vec is called after the user program takes | |
| 221 an exception. */ | |
| 222 extern volatile __PFV __cleanup_vec; | |
| 0 | 223 |
| 224 /* Send an 'O' packet to GDB containing STR. */ | |
| 2 | 225 extern int __output_gdb_string (target_register_t addr, int string_len); |
| 0 | 226 |
| 227 /* Request MAXLEN bytes of input from GDB to be stored in DEST. If BLOCK | |
| 228 is set, GDB should block until MAXLEN bytes are available to be | |
| 229 read; otherwise, it will return immediately with whatever data is | |
| 230 available. | |
| 231 The return value is the number of bytes written into DEST. */ | |
| 2 | 232 extern int __get_gdb_input (target_register_t dest, int maxlen, int block); |
| 0 | 233 |
| 2 | 234 /* Return the ASCII equivalent of C (C>=0 && C<=15). The result will be |
| 235 lower-case. */ | |
| 0 | 236 extern char __tohex (int c); |
| 237 | |
| 2 | 238 /* Convert COUNT bytes of the memory region in MEM to a hexadecimal |
| 239 string in DEST. | |
| 240 The resulting string will contain 2*COUNT characters. | |
| 241 If MAY_FAULT is non-zero, memory faults are trapped; if a fault occurs, | |
| 242 a NULL value will be returned. | |
| 243 The value returned is one byte past the end of the string written. */ | |
| 244 extern char *__mem2hex (char *mem, char *dest, int count, int may_fault); | |
| 245 | |
| 246 /* Given a hexadecimal string in MEM, write the equivalent bytes to DEST. | |
| 247 The string is assumed to contain 2*COUNT characters. | |
| 248 If MAY_FAULT is non-zero, memory faults are trapped; if a fault occurs, | |
| 249 a NULL value will be returned. | |
| 250 Otherwise, the value returned is one byte past the last byte written. */ | |
| 251 extern char *__hex2mem (char *buf, char *mem, int count, int may_fault); | |
| 252 | |
| 253 /* Set the program arguments passed into the user program's main */ | |
| 254 extern void __set_program_args (int argc, char **argv); | |
| 255 | |
| 256 /* Return the user program arguments passed in from GDB (via an 'A' | |
| 257 packet). argcPtr is a pointer into the user program, which will hold | |
| 258 the number of arguments; the strings are returned. */ | |
| 259 extern char **__get_program_args (target_register_t argcPtr); | |
| 260 | |
| 261 /* Encode PACKET as a remote protocol packet and send it to GDB; this takes | |
| 262 care of sending the initial '$' character, as well as the trailing '#' | |
| 263 and checksum, and also waits for an ACK from the remote side, resending | |
| 264 as necessary. */ | |
| 265 extern void __putpacket (char *packet); | |
| 266 | |
| 267 /* Convert the hexadecimal string pointed to by *PTR into an integer, | |
| 268 and store it in the value pointed to by INTVALUE. The number of | |
| 269 characters read from *PTR will be returned; *PTR will point to the first | |
| 270 non-hexadecmial character encountered. */ | |
| 271 extern unsigned int __hexToInt (char **ptr, target_register_t *intValue); | |
| 272 | |
| 273 /* Convert the value in INTVALUE into a string of hexadecimal | |
| 274 characters stored in PTR. NUMBITS are the number of bits to use | |
| 275 in INTVALUE. The number of characters written to PTR will be returned. */ | |
| 276 extern unsigned int __intToHex (char *ptr, | |
| 277 target_register_t intValue, | |
| 278 int numBits); | |
| 279 | |
| 280 /* Handle an exception, usually some sort of hardware or software trap. | |
| 281 This is responsible for communicating the exception to GDB. */ | |
| 282 extern void __handle_exception (void); | |
| 283 | |
| 284 /* Send a 'X' packet with signal SIGVAL to GDB. */ | |
| 285 extern void __kill_program (int sigval); | |
| 286 | |
| 287 /* Given a packet pointed to by PACKETCONTENTS, decode it and respond to | |
| 288 GDB appropriately. */ | |
| 289 extern int __process_packet (char *packetContents); | |
| 290 | |
| 291 /* Write the C-style string pointed to by STR to the GDB comm port. | |
| 292 Used for printing debug messages. */ | |
| 293 extern void __putDebugStr (char *str); | |
| 294 | |
| 295 #ifdef NO_MALLOC | |
| 296 #define MAX_BP_NUM 64 /* Maximum allowed # of breakpoints */ | |
| 0 | 297 #endif |
| 298 | |
| 2 | 299 #endif /* ASM */ |
| 300 | |
|
76
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
301 #ifdef __cplusplus |
|
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
302 } /* extern "C" */ |
|
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
303 #endif |
|
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
304 |
| 2 | 305 #endif /* GENERIC_STUB_H */ |
