|
2
|
1 #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 //####COPYRIGHTBEGIN#### |
|
|
12 // |
|
|
13 // ------------------------------------------- |
|
|
14 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
15 // Version 1.0 (the "License"); you may not use this file except in |
|
|
16 // compliance with the License. You may obtain a copy of the License at |
|
|
17 // http://sourceware.cygnus.com/ecos |
|
|
18 // |
|
|
19 // Software distributed under the License is distributed on an "AS IS" |
|
|
20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
21 // License for the specific language governing rights and limitations under |
|
|
22 // the License. |
|
|
23 // |
|
|
24 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
25 // September 30, 1998. |
|
|
26 // |
|
|
27 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
28 // by Cygnus are Copyright (C) 1998, 1999 Cygnus Solutions. |
|
|
29 // All Rights Reserved. |
|
|
30 // ------------------------------------------- |
|
|
31 // |
|
|
32 //####COPYRIGHTEND#### |
|
|
33 //============================================================================= |
|
|
34 //#####DESCRIPTIONBEGIN#### |
|
|
35 // |
|
|
36 // Author(s): jskov |
|
|
37 // Contributors:jskov |
|
|
38 // Date: 1999-02-12 |
|
|
39 // Purpose: Generic HAL stub header. |
|
|
40 // Usage: #include <cyg/hal/hal_stub.h> |
|
|
41 // |
|
|
42 //####DESCRIPTIONEND#### |
|
|
43 // |
|
|
44 //============================================================================= |
|
|
45 |
|
|
46 #include <pkgconf/hal.h> |
|
|
47 |
|
|
48 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
|
|
49 #define USE_GDBSTUB_PROTOTYPES 0 // avoid stub-tservice.h atm |
|
|
50 #define __ECOS__ // use to mark eCos hacks |
|
|
51 |
|
|
52 #include <cyg/hal/basetype.h> // HAL_LABEL_NAME |
|
|
53 #include <cyg/hal/hal_arch.h> // HAL header |
|
|
54 #include <cyg/infra/cyg_type.h> |
|
|
55 typedef cyg_uint32 uint32; |
|
|
56 |
|
|
57 #include <cyg/hal/plf_stub.h> |
|
|
58 #include <cyg/hal/generic-stub.h> |
|
|
59 |
|
|
60 #ifdef __cplusplus |
|
|
61 extern "C" { |
|
|
62 #endif |
|
|
63 |
|
|
64 //----------------------------------------------------------------------------- |
|
|
65 // Definitions for generic-stub.c |
|
|
66 |
|
|
67 #define __set_mem_fault_trap(x) ({__mem_fault = 0; x(); __mem_fault;}) |
|
|
68 |
|
|
69 //---------------------------------------------------------------------------- |
|
|
70 // Signal definitions to avoid 'signal.h'/ |
|
|
71 #define SIGHUP 1 /* hangup */ |
|
|
72 #define SIGINT 2 /* interrupt */ |
|
|
73 #define SIGQUIT 3 /* quit */ |
|
|
74 #define SIGILL 4 /* illegal instruction (not reset when caught) */ |
|
|
75 #define SIGTRAP 5 /* trace trap (not reset when caught) */ |
|
|
76 #define SIGIOT 6 /* IOT instruction */ |
|
|
77 #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ |
|
|
78 #define SIGEMT 7 /* EMT instruction */ |
|
|
79 #define SIGFPE 8 /* floating point exception */ |
|
|
80 #define SIGKILL 9 /* kill (cannot be caught or ignored) */ |
|
|
81 #define SIGBUS 10 /* bus error */ |
|
|
82 #define SIGSEGV 11 /* segmentation violation */ |
|
|
83 #define SIGSYS 12 /* bad argument to system call */ |
|
|
84 #define SIGPIPE 13 /* write on a pipe with no one to read it */ |
|
|
85 #define SIGALRM 14 /* alarm clock */ |
|
|
86 #define SIGTERM 15 /* software termination signal from kill */ |
|
|
87 |
|
|
88 //---------------------------------------------------------------------------- |
|
|
89 // Thread support. This setting is used in thread-pkts.h |
|
|
90 #ifdef CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT |
|
|
91 #define DEBUG_THREADS 1 |
|
|
92 #else |
|
|
93 #define DEBUG_THREADS 0 |
|
|
94 #endif |
|
|
95 |
|
|
96 // The function stub_copy_registers() is statically defined in |
|
|
97 // thread-packets.c, but in eCos this external stub is defined as it |
|
|
98 // is used in dbg_gdb.cxx. |
|
|
99 externC void __stub_copy_registers(target_register_t *dest, |
|
|
100 target_register_t *src); |
|
|
101 |
|
|
102 //---------------------------------------------------------------------------- |
|
|
103 // Memory accessor functions. |
|
|
104 #define TARGET_HAS_OWN_MEM_FUNCS |
|
|
105 |
|
|
106 //---------------------------------------------------------------------------- |
|
|
107 // Target extras?! |
|
|
108 extern int __process_target_query(char * pkt, char * out, int maxOut); |
|
|
109 extern int __process_target_set(char * pkt, char * out, int maxout); |
|
|
110 extern int __process_target_packet(char * pkt, char * out, int maxout); |
|
|
111 |
|
|
112 //--------------------------------------------------------------------------- |
|
|
113 // Declarations to avoid compiler warnings. |
|
|
114 |
|
|
115 // Set the baud rate for the current serial port. |
|
|
116 extern void __set_baud_rate (int baud); |
|
|
117 |
|
|
118 // Write C to the current serial port. |
|
|
119 extern void putDebugChar (int c); |
|
|
120 |
|
|
121 // Read one character from the current serial port. |
|
|
122 extern int getDebugChar (void); |
|
|
123 |
|
|
124 // Push CH back onto the debug stream. |
|
|
125 extern void ungetDebugChar (int ch); |
|
|
126 |
|
|
127 // Reset the board. |
|
|
128 extern void __reset (void); |
|
|
129 |
|
|
130 // Multi-bp support. |
|
|
131 extern int __set_breakpoint (target_register_t addr); |
|
|
132 extern int __remove_breakpoint (target_register_t addr); |
|
|
133 |
|
|
134 /* Install the standard set of trap handlers for the stub. */ |
|
|
135 extern void __install_traps (void); |
|
|
136 |
|
|
137 /* Address in text section of a breakpoint instruction. */ |
|
|
138 |
|
|
139 extern void CYG_LABEL_NAME(breakinst) (void); |
|
|
140 |
|
|
141 /* The opcode for a breakpoint instruction. */ |
|
|
142 |
|
|
143 extern unsigned long __break_opcode (void); |
|
|
144 |
|
|
145 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT |
|
|
146 extern void cyg_hal_gdb_interrupt (target_register_t pc); |
|
|
147 extern int cyg_hal_gdb_remove_break (target_register_t pc); |
|
|
148 #endif |
|
|
149 |
|
|
150 //---------------------------------------------------------------------------- |
|
|
151 // eCos extensions to the stub |
|
|
152 |
|
|
153 extern void hal_output_gdb_string(target_register_t str, int string_len); |
|
|
154 |
|
|
155 extern target_register_t registers[]; // The current saved registers. |
|
|
156 extern target_register_t * _registers ; |
|
|
157 extern HAL_SavedRegisters *_hal_registers; |
|
|
158 |
|
|
159 extern int cyg_hal_gdb_break; |
|
|
160 |
|
|
161 //--------------------------------------------------------------------------- |
|
|
162 // Local strcpy/strlen functions removes libc dependency. |
|
|
163 static inline char *strcpy( char *s, const char *t) |
|
|
164 { |
|
|
165 char *r = s; |
|
|
166 |
|
|
167 while( *t ) *s++ = *t++; |
|
|
168 |
|
|
169 // Terminate the copied string. |
|
|
170 *s = 0; |
|
|
171 |
|
|
172 return r; |
|
|
173 } |
|
|
174 |
|
|
175 static inline int strlen( const char *s ) |
|
|
176 { |
|
|
177 int r = 0; |
|
|
178 while( *s++ ) r++; |
|
|
179 return r; |
|
|
180 } |
|
|
181 |
|
|
182 //----------------------------------------------------------------------------- |
|
|
183 // Repeat the cache definitions here to avoid too much hackery in |
|
|
184 // generic-stub.h |
|
|
185 typedef enum { |
|
|
186 CACHE_NOOP, CACHE_ENABLE, CACHE_DISABLE, CACHE_FLUSH |
|
|
187 } cache_control_t; |
|
|
188 |
|
|
189 /* Perform the specified operation on the instruction cache. |
|
|
190 Returns 1 if the cache is enabled, 0 otherwise. */ |
|
|
191 extern int __instruction_cache (cache_control_t request); |
|
|
192 /* Perform the specified operation on the data cache. |
|
|
193 Returns 1 if the cache is enabled, 0 otherwise. */ |
|
|
194 extern int __data_cache (cache_control_t request); |
|
|
195 |
|
|
196 #ifdef __cplusplus |
|
|
197 } // extern "C" |
|
|
198 #endif |
|
|
199 |
|
|
200 #endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
|
|
201 |
|
|
202 //----------------------------------------------------------------------------- |
|
|
203 #endif // CYGONCE_HAL_HAL_STUB_H |
|
|
204 // End of hal_stub.h |