📄 v850_ice.cxx
字号:
//========================================================================//// v850_ice.cxx//// ICE debugging support for V850 processors////========================================================================//####ECOSGPLCOPYRIGHTBEGIN####// -------------------------------------------// This file is part of eCos, the Embedded Configurable Operating System.// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.//// eCos is free software; you can redistribute it and/or modify it under// the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 or (at your option) any later version.//// eCos is distributed in the hope that it will be useful, but WITHOUT ANY// WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License// for more details.//// You should have received a copy of the GNU General Public License along// with eCos; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.//// As a special exception, if other files instantiate templates or use macros// or inline functions from this file, or you compile this file and link it// with other works to produce a work based on this file, this file does not// by itself cause the resulting work to be covered by the GNU General Public// License. However the source code for this file must still be made available// in accordance with section (3) of the GNU General Public License.//// This exception does not invalidate any other reasons why a work based on// this file might be covered by the GNU General Public License.//// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.// at http://sources.redhat.com/ecos/ecos-license/// -------------------------------------------//####ECOSGPLCOPYRIGHTEND####//========================================================================//#####DESCRIPTIONBEGIN####//// Author(s): jlarmour// Contributors: // Date: 2001-03-12// Purpose: // Description: ICE debugging support for V850 processors// Usage: ////####DESCRIPTIONEND####////========================================================================#include <pkgconf/hal.h>#ifdef CYGDBG_HAL_V850_ICE#include <stddef.h>#include <cyg/infra/cyg_type.h>#include <cyg/hal/dbg-threads-api.h>#include <cyg/hal/nec-stub.h>#include <cyg/hal/hal_arch.h>#define ICEDEBUG 0#if ICEDEBUG#include <cyg/infra/diag.h>#endif/* ----------------------------------------------------------------------- *//* Common ICE syscall information *//* Magic area for syscall information, from vectors.S */__externC char hal_v85x_ice_syscall_info[];/* Syscall operation codes. This is a "contract" with the host. */#define V850ICE_SYSCALL_GET_THREADNEXT 1#define V850ICE_SYSCALL_GET_THREADREGS 2#define V850ICE_SYSCALL_SET_THREADREGS 3#define V850ICE_SYSCALL_GET_CURRTHREAD 4#define V850ICE_SYSCALL_GET_THREADINFO 5#define V850ICE_SYSCALL_CONSOLE_INPUT 6/* System call information area layout */#define ICE_SYSCALL_INFO_VALIDATOR (*(int *)&hal_v85x_ice_syscall_info[0])#define ICE_SYSCALL_INFO_STARTPC (*(int *)&hal_v85x_ice_syscall_info[4])#define ICE_SYSCALL_INFO_ENDPC (*(int *)&hal_v85x_ice_syscall_info[8])#define ICE_SYSCALL_INFO_STACK (*(int *)&hal_v85x_ice_syscall_info[12])#define ICE_SYSCALL_INFO_IOBUF (*(int *)&hal_v85x_ice_syscall_info[16])#define ICE_SYSCALL_INFO_DIAGOUTPC (*(int *)&hal_v85x_ice_syscall_info[20])#define ICE_SYSCALL_INFO_DIAGOUTBUF (*(int *)&hal_v85x_ice_syscall_info[24])#define ICE_SYSCALL_INFO_DIAGOUTBUFEND (*(int *)&hal_v85x_ice_syscall_info[28])/* We can't use normal memcpy when invoked via the ICE. It may be unsafe. */static voidmy_memcpy( void *vd, const void *vs, int n){ char *d = (char *)vd; char *s = (char *)vs; while (n--) *d++=*s++;}static voidmy_memset( void *vs, char c, int n){ char *s = (char *)vs; while (n--) *s++ = c;}/* ----------------------------------------------------------------------- *//* Support for diag output via ICE */#ifdef CYGDBG_HAL_V85X_V850_ICE_DIAG#include <cyg/hal/hal_if.h>static volatile cyg_uint8 v850ice_output_buf[128];static volatile cyg_uint8 *v850ice_output_end = v850ice_output_buf;#define OUTPUT_BUF_END (&v850ice_output_buf[ sizeof(v850ice_output_buf)])static volatile cyg_uint8 v850ice_input_buf[128];#define INPUT_BUF_END (&v850ice_input_buf[ sizeof(v850ice_input_buf)])static volatile cyg_uint8 *v850ice_input_ptr_put = v850ice_input_buf;static volatile cyg_uint8 *v850ice_input_ptr_get = v850ice_input_buf;static volatile cyg_uint8 v850ice_input_buf_bytes_used = 0;__externC void hal_v850_ice_output_break(void);static voidhal_v850_ice_indicate_output(void){ HAL_BREAKPOINT(hal_v850_ice_output_break);}// Actually write charactervoidcyg_hal_plf_diag_ice_putc(void* __ch_data, cyg_uint8 c){ CYGARC_HAL_SAVE_GP(); // Send character *v850ice_output_end++ = c; if (c == '\n' || v850ice_output_end == OUTPUT_BUF_END) { hal_v850_ice_indicate_output(); v850ice_output_end = v850ice_output_buf; } CYGARC_HAL_RESTORE_GP();}static cyg_boolcyg_hal_plf_diag_ice_getc_nonblock(void* __ch_data, cyg_uint8* ch){ if ( v850ice_input_buf_bytes_used == 0 ) return false; // buffer empty *ch = *v850ice_input_ptr_get++; if ( v850ice_input_ptr_get == INPUT_BUF_END ) { v850ice_input_ptr_get = v850ice_input_buf; } v850ice_input_buf_bytes_used--; return true;}cyg_uint8cyg_hal_plf_diag_ice_getc(void* __ch_data){ cyg_uint8 ch; CYGARC_HAL_SAVE_GP(); while(!cyg_hal_plf_diag_ice_getc_nonblock(__ch_data, &ch)); CYGARC_HAL_RESTORE_GP(); return ch;}static cyg_boolcyg_hal_plf_diag_ice_receive_char(cyg_uint8 ch){ /* buffer full? */ if ( v850ice_input_buf_bytes_used == sizeof(v850ice_input_buf) ) return false; *v850ice_input_ptr_put++ = ch; if ( v850ice_input_ptr_put == INPUT_BUF_END ) { v850ice_input_ptr_put = v850ice_input_buf; } return true;}static voidcyg_hal_plf_diag_ice_write(void* __ch_data, const cyg_uint8* __buf, cyg_uint32 __len){ CYGARC_HAL_SAVE_GP();#define MIN(__x, __y) ((__x) < (__y) ? (__x) : (__y)) while(__len > 0) { int copylen = MIN(__len, (cyg_uint32) (OUTPUT_BUF_END - v850ice_output_end)); my_memcpy( (void *)v850ice_output_buf, __buf, copylen ); __len -= copylen; v850ice_output_end += copylen; hal_v850_ice_indicate_output(); v850ice_output_end = v850ice_output_buf; } CYGARC_HAL_RESTORE_GP();}static voidcyg_hal_plf_diag_ice_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len){ CYGARC_HAL_SAVE_GP(); while(__len-- > 0) *__buf++ = cyg_hal_plf_diag_ice_getc(__ch_data); CYGARC_HAL_RESTORE_GP();}static cyg_int32 msec_timeout = 1000;cyg_boolcyg_hal_plf_diag_ice_getc_timeout(void* __ch_data, cyg_uint8* ch){ int delay_count = msec_timeout * 10; // delay in .1 ms steps cyg_bool res; CYGARC_HAL_SAVE_GP(); for(;;) { res = cyg_hal_plf_diag_ice_getc_nonblock(__ch_data, ch); if (res || 0 == delay_count--) break; CYGACC_CALL_IF_DELAY_US(100); } CYGARC_HAL_RESTORE_GP(); return res;}static intcyg_hal_plf_diag_ice_control(void *__ch_data, __comm_control_cmd_t __func, ...){ static int irq_state = 0; int ret = 0; CYGARC_HAL_SAVE_GP(); switch (__func) { case __COMMCTL_IRQ_ENABLE: irq_state = 1; break; case __COMMCTL_IRQ_DISABLE: ret = irq_state; irq_state = 0; break; case __COMMCTL_DBG_ISR_VECTOR: ret = 0; break; case __COMMCTL_SET_TIMEOUT: { va_list ap; va_start(ap, __func); ret = msec_timeout; msec_timeout = va_arg(ap, cyg_uint32); va_end(ap); } default: break; } CYGARC_HAL_RESTORE_GP(); return ret;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -