Mercurial > flash_v2
annotate packages/hal/common/current/src/hal_stub.c @ 12:4cc3eff958ab ecos-sw-1999-06-04
Merge from eCos master repository on 1999-06-04-22:24:56-BST
| author | jlarmour |
|---|---|
| date | Fri, 04 Jun 1999 15:08:16 +0000 |
| parents | d3fbcdfa1b2f |
| children | 01ce82f3e11a |
| rev | line source |
|---|---|
| 2 | 1 //============================================================================= |
| 2 // | |
| 3 // hal_stub.c | |
| 4 // | |
| 5 // Helper functions for stub, specific to eCos HAL | |
| 6 // | |
| 7 //============================================================================= | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 25 // by Cygnus are Copyright (C) 1998, 1999 Cygnus Solutions. | |
| 26 // All Rights Reserved. | |
| 27 // ------------------------------------------- | |
| 28 // | |
| 29 //####COPYRIGHTEND#### | |
| 30 //============================================================================= | |
| 31 //#####DESCRIPTIONBEGIN#### | |
| 32 // | |
| 33 // Author(s): jskov (based on powerpc/cogent hal_stub.c) | |
| 34 // Contributors:jskov | |
| 35 // Date: 1999-02-12 | |
| 36 // Purpose: Helper functions for stub, specific to eCos HAL | |
| 37 // Description: Parts of the GDB stub requirements are provided by | |
| 38 // the eCos HAL, rather than target and/or board specific | |
| 39 // code. | |
| 40 // | |
| 41 //####DESCRIPTIONEND#### | |
| 42 // | |
| 43 //============================================================================= | |
| 44 | |
| 45 #include <pkgconf/hal.h> | |
| 46 | |
| 47 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS | |
| 48 | |
| 49 #include <cyg/hal/hal_stub.h> // Our header | |
| 50 | |
| 51 #include <cyg/hal/hal_arch.h> // HAL_BREAKINST | |
| 52 #include <cyg/hal/hal_cache.h> // HAL_xCACHE_x | |
| 53 #include <cyg/hal/hal_intr.h> // interrupt disable/restore | |
| 54 | |
| 55 #ifdef CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT | |
| 56 #include <cyg/hal/dbg-threads-api.h> // dbg_currthread_id | |
| 57 #endif | |
| 58 | |
| 59 | |
| 60 //----------------------------------------------------------------------------- | |
| 61 // Extra eCos data. | |
| 62 | |
| 63 // Saved registers. | |
| 64 HAL_SavedRegisters *_hal_registers; | |
| 65 target_register_t * _registers; // Pointer to current set of registers | |
| 66 target_register_t registers[NUMREGS]; | |
| 67 target_register_t alt_registers[NUMREGS] ; // Thread or saved process state | |
| 68 | |
| 69 // Interrupt control. | |
| 70 static volatile __PFI __interruptible_control; | |
| 71 | |
| 72 //----------------------------------------------------------------------------- | |
| 73 // Register access | |
| 74 | |
| 75 // Return the currently-saved value corresponding to register REG of | |
| 76 // the exception context. | |
| 77 target_register_t | |
| 78 get_register (regnames_t reg) | |
| 79 { | |
| 80 return _registers[reg]; | |
| 81 } | |
| 82 | |
| 83 // Store VALUE in the register corresponding to WHICH in the exception | |
| 84 // context. | |
| 85 void | |
| 86 put_register (regnames_t which, target_register_t value) | |
| 87 { | |
| 88 _registers[which] = value; | |
| 89 } | |
| 90 | |
| 91 //----------------------------------------------------------------------------- | |
| 92 // Serial stuff | |
| 93 | |
| 94 // Write C to the current serial port. | |
| 95 void | |
| 96 putDebugChar (int c) | |
| 97 { | |
| 98 HAL_STUB_PLATFORM_PUT_CHAR(c); | |
| 99 } | |
| 100 | |
| 101 // Read one character from the current serial port. | |
| 102 int | |
| 103 getDebugChar (void) | |
| 104 { | |
| 105 return HAL_STUB_PLATFORM_GET_CHAR(); | |
| 106 } | |
| 107 | |
| 108 // Set the baud rate for the current serial port. | |
| 109 void | |
| 110 __set_baud_rate (int baud) | |
| 111 { | |
| 112 HAL_STUB_PLATFORM_SET_BAUD_RATE(baud); | |
| 113 } | |
| 114 | |
| 115 //----------------------------------------------------------------------------- | |
| 116 // GDB interrupt (BREAK) support. | |
| 117 | |
| 118 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT | |
| 119 | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
10
diff
changeset
|
120 #if (HAL_BREAKINST_SIZE == 2) |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
10
diff
changeset
|
121 typedef cyg_uint16 t_inst; |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
10
diff
changeset
|
122 #elif (HAL_BREAKINST_SIZE == 4) |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
10
diff
changeset
|
123 typedef cyg_uint32 t_inst; |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
10
diff
changeset
|
124 #else |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
10
diff
changeset
|
125 #error "Don't know how to handle that size" |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
10
diff
changeset
|
126 #endif |
| 2 | 127 |
| 128 typedef struct | |
| 129 { | |
| 130 t_inst *targetAddr; | |
| 131 t_inst savedInstr; | |
| 132 } instrBuffer; | |
| 133 | |
| 134 static instrBuffer break_buffer; | |
| 135 | |
| 136 void | |
| 137 cyg_hal_gdb_interrupt (target_register_t pc) | |
| 138 { | |
| 139 if (NULL == break_buffer.targetAddr) { | |
| 140 break_buffer.targetAddr = (t_inst*) pc; | |
| 141 break_buffer.savedInstr = *(t_inst*)pc; | |
| 142 *(t_inst*)pc = (t_inst)HAL_BREAKINST; | |
| 143 | |
| 144 __data_cache(CACHE_FLUSH); | |
| 145 __instruction_cache(CACHE_FLUSH); | |
| 146 } | |
| 147 } | |
| 148 | |
| 149 int | |
| 150 cyg_hal_gdb_remove_break (target_register_t pc) | |
| 151 { | |
| 152 if ((t_inst*)pc == break_buffer.targetAddr) { | |
| 153 *(t_inst*)pc = break_buffer.savedInstr; | |
| 154 break_buffer.targetAddr = NULL; | |
| 155 | |
| 156 __data_cache(CACHE_FLUSH); | |
| 157 __instruction_cache(CACHE_FLUSH); | |
| 158 return 1; | |
| 159 } | |
| 160 return 0; | |
| 161 } | |
| 162 | |
| 163 #endif // CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT | |
| 164 | |
| 165 // Use this function to disable serial interrupts whenever reply | |
| 166 // characters are expected from GDB. The reason we want to control | |
| 167 // whether the target can be interrupted or not is simply that GDB on | |
| 168 // the host will be sending acknowledge characters/commands while the | |
| 169 // stub is running - if serial interrupts were still active, the | |
| 170 // characters would never reach the (polling) getDebugChar. | |
| 171 static void | |
| 172 interruptible(int state) | |
| 173 { | |
| 174 static int __interrupts_suspended = 0; | |
| 175 | |
| 176 if (__interruptible_control) { | |
| 177 if (state) { | |
| 178 __interrupts_suspended--; | |
| 179 if (0 >= __interrupts_suspended) { | |
| 180 __interrupts_suspended = 0; | |
| 181 __interruptible_control(1); | |
| 182 } | |
| 183 } else { | |
| 184 __interrupts_suspended++; | |
| 185 if (1 == __interrupts_suspended) | |
| 186 __interruptible_control(0); | |
| 187 } | |
| 188 } | |
| 189 } | |
| 190 | |
| 191 //----------------------------------------------------------------------------- | |
| 192 // eCos stub entry and exit magic. | |
| 193 | |
| 194 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT | |
| 195 int cyg_hal_gdb_break; | |
| 196 #endif | |
| 197 | |
| 198 // Called at stub *entry* | |
| 199 static void | |
| 200 handle_exception_cleanup( void ) | |
| 201 { | |
| 202 interruptible(0); | |
| 203 | |
| 204 // Expand the HAL_SavedRegisters structure into the GDB register | |
| 205 // array format. | |
| 206 HAL_GET_GDB_REGISTERS(®isters[0], _hal_registers); | |
| 207 _registers = ®isters[0]; | |
| 208 | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
209 #ifdef HAL_STUB_PLATFORM_STUBS_FIXUP |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
210 // Some architectures may need to fix the PC in case of a partial |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
211 // or fully executed trap instruction. GDB only takes correct action |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
212 // when the PC is pointing to the breakpoint instruction it set. |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
213 // |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
214 // Most architectures would leave PC pointing at the trap |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
215 // instruction itself though, and so do not need to do anything |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
216 // special. |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
217 HAL_STUB_PLATFORM_STUBS_FIXUP(); |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
218 #endif |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
219 |
| 2 | 220 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT |
| 221 // FIXME: (there may be a better way to do this) | |
| 222 // If we hit a breakpoint set by the gdb interrupt stub, make it | |
| 223 // seem like an interrupt rather than having hit a breakpoint. | |
| 224 if (cyg_hal_gdb_remove_break(get_register (PC))) | |
| 225 cyg_hal_gdb_break = 1; | |
| 226 else | |
| 227 cyg_hal_gdb_break = 0; | |
| 228 #endif | |
| 229 } | |
| 230 | |
| 231 // Called at stub *exit* | |
| 232 static void | |
| 233 handle_exception_init( void ) | |
| 234 { | |
| 235 // Compact register array again. | |
| 236 HAL_SET_GDB_REGISTERS(_hal_registers, ®isters[0]); | |
| 237 | |
| 238 interruptible(1); | |
| 239 } | |
| 240 | |
| 241 | |
| 242 //----------------------------------------------------------------------------- | |
| 243 // Initialization. | |
| 244 | |
| 245 // Signal handler. | |
| 246 int | |
| 247 cyg_hal_process_signal (int signal) | |
| 248 { | |
| 249 // We don't care about the signal (atm). | |
| 250 return 0; | |
| 251 } | |
| 252 | |
| 253 // Install the standard set of trap handlers for the stub. | |
| 254 void | |
| 255 __install_traps (void) | |
| 256 { | |
| 257 // Set signal handling vector so we can treat 'C<signum>' as 'c'. | |
| 258 __process_signal_vec = &cyg_hal_process_signal; | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
259 // Set exit vector to reset vector. This will allow automatic reset on |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
260 // some platforms. |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
261 __process_exit_vec = &__reset; |
| 2 | 262 |
| 263 __cleanup_vec = &handle_exception_cleanup; | |
| 264 __init_vec = &handle_exception_init; | |
| 265 | |
| 266 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT | |
| 267 // Control of GDB interrupts. | |
| 268 __interruptible_control = HAL_STUB_PLATFORM_INTERRUPTIBLE; | |
| 269 #endif | |
| 270 | |
| 271 // Nothing further to do, handle_exception will be called when an | |
| 272 // exception occurs. | |
| 273 } | |
| 274 | |
| 275 // Initialize the hardware. | |
| 276 void | |
| 277 initHardware (void) | |
| 278 { | |
| 279 static int initialized = 0; | |
| 280 | |
| 281 if (!initialized) { | |
| 282 initialized = 1; | |
| 283 | |
|
10
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
284 #ifdef HAL_STUB_PLATFORM_INIT |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
285 // If the platform defines any initialization code, call it here. |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
286 HAL_STUB_PLATFORM_INIT(); |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
287 #endif |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
288 |
| 2 | 289 // Get serial port initialized. |
| 290 HAL_STUB_PLATFORM_INIT_SERIAL(); | |
| 291 | |
| 292 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT | |
| 293 // Get interrupt handler initialized. | |
| 294 HAL_STUB_PLATFORM_INIT_BREAK_IRQ(); | |
| 295 #endif | |
| 296 | |
| 297 #ifdef CYG_HAL_STARTUP_STUBS | |
| 298 // There may be extra initialization required when configured | |
| 299 // for stubs startup. | |
| 300 HAL_STUB_PLATFORM_STUBS_INIT(); | |
| 301 #endif | |
| 302 } | |
| 303 } | |
| 304 | |
| 305 // Reset the board. | |
| 306 void | |
| 307 __reset (void) | |
| 308 { | |
| 309 HAL_STUB_PLATFORM_RESET(); | |
| 310 } | |
| 311 | |
| 312 //----------------------------------------------------------------------------- | |
| 313 // Breakpoint support. | |
| 314 | |
| 315 #ifndef CYGPKG_HAL_ARM | |
| 316 // This function will generate a breakpoint exception. It is used at | |
| 317 // the beginning of a program to sync up with a debugger and can be | |
| 318 // used otherwise as a quick means to stop program execution and | |
| 319 // "break" into the debugger. | |
| 320 void | |
| 321 breakpoint() | |
| 322 { | |
| 323 HAL_BREAKPOINT(_breakinst); | |
| 324 } | |
| 325 | |
| 326 // This function returns the opcode for a 'trap' instruction. | |
| 327 unsigned long | |
| 328 __break_opcode () | |
| 329 { | |
| 330 return HAL_BREAKINST; | |
| 331 } | |
| 332 #endif | |
| 333 | |
| 334 // FIXME: Add support for multiple breakpoints (libstub/bplist-dynamic.c) | |
| 335 int __set_breakpoint (target_register_t addr) { return 0; } | |
| 336 int __remove_breakpoint (target_register_t addr) { return 0; } | |
| 337 | |
| 338 //----------------------------------------------------------------------------- | |
| 339 // Write the 'T' packet in BUFFER. SIGVAL is the signal the program received. | |
| 340 void | |
| 341 __build_t_packet (int sigval, char *buf) | |
| 342 { | |
| 343 target_register_t addr; | |
| 344 char *ptr = buf; | |
|
6
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
345 target_register_t sp; |
| 2 | 346 |
|
6
d376b777e2ce
Merge from eCos master repository on 1999-05-14-19:27:43-BST
jlarmour
parents:
2
diff
changeset
|
347 sp = (target_register_t) get_register (SP); |
| 2 | 348 |
| 349 *ptr++ = 'T'; | |
| 350 *ptr++ = __tohex (sigval >> 4); | |
| 351 *ptr++ = __tohex (sigval); | |
| 352 | |
| 353 #ifdef CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT | |
| 354 // Include thread ID if thread manipulation is required. | |
| 355 { | |
| 356 int id; | |
| 357 | |
| 358 *ptr++ = 't'; | |
| 359 *ptr++ = 'h'; | |
| 360 *ptr++ = 'r'; | |
| 361 *ptr++ = 'e'; | |
| 362 *ptr++ = 'a'; | |
| 363 *ptr++ = 'd'; | |
| 364 *ptr++ = ':'; | |
| 365 | |
| 366 #if (CYG_BYTEORDER == CYG_MSBFIRST) | |
| 367 id = dbg_currthread_id (); | |
| 368 #else | |
| 369 // FIXME: Temporary workaround for PR 18903. Thread ID must be | |
| 370 // big-endian in the T packet. | |
| 371 { | |
| 372 unsigned char* bep = (unsigned char*)&id; | |
| 373 int be_id; | |
| 374 | |
| 375 be_id = dbg_currthread_id (); | |
| 376 *bep++ = (be_id >> 24) & 0xff ; | |
| 377 *bep++ = (be_id >> 16) & 0xff ; | |
| 378 *bep++ = (be_id >> 8) & 0xff ; | |
| 379 *bep++ = (be_id & 0xff) ; | |
| 380 } | |
| 381 #endif | |
| 382 ptr = __mem2hex((char *)&id, ptr, sizeof(id), 0); | |
| 383 *ptr++ = ';'; | |
| 384 } | |
| 385 #endif | |
| 386 | |
| 387 *ptr++ = __tohex (PC >> 4); | |
| 388 *ptr++ = __tohex (PC); | |
| 389 *ptr++ = ':'; | |
| 390 addr = get_register (PC); | |
| 391 ptr = __mem2hex((char *)&addr, ptr, sizeof(addr), 0); | |
| 392 *ptr++ = ';'; | |
| 393 | |
| 394 *ptr++ = __tohex (SP >> 4); | |
| 395 *ptr++ = __tohex (SP); | |
| 396 *ptr++ = ':'; | |
| 397 ptr = __mem2hex((char *)&sp, ptr, sizeof(sp), 0); | |
| 398 *ptr++ = ';'; | |
| 399 | |
| 400 *ptr++ = 0; | |
| 401 } | |
| 402 | |
| 403 | |
| 404 //----------------------------------------------------------------------------- | |
| 405 // Cache functions. | |
| 406 | |
| 407 // Perform the specified operation on the instruction cache. | |
| 408 // Returns 1 if the cache is enabled, 0 otherwise. | |
| 409 int | |
| 410 __instruction_cache (cache_control_t request) | |
| 411 { | |
| 412 int state = 1; | |
| 413 | |
| 414 switch (request) { | |
| 415 case CACHE_ENABLE: | |
| 416 HAL_ICACHE_ENABLE(); | |
| 417 break; | |
| 418 case CACHE_DISABLE: | |
| 419 HAL_ICACHE_DISABLE(); | |
| 420 state = 0; | |
| 421 break; | |
| 422 case CACHE_FLUSH: | |
| 423 HAL_ICACHE_SYNC(); | |
|
10
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
424 #ifndef CYGPKG_HAL_MIPS |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
425 // SYNC and INVALIDATE_ALL are the same on the MIPS, |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
426 // so avoid doing it twice. |
| 2 | 427 HAL_ICACHE_INVALIDATE_ALL(); |
|
10
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
428 #endif |
| 2 | 429 break; |
| 430 case CACHE_NOOP: | |
| 431 /* fall through */ | |
| 432 default: | |
| 433 break; | |
| 434 } | |
| 435 | |
| 436 #ifdef HAL_ICACHE_IS_ENABLED | |
| 437 HAL_ICACHE_IS_ENABLED(state); | |
| 438 #endif | |
| 439 | |
| 440 return state; | |
| 441 } | |
| 442 | |
| 443 // Perform the specified operation on the data cache. | |
| 444 // Returns 1 if the cache is enabled, 0 otherwise. | |
| 445 int | |
| 446 __data_cache (cache_control_t request) | |
| 447 { | |
| 448 int state = 1; | |
| 449 | |
| 450 switch (request) { | |
| 451 case CACHE_ENABLE: | |
| 452 HAL_DCACHE_ENABLE(); | |
| 453 break; | |
| 454 case CACHE_DISABLE: | |
| 455 HAL_DCACHE_DISABLE(); | |
| 456 state = 0; | |
| 457 break; | |
| 458 case CACHE_FLUSH: | |
| 459 HAL_DCACHE_SYNC(); | |
|
10
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
460 #ifndef CYGPKG_HAL_MIPS |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
461 // SYNC and INVALIDATE_ALL are the same on the MIPS, |
|
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
462 // so avoid doing it twice. |
| 2 | 463 HAL_DCACHE_INVALIDATE_ALL(); |
|
10
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
464 #endif |
| 2 | 465 break; |
| 466 case CACHE_NOOP: | |
| 467 /* fall through */ | |
| 468 default: | |
| 469 break; | |
| 470 } | |
| 471 #ifdef HAL_DCACHE_IS_ENABLED | |
| 472 HAL_DCACHE_IS_ENABLED(state); | |
| 473 #endif | |
| 474 | |
| 475 return state; | |
| 476 } | |
| 477 | |
| 478 //----------------------------------------------------------------------------- | |
| 479 // Memory accessor functions. | |
| 480 | |
| 481 void *__mem_fault_handler = (void *)0; | |
| 482 | |
| 483 /* These are the "arguments" to __do_read_mem and __do_write_mem, | |
| 484 which are passed as globals to avoid squeezing them thru | |
| 485 __set_mem_fault_trap. */ | |
| 486 | |
| 487 static volatile target_register_t memCount; | |
| 488 | |
| 489 static void | |
| 490 __do_copy_mem (unsigned char* src, unsigned char* dst) | |
| 491 { | |
| 492 __mem_fault = 1; // Defaults to 'fail'. Is cleared | |
| 493 // when the copy loop completes. | |
| 494 __mem_fault_handler = &&err; | |
| 495 | |
| 496 while (memCount) | |
| 497 { | |
| 498 *dst++ = *src++; | |
| 499 memCount--; | |
| 500 } | |
| 501 | |
| 502 __mem_fault = 0; | |
| 503 | |
| 504 err: | |
| 505 __mem_fault_handler = (void *)0; | |
| 506 } | |
| 507 | |
| 508 /* | |
| 509 * __read_mem_safe: | |
| 510 * Get contents of target memory, abort on error. | |
| 511 */ | |
| 512 | |
| 513 int | |
| 514 __read_mem_safe (unsigned char *dst, target_register_t src, int count) | |
| 515 { | |
| 516 memCount = count; | |
| 517 __do_copy_mem((unsigned char*) src, (unsigned char*) dst); | |
| 518 return count - memCount; // return number of bytes successfully read | |
| 519 } | |
| 520 | |
| 521 /* | |
| 522 * __write_mem_safe: | |
| 523 * Set contents of target memory, abort on error. | |
| 524 */ | |
| 525 | |
| 526 int | |
| 527 __write_mem_safe (unsigned char *src, target_register_t dst, int count) | |
| 528 { | |
| 529 memCount = count; | |
| 530 __do_copy_mem((unsigned char*) src, (unsigned char*) dst); | |
| 531 return count - memCount; // return number of bytes successfully written | |
| 532 } | |
| 533 | |
| 534 //----------------------------------------------------------------------------- | |
| 535 // Target extras?! | |
| 536 int | |
| 537 __process_target_query(char * pkt, char * out, int maxOut) | |
| 538 { return 0 ; } | |
| 539 int | |
| 540 __process_target_set(char * pkt, char * out, int maxout) | |
| 541 { return 0 ; } | |
| 542 int | |
| 543 __process_target_packet(char * pkt, char * out, int maxout) | |
| 544 { return 0 ; } | |
| 545 | |
| 546 // GDB string output, making sure interrupts are disabled. | |
| 547 // This function gets used by some diag output functions. | |
| 548 void | |
| 549 hal_output_gdb_string(target_register_t str, int string_len) | |
| 550 { | |
| 551 unsigned long __state; | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
6
diff
changeset
|
552 HAL_DISABLE_INTERRUPTS(__state); |
| 2 | 553 __output_gdb_string(str, string_len); |
| 554 HAL_RESTORE_INTERRUPTS(__state); | |
| 555 } | |
| 556 | |
| 557 #endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
