//=============================================================================
|
//=============================================================================
|
//
|
//
|
// hal_if.c
|
// hal_if.c
|
//
|
//
|
// ROM/RAM interfacing functions
|
// ROM/RAM interfacing functions
|
//
|
//
|
//=============================================================================
|
//=============================================================================
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
// -------------------------------------------
|
// -------------------------------------------
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
// Copyright (C) 2002 Gary Thomas
|
// Copyright (C) 2002 Gary Thomas
|
//
|
//
|
// eCos is free software; you can redistribute it and/or modify it under
|
// 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
|
// 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.
|
// 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
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for more details.
|
// for more details.
|
//
|
//
|
// You should have received a copy of the GNU General Public License along
|
// You should have received a copy of the GNU General Public License along
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
//
|
//
|
// As a special exception, if other files instantiate templates or use macros
|
// 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
|
// 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
|
// 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
|
// 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
|
// License. However the source code for this file must still be made available
|
// in accordance with section (3) of the GNU General Public License.
|
// 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 exception does not invalidate any other reasons why a work based on
|
// this file might be covered by the GNU General Public License.
|
// this file might be covered by the GNU General Public License.
|
//
|
//
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// -------------------------------------------
|
// -------------------------------------------
|
//####ECOSGPLCOPYRIGHTEND####
|
//####ECOSGPLCOPYRIGHTEND####
|
//=============================================================================
|
//=============================================================================
|
//#####DESCRIPTIONBEGIN####
|
//#####DESCRIPTIONBEGIN####
|
//
|
//
|
// Author(s): jskov
|
// Author(s): jskov
|
// Contributors:jskov
|
// Contributors:jskov
|
// Date: 2000-06-07
|
// Date: 2000-06-07
|
//
|
//
|
//####DESCRIPTIONEND####
|
//####DESCRIPTIONEND####
|
//
|
//
|
//=============================================================================
|
//=============================================================================
|
|
|
#include <pkgconf/hal.h>
|
#include <pkgconf/hal.h>
|
|
|
#ifdef CYGPKG_KERNEL
|
#ifdef CYGPKG_KERNEL
|
# include <pkgconf/kernel.h>
|
# include <pkgconf/kernel.h>
|
#endif
|
#endif
|
|
|
#include <cyg/infra/cyg_ass.h> // assertions
|
#include <cyg/infra/cyg_ass.h> // assertions
|
|
|
#include <cyg/hal/hal_arch.h> // set/restore GP
|
#include <cyg/hal/hal_arch.h> // set/restore GP
|
|
|
#include <cyg/hal/hal_io.h> // IO macros
|
#include <cyg/hal/hal_io.h> // IO macros
|
#include <cyg/hal/hal_if.h> // our interface
|
#include <cyg/hal/hal_if.h> // our interface
|
|
|
#include <cyg/hal/hal_diag.h> // Diag IO
|
#include <cyg/hal/hal_diag.h> // Diag IO
|
#include <cyg/hal/hal_misc.h> // User break
|
#include <cyg/hal/hal_misc.h> // User break
|
|
|
#include <cyg/hal/hal_stub.h> // stub functionality
|
#include <cyg/hal/hal_stub.h> // stub functionality
|
|
|
#include <cyg/hal/hal_intr.h> // hal_vsr_table and others
|
#include <cyg/hal/hal_intr.h> // hal_vsr_table and others
|
|
|
#ifdef CYGPKG_REDBOOT
|
#ifdef CYGPKG_REDBOOT
|
#include <pkgconf/redboot.h>
|
#include <pkgconf/redboot.h>
|
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
|
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
|
#include <redboot.h>
|
#include <redboot.h>
|
#include <flash_config.h>
|
#include <flash_config.h>
|
#endif
|
#endif
|
#endif
|
#endif
|
|
|
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
|
|
externC void patch_dbg_syscalls(void * vector);
|
externC void patch_dbg_syscalls(void * vector);
|
externC void init_thread_syscall(void * vector);
|
externC void init_thread_syscall(void * vector);
|
|
|
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
// Implementations and function wrappers for monitor services
|
// Implementations and function wrappers for monitor services
|
|
|
// flash config state queries
|
// flash config state queries
|
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
|
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
|
|
|
static __call_if_flash_cfg_op_fn_t flash_config_op;
|
static __call_if_flash_cfg_op_fn_t flash_config_op;
|
|
|
static cyg_bool
|
static cyg_bool
|
flash_config_op( int op, char * key, void *val, int type)
|
flash_config_op( int op, char * key, void *val, int type)
|
{
|
{
|
cyg_bool res = false;
|
cyg_bool res = false;
|
|
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
switch ( op ) {
|
switch ( op ) {
|
case CYGNUM_CALL_IF_FLASH_CFG_GET:
|
case CYGNUM_CALL_IF_FLASH_CFG_GET:
|
res = flash_get_config( key, val, type );
|
res = flash_get_config( key, val, type );
|
break;
|
break;
|
default:
|
default:
|
// nothing else supported yet - though it is expected that "set"
|
// nothing else supported yet - though it is expected that "set"
|
// will fit the same set of arguments, potentially.
|
// will fit the same set of arguments, potentially.
|
break;
|
break;
|
}
|
}
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
return res;
|
return res;
|
}
|
}
|
#endif
|
#endif
|
|
|
//----------------------------
|
//----------------------------
|
// Delay uS
|
// Delay uS
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DELAY_US
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DELAY_US
|
|
|
static __call_if_delay_us_t delay_us;
|
static __call_if_delay_us_t delay_us;
|
|
|
static void
|
static void
|
delay_us(cyg_int32 usecs)
|
delay_us(cyg_int32 usecs)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
#ifdef CYGPKG_KERNEL
|
#ifdef CYGPKG_KERNEL
|
{
|
{
|
cyg_int32 start, elapsed;
|
cyg_int32 start, elapsed;
|
cyg_int32 usec_ticks, slice;
|
cyg_int32 usec_ticks, slice;
|
|
|
// How many ticks total we should wait for.
|
// How many ticks total we should wait for.
|
usec_ticks = usecs*CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;
|
usec_ticks = usecs*CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;
|
usec_ticks /= CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR/1000;
|
usec_ticks /= CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR/1000;
|
|
|
do {
|
do {
|
// Spin in slices of 1/2 the RTC period. Allows interrupts
|
// Spin in slices of 1/2 the RTC period. Allows interrupts
|
// time to run without messing up the algorithm. If we spun
|
// time to run without messing up the algorithm. If we spun
|
// for 1 period (or more) of the RTC, there'd be also problems
|
// for 1 period (or more) of the RTC, there'd be also problems
|
// figuring out when the timer wrapped. We may lose a tick or
|
// figuring out when the timer wrapped. We may lose a tick or
|
// two for each cycle but it shouldn't matter much.
|
// two for each cycle but it shouldn't matter much.
|
slice = usec_ticks % (CYGNUM_KERNEL_COUNTERS_RTC_PERIOD / 2);
|
slice = usec_ticks % (CYGNUM_KERNEL_COUNTERS_RTC_PERIOD / 2);
|
|
|
HAL_CLOCK_READ(&start);
|
HAL_CLOCK_READ(&start);
|
do {
|
do {
|
HAL_CLOCK_READ(&elapsed);
|
HAL_CLOCK_READ(&elapsed);
|
elapsed = (elapsed - start); // counts up!
|
elapsed = (elapsed - start); // counts up!
|
if (elapsed < 0)
|
if (elapsed < 0)
|
elapsed += CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;
|
elapsed += CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;
|
} while (elapsed < slice);
|
} while (elapsed < slice);
|
|
|
// Adjust by elapsed, not slice, since an interrupt may have
|
// Adjust by elapsed, not slice, since an interrupt may have
|
// been stalling us for some time.
|
// been stalling us for some time.
|
usec_ticks -= elapsed;
|
usec_ticks -= elapsed;
|
} while (usec_ticks > 0);
|
} while (usec_ticks > 0);
|
}
|
}
|
#else // CYGPKG_KERNEL
|
#else // CYGPKG_KERNEL
|
#ifdef HAL_DELAY_US
|
#ifdef HAL_DELAY_US
|
// Use a HAL feature if defined
|
// Use a HAL feature if defined
|
HAL_DELAY_US(usecs);
|
HAL_DELAY_US(usecs);
|
#else
|
#else
|
// If no accurate delay mechanism, just spin for a while. Having
|
// If no accurate delay mechanism, just spin for a while. Having
|
// an inaccurate delay is much better than no delay at all. The
|
// an inaccurate delay is much better than no delay at all. The
|
// count of 10 should mean the loop takes something resembling
|
// count of 10 should mean the loop takes something resembling
|
// 1us on most CPUs running between 30-100MHz [depends on how many
|
// 1us on most CPUs running between 30-100MHz [depends on how many
|
// instructions this compiles to, how many dispatch units can be
|
// instructions this compiles to, how many dispatch units can be
|
// used for the simple loop, actual CPU frequency, etc]
|
// used for the simple loop, actual CPU frequency, etc]
|
while (usecs-- > 0) {
|
while (usecs-- > 0) {
|
int i;
|
int i;
|
for (i = 0; i < 10; i++);
|
for (i = 0; i < 10; i++);
|
}
|
}
|
#endif // HAL_DELAY_US
|
#endif // HAL_DELAY_US
|
#endif // CYGPKG_KERNEL
|
#endif // CYGPKG_KERNEL
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DELAY_US
|
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DELAY_US
|
|
|
// Reset functions
|
// Reset functions
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_RESET
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_RESET
|
|
|
static __call_if_reset_t reset;
|
static __call_if_reset_t reset;
|
|
|
static void
|
static void
|
reset(void)
|
reset(void)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
// With luck, the platform defines some magic that will cause a hardware
|
// With luck, the platform defines some magic that will cause a hardware
|
// reset.
|
// reset.
|
HAL_PLATFORM_RESET();
|
HAL_PLATFORM_RESET();
|
|
|
#ifdef HAL_PLATFORM_RESET_ENTRY
|
#ifdef HAL_PLATFORM_RESET_ENTRY
|
// If that's not the case (above is an empty statement) there may
|
// If that's not the case (above is an empty statement) there may
|
// be defined an address we can jump to - and effectively
|
// be defined an address we can jump to - and effectively
|
// reinitialize the system. Not quite as good as a reset, but it
|
// reinitialize the system. Not quite as good as a reset, but it
|
// is often enough.
|
// is often enough.
|
goto *HAL_PLATFORM_RESET_ENTRY;
|
goto *HAL_PLATFORM_RESET_ENTRY;
|
|
|
#else
|
#else
|
#error " no RESET_ENTRY"
|
#error " no RESET_ENTRY"
|
#endif
|
#endif
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
|
|
// This is the system's default kill signal routine. Unless overridden
|
// This is the system's default kill signal routine. Unless overridden
|
// by the application, it will cause a board reset when GDB quits the
|
// by the application, it will cause a board reset when GDB quits the
|
// connection. (The user can avoid the reset by using the GDB 'detach'
|
// connection. (The user can avoid the reset by using the GDB 'detach'
|
// command instead of 'kill' or 'quit').
|
// command instead of 'kill' or 'quit').
|
static int
|
static int
|
kill_by_reset(int __irq_nr, void* __regs)
|
kill_by_reset(int __irq_nr, void* __regs)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
reset();
|
reset();
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
return 0;
|
return 0;
|
}
|
}
|
#endif
|
#endif
|
|
|
//------------------------------------
|
//------------------------------------
|
// NOP service
|
// NOP service
|
#if defined(CYGSEM_HAL_VIRTUAL_VECTOR_INIT_WHOLE_TABLE) || \
|
#if defined(CYGSEM_HAL_VIRTUAL_VECTOR_INIT_WHOLE_TABLE) || \
|
defined(CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_COMMS)
|
defined(CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_COMMS)
|
static int
|
static int
|
nop_service(void)
|
nop_service(void)
|
{
|
{
|
// This is the default service. It always returns false (0), and
|
// This is the default service. It always returns false (0), and
|
// _does not_ trigger any assertions. Clients must either cope
|
// _does not_ trigger any assertions. Clients must either cope
|
// with the service failure or assert.
|
// with the service failure or assert.
|
return 0;
|
return 0;
|
}
|
}
|
#endif
|
#endif
|
|
|
//----------------------------------
|
//----------------------------------
|
// Comm controls
|
// Comm controls
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_COMMS
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_COMMS
|
|
|
#ifdef CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS
|
#ifdef CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS
|
#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
|
#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
|
(CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS+CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS)
|
(CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS+CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS)
|
#else
|
#else
|
#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
|
#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
|
CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS
|
CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS
|
#endif
|
#endif
|
|
|
static hal_virtual_comm_table_t comm_channels[CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS+1];
|
static hal_virtual_comm_table_t comm_channels[CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS+1];
|
|
|
static int
|
static int
|
set_debug_comm(int __comm_id)
|
set_debug_comm(int __comm_id)
|
{
|
{
|
static int __selected_id = CYGNUM_CALL_IF_SET_COMM_ID_EMPTY;
|
static int __selected_id = CYGNUM_CALL_IF_SET_COMM_ID_EMPTY;
|
hal_virtual_comm_table_t* __chan;
|
hal_virtual_comm_table_t* __chan;
|
int interrupt_state = 0;
|
int interrupt_state = 0;
|
int res = 1, update = 0;
|
int res = 1, update = 0;
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
CYG_ASSERT(__comm_id >= CYGNUM_CALL_IF_SET_COMM_ID_MANGLER
|
CYG_ASSERT(__comm_id >= CYGNUM_CALL_IF_SET_COMM_ID_MANGLER
|
&& __comm_id < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS,
|
&& __comm_id < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS,
|
"Invalid channel");
|
"Invalid channel");
|
|
|
switch (__comm_id) {
|
switch (__comm_id) {
|
case CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT:
|
case CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT:
|
if (__selected_id > 0)
|
if (__selected_id > 0)
|
res = __selected_id-1;
|
res = __selected_id-1;
|
else if (__selected_id == 0)
|
else if (__selected_id == 0)
|
res = CYGNUM_CALL_IF_SET_COMM_ID_MANGLER;
|
res = CYGNUM_CALL_IF_SET_COMM_ID_MANGLER;
|
else
|
else
|
res = __selected_id;
|
res = __selected_id;
|
break;
|
break;
|
|
|
case CYGNUM_CALL_IF_SET_COMM_ID_EMPTY:
|
case CYGNUM_CALL_IF_SET_COMM_ID_EMPTY:
|
CYGACC_CALL_IF_DEBUG_PROCS_SET(0);
|
CYGACC_CALL_IF_DEBUG_PROCS_SET(0);
|
__selected_id = __comm_id;
|
__selected_id = __comm_id;
|
break;
|
break;
|
|
|
case CYGNUM_CALL_IF_SET_COMM_ID_MANGLER:
|
case CYGNUM_CALL_IF_SET_COMM_ID_MANGLER:
|
__comm_id = 0;
|
__comm_id = 0;
|
update = 1;
|
update = 1;
|
break;
|
break;
|
|
|
default:
|
default:
|
__comm_id++; // skip mangler entry
|
__comm_id++; // skip mangler entry
|
update = 1;
|
update = 1;
|
break;
|
break;
|
}
|
}
|
|
|
if (update) {
|
if (update) {
|
// Find the interrupt state of the channel.
|
// Find the interrupt state of the channel.
|
__chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
__chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
if (__chan)
|
if (__chan)
|
interrupt_state = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_DISABLE);
|
interrupt_state = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_DISABLE);
|
|
|
__selected_id = __comm_id;
|
__selected_id = __comm_id;
|
CYGACC_CALL_IF_DEBUG_PROCS_SET(comm_channels[__comm_id]);
|
CYGACC_CALL_IF_DEBUG_PROCS_SET(comm_channels[__comm_id]);
|
|
|
// Set interrupt state on the new channel.
|
// Set interrupt state on the new channel.
|
__chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
__chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
if (interrupt_state)
|
if (interrupt_state)
|
CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_ENABLE);
|
CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_ENABLE);
|
else
|
else
|
CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_DISABLE);
|
CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_DISABLE);
|
}
|
}
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
return res;
|
return res;
|
}
|
}
|
|
|
static int
|
static int
|
set_console_comm(int __comm_id)
|
set_console_comm(int __comm_id)
|
{
|
{
|
static int __selected_id = CYGNUM_CALL_IF_SET_COMM_ID_EMPTY;
|
static int __selected_id = CYGNUM_CALL_IF_SET_COMM_ID_EMPTY;
|
int res = 1, update = 0;
|
int res = 1, update = 0;
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
CYG_ASSERT(__comm_id >= CYGNUM_CALL_IF_SET_COMM_ID_MANGLER
|
CYG_ASSERT(__comm_id >= CYGNUM_CALL_IF_SET_COMM_ID_MANGLER
|
&& __comm_id < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS,
|
&& __comm_id < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS,
|
"Invalid channel");
|
"Invalid channel");
|
|
|
switch (__comm_id) {
|
switch (__comm_id) {
|
case CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT:
|
case CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT:
|
if (__selected_id > 0)
|
if (__selected_id > 0)
|
res = __selected_id-1;
|
res = __selected_id-1;
|
else if (__selected_id == 0)
|
else if (__selected_id == 0)
|
res = CYGNUM_CALL_IF_SET_COMM_ID_MANGLER;
|
res = CYGNUM_CALL_IF_SET_COMM_ID_MANGLER;
|
else
|
else
|
res = __selected_id;
|
res = __selected_id;
|
break;
|
break;
|
|
|
case CYGNUM_CALL_IF_SET_COMM_ID_EMPTY:
|
case CYGNUM_CALL_IF_SET_COMM_ID_EMPTY:
|
CYGACC_CALL_IF_CONSOLE_PROCS_SET(0);
|
CYGACC_CALL_IF_CONSOLE_PROCS_SET(0);
|
__selected_id = __comm_id;
|
__selected_id = __comm_id;
|
break;
|
break;
|
|
|
case CYGNUM_CALL_IF_SET_COMM_ID_MANGLER:
|
case CYGNUM_CALL_IF_SET_COMM_ID_MANGLER:
|
__comm_id = 0;
|
__comm_id = 0;
|
update = 1;
|
update = 1;
|
break;
|
break;
|
|
|
default:
|
default:
|
__comm_id++; // skip mangler entry
|
__comm_id++; // skip mangler entry
|
update = 1;
|
update = 1;
|
break;
|
break;
|
}
|
}
|
|
|
if (update) {
|
if (update) {
|
__selected_id = __comm_id;
|
__selected_id = __comm_id;
|
|
|
CYGACC_CALL_IF_CONSOLE_PROCS_SET(comm_channels[__comm_id]);
|
CYGACC_CALL_IF_CONSOLE_PROCS_SET(comm_channels[__comm_id]);
|
}
|
}
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
return res;
|
return res;
|
}
|
}
|
#endif
|
#endif
|
|
|
//----------------------------------
|
//----------------------------------
|
// Cache functions
|
// Cache functions
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_CACHE
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_CACHE
|
|
|
static void
|
static void
|
flush_icache(void *__p, int __nbytes)
|
flush_icache(void *__p, int __nbytes)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
#ifdef HAL_ICACHE_FLUSH
|
#ifdef HAL_ICACHE_FLUSH
|
HAL_ICACHE_FLUSH( __p , __nbytes );
|
HAL_ICACHE_FLUSH( __p , __nbytes );
|
#elif defined(HAL_ICACHE_INVALIDATE)
|
#elif defined(HAL_ICACHE_INVALIDATE)
|
HAL_ICACHE_INVALIDATE();
|
HAL_ICACHE_INVALIDATE();
|
#endif
|
#endif
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
|
|
static void
|
static void
|
flush_dcache(void *__p, int __nbytes)
|
flush_dcache(void *__p, int __nbytes)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
#ifdef HAL_DCACHE_FLUSH
|
#ifdef HAL_DCACHE_FLUSH
|
HAL_DCACHE_FLUSH( __p , __nbytes );
|
HAL_DCACHE_FLUSH( __p , __nbytes );
|
#elif defined(HAL_DCACHE_INVALIDATE)
|
#elif defined(HAL_DCACHE_INVALIDATE)
|
HAL_DCACHE_INVALIDATE();
|
HAL_DCACHE_INVALIDATE();
|
#endif
|
#endif
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
#endif
|
#endif
|
|
|
#if defined(CYGSEM_HAL_VIRTUAL_VECTOR_DIAG)
|
#if defined(CYGSEM_HAL_VIRTUAL_VECTOR_DIAG)
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// GDB console output mangler (O-packetizer)
|
// GDB console output mangler (O-packetizer)
|
// COMMS init function at end.
|
// COMMS init function at end.
|
|
|
// This gets called via the virtual vector console comms entry and
|
// This gets called via the virtual vector console comms entry and
|
// handles O-packetization. The debug comms entries are used for the
|
// handles O-packetization. The debug comms entries are used for the
|
// actual device IO.
|
// actual device IO.
|
static cyg_uint8
|
static cyg_uint8
|
cyg_hal_diag_mangler_gdb_getc(void* __ch_data)
|
cyg_hal_diag_mangler_gdb_getc(void* __ch_data)
|
{
|
{
|
cyg_uint8 __ch;
|
cyg_uint8 __ch;
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
__ch = CYGACC_COMM_IF_GETC(*__chan);
|
__ch = CYGACC_COMM_IF_GETC(*__chan);
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
|
|
return __ch;
|
return __ch;
|
}
|
}
|
|
|
static char __mangler_line[100];
|
static char __mangler_line[100];
|
static int __mangler_pos = 0;
|
static int __mangler_pos = 0;
|
|
|
static void
|
static void
|
cyg_hal_diag_mangler_gdb_flush(void* __ch_data)
|
cyg_hal_diag_mangler_gdb_flush(void* __ch_data)
|
{
|
{
|
CYG_INTERRUPT_STATE old;
|
CYG_INTERRUPT_STATE old;
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
|
|
// Nothing to do if mangler buffer is empty.
|
// Nothing to do if mangler buffer is empty.
|
if (__mangler_pos == 0)
|
if (__mangler_pos == 0)
|
return;
|
return;
|
|
|
// Disable interrupts. This prevents GDB trying to interrupt us
|
// Disable interrupts. This prevents GDB trying to interrupt us
|
// while we are in the middle of sending a packet. The serial
|
// while we are in the middle of sending a packet. The serial
|
// receive interrupt will be seen when we re-enable interrupts
|
// receive interrupt will be seen when we re-enable interrupts
|
// later.
|
// later.
|
#if defined(CYG_HAL_STARTUP_ROM) \
|
#if defined(CYG_HAL_STARTUP_ROM) \
|
|| !defined(CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION)
|
|| !defined(CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION)
|
HAL_DISABLE_INTERRUPTS(old);
|
HAL_DISABLE_INTERRUPTS(old);
|
#else
|
#else
|
CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION(old);
|
CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION(old);
|
#endif
|
#endif
|
|
|
#if CYGNUM_HAL_DEBUG_GDB_PROTOCOL_RETRIES != 0
|
#if CYGNUM_HAL_DEBUG_GDB_PROTOCOL_RETRIES != 0
|
// Only wait 500ms for data to arrive - avoid "stuck" connections
|
// Only wait 500ms for data to arrive - avoid "stuck" connections
|
CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_SET_TIMEOUT, CYGNUM_HAL_DEBUG_GDB_PROTOCOL_TIMEOUT);
|
CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_SET_TIMEOUT, CYGNUM_HAL_DEBUG_GDB_PROTOCOL_TIMEOUT);
|
#endif
|
#endif
|
|
|
while(1)
|
while(1)
|
{
|
{
|
static const char hex[] = "0123456789ABCDEF";
|
static const char hex[] = "0123456789ABCDEF";
|
cyg_uint8 csum = 0, c1;
|
cyg_uint8 csum = 0, c1;
|
int i;
|
int i;
|
|
|
CYGACC_COMM_IF_PUTC(*__chan, '$');
|
CYGACC_COMM_IF_PUTC(*__chan, '$');
|
CYGACC_COMM_IF_PUTC(*__chan, 'O');
|
CYGACC_COMM_IF_PUTC(*__chan, 'O');
|
csum += 'O';
|
csum += 'O';
|
for( i = 0; i < __mangler_pos; i++ )
|
for( i = 0; i < __mangler_pos; i++ )
|
{
|
{
|
char ch = __mangler_line[i];
|
char ch = __mangler_line[i];
|
char h = hex[(ch>>4)&0xF];
|
char h = hex[(ch>>4)&0xF];
|
char l = hex[ch&0xF];
|
char l = hex[ch&0xF];
|
CYGACC_COMM_IF_PUTC(*__chan, h);
|
CYGACC_COMM_IF_PUTC(*__chan, h);
|
CYGACC_COMM_IF_PUTC(*__chan, l);
|
CYGACC_COMM_IF_PUTC(*__chan, l);
|
csum += h;
|
csum += h;
|
csum += l;
|
csum += l;
|
}
|
}
|
CYGACC_COMM_IF_PUTC(*__chan, '#');
|
CYGACC_COMM_IF_PUTC(*__chan, '#');
|
CYGACC_COMM_IF_PUTC(*__chan, hex[(csum>>4)&0xF]);
|
CYGACC_COMM_IF_PUTC(*__chan, hex[(csum>>4)&0xF]);
|
CYGACC_COMM_IF_PUTC(*__chan, hex[csum&0xF]);
|
CYGACC_COMM_IF_PUTC(*__chan, hex[csum&0xF]);
|
|
|
nak:
|
nak:
|
#if CYGNUM_HAL_DEBUG_GDB_PROTOCOL_RETRIES != 0
|
#if CYGNUM_HAL_DEBUG_GDB_PROTOCOL_RETRIES != 0
|
if (CYGACC_COMM_IF_GETC_TIMEOUT(*__chan, &c1) == 0) {
|
if (CYGACC_COMM_IF_GETC_TIMEOUT(*__chan, &c1) == 0) {
|
c1 = '-';
|
c1 = '-';
|
if (tries && (--tries == 0)) c1 = '+';
|
if (tries && (--tries == 0)) c1 = '+';
|
}
|
}
|
#else
|
#else
|
c1 = CYGACC_COMM_IF_GETC(*__chan);
|
c1 = CYGACC_COMM_IF_GETC(*__chan);
|
#endif
|
#endif
|
|
|
if( c1 == '+' ) break;
|
if( c1 == '+' ) break;
|
|
|
if( cyg_hal_is_break( &c1 , 1 ) ) {
|
if( cyg_hal_is_break( &c1 , 1 ) ) {
|
// Caller's responsibility to react on this.
|
// Caller's responsibility to react on this.
|
CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(1);
|
CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(1);
|
break;
|
break;
|
}
|
}
|
if( c1 != '-' ) goto nak;
|
if( c1 != '-' ) goto nak;
|
}
|
}
|
|
|
__mangler_pos = 0;
|
__mangler_pos = 0;
|
// And re-enable interrupts
|
// And re-enable interrupts
|
#if defined(CYG_HAL_STARTUP_ROM) \
|
#if defined(CYG_HAL_STARTUP_ROM) \
|
|| !defined(CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION)
|
|| !defined(CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION)
|
HAL_RESTORE_INTERRUPTS(old);
|
HAL_RESTORE_INTERRUPTS(old);
|
#else
|
#else
|
CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION(old);
|
CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION(old);
|
#endif
|
#endif
|
}
|
}
|
|
|
static void
|
static void
|
cyg_hal_diag_mangler_gdb_putc(void* __ch_data, cyg_uint8 c)
|
cyg_hal_diag_mangler_gdb_putc(void* __ch_data, cyg_uint8 c)
|
{
|
{
|
#if CYGNUM_HAL_DEBUG_GDB_PROTOCOL_RETRIES != 0
|
#if CYGNUM_HAL_DEBUG_GDB_PROTOCOL_RETRIES != 0
|
int tries = CYGNUM_HAL_DEBUG_GDB_PROTOCOL_RETRIES;
|
int tries = CYGNUM_HAL_DEBUG_GDB_PROTOCOL_RETRIES;
|
#endif
|
#endif
|
|
|
// No need to send CRs
|
// No need to send CRs
|
if( c == '\r' ) return;
|
if( c == '\r' ) return;
|
|
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
__mangler_line[__mangler_pos++] = c;
|
__mangler_line[__mangler_pos++] = c;
|
|
|
if( c == '\n' || __mangler_pos == sizeof(__mangler_line) )
|
if( c == '\n' || __mangler_pos == sizeof(__mangler_line) )
|
cyg_hal_diag_mangler_gdb_flush(__ch_data);
|
cyg_hal_diag_mangler_gdb_flush(__ch_data);
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
|
|
static void
|
static void
|
cyg_hal_diag_mangler_gdb_write(void* __ch_data,
|
cyg_hal_diag_mangler_gdb_write(void* __ch_data,
|
const cyg_uint8* __buf, cyg_uint32 __len)
|
const cyg_uint8* __buf, cyg_uint32 __len)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
while(__len-- > 0)
|
while(__len-- > 0)
|
cyg_hal_diag_mangler_gdb_putc(__ch_data, *__buf++);
|
cyg_hal_diag_mangler_gdb_putc(__ch_data, *__buf++);
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
|
|
static void
|
static void
|
cyg_hal_diag_mangler_gdb_read(void* __ch_data,
|
cyg_hal_diag_mangler_gdb_read(void* __ch_data,
|
cyg_uint8* __buf, cyg_uint32 __len)
|
cyg_uint8* __buf, cyg_uint32 __len)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
while(__len-- > 0)
|
while(__len-- > 0)
|
*__buf++ = cyg_hal_diag_mangler_gdb_getc(__ch_data);
|
*__buf++ = cyg_hal_diag_mangler_gdb_getc(__ch_data);
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
|
|
static int
|
static int
|
cyg_hal_diag_mangler_gdb_control(void *__ch_data,
|
cyg_hal_diag_mangler_gdb_control(void *__ch_data,
|
__comm_control_cmd_t __func, ...)
|
__comm_control_cmd_t __func, ...)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
if (__func == __COMMCTL_FLUSH_OUTPUT)
|
if (__func == __COMMCTL_FLUSH_OUTPUT)
|
cyg_hal_diag_mangler_gdb_flush(__ch_data);
|
cyg_hal_diag_mangler_gdb_flush(__ch_data);
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
return 0;
|
return 0;
|
}
|
}
|
|
|
// This is the COMMS init function. It gets called both by the stubs
|
// This is the COMMS init function. It gets called both by the stubs
|
// and diag init code to initialize the COMMS mangler channel table -
|
// and diag init code to initialize the COMMS mangler channel table -
|
// that's all. The callers have to decide whether to actually use this
|
// that's all. The callers have to decide whether to actually use this
|
// channel.
|
// channel.
|
void
|
void
|
cyg_hal_diag_mangler_gdb_init(void)
|
cyg_hal_diag_mangler_gdb_init(void)
|
{
|
{
|
hal_virtual_comm_table_t* comm;
|
hal_virtual_comm_table_t* comm;
|
int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
|
int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
|
|
|
// Initialize mangler procs
|
// Initialize mangler procs
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_MANGLER);
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_MANGLER);
|
comm = CYGACC_CALL_IF_CONSOLE_PROCS();
|
comm = CYGACC_CALL_IF_CONSOLE_PROCS();
|
CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_diag_mangler_gdb_write);
|
CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_diag_mangler_gdb_write);
|
CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_diag_mangler_gdb_read);
|
CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_diag_mangler_gdb_read);
|
CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_diag_mangler_gdb_putc);
|
CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_diag_mangler_gdb_putc);
|
CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_diag_mangler_gdb_getc);
|
CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_diag_mangler_gdb_getc);
|
CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_diag_mangler_gdb_control);
|
CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_diag_mangler_gdb_control);
|
|
|
// Restore the original console channel.
|
// Restore the original console channel.
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
|
}
|
}
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// Null console output mangler
|
// Null console output mangler
|
// COMMS init function at end.
|
// COMMS init function at end.
|
|
|
// This gets called via the virtual vector console comms entry and
|
// This gets called via the virtual vector console comms entry and
|
// just forwards IO to the debug comms entries.
|
// just forwards IO to the debug comms entries.
|
// This differs from setting the console channel to the same as the
|
// This differs from setting the console channel to the same as the
|
// debug channel in that console output will go to the debug channel
|
// debug channel in that console output will go to the debug channel
|
// even if the debug channel is changed.
|
// even if the debug channel is changed.
|
static cyg_uint8
|
static cyg_uint8
|
cyg_hal_diag_mangler_null_getc(void* __ch_data)
|
cyg_hal_diag_mangler_null_getc(void* __ch_data)
|
{
|
{
|
cyg_uint8 __ch;
|
cyg_uint8 __ch;
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
__ch = CYGACC_COMM_IF_GETC(*__chan);
|
__ch = CYGACC_COMM_IF_GETC(*__chan);
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
|
|
return __ch;
|
return __ch;
|
}
|
}
|
|
|
|
|
static void
|
static void
|
cyg_hal_diag_mangler_null_putc(void* __ch_data, cyg_uint8 c)
|
cyg_hal_diag_mangler_null_putc(void* __ch_data, cyg_uint8 c)
|
{
|
{
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
|
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
CYGACC_COMM_IF_PUTC(*__chan, c);
|
CYGACC_COMM_IF_PUTC(*__chan, c);
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
|
|
static void
|
static void
|
cyg_hal_diag_mangler_null_write(void* __ch_data,
|
cyg_hal_diag_mangler_null_write(void* __ch_data,
|
const cyg_uint8* __buf, cyg_uint32 __len)
|
const cyg_uint8* __buf, cyg_uint32 __len)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
while(__len-- > 0)
|
while(__len-- > 0)
|
cyg_hal_diag_mangler_null_putc(__ch_data, *__buf++);
|
cyg_hal_diag_mangler_null_putc(__ch_data, *__buf++);
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
|
|
static void
|
static void
|
cyg_hal_diag_mangler_null_read(void* __ch_data,
|
cyg_hal_diag_mangler_null_read(void* __ch_data,
|
cyg_uint8* __buf, cyg_uint32 __len)
|
cyg_uint8* __buf, cyg_uint32 __len)
|
{
|
{
|
CYGARC_HAL_SAVE_GP();
|
CYGARC_HAL_SAVE_GP();
|
|
|
while(__len-- > 0)
|
while(__len-- > 0)
|
*__buf++ = cyg_hal_diag_mangler_null_getc(__ch_data);
|
*__buf++ = cyg_hal_diag_mangler_null_getc(__ch_data);
|
|
|
CYGARC_HAL_RESTORE_GP();
|
CYGARC_HAL_RESTORE_GP();
|
}
|
}
|
|
|
static int
|
static int
|
cyg_hal_diag_mangler_null_control(void *__ch_data,
|
cyg_hal_diag_mangler_null_control(void *__ch_data,
|
__comm_control_cmd_t __func, ...)
|
__comm_control_cmd_t __func, ...)
|
{
|
{
|
// Do nothing (yet).
|
// Do nothing (yet).
|
return 0;
|
return 0;
|
}
|
}
|
|
|
// This is the COMMS init function. It gets called both by the stubs
|
// This is the COMMS init function. It gets called both by the stubs
|
// and diag init code to initialize the COMMS mangler channel table -
|
// and diag init code to initialize the COMMS mangler channel table -
|
// that's all. The callers have to decide whether to actually use this
|
// that's all. The callers have to decide whether to actually use this
|
// channel.
|
// channel.
|
void
|
void
|
cyg_hal_diag_mangler_null_init(void)
|
cyg_hal_diag_mangler_null_init(void)
|
{
|
{
|
hal_virtual_comm_table_t* comm;
|
hal_virtual_comm_table_t* comm;
|
int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
|
int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
|
|
|
// Initialize mangler procs
|
// Initialize mangler procs
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_MANGLER);
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_MANGLER);
|
comm = CYGACC_CALL_IF_CONSOLE_PROCS();
|
comm = CYGACC_CALL_IF_CONSOLE_PROCS();
|
CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_diag_mangler_null_write);
|
CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_diag_mangler_null_write);
|
CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_diag_mangler_null_read);
|
CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_diag_mangler_null_read);
|
CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_diag_mangler_null_putc);
|
CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_diag_mangler_null_putc);
|
CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_diag_mangler_null_getc);
|
CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_diag_mangler_null_getc);
|
CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_diag_mangler_null_control);
|
CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_diag_mangler_null_control);
|
|
|
// Restore the original console channel.
|
// Restore the original console channel.
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
|
}
|
}
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// Console IO functions that adhere to the virtual vector table semantics in
|
// Console IO functions that adhere to the virtual vector table semantics in
|
// order to ensure proper debug agent mangling when required.
|
// order to ensure proper debug agent mangling when required.
|
//
|
//
|
externC void cyg_hal_plf_comms_init(void);
|
externC void cyg_hal_plf_comms_init(void);
|
|
|
void
|
void
|
hal_if_diag_init(void)
|
hal_if_diag_init(void)
|
{
|
{
|
// This function may be called from various places and the code
|
// This function may be called from various places and the code
|
// should only run once.
|
// should only run once.
|
static cyg_uint8 called = 0;
|
static cyg_uint8 called = 0;
|
if (called) return;
|
if (called) return;
|
called = 1;
|
called = 1;
|
|
|
#ifndef CYGSEM_HAL_VIRTUAL_VECTOR_INHERIT_CONSOLE
|
#ifndef CYGSEM_HAL_VIRTUAL_VECTOR_INHERIT_CONSOLE
|
|
|
#if defined(CYGDBG_HAL_DIAG_TO_DEBUG_CHAN)
|
#if defined(CYGDBG_HAL_DIAG_TO_DEBUG_CHAN)
|
// Use the mangler channel, which in turn uses the debug channel.
|
// Use the mangler channel, which in turn uses the debug channel.
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_MANGLER);
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_MANGLER);
|
|
|
// Initialize the mangler channel.
|
// Initialize the mangler channel.
|
#if defined(CYGSEM_HAL_DIAG_MANGLER_GDB)
|
#if defined(CYGSEM_HAL_DIAG_MANGLER_GDB)
|
cyg_hal_diag_mangler_gdb_init();
|
cyg_hal_diag_mangler_gdb_init();
|
#elif defined(CYGSEM_HAL_DIAG_MANGLER_None)
|
#elif defined(CYGSEM_HAL_DIAG_MANGLER_None)
|
cyg_hal_diag_mangler_null_init();
|
cyg_hal_diag_mangler_null_init();
|
#endif
|
#endif
|
|
|
#else // CYGDBG_HAL_DIAG_TO_DEBUG_CHAN
|
#else // CYGDBG_HAL_DIAG_TO_DEBUG_CHAN
|
|
|
// Use an actual (raw) IO channel
|
// Use an actual (raw) IO channel
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL);
|
CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL);
|
|
|
#endif // CYGDBG_HAL_DIAG_TO_DEBUG_CHAN
|
#endif // CYGDBG_HAL_DIAG_TO_DEBUG_CHAN
|
|
|
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_INHERIT_CONSOLE
|
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_INHERIT_CONSOLE
|
}
|
}
|
|
|
void
|
void
|
hal_if_diag_write_char(char c)
|
hal_if_diag_write_char(char c)
|
{
|
{
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
|
|
|
if (__chan)
|
if (__chan)
|
CYGACC_COMM_IF_PUTC(*__chan, c);
|
CYGACC_COMM_IF_PUTC(*__chan, c);
|
else {
|
else {
|
__chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
__chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
|
|
// FIXME: What should be done if assertions are not enabled?
|
// FIXME: What should be done if assertions are not enabled?
|
// This is a bad bad situation - we have no means for diag
|
// This is a bad bad situation - we have no means for diag
|
// output; we want to hit a breakpoint to alert the developer
|
// output; we want to hit a breakpoint to alert the developer
|
// or something like that.
|
// or something like that.
|
CYG_ASSERT(__chan, "No valid channel set");
|
CYG_ASSERT(__chan, "No valid channel set");
|
|
|
CYGACC_COMM_IF_PUTC(*__chan, c);
|
CYGACC_COMM_IF_PUTC(*__chan, c);
|
}
|
}
|
|
|
// Check interrupt flag
|
// Check interrupt flag
|
if (CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG()) {
|
if (CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG()) {
|
CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(0);
|
CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(0);
|
cyg_hal_user_break(0);
|
cyg_hal_user_break(0);
|
}
|
}
|
}
|
}
|
|
|
void
|
void
|
hal_if_diag_read_char(char *c)
|
hal_if_diag_read_char(char *c)
|
{
|
{
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
|
|
|
if (__chan)
|
if (__chan)
|
*c = CYGACC_COMM_IF_GETC(*__chan);
|
*c = CYGACC_COMM_IF_GETC(*__chan);
|
else {
|
else {
|
__chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
__chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
|
|
// FIXME: What should be done if assertions are not enabled?
|
// FIXME: What should be done if assertions are not enabled?
|
// This is a bad bad situation - we have no means for diag
|
// This is a bad bad situation - we have no means for diag
|
// output; we want to hit a breakpoint to alert the developer
|
// output; we want to hit a breakpoint to alert the developer
|
// or something like that.
|
// or something like that.
|
CYG_ASSERT(__chan, "No valid channel set");
|
CYG_ASSERT(__chan, "No valid channel set");
|
|
|
*c = CYGACC_COMM_IF_GETC(*__chan);
|
*c = CYGACC_COMM_IF_GETC(*__chan);
|
}
|
}
|
}
|
}
|
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
|
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
|
|
|
//=============================================================================
|
//=============================================================================
|
// CtrlC support
|
// CtrlC support
|
//=============================================================================
|
//=============================================================================
|
|
|
#if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT) \
|
#if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT) \
|
|| defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
|
|| defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
|
|
|
struct Hal_SavedRegisters *hal_saved_interrupt_state;
|
struct Hal_SavedRegisters *hal_saved_interrupt_state;
|
|
|
void
|
void
|
hal_ctrlc_isr_init(void)
|
hal_ctrlc_isr_init(void)
|
{
|
{
|
// A ROM monitor never enables the interrupt itself. This is left
|
// A ROM monitor never enables the interrupt itself. This is left
|
// to the (RAM) application.
|
// to the (RAM) application.
|
#ifndef CYGSEM_HAL_ROM_MONITOR
|
#ifndef CYGSEM_HAL_ROM_MONITOR
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
|
|
#if 1 // Prevents crash on older stubs
|
#if 1 // Prevents crash on older stubs
|
int v_m;
|
int v_m;
|
// Allow only ctrl-c interrupt enabling when version in table is
|
// Allow only ctrl-c interrupt enabling when version in table is
|
// below legal max and above the necessary service, and _not_
|
// below legal max and above the necessary service, and _not_
|
// the value we set it to below.
|
// the value we set it to below.
|
v_m = CYGACC_CALL_IF_VERSION() & CYGNUM_CALL_IF_TABLE_VERSION_CALL_MASK;
|
v_m = CYGACC_CALL_IF_VERSION() & CYGNUM_CALL_IF_TABLE_VERSION_CALL_MASK;
|
if (v_m >= CYGNUM_CALL_IF_TABLE_VERSION_CALL_MAX
|
if (v_m >= CYGNUM_CALL_IF_TABLE_VERSION_CALL_MAX
|
|| v_m < CYGNUM_CALL_IF_SET_DEBUG_COMM
|
|| v_m < CYGNUM_CALL_IF_SET_DEBUG_COMM
|
|| v_m == CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK)
|
|| v_m == CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK)
|
return;
|
return;
|
|
|
// Now trash that value - otherwise downloading an image with
|
// Now trash that value - otherwise downloading an image with
|
// builtin stubs on a board with older stubs (which will cause the
|
// builtin stubs on a board with older stubs (which will cause the
|
// version to be set to VERSION_CALL) may cause all subsequent
|
// version to be set to VERSION_CALL) may cause all subsequent
|
// runs to (wrongly) fall through to the below code. If there is
|
// runs to (wrongly) fall through to the below code. If there is
|
// a new stub on the board, it will reinitialize the version field
|
// a new stub on the board, it will reinitialize the version field
|
// on reset. Yes, this is a gross hack!
|
// on reset. Yes, this is a gross hack!
|
CYGACC_CALL_IF_VERSION_SET(CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK);
|
CYGACC_CALL_IF_VERSION_SET(CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK);
|
#endif
|
#endif
|
|
|
// We can only enable interrupts on a valid debug channel.
|
// We can only enable interrupts on a valid debug channel.
|
if (__chan)
|
if (__chan)
|
CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_ENABLE);
|
CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_ENABLE);
|
#endif
|
#endif
|
}
|
}
|
|
|
cyg_uint32
|
cyg_uint32
|
hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
|
hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
|
{
|
{
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
int isr_ret = 0, ctrlc = 0;
|
int isr_ret = 0, ctrlc = 0;
|
|
|
if (__chan) {
|
if (__chan) {
|
isr_ret = CYGACC_COMM_IF_DBG_ISR(*__chan, &ctrlc, vector, data);
|
isr_ret = CYGACC_COMM_IF_DBG_ISR(*__chan, &ctrlc, vector, data);
|
if (ctrlc)
|
if (ctrlc)
|
cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state );
|
cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state );
|
}
|
}
|
return isr_ret;
|
return isr_ret;
|
}
|
}
|
|
|
cyg_bool
|
cyg_bool
|
hal_ctrlc_check(CYG_ADDRWORD vector, CYG_ADDRWORD data)
|
hal_ctrlc_check(CYG_ADDRWORD vector, CYG_ADDRWORD data)
|
{
|
{
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
|
int gdb_vector = vector-1;
|
int gdb_vector = vector-1;
|
int isr_ret, ctrlc = 0;
|
int isr_ret, ctrlc = 0;
|
|
|
// This check only to avoid crash on older stubs in case of unhandled
|
// This check only to avoid crash on older stubs in case of unhandled
|
// interrupts. It is a bit messy, but required in a transition period.
|
// interrupts. It is a bit messy, but required in a transition period.
|
if (__chan &&
|
if (__chan &&
|
(CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK ==
|
(CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK ==
|
(CYGACC_CALL_IF_VERSION() & CYGNUM_CALL_IF_TABLE_VERSION_CALL_MASK))){
|
(CYGACC_CALL_IF_VERSION() & CYGNUM_CALL_IF_TABLE_VERSION_CALL_MASK))){
|
gdb_vector = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_DBG_ISR_VECTOR);
|
gdb_vector = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_DBG_ISR_VECTOR);
|
}
|
}
|
if (vector == gdb_vector) {
|
if (vector == gdb_vector) {
|
isr_ret = CYGACC_COMM_IF_DBG_ISR(*__chan, &ctrlc, vector, data);
|
isr_ret = CYGACC_COMM_IF_DBG_ISR(*__chan, &ctrlc, vector, data);
|
if (ctrlc) {
|
if (ctrlc) {
|
cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state );
|
cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state );
|
return true;
|
return true;
|
}
|
}
|
}
|
}
|
return false;
|
return false;
|
}
|
}
|
#endif // CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT || CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT
|
#endif // CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT || CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT
|
|
|
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
// Init function. It should be called from the platform initialization code.
|
// Init function. It should be called from the platform initialization code.
|
// For monitor configurations it will initialize the calling interface table,
|
// For monitor configurations it will initialize the calling interface table,
|
// for client configurations it will patch the existing table as per
|
// for client configurations it will patch the existing table as per
|
// configuration.
|
// configuration.
|
void
|
void
|
hal_if_init(void)
|
hal_if_init(void)
|
{
|
{
|
//**********************************************************************
|
//**********************************************************************
|
//
|
//
|
// Note that if your RAM application is configured to initialize
|
// Note that if your RAM application is configured to initialize
|
// the whole table _or_ the communication channels, you _cannot_
|
// the whole table _or_ the communication channels, you _cannot_
|
// step through this function with the debugger. If your channel
|
// step through this function with the debugger. If your channel
|
// configurations are set to the default, you should be able to
|
// configurations are set to the default, you should be able to
|
// simply step over this function though (or use 'finish' once you
|
// simply step over this function though (or use 'finish' once you
|
// have entered this function if that GDB command works).
|
// have entered this function if that GDB command works).
|
//
|
//
|
// If you really do need to debug this code, the best approach is
|
// If you really do need to debug this code, the best approach is
|
// to have a working RedBoot / GDB stub in ROM and then change the
|
// to have a working RedBoot / GDB stub in ROM and then change the
|
// hal_virtual_vector_table to reside at some other address in the
|
// hal_virtual_vector_table to reside at some other address in the
|
// RAM configuration than that used by the ROM monitor. Then
|
// RAM configuration than that used by the ROM monitor. Then
|
// you'll be able to use the ROM monitor to debug the below code
|
// you'll be able to use the ROM monitor to debug the below code
|
// and check that it does the right thing.
|
// and check that it does the right thing.
|
//
|
//
|
// Note that if you have a ROM monitor in ROM/flash which does
|
// Note that if you have a ROM monitor in ROM/flash which does
|
// support virtual vectors, you should be able to disable the
|
// support virtual vectors, you should be able to disable the
|
// option CYGSEM_HAL_VIRTUAL_VECTOR_INIT_WHOLE_TABLE. On some
|
// option CYGSEM_HAL_VIRTUAL_VECTOR_INIT_WHOLE_TABLE. On some
|
// targets (which predate the introduction of virtual vectors)
|
// targets (which predate the introduction of virtual vectors)
|
// that option is enabled per default and needs to be explicitly
|
// that option is enabled per default and needs to be explicitly
|
// disabled when you have an updated ROM monitor.
|
// disabled when you have an updated ROM monitor.
|
//
|
//
|
//**********************************************************************
|
//**********************************************************************
|
|
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_INIT_WHOLE_TABLE
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_INIT_WHOLE_TABLE
|
{
|
{
|
int i;
|
int i;
|
|
|
// Initialize tables with the NOP service.
|
// Initialize tables with the NOP service.
|
// This should only be done for service routine entries - data
|
// This should only be done for service routine entries - data
|
// pointers should be NULLed.
|
// pointers should be NULLed.
|
for (i = 0; i < CYGNUM_CALL_IF_TABLE_SIZE; i++)
|
for (i = 0; i < CYGNUM_CALL_IF_TABLE_SIZE; i++)
|
hal_virtual_vector_table[i] = (CYG_ADDRWORD) &nop_service;
|
hal_virtual_vector_table[i] = (CYG_ADDRWORD) &nop_service;
|
|
|
// Version number
|
// Version number
|
CYGACC_CALL_IF_VERSION_SET(CYGNUM_CALL_IF_TABLE_VERSION_CALL
|
CYGACC_CALL_IF_VERSION_SET(CYGNUM_CALL_IF_TABLE_VERSION_CALL
|
|((CYG_ADDRWORD)CYGNUM_CALL_IF_TABLE_VERSION_COMM<<CYGNUM_CALL_IF_TABLE_VERSION_COMM_shift));
|
|((CYG_ADDRWORD)CYGNUM_CALL_IF_TABLE_VERSION_COMM<<CYGNUM_CALL_IF_TABLE_VERSION_COMM_shift));
|
}
|
}
|
#endif
|
#endif
|
|
|
// Miscellaneous services with wrappers in this file.
|
// Miscellaneous services with wrappers in this file.
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_RESET
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_RESET
|
CYGACC_CALL_IF_RESET_SET(reset);
|
CYGACC_CALL_IF_RESET_SET(reset);
|
CYGACC_CALL_IF_KILL_VECTOR_SET(kill_by_reset);
|
CYGACC_CALL_IF_KILL_VECTOR_SET(kill_by_reset);
|
#endif
|
#endif
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DELAY_US
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DELAY_US
|
CYGACC_CALL_IF_DELAY_US_SET(delay_us);
|
CYGACC_CALL_IF_DELAY_US_SET(delay_us);
|
#endif
|
#endif
|
|
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_CACHE
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_CACHE
|
// Cache functions
|
// Cache functions
|
CYGACC_CALL_IF_FLUSH_ICACHE_SET(flush_icache);
|
CYGACC_CALL_IF_FLUSH_ICACHE_SET(flush_icache);
|
CYGACC_CALL_IF_FLUSH_DCACHE_SET(flush_dcache);
|
CYGACC_CALL_IF_FLUSH_DCACHE_SET(flush_dcache);
|
#endif
|
#endif
|
|
|
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
|
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
|
CYGACC_CALL_IF_FLASH_CFG_OP_SET(flash_config_op);
|
CYGACC_CALL_IF_FLASH_CFG_OP_SET(flash_config_op);
|
#endif
|
#endif
|
|
|
// Data entries not currently supported in eCos
|
// Data entries not currently supported in eCos
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DATA
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_DATA
|
CYGACC_CALL_IF_DBG_DATA_SET(0);
|
CYGACC_CALL_IF_DBG_DATA_SET(0);
|
#endif
|
#endif
|
|
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_VERSION
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_VERSION
|
CYGACC_CALL_IF_MONITOR_VERSION_SET(0);
|
CYGACC_CALL_IF_MONITOR_VERSION_SET(0);
|
#endif
|
#endif
|
|
|
// Comm controls
|
// Comm controls
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_COMMS
|
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_CLAIM_COMMS
|
{
|
{
|
int i, j;
|
int i, j;
|
|
|
// Clear out tables with safe dummy function.
|
// Clear out tables with safe dummy function.
|
for (j = 0; j < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS+1; j++)
|
for (j = 0; j < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS+1; j++)
|
for (i = 0; i < CYGNUM_COMM_IF_TABLE_SIZE; i++)
|
for (i = 0; i < CYGNUM_COMM_IF_TABLE_SIZE; i++)
|
comm_channels[j][i] = (CYG_ADDRWORD) &nop_service;
|
comm_channels[j][i] = (CYG_ADDRWORD) &nop_service;
|
|
|
// Set accessor functions
|
// Set accessor functions
|
CYGACC_CALL_IF_SET_DEBUG_COMM_SET(set_debug_comm);
|
CYGACC_CALL_IF_SET_DEBUG_COMM_SET(set_debug_comm);
|
CYGACC_CALL_IF_SET_CONSOLE_COMM_SET(set_console_comm);
|
CYGACC_CALL_IF_SET_CONSOLE_COMM_SET(set_console_comm);
|
|
|
// Initialize console/debug procs. Note that these _must_
|
// Initialize console/debug procs. Note that these _must_
|
// be set to empty before the comms init call.
|
// be set to empty before the comms init call.
|
set_debug_comm(CYGNUM_CALL_IF_SET_COMM_ID_EMPTY);
|
set_debug_comm(CYGNUM_CALL_IF_SET_COMM_ID_EMPTY);
|
set_console_comm(CYGNUM_CALL_IF_SET_COMM_ID_EMPTY);
|
set_console_comm(CYGNUM_CALL_IF_SET_COMM_ID_EMPTY);
|
|
|
// Initialize channels. This used to be done in
|
// Initialize channels. This used to be done in
|
// hal_diag_init() and the stub initHardware() functions, but
|
// hal_diag_init() and the stub initHardware() functions, but
|
// it makes more sense to have here.
|
// it makes more sense to have here.
|
cyg_hal_plf_comms_init();
|
cyg_hal_plf_comms_init();
|
|
|
// Always set the debug channel. If stubs are included, it is
|
// Always set the debug channel. If stubs are included, it is
|
// necessary. If no stubs are included it does not hurt and is
|
// necessary. If no stubs are included it does not hurt and is
|
// likely to be required by the hal_if_diag_init code anyway
|
// likely to be required by the hal_if_diag_init code anyway
|
// as it may rely on it if using a mangler.
|
// as it may rely on it if using a mangler.
|
set_debug_comm(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL);
|
set_debug_comm(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL);
|
// Set console channel to a safe default. hal_if_diag_init
|
// Set console channel to a safe default. hal_if_diag_init
|
// will override with console channel or mangler if necessary.
|
// will override with console channel or mangler if necessary.
|
set_console_comm(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL);
|
set_console_comm(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL);
|
}
|
}
|
|
|
// Reset console interrupt flag.
|
// Reset console interrupt flag.
|
CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(0);
|
CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(0);
|
#endif
|
#endif
|
|
|
// Set up services provided by clients
|
// Set up services provided by clients
|
#if defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT) && \
|
#if defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT) && \
|
( defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs) \
|
( defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs) \
|
|| defined(CYGSEM_HAL_USE_ROM_MONITOR_CygMon))
|
|| defined(CYGSEM_HAL_USE_ROM_MONITOR_CygMon))
|
|
|
patch_dbg_syscalls( (void *)(hal_virtual_vector_table) );
|
patch_dbg_syscalls( (void *)(hal_virtual_vector_table) );
|
#endif
|
#endif
|
|
|
// Init client services
|
// Init client services
|
#if !defined(CYGPKG_KERNEL) && defined(CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT)
|
#if !defined(CYGPKG_KERNEL) && defined(CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT)
|
// Only include this code if we do not have a kernel. Otherwise
|
// Only include this code if we do not have a kernel. Otherwise
|
// the kernel supplies the functionality for the app we are linked
|
// the kernel supplies the functionality for the app we are linked
|
// with.
|
// with.
|
|
|
// Prepare for application installation of thread info function in
|
// Prepare for application installation of thread info function in
|
// vector table.
|
// vector table.
|
init_thread_syscall( (void *)&hal_virtual_vector_table[CYGNUM_CALL_IF_DBG_SYSCALL] );
|
init_thread_syscall( (void *)&hal_virtual_vector_table[CYGNUM_CALL_IF_DBG_SYSCALL] );
|
#endif
|
#endif
|
|
|
// Finally, install async breakpoint handler if it is configured in.
|
// Finally, install async breakpoint handler if it is configured in.
|
// FIXME: this should probably check for STUBS instead (but code is
|
// FIXME: this should probably check for STUBS instead (but code is
|
// conditional on BREAK for now)
|
// conditional on BREAK for now)
|
#if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT)
|
#if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT)
|
// Install async breakpoint handler into vector table.
|
// Install async breakpoint handler into vector table.
|
CYGACC_CALL_IF_INSTALL_BPT_FN_SET(&cyg_hal_gdb_interrupt);
|
CYGACC_CALL_IF_INSTALL_BPT_FN_SET(&cyg_hal_gdb_interrupt);
|
#endif
|
#endif
|
|
|
#if 0 != CYGINT_HAL_PLF_IF_INIT
|
#if 0 != CYGINT_HAL_PLF_IF_INIT
|
// Call platform specific initializations - should only be used
|
// Call platform specific initializations - should only be used
|
// to augment what has already been set up, etc.
|
// to augment what has already been set up, etc.
|
plf_if_init();
|
plf_if_init();
|
#endif
|
#endif
|
}
|
}
|
|
|