Mercurial > ecos
comparison packages/hal/common/current/src/hal_stub.c @ 151:25e238959bae
Merge from eCos master repository on 2001-02-12-23:44:24-GMT
| author | jlarmour |
|---|---|
| date | Tue, 13 Feb 2001 01:23:16 +0000 |
| parents | 6b5f480c6929 |
| children | e2d866e32dac |
comparison
equal
deleted
inserted
replaced
| 150:f0e3fb000de8 | 151:25e238959bae |
|---|---|
| 321 __interruptible_control(0); | 321 __interruptible_control(0); |
| 322 #endif | 322 #endif |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 | 325 |
| 326 #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT | |
| 327 //----------------------------------------------------------------------------- | |
| 328 // GDB O-packetizer function. | |
| 329 | |
| 330 // This gets called via the virtual vector debug comms entry and | |
| 331 // handles O-packetization. The debug comms entries are used for the | |
| 332 // actual device IO. | |
| 333 | |
| 334 static cyg_uint8 | |
| 335 cyg_hal_gdb_diag_getc(void* __ch_data) | |
| 336 { | |
| 337 cyg_uint8 __ch; | |
| 338 hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS(); | |
| 339 CYGARC_HAL_SAVE_GP(); | |
| 340 | |
| 341 __ch = CYGACC_COMM_IF_GETC(*__chan); | |
| 342 | |
| 343 CYGARC_HAL_RESTORE_GP(); | |
| 344 | |
| 345 return __ch; | |
| 346 } | |
| 347 | |
| 348 | |
| 349 static void | |
| 350 cyg_hal_gdb_diag_putc(void* __ch_data, cyg_uint8 c) | |
| 351 { | |
| 352 static char line[100]; | |
| 353 static int pos = 0; | |
| 354 CYGARC_HAL_SAVE_GP(); | |
| 355 | |
| 356 // No need to send CRs | |
| 357 if( c == '\r' ) return; | |
| 358 | |
| 359 line[pos++] = c; | |
| 360 | |
| 361 if( c == '\n' || pos == sizeof(line) ) | |
| 362 { | |
| 363 CYG_INTERRUPT_STATE old; | |
| 364 hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS(); | |
| 365 | |
| 366 // Disable interrupts. This prevents GDB trying to interrupt us | |
| 367 // while we are in the middle of sending a packet. The serial | |
| 368 // receive interrupt will be seen when we re-enable interrupts | |
| 369 // later. | |
| 370 #ifdef CYG_HAL_STARTUP_ROM | |
| 371 HAL_DISABLE_INTERRUPTS(old); | |
| 372 #else | |
| 373 CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION(old); | |
| 374 #endif | |
| 375 | |
| 376 while(1) | |
| 377 { | |
| 378 static const char hex[] = "0123456789ABCDEF"; | |
| 379 cyg_uint8 csum = 0, c1; | |
| 380 int i; | |
| 381 | |
| 382 CYGACC_COMM_IF_PUTC(*__chan, '$'); | |
| 383 CYGACC_COMM_IF_PUTC(*__chan, 'O'); | |
| 384 csum += 'O'; | |
| 385 for( i = 0; i < pos; i++ ) | |
| 386 { | |
| 387 char ch = line[i]; | |
| 388 char h = hex[(ch>>4)&0xF]; | |
| 389 char l = hex[ch&0xF]; | |
| 390 CYGACC_COMM_IF_PUTC(*__chan, h); | |
| 391 CYGACC_COMM_IF_PUTC(*__chan, l); | |
| 392 csum += h; | |
| 393 csum += l; | |
| 394 } | |
| 395 CYGACC_COMM_IF_PUTC(*__chan, '#'); | |
| 396 CYGACC_COMM_IF_PUTC(*__chan, hex[(csum>>4)&0xF]); | |
| 397 CYGACC_COMM_IF_PUTC(*__chan, hex[csum&0xF]); | |
| 398 | |
| 399 nak: | |
| 400 c1 = CYGACC_COMM_IF_GETC(*__chan); | |
| 401 | |
| 402 if( c1 == '+' ) break; | |
| 403 | |
| 404 if( cyg_hal_is_break( &c1 , 1 ) ) { | |
| 405 // Caller's responsibility to react on this. | |
| 406 CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(1); | |
| 407 break; | |
| 408 } | |
| 409 if( c1 != '-' ) goto nak; | |
| 410 } | |
| 411 | |
| 412 pos = 0; | |
| 413 // And re-enable interrupts | |
| 414 #ifdef CYG_HAL_STARTUP_ROM | |
| 415 HAL_RESTORE_INTERRUPTS(old); | |
| 416 #else | |
| 417 CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION(old); | |
| 418 #endif | |
| 419 } | |
| 420 | |
| 421 CYGARC_HAL_RESTORE_GP(); | |
| 422 } | |
| 423 | |
| 424 static void | |
| 425 cyg_hal_gdb_diag_write(void* __ch_data, const cyg_uint8* __buf, | |
| 426 cyg_uint32 __len) | |
| 427 { | |
| 428 CYGARC_HAL_SAVE_GP(); | |
| 429 | |
| 430 while(__len-- > 0) | |
| 431 cyg_hal_gdb_diag_putc(__ch_data, *__buf++); | |
| 432 | |
| 433 CYGARC_HAL_RESTORE_GP(); | |
| 434 } | |
| 435 | |
| 436 static void | |
| 437 cyg_hal_gdb_diag_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len) | |
| 438 { | |
| 439 CYGARC_HAL_SAVE_GP(); | |
| 440 | |
| 441 while(__len-- > 0) | |
| 442 *__buf++ = cyg_hal_gdb_diag_getc(__ch_data); | |
| 443 | |
| 444 CYGARC_HAL_RESTORE_GP(); | |
| 445 } | |
| 446 | |
| 447 static int | |
| 448 cyg_hal_gdb_diag_control(void *__ch_data, __comm_control_cmd_t __func, ...) | |
| 449 { | |
| 450 // Do nothing (yet). | |
| 451 return 0; | |
| 452 } | |
| 453 #endif | |
| 454 | |
| 455 | |
| 456 //----------------------------------------------------------------------------- | 326 //----------------------------------------------------------------------------- |
| 457 // eCos stub entry and exit magic. | 327 // eCos stub entry and exit magic. |
| 458 | 328 |
| 459 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT | 329 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT |
| 460 int cyg_hal_gdb_break; | 330 int cyg_hal_gdb_break; |
| 563 initialized = 1; | 433 initialized = 1; |
| 564 | 434 |
| 565 // Get serial port initialized. | 435 // Get serial port initialized. |
| 566 HAL_STUB_PLATFORM_INIT_SERIAL(); | 436 HAL_STUB_PLATFORM_INIT_SERIAL(); |
| 567 | 437 |
| 568 #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT | |
| 569 { | |
| 570 hal_virtual_comm_table_t* comm; | |
| 571 int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); | |
| 572 | |
| 573 // Initialize mangler procs | |
| 574 CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_MANGLER); | |
| 575 comm = CYGACC_CALL_IF_CONSOLE_PROCS(); | |
| 576 CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_gdb_diag_write); | |
| 577 CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_gdb_diag_read); | |
| 578 CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_gdb_diag_putc); | |
| 579 CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_gdb_diag_getc); | |
| 580 CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_gdb_diag_control); | |
| 581 | |
| 582 // Now either restore the previous console channel, or let the | |
| 583 // mangler stay in its place. The latter happens if the | |
| 584 // console channel was previously unspecified, or if the | |
| 585 // previous channel matches the used for GDB communication. | |
| 586 if (CYGNUM_CALL_IF_SET_COMM_ID_EMPTY != cur | |
| 587 && CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL != cur) | |
| 588 CYGACC_CALL_IF_SET_CONSOLE_COMM(cur); | |
| 589 | |
| 590 // Set the debug channel. | |
| 591 CYGACC_CALL_IF_SET_DEBUG_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL); | |
| 592 } | |
| 593 #endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT | |
| 594 | |
| 595 #ifdef HAL_STUB_PLATFORM_INIT | 438 #ifdef HAL_STUB_PLATFORM_INIT |
| 596 // If the platform defines any initialization code, call it here. | 439 // If the platform defines any initialization code, call it here. |
| 597 HAL_STUB_PLATFORM_INIT(); | 440 HAL_STUB_PLATFORM_INIT(); |
| 598 #endif | 441 #endif |
| 599 | 442 |
| 612 #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT | 455 #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT |
| 613 __call_if_reset_t __rom_reset = CYGACC_CALL_IF_RESET_GET(); | 456 __call_if_reset_t __rom_reset = CYGACC_CALL_IF_RESET_GET(); |
| 614 if (__rom_reset) | 457 if (__rom_reset) |
| 615 __rom_reset(); | 458 __rom_reset(); |
| 616 #else | 459 #else |
| 617 HAL_STUB_PLATFORM_RESET(); | 460 HAL_PLATFORM_RESET(); |
| 618 #endif | 461 #endif |
| 619 } | 462 } |
| 620 | 463 |
| 621 //----------------------------------------------------------------------------- | 464 //----------------------------------------------------------------------------- |
| 622 // Breakpoint support. | 465 // Breakpoint support. |
