Mercurial > ecos
diff packages/hal/powerpc/viper/current/src/hal_diag.c @ 382:0f9e057c8163
Mostly cosmetic cleanups. TS1000 FLASH package renamed. Remove some old cruft in Viper & TS1000 ports.
| author | gthomas |
|---|---|
| date | Fri, 18 Oct 2002 16:56:52 +0000 |
| parents | d2c90368aeef |
| children | 74dbf4c3f2e1 |
line wrap: on
line diff
--- a/packages/hal/powerpc/viper/current/src/hal_diag.c +++ b/packages/hal/powerpc/viper/current/src/hal_diag.c @@ -77,199 +77,7 @@ cyg_hal_plf_comms_init(void) return; initialized = 1; - cyg_hal_plf_serial_init(); -} - - -#if !defined(CYGSEM_HAL_VIRTUAL_VECTOR_DIAG) - -//----------------------------------------------------------------------------- -// Select default diag channel to use - -//#define CYG_KERNEL_DIAG_ROMART -//#define CYG_KERNEL_DIAG_SERIAL - -#if !defined(CYG_KERNEL_DIAG_SERIAL) -#define CYG_KERNEL_DIAG_SERIAL -#endif - -#ifdef CYGDBG_DIAG_BUF -// Keep diag messages in a buffer for later [re]display - -int enable_diag_uart = 1; -int enable_diag_buf = 1; -static char diag_buf[40960*4]; -static int diag_buf_ptr = 0; - -static void -diag_putc(char c) -{ - if (enable_diag_buf) { - diag_buf[diag_buf_ptr++] = c; - if (diag_buf_ptr == sizeof(diag_buf)) diag_buf_ptr--; - } -} - -void -dump_diag_buf(int start, int len) -{ - int i; - enable_diag_uart = 1; - enable_diag_buf = 0; - if (len == 0) len = diag_buf_ptr; - diag_printf("\nDiag buf\n"); - for (i = start; i < len; i++) { - hal_diag_write_char(diag_buf[i]); - } -} -#endif // CYGDBG_DIAG_BUF - - -//----------------------------------------------------------------------------- -// MBX board specific serial output; using GDB protocol by default: - - -#if defined(CYG_KERNEL_DIAG_SERIAL) - -EPPC *eppc; - -void hal_diag_init(void) -{ - static int init = 0; - if (init) return; - init++; - - // hardwired base - eppc = eppc_base(); - - // init the actual serial port - cyg_hal_plf_serial_init_channel(); -#ifdef CYGSEM_HAL_DIAG_MANGLER_GDB -#ifndef CYG_HAL_STARTUP_ROM - // We are talking to GDB; ack the "go" packet! - cyg_hal_plf_serial_putc(eppc, '+'); -#endif -#endif -} - -void hal_diag_write_char_serial( char c ) -{ - unsigned long __state; - HAL_DISABLE_INTERRUPTS(__state); - cyg_hal_plf_serial_putc(eppc, c); - HAL_RESTORE_INTERRUPTS(__state); -} - -#if defined(CYG_HAL_STARTUP_ROM) || !defined(CYGDBG_HAL_DIAG_TO_DEBUG_CHAN) -void hal_diag_write_char(char c) -{ -#ifdef CYGDBG_DIAG_BUF - diag_putc(c); - if (!enable_diag_uart) return; -#endif // CYGDBG_DIAG_BUF - hal_diag_write_char_serial(c); + cyg_hal_plf_serial_init(); // Defined in hal/powerpc/quicc/... } -#else // RAM start so encode for GDB - -void hal_diag_write_char(char c) -{ - static char line[100]; - static int pos = 0; - -#ifdef CYGDBG_DIAG_BUF - diag_putc(c); - if (!enable_diag_uart) return; -#endif // CYGDBG_DIAG_BUF - - // No need to send CRs - if( c == '\r' ) return; - - line[pos++] = c; - - if( c == '\n' || pos == sizeof(line) ) - { - CYG_INTERRUPT_STATE old; - - // Disable interrupts. This prevents GDB trying to interrupt us - // while we are in the middle of sending a packet. The serial - // receive interrupt will be seen when we re-enable interrupts - // later. - -#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS - CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION(old); -#else - HAL_DISABLE_INTERRUPTS(old); -#endif - - while(1) - { - static char hex[] = "0123456789ABCDEF"; - cyg_uint8 csum = 0; - int i; - - hal_diag_write_char_serial('$'); - hal_diag_write_char_serial('O'); - csum += 'O'; - for( i = 0; i < pos; i++ ) - { - char ch = line[i]; - char h = hex[(ch>>4)&0xF]; - char l = hex[ch&0xF]; - hal_diag_write_char_serial(h); - hal_diag_write_char_serial(l); - csum += h; - csum += l; - } - hal_diag_write_char_serial('#'); - hal_diag_write_char_serial(hex[(csum>>4)&0xF]); - hal_diag_write_char_serial(hex[csum&0xF]); - -#ifndef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT - // only gobble characters if no interrupt handler to grab ^Cs - // is installed (which is exclusive with device driver use) - - // Wait for the ACK character '+' from GDB here and handle - // receiving a ^C instead. This is the reason for this clause - // being a loop. - c = cyg_hal_plf_serial_getc(eppc); - - if( c == '+' ) - break; // a good acknowledge -#if 0 - if( c1 == 3 ) { - // Ctrl-C: breakpoint. - breakpoint(); - break; - } -#endif - // otherwise, loop round again -#else - break; -#endif - } - - pos = 0; - - // And re-enable interrupts -#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS - CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION(old); -#else - HAL_RESTORE_INTERRUPTS(old); -#endif - - } -} -#endif // NOT def CYG_HAL_STARTUP_ROM - - -void hal_diag_read_char(char *c) -{ - *c = cyg_hal_plf_serial_getc(eppc); -} - -#endif // CYG_KERNEL_DIAG_SERIAL - -#endif // CYGSEM_HAL_VIRTUAL_VECTOR_DIAG - // EOF hal_diag.c
