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