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