OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/rtos/ecos-2.0/packages/cygmon/v2_0
    from Rev 27 to Rev 174
    Reverse comparison

Rev 27 → Rev 174

/cdl/cygmon.cdl
0,0 → 1,140
# ====================================================================
#
# cygmon.cdl
#
# CygMon package configuration data
#
# ====================================================================
#####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): jskov
# Original data: gthomas
# Contributors: dmoseley
# Date: 1999-11-03
#
#####DESCRIPTIONEND####
#
# ====================================================================
cdl_package CYGPKG_CYGMON {
display "CygMon ROM monitor"
requires CYGPKG_LIBC_STRING
include_dir cyg/cygmon
define_header cygmon.h
description "
This package supports the CygMon \[stand-alone debug monitor\]
using eCos as the underlying board support mechanism."
 
 
# Since the CYGDAT_CYGMON_CONSOLE_DEV setting ends up in the platform
# HAL header, we need to include that here (via hal.h).
define_proc {
puts $::cdl_header "#include <pkgconf/hal.h>"
}
 
cdl_option CYGDAT_CYGMON_USE_HELP {
display "Include detailed command help"
default_value 1
description "
When this option is selected, the CygMon image will include
detailed help information for all built-in commands. Without
it, only minimal help will be provided."
}
 
cdl_option CYGBLD_BUILD_CYGMON {
display "Build CygMon ROM ELF image"
default_value 0
requires { CYG_HAL_STARTUP == "ROM" }
requires CYGPKG_INFRA
requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
requires ! CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
requires ! CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT
requires ! CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
requires CYGPKG_LIBC_STRING
requires ! CYGFUN_LIBC_strtod
requires ! CYGPKG_LIBC_STDIO
requires ! CYGSEM_LIBC_SIGNALS_THREAD_SAFE
requires ! CYGIMP_LIBC_SIGNALS_RAISE_INLINE
requires ! CYGIMP_LIBC_SIGNALS_SIGNAL_INLINE
requires ! CYGSEM_LIBC_SIGNALS_RAISE_SETS_ERRNO
requires ! CYGSEM_LIBC_SIGNALS_SIGNAL_SETS_ERRNO
requires ! CYGFUN_LIBC_ATEXIT
requires ! CYGSEM_LIBC_EXIT_CALLS_FFLUSH
requires ! CYGPKG_LIBC_ENVIRONMENT
requires ! CYGSEM_LIBC_PER_THREAD_ERRNO
requires ! CYGSEM_LIBC_TIME_TIME_WORKING
requires ! CYGSEM_LIBC_TIME_SETTIME_WORKING
requires { CYGPKG_HAL_ARM || CYGPKG_HAL_MIPS || CYGPKG_HAL_MN10300 }
 
no_define
description "This option enables the building of the CygMon ELF image.
The image may require further relocation or symbol
stripping before being converted to a binary image.
This is handled by a rule in the target CDL."
 
make -priority 320 {
<PREFIX>/bin/cygmon.elf : $(PREFIX)/lib/target.ld $(PREFIX)/lib/vectors.o $(PREFIX)/lib/libtarget.a $(PREFIX)/lib/libextras.a <PACKAGE>/misc/ecos_bsp.c <PACKAGE>/misc/ecos_dummy.c <PACKAGE>/misc/cpu-mon.c <PACKAGE>/misc/monitor.c <PACKAGE>/misc/monitor_cmd.c <PACKAGE>/misc/ledit.c <PACKAGE>/misc/breakpoints.c <PACKAGE>/misc/bplist-dynamic.c <PACKAGE>/misc/utils.c <PACKAGE>/misc/generic_fmt32.c <PACKAGE>/misc/generic_mem.c <PACKAGE>/misc/bsp/common/bsp.c <PACKAGE>/misc/bsp/common/bsp_if.c <PACKAGE>/misc/bsp/common/shared-data.c <PACKAGE>/misc/bsp/common/sysinfo.c <PACKAGE>/misc/bsp/common/console-io.c <PACKAGE>/misc/bsp/common/debug-io.c <PACKAGE>/misc/bsp/common/sprintf.c <PACKAGE>/misc/bsp/common/syscall.c <PACKAGE>/misc/bsp/common/printf.c <PACKAGE>/misc/bsp/common/vprintf.c <PACKAGE>/misc/bsp/common/breakpoint.c <PACKAGE>/misc/bsp/common/singlestep.c <PACKAGE>/misc/bsp/common/generic-mem.c <PACKAGE>/misc/bsp/common/bsp_cache.c <PACKAGE>/misc/bsp/common/gdb-cpu.c <PACKAGE>/misc/bsp/common/hex-utils.c
@sh -c "mkdir -p misc/bsp/common $(dir $@)"
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/ecos_bsp.o $(REPOSITORY)/$(PACKAGE)/misc/ecos_bsp.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/ecos_dummy.o $(REPOSITORY)/$(PACKAGE)/misc/ecos_dummy.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/cpu-mon.o $(REPOSITORY)/$(PACKAGE)/misc/cpu-mon.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/monitor.o $(REPOSITORY)/$(PACKAGE)/misc/monitor.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/monitor_cmd.o $(REPOSITORY)/$(PACKAGE)/misc/monitor_cmd.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/ledit.o $(REPOSITORY)/$(PACKAGE)/misc/ledit.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/breakpoints.o $(REPOSITORY)/$(PACKAGE)/misc/breakpoints.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bplist-dynamic.o $(REPOSITORY)/$(PACKAGE)/misc/bplist-dynamic.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/utils.o $(REPOSITORY)/$(PACKAGE)/misc/utils.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/generic_fmt32.o $(REPOSITORY)/$(PACKAGE)/misc/generic_fmt32.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/generic_mem.o $(REPOSITORY)/$(PACKAGE)/misc/generic_mem.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/bsp.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/bsp.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/bsp_if.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/bsp_if.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/shared-data.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/shared-data.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/sysinfo.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/sysinfo.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/console-io.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/console-io.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/debug-io.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/debug-io.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/sprintf.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/sprintf.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/syscall.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/syscall.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/printf.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/printf.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/vprintf.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/vprintf.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/breakpoint.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/breakpoint.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/singlestep.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/singlestep.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/generic-mem.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/generic-mem.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/bsp_cache.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/bsp_cache.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/gdb-cpu.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/gdb-cpu.c
$(CC) -c -I$(REPOSITORY)/$(PACKAGE)/misc $(INCLUDE_PATH) $(CFLAGS) -DHAVE_BSP -D__ECOS__ -o misc/bsp/common/hex-utils.o $(REPOSITORY)/$(PACKAGE)/misc/bsp/common/hex-utils.c
$(CC) $(LDFLAGS) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(filter-out %.ld %vectors.o, $(patsubst $(REPOSITORY)/$(PACKAGE)/%.c,%.o,$^))
}
}
}
/ChangeLog
0,0 → 1,252
2000-12-04 Drew Moseley <dmoseley@redhat.com>
 
* misc/monitor_cmd.c (breakpoint_cmd): Fix typo in printf
formatting for error message.
 
2000-11-20 Drew Moseley <dmoseley@redhat.com>
 
* cdl/cygmon.cdl: Make sure we don't specify vectors.o and target.ld twice.
 
2000-11-03 Jonathan Larmour <jlarmour@redhat.com>
 
* cdl/cygmon.cdl: Improve cygmon.elf make dependencies
 
2000-10-17 Drew Moseley <dmoseley@redhat.com>
 
* misc/utils.c: Fix a typo. Also make sure we are ignoring the
'+' characters from gdb.
 
* misc/monitor_cmd.c: Add a few cache flushes.
 
* misc/monitor.h: Use the debug port for xvprintf.
 
2000-08-14 Drew Moseley <dmoseley@redhat.com>
 
* misc/ecos_bsp.c: Added some include files to fix some build
failures on partially unsupported systems. (ie non-cygmon, etc).
 
2000-08-12 Drew Moseley <dmoseley@redhat.com>
 
* misc/bsp/common/debug-io.c (bsp_debug_write): Use
output_gdb_string when stub_is_active.
 
2000-08-10 Drew Moseley <dmoseley@redhat.com>
 
* misc/utils.c: Removed some unused functions. Also handle
printing invalid registers.
 
* misc/monitor_cmd.c: Handle some unprintable characters better.
Also handle displaying of invalid memory locations better.
Add handling for register validity checking.
 
* misc/monitor.h: Add a conditional field "reg_valid" to struct
regstruct.
 
* misc/monitor.c: Added a call to a conditionally defined routine
INITIALIZE_MON_EACH_TIME(). This is called everytime the monitor
is invoked. For instance, this is used to determine which
registers have actually been read.
 
* misc/generic_mem.c: Allow Cygmon to use the Safe memory routines
in the HAL.
 
* misc/board.h: Added MN10300 basic support.
* misc/cpu-mon.c: Ditto.
* misc/cpu_info.h: Ditto.
* misc/bsp/cpu.h: Ditto.
* misc/bsp/mn10300/gdb-cpu.c: Ditto. New file.
* misc/bsp/mn10300/gdb-cpu.h: Ditto. New file.
* misc/bsp/mn10300/gdb.h: Ditto. New file.
* misc/bsp/mn10300/insn.h: Ditto. New file.
* misc/bsp/mn10300/singlestep.c: Ditto. New file.
* misc/mn10300/board.h: Ditto. New file.
* misc/mn10300/cpu.h: Ditto. New file.
* misc/mn10300/cpu_info.h: Ditto. New file.
* misc/mn10300/mn10300-mon.c: Ditto. New file.
 
* cdl/cygmon.cdl: Removed dependency on the kernel and Serial I/O.
* misc/ecos_bsp.c: Ditto.
* misc/ecos_dummy.c: Ditto.
 
2000-07-21 Drew Moseley <dmoseley@redhat.com>
 
* misc/ecos_bsp.c: Rearrange the linkage between Cygmon and HAL so
that Cygmon needs HAL but not vice-versa. ie HAL no longer calls
any Cygmon functions.
* misc/monitor.c: Ditto.
 
2000-07-14 Drew Moseley <dmoseley@redhat.com>
 
* misc/bsp/mips/gdb-cpu.c: New files. Mips based Cygmon now running on top of eCos HAL.
* misc/bsp/mips/gdb-cpu.h: Ditto.
* misc/bsp/mips/gdb.h: Ditto.
* misc/bsp/mips/insn.h: Ditto.
* misc/bsp/mips/singlestep.c: Ditto.
* misc/mips/board.h: Ditto.
* misc/mips/cpu.h: Ditto.
* misc/mips/cpu_info.h: Ditto.
* misc/mips/mips-mon.c: Ditto.
 
* misc/bsp/common/syscall.c: Added SYS_meminfo call to find out
how much RAM we have.
* misc/bsp/common/syscall.h: Ditto.
 
* misc/bsp/common/breakpoint.c: Added __ECOS__ support.
 
* misc/monitor_cmd.c: Cleanup. Added some more error handling.
* misc/utils.c: Ditto.
 
* misc/monitor.c: Added basic syscall handling to support libgloss.
Added support for using more features of the HAL (ie breakpoints
and exceptions).
* misc/monitor.h: Ditto.
* misc/tservice.h: Ditto.
* misc/bsp/bsp.h: Ditto.
* misc/arm/cpu_info.h: Ditto.
 
* misc/ledit.c: Cleanup.
 
* misc/ecos_dummy.c: Support for reset through the HAL.
 
* misc/ecos_bsp.c: Filled in uart_control function for setting baud rate
through the HAL. Also added VIRTUAL_VECTOR_SUPPORT and support of the
low-level HAL-based serial driver. Also added set_memsize() support.
 
* misc/bplist-dynamic.c: Added option for using breakpoints in the HAL.
Also, various cleanups of build warnings, etc.
* misc/breakpoints.c: Ditto.
 
* cdl/cygmon.cdl: Allow cygmon to be built for either Arm or Mips.
* misc/board.h: Move architecture-dependent things out.
* misc/cpu-mon.c: Ditto.
* misc/cpu_info.h: Ditto.
* misc/bsp/cpu.h: Ditto.
* misc/bsp/common/gdb-cpu.c: Ditto.
* misc/bsp/common/gdb-cpu.h: Ditto.
* misc/bsp/common/singlestep.c: Ditto.
 
2000-01-28 Jesper Skov <jskov@redhat.com>
 
* misc/Notes_CygMon_PID: Added.
 
2000-01-27 Jesper Skov <jskov@redhat.com>
 
* cdl/cygmon.cdl: Include hal.h config for CygMon options defined
by platform CDL.
 
2000-01-26 Jonathan Larmour <jlarmour@redhat.co.uk>
 
* cdl/cygmon.cdl: Remove CYGDAT_CYGMON_ENABLE - no longer required
 
2000-01-25 Jesper Skov <jskov@cygnus.co.uk>
 
* cdl/cygmon.cdl: Moved console device config to target CDL.
Let target CDL handle binary conversion.
 
1999-12-17 Bart Veer <bartv@cygnus.co.uk>
 
* cdl/cygmon.cdl:
Fix a requires property, getting the quoting right
 
1999-12-14 John Dallaway <jld@cygnus.co.uk>
 
* cdl/cygmon.cdl: Add custom make rule to build CygMon.
 
1999-12-06 Gary Thomas <gthomas@cygnus.co.uk>
 
* misc/arm/arm-mon.c (machine_syscall):
* misc/ecos_bsp.c (_bsp_handle_exception):
* misc/PKGconf.mak: Adding 'syscall' support.
 
* misc/CygMon_PID.cfg:
* misc/bsp/common/syscall.h:
* misc/bsp/common/syscall.c: New file(s).
 
1999-11-26 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* misc/CygMon_EDB7211.cfg: Rename to misc/CygMon/EDB7xxx.cfg
* misc/CygMon_EDB7xxx.cfg: New file
 
1999-11-26 Gary Thomas <gthomas@cygnus.co.uk>
 
* misc/ecos_bsp.c (_bsp_board_init): Use/define HAL symbols
for board/cpu information.
(_bsp_memory_list): Use MLT information here.
 
* misc/CygMon_EDB7211.cfg: Fix typo. Change startup to be
ROM which gives more useful RAM information.
 
1999-11-19 Gary Thomas <gthomas@cygnus.co.uk>
 
* misc/CygMon_EDB7211.cfg: Add platform parameter. Update
patch for latest changes.
 
1999-11-03 Jesper Skov <jskov@cygnus.co.uk>
 
* cdl/cygmon.cdl: Added.
 
1999-10-27 Gary Thomas <gthomas@cygnus.co.uk>
 
* misc/PKGconf.mak: Add new targets (.bin .srec images).
 
* include/pkgconf/cygmon.h: Update strings to be more conformant.
 
* misc/CygMon_EDB7211.cfg: New file for building CygMon.
 
* include/pkgconf/cygmon.h: Add work-around because packages
can't be disabled by default.
 
1999-10-26 Gary Thomas <gthomas@cygnus.co.uk>
 
* include/pkgconf/cygmon.h: Fix typo 'CYGPKC_LIBC'=>'CYGPKG_LIBC'
Also, node type was wrong ('radio' instead of 'boolean')
 
1999-10-25 Gary Thomas <gthomas@cygnus.co.uk>
 
* include/pkgconf/cygmon.h: Add configuration options for
console device [name] and extended help. Remove duplicate
boilerplate.
 
* misc/board.h: Enable "help" via configuration option.
 
* misc/ecos_bsp.c: Cleanup/remove extra (debug) code.
Add support for console port configuration.
 
* misc/monitor.c:
* misc/monitor_cmd.c: Cleanup/remove some debug code.
 
//===========================================================================
//####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####
//===========================================================================
/misc/arm/arm-mon.c
0,0 → 1,281
//==========================================================================
//
// arm-mon.c
//
// Support code to extend the generic monitor code to support
// ARM(R) 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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Support code to extend the generic monitor code to support
// ARM(R) processors.
// Description: Further board specific support is in other files.
// This file contains:
// register names lookup table
//
// Empty Stubs:
// Interval timer - This should really belong to the application
// operating system.
//
// Should not contain:
// low level uart getchar and putchar functions
// delay function to support uart
//
// ARM is a Registered Trademark of Advanced RISC Machines
// Limited.
// Other Brands and Trademarks are the property of their
// respective owners.
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include <setjmp.h>
#include <bsp/bsp.h>
#include <bsp/cpu.h>
#ifdef DISASSEMBLER
#include <dis-asm.h>
#endif
 
#include "cpu_info.h"
#include "monitor.h"
 
/* This module is required to provide many of the services defined
in tservice.h */
 
static char *apcs_names[] = {
"a1", "a2", "a3", "a4",
"v1", "v2", "v3", "v4",
"v5", "v6", "sl", "fp",
"ip", "sp", "lr", "pc",
#if HAVE_FLOAT_REGS
"f0", "f1", "f2", "f3",
"f4", "f5", "f6", "f7",
"fps",
#endif
"ps"
};
 
static char *standard_names[] =
{
"r0", "r1", "r2", "r3",
"r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11",
"r12", "r13", "r14", "pc",
#if HAVE_FLOAT_REGS
"f0", "f1", "f2", "f3",
"f4", "f5", "f6", "f7",
"fps",
#endif
"ps",
};
 
 
void arm_othernames (void);
 
struct regstruct regtab[] =
{
{ 0, REG_R0, REGTYPE_INT },
{ 0, REG_R1, REGTYPE_INT },
{ 0, REG_R2, REGTYPE_INT },
{ 0, REG_R3, REGTYPE_INT },
{ 0, REG_R4, REGTYPE_INT },
{ 0, REG_R5, REGTYPE_INT },
{ 0, REG_R6, REGTYPE_INT },
{ 0, REG_R7, REGTYPE_INT },
{ 0, REG_R8, REGTYPE_INT },
{ 0, REG_R9, REGTYPE_INT },
{ 0, REG_R10, REGTYPE_INT },
{ 0, REG_R11, REGTYPE_INT },
{ 0, REG_R12, REGTYPE_INT },
{ 0, REG_SP, REGTYPE_INT },
{ 0, REG_LR, REGTYPE_INT },
{ 0, REG_PC, REGTYPE_INT },
#if HAVE_FLOAT_REGS
{ 0, REG_F0, REGTYPE_FLOAT },
{ 0, REG_F1, REGTYPE_FLOAT },
{ 0, REG_F2, REGTYPE_FLOAT },
{ 0, REG_F3, REGTYPE_FLOAT },
{ 0, REG_F4, REGTYPE_FLOAT },
{ 0, REG_F5, REGTYPE_FLOAT },
{ 0, REG_F6, REGTYPE_FLOAT },
{ 0, REG_F6, REGTYPE_FLOAT },
{ 0, REG_FPS, REGTYPE_FLOAT },
#endif
{ 0, REG_CPSR, REGTYPE_INT },
{ 0, 0, 0 } /* Terminating element must be last */
} ;
 
void
initialize_mon(void)
{
/* FIXME: Convert ALL variable initializations to assignments
in order to support ROMABLE CODE.
This includes the register table
*/
 
/*
* Call arm_othernames to sync up Cygmon and the disassembler
* and ensure they are using the same set of registernames
*/
arm_othernames();
 
/*
* Call arm_othernames again to revert to the assembler
* default names
*/
arm_othernames();
 
} /* initialize_mon */
 
 
/*
read_memory
write_memory
Defaults to generic_mem.c
*/
 
 
/* SET_BREAKPOINT -
CLEAR_BREAKPOINT
Defaults to generic_bp32.c
*/
 
 
#ifndef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
 
/* Return the currently-saved value corresponding to register "regnum". */
target_regval_t
get_register (int regnum)
{
struct regstruct *p;
target_regval_t reg;
int offset, len;
char *dest = (char*)0;
 
for (p = regtab; p->registername && p->registernumber != regnum; ++p)
;
 
if (p->registername) {
len = bsp_regsize(p->registernumber);
offset = bsp_regbyte(p->registernumber);
switch (p->registertype) {
case REGTYPE_INT:
dest = (char*)&(reg.i);
break;
#if HAVE_FLOAT_REGS
case REGTYPE_FLOAT:
dest = (char*)&(reg.f);
break;
#endif
#if HAVE_DOUBLE_REGS
case REGTYPE_DOUBLE:
dest = (char*)&(reg.d);
break;
#endif
}
if (dest)
memcpy(dest, (char *)mon_saved_regs + offset, len);
} else
reg.i = 0;
 
return reg;
}
 
 
 
/* Store VALUE in the register corresponding to REGNUM. */
void
put_register (int regnum, target_regval_t value)
{
int offset, len;
 
len = bsp_regsize(regnum);
offset = bsp_regbyte(regnum);
memcpy((char *)mon_saved_regs + offset, &value, len);
}
 
#endif // !CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
 
/* Change to the alternate register set names */
void
arm_othernames (void)
{
static int regset = 1;
char **name;
int i;
 
#ifdef DISASSEMBLER
/* Change the disassembler */
regset = arm_toggle_regnames();
#else
regset = (regset == 0) ? 1 : 0;
#endif
 
/* Change cygmon */
if (regset == 1)
/* Disassembler is using apcs names. */
name = apcs_names;
else
/* Disassembler is using standard names. */
name = standard_names;
 
for (i = 0; i < (sizeof(apcs_names)/sizeof(apcs_names[0])); i++)
regtab[i].registername = name[i];
}
 
#ifdef __ECOS__
 
#include <pkgconf/hal.h>
#include <cyg/hal/hal_arch.h>
#include "bsp/common/bsp_if.h"
 
int
machine_syscall(HAL_SavedRegisters *regs)
{
int res, err;
err = _bsp_do_syscall(regs->d[0], // Function
regs->d[1], regs->d[2], regs->d[3], 0, // arguments,
&res);
regs->d[0] = res;
regs->pc += 4; // Advance PC
return err;
}
#endif
/misc/arm/cpu_info.h
0,0 → 1,100
#ifndef __ARM_CPU_INFO_H__
#define __ARM_CPU_INFO_H__
//==========================================================================
//
// cpu_info.h
//
// Architecture information for ARM 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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description: ARM is a Registered Trademark of Advanced RISC Machines
// Limited.
// Other Brands and Trademarks are the property of their
// respective owners.
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#define IS_ARM 1
 
#ifndef __CYGMON_TYPES
#define __CYGMON_TYPES
typedef unsigned int uint32;
typedef int int32;
#endif // __CYGMON_TYPES
 
 
/* Temporary as long a multiple protypes are copied in multiple files */
/* This variation does NOT clone the prototypes */
#define NO_MALLOC 1
#define MAX_NUM_BP 32
#define MAX_HIST_ENTS 10
 
/* big enuf to store a trap in the BP structure */
 
#define BP_INST_T_DEFINED 1
typedef unsigned long bp_inst_t ;
 
#define MEM_ADDR_DEFINED 1
typedef struct mem_addr {
unsigned long addr;
} mem_addr_t ;
 
#ifndef TARGET_REGISTER_T_DEFINED
#define TARGET_REGISTER_T_DEFINED
typedef unsigned long target_register_t;
#endif
 
#if defined(__ARMEB__)
#define PRINT_INSN print_insn_big_arm
#else
#define PRINT_INSN print_insn_little_arm
#endif
 
#define OTHERNAMES_CMD arm_othernames
extern void arm_othernames (void);
 
#undef BFD_MACH
#define BFD_MACH 0
 
#endif // __ARM_CPU_INFO_H__
/misc/arm/board.h
0,0 → 1,82
#ifndef __CYGMON_ARM_BOARD_H__
#define __CYGMON_ARM_BOARD_H__
//==========================================================================
//
// board.h
//
// Cygmon board/platform configuration file
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
// Hardware/platform/configuration specifics
 
#include <pkgconf/hal.h>
#include <pkgconf/cygmon.h>
 
#define HAVE_FLOAT_REGS 0
#define HAVE_DOUBLE_REGS 0
#define HAVE_CACHE 0 // FIXME
#define HAVE_USAGE 0 // FIXME
#define USE_CYGMON_PROTOTYPES 1
#define NOMAIN 1
#define CYGMON_SYSTEM_SERVICES 0 // Not used, fall back to BSP support
#ifdef CYGDAT_CYGMON_USE_HELP
#define USE_HELP 1
#endif
 
// For breakpoint support
#define NO_MALLOC 1
#define MAX_BP_NUM 8
#include "cpu_info.h"
#define TRAP_SIZE 4
#define __set_breakpoint set_breakpoint
#define __remove_breakpoint clear_breakpoint
#define __write_mem_safe memcpy
#define WRITE_MEM_IS_MEMCPY
#define _breakinst bsp_breakinsn
 
#endif // __CYGMON_ARM_BOARD_H__
/misc/arm/cpu.h
0,0 → 1,978
#ifndef __ARM_CPU_H__
#define __ARM_CPU_H__
//==========================================================================
//
// cpu.h
//
// ARM specific processor defines
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: ARM specific processor defines
// Description: ARM is a Registered Trademark of Advanced RISC Machines
// Limited.
// Other Brands and Trademarks are the property of their
// respective owners.
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include <bsp/bsp.h>
#include <bsp/defs.h>
#ifdef __ECOS__
#include <cyg/hal/hal_arch.h>
#endif
 
/*
* Only define __NEED_UNDERSCORE__ for arm-coff targets
*/
#if !defined(__ELF__)
# define __NEED_UNDERSCORE__
#endif
 
/*
* Macros to glue together two tokens.
*/
# ifdef __STDC__
# define XGLUE(a,b) a##b
# else
# define XGLUE(a,b) a/**/b
# endif
 
# define GLUE(a,b) XGLUE(a,b)
 
/*
* Symbol Names with leading underscore if necessary
*/
# ifdef __NEED_UNDERSCORE__
# define SYM_NAME(name) GLUE(_,name)
# else
# define SYM_NAME(name) name
# endif /* __NEED_UNDERSCORE__ */
 
/*
* Various macros to better handle assembler/object format differences
*/
#if defined(__ASSEMBLER__)
 
/*
* Assembly function start definition
*/
#ifdef __NEED_UNDERSCORE__
.macro FUNC_START name
.global _\name
.align 4
_\name:
.endm
#else
.macro FUNC_START name
.global \name
.align 4
\name:
.endm
#endif
 
/*
* Assembly function end definition
*/
#ifdef __NEED_UNDERSCORE__
.macro FUNC_END name
.endm
#else
.macro FUNC_END name
.endm
#endif
 
/*
* Register Prefix
*/
# ifndef __REGISTER_PREFIX__
# define __REGISTER_PREFIX__
# endif /* __REGISTER_PREFIX__ */
 
/*
* Immediate Prefix
*/
# ifndef __IMM_PREFIX__
# define __IMM_PREFIX__ #
# endif /* __IMM_PREFIX__ */
 
/*
* use the right prefix for registers.
*/
# define REG(x) GLUE(__REGISTER_PREFIX__,x)
 
/*
* use the right prefix for immediate values.
*/
# define IMM(x) GLUE(__IMM_PREFIX__,x)
 
#endif /* defined(__ASSEMBLER__) */
 
 
/*
* Setup register defines and such
*/
#if defined(__ASSEMBLER__)
 
# define r0 REG (r0)
# define r1 REG (r1)
# define r2 REG (r2)
# define r3 REG (r3)
 
# define r4 REG (r4)
# define r5 REG (r5)
# define r6 REG (r6)
# define r7 REG (r7)
# define r8 REG (r8)
# define r9 REG (r9)
# define r10 REG (r10)
# define r11 REG (r11)
# define r12 REG (r12)
# define r13 REG (r13)
# define sp REG (sp)
# define r14 REG (r14)
# define lr REG (lr)
# define pc REG (pc)
 
# define f0 REG (f0)
# define f1 REG (f1)
# define f2 REG (f2)
# define f3 REG (f3)
# define f4 REG (f4)
# define f5 REG (f5)
# define f6 REG (f6)
# define f7 REG (f7)
# define fps REG (fps)
 
# define cpsr REG (cpsr)
# define spsr REG (spsr)
 
/*
* Register offset definitions
* These numbers are offsets into the ex_regs_t struct.
*/
# define r0_o 0
# define r1_o 4
# define r2_o 8
# define r3_o 12
# define r4_o 16
# define r5_o 20
# define r6_o 24
# define r7_o 28
# define r8_o 32
# define r9_o 36
# define r10_o 40
# define r11_o 44
# define r12_o 48
# define r13_o 52
# define sp_o r13_o
# define r14_o 56
# define lr_o r14_o
# define pc_o 60
 
# define f0_o 64
# define f1_o 76
# define f2_o 88
# define f3_o 100
# define f4_o 112
# define f5_o 124
# define f6_o 136
# define f7_o 148
# define fps_o 160
 
# define cpsr_o 164
# define spsvc_o 168
# define ARM_EX_REGS_T_SIZE 172
 
#else /* !defined(__ASSEMBLER__) */
 
/*
* Register name that is used in help strings and such
*/
# define REGNAME_EXAMPLE "r0"
 
/*
* Register numbers. These are assumed to match the
* register numbers used by GDB.
*/
enum __regnames {
REG_R0,
REG_R1,
REG_R2,
REG_R3,
REG_R4,
REG_R5,
REG_R6,
REG_R7,
REG_R8,
REG_R9,
REG_R10,
REG_R11,
REG_R12,
REG_R13,
REG_SP=REG_R13,
REG_R14,
REG_LR=REG_R14,
REG_PC,
 
REG_F0,
REG_F1,
REG_F2,
REG_F3,
REG_F4,
REG_F5,
REG_F6,
REG_F7,
REG_FPS,
 
REG_CPSR,
REG_SPSVC,
REG_MAX=REG_SPSVC
};
 
/*
* 12-byte struct for storing Floating point registers
*/
typedef struct
{
unsigned long high;
unsigned long middle;
unsigned long low;
} fp_reg;
 
/*
* How registers are stored for exceptions.
*/
#ifdef __ECOS__
#define ex_regs_t HAL_SavedRegisters
#define _r0 d[0]
#define _r1 d[1]
#define _r2 d[2]
#define _r3 d[3]
#define _r4 d[4]
#define _r5 d[5]
#define _r6 d[6]
#define _r7 d[7]
#define _r8 d[8]
#define _r9 d[9]
#define _r10 d[10]
#define _r11 fp
#define _r12 ip
#define _r13 sp
#define _r14 lr
#define _pc pc
#define _cpsr cpsr
#define _spsvc msr
#else
typedef struct
{
unsigned long _r0;
unsigned long _r1;
unsigned long _r2;
unsigned long _r3;
unsigned long _r4;
unsigned long _r5;
unsigned long _r6;
unsigned long _r7;
unsigned long _r8;
unsigned long _r9;
unsigned long _r10;
unsigned long _r11;
unsigned long _r12;
unsigned long _r13;
unsigned long _r14;
unsigned long _pc;
 
fp_reg _f0;
fp_reg _f1;
fp_reg _f2;
fp_reg _f3;
fp_reg _f4;
fp_reg _f5;
fp_reg _f6;
fp_reg _f7;
unsigned long _fps;
unsigned long _cpsr;
 
unsigned long _spsvc; /* saved svc mode sp */
 
} ex_regs_t;
#endif
# define _sp _r13
# define _lr _r14
 
extern void __icache_flush(void *addr, int nbytes);
extern void __dcache_flush(void *addr, int nbytes);
 
#endif /* __ASSEMBLER__ */
 
 
/*
* Program Status Register Definitions
*/
#if defined(__ASSEMBLER__)
# define ARM_PSR_NEGATIVE 0x80000000 /* Negative Bit */
# define ARM_PSR_ZERO 0x40000000 /* Zero Bit */
# define ARM_PSR_CARRY 0x20000000 /* Carry Bit */
# define ARM_PSR_OVERFLOW 0x10000000 /* Overflow Bit */
# define ARM_PSR_IRQ 0x00000080 /* IRQ Bit */
# define ARM_PSR_FIQ 0x00000040 /* FIQ Bit */
# define ARM_PSR_THUMB_STATE 0x00000020 /* Thumb/ARM(R) Execution */
# define ARM_PSR_MODE_MASK 0x0000001F /* ARM(R) Processor Mode Mask */
#else /* ! defined(__ASSEMBLER__) */
struct psr_struct {
unsigned mode : 5;
unsigned t_bit : 1;
unsigned f_bit : 1;
unsigned i_bit : 1;
unsigned rsv1 : 20; /* == 0x00000 */
unsigned v_bit : 1;
unsigned c_bit : 1;
unsigned z_bit : 1;
unsigned n_bit : 1;
};
 
union arm_psr {
unsigned long word;
struct psr_struct psr;
};
#endif /* __ASSEMBLER__ */
 
/*
* PSR Mode values
*/
#define ARM_PSR_MODE_USER 0x00000010 /* User mode */
#define ARM_PSR_MODE_FIQ 0x00000011 /* FIQ mode */
#define ARM_PSR_MODE_IRQ 0x00000012 /* IRQ mode */
#define ARM_PSR_MODE_SVC 0x00000013 /* SVC mode */
#define ARM_PSR_MODE_ABORT 0x00000017 /* ABORT mode */
#define ARM_PSR_MODE_UNDEF 0x0000001B /* UNDEF mode */
#define ARM_PSR_MODE_SYSTEM 0x0000001F /* System Mode */
#define ARM_PSR_NUM_MODES 7
 
/*
* Core Exception vectors.
*/
#define BSP_CORE_EXC_RESET 0
#define BSP_CORE_EXC_UNDEFINED_INSTRUCTION 1
#define BSP_CORE_EXC_SOFTWARE_INTERRUPT 2
#define BSP_CORE_EXC_PREFETCH_ABORT 3
#define BSP_CORE_EXC_DATA_ABORT 4
#define BSP_CORE_EXC_ADDRESS_ERROR_26_BIT 5
#define BSP_CORE_EXC_IRQ 6
#define BSP_CORE_EXC_FIQ 7
#define BSP_MAX_EXCEPTIONS 8
#define BSP_CORE_EXC(vec_num) (unsigned long*)(vec_num << 2)
 
#define BREAKPOINT_INSN 0xE7FFDEFE /* Illegal inst opcode */
#define SYSCALL_SWI 0x00180001
 
#if defined(__ASSEMBLER__)
.macro BREAKPOINT
.word BREAKPOINT_INSN
.endm
.macro SYSCALL
swi IMM(SYSCALL_SWI)
.endm
.macro __CLI
stmfd sp!, {r0}
mrs r0, cpsr
bic r0, r0, IMM(ARM_PSR_IRQ | ARM_PSR_FIQ)
msr cpsr, r0
ldmfd sp!, {r0}
.endm
.macro __STI
stmfd sp!, {r0}
mrs r0, cpsr
orr r0, r0, IMM(ARM_PSR_IRQ | ARM_PSR_FIQ)
msr cpsr, r0
ldmfd sp!, {r0}
.endm
 
# if 0
/*
* Use this code to verify a particular processing mode
*/
mrs r0, cpsr
and r0, r0, IMM(ARM_PSR_MODE_MASK)
ldr r1, =ARM_PSR_MODE_IRQ
cmps r0, r1
0: bne 0b
PORT_TOGGLE_DEBUG
# endif /* 0 */
 
#else /* !defined(__ASSEMBLER__) */
 
# define BREAKPOINT() asm volatile(" .word 0xE7FFDEFE")
# define SYSCALL() asm volatile(" swi %0" : /* No outputs */ : "i" (SYSCALL_SWI))
# define __cli() asm volatile("
stmfd sp!, {r0}
mrs r0, cpsr
bic r0, r0, #0x000000C0
msr cpsr, r0
ldmfd sp!, {r0}")
# define __sti() asm volatile("
stmfd sp!, {r0}
mrs r0, cpsr
orr r0, r0, #0x000000C0
msr cpsr, r0
ldmfd sp!, {r0}")
# define __mcr(cp_num, opcode1, Rd, CRn, CRm, opcode2) \
asm volatile (" mcr " cp_num ", " \
opcode1 ", " \
"%0" ", " \
CRn ", " \
CRm ", " \
opcode2 : /* no outputs */ : "r" (Rd))
# define __mrc(cp_num, opcode1, Rd, CRn, CRm, opcode2) \
asm volatile (" mrc " cp_num ", " \
opcode1 ", " \
"%0" ", " \
CRn ", " \
CRm ", " \
opcode2 : "=r" (Rd) : /* no inputs */)
 
static inline unsigned __get_cpsr(void)
{
unsigned long retval;
asm volatile (" mrs %0, cpsr" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_cpsr(unsigned val)
{
asm volatile (" msr cpsr, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_spsr(void)
{
unsigned long retval;
asm volatile (" mrs %0, spsr" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_spsr(unsigned val)
{
asm volatile (" msr spsr, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_sp(void)
{
unsigned long retval;
asm volatile (" mov %0, sp" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_sp(unsigned val)
{
asm volatile (" mov sp, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_fp(void)
{
unsigned long retval;
asm volatile (" mov %0, fp" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_fp(unsigned val)
{
asm volatile (" mov fp, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_pc(void)
{
unsigned long retval;
asm volatile (" mov %0, pc" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_pc(unsigned val)
{
asm volatile (" mov pc, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_lr(void)
{
unsigned long retval;
asm volatile (" mov %0, lr" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_lr(unsigned val)
{
asm volatile (" mov lr, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_r8(void)
{
unsigned long retval;
asm volatile (" mov %0, r8" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_r8(unsigned val)
{
asm volatile (" mov r8, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_r9(void)
{
unsigned long retval;
asm volatile (" mov %0, r9" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_r9(unsigned val)
{
asm volatile (" mov r9, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_r10(void)
{
unsigned long retval;
asm volatile (" mov %0, r10" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_r10(unsigned val)
{
asm volatile (" mov r10, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_r11(void)
{
unsigned long retval;
asm volatile (" mov %0, r11" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_r11(unsigned val)
{
asm volatile (" mov r11, %0" : /* no outputs */ : "r" (val) );
}
 
static inline unsigned __get_r12(void)
{
unsigned long retval;
asm volatile (" mov %0, r12" : "=r" (retval) : /* no inputs */ );
return retval;
}
 
static inline void __set_r12(unsigned val)
{
asm volatile (" mov r12, %0" : /* no outputs */ : "r" (val) );
}
 
#endif /* defined(__ASSEMBLER__) */
 
#define GDB_BREAKPOINT_VECTOR BSP_CORE_EXC_UNDEFINED_INSTRUCTION
#define GDB_SYSCALL_VECTOR BSP_CORE_EXC_SOFTWARE_INTERRUPT
 
#define ARM_INST_SIZE sizeof(unsigned long)
#define GDB_BREAKPOINT_INST_SIZE ARM_INST_SIZE
 
#ifdef __CPU_LH77790A__
# include <bsp/lh77790a.h>
#endif /* __CPU_LH77790A__ */
 
#if !defined(__ASSEMBLER__)
/*
* Define the CPU specific data
*/
#ifdef __CPU_LH77790A__
typedef struct {
unsigned char lh77790a_port_control_shadow;
} arm_cpu_data;
#endif /* __CPU_LH77790A__ */
#endif /* !defined(__ASSEMBLER__) */
 
#ifdef __CPU_SA110__
#include <bsp/sa-110.h>
#endif /* __CPU_SA110__ */
 
#ifdef __CPU_SA1100__
#include <bsp/sa-1100.h>
#endif /* __CPU_SA110__ */
 
#ifdef __CPU_710T__
#include <bsp/arm710t.h>
#endif /* __CPU_710T__ */
 
#ifdef MMU
/*
* ARM(R) MMU Definitions
*/
 
#ifndef __ASSEMBLER__
extern void *page1;
#endif /* __ASSEMBLER__ */
 
/*
* ARM(R) Cache and MMU Control Registers
*
* Accessed through coprocessor instructions.
*/
#ifdef __ASSEMBLER__
# define ARM_CACHE_COPROCESSOR_NUM p15
# define ARM_COPROCESSOR_OPCODE_DONT_CARE 0x0
# define ARM_COPROCESSOR_RM_DONT_CARE c0
#else /* __ASSEMBLER__ */
# define ARM_CACHE_COPROCESSOR_NUM "p15"
# define ARM_COPROCESSOR_OPCODE_DONT_CARE "0x0"
# define ARM_COPROCESSOR_RM_DONT_CARE "c0"
#endif /* __ASSEMBLER__ */
 
#ifdef __ASSEMBLER__
# define ARM_ID_REGISTER c0
# define ARM_CONTROL_REGISTER c1
# define ARM_TRANSLATION_TABLE_BASE_REGISTER c2
# define ARM_DOMAIN_ACCESS_CONTROL_REGISTER c3
# define ARM_FAULT_STATUS_REGISTER c5
# define ARM_FAULT_ADDRESS_REGISTER c6
# define ARM_CACHE_OPERATIONS_REGISTER c7
# define ARM_TLB_OPERATIONS_REGISTER c8
# define ARM_READ_BUFFER_OPERATIONS_REGISTER c9
#else /* __ASSEMBLER__ */
# define ARM_ID_REGISTER "c0"
# define ARM_CONTROL_REGISTER "c1"
# define ARM_TRANSLATION_TABLE_BASE_REGISTER "c2"
# define ARM_DOMAIN_ACCESS_CONTROL_REGISTER "c3"
# define ARM_FAULT_STATUS_REGISTER "c5"
# define ARM_FAULT_ADDRESS_REGISTER "c6"
# define ARM_CACHE_OPERATIONS_REGISTER "c7"
# define ARM_TLB_OPERATIONS_REGISTER "c8"
# define ARM_READ_BUFFER_OPERATIONS_REGISTER "c9"
#endif /* __ASSEMBLER__ */
 
/*
* SA-1100 Cache and MMU ID Register value
*/
#define ARM_ID_MASK 0xFFFFFFF0
#define ARM_ID_VALUE 0x4401a110
 
/*
* SA-1100 Cache Control Register Bit Fields and Masks
*/
#define ARM_MMU_DISABLED 0x00000000
#define ARM_MMU_ENABLED 0x00000001
#define ARM_MMU_MASK 0x00000001
#define ARM_ADDRESS_FAULT_DISABLED 0x00000000
#define ARM_ADDRESS_FAULT_ENABLED 0x00000002
#define ARM_ADDRESS_FAULT_MASK 0x00000002
#define ARM_DATA_CACHE_DISABLED 0x00000000
#define ARM_DATA_CACHE_ENABLED 0x00000004
#define ARM_DATA_CACHE_MASK 0x00000004
#define ARM_WRITE_BUFFER_DISABLED 0x00000000
#define ARM_WRITE_BUFFER_ENABLED 0x00000008
#define ARM_WRITE_BUFFER_MASK 0x00000008
#define ARM_LITTLE_ENDIAN 0x00000000
#define ARM_BIG_ENDIAN 0x00000080
#define ARM_ACCESS_CHECKS_NONE 0x00000000
#define ARM_ACCESS_CHECKS_SYSTEM 0x00000100
#define ARM_ACCESS_CHECKS_ROM 0x00000200
#define ARM_INSTRUCTION_CACHE_DISABLED 0x00000000
#define ARM_INSTRUCTION_CACHE_ENABLED 0x00001000
#define ARM_INSTRUCTION_CACHE_MASK 0x00001000
#define ARM_VIRTUAL_IVR_BASE_00000000 0x00000000
#define ARM_VIRTUAL_IVR_BASE_FFFF0000 0x00002000
#define ARM_CONTROL_SBZ_MASK 0x00001FFF
 
/*
* SA-1100 Translation Table Base Bit Masks
*/
#define ARM_TRANSLATION_TABLE_MASK 0xFFFFC000
 
/*
* SA-1100 Domain Access Control Bit Masks
*/
#define ARM_DOMAIN_0_MASK 0x00000003
#define ARM_DOMAIN_1_MASK 0x0000000C
#define ARM_DOMAIN_2_MASK 0x00000030
#define ARM_DOMAIN_3_MASK 0x000000C0
#define ARM_DOMAIN_4_MASK 0x00000300
#define ARM_DOMAIN_5_MASK 0x00000C00
#define ARM_DOMAIN_6_MASK 0x00003000
#define ARM_DOMAIN_7_MASK 0x0000C000
#define ARM_DOMAIN_8_MASK 0x00030000
#define ARM_DOMAIN_9_MASK 0x000C0000
#define ARM_DOMAIN_10_MASK 0x00300000
#define ARM_DOMAIN_11_MASK 0x00C00000
#define ARM_DOMAIN_12_MASK 0x03000000
#define ARM_DOMAIN_13_MASK 0x0C000000
#define ARM_DOMAIN_14_MASK 0x30000000
#define ARM_DOMAIN_15_MASK 0xC0000000
 
#define ARM_ACCESS_TYPE_NO_ACCESS(domain_num) (0x0 << (domain_num))
#define ARM_ACCESS_TYPE_CLIENT(domain_num) (0x1 << (domain_num))
#define ARM_ACCESS_TYPE_MANAGER(domain_num) (0x3 << (domain_num))
 
/*
* SA-1100 Fault Status Bit Masks
*/
#define ARM_FAULT_STATUS_MASK 0x0000000F
#define ARM_DOMAIN_MASK 0x000000F0
#define ARM_DATA_BREAKPOINT_MASK 0x00000200
 
/*
* SA-1100 Cache Control Operations Definitions
*/
#ifdef __ASSEMBLER__
# define ARM_FLUSH_CACHE_INST_DATA_OPCODE 0x0
# define ARM_FLUSH_CACHE_INST_DATA_RM c7
# define ARM_FLUSH_CACHE_INST_OPCODE 0x0
# define ARM_FLUSH_CACHE_INST_RM c5
# define ARM_FLUSH_CACHE_DATA_OPCODE 0x0
# define ARM_FLUSH_CACHE_DATA_RM c6
# define ARM_FLUSH_CACHE_DATA_SINGLE_OPCODE 0x1
# define ARM_FLUSH_CACHE_DATA_SINGLE_RM c6
# define ARM_CLEAN_CACHE_DATA_ENTRY_OPCODE 0x1
# define ARM_CLEAN_CACHE_DATA_ENTRY_RM c10
# define ARM_DRAIN_CACHE_WRITE_BUFFER_OPCODE 0x4
# define ARM_DRAIN_CACHE_WRITE_BUFFER_RM c10
#else /* __ASSEMBLER__ */
# define ARM_FLUSH_CACHE_INST_DATA_OPCODE "0x0"
# define ARM_FLUSH_CACHE_INST_DATA_RM "c7"
# define ARM_FLUSH_CACHE_INST_OPCODE "0x0"
# define ARM_FLUSH_CACHE_INST_RM "c5"
# define ARM_FLUSH_CACHE_DATA_OPCODE "0x0"
# define ARM_FLUSH_CACHE_DATA_RM "c6"
# define ARM_FLUSH_CACHE_DATA_SINGLE_OPCODE "0x1"
# define ARM_FLUSH_CACHE_DATA_SINGLE_RM "c6"
# define ARM_CLEAN_CACHE_DATA_ENTRY_OPCODE "0x1"
# define ARM_CLEAN_CACHE_DATA_ENTRY_RM "c10"
# define ARM_DRAIN_CACHE_WRITE_BUFFER_OPCODE "0x4"
# define ARM_DRAIN_CACHE_WRITE_BUFFER_RM "c10"
#endif /* __ASSEMBLER__ */
 
/*
* SA-1100 TLB Operations Definitions
*/
#ifdef __ASSEMBLER__
# define ARM_FLUSH_INST_DATA_TLB_OPCODE 0x0
# define ARM_FLUSH_INST_DATA_TLB_RM c7
# define ARM_FLUSH_INST_TLB_OPCODE 0x0
# define ARM_FLUSH_INST_TLB_RM c5
# define ARM_FLUSH_DATA_TLB_OPCODE 0x0
# define ARM_FLUSH_DATA_TLB_RM c6
# define ARM_FLUSH_DATA_ENTRY_TLB_OPCODE 0x1
# define ARM_FLUSH_DATA_ENTRY_TLB_RM c6
#else /* __ASSEMBLER__ */
# define ARM_FLUSH_INST_DATA_TLB_OPCODE "0x0"
# define ARM_FLUSH_INST_DATA_TLB_RM "c7"
# define ARM_FLUSH_INST_TLB_OPCODE "0x0"
# define ARM_FLUSH_INST_TLB_RM "c5"
# define ARM_FLUSH_DATA_TLB_OPCODE "0x0"
# define ARM_FLUSH_DATA_TLB_RM "c6"
# define ARM_FLUSH_DATA_ENTRY_TLB_OPCODE "0x1"
# define ARM_FLUSH_DATA_ENTRY_TLB_RM "c6"
#endif /* __ASSEMBLER__ */
 
/*
* SA-1100 Read-Buffer Operations Definitions
*/
#ifdef __ASSEMBLER__
# define ARM_FLUSH_ALL_BUFFERS_OPCODE 0x0
# define ARM_FLUSH_ALL_BUFFERS_RM c0
# define ARM_FLUSH_BUFFER_0_OPCODE 0x1
# define ARM_FLUSH_BUFFER_0_RM c0
# define ARM_FLUSH_BUFFER_1_OPCODE 0x1
# define ARM_FLUSH_BUFFER_1_RM c1
# define ARM_FLUSH_BUFFER_2_OPCODE 0x1
# define ARM_FLUSH_BUFFER_2_RM c2
# define ARM_FLUSH_BUFFER_3_OPCODE 0x1
# define ARM_FLUSH_BUFFER_3_RM c3
# define ARM_LOAD_BUFFER_0_1_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_0_1_WORD_RM c0
# define ARM_LOAD_BUFFER_0_4_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_0_4_WORD_RM c4
# define ARM_LOAD_BUFFER_0_8_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_0_8_WORD_RM c8
# define ARM_LOAD_BUFFER_1_1_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_1_1_WORD_RM c1
# define ARM_LOAD_BUFFER_1_4_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_1_4_WORD_RM c5
# define ARM_LOAD_BUFFER_1_8_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_1_8_WORD_RM c9
# define ARM_LOAD_BUFFER_2_1_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_2_1_WORD_RM c2
# define ARM_LOAD_BUFFER_2_4_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_2_4_WORD_RM c6
# define ARM_LOAD_BUFFER_2_8_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_2_8_WORD_RM cA
# define ARM_LOAD_BUFFER_3_1_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_3_1_WORD_RM c3
# define ARM_LOAD_BUFFER_3_4_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_3_4_WORD_RM c7
# define ARM_LOAD_BUFFER_3_8_WORD_OPCODE 0x2
# define ARM_LOAD_BUFFER_3_8_WORD_RM cB
# define ARM_DISABLE_USER_MCR_ACCESS_OPCODE 0x4
# define ARM_DISABLE_USER_MCR_ACCESS_RM c0
# define ARM_ENABLE_USER_MCR_ACCESS_OPCODE 0x5
# define ARM_ENABLE_USER_MCR_ACCESS_RM c0
#else /* __ASSEMBLER__ */
# define ARM_FLUSH_ALL_BUFFERS_OPCODE "0x0"
# define ARM_FLUSH_ALL_BUFFERS_RM "c0"
# define ARM_FLUSH_BUFFER_0_OPCODE "0x1"
# define ARM_FLUSH_BUFFER_0_RM "c0"
# define ARM_FLUSH_BUFFER_1_OPCODE "0x1"
# define ARM_FLUSH_BUFFER_1_RM "c1"
# define ARM_FLUSH_BUFFER_2_OPCODE "0x1"
# define ARM_FLUSH_BUFFER_2_RM "c2"
# define ARM_FLUSH_BUFFER_3_OPCODE "0x1"
# define ARM_FLUSH_BUFFER_3_RM "c3"
# define ARM_LOAD_BUFFER_0_1_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_0_1_WORD_RM "c0"
# define ARM_LOAD_BUFFER_0_4_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_0_4_WORD_RM "c4"
# define ARM_LOAD_BUFFER_0_8_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_0_8_WORD_RM "c8"
# define ARM_LOAD_BUFFER_1_1_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_1_1_WORD_RM "c1"
# define ARM_LOAD_BUFFER_1_4_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_1_4_WORD_RM "c5"
# define ARM_LOAD_BUFFER_1_8_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_1_8_WORD_RM "c9"
# define ARM_LOAD_BUFFER_2_1_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_2_1_WORD_RM "c2"
# define ARM_LOAD_BUFFER_2_4_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_2_4_WORD_RM "c6"
# define ARM_LOAD_BUFFER_2_8_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_2_8_WORD_RM "cA"
# define ARM_LOAD_BUFFER_3_1_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_3_1_WORD_RM "c3"
# define ARM_LOAD_BUFFER_3_4_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_3_4_WORD_RM "c7"
# define ARM_LOAD_BUFFER_3_8_WORD_OPCODE "0x2"
# define ARM_LOAD_BUFFER_3_8_WORD_RM "cB"
# define ARM_DISABLE_USER_MCR_ACCESS_OPCODE "0x4"
# define ARM_DISABLE_USER_MCR_ACCESS_RM "c0"
# define ARM_ENABLE_USER_MCR_ACCESS_OPCODE "0x5"
# define ARM_ENABLE_USER_MCR_ACCESS_RM "c0"
#endif /* __ASSEMBLER__ */
 
/*
* ARM(R) First Level Descriptor Format Definitions
*/
#ifndef __ASSEMBLER__
struct ARM_MMU_FIRST_LEVEL_FAULT {
int id : 2;
int sbz : 30;
};
#define ARM_MMU_FIRST_LEVEL_FAULT_ID 0x0
 
struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE {
int id : 2;
int imp : 2;
int domain : 4;
int sbz : 1;
int base_address : 23;
};
#define ARM_MMU_FIRST_LEVEL_PAGE_TABLE_ID 0x1
 
struct ARM_MMU_FIRST_LEVEL_SECTION {
int id : 2;
int b : 1;
int c : 1;
int imp : 1;
int domain : 4;
int sbz0 : 1;
int ap : 2;
int sbz1 : 8;
int base_address : 12;
};
#define ARM_MMU_FIRST_LEVEL_SECTION_ID 0x2
 
struct ARM_MMU_FIRST_LEVEL_RESERVED {
int id : 2;
int sbz : 30;
};
#define ARM_MMU_FIRST_LEVEL_RESERVED_ID 0x3
 
#define ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, table_index) \
(unsigned long *)((unsigned long)(ttb_base) + ((table_index) << 2))
#define ARM_MMU_SECTION(ttb_base, actual_base, virtual_base, cacheable, bufferable, perm) \
{ \
register union ARM_MMU_FIRST_LEVEL_DESCRIPTOR desc; \
\
desc.word = 0; \
desc.section.id = ARM_MMU_FIRST_LEVEL_SECTION_ID; \
desc.section.domain = 0; \
desc.section.c = (cacheable); \
desc.section.b = (bufferable); \
desc.section.ap = (perm); \
desc.section.base_address = (actual_base); \
*ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, (virtual_base)) = desc.word; \
}
 
union ARM_MMU_FIRST_LEVEL_DESCRIPTOR {
unsigned long word;
struct ARM_MMU_FIRST_LEVEL_FAULT fault;
struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE page_table;
struct ARM_MMU_FIRST_LEVEL_SECTION section;
struct ARM_MMU_FIRST_LEVEL_RESERVED reserved;
};
 
#endif /* __ASSEMBLER__ */
 
#define ARM_UNCACHEABLE 0
#define ARM_CACHEABLE 1
#define ARM_UNBUFFERABLE 0
#define ARM_BUFFERABLE 1
 
#define ARM_ACCESS_PERM_NONE_NONE 0
#define ARM_ACCESS_PERM_RO_NONE 0
#define ARM_ACCESS_PERM_RO_RO 0
#define ARM_ACCESS_PERM_RW_NONE 1
#define ARM_ACCESS_PERM_RW_RO 2
#define ARM_ACCESS_PERM_RW_RW 3
 
#define ARM_SECTION_SIZE SZ_1M
#define ARM_SMALL_PAGE_SIZE SZ_4K
#define ARM_LARGE_PAGE_SIZE SZ_64K
 
#define ARM_FIRST_LEVEL_PAGE_TABLE_SIZE SZ_16K
#define ARM_SECOND_LEVEL_PAGE_TABLE_SIZE SZ_1K
 
#endif /* MMU */
 
#endif // __ARM_CPU_H__
/misc/utils.c
0,0 → 1,376
//==========================================================================
//
// utils.c
//
// Monitor utilities.
//
//==========================================================================
//####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):
// Contributors: gthomas, dmoseley
// Date: 1999-10-20
// Purpose: Monitor utilities.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_BSP
#include <bsp/bsp.h>
#include <bsp/cpu.h>
#include <bsp/hex-utils.h>
#endif
#include "monitor.h"
#include "tservice.h"
 
#if USE_CYGMON_PROTOTYPES
/* Use common prototypes */
/* Some of the composed board.h files compose these
prototypes redundently, but if they dont,
these are the common definitions */
#include "fmt_util.h" /* Interface to string formatting utilities */
#include "generic-stub.h" /* from libstub */
#endif /* USE_CYGMON_PROTOTYPES */
 
volatile int switch_to_stub_flag = 0;
 
/* Input routine for the line editor. */
int
input_char (void)
{
int i;
 
/* We have to drop the '+' characters on the floor
because gdb will send a '+' as the first character
when connecting to the target. If we waste time
echoing that, slow hw might get a uart overrun. */
while ((i = xgetchar ()) == '+');
 
if (i == '$')
{
xungetchar ('$');
switch_to_stub_flag = 1;
i = '\n';
}
return i;
}
 
 
static char tohex_array[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
 
#define tohex(X) (tohex_array[(X) & 15])
 
#ifdef HAVE_BSP
#define fromhex __hex
#else
static int
fromhex (a)
{
int number = -1;
 
if (a >= '0' && a <= '9')
number = a - '0';
else if (a >= 'a' && a <= 'f')
number = a - 'a' + 10;
else if (a >= 'A' && a <= 'F')
number = a - 'A' + 10;
else
xprintf ("Invalid hex digit %c", a);
 
return number;
}
#endif
 
 
static unsigned long long
str2ull (char *str, int base)
{
unsigned long long l = 0;
 
if (str[0] == '0' && str[1] == 'x')
{
str += 2 ;
base = 16 ;
}
 
while (*str != '\0')
{
if (*str == '.')
str++;
else
l = (l * base) + fromhex(*str++);
}
 
return l;
}
 
 
/* Converts a string to a long, base is the assumed base of the string */
 
target_register_t
str2int (char *str, int base)
{
return str2ull(str, base);
}
 
/* Converts a string to a double, input is a raw integer string
* of the given assumed base. */
#if HAVE_DOUBLE_REGS
static double
str2double (char *str, int base)
{
double d;
 
switch (sizeof(double))
{
case sizeof(unsigned int):
*((unsigned int *)&d) = str2ull(str, base);
break;
#if __LONG_MAX__ != __INT_MAX__
case sizeof(unsigned long):
*((unsigned long *)&d) = str2ull(str, base);
break;
#endif
#if __LONG_LONG_MAX__ != __LONG_MAX__
case sizeof(unsigned long long):
*((unsigned long long *)&d) = str2ull(str, base);
break;
#endif
default:
d = 0.0;
break;
}
return d;
}
#endif
 
target_register_t
str2intlen (char *str, int base, int len)
{
target_register_t number = 0;
 
while ((len--) > 0 && *str != '\0')
number = number * base + fromhex (*(str++));
 
return number;
}
 
int
hex2bytes (char *str, char *dest, int maxsize)
{
int i;
char *ptr;
 
for (i = 0; i < maxsize; i++)
dest[i] = 0;
maxsize--;
 
// Don't try and convert 0x prefix
if ((str[0] == '0') && (str[1] == 'x'))
str += 2;
 
ptr = str + strlen(str) - 1;
while (maxsize >= 0 && ptr >= str)
{
dest [maxsize] = fromhex(*ptr);
ptr--;
if (ptr >= str)
{
dest [maxsize--] |= fromhex(*ptr) * 16;
ptr--;
}
}
return 0;
}
 
 
/* Converts an unsigned long long to an ASCII string, adding leading
zeroes to pad space up to numdigs. */
static int use_dots = 1;
 
#define MAX_NUM_DIGS 51
 
static char *
ull2str (unsigned long long number, int base, int numdigs)
{
static char string[MAX_NUM_DIGS+1];
int dots, i;
char *ptr = string + MAX_NUM_DIGS;
 
dots = (use_dots && base == 16);
 
*(ptr--) = '\0';
*(ptr--) = tohex (number % base);
i = 1;
number = number / base;
 
while (number != 0)
{
if (dots && (i % 4) == 0)
*(ptr--) = '.';
*(ptr--) = tohex (number % base);
i++;
number = number / base;
}
 
if (numdigs == 0)
{
numdigs = i;
}
else
{
while(i < numdigs)
{
if (dots && (i % 4) == 0)
*(ptr--) = '.';
*(ptr--) = '0';
i++;
}
}
return ptr + 1;
}
 
 
char *
int2str (target_register_t number, int base, int numdigs)
{
return ull2str((unsigned long long)number, base, numdigs);
}
 
#if HAVE_DOUBLE_REGS
static char *
double2str(double d)
{
switch(sizeof(double))
{
case sizeof(unsigned int):
return ull2str(*((unsigned int *)&d), 16, sizeof(double) * 2);
break;
#if __LONG_MAX__ != __INT_MAX__
case sizeof(unsigned long):
return ull2str(*((unsigned long *)&d), 16, sizeof(double) * 2);
break;
#endif
#if __LONG_LONG_MAX__ != __LONG_MAX__
case sizeof(unsigned long long):
return ull2str(*((unsigned long long *)&d), 16, sizeof(double) * 2);
break;
#endif
}
return "....fixme...";
}
#endif
 
#ifndef NO_MALLOC
char *
strdup(const char *str)
{
char *x = malloc (strlen (str) + 1);
if (x != NULL)
strcpy (x, str);
return x;
}
#endif
 
 
target_register_t
get_pc(void)
{
return get_register(REG_PC);
}
 
 
#if defined(HAVE_BSP) && !defined(__ECOS__)
static int
get_register_type(regnames_t which)
{
int i;
 
for (i = 0; regtab[i].registername != NULL; i++)
if (regtab[i].registernumber == which)
return regtab[i].registertype;
return REGTYPE_INT;
}
#endif
 
char *get_register_str (regnames_t which, int detail, int valid)
{
#ifdef SPECIAL_REG_OUTPUT
char *res;
 
if ((res = SPECIAL_REG_OUTPUT (which, detail)) != NULL)
{
return res;
}
#endif
if (valid == 0)
{
switch (sizeof (target_register_t))
{
case 1: return "...";
case 2: return ".....";
case 4: return ".........";
case 8: return ".................";
default: return ".........";
}
}
else
{
return int2str (get_register (which), 16, sizeof (target_register_t) * 2);
}
}
 
 
void
store_register (regnames_t which, char *string)
{
#ifdef SPECIAL_REG_STORE
if (SPECIAL_REG_STORE(which, string))
return;
#endif
put_register (which, str2int (string, 16));
}
 
 
 
/misc/ledit.c
0,0 → 1,604
//==========================================================================
//
// ledit.c
//
// Utterly simple line editor
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Udderly simple line editor
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <monitor.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_BSP
#include <bsp/bsp.h>
#endif
#include "ledit.h"
 
#ifndef NULL
#define NULL 0
#endif
 
static char *cutBuf = NULL;
 
#ifdef NO_MALLOC
static char linebufArray [MAX_HIST_ENTS + 2][MAXLINELEN + 1];
#endif
 
static struct termcap
{
char *relleft, *relright;
char *oneleft;
char *insertch;
char *deletech;
char *deleteonech;
char *clreol;
char *gobol;
int width;
} terminal;
 
static struct linepos
{
char *prompt;
char *buffer;
char *ebuf;
int cursor;
} linebuf;
 
static struct history
{
char *cmd;
struct history *next, *prev;
} *list = NULL, *topl = NULL, *curl = NULL;
 
static int histlen = 0;
static int histLimit = MAX_HIST_ENTS;
 
static struct history histEnts[MAX_HIST_ENTS + 1], *histPtr = histEnts;
static struct history currLine = { NULL, NULL, NULL };
 
void
beep (void)
{
xputchar ('\007');
}
 
void
printHistoryList ()
{
struct history *hist = list;
int hist_num = 1;
 
if (hist != NULL)
{
while (hist->prev != NULL)
{
hist = hist->prev;
}
 
while (hist != NULL)
{
if (hist->cmd != NULL)
xprintf(" %d %s\n", hist_num++, hist->cmd);
hist = hist->next;
}
}
}
 
static void
outputParamStr (char *str, int val)
{
char *i = strchr (str, '%');
char *ptr;
int dist = val;
 
if (i == NULL)
{
while (dist-- > 0)
xprintf (str);
}
else
{
for (ptr = str; *ptr && ptr < i; ptr++)
xputchar (*ptr);
if (dist > 99)
{
xputchar ('0' + dist / 100);
dist = dist % 100;
}
if (dist > 9)
{
xputchar ('0' + dist / 10);
dist = dist % 10;
}
xputchar ('0' + dist);
if (*ptr)
xprintf (ptr + 1);
}
}
 
static void
absMoveCursor (int pos)
{
int dist, oldpos = linebuf.cursor;
int absdist;
char *bigmove;
 
if (pos > (linebuf.ebuf - linebuf.buffer))
{
beep ();
pos = linebuf.ebuf - linebuf.buffer;
}
else if (pos < 0)
pos = 0;
dist = pos - linebuf.cursor;
absdist = (dist < 0 ? -dist : dist);
linebuf.cursor = pos;
if (dist == 0)
return;
if (dist < 0)
bigmove = terminal.relleft;
else
bigmove = terminal.relright;
 
if ((absdist < 4) || (bigmove == NULL))
{
int x;
int promptLen = strlen (linebuf.prompt);
 
if (pos < (absdist - promptLen))
{
xprintf (terminal.gobol);
xprintf (linebuf.prompt);
for (x = 0; x < pos; x++)
xputchar (linebuf.buffer[x]);
return;
}
 
if (dist < 0)
{
for (x = 0; x < -dist ;x++)
xprintf (terminal.oneleft);
}
else
{
for (x = 0; x < dist; x++)
xputchar (linebuf.buffer [oldpos + x]);
}
}
else
{
outputParamStr (bigmove, absdist);
}
}
 
static void
clrScrToEol (void)
{
int len = linebuf.ebuf - linebuf.buffer;
 
if (len < linebuf.cursor)
return;
 
if(terminal.clreol)
{
xprintf (terminal.clreol);
}
else if (terminal.deletech)
{
outputParamStr (terminal.deletech, len - linebuf.cursor);
}
else
{
int oldcur = linebuf.cursor;
while (linebuf.cursor < len)
{
xputchar (' ');
linebuf.cursor++;
}
absMoveCursor (oldcur);
}
}
 
static void
redrawCmd (void)
{
xprintf (terminal.gobol);
xprintf (linebuf.prompt);
linebuf.buffer[linebuf.cursor] = 0;
xprintf (linebuf.buffer);
clrScrToEol ();
}
 
static void
instCmd (char *ncmd)
{
linebuf.cursor = strlen (ncmd);
strcpy (linebuf.buffer, ncmd);
redrawCmd ();
linebuf.ebuf = linebuf.buffer + linebuf.cursor;
}
 
static void
prevCmd (void)
{
if (curl == &currLine)
{
if (list != NULL)
{
*linebuf.ebuf = 0;
#ifdef NO_MALLOC
currLine.cmd = linebufArray[MAX_HIST_ENTS];
strcpy (currLine.cmd, linebuf.buffer);
#else
if (currLine.cmd != NULL)
free (currLine.cmd);
currLine.cmd = strdup (linebuf.buffer);
#endif
curl = list;
}
}
else
{
if (curl->prev != NULL)
curl = curl->prev;
}
if (curl != NULL && curl->cmd != NULL)
instCmd (curl->cmd);
else
beep ();
}
 
static void
nextCmd (void)
{
if (curl->next == NULL)
{
beep ();
}
else
{
curl = curl->next;
instCmd (curl->cmd);
}
 
}
 
static int initted = 0;
 
void
initVt100 (void)
{
terminal.gobol = "\r";
terminal.oneleft = "\010";
terminal.relleft = "\033[%D";
terminal.relright = "\033[%C";
terminal.insertch = "\033[%@";
terminal.deletech = "\033[%P";
terminal.deleteonech = "\033[P";
terminal.clreol = "\033[K";
terminal.width = 80;
initted = 1;
}
 
void
initDumb (void)
{
terminal.gobol = "\r";
terminal.oneleft = "\010";
terminal.relleft = NULL;
terminal.relright = NULL;
terminal.insertch = NULL;
terminal.deletech = NULL;
terminal.deleteonech = NULL;
terminal.clreol = NULL;
terminal.width = 80;
initted = 1;
}
 
static void
insertChar (char *chars, int num)
{
int len = linebuf.ebuf - linebuf.buffer + strlen (linebuf.prompt);
int n = 0;
 
if ((len + num) >= terminal.width)
{
beep ();
return;
}
if ((linebuf.ebuf - linebuf.buffer) > linebuf.cursor)
{
char *ptr, *eptr = linebuf.buffer + linebuf.cursor;
 
for (ptr = linebuf.ebuf; ptr >= eptr; ptr--)
*(ptr+num) = *ptr;
 
if (terminal.insertch != NULL)
outputParamStr (terminal.insertch, num);
}
for (n = 0; n < num; n++)
{
xputchar (*chars);
linebuf.buffer[linebuf.cursor++] = *(chars++);
}
 
linebuf.ebuf += num;
 
if (terminal.insertch == NULL)
{
char *ptr = linebuf.buffer + linebuf.cursor;
int oldcur = linebuf.cursor;
for (; ptr < linebuf.ebuf; ptr++)
xputchar (*ptr);
linebuf.cursor = linebuf.ebuf - linebuf.buffer;
absMoveCursor (oldcur);
}
}
 
static void
deleteEol (int putInCutBuffer)
{
int len = linebuf.ebuf - linebuf.buffer;
if (linebuf.cursor < len)
{
clrScrToEol ();
 
if (putInCutBuffer)
{
*linebuf.ebuf = 0;
#ifdef NO_MALLOC
cutBuf = linebufArray[MAX_HIST_ENTS + 1];
strcpy (cutBuf, linebuf.buffer + linebuf.cursor);
#else
if (cutBuf != NULL)
free (cutBuf);
cutBuf = strdup (linebuf.buffer + linebuf.cursor);
#endif
}
linebuf.ebuf = linebuf.buffer + linebuf.cursor;
}
}
 
static void
deleteCurrChar (void)
{
int len = linebuf.ebuf - linebuf.buffer;
char *ptr;
if (len == linebuf.cursor || len == 0)
return;
for (ptr = linebuf.buffer + linebuf.cursor; ptr < (linebuf.ebuf - 1); ptr++)
{
*ptr = *(ptr + 1);
if (terminal.deleteonech == NULL)
xputchar (*ptr);
}
linebuf.ebuf--;
if (terminal.deleteonech && (len - 1) != linebuf.cursor)
xprintf (terminal.deleteonech);
else
{
int oldcur = linebuf.cursor;
xputchar (' ');
linebuf.cursor = linebuf.ebuf - linebuf.buffer + 1;
absMoveCursor (oldcur);
}
}
 
static void
deleteChar (void)
{
if (linebuf.cursor == 0)
{
beep ();
return;
}
absMoveCursor (linebuf.cursor - 1);
deleteCurrChar ();
}
 
int
lineedit (char *prompt, char *buffer, int maxLen)
{
int c;
 
curl = &currLine;
 
if (!initted)
{
initted = 1;
/*initVt100 ();*/
initDumb();
}
linebuf.prompt = prompt;
linebuf.buffer = buffer;
linebuf.ebuf = buffer;
buffer[0] = 0;
linebuf.cursor = 0;
redrawCmd ();
while ((c=input_char ()) > 0)
{
switch (c)
{
case PREVCMD:
prevCmd ();
break;
case NEXTCMD:
nextCmd ();
break;
case LF:
case CR:
*linebuf.ebuf = 0;
#ifdef NO_MALLOC
cutBuf = NULL;
currLine.cmd = NULL;
#else
if (cutBuf != NULL)
{
free (cutBuf);
cutBuf = NULL;
}
if (currLine.cmd != NULL)
{
free (currLine.cmd);
currLine.cmd = NULL;
}
#endif
return linebuf.ebuf - linebuf.buffer;
break;
case BOLCMD:
absMoveCursor (0);
break;
case EOLCMD:
absMoveCursor (linebuf.ebuf-linebuf.buffer);
break;
case FORWCMD:
absMoveCursor (linebuf.cursor + 1);
break;
case BACKCMD:
absMoveCursor (linebuf.cursor - 1);
break;
case DELBACK:
case '\177':
deleteChar ();
break;
case ERASELINE:
absMoveCursor (0);
deleteEol (0);
break;
case DELEOL:
deleteEol (1);
break;
case DELCURRCH:
deleteCurrChar ();
break;
case YANKCH:
if (cutBuf != NULL)
insertChar (cutBuf,strlen (cutBuf));
break;
default:
if (c >= 32 && c < 127)
{
char ch = c;
insertChar (&ch, 1);
}
break;
}
}
return -1;
}
 
void
addHistoryCmd (char *cmd)
{
struct history *newent = NULL;
 
if (histlen >= histLimit)
{
newent = topl;
topl = topl->next;
topl->prev = NULL;
#ifdef NO_MALLOC
newent->prev = NULL;
newent->next = NULL;
#else
free (newent->cmd);
newent->cmd = NULL;
#endif
histlen = histLimit - 1;
}
 
histlen++;
 
if (newent == NULL)
{
newent = histPtr++;
#ifdef NO_MALLOC
newent->cmd = linebufArray[histlen - 1];
#endif
}
 
if (list == NULL)
{
list = newent;
list->prev = NULL;
topl = list;
}
else
{
list->next = newent;
list->next->prev = list;
list = list->next;
}
currLine.prev = list;
list->next = &currLine;
#ifdef NO_MALLOC
strcpy (list->cmd, cmd);
#else
list->cmd = strdup (cmd);
#endif
curl = &currLine;
}
 
void
set_term_name (char *name)
{
if (! strcmp (name, "vt100"))
{
initVt100 ();
}
else if (! strcmp (name, "dumb"))
{
initDumb ();
}
else
{
xprintf ("Unknown terminal name %s\n", name);
}
}
/misc/bsp/arm/gdb-cpu.c
0,0 → 1,208
//==========================================================================
//
// gdb-cpu.c
//
// CPU specific support for GDB stub.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: CPU specific support for GDB stub.
// Description: ARM is a Registered Trademark of Advanced RISC Machines
// Limited.
// Other Brands and Trademarks are the property of their
// respective owners.
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include <bsp/cpu.h>
#include <bsp/bsp.h>
#include "insn.h"
#include "gdb.h"
 
/*
* Return byte offset within the saved register area of the
* given register.
*/
int
bsp_regbyte(int regno)
{
switch(regno)
{
case REG_R0: return (int)&(((ex_regs_t*)0)->_r0); break;
case REG_R1: return (int)&(((ex_regs_t*)0)->_r1); break;
case REG_R2: return (int)&(((ex_regs_t*)0)->_r2); break;
case REG_R3: return (int)&(((ex_regs_t*)0)->_r3); break;
case REG_R4: return (int)&(((ex_regs_t*)0)->_r4); break;
case REG_R5: return (int)&(((ex_regs_t*)0)->_r5); break;
case REG_R6: return (int)&(((ex_regs_t*)0)->_r6); break;
case REG_R7: return (int)&(((ex_regs_t*)0)->_r7); break;
case REG_R8: return (int)&(((ex_regs_t*)0)->_r8); break;
case REG_R9: return (int)&(((ex_regs_t*)0)->_r9); break;
case REG_R10: return (int)&(((ex_regs_t*)0)->_r10); break;
case REG_R11: return (int)&(((ex_regs_t*)0)->_r11); break;
case REG_R12: return (int)&(((ex_regs_t*)0)->_r12); break;
case REG_SP: return (int)&(((ex_regs_t*)0)->_sp); break;
case REG_LR: return (int)&(((ex_regs_t*)0)->_lr); break;
case REG_PC: return (int)&(((ex_regs_t*)0)->_pc); break;
 
#ifndef __ECOS__
case REG_F0: return (int)&(((ex_regs_t*)0)->_f0); break;
case REG_F1: return (int)&(((ex_regs_t*)0)->_f1); break;
case REG_F2: return (int)&(((ex_regs_t*)0)->_f2); break;
case REG_F3: return (int)&(((ex_regs_t*)0)->_f3); break;
case REG_F4: return (int)&(((ex_regs_t*)0)->_f4); break;
case REG_F5: return (int)&(((ex_regs_t*)0)->_f5); break;
case REG_F6: return (int)&(((ex_regs_t*)0)->_f6); break;
case REG_F7: return (int)&(((ex_regs_t*)0)->_f7); break;
case REG_FPS: return (int)&(((ex_regs_t*)0)->_fps); break;
#endif
 
case REG_CPSR: return (int)&(((ex_regs_t*)0)->_cpsr); break;
case REG_SPSVC: return (int)&(((ex_regs_t*)0)->_spsvc); break;
}
 
return 0;
}
 
 
/*
* Return size in bytes of given register.
*/
int
bsp_regsize(int regno)
{
switch(regno)
{
case REG_R0: return (sizeof (((ex_regs_t*)0)->_r0)); break;
case REG_R1: return (sizeof (((ex_regs_t*)0)->_r1)); break;
case REG_R2: return (sizeof (((ex_regs_t*)0)->_r2)); break;
case REG_R3: return (sizeof (((ex_regs_t*)0)->_r3)); break;
case REG_R4: return (sizeof (((ex_regs_t*)0)->_r4)); break;
case REG_R5: return (sizeof (((ex_regs_t*)0)->_r5)); break;
case REG_R6: return (sizeof (((ex_regs_t*)0)->_r6)); break;
case REG_R7: return (sizeof (((ex_regs_t*)0)->_r7)); break;
case REG_R8: return (sizeof (((ex_regs_t*)0)->_r8)); break;
case REG_R9: return (sizeof (((ex_regs_t*)0)->_r9)); break;
case REG_R10: return (sizeof (((ex_regs_t*)0)->_r10)); break;
case REG_R11: return (sizeof (((ex_regs_t*)0)->_r11)); break;
case REG_R12: return (sizeof (((ex_regs_t*)0)->_r12)); break;
case REG_SP: return (sizeof (((ex_regs_t*)0)->_sp)); break;
case REG_LR: return (sizeof (((ex_regs_t*)0)->_lr)); break;
case REG_PC: return (sizeof (((ex_regs_t*)0)->_pc)); break;
 
#ifndef __ECOS__
case REG_F0: return (sizeof (((ex_regs_t*)0)->_f0)); break;
case REG_F1: return (sizeof (((ex_regs_t*)0)->_f1)); break;
case REG_F2: return (sizeof (((ex_regs_t*)0)->_f2)); break;
case REG_F3: return (sizeof (((ex_regs_t*)0)->_f3)); break;
case REG_F4: return (sizeof (((ex_regs_t*)0)->_f4)); break;
case REG_F5: return (sizeof (((ex_regs_t*)0)->_f5)); break;
case REG_F6: return (sizeof (((ex_regs_t*)0)->_f6)); break;
case REG_F7: return (sizeof (((ex_regs_t*)0)->_f7)); break;
case REG_FPS: return (sizeof (((ex_regs_t*)0)->_fps)); break;
#endif
case REG_CPSR: return (sizeof (((ex_regs_t*)0)->_cpsr)); break;
case REG_SPSVC: return (sizeof (((ex_regs_t*)0)->_spsvc)); break;
}
 
return 0;
}
 
 
/*
* Given an exception number and a pointer to saved registers,
* return a GDB signal value.
*/
int
bsp_get_signal(int exc_nr, void *saved_regs)
{
int sig = TARGET_SIGNAL_TRAP;
ex_regs_t *regs = (ex_regs_t *)saved_regs;
 
switch (exc_nr) {
case BSP_CORE_EXC_UNDEFINED_INSTRUCTION:
{
union arm_insn inst;
if (bsp_memory_read((void *)regs->_pc, 0, ARM_INST_SIZE * 8, 1, &(inst.word)) != 0)
{
/*
* We were able to read this address. It must be a valid address.
*/
if (inst.word == BREAKPOINT_INSN)
sig = TARGET_SIGNAL_TRAP;
}
else
sig = TARGET_SIGNAL_ILL;
}
break;
case BSP_CORE_EXC_SOFTWARE_INTERRUPT: sig = TARGET_SIGNAL_TRAP; break;
case BSP_CORE_EXC_PREFETCH_ABORT: sig = TARGET_SIGNAL_BUS; break;
case BSP_CORE_EXC_DATA_ABORT: sig = TARGET_SIGNAL_BUS; break;
case BSP_CORE_EXC_ADDRESS_ERROR_26_BIT: sig = TARGET_SIGNAL_BUS; break;
case BSP_CORE_EXC_IRQ: sig = TARGET_SIGNAL_INT; break;
case BSP_CORE_EXC_FIQ: sig = TARGET_SIGNAL_INT; break;
default: sig = TARGET_SIGNAL_TRAP; break;
}
 
return sig;
}
 
 
/*
* Set the PC value in the saved registers.
*/
void
bsp_set_pc(unsigned long pc, void *saved_regs)
{
((ex_regs_t *)saved_regs)->_pc = pc;
}
 
 
/*
* Get the PC value from the saved registers.
*/
unsigned long
bsp_get_pc(void *saved_regs)
{
return ((ex_regs_t *)saved_regs)->_pc;
}
/misc/bsp/arm/gdb.h
0,0 → 1,58
#ifndef __BSP_ARM_GDB_H__
#define __BSP_ARM_GDB_H__
//==========================================================================
//
// gdb.h
//
//
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include "../common/gdb.h"
 
#endif // __BSP_ARM_GDB_H__
/misc/bsp/arm/gdb-cpu.h
0,0 → 1,61
#ifndef __BSP_ARM_GDB_CPU_H__
#define __BSP_ARM_GDB_CPU_H__
//==========================================================================
//
// gdb-cpu.h
//
// CPU specific definitions for GDB stub.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: CPU specific definitions for GDB stub.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
/*
* Number of registers that gdb is interested in.
*/
#define NUMREGS 26
 
#endif // __BSP_ARM_GDB_CPU_H__
/misc/bsp/arm/insn.h
0,0 → 1,482
#ifndef __BSP_ARM_INSN_H__
#define __BSP_ARM_INSN_H__
//==========================================================================
//
// insn.h
//
// ARM(R) instruction descriptions.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: ARM(R) instruction descriptions.
// Description: ARM is a Registered Trademark of Advanced RISC Machines
// Limited.
// Other Brands and Trademarks are the property of their
// respective owners.
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
/* Data Processing Immediate Type */
struct dpi_type {
unsigned immediate : 8;
unsigned rotate : 4;
unsigned Rd : 4;
unsigned Rn : 4;
unsigned S_bit : 1;
unsigned opcode : 4;
unsigned rsv1 : 3; /* == 001b */
unsigned cond : 4;
};
#define DPI_RSV1_VALUE 0x1
 
/* Data Processing Immediate Shift Type */
struct dpis_type {
unsigned Rm : 4;
unsigned rsv2 : 1; /* == 0b */
unsigned shift : 2;
unsigned shift_immed : 5;
unsigned Rd : 4;
unsigned Rn : 4;
unsigned S_bit : 1;
unsigned opcode : 4;
unsigned rsv1 : 3; /* == 000b */
unsigned cond : 4;
};
#define DPIS_RSV1_VALUE 0x0
#define DPIS_RSV2_VALUE 0x0
 
/* Data Processing Register Shift Type */
struct dprs_type {
unsigned Rm : 4;
unsigned rsv3 : 1; /* == 1b */
unsigned shift : 2;
unsigned rsv2 : 1; /* == 0b */
unsigned Rs : 4;
unsigned Rd : 4;
unsigned Rn : 4;
unsigned S_bit : 1;
unsigned opcode : 4;
unsigned rsv1 : 3; /* == 000b */
unsigned cond : 4;
};
#define DPRS_RSV1_VALUE 0x0
#define DPRS_RSV2_VALUE 0x0
#define DPRS_RSV3_VALUE 0x1
 
/* Multiply Type */
struct m_type {
unsigned Rm : 4;
unsigned rsv2 : 4; /* == 1001b */
unsigned Rs : 4;
unsigned Rn : 4;
unsigned Rd : 4;
unsigned S_bit : 1;
unsigned A_bit : 1;
unsigned rsv1 : 6; /* == 000000b */
unsigned cond : 4;
};
#define M_RSV1_VALUE 0x0
#define M_RSV2_VALUE 0x9
 
/* Multiply Long Type */
struct ml_type {
unsigned Rm : 4;
unsigned rsv2 : 4; /* == 1001b */
unsigned Rs : 4;
unsigned RdLo : 4;
unsigned RdHi : 4;
unsigned S_bit : 1;
unsigned A_bit : 1;
unsigned U_bit : 1;
unsigned rsv1 : 5; /* == 00001b */
unsigned cond : 4;
};
#define ML_RSV1_VALUE 0x1
#define ML_RSV2_VALUE 0x9
 
/* Move from status register Type */
struct mrs_type {
unsigned SBZ : 12;
unsigned Rd : 4;
unsigned SBO : 4;
unsigned rsv2 : 2; /* == 00b */
unsigned R_bit : 1;
unsigned rsv1 : 5; /* == 00010b */
unsigned cond : 4;
};
#define MRS_RSV1_VALUE 0x2
#define MRS_RSV2_VALUE 0x0
 
/* Move Immediate to status register Type */
struct misr_type {
unsigned immediate : 8;
unsigned rotate : 4;
unsigned SBO : 4;
unsigned mask : 4;
unsigned rsv2 : 2; /* == 10b */
unsigned R_bit : 1;
unsigned rsv1 : 5; /* == 00110b */
unsigned cond : 4;
};
#define MISR_RSV1_VALUE 0x6
#define MISR_RSV2_VALUE 0x2
 
/* Move register to status register Type */
struct mrsr_type {
unsigned Rm : 4;
unsigned rsv3 : 1; /* == 0b */
unsigned SBZ : 7;
unsigned SBO : 4;
unsigned mask : 4;
unsigned rsv2 : 2; /* == 10b */
unsigned R_bit : 1;
unsigned rsv1 : 5; /* == 00010b */
unsigned cond : 4;
};
#define MRSR_RSV1_VALUE 0x2
#define MRSR_RSV2_VALUE 0x2
#define MRSR_RSV3_VALUE 0x0
 
/* Branch/Exchange Type */
struct bx_type {
unsigned Rm : 4;
unsigned rsv2 : 4; /* == 0001b */
unsigned SBO3 : 4;
unsigned SBO2 : 4;
unsigned SBO1 : 4;
unsigned rsv1 : 8; /* == 00010010b */
unsigned cond : 4;
};
#define BX_RSV1_VALUE 0x12
#define BX_RSV2_VALUE 0x1
 
/* Load/Store Immediate Offset Type */
struct lsio_type {
unsigned immediate : 12;
unsigned Rd : 4;
unsigned Rn : 4;
unsigned L_bit : 1;
unsigned W_bit : 1;
unsigned B_bit : 1;
unsigned U_bit : 1;
unsigned P_bit : 1;
unsigned rsv1 : 3; /* == 010b */
unsigned cond : 4;
};
#define LSIO_RSV1_VALUE 0x2
 
/* Load/Store Register Offset Type */
struct lsro_type {
unsigned Rm : 4;
unsigned rsv2 : 1; /* == 0b */
unsigned shift : 2;
unsigned shift_immed : 5;
unsigned Rd : 4;
unsigned Rn : 4;
unsigned L_bit : 1;
unsigned W_bit : 1;
unsigned B_bit : 1;
unsigned U_bit : 1;
unsigned P_bit : 1;
unsigned rsv1 : 3; /* == 011b */
unsigned cond : 4;
};
#define LSRO_RSV1_VALUE 0x3
#define LSRO_RSV2_VALUE 0x0
 
/* Load/Store halfword/signed byte Immediate Offset Type */
struct lshwi_type {
unsigned Lo_Offset : 4;
unsigned rsv4 : 1; /* == 1b */
unsigned H_bit : 1;
unsigned S_bit : 1;
unsigned rsv3 : 1; /* == 1b */
unsigned Hi_Offset : 4;
unsigned Rd : 4;
unsigned Rn : 4;
unsigned L_bit : 1;
unsigned W_bit : 1;
unsigned rsv2 : 1; /* == 1b */
unsigned U_bit : 1;
unsigned P_bit : 1;
unsigned rsv1 : 3; /* == 000b */
unsigned cond : 4;
};
#define LSHWI_RSV1_VALUE 0x0
#define LSHWI_RSV2_VALUE 0x1
#define LSHWI_RSV3_VALUE 0x1
#define LSHWI_RSV4_VALUE 0x1
 
/* Load/Store halfword/signed byte Register Offset Type */
struct lshwr_type {
unsigned Rm : 4;
unsigned rsv4 : 1; /* == 1b */
unsigned H_bit : 1;
unsigned S_bit : 1;
unsigned rsv3 : 1; /* == 1b */
unsigned SBZ : 4;
unsigned Rd : 4;
unsigned Rn : 4;
unsigned L_bit : 1;
unsigned W_bit : 1;
unsigned rsv2 : 1; /* == 0b */
unsigned U_bit : 1;
unsigned P_bit : 1;
unsigned rsv1 : 3; /* == 000b */
unsigned cond : 4;
};
#define LSHWR_RSV1_VALUE 0x3
#define LSHWR_RSV2_VALUE 0x1
#define LSHWR_RSV3_VALUE 0x1
#define LSHWR_RSV4_VALUE 0x1
 
/* Swap/Swap Byte Type */
struct swap_type {
unsigned Rm : 4;
unsigned rsv3 : 4; /* == 1001b */
unsigned SBZ : 4;
unsigned Rd : 4;
unsigned Rn : 4;
unsigned rsv2 : 2; /* == 00b */
unsigned B_bit : 1;
unsigned rsv1 : 5; /* == 00010b */
unsigned cond : 4;
};
#define SWAP_RSV1_VALUE 0x2
#define SWAP_RSV2_VALUE 0x0
#define SWAP_RSV3_VALUE 0x9
 
/* Load/Store Multiple Type */
struct lsm_type {
unsigned Reg_List : 16 ;
unsigned Rn : 4;
unsigned L_bit : 1;
unsigned W_bit : 1;
unsigned S_bit : 1;
unsigned U_bit : 1;
unsigned P_bit : 1;
unsigned rsv1 : 3; /* == 100b */
unsigned cond : 4;
};
#define LSM_RSV1_VALUE 0x4
 
/* Coprocessor Data Processing Type */
struct cpdp_type {
unsigned CRm : 4;
unsigned rsv2 : 1; /* == 0b */
unsigned op2 : 3;
unsigned cp_num : 4;
unsigned CRd : 4;
unsigned CRn : 4;
unsigned op1 : 4;
unsigned rsv1 : 4; /* == 1110b */
unsigned cond : 4;
};
#define CPDP_RSV1_VALUE 0xE
#define CPDP_RSV2_VALUE 0x0
 
/* Coprocessor Register Transfer Type */
struct cprt_type {
unsigned CRm : 4;
unsigned rsv2 : 1; /* == 1b */
unsigned op2 : 3;
unsigned cp_num : 4;
unsigned Rd : 4;
unsigned CRn : 4;
unsigned L_bit : 1;
unsigned op1 : 3;
unsigned rsv1 : 4; /* == 1110b */
unsigned cond : 4;
};
#define CPRT_RSV1_VALUE 0xE
#define CPRT_RSV2_VALUE 0x1
 
/* Coprocessor Load/Store Type */
struct cpls_type {
unsigned offset : 8;
unsigned cp_num : 4;
unsigned CRd : 4;
unsigned Rn : 4;
unsigned L_bit : 1;
unsigned W_bit : 1;
unsigned N_bit : 1;
unsigned U_bit : 1;
unsigned P_bit : 1;
unsigned rsv1 : 3; /* == 110b */
unsigned cond : 4;
};
#define CPLS_RSV1_VALUE 0x6
 
/* Branch/Branch w/ Link Type */
struct bbl_type {
unsigned offset : 24;
unsigned L_bit : 1;
unsigned rsv1 : 3; /* == 101b */
unsigned cond : 4;
};
#define BBL_RSV1_VALUE 0x5
 
/* SWI Type */
struct swi_type {
unsigned swi_number : 24;
unsigned rsv1 : 4; /* == 1111b */
unsigned cond : 4;
};
#define SWI_RSV1_VALUE 0xF
 
/* Undefined Instruction Type */
struct undef_type {
unsigned pad2 : 4;
unsigned rsv2 : 1; /* == 1b */
unsigned pad1 : 20;
unsigned rsv1 : 3; /* == 011b */
unsigned cond : 4;
};
#define UNDEF_RSV1_VALUE 0x3
#define UNDEF_RSV2_VALUE 0x1
 
union arm_insn {
unsigned long word;
struct dpi_type dpi;
struct dpis_type dpis;
struct dprs_type dprs;
struct m_type m;
struct ml_type ml;
struct mrs_type mrs;
struct misr_type misr;
struct mrsr_type mrsr;
struct bx_type bx;
struct lsio_type lsio;
struct lsro_type lsro;
struct lshwi_type lshwi;
struct lshwr_type lshwr;
struct swap_type swap;
struct lsm_type lsm;
struct cpdp_type cpdp;
struct cprt_type cprt;
struct cpls_type cpls;
struct bbl_type bbl;
struct swi_type swi;
struct undef_type undef;
};
 
/*
* Conditional field values
*/
#define COND_EQ 0x0
#define COND_NE 0x1
#define COND_CS_HI 0x2
#define COND_CC_LO 0x3
#define COND_MI 0x4
#define COND_PL 0x5
#define COND_VS 0x6
#define COND_VC 0x7
#define COND_HI 0x8
#define COND_LS 0x9
#define COND_GE 0xA
#define COND_LT 0xB
#define COND_GT 0xC
#define COND_LE 0xD
#define COND_AL 0xE
#define COND_NV 0xF
 
/*
* Data Processiong Opcode field values
*/
#define DP_OPCODE_MOV 0xD
#define DP_OPCODE_MVN 0xF
#define DP_OPCODE_ADD 0x4
#define DP_OPCODE_ADC 0x5
#define DP_OPCODE_SUB 0x2
#define DP_OPCODE_SBC 0x6
#define DP_OPCODE_RSB 0x3
#define DP_OPCODE_RSC 0x7
#define DP_OPCODE_AND 0x0
#define DP_OPCODE_EOR 0x1
#define DP_OPCODE_ORR 0xC
#define DP_OPCODE_BIC 0xE
#define DP_OPCODE_CMP 0xA
#define DP_OPCODE_CMN 0xB
#define DP_OPCODE_TST 0x8
#define DP_OPCODE_TEQ 0x9
 
/*
* Shift field values
*/
#define SHIFT_LSL 0x0
#define SHIFT_LSR 0x1
#define SHIFT_ASR 0x2
#define SHIFT_ROR 0x3
#define SHIFT_RRX 0x3 /* Special case: ROR(0) implies RRX */
 
/*
* Load/Store indexing definitions
*/
#define LS_INDEX_POST 0x0
#define LS_INDEX_PRE 0x1
 
/*
* Load/Store offset operation definitions
*/
#define LS_OFFSET_SUB 0x0
#define LS_OFFSET_ADD 0x1
 
/*
* Load/Store size definitions
*/
#define LS_SIZE_WORD 0x0
#define LS_SIZE_BYTE 0x1
 
/*
* Load/Store Update definitions
*/
#define LS_NO_UPDATE 0x0
#define LS_UPDATE 0x1
 
/*
* Load/Store Opcode definitions
*/
#define LS_STORE 0x0
#define LS_LOAD 0x1
 
#endif // __BSP_ARM_INSN_H__
/misc/bsp/arm/singlestep.c
0,0 → 1,1320
//==========================================================================
//
// singlestep.c
//
// ARM(R) specific single-step support.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: ARM(R) specific single-step support.
// Description: ARM is a Registered Trademark of Advanced RISC Machines Limited.
// Other Brands and Trademarks are the property of their
// respective owners.
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <stdlib.h>
#include <bsp/bsp.h>
#include <bsp/cpu.h>
#include "insn.h"
 
#define DEBUG_SINGLESTEP 0
#define DEBUG_SINGLESTEP_VERBOSE 0
 
/*
* Structure to hold opcodes hoisted when breakpoints are
* set for single-stepping or async interruption.
*/
struct _bp_save {
unsigned long *addr;
unsigned long opcode;
};
 
#define NUM_BREAKS_SAVED 2
static struct _bp_save _breaks[NUM_BREAKS_SAVED];
 
/*
* Insert a breakpoint at 'pc' using first available
* _bp_save struct.
*/
static void
insert_ss_break(unsigned long *pc)
{
struct _bp_save *p = _breaks;
union arm_insn inst;
 
if (p->addr && (++p)->addr)
return;
 
/*
* We can't set a breakpoint at 0
*/
if (pc == 0)
{
#if DEBUG_SINGLESTEP
bsp_printf("Setting BP at <0x%08lx>: Error\n", pc);
#endif /* DEBUG_SINGLESTEP */
return;
}
 
/*
* Make sure we are on a long word boundary.
*/
if (((unsigned long)pc & 0x3) != 0)
{
/*
* All ARM(R) instructions are on a word boundary.
* This would be invalid. Don't set a bkpt here.
*/
#if DEBUG_SINGLESTEP
bsp_printf("Setting BP at <0x%08lx>: Error\n", pc);
#endif /* DEBUG_SINGLESTEP */
return;
}
 
 
/*
* What is the current instruction
*/
if (bsp_memory_read(pc, 0, ARM_INST_SIZE * 8, 1, &(inst.word)) == 0)
{
/*
* Unable to read this address, probably an invalid address.
* Don't set a breakpoint here, as it will likely cause a bus error
*/
#if DEBUG_SINGLESTEP
bsp_printf("Setting BP at <0x%08lx>: Error\n", pc);
#endif /* DEBUG_SINGLESTEP */
return;
}
 
if (inst.word != BREAKPOINT_INSN)
{
/*
* Only insert a breakpoint if we haven't done so already
*
* We may try to insert 2 breakpoints if we to a branch to
* the immediately following instruction.
*/
#if DEBUG_SINGLESTEP
bsp_printf("Setting BP at <0x%08lx>: inst <0x%08lx>\n", pc, inst.word);
#endif /* DEBUG_SINGLESTEP */
 
p->addr = pc;
p->opcode = inst.word;
inst.word = BREAKPOINT_INSN;
if (bsp_memory_write(pc, 0, ARM_INST_SIZE * 8, 1, &(inst.word)) == 0)
{
/*
* Unable to write this address, probably an invalid address.
* Don't set a breakpoint here, as it will likely cause a bus error
*/
#if DEBUG_SINGLESTEP
bsp_printf("Setting BP at <0x%08lx>: Error\n", pc);
#endif /* DEBUG_SINGLESTEP */
return;
}
 
/* flush icache and dcache, now */
bsp_flush_dcache((void *)pc, ARM_INST_SIZE);
bsp_flush_icache((void *)pc, ARM_INST_SIZE);
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Done setting BP at <0x%08lx>: inst <0x%08lx>\n", pc, *pc);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
}
}
 
/*
* Cleanup after a singlestep.
*/
void
bsp_singlestep_cleanup(void *registers)
{
struct _bp_save *p = _breaks;
int i;
for (i = 0; i < NUM_BREAKS_SAVED; i++, p++)
{
if (p->addr)
{
unsigned long *old_addr = p->addr;
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Remove BP at <0x%08lx>: inst <0x%08lx>\n", old_addr, *old_addr);
#endif /* DEBUG_SINGLESTEP */
*(p->addr) = p->opcode;
p->addr = NULL;
 
/* flush icache and dcache, now */
bsp_flush_dcache((void *)old_addr, ARM_INST_SIZE);
bsp_flush_icache((void *)old_addr, ARM_INST_SIZE);
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Done removing BP at <0x%08lx>: inst <0x%08lx>\n", old_addr, *old_addr);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
}
}
}
 
/*
* Rotate right a value by count
*/
static unsigned long ror(unsigned long value, unsigned count)
{
while (count-- > 0)
{
if (value & 0x1)
value = (value >> 1) | 0x80000000;
else
value = (value >> 1);
}
 
return(value);
}
 
/*
* Rotate right a value by 1 with extend
*/
static unsigned long rrx(union arm_psr sr, unsigned long value)
{
if (sr.psr.c_bit)
value = (value >> 1) | 0x80000000;
else
value = (value >> 1);
 
return(value);
}
 
/*
* Logical shift left by count
*/
static unsigned long lsl(unsigned long value, unsigned count)
{
value <<= count;
 
return(value);
}
 
/*
* Logical shift right by count
*/
static unsigned long lsr(unsigned long value, unsigned count)
{
value >>= count;
 
return(value);
}
 
/*
* Arithmetic shift right by count
*/
static unsigned long asr(unsigned long value, unsigned count)
{
unsigned long sign_ext_mask = 0;
 
if (value & 0x80000000)
{
if (count >= sizeof(value)*8)
sign_ext_mask = ~0;
else
sign_ext_mask = (~0 << (sizeof(value)*8 - count));
}
value = (value >> count) | sign_ext_mask;
 
return(value);
}
 
/*
* Calculate an immediate shift operand based on input shift operand,
* shift value and register address.
*/
static unsigned long immediate_shift_operand(ex_regs_t *regs, unsigned shift_immediate,
unsigned shift, unsigned Rm)
{
unsigned char *regs_array = (unsigned char *)regs;
unsigned char *reg_ptr = &regs_array[bsp_regbyte(Rm)];
unsigned long reg_value = *((unsigned long *)(reg_ptr));
unsigned long rc = 0;
 
BSP_ASSERT((shift_immediate >= 0) && (shift_immediate <= 0x1f));
BSP_ASSERT((shift >= 0) && (shift <= 0x3));
BSP_ASSERT((Rm >= 0) && (Rm <= 0xf));
BSP_ASSERT(bsp_regsize(Rm) == sizeof(unsigned long));
 
/*
* According to the ARM(R) Manual, if Rm is PC then,
* the value used is the address of the current instruction
* plus 8
*/
if (Rm == REG_PC)
reg_value += 8;
 
switch (shift)
{
case SHIFT_LSL:
rc = lsl(reg_value, shift_immediate);
break;
 
case SHIFT_LSR:
if (shift_immediate == 0)
{
/*
* Special Case: LSR IMM(0) == 0
*/
rc = 0;
} else {
rc = lsr(reg_value, shift_immediate);
}
break;
 
case SHIFT_ASR:
if (shift_immediate == 0)
{
/*
* Special Case: ASR IMM(0)
*/
if (reg_value & 0x80000000)
{
rc = 0xFFFFFFFF;
} else {
rc = 0;
}
} else {
rc = asr(reg_value, shift_immediate);
}
break;
 
case SHIFT_ROR:
if (shift_immediate == 0)
{
/*
* SHIFT_RRX
* Special case: ROR(0) implies RRX
*/
rc = rrx((union arm_psr)(unsigned long)regs->_cpsr, reg_value);
} else {
rc = ror(reg_value, shift_immediate);
}
break;
 
default:
BSP_ASSERT(0);
break;
}
 
return (rc);
}
 
/*
* Calculate a register shift operand based on input shift operand,
* and target registers.
*/
static unsigned long register_shift_operand(ex_regs_t *regs, unsigned Rs,
unsigned shift, unsigned Rm)
{
unsigned char *regs_array = (unsigned char *)regs;
unsigned char *Rs_ptr = &regs_array[bsp_regbyte(Rs)];
unsigned char *Rm_ptr = &regs_array[bsp_regbyte(Rm)];
unsigned long Rs_val = *((unsigned long *)(Rs_ptr));
unsigned long Rm_val = *((unsigned long *)(Rm_ptr));
unsigned long rc = 0;
 
/*
* Use only the least significant byte of Rs
*/
Rs_val &= 0xFF;
 
BSP_ASSERT((Rs >= 0) && (Rs <= 0xf));
BSP_ASSERT((shift >= 0) && (shift <= 0x3));
BSP_ASSERT((Rm >= 0) && (Rm <= 0xf));
BSP_ASSERT(bsp_regsize(Rs) == sizeof(unsigned long));
BSP_ASSERT(bsp_regsize(Rm) == sizeof(unsigned long));
BSP_ASSERT((Rs_val >=0) && (Rs_val <= 0xff));
 
/*
* According to the ARM(R) Manual, if Rm is PC then,
* the value used is the address of the current instruction
* plus 8
*/
if (Rm == REG_PC)
Rm_val += 8;
 
switch (shift)
{
case SHIFT_LSL: rc = lsl(Rm_val, Rs_val); break;
case SHIFT_LSR: rc = lsr(Rm_val, Rs_val); break;
case SHIFT_ASR: rc = asr(Rm_val, Rs_val); break;
case SHIFT_ROR: rc = ror(Rm_val, Rs_val); break;
default: BSP_ASSERT(0); break;
}
 
return (rc);
}
 
/*
* Calculate a branch exchange operand based on input destination register
*/
static unsigned long branch_exchange_operand(ex_regs_t *regs, unsigned Rm)
{
unsigned char *regs_array = (unsigned char *)regs;
unsigned char *reg_ptr = &regs_array[bsp_regbyte(Rm)];
unsigned long reg_value = *((unsigned long *)(reg_ptr));
 
BSP_ASSERT((Rm >= 0) && (Rm <= 0xf));
BSP_ASSERT(bsp_regsize(Rm) == sizeof(unsigned long));
 
/*
* Clear the low-order bit
*/
return (reg_value & ~0x1);
}
 
/*
* Handle a load to the PC
*/
static void handle_pc_load(unsigned size, unsigned long operand)
{
unsigned long mem_value = 0;
 
if (size == LS_SIZE_WORD)
{
if (bsp_memory_read((void*)(operand & ~0x3), 0, 32, 1, &mem_value) == 0)
{
/*
* Unable to read the memory address.
* Don't try any further.
*/
#if DEBUG_SINGLESTEP
bsp_printf("Setting BP at *(0x%08lx): Error\n", operand & ~0x3);
#endif /* DEBUG_SINGLESTEP */
return;
} else {
#if DEBUG_SINGLESTEP
bsp_printf("Setting BP at *(0x%08lx): data <0x%08lx>\n", operand & ~0x3, mem_value);
#endif /* DEBUG_SINGLESTEP */
}
 
/*
* Handle rotations if required
*/
switch (operand & 0x3)
{
case 0x0: break;
case 0x1: mem_value = ror(mem_value, 8); break;
case 0x2: mem_value = ror(mem_value, 16); break;
case 0x3: mem_value = ror(mem_value, 24); break;
}
} else {
/*
* Byte load of the PC
*/
if (bsp_memory_read((void*)operand, 0, 8, 1, &mem_value) == 0)
{
/*
* Unable to read the memory address.
* Don't try any further.
*/
#if DEBUG_SINGLESTEP
bsp_printf("Setting BP at *(0x%08lx): Error\n", operand & ~0x3);
#endif /* DEBUG_SINGLESTEP */
return;
} else {
#if DEBUG_SINGLESTEP
bsp_printf("Setting BP at *(0x%08lx): data <0x%08lx>\n", operand & ~0x3, mem_value);
#endif /* DEBUG_SINGLESTEP */
}
}
insert_ss_break((unsigned long *)mem_value);
}
 
/*
* Calculate a load/store w/ Immediate offset operand based on input
* source register, offset value, and opcode (add/sub)
*/
static unsigned long load_store_immediate_operand(ex_regs_t *regs,
unsigned p_bit,
unsigned u_bit,
unsigned Rn,
unsigned offset)
{
unsigned char *regs_array = (unsigned char *)regs;
unsigned char *reg_ptr = &regs_array[bsp_regbyte(Rn)];
unsigned long rc = *((unsigned long *)(reg_ptr));
 
BSP_ASSERT((Rn >= 0) && (Rn <= 0xf));
BSP_ASSERT(bsp_regsize(Rn) == sizeof(unsigned long));
BSP_ASSERT((offset >= 0) && (offset <= 0xfff));
BSP_ASSERT((p_bit >= 0) && (p_bit <= 1));
BSP_ASSERT((u_bit >= 0) && (u_bit <= 1));
 
/*
* According to the ARM(R) Manual, if Rn is PC then,
* the value used is the address of the current instruction
* plus 8
*/
if (Rn == REG_PC)
rc += 8;
 
/*
* Do the update pre-index update
*/
if (p_bit == LS_INDEX_PRE)
{
if (u_bit == LS_OFFSET_SUB)
rc -= offset;
else /* opcode == LS_OFFSET_ADD */
rc += offset;
}
 
return (rc);
}
 
/*
* Calculate a load/store w/ Register offset operand based on input
* source register, offset value, and opcode (add/sub)
*
* This calculates the appropriate pre-indexed operand
*/
static unsigned long load_store_register_operand(ex_regs_t *regs,
unsigned p_bit,
unsigned u_bit,
unsigned Rn,
unsigned Rm,
unsigned shift,
unsigned shift_immed)
{
unsigned char *regs_array = (unsigned char *)regs;
unsigned char *Rn_ptr = &regs_array[bsp_regbyte(Rn)];
unsigned long Rn_val = *((unsigned long *)(Rn_ptr));
unsigned long rc, index;
 
BSP_ASSERT((Rn >= 0) && (Rn <= 0xf));
BSP_ASSERT((Rm >= 0) && (Rm <= 0xf));
BSP_ASSERT(bsp_regsize(Rn) == sizeof(unsigned long));
BSP_ASSERT(bsp_regsize(Rm) == sizeof(unsigned long));
BSP_ASSERT((p_bit >= 0) && (p_bit <= 1));
BSP_ASSERT((u_bit >= 0) && (u_bit <= 1));
BSP_ASSERT((shift >= 0) && (shift <= 0x3));
BSP_ASSERT((shift_immed >= 0) && (shift_immed <= 0x1F));
 
/*
* According to the ARM(R) Manual, if Rn is PC then
* the value used is the address of the current
* instruction plus 8
*/
if (Rn == REG_PC)
Rn_val += 8;
 
/*
* According to the ARM(R) Manual, if Rm is PC then
* the result is unpredictable. Don't do anything
* here. Just return.
*/
if (Rm == REG_PC)
return 0;
 
index = immediate_shift_operand(regs, shift_immed, shift, Rm);
rc = Rn_val;
 
/*
* Do the update pre-index update
*/
if (p_bit == LS_INDEX_PRE)
{
if (u_bit == LS_OFFSET_SUB)
rc = Rn_val - index;
else /* opcode == LS_OFFSET_ADD */
rc = Rn_val + index;
}
 
return (rc);
}
 
/*
* Decode all data processing immediate instructions
*/
static void decode_dpi_inst(ex_regs_t *regs, union arm_insn inst)
{
if (inst.dpi.Rd == REG_PC)
{
unsigned long operand = ror(inst.dpi.immediate, (inst.dpi.rotate << 1));
unsigned long *dest = 0;
unsigned carry = ((union arm_psr)(unsigned long)(regs->_cpsr)).psr.c_bit;
unsigned char *regs_array = (unsigned char *)regs;
unsigned char *Rn_ptr = &regs_array[bsp_regbyte(inst.dpi.Rn)];
unsigned long Rn_val = *((unsigned long *)(Rn_ptr));
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Decoded an data processing immediate instruction.\n");
bsp_printf("inst.dpi.immediate = 0x%x\n", inst.dpi.immediate);
bsp_printf("inst.dpi.rotate = 0x%x\n", inst.dpi.rotate);
bsp_printf("inst.dpi.Rd = 0x%x\n", inst.dpi.Rd);
bsp_printf("inst.dpi.Rn = 0x%x\n", inst.dpi.Rn);
bsp_printf("inst.dpi.S_bit = 0x%x\n", inst.dpi.S_bit);
bsp_printf("inst.dpi.opcode = 0x%x\n", inst.dpi.opcode);
bsp_printf("inst.dpi.cond = 0x%x\n", inst.dpi.cond);
bsp_printf("operand = 0x%x\n", operand);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
 
/*
* According to the ARM(R) Manual, if Rn is PC then
* the value used is the address of the current
* instruction plus 8
*/
if (inst.dpi.Rn == REG_PC)
Rn_val += 8;
 
switch (inst.dpi.opcode) {
case DP_OPCODE_ADC: dest = (unsigned long *)(Rn_val + operand + carry); break;
case DP_OPCODE_ADD: dest = (unsigned long *)(Rn_val + operand); break;
case DP_OPCODE_AND: dest = (unsigned long *)(Rn_val & operand); break;
case DP_OPCODE_BIC: dest = (unsigned long *)(Rn_val & ~operand); break;
case DP_OPCODE_EOR: dest = (unsigned long *)(Rn_val ^ operand); break;
case DP_OPCODE_MOV: dest = (unsigned long *)operand; break;
case DP_OPCODE_MVN: dest = (unsigned long *)(~operand); break;
case DP_OPCODE_ORR: dest = (unsigned long *)(Rn_val | operand); break;
case DP_OPCODE_RSB: dest = (unsigned long *)(operand - Rn_val); break;
case DP_OPCODE_RSC: dest = (unsigned long *)(operand - Rn_val - !carry); break;
case DP_OPCODE_SBC: dest = (unsigned long *)(Rn_val - operand - !carry); break;
case DP_OPCODE_SUB: dest = (unsigned long *)(Rn_val - operand); break;
default: dest = (unsigned long *)0; break;
}
dest = (unsigned long *)((unsigned long)dest & ~0x3);
insert_ss_break(dest);
}
}
 
/*
* Decode all data processing immediate w/ shift instructions
*/
static void decode_dpis_inst(ex_regs_t *regs, union arm_insn inst)
{
if (inst.dpis.Rd == REG_PC)
{
unsigned long operand = immediate_shift_operand(regs, inst.dpis.shift_immed,
inst.dpis.shift, inst.dpis.Rm);
unsigned long *dest = 0;
unsigned carry = ((union arm_psr)(unsigned long)(regs->_cpsr)).psr.c_bit;
unsigned char *regs_array = (unsigned char *)regs;
unsigned char *Rn_ptr = &regs_array[bsp_regbyte(inst.dpis.Rn)];
unsigned long Rn_val = *((unsigned long *)(Rn_ptr));
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Decoded an data processing immediate shift instruction.\n");
bsp_printf("inst.dpis.Rm = 0x%x\n", inst.dpis.Rm);
bsp_printf("inst.dpis.shift = 0x%x\n", inst.dpis.shift);
bsp_printf("inst.dpis.shift_immed = 0x%x\n", inst.dpis.shift_immed);
bsp_printf("inst.dpis.Rd = 0x%x\n", inst.dpis.Rd);
bsp_printf("inst.dpis.Rn = 0x%x\n", inst.dpis.Rn);
bsp_printf("inst.dpis.S_bit = 0x%x\n", inst.dpis.S_bit);
bsp_printf("inst.dpis.opcode = 0x%x\n", inst.dpis.opcode);
bsp_printf("inst.dpis.cond = 0x%x\n", inst.dpis.cond);
bsp_printf("operand = 0x%x\n", operand);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
 
/*
* According to the ARM(R) Manual, if Rn is PC then
* the value used is the address of the current
* instruction plus 8
*/
if (inst.dpis.Rn == REG_PC)
Rn_val += 8;
 
switch (inst.dpis.opcode) {
case DP_OPCODE_ADC: dest = (unsigned long *)(Rn_val + operand + carry); break;
case DP_OPCODE_ADD: dest = (unsigned long *)(Rn_val + operand); break;
case DP_OPCODE_AND: dest = (unsigned long *)(Rn_val & operand); break;
case DP_OPCODE_BIC: dest = (unsigned long *)(Rn_val & ~operand); break;
case DP_OPCODE_EOR: dest = (unsigned long *)(Rn_val ^ operand); break;
case DP_OPCODE_MOV: dest = (unsigned long *)operand; break;
case DP_OPCODE_MVN: dest = (unsigned long *)(~operand); break;
case DP_OPCODE_ORR: dest = (unsigned long *)(Rn_val | operand); break;
case DP_OPCODE_RSB: dest = (unsigned long *)(operand - Rn_val); break;
case DP_OPCODE_RSC: dest = (unsigned long *)(operand - Rn_val - !carry); break;
case DP_OPCODE_SBC: dest = (unsigned long *)(Rn_val - operand - !carry); break;
case DP_OPCODE_SUB: dest = (unsigned long *)(Rn_val - operand); break;
default: dest = (unsigned long *)0; break;
}
dest = (unsigned long *)((unsigned long)dest & ~0x3);
insert_ss_break(dest);
}
}
 
/*
* Decode all data processing register w/ shift instructions
*/
static void decode_dprs_inst(ex_regs_t *regs, union arm_insn inst)
{
if (inst.dprs.Rd == REG_PC)
{
unsigned long operand = register_shift_operand(regs, inst.dprs.Rs,
inst.dprs.shift, inst.dprs.Rm);
unsigned long *dest = 0;
unsigned carry = ((union arm_psr)(unsigned long)(regs->_cpsr)).psr.c_bit;
unsigned char *regs_array = (unsigned char *)regs;
unsigned char *Rn_ptr = &regs_array[bsp_regbyte(inst.dprs.Rn)];
unsigned long Rn_val = *((unsigned long *)(Rn_ptr));
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Decoded an data processing register shift instruction.\n");
bsp_printf("inst.dprs.Rm = 0x%x\n", inst.dprs.Rm);
bsp_printf("inst.dprs.rsv3 = 0x%x\n", inst.dprs.rsv3);
bsp_printf("inst.dprs.shift = 0x%x\n", inst.dprs.shift);
bsp_printf("inst.dprs.rsv2 = 0x%x\n", inst.dprs.rsv2);
bsp_printf("inst.dprs.Rs = 0x%x\n", inst.dprs.Rs);
bsp_printf("inst.dprs.Rd = 0x%x\n", inst.dprs.Rd);
bsp_printf("inst.dprs.Rn = 0x%x\n", inst.dprs.Rn);
bsp_printf("inst.dprs.S_bit = 0x%x\n", inst.dprs.S_bit);
bsp_printf("inst.dprs.opcode = 0x%x\n", inst.dprs.opcode);
bsp_printf("inst.dprs.rsv1 = 0x%x\n", inst.dprs.rsv1);
bsp_printf("inst.dprs.cond = 0x%x\n", inst.dprs.cond);
bsp_printf("operand = 0x%x\n", operand);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
 
/*
* According to the ARM(R) Manual, if Rn is PC then
* the value used is the address of the current
* instruction plus 8
*/
if (inst.dprs.Rn == REG_PC)
Rn_val += 8;
 
switch (inst.dprs.opcode) {
case DP_OPCODE_ADC: dest = (unsigned long *)(Rn_val + operand + carry); break;
case DP_OPCODE_ADD: dest = (unsigned long *)(Rn_val + operand); break;
case DP_OPCODE_AND: dest = (unsigned long *)(Rn_val & operand); break;
case DP_OPCODE_BIC: dest = (unsigned long *)(Rn_val & ~operand); break;
case DP_OPCODE_EOR: dest = (unsigned long *)(Rn_val ^ operand); break;
case DP_OPCODE_MOV: dest = (unsigned long *)operand; break;
case DP_OPCODE_MVN: dest = (unsigned long *)(~operand); break;
case DP_OPCODE_ORR: dest = (unsigned long *)(Rn_val | operand); break;
case DP_OPCODE_RSB: dest = (unsigned long *)(operand - Rn_val); break;
case DP_OPCODE_RSC: dest = (unsigned long *)(operand - Rn_val - !carry); break;
case DP_OPCODE_SBC: dest = (unsigned long *)(Rn_val - operand - !carry); break;
case DP_OPCODE_SUB: dest = (unsigned long *)(Rn_val - operand); break;
default: dest = (unsigned long *)0; break;
}
 
dest = (unsigned long *)((unsigned long)dest & ~0x3);
insert_ss_break(dest);
}
}
 
/*
* Decode all multiply instructions
*/
static void decode_m_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* According to the ARM(R) Manual, if Rd is PC then
* the result is unpredictable. Don't do anything
* here. Just return.
*/
}
 
/*
* Decode all multiply long instructions
*/
static void decode_ml_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* According to the ARM(R) Manual, if Rd is PC then
* the result is unpredictable. Don't do anything
* here. Just return.
*/
}
 
 
/*
* Decode all move from status register instructions
*/
static void decode_mrs_inst(ex_regs_t *regs, union arm_insn inst)
{
#if 0
if (inst.mrs.Rd == REG_PC)
{
unsigned long *dest = 0;
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Decoded an move from status register instruction.\n");
bsp_printf("inst.mrs.SBZ = 0x%x\n", inst.mrs.SBZ);
bsp_printf("inst.mrs.Rd = 0x%x\n", inst.mrs.Rd);
bsp_printf("inst.mrs.SBO = 0x%x\n", inst.mrs.SBO);
bsp_printf("inst.mrs.rsv2 = 0x%x\n", inst.mrs.rsv2);
bsp_printf("inst.mrs.R_bit = 0x%x\n", inst.mrs.R_bit);
bsp_printf("inst.mrs.rsv1 = 0x%x\n", inst.mrs.rsv1);
bsp_printf("inst.mrs.cond = 0x%x\n", inst.mrs.cond);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
 
if (inst.mrs.R_bit == 1)
dest = (unsigned long *)regs->_spsr;
else
dest = (unsigned long *)regs->_cpsr;
 
dest = (unsigned long *)((unsigned long)dest & ~0x3);
insert_ss_break(dest);
}
#endif
}
 
 
/*
* Decode all move immediate to status register instructions
*/
static void decode_misr_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Can't update the PC w/ this instruction.
* Don't set any more breakpoints
*/
}
 
 
/*
* Decode all move register to status registers instructions
*/
static void decode_mrsr_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Can't update the PC w/ this instruction.
* Don't set any more breakpoints
*/
}
 
 
/*
* Decode all branch/exchange instructions
*/
static void decode_bx_inst(ex_regs_t *regs, union arm_insn inst)
{
unsigned long operand = branch_exchange_operand(regs, inst.bx.Rm);
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Decoded an branch/exchange shift instruction.\n");
bsp_printf("inst.bx.Rm = 0x%x\n", inst.bx.Rm);
bsp_printf("inst.bx.rsv2 = 0x%x\n", inst.bx.rsv2);
bsp_printf("inst.bx.SBO3 = 0x%x\n", inst.bx.SBO3);
bsp_printf("inst.bx.SBO2 = 0x%x\n", inst.bx.SBO2);
bsp_printf("inst.bx.SBO1 = 0x%x\n", inst.bx.SBO1);
bsp_printf("inst.bx.rsv1 = 0x%x\n", inst.bx.rsv1);
bsp_printf("inst.bx.cond = 0x%x\n", inst.bx.cond);
bsp_printf("operand = 0x%x\n", operand);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
 
insert_ss_break((unsigned long *)operand);
}
 
 
/*
* Decode all load/store immediate offset instructions
*/
static void decode_lsio_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Only support direct loads of the PC
*
* According to the ARM(R) manual, automatic updates of the PC
* are UNPREDICTABLE (ie implementation defined).
*/
if ((inst.lsio.Rd == REG_PC) && (inst.lsio.L_bit == LS_LOAD))
{
unsigned long operand = load_store_immediate_operand(regs, inst.lsio.P_bit,
inst.lsio.U_bit, inst.lsio.Rn,
inst.lsio.immediate);
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Decoded an load/store w/ immediate offset instruction.\n");
bsp_printf("inst.lsio.immediate = 0x%x\n", inst.lsio.immediate);
bsp_printf("inst.lsio.Rd = 0x%x\n", inst.lsio.Rd);
bsp_printf("inst.lsio.Rn = 0x%x\n", inst.lsio.Rn);
bsp_printf("inst.lsio.L_bit = 0x%x\n", inst.lsio.L_bit);
bsp_printf("inst.lsio.W_bit = 0x%x\n", inst.lsio.W_bit);
bsp_printf("inst.lsio.B_bit = 0x%x\n", inst.lsio.B_bit);
bsp_printf("inst.lsio.U_bit = 0x%x\n", inst.lsio.U_bit);
bsp_printf("inst.lsio.P_bit = 0x%x\n", inst.lsio.P_bit);
bsp_printf("inst.lsio.rsv1 = 0x%x\n", inst.lsio.rsv1);
bsp_printf("inst.lsio.cond = 0x%x\n", inst.lsio.cond);
bsp_printf("operand = 0x%x\n", operand);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
 
handle_pc_load(inst.lsio.B_bit, operand);
}
}
 
 
/*
* Decode all load/store register offset instructions
*/
static void decode_lsro_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Only support direct loads of the PC
*
* According to the ARM(R) manual, automatic updates of the PC
* are UNPREDICTABLE (ie implementation defined).
*/
if ((inst.lsro.Rd == REG_PC) && (inst.lsro.L_bit == LS_LOAD))
{
unsigned long operand = load_store_register_operand(regs,
inst.lsro.P_bit,
inst.lsro.U_bit,
inst.lsro.Rn,
inst.lsro.Rm,
inst.lsro.shift,
inst.lsro.shift_immed);
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Decoded an load/store w/ register offset instruction.\n");
bsp_printf("inst.lsro.Rm = 0x%x\n", inst.lsro.Rm);
bsp_printf("inst.lsro.rsv2 = 0x%x\n", inst.lsro.rsv2);
bsp_printf("inst.lsro.shift = 0x%x\n", inst.lsro.shift);
bsp_printf("inst.lsro.shift_immed = 0x%x\n", inst.lsro.shift_immed);
bsp_printf("inst.lsro.Rd = 0x%x\n", inst.lsro.Rd);
bsp_printf("inst.lsro.Rn = 0x%x\n", inst.lsro.Rn);
bsp_printf("inst.lsro.L_bit = 0x%x\n", inst.lsro.L_bit);
bsp_printf("inst.lsro.W_bit = 0x%x\n", inst.lsro.W_bit);
bsp_printf("inst.lsro.B_bit = 0x%x\n", inst.lsro.B_bit);
bsp_printf("inst.lsro.U_bit = 0x%x\n", inst.lsro.U_bit);
bsp_printf("inst.lsro.P_bit = 0x%x\n", inst.lsro.P_bit);
bsp_printf("inst.lsro.rsv1 = 0x%x\n", inst.lsro.rsv1);
bsp_printf("inst.lsro.cond = 0x%x\n", inst.lsro.cond);
bsp_printf("operand = 0x%x\n", operand);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
 
handle_pc_load(inst.lsro.B_bit, operand);
}
}
 
 
/*
* Decode all load/store halfword/signed byte immediate offset instructions
*/
static void decode_lshwi_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* According to the ARM(R) Manual, if Rd is PC then
* the result is unpredictable. Don't do anything
* here. Just return.
*/
}
 
 
/*
* Decode all load/store halfword/signed byte register offset instructions
*/
static void decode_lshwr_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* According to the ARM(R) Manual, if Rd is PC then
* the result is unpredictable. Don't do anything
* here. Just return.
*/
}
 
 
/*
* Decode all swap/swap byte instructions
*/
static void decode_swap_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* According to the ARM(R) Manual, if Rd is PC then
* the result is unpredictable. Don't do anything
* here. Just return.
*/
}
 
 
/*
* Decode all load/store multiple instructions
*/
static void decode_lsm_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Only support direct load multiples where the PC is in the
* register list.
*
* According to the ARM(R) manual, automatic updates of the PC
* are UNPREDICTABLE (ie implementation defined).
*/
if ((inst.lsm.L_bit == LS_LOAD) && (inst.lsm.Reg_List & (0x1 << REG_PC)))
{
unsigned char *regs_array = (unsigned char *)regs;
unsigned char *Rn_ptr = &regs_array[bsp_regbyte(inst.lsm.Rn)];
unsigned long Rn_val = *((unsigned long *)(Rn_ptr));
unsigned long offset_to_pc = 0;
int i;
unsigned long **dest = 0;
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Decoded an load multiple instruction.\n");
bsp_printf("inst.lsm.Reg_List = 0x%x\n", inst.lsm.Reg_List);
 
bsp_printf("inst.lsm.Rn = 0x%x\n", inst.lsm.Rn);
bsp_printf("inst.lsm.L_bit = 0x%x\n", inst.lsm.L_bit);
bsp_printf("inst.lsm.W_bit = 0x%x\n", inst.lsm.W_bit);
bsp_printf("inst.lsm.S_bit = 0x%x\n", inst.lsm.S_bit);
bsp_printf("inst.lsm.U_bit = 0x%x\n", inst.lsm.U_bit);
bsp_printf("inst.lsm.P_bit = 0x%x\n", inst.lsm.P_bit);
bsp_printf("inst.lsm.rsv1 = 0x%x\n", inst.lsm.rsv1);
bsp_printf("inst.lsm.cond = 0x%x\n", inst.lsm.cond);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
 
if (inst.lsm.U_bit == 0)
{
/*
* We are using a ascending stack.
* That means the PC is actually the register
* nearest to Rn currently.
*/
if (inst.lsm.P_bit == 1)
/*
* Using a pre-decrement.
*/
offset_to_pc = -bsp_regsize(REG_PC);
else
offset_to_pc = 0;
} else {
/*
* We are using an descending stack.
* That means the PC is actually the register
* farthest from Rn currently.
*
* Find the number of registers stored before the PC
*/
for (i = 0; i < REG_PC; i++)
{
if ((inst.lsm.Reg_List & (0x1 << i)) != 0)
{
/*
* Bit #i is set. Increment our count.
*/
offset_to_pc += bsp_regsize(i);
}
}
 
/*
* Adjust the offset if we do a decrement/increment __BEFORE__
* the write.
*/
if (inst.lsm.P_bit == 1)
offset_to_pc += bsp_regsize(REG_PC);
}
 
/*
* Now let's calculate the real address of the stored PC
* making sure to mask out the two LO bits.
*/
dest = (unsigned long **)((Rn_val + offset_to_pc) & ~0x3);
 
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Rn_val = 0x%08lx\n", Rn_val);
bsp_printf("offset_to_pc = 0x%08lx\n", offset_to_pc);
bsp_printf("dest = 0x%08lx\n", dest);
bsp_printf("*dest = 0x%08lx\n", *dest);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
insert_ss_break(*dest);
}
}
 
 
/*
* Decode all coprocessor data processing instructions
*/
static void decode_cpdp_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Can't possibly predict what this instruction will do.
* Don't do anything here. Just return.
*/
}
 
 
/*
* Decode all coprocessor register transfer instructions
*/
static void decode_cprt_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Can't possibly predict what this instruction will do.
* Don't do anything here. Just return.
*/
}
 
 
/*
* Decode all coprocessor load/store instructions
*/
static void decode_cpls_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Can't possibly predict what this instruction will do.
* Don't do anything here. Just return.
*/
}
 
 
/*
* Decode all branch/branch w/ link instructions
*/
static void decode_bbl_inst(ex_regs_t *regs, union arm_insn inst)
{
unsigned long disp = inst.bbl.offset;
 
/*
* Sign extend the 24 bit value
*/
if (disp & 0x00800000)
disp |= 0xff000000;
/*
* Convert to long words
*/
disp <<= 2;
 
/*
* Note: when the processor actually executes this instruction, the pc
* will point to the address of the current instruction + 8 because
* of the fetch/decode/execute cycle
*/
disp += 8;
insert_ss_break((unsigned long *)(regs->_pc + disp));
}
 
 
/*
* Decode all swi instructions
*/
static void decode_swi_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Can't possibly predict where we should set the breakpoint for this.
* Don't do anything here. Just return.
*/
}
 
 
/*
* Decode all undefined instructions
*/
static void decode_undef_inst(ex_regs_t *regs, union arm_insn inst)
{
/*
* Can't possibly predict what this instruction will do.
* Don't do anything here. Just return.
*/
}
 
 
/*
* Set breakpoint instructions for single stepping.
*/
void
bsp_singlestep_setup(void *registers)
{
ex_regs_t *regs = (ex_regs_t *)registers;
union arm_insn inst;
 
if (bsp_memory_read((void*)(regs->_pc), 0, ARM_INST_SIZE * 8, 1, &(inst.word)) == 0)
{
/*
* Unable to read the instruction at the current address.
* Let's not do anything with this. We can't set breakpoints
* so let's get out now.
*/
return;
}
 
/*
* Handle the simple case -- linear code
*/
insert_ss_break((unsigned long *)(regs->_pc + ARM_INST_SIZE));
 
/*
* Now, we need to decode the instructions and figure out what
* they would do.
*/
if ((inst.mrs.rsv1 == MRS_RSV1_VALUE) &&
(inst.mrs.rsv2 == MRS_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("MRS type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_mrs_inst(regs, inst);
} else if ((inst.misr.rsv1 == MISR_RSV1_VALUE) &&
(inst.misr.rsv2 == MISR_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("MISR type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_misr_inst(regs, inst);
} else if ((inst.mrsr.rsv1 == MRSR_RSV1_VALUE) &&
(inst.mrsr.rsv2 == MRSR_RSV2_VALUE) &&
(inst.mrsr.rsv3 == MRSR_RSV3_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("MRSR type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_mrsr_inst(regs, inst);
} else if (inst.dpi.rsv1 == DPI_RSV1_VALUE) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("DPI type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_dpi_inst(regs, inst);
} else if ((inst.bx.rsv1 == BX_RSV1_VALUE) &&
(inst.bx.rsv2 == BX_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("BX type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_bx_inst(regs, inst);
} else if ((inst.dpis.rsv1 == DPIS_RSV1_VALUE) &&
(inst.dpis.rsv2 == DPIS_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("DPIS type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_dpis_inst(regs, inst);
} else if ((inst.dprs.rsv1 == DPRS_RSV1_VALUE) &&
(inst.dprs.rsv2 == DPRS_RSV2_VALUE) &&
(inst.dprs.rsv3 == DPRS_RSV3_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("DPRS type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_dprs_inst(regs, inst);
} else if ((inst.m.rsv1 == M_RSV1_VALUE) &&
(inst.m.rsv2 == M_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("M type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_m_inst(regs, inst);
} else if ((inst.ml.rsv1 == ML_RSV1_VALUE) &&
(inst.ml.rsv2 == ML_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("ML type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_ml_inst(regs, inst);
} else if (inst.lsio.rsv1 == LSIO_RSV1_VALUE) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("LSIO type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_lsio_inst(regs, inst);
} else if ((inst.lsro.rsv1 == LSRO_RSV1_VALUE) &&
(inst.lsro.rsv2 == LSRO_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("LSRO type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_lsro_inst(regs, inst);
} else if ((inst.lshwi.rsv1 == LSHWI_RSV1_VALUE) &&
(inst.lshwi.rsv2 == LSHWI_RSV2_VALUE) &&
(inst.lshwi.rsv3 == LSHWI_RSV3_VALUE) &&
(inst.lshwi.rsv4 == LSHWI_RSV4_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("LSHWI type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_lshwi_inst(regs, inst);
} else if ((inst.lshwr.rsv1 == LSHWR_RSV1_VALUE) &&
(inst.lshwr.rsv2 == LSHWR_RSV2_VALUE) &&
(inst.lshwr.rsv3 == LSHWR_RSV3_VALUE) &&
(inst.lshwr.rsv4 == LSHWR_RSV4_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("LSHWR type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_lshwr_inst(regs, inst);
} else if ((inst.swap.rsv1 == SWAP_RSV1_VALUE) &&
(inst.swap.rsv2 == SWAP_RSV2_VALUE) &&
(inst.swap.rsv3 == SWAP_RSV3_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("SWAP type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_swap_inst(regs, inst);
} else if (inst.lsm.rsv1 == LSM_RSV1_VALUE) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("LSM type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_lsm_inst(regs, inst);
} else if ((inst.cpdp.rsv1 == CPDP_RSV1_VALUE) &&
(inst.cpdp.rsv2 == CPDP_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("CPDP type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_cpdp_inst(regs, inst);
} else if ((inst.cprt.rsv1 == CPRT_RSV1_VALUE) &&
(inst.cprt.rsv2 == CPRT_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("CPRT type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_cprt_inst(regs, inst);
} else if (inst.cpls.rsv1 == CPLS_RSV1_VALUE) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("CPLS type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_cpls_inst(regs, inst);
} else if (inst.bbl.rsv1 == BBL_RSV1_VALUE) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("BBL type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_bbl_inst(regs, inst);
} else if (inst.swi.rsv1 == SWI_RSV1_VALUE) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("SWI type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_swi_inst(regs, inst);
} else if ((inst.undef.rsv1 == UNDEF_RSV1_VALUE) &&
(inst.undef.rsv2 == UNDEF_RSV2_VALUE)) {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("UNDEF type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
decode_undef_inst(regs, inst);
} else {
#if DEBUG_SINGLESTEP_VERBOSE
bsp_printf("Unknown instruction type: 0x%08lx\n", inst.word);
#endif /* DEBUG_SINGLESTEP_VERBOSE */
}
}
 
void
bsp_skip_instruction(void *registers)
{
ex_regs_t *regs = (ex_regs_t *)registers;
regs->_pc += ARM_INST_SIZE;
}
/misc/bsp/dbg-threads-api.h
0,0 → 1,148
#ifndef __BSP_DBG_THREADS_API_H__
#define __BSP_DBG_THREADS_API_H__
//==========================================================================
//
// dbg-threads-api.h
//
// <DESCRIPTION>
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description: These are the calls used to extract operating system
// specific information used in supporting thread aware
// debugging.
// The Operating Environment being debugged needs to supply
// these functions.
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#define has_thread_void 0
#define has_thread_current 1
#define has_thread_registers 2
#define has_thread_reg_change 4
#define has_thread_list 8
#define has_thread_info 16
 
typedef unsigned char threadref[8] ;
 
struct dbg_capabilities
{
unsigned long mask1;
};
 
/* fill in the list of thread aware capabilities */
extern int dbg_thread_capabilities(struct dbg_capabilities *cbp);
 
 
/* Fill in the identifier of the current thread */
/* return 1 if defined, 0 if not defined */
extern int dbg_currthread(threadref *varparm);
 
/* get the first or next member of the list of known threads */
extern int dbg_threadlist(int startflag,
threadref *lastthreadid,
threadref *next_thread);
 
/* return 1 if next_threadid has been filled in with a value */
/* return 0 if there are none or no more */
 
/* The O.S can fill in the following information about a thread when queried.
The structure of thise strings is determined by the O.S.
It is display oriented, so figure out what the users need to see.
Nulls are OK but GDB will fill some not so meaningful data.
These pointers may be in the calles private structures, the info will
get copied immediatly after the call to retreive it.
*/
struct cygmon_thread_debug_info
{
threadref thread_id ;
int context_exists ; /* To the point where examining its state,
registers and stack makes sense to GDB */
char * thread_display ; /* As shown in thread status window, name, state */
char * unique_thread_name ; /* human readable identifier, window label */
char * more_display ; /* more detailed info about thread.
priority, queuedepth, state, stack usage, statistics */
} ;
 
 
 
 
extern int dbg_threadinfo(threadref *threadid,
struct cygmon_thread_debug_info *info);
 
/* Return 1 if threadid is defined and info copied, 0 otherwise */
 
/* The O.S should fillin the array of registers using values from the
saves context. The array MUST be in GDB register save order even if
the saved context is different or smaller. Do not alter the values of
registers which are NOT in the O.S. thread context. Their default values
have already been assigned.
*/
 
extern int dbg_getthreadreg(threadref *osthreadid,
int regcount, /* count of registers in the array */
void * regval); /* fillin this array */
 
 
/* The O.S. should scan through this list of registers which are in
GDB order and the O.S. should replace the values of all registers
which are defined in the saved context of thread or process identified
by osthreadid. Return 0 if the threadis does not map to a known
process or other error. Return 1 if the setting is successful. */
 
extern int dbg_setthreadreg(threadref *osthreadid,
int regcount, /* number of registers */
void *regval) ;
 
 
extern int dbg_scheduler(threadref *thread_id, int lock, int mode);
 
/* --- EXCEPTION -
The O.S. does not provide this function , it calls this to specify the
location of the dbg_syscall vector
*/
extern void patch_dbg_syscalls(void * vector);
 
#endif /* DBG_THREADS_API_INCLUDED */
#endif // __BSP_DBG_THREADS_API_H__
/misc/bsp/defs.h
0,0 → 1,112
#ifndef __BSP_DEFS_H__
#define __BSP_DEFS_H__
//==========================================================================
//
// defs.h
//
// Definitions of interest to Red Hat BSP.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Definitions of interest to Red Hat BSP.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#define BIT0 0x00000001
#define BIT1 0x00000002
#define BIT2 0x00000004
#define BIT3 0x00000008
#define BIT4 0x00000010
#define BIT5 0x00000020
#define BIT6 0x00000040
#define BIT7 0x00000080
#define BIT8 0x00000100
#define BIT9 0x00000200
#define BIT10 0x00000400
#define BIT11 0x00000800
#define BIT12 0x00001000
#define BIT13 0x00002000
#define BIT14 0x00004000
#define BIT15 0x00008000
#define BIT16 0x00010000
#define BIT17 0x00020000
#define BIT18 0x00040000
#define BIT19 0x00080000
#define BIT20 0x00100000
#define BIT21 0x00200000
#define BIT22 0x00400000
#define BIT23 0x00800000
#define BIT24 0x01000000
#define BIT25 0x02000000
#define BIT26 0x04000000
#define BIT27 0x08000000
#define BIT28 0x10000000
#define BIT29 0x20000000
#define BIT30 0x40000000
#define BIT31 0x80000000
 
#define SZ_1K 0x00000400
#define SZ_2K 0x00000800
#define SZ_4K 0x00001000
#define SZ_8K 0x00002000
#define SZ_16K 0x00004000
#define SZ_32K 0x00008000
#define SZ_64K 0x00010000
#define SZ_128K 0x00020000
#define SZ_256K 0x00040000
#define SZ_512K 0x00080000
#define SZ_1M 0x00100000
#define SZ_2M 0x00200000
#define SZ_4M 0x00400000
#define SZ_8M 0x00800000
#define SZ_16M 0x01000000
#define SZ_32M 0x02000000
#define SZ_64M 0x04000000
#define SZ_128M 0x08000000
#define SZ_256M 0x10000000
#define SZ_512M 0x20000000
#define SZ_1G 0x40000000
 
#endif // __BSP_DEFS_H__
/misc/bsp/common/breakpoint.c
0,0 → 1,97
//==========================================================================
//
// breakpoint.c
//
// Breakpoint generation.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Breakpoint generation.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <bsp/cpu.h>
#include <bsp/bsp.h>
 
#ifndef DEBUG_BREAKPOINT
#define DEBUG_BREAKPOINT 0
#endif
 
#ifdef __ECOS__
#include <cyg/hal/hal_arch.h>
#endif /* __ECOS__ */
 
/*
* Trigger a breakpoint exception.
*/
void
bsp_breakpoint(void)
{
#if DEBUG_BREAKPOINT
bsp_printf("Before BP\n");
#endif
 
#ifdef __ECOS__
# ifdef __NEED_UNDERSCORE__
HAL_BREAKPOINT(_bsp_breakinsn);
# else
HAL_BREAKPOINT(bsp_breakinsn);
# endif
#else
# ifdef __NEED_UNDERSCORE__
asm volatile (".globl _bsp_breakinsn\n"
"_bsp_breakinsn:\n");
# else
asm volatile (".globl bsp_breakinsn\n"
"bsp_breakinsn:\n");
# endif
BREAKPOINT();
#endif
 
#if DEBUG_BREAKPOINT
bsp_printf("After BP\n");
#endif
}
 
/misc/bsp/common/gdb.h
0,0 → 1,103
#ifndef __BSP_COMMON_GDB_H__
#define __BSP_COMMON_GDB_H__
//==========================================================================
//
// gdb.h
//
// Definitions for GDB stub.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Definitions for GDB stub.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include "gdb-cpu.h"
#include <bsp/gdb-data.h>
 
#ifndef DEBUG_STUB
#define DEBUG_STUB 0
#endif
 
/*
* These need to match the same in devo/gdb/target.h
*/
#define TARGET_SIGNAL_INT 2
#define TARGET_SIGNAL_ILL 4
#define TARGET_SIGNAL_TRAP 5
#define TARGET_SIGNAL_ABRT 6
#define TARGET_SIGNAL_FPE 8
#define TARGET_SIGNAL_BUS 10
#define TARGET_SIGNAL_SEGV 11
 
 
/*
* Socket to use for tcp/ip debug channel.
*/
#define GDB_TCP_SOCKET 1000
 
 
#ifndef __ASSEMBLER__
 
/* generic gdb protocol handler */
extern void _bsp_gdb_handler(int exc_nr, void *saved_regs);
extern gdb_data_t _bsp_gdb_data;
 
 
/* start forming an outgoing gdb packet */
/* if ack is true, prepend an ack character */
extern void _gdb_pkt_start(int ack);
 
/* Append data to packet using formatted string. */
extern void _gdb_pkt_append(char *fmt, ...);
 
/* Calculate checksum and append to end of packet. */
extern void _gdb_pkt_end(void);
 
/* Send the packet. Blocks waiting for ACK */
extern void _gdb_pkt_send(void);
#endif
 
#endif //__BSP_COMMON_GDB_H__
/misc/bsp/common/bsp_if.c
0,0 → 1,160
//==========================================================================
//
// bsp_if.c
//
// Miscellaneous BSP Interfaces.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Miscellaneous BSP Interfaces.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <bsp/bsp.h>
#include "bsp_if.h"
 
/*
* Install a debug handler.
* Returns old handler being replaced.
*/
bsp_handler_t
bsp_install_dbg_handler(bsp_handler_t new_handler)
{
bsp_handler_t old_handler;
 
old_handler = *bsp_shared_data->__dbg_vector;
*bsp_shared_data->__dbg_vector = new_handler;
 
return old_handler;
}
 
/*
* Sometimes it is desireable to call the debug handler directly. This routine
* accomplishes that. It is the responsibility of the caller to insure that
* interrupts are disabled before calling this routine.
*/
void
bsp_invoke_dbg_handler(int exc_nr, void *regs)
{
(*bsp_shared_data->__dbg_vector)(exc_nr, regs);
}
 
/*
* Install a 'kill' handler.
* Returns old handler being replaced.
*/
bsp_handler_t
bsp_install_kill_handler(bsp_handler_t new_handler)
{
bsp_handler_t old_handler;
 
old_handler = bsp_shared_data->__kill_vector;
bsp_shared_data->__kill_vector = new_handler;
 
return old_handler;
}
 
 
void *
bsp_cpu_data(void)
{
return bsp_shared_data->__cpu_data;
}
 
 
void *
bsp_board_data(void)
{
return bsp_shared_data->__board_data;
}
 
 
int
bsp_sysinfo(enum bsp_info_id id, ...)
{
int retval;
va_list ap;
 
va_start (ap, id);
retval = bsp_shared_data->__sysinfo(id, ap);
va_end(ap);
return retval;
}
 
int
bsp_set_debug_comm(int id)
{
return bsp_shared_data->__set_debug_comm(id);
}
 
int
bsp_set_console_comm(int id)
{
return bsp_shared_data->__set_console_comm(id);
}
 
int
bsp_set_serial_baud(int id, int baud)
{
return bsp_shared_data->__set_serial_baud(id, baud);
}
 
 
#if !defined(NDEBUG)
 
void _bsp_assert(const char *file, const int line, const char *condition)
{
bsp_printf("Assertion \"%s\" failed\n", condition);
bsp_printf("File \"%s\"\n", file);
bsp_printf("Line %d\n", line);
#if defined(PORT_TOGGLE_DEBUG)
PORT_TOGGLE_DEBUG();
#else
while(1) ;
#endif /* defined(PORT_TOGGLE_DEBUG) */
}
 
#endif /* !defined(NDEBUG) */
 
/misc/bsp/common/printf.c
0,0 → 1,95
//==========================================================================
//
// printf.c
//
// Light-weight BSP printf.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Light-weight BSP printf.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <bsp/bsp.h>
#include "bsp_if.h"
 
 
void
bsp_vprintf(const char *fmt, va_list ap)
{
__vprintf(bsp_console_putc, fmt, ap);
}
 
 
void
bsp_dvprintf(const char *fmt, va_list ap)
{
__vprintf(bsp_debug_putc, fmt, ap);
}
 
 
void
bsp_printf(const char *fmt, ...)
{
va_list ap;
 
va_start (ap, fmt);
__vprintf(bsp_console_putc, fmt, ap);
va_end (ap);
}
 
 
void
bsp_dprintf(const char *fmt, ...)
{
va_list ap;
 
va_start (ap, fmt);
__vprintf(bsp_debug_putc, fmt, ap);
va_end (ap);
}
 
 
 
/misc/bsp/common/bsp_cache.c
0,0 → 1,70
//==========================================================================
//
// bsp_cache.c
//
// BSP Cache Interfaces.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: BSP Cache Interfaces.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include "bsp_if.h"
 
void
bsp_flush_dcache(void *p, int nbytes)
{
bsp_shared_data->__flush_dcache(p, nbytes);
}
 
 
void
bsp_flush_icache(void *p, int nbytes)
{
bsp_shared_data->__flush_icache(p, nbytes);
}
 
 
/misc/bsp/common/bsp_if.h
0,0 → 1,433
#ifndef __BSP_COMMON_BSP_IF_H__
#define __BSP_COMMON_BSP_IF_H__
//==========================================================================
//
// bsp_if.h
//
// BSP interface definitions.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: BSP interface definitions.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <bsp/bsp.h>
 
/*
* Maximum number of interrupt controllers supported by
* this bsp.
*/
#define BSP_MAX_IRQ_CONTROLLERS 8
 
#ifndef __ASSEMBLER__
 
 
/*
* Interrupt controller abstraction.
* Each interrupt controller on a given board should be described using
* this data structure.
*/
struct bsp_irq_controller {
/*
* First and last irqs handled by this controller.
*/
short first;
short last;
 
/*
* pointer to array of bsp_vec struct pointers. These are
* the heads of the linked list of ISRs for each irq handled
* by this controller.
*/
bsp_vec_t **vec_list;
 
/*
* Pointer to initialization routine which is run once at boot time.
*/
void (*init)(const struct bsp_irq_controller *__ic);
 
/*
* Pointer to routines used to disable and enable interrupts handled
* by this controller.
*/
int (*disable)(const struct bsp_irq_controller *__ic,
int __irq_nr);
void (*enable)(const struct bsp_irq_controller *__ic,
int __irq_nr);
};
 
 
/*
* Board specific code needs to provide at least one communication channel
* for use as the debug and console (stdio) channel. For each channel,
* there must be a set of function vectors for the common BSP code to
* control the channel.
*/
struct bsp_comm_procs {
/*
* Implementation dependent data pointer passed to the following procs.
*/
void *ch_data;
 
/*
* Write a buffer of the given length. All of buffer is sent before
* the write call returns.
*/
void (*__write)(void *ch_data, const char *buf, int len);
 
/*
* Fill a buffer with up to the given length. Returns the actual number
* of characters read.
*/
int (*__read)(void *ch_data, char *buf, int len);
 
/*
* Send a single character.
*/
void (*__putc)(void *ch_data, char ch);
 
/*
* Read a single character. If no character is immediately available, will
* block until one becomes available.
*/
int (*__getc)(void *ch_data);
 
/*
* Catchall comm port control.
*/
int (*__control)(void *ch_data, int func, ...);
 
/*
* For serial ports, the control function may be used to set and get the
* current baud rate. Usage:
*
* err = (*__control)(COMMCTL_SETBAUD, int bits_per_second);
* err => Zero if successful, -1 if error.
*
* baud = (*__control)(COMMCTL_GETBAUD);
* baud => -1 if error, current baud otherwise.
*/
#define COMMCTL_SETBAUD 0
#define COMMCTL_GETBAUD 1
 
/*
* Install and remove debugger interrupt handlers. These are the receiver
* interrupt routines which are used to change control from a running
* program to the debugger stub.
*/
#define COMMCTL_INSTALL_DBG_ISR 2
#define COMMCTL_REMOVE_DBG_ISR 3
 
/*
* Disable comm port interrupt. Returns TRUE if interrupt was enabled,
* FALSE otherwise.
*/
#define COMMCTL_IRQ_DISABLE 4
/*
* Enable comm port interrupt.
*/
#define COMMCTL_IRQ_ENABLE 5
};
 
 
/*
* The board specific code uses this data structure to provide information
* about and procedure vectors for each supported communication channel.
* See _bsp_comm_list below.
*/
struct bsp_comm_channel {
struct bsp_comm_info info;
struct bsp_comm_procs procs;
};
 
 
/*
* Number to place in the version field. If structure is changed
* in a way which is not backwards compatible, this number should
* be incremented.
*/
#define BSP_SHARED_DATA_VERSION 2
 
/*
* Clients of this BSP will need to have access to BSP functions and
* data structures. Because, the client and the BSP may not be linked
* together, a structure of vectors is used to gain this access. A
* pointer to this structure can be gotten via a syscall. This syscall
* is made automatically from within the crt0.o file.
*/
typedef struct {
int version; /* version number for future expansion */
 
/*
* Pointer to the array of pointers to interrupt controller descriptors.
*/
const struct bsp_irq_controller **__ictrl_table;
 
/*
* Pointer to the array of exception vectors.
*/
bsp_vec_t **__exc_table;
 
/*
* Pointer to debug handler vector.
*/
bsp_handler_t *__dbg_vector;
 
/*
* User hook to catch debugger 'kill' command.
*/
bsp_handler_t __kill_vector;
 
/*
* Vectored functions for console and debug i/o.
*/
struct bsp_comm_procs *__console_procs;
struct bsp_comm_procs *__debug_procs;
 
/*
* Vectored cache control functions.
*/
void (*__flush_dcache)(void *__p, int __nbytes);
void (*__flush_icache)(void *__p, int __nbytes);
 
/*
* Generic data pointers
*/
void *__cpu_data;
void *__board_data;
 
/*
* General BSP information access.
* See bsp.h for details.
*/
int (*__sysinfo)(enum bsp_info_id __id, va_list __ap);
 
/*
* Set or get active debug and console channels.
* Returns -1 if unsucessful.
* If the passed in __comm_id is -1, then the id of the current channel
* is returned.
*/
int (*__set_debug_comm)(int __comm_id);
int (*__set_console_comm)(int __comm_id);
 
/*
* Set or get the current baud rate of a serial comm channel.
* Returns -1 on if unsuccessful.
* If the given baud is -1, then the current baudrate is returned.
*/
int (*__set_serial_baud)(int __comm_id, int baud);
 
/*
* Debug agent data.
*/
void *__dbg_data;
 
/*
* Reset function
* We want to avoid calling this with a trap since
* we may be calling it from SWI mode (in cygmon).
* That is problematic, as nested SWI's are not
* very good.
*/
void (*__reset)(void);
 
/*
* TRUE if console interrupt detected during program output.
*/
int __console_interrupt_flag;
 
} bsp_shared_t;
 
 
extern bsp_shared_t *bsp_shared_data;
 
/*
* Platform info which may be overriden/modified by arch/board specific code.
*/
extern struct bsp_platform_info _bsp_platform_info;
 
/*
* Cache info which may be overriden/modified by arch/board specific code.
*/
extern struct bsp_cachesize_info _bsp_dcache_info;
extern struct bsp_cachesize_info _bsp_icache_info;
extern struct bsp_cachesize_info _bsp_scache_info;
 
/*
* Array of comm channel descriptors which must be provided by board specific
* code.
*/
extern struct bsp_comm_channel _bsp_comm_list[];
 
/*
* Number of comm channel descriptors which must be provided by board specific
* code.
*/
extern int _bsp_num_comms;
 
 
/*
* Array of memory region descriptors which must be provided by board specific
* code.
*/
extern struct bsp_mem_info _bsp_memory_list[];
 
/*
* Number of memory region descriptors which must be provided by board specific
* code.
*/
extern int _bsp_num_mem_regions;
 
/*
* In order to construct the above _bsp_memory_list, some board specific
* code may have to size RAM regions. To do this easily and reliably,
* the code needs to run from ROM before .bss and .data sections are
* initialized. This leads to the problem of where to store the results
* of the memory sizing tests. In this case, the _bsp_init_stack routine
* which sizes memory and sets up the stack will place the board-specific
* information on the stack and return with the stack pointer pointing to
* a pointer to the information. That is, addr_of_info = *(void **)sp.
* The architecture specific code will then copy that pointer to the
* _bsp_ram_info_ptr variable after initializing the .data and .bss sections.
*/
extern void *_bsp_ram_info_ptr;
 
/*
* Generic bsp initialization. Called by low level startup code
*/
extern void _bsp_init(void);
 
/*
* Initialize board communication in polling mode. This enables
* debugging printf for later initializations. Interrupts for
* comm channels may be set up later in _bsp_board_init().
*/
extern void _bsp_init_board_comm(void);
 
/*
* Make generic BSP aware of CPU/MCU specific interrupt controllers.
*/
extern void _bsp_install_cpu_irq_controllers(void);
 
/*
* Make generic BSP aware of board specific interrupt controllers.
*/
extern void _bsp_install_board_irq_controllers(void);
 
/*
* Callback used by above two routines to install a single
* interrupt controller.
*/
extern void _bsp_install_irq_controller(const struct bsp_irq_controller *__ic);
 
/*
* Generic exception dispatch routine. Usually called from asm-level
* exception handler to call vectors in vector chain for the given
* exception number. Stops traversing vector chain when a called
* vector returns a non-zero value. If no vector returns non-zero,
* a default error message and register dump is printed.
*/
extern int _bsp_exc_dispatch(int __exc_number, void *__regs);
 
 
/*
* Architecture specific routine to dump register values.
*/
extern void _bsp_dump_regs(void *__regs);
 
 
/*
* Generic syscall handler called by architecture specific handler.
* Returns non-zero if given 'func' number was handled by the generic
* code, zero otherwise. If handled, the syscall error is returned
* via the err_ptr.
*/
extern int _bsp_do_syscall(int __func,
long __arg1, long __arg2, long __arg3, long __arg4,
int *__err_ptr);
 
 
extern void _bsp_cpu_init(void);
extern void _bsp_board_init(void);
 
 
/*
* General interface for getting certain BSP parameters.
* See bsp.h for details.
*/
extern int _bsp_sysinfo(enum bsp_info_id __id, va_list __ap);
 
/*
* Called from comm channel when a connection to host is closed.
*/
extern void _bsp_dbg_connect_abort(void);
 
/*
* Pointer to a network channel. NULL if no network channel
* exists.
*/
extern struct bsp_comm_channel *_bsp_net_channel;
 
 
/*
* Formatted output primitive.
*/
extern void __vprintf(void (*putc_func)(char c), const char *fmt0, va_list ap);
 
 
 
#endif /* !__ASSEMBLER__ */
 
/*
* SYSCALL number to use to get pointer to above bsp_shared_t structure.
*/
#define BSP_GET_SHARED 0xbaad
 
#endif // __BSP_COMMON_BSP_IF_H__
 
 
/misc/bsp/common/console-io.c
0,0 → 1,140
//==========================================================================
//
// console-io.c
//
// BSP Console Channel Interfaces.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: BSP Console Channel Interfaces.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <stdlib.h>
#include <bsp/bsp.h>
#include "bsp_if.h"
 
static unsigned char __console_ungetc;
 
void
bsp_console_write(const char *p, int len)
{
struct bsp_comm_procs *com;
 
if ((com = bsp_shared_data->__console_procs) != NULL)
com->__write(com->ch_data, p, len);
else
bsp_debug_write(p, len);
}
 
 
int
bsp_console_read(char *p, int len)
{
struct bsp_comm_procs *com;
 
if (len <= 0)
return 0;
 
if ((com = bsp_shared_data->__console_procs) != NULL) {
if (__console_ungetc) {
*p = __console_ungetc;
__console_ungetc = 0;
return 1;
}
return com->__read(com->ch_data, p, len);
} else
return bsp_debug_read(p, len);
}
 
/*#define PRINTABLE_ONLY*/
#ifdef PRINTABLE_ONLY
#include <ctype.h>
#endif /* PRINTABLE_ONLY */
 
void
bsp_console_putc(char ch)
{
struct bsp_comm_procs *com;
 
#ifdef PRINTABLE_ONLY
if ((!isprint(ch)) && (!isspace(ch)))
ch = '.';
#endif /* PRINTABLE_ONLY */
 
if ((com = bsp_shared_data->__console_procs) != NULL)
com->__putc(com->ch_data, ch);
else
bsp_debug_putc(ch);
}
 
int
bsp_console_getc(void)
{
struct bsp_comm_procs *com;
int ch;
 
if ((com = bsp_shared_data->__console_procs) != NULL) {
if (__console_ungetc) {
ch = __console_ungetc;
__console_ungetc = 0;
return ch;
}
return com->__getc(com->ch_data);
} else
return bsp_debug_getc();
}
 
 
void
bsp_console_ungetc(char ch)
{
if (bsp_shared_data->__console_procs != NULL)
__console_ungetc = (unsigned char)ch;
else
bsp_debug_ungetc(ch);
}
 
 
/misc/bsp/common/syscall.c
0,0 → 1,218
//==========================================================================
//
// syscall.c
//
// Minimal generic syscall support.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Minimal generic syscall support.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include <errno.h>
#include <bsp/cpu.h>
#include <bsp/bsp.h>
#include "bsp_if.h"
#include "syscall.h"
 
/*
* read -- read bytes from the serial port. Ignore fd, since
* we only have stdin.
*/
static int
sys_read(int fd, char *buf, int nbytes)
{
int i = 0;
 
for (i = 0; i < nbytes; i++) {
*(buf + i) = bsp_console_getc();
if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
(*(buf + i + 1)) = 0;
break;
}
}
return (i);
}
 
 
/*
* write -- write bytes to the serial port. Ignore fd, since
* stdout and stderr are the same. Since we have no filesystem,
* open will only return an error.
*/
static int
sys_write(int fd, char *buf, int nbytes)
{
#define WBUFSIZE 256
char ch, lbuf[WBUFSIZE];
int i, tosend;
 
tosend = nbytes;
 
while (tosend > 0) {
for (i = 0; tosend > 0 && i < (WBUFSIZE-2); tosend--) {
ch = *buf++;
if (ch == '\n')
lbuf[i++] = '\r';
lbuf[i++] = ch;
}
bsp_console_write(lbuf, i);
}
 
return (nbytes);
}
 
 
/*
* open -- open a file descriptor. We don't have a filesystem, so
* we return an error.
*/
static int
sys_open (const char *buf, int flags, int mode)
{
return (-EIO);
}
 
 
/*
* close -- We don't need to do anything, but pretend we did.
*/
static int
sys_close(int fd)
{
return (0);
}
 
 
/*
* lseek -- Since a serial port is non-seekable, we return an error.
*/
static int
sys_lseek(int fd, int offset, int whence)
{
#ifdef ESPIPE
return (-ESPIPE);
#else
return (-EIO);
#endif
}
 
 
/*
* Generic syscall handler.
*
* Returns 0 if syscall number is not handled by this
* module, 1 otherwise. This allows applications to
* extend the syscall handler by using exception chaining.
*/
int
_bsp_do_syscall(int func, /* syscall function number */
long arg1, long arg2, /* up to four args. */
long arg3, long arg4,
int *retval) /* syscall return value */
{
int err = 0;
 
switch (func) {
 
case SYS_read:
err = sys_read((int)arg1, (char *)arg2, (int)arg3);
break;
 
case SYS_write:
err = sys_write((int)arg1, (char *)arg2, (int)arg3);
break;
 
case SYS_open:
err = sys_open((const char *)arg1, (int)arg2, (int)arg3);
break;
 
case SYS_close:
err = sys_close((int)arg1);
break;
 
case SYS_lseek:
err = sys_lseek((int)arg1, (int)arg2, (int)arg3);
break;
 
case BSP_GET_SHARED:
*(bsp_shared_t **)arg1 = bsp_shared_data;
break;
 
case SYS_meminfo:
{
// Return the top and size of memory.
struct bsp_mem_info mem;
int i;
unsigned long u, totmem, topmem, numbanks;
 
i = totmem = topmem = numbanks = 0;
while (bsp_sysinfo(BSP_INFO_MEMORY, i++, &mem) == 0)
{
if (mem.kind == BSP_MEM_RAM)
{
numbanks++;
totmem += mem.nbytes;
u = (unsigned long)mem.virt_start + mem.nbytes;
if (u > topmem)
topmem = u;
}
}
*(unsigned long *)arg1 = totmem;
*(unsigned long *)arg2 = topmem;
*retval = numbanks;
}
return 1;
break;
 
default:
return 0;
}
 
*retval = err;
return 1;
}
 
 
/misc/bsp/common/shared-data.c
0,0 → 1,59
//==========================================================================
//
// shared-data.c
//
// Declaration of bsp shared data pointer.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Declaration of bsp shared data pointer.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include "bsp_if.h"
 
bsp_shared_t *bsp_shared_data;
 
 
/misc/bsp/common/singlestep.c
0,0 → 1,61
//==========================================================================
//
// singlestep.c
//
// Architecture specific single-step support
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
#include <pkgconf/system.h>
 
#ifdef CYGPKG_HAL_ARM
#include "bsp/arm/singlestep.c"
#endif
 
#ifdef CYGPKG_HAL_MIPS
#include "bsp/mips/singlestep.c"
#endif
/misc/bsp/common/syscall.h
0,0 → 1,50
/* General use syscall.h file.
The more ports that use this file, the simpler sim/common/nltvals.def
remains. */
 
#ifndef LIBGLOSS_SYSCALL_H
#define LIBGLOSS_SYSCALL_H
 
/* Note: This file may be included by assembler source. */
 
/* These should be as small as possible to allow a port to use a trap type
instruction, which the system call # as the trap (the d10v for instance
supports traps 0..31). An alternative would be to define one trap for doing
system calls, and put the system call number in a register that is not used
for the normal calling sequence (so that you don't have to shift down the
arguments to add the system call number). Obviously, if these system call
numbers are ever changed, all of the simulators and potentially user code
will need to be updated. */
 
/* There is no current need for the following: SYS_execv, SYS_creat, SYS_wait,
etc. etc. Don't add them. */
 
/* These are required by the ANSI C part of newlib (excluding system() of
course). */
#define SYS_exit 1
#define SYS_open 2
#define SYS_close 3
#define SYS_read 4
#define SYS_write 5
#define SYS_lseek 6
#define SYS_unlink 7
#define SYS_getpid 8
#define SYS_kill 9
#define SYS_fstat 10
/*#define SYS_sbrk 11 - not currently a system call, but reserved. */
 
/* ARGV support. */
#define SYS_argvlen 12
#define SYS_argv 13
 
/* These are extras added for one reason or another. */
#define SYS_chdir 14
#define SYS_stat 15
#define SYS_chmod 16
#define SYS_utime 17
#define SYS_time 18
 
#define SYS_interrupt 1000
 
#define SYS_meminfo 1001
#endif
/misc/bsp/common/gdb-cpu.c
0,0 → 1,61
//==========================================================================
//
// gdb-cpu.c
//
// Architecture specific support for GDB
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
#include <pkgconf/system.h>
 
#ifdef CYGPKG_HAL_ARM
#include "bsp/arm/gdb-cpu.c"
#endif
 
#ifdef CYGPKG_HAL_MIPS
#include "bsp/mips/gdb-cpu.c"
#endif
/misc/bsp/common/hex-utils.c
0,0 → 1,126
//==========================================================================
//
// hex-utils.c
//
// Utilities for dealing with hexadecimal strings.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <bsp/hex-utils.h>
 
int
__hex(char ch)
{
if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10);
if ((ch >= '0') && (ch <= '9')) return (ch-'0');
if ((ch >= 'A') && (ch <= 'F')) return (ch-'A'+10);
return (-1);
}
 
 
/*
* Convert the hex data in 'buf' into 'count' bytes to be placed in 'mem'.
* Returns a pointer to the character in mem AFTER the last byte written.
*/
char *
__unpack_bytes_to_mem(char *buf, char *mem, int count)
{
int i;
char ch;
 
for (i = 0; i < count; i++) {
ch = __hex(*buf++) << 4;
ch = ch + __hex(*buf++);
*mem++ = ch;
}
return(mem);
}
 
/*
* While finding valid hex chars, build an unsigned long int.
* Return number of hex chars processed.
*/
int
__unpack_ulong(char **ptr, unsigned long *val)
{
int numChars = 0;
int hexValue;
*val = 0;
 
while (**ptr) {
hexValue = __hex(**ptr);
if (hexValue >= 0) {
*val = (*val << 4) | hexValue;
numChars ++;
} else
break;
(*ptr)++;
}
return (numChars);
}
 
 
/*
* Unpack 'count' hex characters, forming them into a binary value.
* Return that value as an int. Adjust the source pointer accordingly.
*/
int
__unpack_nibbles(char **ptr, int count)
{
int value = 0;
 
while (--count >= 0) {
value = (value << 4) | __hex(**ptr);
(*ptr)++;
}
return value;
}
 
 
/misc/bsp/common/bsp.c
0,0 → 1,341
//==========================================================================
//
// bsp.c
//
// General BSP support.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: General BSP support.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <stdlib.h>
#include <bsp/cpu.h>
#include <bsp/bsp.h>
#include "bsp_if.h"
#include "gdb.h"
 
#ifndef DEBUG_BSP_INIT
#define DEBUG_BSP_INIT 0
#endif
 
struct bsp_comm_channel *_bsp_net_channel = NULL;
 
/*
* This is the array of pointers to interrupt controller descriptors.
*/
static struct bsp_irq_controller *_bsp_ictrl_table[BSP_MAX_IRQ_CONTROLLERS];
 
/*
* This is the array of second-level exception vectors.
*/
static bsp_vec_t *_bsp_exc_table[BSP_MAX_EXCEPTIONS];
 
 
/*
* Debug (default exception) handler vector.
*/
bsp_handler_t _bsp_dbg_vector;
 
 
static bsp_shared_t __bsp_shared = {
BSP_SHARED_DATA_VERSION, /* version */
(const struct bsp_irq_controller **)&_bsp_ictrl_table[0], /* __ictrl_table */
&_bsp_exc_table[0], /* __exc_table */
&_bsp_dbg_vector, /* __dbg_vector */
(bsp_handler_t)0, /* __kill_vector */
(struct bsp_comm_procs *)NULL, /* __console_procs */
(struct bsp_comm_procs *)NULL, /* __debug_procs */
(void (*)(void *, int ))NULL, /* __flush_dcache */
(void (*)(void *, int ))NULL, /* __flush_icache */
(void (*)(void ))NULL, /* __reset */
(void*)NULL, /* __cpu_data */
(void*)NULL /* __board_data */
};
 
 
static void
default_cache_proc(void *p, int nbytes)
{
/* do nothing */
}
 
 
static void
default_reset_proc(void)
{
/* do nothing */
}
 
 
static int
find_comm_id(struct bsp_comm_procs *procs)
{
int i;
 
for (i = 0; i < _bsp_num_comms; i++)
if (&_bsp_comm_list[i].procs == procs)
return i;
 
if (procs == &_bsp_net_channel->procs)
return _bsp_num_comms;
 
return -1;
}
 
 
/*
* Set or get active debug channel.
* Returns -1 if unsucessful.
* If the passed in comm id is -1, then the id of the current channel
* is returned.
*/
static int
set_debug_comm(int id)
{
struct bsp_comm_channel *chan;
struct bsp_comm_procs *procs;
int current_chan = find_comm_id(bsp_shared_data->__debug_procs);
 
if (id < 0)
return current_chan;
 
if (id > _bsp_num_comms)
return -1;
 
if (id == _bsp_num_comms && _bsp_net_channel == NULL)
return -1;
 
if (id == current_chan)
return 0;
 
/* Remove existing channel */
if ((procs = bsp_shared_data->__debug_procs) != NULL)
(*procs->__control)(procs->ch_data, COMMCTL_REMOVE_DBG_ISR);
/* Install new channel */
if (id == _bsp_num_comms)
chan = _bsp_net_channel;
else
chan = &_bsp_comm_list[id];
bsp_shared_data->__debug_procs = &chan->procs;
(*chan->procs.__control)(chan->procs.ch_data, COMMCTL_INSTALL_DBG_ISR);
 
return 0;
}
 
 
/*
* Set or get active console channel.
* Returns -1 if unsucessful.
* If the passed in comm id is -1, then the id of the current channel
* is returned.
*/
static int
set_console_comm(int id)
{
int current_chan = find_comm_id(bsp_shared_data->__console_procs);
 
if (id < 0)
return current_chan;
 
if (id > _bsp_num_comms)
return -1;
 
if (id == _bsp_num_comms && _bsp_net_channel == NULL)
return -1;
 
if (id == current_chan)
return 0;
 
/*
* Install new channel. If its the same as the debug channel,
* just clear the __console_procs and the bsp_console_*
* interface functions will take care of the rest.
*/
if (id == _bsp_num_comms)
bsp_shared_data->__console_procs = &_bsp_net_channel->procs;
else
bsp_shared_data->__console_procs = &_bsp_comm_list[id].procs;
 
if (bsp_shared_data->__console_procs == bsp_shared_data->__debug_procs)
bsp_shared_data->__console_procs = NULL;
 
return 0;
}
 
 
/*
* Set or get the current baud rate of a serial comm channel.
* Returns -1 on if unsuccessful.
* If the given baud is -1, then the current baudrate is returned.
*/
int
set_serial_baud(int id, int baud)
{
struct bsp_comm_channel *chan;
 
if (id < 0 || id >= _bsp_num_comms)
return -1;
 
chan = &_bsp_comm_list[id];
 
if (chan->info.kind != BSP_COMM_SERIAL)
return -1;
 
if (baud == -1)
return (*chan->procs.__control)(chan->procs.ch_data,
COMMCTL_GETBAUD);
 
return (*chan->procs.__control)(chan->procs.ch_data,
COMMCTL_SETBAUD, baud);
}
 
/*
* Final initialization before calling main.
*/
void
_bsp_init(void)
{
struct bsp_comm_procs *com;
extern void __init_irq_controllers(void);
 
bsp_shared_data = &__bsp_shared;
_bsp_dbg_vector = (bsp_handler_t)_bsp_gdb_handler;
bsp_shared_data->__dbg_data = &_bsp_gdb_data;
 
bsp_shared_data->__flush_dcache = default_cache_proc;
bsp_shared_data->__flush_icache = default_cache_proc;
 
bsp_shared_data->__reset = default_reset_proc;
 
/*
* General BSP information access.
*/
bsp_shared_data->__sysinfo = _bsp_sysinfo;
 
/*
* Setup comm port handlers.
*/
bsp_shared_data->__set_debug_comm = set_debug_comm;
bsp_shared_data->__set_console_comm = set_console_comm;
bsp_shared_data->__set_serial_baud = set_serial_baud;
 
/*
* Very first thing is to initialize comm channels so
* we can have debug printfs working. None of this
* must rely on interrupts until interrupt controllers
* are initialized below.
*/
_bsp_init_board_comm();
 
/*
* Assume first comm channel is the default.
*/
bsp_shared_data->__debug_procs = &_bsp_comm_list[0].procs;
 
/*
* By default, console i/o goes through the debug channel.
* We indicate this by making the console i/o procs
* pointer NULL.
*/
bsp_shared_data->__console_procs = NULL;
 
/*
* Install interrupt controllers.
*/
#if DEBUG_BSP_INIT
bsp_printf("Installing interrupt controllers...\n");
#endif
 
_bsp_install_cpu_irq_controllers();
_bsp_install_board_irq_controllers();
 
#if DEBUG_BSP_INIT
bsp_printf("Done installing interrupt controllers.\n");
bsp_printf("Initializing interrupt controllers...\n");
#endif
/*
* Actually run the init routines for all installed
* interrupt controllers.
*/
__init_irq_controllers();
 
#if DEBUG_BSP_INIT
bsp_printf("Done initializing interrupt controllers.\n");
bsp_printf("CPU-specific initialization...\n");
#endif
 
/*
* Final architecture specific initialization.
*/
_bsp_cpu_init();
 
#if DEBUG_BSP_INIT
bsp_printf("Done w/ CPU-specific initialization.\n");
bsp_printf("Board specific initialization...\n");
#endif
/*
* Final board specific initialization.
*/
_bsp_board_init();
 
#if DEBUG_BSP_INIT
bsp_printf("Done w/ board specific initialization.\n");
#endif
 
/*
* Now we can install the debug interrupt handler on the debug channel.
*/
com = bsp_shared_data->__debug_procs;
(*com->__control)(com->ch_data, COMMCTL_INSTALL_DBG_ISR);
 
 
if (_bsp_net_channel != NULL) {
set_debug_comm(_bsp_num_comms);
set_console_comm(0);
}
}
/misc/bsp/common/sprintf.c
0,0 → 1,86
//==========================================================================
//
// sprintf.c
//
// Light-weight BSP sprintf.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Light-weight BSP sprintf.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <bsp/bsp.h>
#include "bsp_if.h"
 
static char *str_ptr;
 
static void
str_putc(char ch)
{
*str_ptr++ = ch;
}
 
int
bsp_vsprintf(char *str, const char *fmt, va_list ap)
{
str_ptr = str;
__vprintf(str_putc, fmt, ap);
*str_ptr = '\0';
return str_ptr - str;
}
 
 
void
bsp_sprintf(char *str, const char *fmt, ...)
{
va_list ap;
 
va_start (ap, fmt);
bsp_vsprintf(str, fmt, ap);
va_end (ap);
}
 
 
/misc/bsp/common/gdb-cpu.h
0,0 → 1,65
#ifndef __BSP_COMMON_GDB_CPU_H__
#define __BSP_COMMON_GDB_CPU_H__
//==========================================================================
//
// gdb-cpu.h
//
// CPU specifics for GDB
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
#include <pkgconf/system.h>
 
#ifdef CYGPKG_HAL_ARM
#include "../arm/gdb-cpu.h"
#endif
 
#ifdef CYGPKG_HAL_MIPS
#include "../mips/gdb-cpu.h"
#endif
 
#endif // __BSP_COMMON_GDB_CPU_H__
/misc/bsp/common/generic-mem.c
0,0 → 1,194
//==========================================================================
//
// generic-mem.c
//
// Generic support for safe memory read/write.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Generic support for safe memory read/write.
// Description: Some targets may need to provide their own version.
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include <stdlib.h>
#include <setjmp.h>
#include <bsp/bsp.h>
 
typedef void (*moveproc_t)(void *s, void *d);
 
static jmp_buf __errjmp;
 
/*
* These are globals because we want them preserved
* across function calls.
*/
static bsp_handler_t __oldtrap;
static int __done;
 
 
static void
move_8(void *src, void *dest)
{
*(char *)dest = *(char *)src;
}
 
 
static void
move_16(void *src, void *dest)
{
*(short *)dest = *(short *)src;
}
 
 
static void
move_32(void *src, void *dest)
{
*(int *)dest = *(int *)src;
}
 
 
static int
err_trap(int exc_nr, void *regs)
{
longjmp(__errjmp, 1);
}
 
 
int
bsp_memory_read(void *addr, /* start addr of memory to read */
int asid, /* address space id */
int rsize, /* size of individual read operation */
int nreads, /* number of read operations */
void *buf) /* result buffer */
{
if (nreads <= 0)
return 0;
 
__oldtrap = bsp_install_dbg_handler(err_trap);
if (setjmp(__errjmp) == 0) {
moveproc_t move_mem;
int incr;
char *src, *dest;
 
switch (rsize) {
case 8:
move_mem = move_8;
incr = 1;
break;
case 16:
move_mem = move_16;
incr = 2;
break;
case 32:
move_mem = move_32;
incr = 4;
break;
default:
(void)bsp_install_dbg_handler(__oldtrap);
return 0;
}
 
src = addr;
dest = buf;
 
for (__done = 0; __done < nreads; __done++) {
move_mem(src, dest);
src += incr;
dest += incr;
}
}
 
(void)bsp_install_dbg_handler(__oldtrap);
return __done;
}
 
 
int bsp_memory_write(void *addr, /* start addr of memory to write */
int asid, /* address space id */
int wsize, /* size of individual write operation */
int nwrites, /* number of write operations */
void *buf) /* source buffer for write data */
{
if (nwrites <= 0)
return 0;
 
__oldtrap = bsp_install_dbg_handler(err_trap);
if (setjmp(__errjmp) == 0) {
moveproc_t move_mem;
int incr;
char *src, *dest;
 
switch (wsize) {
case 8:
move_mem = move_8;
incr = 1;
break;
case 16:
move_mem = move_16;
incr = 2;
break;
case 32:
move_mem = move_32;
incr = 4;
break;
default:
(void)bsp_install_dbg_handler(__oldtrap);
return 0;
}
 
src = buf;
dest = addr;
 
for (__done = 0; __done < nwrites; __done++) {
move_mem(src, dest);
src += incr;
dest += incr;
}
}
 
(void)bsp_install_dbg_handler(__oldtrap);
return __done;
}
/misc/bsp/common/vprintf.c
0,0 → 1,445
//==========================================================================
//
// vprintf.c
//
// Stripped down (no floating point) for debugging printf in ROMable BSP.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
/*
* Copyright (c) 1990, 1999 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
 
/*
* Stripped down (no floating point) for debugging printf in ROMable BSP.
*/
#include <string.h>
#include <stdarg.h>
 
#define BUF 40
 
#ifndef NULL
#define NULL ((void *)0)
#endif
 
/*
* Macros for converting digits to letters and vice versa
*/
#define to_digit(c) ((c) - '0')
#define is_digit(c) ((unsigned)to_digit(c) <= 9)
#define to_char(n) ((n) + '0')
 
/*
* Flags used during conversion.
*/
#define ALT 0x001 /* alternate form */
#define HEXPREFIX 0x002 /* add 0x or 0X prefix */
#define LADJUST 0x004 /* left adjustment */
#define LONGDBL 0x008 /* long double; unimplemented */
#define LONGINT 0x010 /* long integer */
#define QUADINT 0x020 /* quad integer */
#define SHORTINT 0x040 /* short integer */
#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
#define FPT 0x100 /* Floating point number */
 
 
void
__vprintf(void (*putc_func)(char c), const char *fmt0, va_list ap)
{
char *fmt; /* format string */
int ch; /* character from fmt */
int n, m; /* handy integers (short term usage) */
char *cp; /* handy char pointer (short term usage) */
int flags; /* flags as above */
int width; /* width from format (%8d), or 0 */
int prec; /* precision from format (%.3d), or -1 */
char sign; /* sign prefix (' ', '+', '-', or \0) */
unsigned long _uquad;
enum {OCT, DEC, HEX} base; /* base for [diouxX] conversion */
int dprec; /* a copy of prec if [diouxX], 0 otherwise */
int realsz; /* field size expanded by dprec */
int size; /* size of converted field or string */
char *xdigs = NULL; /* digits for [xX] conversion */
char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
char ox[2]; /* space for 0x hex-prefix */
 
#define PRINT(ptr, len) { \
for(n=0;n<(len);n++) { \
if((ptr)[n] == '\n') \
(*putc_func)('\r'); \
(*putc_func)((ptr)[n]); \
} \
}
 
#define PAD(howmany, with) { \
if ((n = (howmany)) > 0) { \
while (n--) \
(*putc_func)(with); \
} \
}
 
/*
* To extend shorts properly, we need both signed and unsigned
* argument extraction methods.
*/
#define SARG() \
(flags&LONGINT ? va_arg(ap, long) : \
flags&SHORTINT ? (long)(short)va_arg(ap, int) : \
(long)va_arg(ap, int))
 
#define UARG() \
(flags&LONGINT ? va_arg(ap, unsigned long) : \
flags&SHORTINT ? (unsigned long)(unsigned short)va_arg(ap, int) : \
(unsigned long)va_arg(ap, unsigned int))
 
fmt = (char *)fmt0;
 
/*
* Scan the format for conversions (`%' character).
*/
for (;;) {
cp = fmt;
while (*fmt && *fmt != '%')
fmt++;
if ((m = fmt - cp) != 0) {
PRINT(cp, m);
}
 
if (*fmt)
fmt++; /* skip over '%' */
else
goto done;
 
flags = 0;
dprec = 0;
width = 0;
prec = -1;
sign = '\0';
 
rflag:
ch = *fmt++;
reswitch:
switch (ch) {
case ' ':
/*
* ``If the space and + flags both appear, the space
* flag will be ignored.''
* -- ANSI X3J11
*/
if (!sign)
sign = ' ';
goto rflag;
case '#':
flags |= ALT;
goto rflag;
case '*':
/*
* ``A negative field width argument is taken as a
* - flag followed by a positive field width.''
* -- ANSI X3J11
* They don't exclude field widths read from args.
*/
if ((width = va_arg(ap, int)) >= 0)
goto rflag;
width = -width;
/* FALLTHROUGH */
case '-':
flags |= LADJUST;
goto rflag;
case '+':
sign = '+';
goto rflag;
case '.':
if ((ch = *fmt++) == '*') {
n = va_arg(ap, int);
prec = n < 0 ? -1 : n;
goto rflag;
}
n = 0;
while (is_digit(ch)) {
n = 10 * n + to_digit(ch);
ch = *fmt++;
}
prec = n < 0 ? -1 : n;
goto reswitch;
case '0':
/*
* ``Note that 0 is taken as a flag, not as the
* beginning of a field width.''
* -- ANSI X3J11
*/
flags |= ZEROPAD;
goto rflag;
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
n = 0;
do {
n = 10 * n + to_digit(ch);
ch = *fmt++;
} while (is_digit(ch));
width = n;
goto reswitch;
case 'h':
flags |= SHORTINT;
goto rflag;
case 'l':
if (*fmt == 'l') {
fmt++;
flags |= QUADINT;
} else {
flags |= LONGINT;
}
goto rflag;
case 'c':
*(cp = buf) = va_arg(ap, int);
size = 1;
sign = '\0';
break;
case 'd':
case 'i':
_uquad = SARG();
if ((long) _uquad < 0)
{
 
_uquad = -_uquad;
sign = '-';
}
base = DEC;
goto number;
case 'o':
_uquad = UARG();
base = OCT;
goto nosign;
case 's':
if ((cp = va_arg(ap, char *)) == NULL)
cp = "(null)";
if (prec >= 0) {
/*
* can't use strlen; can only look for the
* NUL in the first `prec' characters, and
* strlen() will go further.
*/
char *p = memchr(cp, 0, prec);
 
if (p != NULL) {
size = p - cp;
if (size > prec)
size = prec;
} else
size = prec;
} else
size = strlen(cp);
sign = '\0';
break;
case 'u':
_uquad = UARG();
base = DEC;
goto nosign;
case 'X':
xdigs = "0123456789ABCDEF";
goto hex;
case 'x':
xdigs = "0123456789abcdef";
hex: _uquad = UARG();
base = HEX;
/* leading 0x/X only if non-zero */
if (flags & ALT && _uquad != 0)
flags |= HEXPREFIX;
 
/* unsigned conversions */
nosign: sign = '\0';
/*
* ``... diouXx conversions ... if a precision is
* specified, the 0 flag will be ignored.''
* -- ANSI X3J11
*/
number: if ((dprec = prec) >= 0)
flags &= ~ZEROPAD;
 
/*
* ``The result of converting a zero value with an
* explicit precision of zero is no characters.''
* -- ANSI X3J11
*/
cp = buf + BUF;
if (_uquad != 0 || prec != 0) {
/*
* Unsigned mod is hard, and unsigned mod
* by a constant is easier than that by
* a variable; hence this switch.
*/
switch (base) {
case OCT:
do {
*--cp = to_char(_uquad & 7);
_uquad >>= 3;
} while (_uquad);
/* handle octal leading 0 */
if (flags & ALT && *cp != '0')
*--cp = '0';
break;
 
case DEC:
/* many numbers are 1 digit */
while (_uquad >= 10) {
*--cp = to_char(_uquad % 10);
_uquad /= 10;
}
*--cp = to_char(_uquad);
break;
 
case HEX:
do {
*--cp = xdigs[_uquad & 15];
_uquad >>= 4;
} while (_uquad);
break;
 
default:
cp = "bug in vfprintf: bad base";
size = strlen(cp);
goto skipsize;
}
}
size = buf + BUF - cp;
skipsize:
break;
default: /* "%?" prints ?, unless ? is NUL */
if (ch == '\0')
goto done;
/* pretend it was %c with argument ch */
cp = buf;
*cp = ch;
size = 1;
sign = '\0';
break;
}
 
/*
* All reasonable formats wind up here. At this point, `cp'
* points to a string which (if not flags&LADJUST) should be
* padded out to `width' places. If flags&ZEROPAD, it should
* first be prefixed by any sign or other prefix; otherwise,
* it should be blank padded before the prefix is emitted.
* After any left-hand padding and prefixing, emit zeroes
* required by a decimal [diouxX] precision, then print the
* string proper, then emit zeroes required by any leftover
* floating precision; finally, if LADJUST, pad with blanks.
*
* Compute actual size, so we know how much to pad.
* size excludes decimal prec; realsz includes it.
*/
realsz = dprec > size ? dprec : size;
if (sign)
realsz++;
else if (flags & HEXPREFIX)
realsz+= 2;
 
/* right-adjusting blank padding */
if ((flags & (LADJUST|ZEROPAD)) == 0)
PAD(width - realsz, ' ');
 
/* prefix */
if (sign) {
PRINT(&sign, 1);
} else if (flags & HEXPREFIX) {
ox[0] = '0';
ox[1] = ch;
PRINT(ox, 2);
}
 
/* right-adjusting zero padding */
if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
PAD(width - realsz, '0');
 
/* leading zeroes from decimal precision */
PAD(dprec - size, '0');
 
/* the string or number proper */
PRINT(cp, size);
 
/* left-adjusting padding (always blank) */
if (flags & LADJUST)
PAD(width - realsz, ' ');
}
done:
}
 
 
/misc/bsp/common/sysinfo.c
0,0 → 1,170
//==========================================================================
//
// sysinfo.c
//
// Interface for getting system information.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Interface for getting system information.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <stdlib.h>
#include <bsp/bsp.h>
#include "bsp_if.h"
 
 
/*
* In order to construct the _bsp_memory_list, some board specific code
* may have to size RAM regions. To do this easily and reliably, the code
* needs to run from ROM before .bss and .data sections are initialized.
* This leads to the problem of where to store the results of the memory
* sizing tests. In this case, the _bsp_init_stack routine which sizes
* memory and sets up the stack will place the board-specific information
* on the stack and return with the stack pointer pointing to a pointer to
* the information. That is, addr_of_info = *(void **)sp. The architecture
* specific code will then copy that pointer to the _bsp_ram_info_ptr variable
* after initializing the .data and .bss sections.
*/
void *_bsp_ram_info_ptr;
 
/*
* Name of CPU and board. Should be overridden by arch/board specific
* code.
*/
struct bsp_platform_info _bsp_platform_info = {
"Unknown", /* cpu name */
"Unknown", /* board name */
"" /* extra info */
};
 
 
/*
* Information about possible data cache. Should be overridden by
* by arch/board specific code.
*/
struct bsp_cachesize_info _bsp_dcache_info = {
0, 0, 0
};
 
 
/*
* Information about possible instruction cache. Should be overridden by
* by arch/board specific code.
*/
struct bsp_cachesize_info _bsp_icache_info = {
0, 0, 0
};
 
 
/*
* Information about possible secondary cache. Should be overridden by
* by arch/board specific code.
*/
struct bsp_cachesize_info _bsp_scache_info = {
0, 0, 0
};
 
 
 
int
_bsp_sysinfo(enum bsp_info_id id, va_list ap)
{
int index, rval = 0;
void *p;
 
switch (id) {
case BSP_INFO_PLATFORM:
p = va_arg(ap, void *);
*(struct bsp_platform_info *)p = _bsp_platform_info;
break;
 
case BSP_INFO_DCACHE:
p = va_arg(ap, void *);
*(struct bsp_cachesize_info *)p = _bsp_dcache_info;
break;
 
case BSP_INFO_ICACHE:
p = va_arg(ap, void *);
*(struct bsp_cachesize_info *)p = _bsp_icache_info;
break;
 
case BSP_INFO_SCACHE:
p = va_arg(ap, void *);
*(struct bsp_cachesize_info *)p = _bsp_scache_info;
break;
 
case BSP_INFO_MEMORY:
index = va_arg(ap, int);
p = va_arg(ap, void *);
 
if (index >= 0 && index < _bsp_num_mem_regions)
*(struct bsp_mem_info *)p = _bsp_memory_list[index];
else
rval = -1;
break;
 
case BSP_INFO_COMM:
index = va_arg(ap, int);
p = va_arg(ap, void *);
 
if (index >= 0 && index < _bsp_num_comms)
*(struct bsp_comm_info *)p = _bsp_comm_list[index].info;
else if (index == _bsp_num_comms && _bsp_net_channel != NULL)
*(struct bsp_comm_info *)p = _bsp_net_channel->info;
else
rval = -1;
break;
 
default:
rval = -1;
}
 
return rval;
}
 
 
 
/misc/bsp/common/debug-io.c
0,0 → 1,142
//==========================================================================
//
// debug-io.c
//
// BSP Debug Channel Interfaces.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: BSP Debug Channel Interfaces.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <stdlib.h>
#include <bsp/bsp.h>
#include "bsp_if.h"
 
static unsigned char __debug_ungetc;
 
extern int stub_is_active;
extern int __output_gdb_string (const char *str, int string_len);
void
bsp_debug_write(const char *p, int len)
{
struct bsp_comm_procs *com = bsp_shared_data->__debug_procs;
if (stub_is_active) {
// We are running in 'GDB' mode
__output_gdb_string(p, len);
} else {
com->__write(com->ch_data, p, len);
}
}
 
 
int
bsp_debug_read(char *p, int len)
{
struct bsp_comm_procs *com = bsp_shared_data->__debug_procs;
 
if (len <= 0)
return 0;
 
if (__debug_ungetc) {
*p = __debug_ungetc;
__debug_ungetc = 0;
return 1;
}
 
return com->__read(com->ch_data, p, len);
}
 
 
void
bsp_debug_putc(char ch)
{
struct bsp_comm_procs *com = bsp_shared_data->__debug_procs;
 
com->__putc(com->ch_data, ch);
}
 
int
bsp_debug_getc(void)
{
struct bsp_comm_procs *com = bsp_shared_data->__debug_procs;
int ch;
 
if (__debug_ungetc) {
ch = __debug_ungetc;
__debug_ungetc = 0;
} else
ch = com->__getc(com->ch_data);
 
return ch;
}
 
 
void
bsp_debug_ungetc(char ch)
{
__debug_ungetc = (unsigned char)ch;
}
 
 
int
bsp_debug_irq_disable(void)
{
struct bsp_comm_procs *com = bsp_shared_data->__debug_procs;
 
return com->__control(com->ch_data, COMMCTL_IRQ_DISABLE);
}
 
 
void
bsp_debug_irq_enable(void)
{
struct bsp_comm_procs *com = bsp_shared_data->__debug_procs;
 
com->__control(com->ch_data, COMMCTL_IRQ_ENABLE);
}
 
 
/misc/bsp/hex-utils.h
0,0 → 1,85
#ifndef __BSP_HEX_UTILS_H__
#define __BSP_HEX_UTILS_H__
//==========================================================================
//
// hex-utils.h
//
// Utilities for decoding hexadecimal encoded integers.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Utilities for decoding hexadecimal encoded integers.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#ifndef __ASSEMBLER__
 
/*
* Convert a single hex character to its binary value.
* Returns -1 if given character is not a value hex character.
*/
extern int __hex(char ch);
 
/*
* Convert the hex data in 'buf' into 'count' bytes to be placed in 'mem'.
* Returns a pointer to the character in mem AFTER the last byte written.
*/
extern char *__unpack_bytes_to_mem(char *buf, char *mem, int count);
 
/*
* While finding valid hex chars, build an unsigned long int.
* Return number of hex chars processed.
*/
extern int __unpack_ulong(char **ptr, unsigned long *val);
 
/*
* Unpack 'count' hex characters, forming them into a binary value.
* Return that value as an int. Adjust the source pointer accordingly.
*/
extern int __unpack_nibbles(char **ptr, int count);
 
#endif
 
#endif // __BSP_HEX_UTILS_H__
/misc/bsp/mips/gdb-cpu.c
0,0 → 1,53
//==========================================================================
//
// gdb-cpu.c
//
// CPU specific support for GDB stub.
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-06-07
// Purpose: CPU specific support for GDB stub.
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
/misc/bsp/mips/gdb.h
0,0 → 1,58
#ifndef __BSP_MIPS_GDB_H__
#define __BSP_MIPS_GDB_H__
//==========================================================================
//
// gdb.h
//
//
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
 
#endif // __BSP_ARM_GDB_H__
/misc/bsp/mips/gdb-cpu.h
0,0 → 1,58
#ifndef __BSP_MIPS_GDB_CPU_H__
#define __BSP_MIPS_GDB_CPU_H__
//==========================================================================
//
// gdb-cpu.h
//
// CPU specific definitions for GDB stub.
//
//==========================================================================
//####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):
// Contributors: dmoseley
// Date: 2000-07-10
// Purpose: CPU specific definitions for GDB stub.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
 
#endif // __BSP_MIPS_GDB_CPU_H__
/misc/bsp/mips/insn.h
0,0 → 1,59
#ifndef __BSP_MIPS_INSN_H__
#define __BSP_MIPS_INSN_H__
//==========================================================================
//
// insn.h
//
// MIPS instruction descriptions.
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-07-10
// Purpose: MIPS instruction descriptions.
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
// We are using the eCos hal for single-stepping.
// FIXME: this file can be removed
 
#endif // __BSP_ARM_INSN_H__
/misc/bsp/mips/singlestep.c
0,0 → 1,55
//==========================================================================
//
// singlestep.c
//
// MIPS specific single-step support.
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-07-10
// Purpose: MIPS specific single-step support.
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
// We are using the eCos hal for single-stepping.
// FIXME: this file can be removed
/misc/bsp/gdb-data.h
0,0 → 1,126
#ifndef __BSP_GDB_DATA_H__
#define __BSP_GDB_DATA_H__
//==========================================================================
//
// gdb-data.h
//
// Shared data specific to gdb stub.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Shared data specific to gdb stub.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#ifndef __ASSEMBLER__
typedef int (*gdb_memproc_t)(void *__addr, /* start addr of memory to read/write */
int __asid, /* address space id */
int __size, /* size of individual read/write ops */
int __n, /* number of read/write operations */
void *__buf); /* result(read)/src(write) buffer */
 
 
typedef void (*gdb_regproc_t)(int __regno, /* Register number */
void *__regs, /* pointer to saved regs */
void *__val); /* pointer to register value */
 
 
typedef struct {
/*
* An application may override the standard BSP memory
* read and/or write routines with these hooks.
*/
gdb_memproc_t __mem_read_hook;
gdb_memproc_t __mem_write_hook;
 
/*
* An application may override the standard BSP register
* access routines with these hooks.
*/
gdb_regproc_t __reg_get_hook;
gdb_regproc_t __reg_set_hook;
 
/*
* An application may extend the gdb remote protocol by
* installing hooks to handle unknown general query and
* set packets ("q" pkts and 'Q' pkts) with these two hooks.
*/
void (*__pkt_query_hook)(unsigned char *__pkt);
void (*__pkt_set_hook)(unsigned char *__pkt);
 
/*
* An application may also extend the gdb remote protocol
* by installing a hook to handle all unknown packets.
*/
void (*__pkt_hook)(unsigned char *__pkt);
 
/*
* The above hooks for receiving packets will probably need
* a mechanism to respond. This vector is provided to allow
* an application to append data to the outgoing packet which
* will be sent after the above hooks are called.
*
* This vector uses a printf-like format string followed by
* some number of arguments.
*/
void (*__pkt_append)(char *fmt, ...);
 
/*
* An application can read/write from/to gdb console
* through these vectors.
*
* NB: console read is not supported and will block forever.
*/
int (*__console_read)(char *__buf, int len);
int (*__console_write)(char *__buf, int len);
 
} gdb_data_t;
 
 
extern gdb_data_t *__get_gdb_data(void);
 
#endif /* __ASSEMBLER__ */
 
#endif // __BSP_GDB_DATA_H__
/misc/bsp/bsp.h
0,0 → 1,445
#ifndef __BSP_BSP_H__
#define __BSP_BSP_H__
//==========================================================================
//
// bsp.h
//
// Public interface to Red Hat BSP.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Public interface to Red Hat BSP.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#ifndef __ASSEMBLER__
 
/* needed for _bsp_vsprintf() */
#include <stdarg.h>
 
/*
* Exception and interrupt handler type.
*/
#ifndef _BSP_HANDLER_T_DEFINED
#define _BSP_HANDLER_T_DEFINED
typedef int (*bsp_handler_t)(int __irq_nr, void *__regs);
#endif // _BSP_HANDLER_T_DEFINED
 
/*
* Vector descriptor. This is needed for chaining vectors. The interfaces use
* bsp_vec structure pointers instead of direct pointers to handlers. This
* puts the responsibility for allocating the bsp_vec structures on the
* caller, rather than the BSP code.
*/
typedef struct bsp_vec {
bsp_handler_t handler; /* pointer to actual ISR */
struct bsp_vec *next; /* for chaining */
} bsp_vec_t;
 
/*
* Valid op values for vector install routines.
*/
#define BSP_VEC_REPLACE 0
#define BSP_VEC_CHAIN_FIRST 1
#define BSP_VEC_CHAIN_LAST 2
 
/*
* Valid kinds of vectors supported by vector install and remove
* routines.
*/
#define BSP_VEC_EXCEPTION 0
#define BSP_VEC_INTERRUPT 1
 
/*
* Routine to cause a breakpoint exception.
*/
extern void bsp_breakpoint(void);
 
/*
* Dummy function whose address is the address of
* the breakpoint caused by calling bsp_breakpoint().
*/
extern void bsp_breakinsn(void);
 
/*
* Enable given irq.
*/
extern void bsp_enable_irq(int __irq_nr);
 
/*
* Disable given irq. Returns true if irq was enabled.
*/
extern int bsp_disable_irq(int __irq_nr);
 
/*
* Remove given vector from vector chain.
*/
extern void bsp_remove_vec(int __vec_kind,
int __vec_nr,
bsp_vec_t *__vec);
 
/*
* Install a vector chain.
*
* vec_kind may be BSP_VEC_EXCEPTION or BSP_VEC_INTERRUPT.
* vec_nr is the exception or interrupt number.
* op may be one of:
* BSP_VEC_REPLACE - replace existing chain.
* BSP_VEC_CHAIN_FIRST - install at head of chain.
* BSP_VEC_CHAIN_LAST - install at tail of chain.
*
*/
extern bsp_vec_t *bsp_install_vec(int __vec_kind,
int __vec_nr,
int __op,
bsp_vec_t *__vec);
 
/*
* Install a debug handler.
* Returns old handler being replaced.
*/
extern bsp_handler_t bsp_install_dbg_handler(bsp_handler_t __new_handler);
 
/*
* Sometimes it is desireable to call the debug handler directly. This routine
* accomplishes that. It is the responsibility of the caller to insure that
* interrupts are disabled before calling this routine.
*/
extern void bsp_invoke_dbg_handler(int __exc_nr, void *__regs);
 
/*
* Install a 'kill' handler. This handler is called when debugger
* issues a kill command.
* Returns old handler being replaced.
*/
extern bsp_handler_t bsp_install_kill_handler(bsp_handler_t __new_handler);
 
/*
* Architecure specific routine to prepare CPU to execute
* a single machine instruction.
*/
#ifndef USE_ECOS_HAL_SINGLESTEP
extern void bsp_singlestep_setup(void *__saved_regs);
#endif /* USE_ECOS_HAL_SINGLESTEP */
 
/*
* Architecure specific routine to cleanup after a single-step
* completes.
*/
#ifndef USE_ECOS_HAL_SINGLESTEP
extern void bsp_singlestep_cleanup(void *__saved_regs);
#endif /* USE_ECOS_HAL_SINGLESTEP */
 
/*
* Architecture specific routine to skip past the current machine instruction.
*/
#ifndef USE_ECOS_HAL_SINGLESTEP
extern void bsp_skip_instruction(void *__saved_regs);
#endif /* USE_ECOS_HAL_SINGLESTEP */
 
/*
* Return byte offset within the saved register area of the
* given register.
*/
extern int bsp_regbyte(int __regno);
 
/*
* Return size in bytes of given register.
*/
extern int bsp_regsize(int __regno);
 
/*
* Setup the saved registered to establish the given Program Counter.
*/
#ifndef bsp_set_pc
extern void bsp_set_pc(unsigned long __pc, void *__saved_regs);
#endif
 
/*
* Get the current Program Counter from the saved registers.
*/
#ifndef bsp_get_pc
unsigned long bsp_get_pc(void *__saved_regs);
#endif
 
extern int bsp_memory_read(void *__addr, /* start addr of memory to read */
int __asid, /* address space id */
int __rsize, /* size of individual read ops */
int __nreads, /* number of read operations */
void *__buf); /* result buffer */
 
extern int bsp_memory_write(void *__addr, /* start addr of memory to write */
int __asid, /* address space id */
int __wsize, /* size of individual write ops */
int __nwrites, /* number of write operations */
void *__buf); /* source buffer for write data */
 
/*
* Architecture specific routines to read and write CPU registers.
*/
extern void bsp_set_register(int __regno, void *__saved_regs, void *__val);
extern void bsp_get_register(int __regno, void *__saved_regs, void *__val);
 
 
/*
* Architecture specific conversion of raw exception info into
* a signal value.
*/
#ifndef bsp_get_signal
extern int bsp_get_signal(int __exc_nr, void *__saved_regs);
#endif
 
/* light-weight bsp printf to console port */
extern void bsp_printf(const char *__fmt, ...);
 
/* light-weight bsp printf to debug port */
extern void bsp_dprintf(const char *__fmt, ...);
 
/* bsp vsprintf */
extern int bsp_vsprintf(char *__str, const char *__fmt, va_list __ap);
 
/* bsp vprintf to console port */
extern void bsp_vprintf(const char *__fmt, va_list __ap);
 
/* bsp vprintf to debug port */
extern void bsp_dvprintf(const char *__fmt, va_list __ap);
 
/* bsp sprintf */
extern void bsp_sprintf(char *str, const char *fmt, ...);
 
#ifdef NDEBUG
#define BSP_ASSERT(e) ((void)0)
#else /* NDEBUG */
extern void _bsp_assert(const char *, const int, const char *);
#define BSP_ASSERT(e) ((e) ? (void)0 : _bsp_assert(__FILE__, __LINE__, #e))
#endif /* NDEBUG */
 
/*
* Functions for low-level console and debug i/o.
*/
extern void bsp_console_write(const char *__p, int __len);
extern void bsp_console_putc(char __ch);
extern int bsp_console_read(char *__p, int __len);
extern int bsp_console_getc(void);
extern void bsp_console_ungetc(char ch);
extern void bsp_debug_write(const char *__p, int __len);
extern int bsp_debug_read(char *__p, int __len);
extern void bsp_debug_putc(char __ch);
extern int bsp_debug_getc(void);
extern void bsp_debug_ungetc(char ch);
 
/*
* Disable interrupts for debug comm channel.
* Returns true if interrupts were previously enabled,
* false if interrupts were already disabled.
*/
extern int bsp_debug_irq_disable(void);
extern void bsp_debug_irq_enable(void);
 
/*
* Cache control functions. May be noops for architectures not
* supporting caches.
*
* The icache flush simply invalidates _at_least_ the range of
* addresses specified.
*
* The dcache flush writes back (if write-back cache) and invalidates
* _at_least_ the range of addresses specified.
*
*/
extern void bsp_flush_dcache(void *__p, int __nbytes);
extern void bsp_flush_icache(void *__p, int __nbytes);
 
/*
* Reset function. May be noops for architectures not
* supporting software reset.
*/
extern void bsp_reset(void);
 
/*
* Generic data (board and CPU specific) handling
*/
extern void *bsp_cpu_data(void);
extern void *bsp_board_data(void);
 
/*
* List of board characteristics which can be read queried by BSP clients. These
* information IDs are passed to:
*
* int bsp_sysinfo(enum bsp_info_id id, ...);
*
* Some pieces of information may have more than one instance. For example, the
* BSP will likely have information on multiple memory regions. In those cases,
* a particular instance may be accessed using a small integer index argument.
*
* The following comments indicate what additional arguments are needed
* to access the specific information.
*/
enum bsp_info_id {
/*
* CPU and board names.
*
* err = bsp_sysinfo(BSP_INFO_PLATFORM,
* struct bsp_platform_info *result)
*
* err => zero if successful, -1 if unsupported.
*/
BSP_INFO_PLATFORM,
 
/*
* Data, instruction, and secondary caches.
*
* err = bsp_sysinfo(BSP_INFO_[DIS]CACHE,
* struct bsp_cache_info *result)
*
* err => zero if successful, -1 if unsupported.
*
*/
BSP_INFO_DCACHE,
BSP_INFO_ICACHE,
BSP_INFO_SCACHE,
 
/*
* Memory region info.
*
* err = bsp_sysinfo(BSP_INFO_MEMORY,
* int index,
* struct bsp_mem_info *result)
*
* err => zero if successful, -1 if invalid index.
*
* Caller should start index at zero, then increment index for subsequent
* calls until error return indicates no more memory regions.
*/
BSP_INFO_MEMORY,
 
/*
* Communication channel info.
*
* err = bsp_sysinfo(BSP_INFO_COMM,
* int index,
* struct bsp_comm_info *result)
*
* err => zero if successful, -1 if invalid index.
*
* Caller should start index at zero, then increment index for subsequent
* calls until error return indicates no more comm channels.
*/
BSP_INFO_COMM
};
 
 
/*
* Platform info.
*/
struct bsp_platform_info {
const char *cpu; /* CPU name*/
const char *board; /* board name */
const char *extra; /* extra info */
};
 
 
/*
* Cache size info.
*/
struct bsp_cachesize_info {
int size; /* total size in bytes */
short linesize; /* width of cacheline in bytes */
short ways; /* number of ways per line */
};
 
 
/*
* Memory region info.
* The BSP may describe multiple memory regions. For example,
* DRAM may be comprised of several non-contiguous regions.
* ROM and FLASH regions may also be described.
*
*/
struct bsp_mem_info {
void *phys_start; /* physical start address */
void *virt_start; /* virtual start address */
int virt_asid; /* some architectures also use an address space id */
long nbytes; /* length of region in bytes */
int kind; /* kind of memory */
#define BSP_MEM_RAM 1
#define BSP_MEM_FLASH 2
#define BSP_MEM_ROM 3
};
 
 
struct bsp_comm_info {
char *name;
short kind;
#define BSP_COMM_SERIAL 1
#define BSP_COMM_ENET 2
short protocol;
#define BSP_PROTO_NONE 0
#define BSP_PROTO_UDP 1
#define BSP_PROTO_TCP 2
};
 
 
extern int bsp_sysinfo(enum bsp_info_id __id, ...);
 
/*
* Set or get active debug and console channels.
* Returns -1 if unsucessful.
* If the passed in __comm_id is -1, then the id of the current channel
* is returned.
*/
extern int bsp_set_debug_comm(int __comm_id);
extern int bsp_set_console_comm(int __comm_id);
 
/*
* Set or get the current baud rate of a serial comm channel.
* Returns -1 on if unsuccessful.
* If the given baud is -1, then the current baudrate is returned.
*/
extern int bsp_set_serial_baud(int __comm_id, int baud);
 
#endif
 
#endif // __BSP_BSP_H__
/misc/bsp/cpu.h
0,0 → 1,71
#ifndef __BSP_CPU_H__
#define __BSP_CPU_H__
//==========================================================================
//
// cpu.h
//
// Architecture/processor specifics
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas, dmoseley
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
// Pick up architecture info
 
#include <pkgconf/system.h>
 
#ifdef CYGPKG_HAL_ARM
#include "arm/cpu.h"
#endif
 
#ifdef CYGPKG_HAL_MIPS
#include "mips/cpu.h"
#endif
 
#ifdef CYGPKG_HAL_MN10300
#include "mn10300/cpu.h"
#endif
 
#endif // __BSP_CPU_H__
/misc/bsp/mn10300/gdb-cpu.c
0,0 → 1,53
//==========================================================================
//
// gdb-cpu.c
//
// CPU specific support for GDB stub.
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-08-11
// Purpose: CPU specific support for GDB stub.
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
/misc/bsp/mn10300/gdb.h
0,0 → 1,58
#ifndef __BSP_MN10300_GDB_H__
#define __BSP_MN10300_GDB_H__
//==========================================================================
//
// gdb.h
//
//
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-08-11
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
 
#endif // __BSP_ARM_GDB_H__
/misc/bsp/mn10300/gdb-cpu.h
0,0 → 1,58
#ifndef __BSP_MN10300_GDB_CPU_H__
#define __BSP_MN10300_GDB_CPU_H__
//==========================================================================
//
// gdb-cpu.h
//
// CPU specific definitions for GDB stub.
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-08-11
// Purpose: CPU specific definitions for GDB stub.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
 
#endif // __BSP_MN10300_GDB_CPU_H__
/misc/bsp/mn10300/insn.h
0,0 → 1,59
#ifndef __BSP_MN10300_INSN_H__
#define __BSP_MN10300_INSN_H__
//==========================================================================
//
// insn.h
//
// MN10300 instruction descriptions.
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-08-11
// Purpose: MN10300 instruction descriptions.
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
// We are using the eCos hal for single-stepping.
// FIXME: this file can be removed
 
#endif // __BSP_ARM_INSN_H__
/misc/bsp/mn10300/singlestep.c
0,0 → 1,55
//==========================================================================
//
// singlestep.c
//
// MN10300 specific single-step support.
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-08-11
// Purpose: MN10300 specific single-step support.
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Nothing now.
// We are using the eCos hal for single-stepping.
// FIXME: this file can be removed
/misc/stub-tservice.h
0,0 → 1,54
//==========================================================================
//
// stub-tservice.h
//
//
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Placeholder
/misc/ecos_dummy.c
0,0 → 1,70
//==========================================================================
//
// ecos_dummy.c
//
// eCos BSP (for building Cygmon)
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas, dmoseley
// Date: 1999-10-11
// Description: Wrapper functions which provide BSP environment for Cygmon
//####DESCRIPTIONEND####
 
#ifdef CYGPKG_KERNEL
#include <pkgconf/kernel.h> // Configuration header
#include <cyg/kernel/kapi.h>
#endif
#include <cyg/infra/diag.h>
#include <cyg/hal/plf_stub.h>
 
// TEMP
 
#define FAIL(n) \
void n(void) \
{ \
diag_printf("Fail: %s\n", #n); \
while (1) ; \
}
 
#ifndef CYGHWR_HAL_RESET_DEFINED
FAIL(bsp_reset)
#endif
 
FAIL(_bsp_gdb_handler)
FAIL(_bsp_gdb_data)
/misc/ledit.h
0,0 → 1,88
//==========================================================================
//
// ledit.h
//
// Header for the utterly simple line editor
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Header for the udderly simple line editor
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#ifndef LEDIT_H
#define LEDIT_H
 
#define LF '\n'
#define CR '\r'
#define BOLCMD '\001'
#define EOLCMD '\005'
#define FORWCMD '\006'
#define BACKCMD '\002'
#define DELBACK '\010'
#define DELEOL '\013'
#define YANKCH '\031'
#define DELCURRCH '\004'
#define PREVCMD '\020'
#define ERASELINE '\025'
#define NEXTCMD '\016'
 
/* Prompt for one line of input using PROMPT. The input from the user
(up to MAXINPLEN characters) will be stored in BUFFER. The number
of characters read will be returned. */
extern int lineedit(char *prompt, char *buffer, int maxInpLen);
 
/* Add CMD to the user's command history. */
extern void addHistoryCmd (char *cmd);
 
/* Configure the editor to use the specified terminal. */
extern void set_term_name (char *name);
 
/* Beep the terminal. */
extern void beep (void);
 
/* Print a history list. */
extern void printHistoryList(void);
 
#endif
/misc/cpu_info.h
0,0 → 1,69
#ifndef __CYGMON_CPU_INFO_H__
#define __CYGMON_CPU_INFO_H__
//==========================================================================
//
// cpu_info.h
//
// Architecture specific information
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas, dmoseley
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
#include <pkgconf/system.h>
#include <pkgconf/hal.h>
 
#ifdef CYGPKG_HAL_ARM
#include "arm/cpu_info.h"
#endif
 
#ifdef CYGPKG_HAL_MIPS
#include "mips/cpu_info.h"
#endif
 
#ifdef CYGPKG_HAL_MN10300
#include "mn10300/cpu_info.h"
#endif
#endif // __CYGMON_CPU_INFO_H__
/misc/monitor_cmd.c
0,0 → 1,2549
//==========================================================================
//
// monitor_cmd.c
//
// Monitor commands for the CygMON ROM monitor
//
//==========================================================================
//####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):
// Contributors: gthomas, dmoseley
// Date: 1999-10-20
// Purpose: Monitor commands for the CygMON ROM monitor
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#ifdef HAVE_BSP
#include "cpu_info.h"
#include <bsp/bsp.h>
#include <bsp/cpu.h>
#include <bsp/hex-utils.h>
#ifdef __BOARD_HEADER__
#include __BOARD_HEADER__
#endif
#endif
#include <board.h>
#include <unistd.h>
#include <stdlib.h>
#include <monitor.h>
#include <ledit.h>
#include <string.h>
#include <ctype.h>
 
#ifdef HAVE_BSP
#include "fmt_util.h"
#include "tservice.h"
#endif
 
#ifdef __ECOS__
#include <cyg/hal/hal_stub.h>
#endif
 
#if USE_CYGMON_PROTOTYPES
/* Use common prototypes */
/* Some of the composed board.h files compose these
prototypes redundently, but if they dont,
these are the common definitions */
#include "fmt_util.h" /* Interface to string formatting utilities */
#include "tservice.h" /* Interface to target specific services */
#include "generic-stub.h" /* from libstub */
#endif /* USE_CYGMON_PROTOTYPES */
 
static int history_cmd(cmdmode_t mode) ;
 
#ifndef MAXLINELEN
#define MAXLINELEN 80
#endif
 
#define MAXLINES 23
 
char inbuf[MAXLINELEN] ;
static char cmd[MAXLINELEN];
 
#if ! defined(PROVIDE_CRASH_CMD)
#define PROVIDE_CRASH_CMD 0
#endif
 
#if PROVIDE_CRASH_CMD
/*
* The crash command is used while debugging cygmon itself
*/
static int crash_cmd(cmdmode_t mode) ; /* Command to trap into cygmon */
#endif
 
struct cmdentry cmdtab[] = {
{NULL, "baud", set_serial_speed_cmd},
{"b", "break", breakpoint_cmd},
#if HAVE_CACHE
{NULL, "cache", cache_cmd},
#endif
{NULL, "copy", copy_cmd},
#if PROVIDE_CRASH_CMD
{NULL, "crash", crash_cmd},
#endif
{NULL, "crc", checksumcmd},
{"d", "disassemble", disassemble_cmd},
{NULL, "dump", dump_cmd},
#if defined(NVRAM_ETH_ADDR)
{NULL, "ethaddr", ethaddr_cmd},
#endif
{NULL, "fill", fill_cmd},
{NULL, "go", go_cmd},
{NULL, "help", help_cmd},
{"his","history", history_cmd},
#ifdef MONITOR_CONTROL_INTERRUPTS
{NULL, "interrupt", int_cmd},
#endif
#if defined(NVRAM_IP_ADDR)
{NULL, "ipaddr", ipaddr_cmd},
#endif
{NULL, "load", load_cmd},
{"m", "memory", mem_cmd},
#ifdef OTHERNAMES_CMD
{"o", "othernames", othernames_cmd},
#endif
{NULL, "port", set_serial_port_cmd},
{"r", "register", reg_cmd},
{NULL, "reset", reset_cmd},
#ifndef HAVE_BSP
{NULL, "setargs", set_program_args_cmd},
#endif
{"si", "step", step_cmd},
{NULL, "swapmem", swapmem_cmd},
#if defined(NVRAM_TCP_PORT)
{NULL, "tcpport", tcpport_cmd},
#endif
{NULL, "terminal", set_term_cmd},
#ifdef HAS_TIMER
{NULL, "timer", timer_cmd},
#endif
#if !defined(__ECOS__) || defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
{NULL, "transfer", transfer_cmd},
#endif
{"u", "unbreak", clear_breakpoint_cmd},
#if HAVE_USAGE
{NULL, "usage", memusage_cmd},
#endif
{NULL, "version", version_cmd},
/* Really need to redo the way commands are done--there should be a
dynamic list (perhaps in addition to the static one). */
#ifdef TARGET_COMMANDS
TARGET_COMMANDS
#endif
 
{NULL, NULL, NULL}
};
 
static int
alias_compare (char *cmd)
{
int m = 0;
int match = -1;
int num_matches = 0;
 
while (cmdtab[m].cmd != NULL)
{
if (cmdtab[m].alias != NULL && !strcmp (cmd, cmdtab[m].alias))
{
match = m;
num_matches++;
/* We're expecting that aliases will be defined
uniquely, but just in case, we let the user know
if there is a conflict */
if (num_matches > 1)
{
xprintf ("Alias conflict. Executing last matching alias.\n");
}
}
m++;
}
return match;
}
 
static int
command_compare (char *cmd)
{
int m = 0;
int match = -1;
int num_matches = 0;
int cmdlen = strlen(cmd) ;
while (cmdtab[m].cmd != NULL)
{
if (!(strncmp (cmd,cmdtab[m].cmd, cmdlen)))
{
/* we found a match */
num_matches++;
if (num_matches == 2) /* we found a second match */
{
xprintf ("Ambiguous command. Possibilities are:\n%s\n%s\n",
cmdtab[match].cmd,
cmdtab[m].cmd);
}
else if (num_matches > 2) /* we found another match */
{
/* Show the new possibility we just found */
xprintf ("%s\n", cmdtab[m].cmd);
}
/* Point the match at the command we just looked at.
We have to wait until now so that the first duplicate
found can output the earlier match as well */
match = m;
}
m++;
}
return ((num_matches == 1) ? match : -1);
}
 
#ifdef USE_HELP
void
usage (char *string)
{
xprintf ("Usage: %s\n", string);
}
 
void
short_help (char *string)
{
xprintf ("%s\n", string);
}
 
void
long_help (char *string)
{
int linecnt = 0;
int do_leave = 0;
 
for (; *string && !do_leave; string++)
{
xprintf ("%c", *string);
if (*string == '\n')
{
linecnt++;
if (linecnt == MAXLINES)
{
int i;
 
xprintf ("-More-");
while ((i = input_char ()) >= 0)
{
if (i == '\r' || i == '\n')
{
linecnt--;
break;
}
else if (i == ' ')
{
linecnt = 0;
break;
}
else if (i == 'q' || i == 'Q')
{
do_leave = 1;
break;
}
else
beep ();
}
}
}
}
xprintf ("\n");
}
 
void
example (char *example)
{
xprintf ("Example: %s\n", example);
}
 
#else
void
no_help (void)
{
xprintf ("No help available.\n");
}
 
void
no_help_usage (void)
{
xprintf ("Incorrect usage.\n");
}
#endif
 
int
help_cmd (cmdmode_t mode)
{
int command_number = -2;
 
if (mode == USAGE)
{
usage ("help [command]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("The help command");
return 0;
}
if (mode == LONG_HELP)
{
help_cmd (USAGE);
long_help ("\
The help command without arguments shows a list of all available commands\n\
with a short description of each one. With a command name as an argument\n\
it shows usage for the command and a paragraph describing the command.\n\
Usage is shown as command name followed by names of extensions or arguments.\n\
Arguments in [brackets] are optional, plain text arguments are required.\n\
Note that all commands can be invoked by typing enough of the command name\n\
to uniquely specify the command. Some commands have aliases, which are one\n\
letter abbreviations for commands which do not have unique first letters.\n\
Aliases for all commands are shown in the help screen, which displays\n\
commands in the format:\n\
command name: (alias, if any) description of command \n");
example("\
help foo \n\
Shows the help screen for the command foo.");
return 0;
}
 
if (argvect[1] != NULL)
{
if (argvect[2] == NULL)
{
command_number = command_compare (argvect[1]);
if (command_number < 0)
{
xprintf ("No such command as %s\n", argvect[1]);
}
}
if (command_number < 0)
{
return help_cmd (USAGE);
}
else
{
return cmdtab[command_number].function (LONG_HELP);
}
}
else
{
int i;
xprintf ("Available commands are:\n");
for (i = 0; cmdtab[i].cmd != NULL; i++)
{
int x = strlen (cmdtab[i].cmd) + 2;
 
xprintf ("%s: ", cmdtab[i].cmd);
if (cmdtab[i].alias != NULL)
{
xprintf("(%s)", cmdtab[i].alias);
x += 2 + strlen(cmdtab[i].alias);
}
for (; x < 20; x++)
{
xprintf (" ");
}
cmdtab[i].function (SHORT_HELP);
if ((i > 0) && (i % MAXLINES) == 0)
{
xprintf ("-More-");
input_char ();
xprintf ("\n");
}
}
}
return 0;
}
 
#if PROVIDE_CRASH_CMD
static int crash_cmd(cmdmode_t mode)
{
switch (mode)
{
case USAGE : usage("crash") ; break ;
case SHORT_HELP : short_help("invoke the breakpoint function");
break ;
case LONG_HELP :
long_help("The crash command calls the breakpoint function() which is useful\n\
only if you are using an additional debugger to debug this software and,\n\
the general exception handler is hooked to the other debugger\n") ;
break ;
case INVOCATION :
dbg_breakpoint() ;
break ;
}
return 0 ;
}
#endif /* provide_crash_command */
 
 
 
static int history_cmd(cmdmode_t mode)
{
switch (mode)
{
case USAGE : usage("history") ; break ;
case SHORT_HELP : short_help("Print help about line editing features.");
break ;
case INVOCATION :
printHistoryList();
break;
case LONG_HELP :
long_help("Cygmon line editing allows you to repeat previously entered
commands. The line editing commands are:
CR '\\n' Execute the currently displayed command
ctl-a move to Beginning of line
ctl-e End of line
ctl-f Forward char
ctl-b Backward char
ctl-k Delete to end of line
ctl-y yank Character (undelete)
ctl-d Delete current character
ctl-p edit previous command
ctl-u Erase Line
ctl-n Edit next command") ;
break ;
}
return 0 ;
} /* history_cmd */
 
#ifdef OTHERNAMES_CMD
/* Switch to using the othernames (ie alternate register names) */
int
othernames_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("othernames");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Switch between alternate register names.");
return 0;
}
if (mode == LONG_HELP)
{
othernames_cmd (USAGE);
long_help ("\
The othernames command allows you to switch between alternate register
names for a given target.");
example ("\
othernames\n\
Switches to the alternate register name set..");
return 0;
}
OTHERNAMES_CMD();
 
return 0;
}
#endif /* OTHERNAMES_CMD */
 
 
#if defined(NVRAM_ETH_ADDR)
int
ethaddr_cmd (cmdmode_t mode)
{
int i, n;
unsigned char addr[6];
char *p;
 
if (mode == USAGE)
{
usage ("ethaddr [xx:xx:xx:xx:xx:xx]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("get/set NVRAM backed ethernet address");
return 0;
}
if (mode == LONG_HELP)
{
ethaddr_cmd (USAGE);
long_help ("\
The ethaddr command is used to view and modify the non-volatile ethernet\n\
address. The address is specified by 6 colon-seperated 2 digit hexadecimal\n\
numbers. If no address is specified, the current address is displayed.\n");
example ("ethaddr 00:00:8B:F1:36:01");
return 0;
}
 
if (argvect[1] != NULL)
{
if (strlen(argvect[1]) != 17 || argvect[2] != NULL)
{
return ethaddr_cmd (USAGE);
}
 
for (i = 0, p = argvect[1]; i < 6; i++, p++)
{
n = __hex(*p++);
if (n < 0)
return ethaddr_cmd (USAGE);
addr[i] = (n << 4);
n = __hex(*p++);
if (n < 0)
return ethaddr_cmd (USAGE);
addr[i] |= n;
 
if (*p != ':' && !(i == 5 && *p == '\0'))
return ethaddr_cmd (USAGE);
}
for (i = 0; i < 6; i++)
NVRAM_ETH_ADDR(i) = addr[i];
}
else
{
for (i = 0; i < 5; i++)
xprintf("%02x:", NVRAM_ETH_ADDR(i));
xprintf("%02x\n", NVRAM_ETH_ADDR(i));
}
 
return 0;
}
#endif /* NVRAM_ETH_ADDR */
 
 
#if defined(NVRAM_IP_ADDR)
int
ipaddr_cmd (cmdmode_t mode)
{
int i, j, n;
unsigned char addr[4];
char *p;
 
if (mode == USAGE)
{
usage ("ipaddr [n.n.n.n]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("get/set NVRAM backed ip address");
return 0;
}
if (mode == LONG_HELP)
{
ipaddr_cmd (USAGE);
long_help ("\
The ipaddr command is used to view and modify the non-volatile internet\n\
address. The address is specified by 4 dot-seperated 1-3 digit decimal\n\
numbers. If no address is specified, the current address is displayed.\n");
example ("ipaddr 192.161.0.1");
return 0;
}
 
if (argvect[1] != NULL)
{
if (argvect[2] != NULL)
return ipaddr_cmd (USAGE);
 
p = argvect[1];
 
for (i = 0; i < 3; i++, p++)
{
for (j = n = 0; j < 3 && isdigit(*p); j++, p++)
n = n*10 + (*p - '0');
if (j == 0 || *p != '.' || n > 255)
return ipaddr_cmd (USAGE);
addr[i] = n;
}
for (j = n = 0; j < 3 && isdigit(*p); j++, p++)
n = n*10 + (*p - '0');
if (j == 0 || *p != '\0' || n > 255)
return ipaddr_cmd (USAGE);
addr[i] = n;
 
for (i = 0; i < 4; i++)
NVRAM_IP_ADDR(i) = addr[i];
}
else
{
for (i = 0; i < 3; i++)
xprintf("%d.", NVRAM_IP_ADDR(i));
xprintf("%d\n", NVRAM_IP_ADDR(i));
}
 
return 0;
}
#endif /* NVRAM_IP_ADDR */
 
#if defined(NVRAM_TCP_PORT)
int
tcpport_cmd (cmdmode_t mode)
{
int n;
char *p;
 
if (mode == USAGE)
{
usage ("ethaddr [xx:xx:xx:xx:xx:xx]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("get/set NVRAM backed tcp port number");
return 0;
}
if (mode == LONG_HELP)
{
tcpport_cmd (USAGE);
long_help ("\
The tcpport command is used to view and modify the non-volatile tcp port\n\
address used for debugging. The address is specified by decimal numer in\n\
the range of 1-65535. If no port number is specified, the current port is\n\
displayed.\n");
example ("tcpport 1000");
return 0;
}
 
if (argvect[1] != NULL)
{
if (argvect[2] != NULL)
return tcpport_cmd (USAGE);
 
p = argvect[1];
n = 0;
while (isdigit(*p))
{
n = n*10 + (*p++ - '0');
if (n > 65535)
return tcpport_cmd (USAGE);
}
if (*p != '\0')
return tcpport_cmd (USAGE);
 
NVRAM_TCP_PORT(0) = (n >> 8) & 0xff;
NVRAM_TCP_PORT(1) = n & 0xff;
}
else
xprintf("%d\n", (NVRAM_TCP_PORT(0) << 8) + NVRAM_TCP_PORT(1));
 
return 0;
}
#endif /* NVRAM_TCP_PORT */
 
 
#ifdef __ECOS__
# if (CYG_BYTEORDER == CYG_LSBFIRST)
# define LITTLE_ENDIAN_TARGET
# else
# define BIG_ENDIAN_TARGET
# endif
#endif
 
#ifdef LITTLE_ENDIAN_TARGET
static int swap_bytes = 1;
#else
static int swap_bytes = 0;
#endif
 
int
get_memory_display_mode (void)
{
return swap_bytes;
}
 
void
set_memory_display_mode (int mode)
{
swap_bytes = mode;
}
 
 
/* Just to make DEFAULT_SIZE something usable, this may go elsewhere later.*/
#ifndef DEFAULT_SIZE
#define DEFAULT_SIZE 1
#endif
 
static int
get_cmd_size (void)
{
int size = 0;
char *sizestr;
 
sizestr = strchr (argvect[0], '.');
 
if (sizestr == NULL || sizestr[0] == '\0' || sizestr[1] == '\0')
{
size = DEFAULT_SIZE;
}
else
{
size = str2int (sizestr + 1, 10) / 8;
}
if (size != 1 && size != 2 && size != 4 && size != 8)
{
xprintf ("Invalid size.\n");
return -1;
}
return size;
}
 
 
void
display_memory (char *value, int size, int littleEndian)
{
int x;
int start = littleEndian ? size - 1 : 0 ;
int end = littleEndian ? -1 : size;
int incr = littleEndian ? -1 : 1;
 
if (value)
{
for (x = start; x != end; x += incr)
xprintf ("%02x", value[x] & 0xff);
}
else
{
for (x = start; x != end; x += incr)
xprintf ("..");
}
}
 
 
static int
peek (void)
{
mem_addr_t addr;
int size = get_cmd_size ();
 
if (size > 0)
{
/* We already checked to see if the command was legal when we called the
function, so there's no need to worry about that here. */
 
if (argvect[1] != 0)
{
char value[8];
 
str2addr (argvect[1], &addr);
if (read_memory (&addr, size, 1, value))
{
xprintf ("Memory read failed\n");
}
else
{
display_memory (value, size, get_memory_display_mode ());
xprintf ("\n");
}
}
else
{
xprintf ("Not enough arguments\n");
return mem_cmd (USAGE);
}
}
return 0;
}
 
/* Poke a single byte in memory. */
 
static int
poke (void)
{
int size = 0;
 
size = get_cmd_size ();
if (size > 0)
{
/* We already checked to see if the command was legal when we called the
function, so there's no need to worry about that here. */
 
if ((argvect[1] != 0) && (argvect[2] != 0))
{
char value[8];
mem_addr_t addr;
 
str2addr (argvect[1], &addr);
hex2bytes (argvect[2], value, size);
 
if (get_memory_display_mode ())
{
/* Gotta swap this puppy. */
int x;
 
for (x = 0; x < (size / 2); x++)
{
char tmp = value[x];
value [x] = value [size - 1 - x];
value [size - 1 - x] = tmp;
}
}
if (write_memory (&addr, size, 1, value))
{
xprintf ("Memory write failed\n");
}
#ifdef HAVE_BSP
bsp_flush_dcache((void *)addr.addr, size);
bsp_flush_icache((void *)addr.addr, size);
#endif
}
else
{
xprintf ("Not enough arguments\n");
return mem_cmd (USAGE);
}
}
return 0;
}
 
 
/* I am cheap and easy. */
int
mem_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("memory[.size] address [value]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("read/write memory");
return 0;
}
if (mode == LONG_HELP)
{
mem_cmd (USAGE);
long_help ("\
The memory command is used to view and modify single locations in memory.\n\
It can take a size extension, which follows the command name or partial\n\
command name without a space, and is a period followed by the number of\n\
bits to be viewed or modified. Options are 8, 16, 32, and 64. Without\n\
a size extension, the memory command defaults to displaying or changing 8\n\
bits at a time.\n\
The memory command can take one or two arguments, independent of\n\
whether a size extension is specified. With one argument, it displays the\n\
contents of the specified location. With two arguments, it replaces the\n\
contents of the specified location with the specified value.\n");
example ("\
memory.8 45f6b2 57\n\
Places the 8 bit value 57 at the location 45f6b2.");
return 0;
}
 
if (argvect[1] == NULL || (argvect[2] != NULL && argvect[3] != NULL))
{
return mem_cmd (USAGE);
}
if (argvect[1] != NULL && argvect[2] != NULL)
return poke ();
else
return peek ();
}
 
/* Memory dump function. */
 
int
dump_cmd (cmdmode_t mode)
{
mem_addr_t addr;
char value[8];
 
if (mode == USAGE)
{
usage ("dump[.size] location [count]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Memory dump command");
return 0;
}
if (mode == LONG_HELP)
{
dump_cmd (USAGE);
long_help ("\
The dump command displays a region of memory. If no count value is\n\
supplied, the command displays 16 bytes. It can take a size\n\
extension, which follows the command name or partial command name\n\
without a space, and is a period followed by the number of bits to be\n\
viewed or modified. Options are 8, 16, 32, and 64. Without a size\n\
extension, the dump command defaults to displaying 8 bits at a time.\n\
Addresses are aligned to a 16-byte boundary. Thus, dump 65 would show\n\
all bytes from 60 through 6f.\n");
example ("\
dump 44f5\n\
Displays 16 bytes starting with 44f0 and ending with 44ff.");
return 0;
}
 
if (argvect[1] != 0 && (argvect[2] == NULL || argvect[3] == NULL))
{
mem_addr_t start_addr;
char chardumps[32];
int offset;
int count;
int line;
int size = get_cmd_size ();
int i;
 
if (size == -1)
/*
* Invalid size specified.
*/
return 0;
 
str2addr (argvect[1], &addr);
if (argvect[2] != NULL)
{
count = str2int (argvect[2], 10);
count = (count + 15) / 16;
}
else
{
count = 1;
}
ADD_ALIGN(&addr, &start_addr, 16);
for (line = 0; line < count; line ++)
{
for (offset = 0; offset < 16; offset += size)
{
ADD_OFFSET(&start_addr, &addr, offset + line * 16);
 
if (offset == 0)
{
char buf[32];
addr2str (&addr, buf);
xprintf("%s: ", buf);
}
if (read_memory (&addr, size, 1, value))
{
display_memory (0, size, get_memory_display_mode ());
for (i = 0; i < size; i++)
{
value[i] = 0;
}
} else {
display_memory (value, size, get_memory_display_mode ());
}
xprintf (" ");
for (i = 0; i < size; i++)
{
chardumps[offset + i] = value[i] & 0x7f;
if (chardumps[offset + i] < 32)
chardumps[offset + i] = '.';
}
}
xprintf (" ");
for(i = 0; i < offset; i++)
{
xprintf ("%c", chardumps[i]);
}
xprintf ("\n");
}
}
else
{
dump_cmd (USAGE);
}
return 0;
}
 
static int scnt;
static int (*srec_input_char) (void);
 
static inline int
gethexnibble(void)
{
int ch;
 
inbuf[scnt++] = ch = srec_input_char();
if (ch >= '0' && ch <= '9')
return (ch - '0');
if (ch >= 'a' && ch <= 'f')
return (ch - 'a' + 10);
if (ch >= 'A' && ch <= 'F')
return (ch - 'A' + 10);
 
inbuf[scnt] = '\0';
xprintf("Bad hex char: %s\n", inbuf);
return -1;
}
 
 
static inline int
gethexbyte(void)
{
int nib;
unsigned char n;
 
if ((nib = gethexnibble()) < 0)
return -1;
n = nib << 4;
if ((nib = gethexnibble()) < 0)
return -1;
n |= nib;
return n;
}
 
static inline int
chk_cksum(unsigned int cksum, int rval)
{
int n;
 
if ((n = gethexbyte()) < 0)
return -1;
 
cksum = ~cksum & 0xff;
 
if (cksum != n)
{
inbuf[scnt] = '\0';
xprintf("Bad cksum[%02x]: %s\n", cksum, inbuf);
return -1;
}
return rval;
}
 
int
load_srec(srec_input_func_t inp_func)
{
int count, dcount, data, n, addr_bytes = 0, is_term, is_comment;
unsigned int address, cksum;
unsigned char data_buf[256];
mem_addr_t memaddr;
 
srec_input_char = inp_func;
 
is_comment = is_term = 0;
 
while (srec_input_char() != 'S')
;
 
scnt = 0;
inbuf[scnt++] = 'S';
 
if ((n = gethexnibble()) < 0)
return -1;
 
switch (n)
{
case 0:
case 5:
is_comment = 1;
break;
 
case 1:
case 2:
case 3:
addr_bytes = n + 1;
break;
 
case 7:
case 8:
case 9:
is_term = 1;
addr_bytes = 11 - n;
break;
 
default:
inbuf[scnt] = '\0';
xprintf("Bad record type: %s\n", inbuf);
return -1;
}
 
if ((count = gethexbyte()) < 0)
return -1;
cksum = count;
 
--count; /* don't count chksum */
 
if (is_comment)
{
while (count > 0)
{
if ((n = gethexbyte()) < 0)
return -1;
cksum += n;
--count;
}
return chk_cksum(cksum, 0);
}
 
address = 0;
while (count > 0 && addr_bytes)
{
if ((n = gethexbyte()) < 0)
return -1;
cksum += n;
address = (address << 8) | n;
--addr_bytes;
--count;
}
 
if (is_term)
{
if (count || addr_bytes)
{
inbuf[scnt] = '\0';
xprintf("Malformed record cnt[%d] abytes[%d]: %s\n",
count, addr_bytes, inbuf);
return -1;
}
if (chk_cksum(cksum, 1) == 1)
{
set_pc (address);
xprintf("Setting start address: 0x%08x\n", address);
return 1;
}
return -1;
}
 
dcount = 0;
 
while (count > 0)
{
if ((data = gethexbyte()) < 0)
return -1;
cksum += data;
data_buf[dcount++] = data;
--count;
}
if (chk_cksum(cksum, 0))
return -1;
 
MAKE_STD_ADDR (address, &memaddr);
write_memory (&memaddr, 1, dcount, data_buf);
#ifdef HAVE_BSP
bsp_flush_dcache((void *)memaddr.addr, dcount);
bsp_flush_icache((void *)memaddr.addr, dcount);
#endif
 
return 0;
}
 
 
int
load_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("load");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Load srecords into memory");
return 0;
}
if (mode == LONG_HELP)
{
load_cmd (USAGE);
long_help ("\
The load command switches the monitor into a state where it takes all input
as s-records and stores them in memory. The monitor exits this mode when a
termination record is hit, or certain errors (such as an invalid s-record)
cause the load to fail.");
return 0;
}
if (argvect[1] != NULL)
{
return load_cmd (USAGE);
}
 
while (!load_srec(xgetchar))
;
 
return 0;
}
 
#ifndef REGNAME_EXAMPLE
# define REGNAME_EXAMPLE "a0"
#endif
 
#if !defined(__ECOS__) || defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
int
transfer_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("$");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Transfer to gdb stub");
return 0;
}
if (mode == LONG_HELP)
{
transfer_cmd (USAGE);
long_help ("\
The transfer or $ command transfers control to the gdb stub. This function\n\
does not actually need to be called by the user, as connecting to the board\n\
with gdb will call it automatically. The transfer command takes no\n\
arguments. The $ command does not wait for a return, but executes\n\
immediately. A telnet setup in line mode will require a return when $ is\n\
executed by the user, as the host computer does not pass any characters to\n\
the monitor until a return is pressed. Disconnecting from the board in gdb\n\
automatically returns control to the monitor.");
return 0;
}
if (argvect[1] == NULL)
{
return transfer_to_stub ();
}
else
{
transfer_cmd (USAGE);
}
return 0;
}
#endif
 
static void
display_group (int which_group)
{
int len = 0;
int skipping_group = 0;
char buf[80];
int start_entry = 0;
int i;
 
if (which_group >= 0)
{
start_entry = which_group;
}
 
for (i = start_entry; regtab[i].registername != NULL; i++)
{
int buflen;
 
if (regtab[i].registernumber < 0)
{
if (which_group >= 0 && i != which_group)
{
break;
}
 
if (len > 0)
{
xprintf ("\n");
len = 0;
}
if (which_group < 0)
{
if (regtab[i].registernumber == -2)
{
skipping_group = 1;
xprintf ("[skipping %s]\n", regtab[i].registername);
}
else
{
skipping_group = 0;
xprintf ("[%s]\n", regtab[i].registername);
#if 0
len = strlen (regtab[i].registername) + 2;
while (len < MAXLINES)
{
xputchar (' ');
len++;
}
#endif
}
}
}
else
if (!skipping_group)
{
#ifdef REG_VALID_FIELD_IN_REGSTRUCT
#define REGVALID_VAL regtab[i].registervalid
#else
#define REGVALID_VAL 1
#endif
xsprintf(buf, "%4s: %s",
regtab[i].registername,
get_register_str (regtab[i].registernumber, 0 , REGVALID_VAL));
#undef REGVALID_VAL
buflen = strlen (buf);
if ((buflen + len + 3) >= 80)
{
xprintf ("\n");
len = 0;
}
else if(len > 0)
{
xprintf (" ");
len += 3;
}
 
xprintf (buf);
len += buflen;
}
}
if (len > 0)
{
xprintf ("\n");
}
}
 
static int
getregister (void)
{
int i;
if (argvect[1] == 0)
{
display_group (-1);
}
else
{
for (i = 0; regtab[i].registername != NULL; i++)
{
if (!(strcmp (argvect[1], regtab[i].registername)))
{
break;
}
}
if (regtab[i].registername == NULL)
{
xprintf ("No such register\n");
}
else
{
if (regtab[i].registernumber < 0)
{
display_group (i);
}
else
{
#ifdef REG_VALID_FIELD_IN_REGSTRUCT
#define REGVALID_VAL regtab[i].registervalid
#else
#define REGVALID_VAL 1
#endif
xprintf("%s: %s\n", argvect[1],
get_register_str (regtab[i].registernumber, 1, REGVALID_VAL));
#undef REGVALID_VAL
}
}
}
return 0;
}
 
static int
setregister (void)
{
int number = -1;
int i;
if ((argvect[1] != 0) && (argvect[2] != 0))
{
i = 0;
while (regtab[i].registername != NULL)
{
if (!(strcmp (argvect[1], regtab[i].registername)))
{
number = regtab[i].registernumber;
break;
}
i++;
}
if (number < 0)
xprintf ("Unknown register name %s\n", argvect[1]);
else
store_register (number, argvect[2]);
}
else
{
xprintf ("Not enough arguments\n");
}
return 0;
}
 
 
int
reg_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("register [register name] [value]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("View and manipulate registers");
return 0;
}
if (mode == LONG_HELP)
{
reg_cmd (USAGE);
long_help ("\
The register command allows the viewing and manipulation of register\n\
contents. It can take zero, one, or two arguments. When called with zero\n\
arguments, the register command displays the values of all registers. When\n\
called with only the register name argument, it displays the contents of\n\
the specified register. When called with both a register name and a value,\n\
it places that value into the specified register.\n");
example ("\
register " REGNAME_EXAMPLE " 1f\n\
Places the value 1f in the register " REGNAME_EXAMPLE);
return 0;
}
 
if (argvect[1] != NULL && argvect[2] != NULL)
{
if (argvect[3] != NULL)
{
return reg_cmd (USAGE);
}
return setregister ();
}
else
return getregister ();
}
 
 
/* execute the program in memory */
int
go_cmd (cmdmode_t mode)
{
#ifdef HAS_TIMER
extern tick_type start_tickcount;
#endif
 
if (mode == USAGE)
{
usage ("go [location]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Start user program execution");
return 0;
}
if (mode == LONG_HELP)
{
go_cmd (USAGE);
long_help ("\
The go command starts user program execution. It can take zero or one\n\
argument. If no argument is provided, go starts execution at the current\n\
pc. If an argument is specified, go sets the pc to that location, and then\n\
starts execution at that location.\n");
example ("
go 40020000\n\
Sets the pc to 40020000, and starts program execution.");
return 0;
}
 
if (argvect[1] != NULL && argvect[2] != NULL)
{
return go_cmd (USAGE);
}
if (argvect[1] != NULL)
{
set_pc (str2int (argvect[1], 16));
}
 
#ifdef HAS_TIMER
start_tickcount = __read_ticks ();
#endif
/* We want monitor_loop to exit now. */
return 1;
}
 
#ifdef HAS_TIMER
int
timer_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("timer [state]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Enable and disable timer");
return 0;
}
if (mode == LONG_HELP)
{
timer_cmd (USAGE);
long_help ("\
The timer command allows control of the on board timer. It takes zero\n\
or one argument. With zero arguments, it displays the state of the timer,\n\
with one argument, which can start with e or d, it enables or disables the\n\
timer, respectively.\n");
example ("\
timer e\n\
Enables the timer.");
return 0;
}
 
if (argvect[1] != NULL)
{
if (argvect[2] != NULL)
{
return timer_cmd (USAGE);
}
else if (argvect[1][0] == 'e')
{
__settimer (0, 0);
}
else if (argvect[1][0] == 'd')
{
__disable_timer ();
}
else
{
timer_cmd (USAGE);
}
}
if (__timer_enabled ())
{
xprintf ("Timer is currently enabled.\n");
}
else
{
xprintf ("Timer is currently disabled.\n");
}
return 0;
}
#endif
 
int
clear_breakpoint_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("unbreak location");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Clear breakpoint");
return 0;
}
if (mode == LONG_HELP)
{
clear_breakpoint_cmd (USAGE);
long_help ("\
The unbreak command removes breakpoints from memory. It takes one\n\
argument, the location to remove the breakpoint from.\n");
example ("\
unbreak 4ff5\n\
Removes a previously set breakpoint at memory location 4ff5.");
return 0;
}
if (argvect[1] == NULL || argvect[2] != NULL)
{
clear_breakpoint_cmd (USAGE);
}
else
{
mem_addr_t location;
str2addr (argvect[1], &location);
if (clear_mon_breakpoint (location))
{
xprintf("Unable to remove breakpoint at 0x%08lx\n", location.addr);
}
}
return 0;
}
 
 
int
breakpoint_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("break [location]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Set or display breakpoints");
return 0;
}
if (mode == LONG_HELP)
{
breakpoint_cmd (USAGE);
long_help ("\
The break command displays and sets breakpoints in memory. It takes zero\n\
or one argument. With zero arguments, it displays a list of all currently\n\
set breakpoints. With one argument it sets a new breakpoint at the\n\
specified location.\n");
example ("\
break 4ff5\n\
Sets a breakpoint at address 4ff5.");
return 0;
}
if (argvect[1] == NULL)
{
return show_breakpoints ();
}
else if (argvect[2] != NULL)
{
breakpoint_cmd (USAGE);
}
else
{
mem_addr_t location;
str2addr (argvect[1], &location);
if (add_mon_breakpoint (location))
{
xprintf("Unable to set breakpoint at 0x%08lx\n", location.addr);
}
}
return 0;
}
 
 
int
version_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("version");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Display version");
return 0;
}
if (mode == LONG_HELP)
{
version_cmd (USAGE);
long_help ("\
The version command displays the version of the monitor.");
return 0;
}
if (argvect[1] == NULL)
{
version ();
}
else
{
version_cmd (USAGE);
}
return 0;
}
 
int
set_serial_port_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("port [port number]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Set the active serial port");
return 0;
}
if (mode == LONG_HELP)
{
set_serial_port_cmd (USAGE);
long_help ("\
The port command allows control over the serial port being used by the\n\
monitor. It takes zero or one argument. Called with zero arguments it\n\
displays the port currently in use by the monitor. Called with one\n\
argument it switches the port in use by the monitor to the one specified.\n\
It then prints out a message on the new port to confirm the switch.\n");
example ("\
port 1\n\
Switches the port in use by the monitor to port 1.");
return 0;
}
if (argvect[1] != NULL && argvect[2] != NULL)
{
set_serial_port_cmd (USAGE);
return 0;
}
if (argvect [1] != NULL)
{
#ifdef HAVE_BSP
if (bsp_set_debug_comm(str2int (argvect[1], 10)) < 0)
xprintf("Invalid port number.\n");
else
/* Since we are using the new port, we just need to write
something to tell the user that this is the active port */
xprintf ("Cygmon I/O now on this port.\n");
#else
__setTty (str2int (argvect[1], 10));
/* Since we are using the new port, we just need to write
something to tell the user that this is the active port */
xprintf ("Cygmon I/O now on this port.\n");
#endif
}
else
{
xprintf ("serial port currently set to %d\n", __getTty());
return 0;
}
return 0;
}
 
int
step_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("step [location]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Single step user program");
return 0;
}
if (mode == LONG_HELP)
{
step_cmd (USAGE);
long_help ("\
The step command causes one instruction of the user program to execute, then\n\
returns control to the monitor. It can take zero or one argument. If no\n\
argument is provided, step executes one instruction at the current pc. If\n\
a location is specified, step executes one instruction at the specified\n\
location.\n");
example ("
step\n\
Executes one instruction at the current pc.");
return 0;
}
if (argvect[1] != NULL && argvect[2] != NULL)
{
step_cmd (USAGE);
return 0;
}
if (argvect[1] != NULL)
set_pc (str2int (argvect[1], 16));
__single_step ();
return 1;
 
}
 
#if HAVE_CACHE
/* This cache function needs to be in processor-specific files. */
 
int
cache_cmd (cmdmode_t mode)
{
int x;
int cache_op = CACHE_NOOP;
int which_cache = -1;
 
if (mode == USAGE)
{
usage ("cache [type] [state]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Manipulate caches");
return 0;
}
if (mode == LONG_HELP)
{
cache_cmd (USAGE);
long_help ("\
The cache command displays and changes the states of the caches. It takes\n\
zero, one, or two arguments. With no arguments, it displays the state of\n\
both the instruction cache and the data cache. With one argument, it\n\
displays the state of the specified type of cache. With two arguments, it\n\
changes the state of the specified cache to the specified state.\n");
example ("\
cache i d\n\
Disables the instruction cache.");
return 0;
}
 
if (argvect[1] != NULL && argvect[2] != NULL && argvect[3] != NULL)
{
return cache_cmd (USAGE);
}
if (argvect[1] != NULL)
{
if (argvect[1][0] == 'd')
which_cache = 0;
else if (argvect[1][0] == 'i')
which_cache = 1;
else
{
xprintf ("unknown cache type %s\n", argvect[1]);
return 0;
}
if (argvect[2] != NULL)
{
if (argvect[2][0] == 'e')
cache_op = CACHE_ENABLE;
else if (argvect[2][0] == 'd')
cache_op = CACHE_DISABLE;
else if (argvect[2][0] == 'f')
cache_op = CACHE_FLUSH;
else
{
xprintf ("Unknown cache op %s\n", argvect[2]);
return 0;
}
}
}
if (which_cache == 0 || which_cache == -1)
{
__data_cache (cache_op);
if (cache_op == CACHE_FLUSH)
{
xprintf ("Flushed dcache\n");
}
x = __data_cache (CACHE_NOOP);
xprintf ("dcache is ");
xprintf (x ? "enabled\n" : "disabled\n");
}
if (which_cache == 1 || which_cache == -1)
{
__instruction_cache (cache_op);
if (cache_op == CACHE_FLUSH)
{
xprintf ("Flushed icache\n");
}
x = __instruction_cache (CACHE_NOOP);
xprintf ("icache is ");
xprintf (x ? "enabled\n" : "disabled\n");
}
return 0;
}
#endif
 
int
set_serial_speed_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("baud speed");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Set serial port baud rate");
return 0;
}
if (mode == LONG_HELP)
{
set_serial_speed_cmd (USAGE);
long_help ("\
The baud command sets the speed of the active serial port. It takes one\n\
argument, which specifies the speed to which the port will be set.\n");
example ("\
baud 9600\n\
Sets the speed of the active port to 9600 baud.");
return 0;
}
 
if (argvect[1] == NULL || argvect[2] != NULL)
{
return set_serial_speed_cmd (USAGE);
}
else
{
#ifdef HAVE_BSP
int channel_id = bsp_set_debug_comm(-1);
int baud = str2int (argvect[1], 10);
 
xprintf("Setting serial baud rate on channel %d to %d baud\n",
channel_id, baud);
 
if (bsp_set_serial_baud(bsp_set_debug_comm(-1),
str2int (argvect[1], 10)) < 0)
xprintf("Invalid baud rate\n");
#else
__set_baud_rate (str2int (argvect[1], 10));
#endif
}
return 0;
}
 
 
int
set_term_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("terminal type");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Set the terminal type");
return 0;
}
if (mode == LONG_HELP)
{
set_term_cmd (USAGE);
long_help ("\
The terminal command sets the type of the current terminal to that specified\n\
in the type argument. The only available terminal types are vt100 and dumb.\n\
This is used by the line editor to determine how to update the terminal\n\
display.\n");
example ("\
terminal dumb\n\
Sets the type of the current terminal to a dumb terminal.\n");
return 0;
}
 
if (argvect[1] == NULL || argvect[2] != NULL)
set_term_cmd (USAGE);
else
set_term_name (argvect[1]);
return 0;
}
 
int
reset_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("reset");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Reset the board (not on all architectures).");
return 0;
}
if (mode == LONG_HELP)
{
reset_cmd (USAGE);
long_help ("\
The reset command resets the board. This may not be implemented\n\
on all architectures");
return 0;
}
 
if (argvect[1] != NULL)
{
reset_cmd (USAGE);
}
else
{
__reset ();
}
return 0;
}
 
#if HAVE_USAGE
int
memusage_cmd (cmdmode_t mode)
{
extern int sdata, _end;
 
if (mode == USAGE)
{
usage ("usage");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Show monitor memory usage");
return 0;
}
if (mode == LONG_HELP)
{
memusage_cmd (USAGE);
long_help ("\
The usage command shows the amount of memory being used by the monitor,\n\
broken down by category. Despite its name, it has nothing to do with the\n\
usage of any other command.\n");
return 0;
}
 
if (argvect[1] != NULL)
{
return memusage_cmd (USAGE);
}
else
{
xprintf ("%d bytes were allocated with sbrk\n", (char *)sbrk (0) - (char *)&_end);
}
return 0;
}
#endif /* HAVE_USAGE */
 
int
disassemble_cmd (cmdmode_t mode)
{
#ifdef DISASSEMBLER
int x;
 
if (mode == USAGE)
{
usage ("disassemble [location]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Disassemble memory");
return 0;
}
if (mode == LONG_HELP)
{
disassemble_cmd (USAGE);
long_help ("\
The disassemble command disassembles the contents of memory. Because of the\n\
way breakpoints are handled, all instructions are shown and breakpoints are\n\
not visible in the disassembled code. The disassemble command takes zero\n\
or one argument. When called with zero arguments, it starts disassembling\n\
from the current (user program) pc. When called with a location, it starts\n\
disassembling from the specified location. When called after a previous\n\
call and with no arguments, it disassembles the next area of memory after\n\
the one previously disassembled.\n");
example ("\
disassemble 45667000\n\
Displays disassembled code starting at location 45667000.");
return 0;
}
if (argvect [1] != NULL && argvect[2] != NULL)
{
return disassemble_cmd (USAGE);
}
 
if(argvect [1] != NULL)
str2addr (argvect [1], &last_pc);
for (x = 0; x < 10; x++)
last_pc = do_dis (&last_pc);
flush_dis ();
#else
#warning "DISASSEMBLER not implemented"
xprintf ("disassembler not available\n");
#endif
 
return 0;
}
 
int
copy_cmd (cmdmode_t mode)
{
mem_addr_t src, dst;
target_register_t size;
 
if (mode == USAGE)
{
usage ("copy startaddr destaddr amount");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Copies one area of memory to another");
return 0;
}
if (mode == LONG_HELP)
{
copy_cmd (USAGE);
long_help ("\
The copy command is used to copy 'amount' bytes of memory\n\
from 'startaddr' to 'destaddr'\n");
example ("\
copy 10000 20000 300\n\
Copies 0x300 bytes of memory from 0x10000 to 0x20000.");
return 0;
}
if (argvect[1] == NULL || argvect[2] == NULL || argvect[3] == NULL
|| argvect[4] != NULL)
{
return copy_cmd (USAGE);
}
str2addr (argvect[1], &src);
str2addr (argvect[2], &dst);
size = str2int (argvect[3], 16);
while (size > 0)
{
char buf[128];
 
int msize = (size > 128) ? 128 : size;
if (read_memory (&src, 1, msize, buf))
{
xprintf ("Memory read failed\n");
break;
}
if (write_memory (&dst, 1, msize, buf))
{
xprintf ("Memory write failed\n");
break;
}
#ifdef HAVE_BSP
bsp_flush_dcache((void *)dst.addr, msize);
bsp_flush_icache((void *)dst.addr, msize);
#endif
ADD_OFFSET (&src, &src, msize);
ADD_OFFSET (&dst, &dst, msize);
size -= msize;
}
return 0;
}
 
#ifndef HAVE_BSP
int
set_program_args_cmd (cmdmode_t mode)
{
int argc;
 
if (mode == USAGE)
{
usage ("setargs [args]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Sets the program arguments passed to main()");
return 0;
}
if (mode == LONG_HELP)
{
set_program_args_cmd (SHORT_HELP);
return 0;
}
for (argc = 1; argvect[argc] != NULL; argc++)
;
__set_program_args (argc - 1, argvect + 1);
return 0;
}
#endif
 
 
int
fill_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("fill[.size] startaddress endaddress [value]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Fills memory with a specified value");
return 0;
}
if (mode == LONG_HELP)
{
fill_cmd (USAGE);
long_help("\
The fill command is used to fill a region of memory from 'startaddress'\n\
to 'endaddress' with the value in 'value'. If no value is specificed,\n\
it uses zero. It can take a size extension, which follows the command\n\
name or partial command name without a space, and is a period followed\n\
by the size of the writes that are used, in bits. Options are 8, 16,\n\
32, and 64. Without a size extension, the fill command defaults to\n\
changing 8 bits at a time.\n");
example ("\
fill.32 10000 20000 32\n\
Fills the region between 0x10000 and 0x20000 with the 32 bit value 0x32.");
return 0;
}
if ((argvect[1] == NULL || argvect[2] == NULL)
|| (argvect[3] != NULL && argvect[4] != NULL))
{
fill_cmd (USAGE);
return 0;
} else {
mem_addr_t start,end;
char value[8];
int size = get_cmd_size();
int amt;
 
if (size == -1)
/*
* Invalid size specified.
*/
return 0;
 
if (argvect[3] != NULL)
{
hex2bytes (argvect[3], value, size);
}
else
{
hex2bytes ("0", value, size);
}
str2addr (argvect[1], &start);
str2addr (argvect[2], &end);
amt = MEM_ADDR_DIFF (end, start);
if (amt < 0)
{
xprintf ("Addresses in incorrect order\n");
}
else
{
int x;
if (get_memory_display_mode ())
{
/* Gotta swap this puppy. */
int x;
 
for (x = 0; x < (size / 2); x++)
{
char tmp = value[x];
value [x] = value [size - 1 - x];
value [size - 1 - x] = tmp;
}
}
 
xprintf ("Writing %d units\n", amt / size + 1);
for (x = amt / size; x >= 0; x--)
{
if (write_memory (&start, size, 1, value))
{
xprintf ("Memory write failed\n");
break;
}
ADD_OFFSET (&start, &start, size);
}
}
}
return 0;
}
 
 
int
swapmem_cmd (cmdmode_t mode)
{
int display_settings = 0;
 
if (mode == USAGE)
{
usage ("swapmem [little|big]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Sets whether or not memory values are byte-swapped");
return 0;
}
if (mode == LONG_HELP)
{
swapmem_cmd (USAGE);
 
long_help("\
The swapmem command is used to determine whether or not memory values are\n\
displayed and written in little or big-endian byte order. By default, values\n\
are read and written to match the byte order of the target CPU.\n\
This command does not alter the CPU state in any way; it only changes the\n\
way memory values are displayed and written within the monitor.\n");
example("\
swapmem \n\
Displays the byte order that is currently in effect.");
return 0;
display_settings = 1;
}
else
{
if (argvect[1] != NULL && argvect[2] != NULL)
{
swapmem_cmd (USAGE);
return 0;
}
}
if (display_settings || argvect[1] == NULL)
{
if (get_memory_display_mode ())
{
xprintf ("Memory values are read and written in little-endian byte order.\n");
}
else
{
xprintf ("Memory values are read and written in big-endian byte order.\n");
}
return 0;
}
if (strncmp (argvect[1], "little", strlen (argvect[1])) == 0)
{
set_memory_display_mode (1);
xprintf ("Memory values are now read and written in little-endian order.\n");
}
else if (strncmp (argvect[1], "big", strlen (argvect[1])) == 0)
{
set_memory_display_mode (0);
xprintf ("Memory values are now read and written in big-endian order.\n");
}
else
{
return swapmem_cmd (USAGE);
}
return 0;
}
 
#ifdef MONITOR_CONTROL_INTERRUPTS
int
int_cmd (cmdmode_t mode)
{
if (mode == USAGE)
{
usage ("interrupt [on|off]");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("Enables or disables interrupts within the monitor");
return 0;
}
if (mode == LONG_HELP)
{
int_cmd (USAGE);
long_help("\
The interrupt command is used to enable or disable interrupts while the\n\
monitor is running.");
return 0;
}
if (argvect[1] != NULL && argvect[2] != NULL)
{
int_cmd (USAGE);
return 0;
}
if (argvect[1] != NULL)
{
if (strcmp (argvect[1], "on") == 0)
{
monitor_enable_interrupts ();
}
else if (strcmp (argvect[1], "off") == 0)
{
monitor_disable_interrupts ();
}
else
{
int_cmd (USAGE);
return 0;
}
}
xprintf ("Interrupts ");
if (monitor_interrupt_state ())
{
xprintf ("enabled\n");
}
else
{
xprintf ("disabled\n");
}
return 0;
}
#endif
 
 
/* Table used by the crc32 function to calcuate the checksum. */
static uint32 crc32_table[256];
static int crc_initted = 0;
 
static uint32
crc32 (unsigned char *buf, int len, uint32 crc)
{
if (! crc_initted)
{
/* Initialize the CRC table and the decoding table. */
int i, j;
uint32 c;
 
crc_initted = 1;
for (i = 0; i < 256; i++)
{
for (c = i << 24, j = 8; j > 0; --j)
c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1);
crc32_table[i] = c;
}
}
 
while (len--)
{
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ *buf) & 255];
buf++;
}
return crc;
}
 
 
int
checksumcmd (cmdmode_t mode)
{
mem_addr_t start, end;
uint32 crc = 0xffffffff;
 
if (mode == USAGE)
{
usage ("crc startaddr endaddr");
return 0;
}
if (mode == SHORT_HELP)
{
short_help ("checksum an area of memory");
return 0;
}
if (mode == LONG_HELP)
{
checksumcmd (USAGE);
long_help ("\
The crc command is used to calculate a standard CRC32 checksum of the\n\
specified memory region. The checksum is printed out as a hexadecimal\n\
value.");
return 0;
}
if (argvect[1] == NULL || argvect[2] == NULL || argvect[3] != NULL)
{
return checksumcmd (USAGE);
}
 
str2addr (argvect[1], &start);
str2addr (argvect[2], &end);
while (start.addr < end.addr)
{
char c[1024];
int len = end.addr - start.addr;
if (len > sizeof(c))
len = sizeof(c);
read_memory (&start, 1, len, c);
crc = crc32 (c, len, crc);
start.addr += len;
}
xprintf("0x%08lx is checksum\n", crc);
return 0;
}
 
char **argvect;
static char argvect_cmd[MAXLINELEN];
 
static char **
buildargv (char *input)
{
static char *arglist[256];
int numargs = 0;
 
while (1)
{
while (isspace ((unsigned char)*input) && *input != 0)
input++;
if (*input == 0)
break;
arglist [numargs++] = input;
while (!isspace ((unsigned char)*input) && *input != 0)
input++;
if (*input == 0)
break;
*(input++) = 0;
}
arglist [numargs] = NULL;
return arglist;
}
 
 
int
monitor_loop (void)
{
int state = 1, return_value = 0;
 
while (state == 1)
{
/* Get a line of input, putting it in the input buffer */
lineedit (PROMPT, inbuf, sizeof (inbuf));
xprintf ("\n");
 
if (switch_to_stub_flag)
{
#ifndef HAVE_BSP
switch_to_stub_flag = 0;
#endif
return transfer_to_stub ();
}
 
/* Separate off the command from any other stuff on the line */
strcpy (argvect_cmd, inbuf);
argvect = buildargv (argvect_cmd);
 
if (argvect[0] != NULL && argvect[0][0] != '\0')
{
char *ptr;
int command_number;
 
strcpy (cmd, argvect[0]);
 
/* Function to split off . delimiters. */
ptr = strchr (cmd, '.');
 
if (ptr != NULL && *ptr == '.')
*ptr = '\0';
 
/* See if it's an alias. */
command_number = alias_compare (cmd);
 
/* Compare input to command list, check for conflicts. */
if (command_number < 0)
command_number = command_compare (cmd);
 
/* If we found a command, just run the function */
if (command_number >= 0)
{
int status;
/* Execute the function, if the function returns a non-zero
value, break out of the loop and return. */
status = (*cmdtab[command_number].function) (INVOCATION);
if (status)
{
state = 0;
if (status < 0)
return_value = 1;
}
}
else
{
/* If none of the commands or aliases match, complain. */
xprintf ("Not a legal command\n");
}
if (inbuf[0] != '\0')
addHistoryCmd (inbuf);
}
}
return return_value;
}
 
 
/misc/generic_mem.c
0,0 → 1,99
//==========================================================================
//
// generic_mem.c
//
// Routines for reading and writing memory.
//
//==========================================================================
//####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):
// Contributors: gthomas, dmoseley
// Date: 1999-10-20
// Purpose:
// Description: It may be appropriate to relay directly into the stubs
// implementation of read memory, without board specific
// considerations such as checking the allowed ranges of
// addresses. Perhaps there needs to be some consideration
// of address spaces or, masking addresses.
//
// This file implements a default version of reading and writing
// memory when none of this is an issue
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#ifdef HAVE_BSP
#include <bsp/bsp.h>
#include "cpu_info.h"
#endif
#include "board.h"
#include "monitor.h"
#include "tservice.h"
 
#ifndef HAVE_BSP
#include "generic-stub.h"
#endif
 
 
int
read_memory (mem_addr_t *src, int size, int amt, char *dst)
{
#if defined(HAVE_BSP) && !defined(USE_ECOS_HAL_SAFE_MEMORY)
return (bsp_memory_read((unsigned char *)src->addr, MEM_ADDR_ASI(src),
size << 3, amt, dst) != amt);
#else
int totamt = size * amt;
return (totamt != __read_mem_safe (dst, (void*)src->addr, totamt));
#endif
}
 
int
write_memory (mem_addr_t *dst, int size, int amt, char *src)
{
#if defined(HAVE_BSP) && !defined(USE_ECOS_HAL_SAFE_MEMORY)
return (bsp_memory_write((unsigned char *)dst->addr, MEM_ADDR_ASI(dst),
size << 3, amt, src) != amt);
#else
int totamt = size * amt;
return (totamt != __write_mem_safe (src, (void*)dst->addr, totamt));
#endif
}
 
 
/misc/unistd.h
0,0 → 1,54
//==========================================================================
//
// unistd.h
//
// Standard Unix/POSIX environment
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Placeholder only
/misc/mn10300/mn10300-mon.c
0,0 → 1,206
//==========================================================================
//
// mn10300-mon.c
//
// Support code to extend the generic monitor code to support
// MN10300 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): dmoseley
// Contributors: dmoseley
// Date: 2000-08-11
// Purpose: Support code to extend the generic monitor code to support
// MN10300 processors.
// Description: Further board specific support is in other files.
// This file contains:
// register names lookup table
//
// Empty Stubs:
// Interval timer - This should really belong to the application
// operating system.
//
// Should not contain:
// low level uart getchar and putchar functions
// delay function to support uart
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include "monitor.h"
 
struct regstruct regtab[] =
{
{"d0", D0, 1},
{"d1", D1, 1},
{"d2", D2, 1},
{"d3", D3, 1},
{"a0", A0, 1},
{"a1", A1, 1},
{"a2", A2, 1},
{"a3", A3, 1},
{"sp", SP, 1},
{"pc", PC, 1},
{"mdr", MDR, 1},
{"psw", PSW, 1},
{"lir", LIR, 1},
{"lar", LAR, 1},
#ifdef CYGPKG_HAL_MN10300_AM33
{"r0", R0, 1},
{"r1", R1, 1},
{"r2", R2, 1},
{"r3", R3, 1},
{"r4", R4, 1},
{"r5", R5, 1},
{"r6", R6, 1},
{"r7", R7, 1},
{"ssp", SSP, 1},
{"msp", MSP, 1},
{"usp", USP, 1},
{"mcrh", MCRH, 1},
{"mcrl", MCRL, 1},
{"mcvf", MCVF, 1},
{"mdrq", MDRQ, 1},
#if CYGHWR_HAL_MN10300_AM33_REVISION == 2
{"fpcr", FPCR, 1},
{"fs0", FS0, 1},
{"fs1", FS1, 1},
{"fs2", FS2, 1},
{"fs3", FS3, 1},
{"fs4", FS4, 1},
{"fs5", FS5, 1},
{"fs6", FS6, 1},
{"fs7", FS7, 1},
{"fs8", FS8, 1},
{"fs9", FS9, 1},
{"fs10", FS10, 1},
{"fs11", FS11, 1},
{"fs12", FS12, 1},
{"fs13", FS13, 1},
{"fs14", FS14, 1},
{"fs15", FS15, 1},
{"fs16", FS16, 1},
{"fs17", FS17, 1},
{"fs18", FS18, 1},
{"fs19", FS19, 1},
{"fs20", FS20, 1},
{"fs21", FS21, 1},
{"fs22", FS22, 1},
{"fs23", FS23, 1},
{"fs24", FS24, 1},
{"fs25", FS25, 1},
{"fs26", FS26, 1},
{"fs27", FS27, 1},
{"fs28", FS28, 1},
{"fs29", FS29, 1},
{"fs30", FS30, 1},
{"fs31", FS31, 1},
#endif
#endif
{ 0, 0, 1}, /* Terminating element must be last */
} ;
 
void
initialize_mon(void)
{
} /* initialize_mon */
 
#if CYGHWR_HAL_MN10300_AM33_REVISION == 2
extern int fpu_regs_read;
#endif
 
#ifdef CYGPKG_HAL_MN10300_AM33
extern int msp_read;
#endif
 
void
initialize_mon_each_time(void)
{
int i;
#if CYGHWR_HAL_MN10300_AM33_REVISION == 2
// Make sure the regtab[] indicates the valid status of the FPU registers
for (i = 0; regtab[i].registername != NULL; i++)
{
if ((regtab[i].registernumber >= FP_START) && (regtab[i].registernumber <= FP_END))
regtab[i].registervalid = fpu_regs_read;
}
#endif
 
#ifdef CYGPKG_HAL_MN10300_AM33
// Make sure the regtab[] indicates the valid status of the MSP
for (i = 0; regtab[i].registername != NULL; i++)
{
if (regtab[i].registernumber == MSP)
regtab[i].registervalid = msp_read;
}
#endif
} /* initialize_mon_each_time */
 
 
#include <cyg/hal/hal_arch.h>
#include <bsp/common/bsp_if.h>
int
machine_syscall(HAL_SavedRegisters *regs)
{
int res, err;
target_register_t d0, d1, d2, d3;
 
d0 = get_register(D0);
d1 = get_register(D1);
d2 = get_register(D2);
d3 = get_register(D3);
 
err = _bsp_do_syscall(d0, // Function
d1, d2, d3, 0, // arguments,
&res);
if (err)
{
// This was a syscall. It has now been handled, so update the registers appropriately
put_register(D0, res);
bsp_skip_instruction(regs);
}
 
return err;
}
 
 
// Utility function for printing breakpoints
void bp_print(target_register_t bp_val)
{
bsp_printf("0x%08lx\n", (unsigned long)bp_val);
}
/misc/mn10300/cpu_info.h
0,0 → 1,91
#ifndef __MN10300_CPU_INFO_H__
#define __MN10300_CPU_INFO_H__
//==========================================================================
//
// cpu_info.h
//
// Architecture information for MN10300 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): dmoseley
// Contributors: dmoseley
// Date: 2000-08-11
// Purpose:
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#define IS_MN10300 1
 
/* Temporary as long a multiple protypes are copied in multiple files */
/* This variation does NOT clone the prototypes */
#define NO_MALLOC 1
 
#ifndef USE_ECOS_HAL_BREAKPOINTS
 
/* big enuf to store a trap in the BP structure */
 
#define BP_INST_T_DEFINED 1
typedef unsigned char bp_inst_t ;
 
#else /* USE_ECOS_HAL_BREAKPOINTS */
 
#define MEM_ADDR_DEFINED 1
typedef struct mem_addr {
unsigned long addr;
} mem_addr_t ;
 
#endif /* USE_ECOS_HAL_BREAKPOINTS */
 
typedef unsigned long target_register_t;
 
#include <cyg/infra/cyg_type.h>
#include <cyg/hal/basetype.h>
#define PRINT_INSN print_insn_mn10300
 
#undef BFD_MACH
#define BFD_MACH 0
 
// Ensure that the reg_valid field in regstruct is used.
#define REG_VALID_FIELD_IN_REGSTRUCT
#define INITIALIZE_MON_EACH_TIME() initialize_mon_each_time()
extern void initialize_mon_each_time(void);
 
#endif // __MN10300_CPU_INFO_H__
/misc/mn10300/board.h
0,0 → 1,103
#ifndef __CYGMON_MN10300_BOARD_H__
#define __CYGMON_MN10300_BOARD_H__
//==========================================================================
//
// board.h
//
// Cygmon board/platform configuration file
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-08-11
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
// Hardware/platform/configuration specifics
 
// These defines are only necessary for using target_reg union in monitor.h
// It should be possible to remove that once the HAL integration is complete.
#if CYGHWR_HAL_MN10300_AM33_REVISION == 2
#define HAVE_FLOAT_REGS 1
#else
#define HAVE_FLOAT_REGS 0
#endif
#define HAVE_DOUBLE_REGS 0
 
#define HAVE_CACHE 0
#define HAVE_USAGE 0
#define USE_CYGMON_PROTOTYPES 1
#define NOMAIN 1
#define CYGMON_SYSTEM_SERVICES 0 // Not used, fall back to BSP/HAL support
 
#ifdef CYGDAT_CYGMON_USE_HELP
#define USE_HELP 1
#endif
 
#define USE_ECOS_HAL_EXCEPTIONS
#define USE_ECOS_HAL_BREAKPOINTS
#define USE_ECOS_HAL_SINGLESTEP
#define USE_ECOS_HAL_SAFE_MEMORY
extern int __read_mem_safe (void *dst, void *src, int count);
extern int __write_mem_safe (void *src, void *dst, int count);
 
 
#include "cpu_info.h"
extern void bp_print (target_register_t bp_val);
extern int __set_breakpoint (target_register_t addr);
extern int __remove_breakpoint (target_register_t addr);
extern void __install_breakpoint_list (void);
extern void __clear_breakpoint_list (void);
extern int __display_breakpoint_list (void (*print_func)(target_register_t));
 
#define bsp_skip_instruction(regs) __skipinst()
#define install_breakpoints() __install_breakpoints()
#define add_mon_breakpoint(bpt) __set_breakpoint((bpt).addr)
#define clear_mon_breakpoint(bpt) __remove_breakpoint((bpt).addr)
#define show_breakpoints() __display_breakpoint_list(bp_print)
#define clear_breakpoints() __clear_breakpoint_list()
 
#define bsp_get_signal(exc_nr, regs) __computeSignal(exc_nr)
#define bsp_get_pc(regs) get_register(PC)
#define bsp_set_pc(pc, regs) put_register(PC, pc);
 
#endif // __CYGMON_MN10300_BOARD_H__
/misc/mn10300/cpu.h
0,0 → 1,61
#ifndef __MN10300_CPU_H__
#define __MN10300_CPU_H__
//==========================================================================
//
// cpu.h
//
// MN10300 specific processor defines
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-08-11
// Purpose: MN10300 specific processor defines
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include <cyg/hal/hal_intr.h>
 
#define BSP_MAX_EXCEPTIONS CYGNUM_HAL_VSR_COUNT
 
#define REG_PC PC
 
#endif // __MN10300_CPU_H__
/misc/cpu-mon.c
0,0 → 1,61
//==========================================================================
//
// cpu-mon.c
//
// eCos BSP (for building Cygmon)
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas, dmoseley
// Date: 1999-10-11
// Description: Architecture support for Cygmon
//####DESCRIPTIONEND####
 
#include <pkgconf/system.h> // Configuration header
 
#ifdef CYGPKG_HAL_ARM
#include "arm/arm-mon.c"
#endif
 
#ifdef CYGPKG_HAL_MIPS
#include "mips/mips-mon.c"
#endif
 
#ifdef CYGPKG_HAL_MN10300
#include "mn10300/mn10300-mon.c"
#endif
/misc/monitor_cmd.h
0,0 → 1,126
//==========================================================================
//
// monitor_cmd.h
//
// Monitor command definitions for the CygMON ROM monitor
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Monitor command definitions for the CygMON ROM monitor
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#ifndef MONITOR_CMD_H
#define MONITOR_CMD_H
 
#ifndef ASM
typedef enum {
INVOCATION, USAGE, SHORT_HELP, LONG_HELP
} cmdmode_t;
 
struct cmdentry
{
char *alias;
char *cmd;
int (*function) (cmdmode_t);
};
 
extern struct cmdentry cmdtab [];
 
extern int monitor_loop (void);
 
extern char inbuf[];
 
extern char **argvect;
 
typedef int (*srec_input_func_t)(void);
 
extern int load_srec(srec_input_func_t inp_func);
 
#ifdef USE_HELP
extern void usage (char *string);
extern void short_help (char *string);
extern void long_help (char *string);
extern void example (char *string);
#else
#define usage(x) no_help_usage ()
#define short_help(x) no_help()
#define long_help(x) no_help()
#define example(x)
extern void no_help (void);
extern void no_help_usage (void);
#endif
extern int help_cmd (cmdmode_t mode);
extern int mem_cmd (cmdmode_t mode);
 
extern int dump_cmd (cmdmode_t mode);
extern int ethaddr_cmd (cmdmode_t mode);
extern int ipaddr_cmd (cmdmode_t mode);
extern int tcpport_cmd (cmdmode_t mode);
extern int load_cmd (cmdmode_t mode);
extern int reg_cmd (cmdmode_t mode);
extern int go_cmd (cmdmode_t mode);
extern int othernames_cmd (cmdmode_t mode);
extern int step_cmd (cmdmode_t mode);
extern int transfer_cmd (cmdmode_t mode);
extern int timer_cmd (cmdmode_t mode);
extern int disassemble_cmd (cmdmode_t mode);
extern int breakpoint_cmd (cmdmode_t mode);
extern int clear_breakpoint_cmd (cmdmode_t mode);
extern int memusage_cmd (cmdmode_t mode);
extern int set_serial_port_cmd (cmdmode_t mode);
extern int set_serial_speed_cmd (cmdmode_t mode);
extern int version_cmd (cmdmode_t mode);
extern int cache_cmd (cmdmode_t mode);
extern int set_term_cmd (cmdmode_t mode);
extern int reset_cmd (cmdmode_t mode);
extern int copy_cmd (cmdmode_t mode);
extern int fill_cmd (cmdmode_t mode);
extern int set_program_args_cmd (cmdmode_t mode);
extern int swapmem_cmd (cmdmode_t mode);
extern int checksumcmd (cmdmode_t mode);
extern int int_cmd (cmdmode_t mode);
#endif
 
#endif
/misc/Notes_CygMon_PID
0,0 → 1,168
===========================================================================
#####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####
===========================================================================
 
28 Jan 2000
 
How to build and install CygMon on the PID
 
Make CygMon image
~~~~~~~~~~~~~~~~~
 
Configure and build using the 'cygmon' template for the PID
target. These are the necessary CLI instructions. It can also be done
from the Configtool by selecting the appropriate templates.
 
% cd /tmp
% mkdir cygmon
% cd cygmon
% ecosconfig new pid cygmon
% ecosconfig tree
% make
 
This will install some files in ./install/bin:
 
cygmon.elf: The built CygMon image
cygmon.bin: The image converted to binary (suitable for burning to ROM)
cygmon.img: The relocated ELF image (suitable for FLASH writing, see below)
cygmon.srec: The image converted to srecords
 
Make FLASH tool
~~~~~~~~~~~~~~~
 
Again, these are the necessary CLI instructions. It can also be done
from the Configtool by selecting the appropriate templates, and
enabling the option.
 
% cd /tmp
% mkdir pid-flash
% cd pid-flash
% ecosconfig new pid
% <edit ecos.ecc, enabling the CYGBLD_BUILD_FLASH_TOOL option:>
--- ecos.ecc.orig Fri Jan 28 11:21:43 2000
+++ ecos.ecc Fri Jan 28 11:22:01 2000
@@ -150,7 +150,7 @@
cdl_option CYGBLD_BUILD_FLASH_TOOL {
# Flavor: bool
# No user value, uncomment the following line to provide one.
- # user_value 0
+ user_value 1
# value_source default
# Default value: 0
# Requires: CYG_HAL_STARTUP == "RAM"
% ecosconfig resolve
% ecosconfig tree
% make
 
The flash tool is installed in ./install/bin
 
Prepare board for CygMon
~~~~~~~~~~~~~~~~~~~~~~~~
1. Set jumper 7-8 on LK6 [using the Angle code in the 16 bit EPROM]
2. Set jumper 5-6 on LK6 [select 8bit ROM mode]
3. Set jumper LK18 [ROM remap - this is also required for eCos]
4. Set S1 to 0-0-1-1 [20MHz operation]
 
 
Program FLASH
~~~~~~~~~~~~~
1. Download the CygMon relocated image onto the PID board:
% cd /tmp
% arm-elf-gdb -nw cygmon/install/bin/cygmon.img
 
(gdb) target rdi s=<serial device>
Angel Debug Monitor V1.04 (Advanced RISC Machines SDT 2.11a) for PID
Built with Serial(x1), Parallel, DCC
Rebuilt on Apr 7 1998 at 22:20:43
Serial Rate: 9600
Connected to ARM RDI target.
(gdb) load
Loading section .rom_vectors, size 0x60 lma 0x60000
Loading section .text, size 0xeea8 lma 0x60060
Loading section .rodata, size 0x304c lma 0x6ef08
Loading section .data, size 0x7f8 lma 0x71f54
Start address 0x60060 , load size 75596
Transfer rate: 5548 bits/sec.
(gdb) quit
 
This will download the stubs onto the board at 0x60000..0x80000
 
Use /dev/ttyS0, COM1 or similar for the <serial device> name.
 
2. Now download the FLASH programmer tool
% arm-elf-gdb -nw pid-flash/install/bin/prog_flash.img
 
(gdb) target rdi s=<serial device>
Angel Debug Monitor V1.04 (Advanced RISC Machines SDT 2.11a) for PID
Built with Serial(x1), Parallel, DCC
Rebuilt on Apr 7 1998 at 22:20:43
Serial Rate: 9600
Connected to ARM RDI target.
(gdb) load
Loading section .rom_vectors, size 0x60 lma 0x4000
Loading section .text, size 0x4964 lma 0x4060
Loading section .rodata, size 0x384 lma 0x89c4
Loading section .data, size 0x28c lma 0x8d48
Start address 0x4060 , load size 20436
Transfer rate: 5449 bits/sec.
(gdb) cont
 
3. The FLASH tool will output some text on the board serial port B at
38400 baud:
 
ARM eCos
FLASH here!
manuf: 8, device: 40
Error: Wrong Manufaturer: 08
... Please change FLASH jumper
 
4. This text is repeated until you remove the jumper 7-8 on LK6. Then
the output should be:
 
manuf: 1F, device: A4
AT29C040A recognised
About to program FLASH using data at 60000..80000
*** Press RESET now to abort!
5. You have about 10 seconds to abort the operation by pressing
reset. After this timeout, the FLASH programming happens:
...Programming FLASH
All done!
 
6. Quit/kill the GDB process which will hang.
 
7. Next time you reset the board, CygMon will be in control, communicating
on serial port A at 38400 baud. See documentation for further details
on how to connect with GDB.
/misc/bplist-dynamic.c
0,0 → 1,234
//==========================================================================
//
// bplist-dynamic.c
//
// Breakpoint list using dynamic memory.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Breakpoint list using dynamic memory.
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include "board.h"
 
#ifndef USE_ECOS_HAL_BREAKPOINTS
 
#include <stdlib.h>
 
#ifndef NO_MALLOC
#ifndef NO_MALLOC_H
#include "malloc.h"
#else
void free ();
char *malloc ();
#endif
#endif
 
#ifdef __ECOS__
#include <cyg/hal/plf_stub.h>
#endif /* __ECOS__ */
 
/*
* A simple target breakpoint list using malloc.
* To use this package, you must define TRAP_SIZE to be the size
* in bytes of a trap instruction (max if there's more than one),
* and export a char array called _breakinst that contains a
* breakpoint trap. This package will copy trap instructions
* from _breakinst into the breakpoint locations.
*/
 
static struct breakpoint_list {
target_register_t addr;
char old_contents [TRAP_SIZE];
struct breakpoint_list *next;
char in_memory;
} *breakpoint_list = NULL;
 
#ifdef NO_MALLOC
static struct breakpoint_list bp_list [MAX_BP_NUM];
static struct breakpoint_list *free_bp_list = NULL;
static int curr_bp_num = 0;
#endif
 
#ifndef BREAKINST_DEFINED
#define BREAKINST_DEFINED
extern unsigned char _breakinst[];
#endif
 
int
__set_breakpoint (target_register_t addr)
{
struct breakpoint_list **addent = &breakpoint_list;
struct breakpoint_list *l = breakpoint_list;
struct breakpoint_list *newent;
 
while (l != NULL && l->addr < addr)
{
addent = &l->next;
l = l->next;
}
 
if (l != NULL && l->addr == addr)
return 2;
 
#ifdef NO_MALLOC
if (free_bp_list != NULL)
{
newent = free_bp_list;
free_bp_list = free_bp_list->next;
}
else
{
if (curr_bp_num < MAX_BP_NUM)
{
newent = &bp_list[curr_bp_num++];
}
else
{
return 1;
}
}
#else
newent = (struct breakpoint_list *) malloc (sizeof (struct breakpoint_list));
#endif
newent->addr = addr;
newent->in_memory = 0;
newent->next = l;
*addent = newent;
return 0;
}
 
int
__remove_breakpoint (target_register_t addr)
{
struct breakpoint_list *l = breakpoint_list;
struct breakpoint_list *prev = NULL;
 
while (l != NULL && l->addr < addr)
{
prev = l;
l = l->next;
}
 
if (l == NULL)
return 1;
 
if (l->in_memory)
{
__write_mem_safe (&l->old_contents[0],
(void*)l->addr,
sizeof (l->old_contents));
}
 
if (prev == NULL)
breakpoint_list = l->next;
else
prev->next = l->next;
 
#ifdef NO_MALLOC
l->next = free_bp_list;
free_bp_list = l;
#else
free (l);
#endif
return 0;
}
 
#include <cyg/hal/generic-stub.h>
#include <cyg/hal/hal_stub.h>
void
__cygmon_install_breakpoints (void)
{
struct breakpoint_list *l = breakpoint_list;
 
while (l != NULL)
{
if (! l->in_memory)
{
int len = sizeof (l->old_contents);
 
if (__read_mem_safe (&l->old_contents[0], (void*)l->addr, len) == len)
{
#ifdef WRITE_MEM_IS_MEMCPY
if (__write_mem_safe (_breakinst, (void*)l->addr, len) == (void*)l->addr)
#else
if (__write_mem_safe (_breakinst, (void*)l->addr, len) == len)
#endif
{
l->in_memory = 1;
}
}
}
l = l->next;
}
flush_i_cache ();
}
 
void
__cygmon_clear_breakpoints (void)
{
struct breakpoint_list *l = breakpoint_list;
 
while (l != NULL)
{
if (l->in_memory)
{
int len = sizeof (l->old_contents);
 
#ifdef WRITE_MEM_IS_MEMCPY
if (__write_mem_safe (_breakinst, (void*)l->addr, len) == (void*)l->addr)
#else
if (__write_mem_safe (&l->old_contents[0], (void*)l->addr, len) == len)
#endif
{
l->in_memory = 0;
}
}
l = l->next;
}
flush_i_cache ();
}
 
#endif // USE_ECOS_HAL_BREAKPOINTS
/misc/breakpoints.c
0,0 → 1,220
//==========================================================================
//
// breakpoints.c
//
// Support aribtrary set of breakpoints.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include "board.h"
 
#ifndef USE_ECOS_HAL_BREAKPOINTS
 
#include <stdlib.h>
#ifdef HAVE_BSP
#include <bsp/bsp.h>
#include <bsp/cpu.h>
#endif
 
#include "monitor.h"
#include "tservice.h"
#include "stub-tservice.h"
 
#include "fmt_util.h"
 
 
static struct bp *last_bp_ptr;
static struct bp *first_bp_ptr;
 
#ifdef NO_MALLOC
static struct bp *free_bp_list;
static struct bp bp_list[MAX_NUM_BP];
static int curr_bp_num;
#endif
 
int
add_mon_breakpoint (mem_addr_t location)
{
struct bp *ptr;
struct bp *new_bp_ptr;
 
for (ptr = first_bp_ptr; ptr != NULL; ptr = ptr->next)
{
if (MEM_ADDR_EQ_P (ptr->address, location))
return 1;
}
#ifdef NO_MALLOC
if (free_bp_list != NULL)
{
new_bp_ptr = free_bp_list;
free_bp_list = new_bp_ptr->next;
}
else
{
if (curr_bp_num < MAX_NUM_BP)
{
new_bp_ptr = &bp_list[curr_bp_num++];
}
else
{
xprintf ("No more breakpoints\n");
return 1;
}
}
#else
new_bp_ptr = (struct bp *)malloc (sizeof (struct bp));
#endif
 
if (first_bp_ptr == NULL)
{
first_bp_ptr = new_bp_ptr;
}
else
{
last_bp_ptr->next = new_bp_ptr;
}
last_bp_ptr = new_bp_ptr;
 
last_bp_ptr->next = NULL;
last_bp_ptr->address = location;
last_bp_ptr->in_memory = 0;
return 0;
}
 
 
void
install_breakpoints (void)
{
struct bp *ptr = first_bp_ptr;
while (ptr != NULL)
{
set_breakpoint (ptr);
ptr = ptr->next;
}
}
 
 
void
clear_breakpoints (void)
{
struct bp *ptr = first_bp_ptr;
 
while (ptr != NULL)
{
clear_breakpoint (ptr);
ptr = ptr->next;
}
}
 
int
show_breakpoints (void)
{
struct bp *ptr;
 
for (ptr = first_bp_ptr; ptr != NULL; ptr = ptr->next)
{
char buf[20];
 
addr2str (&ptr->address, buf);
xprintf ("%s\n", buf);
}
return 0;
}
 
 
 
int
clear_mon_breakpoint (mem_addr_t location)
{
int error = 0;
struct bp *ptr = first_bp_ptr;
struct bp *prev_ptr = NULL;
 
/* Scan the list looking for the address to clear */
while (ptr != NULL && !MEM_ADDR_EQ_P (ptr->address, location))
{
/* keep a pointer one behind the current position */
prev_ptr = ptr;
ptr = ptr->next;
}
if (ptr == NULL)
{
xprintf ("That address has no breakpoint on it.\n");
error = 1;
}
else
{
/* Just in case it's still in memory. */
clear_breakpoint (ptr);
 
/* now we'll point the previous bp->next at the one after the one
we're deleting, unless there is no previous bp. */
if (prev_ptr != NULL)
{
prev_ptr->next = ptr->next;
}
 
if (first_bp_ptr == ptr)
first_bp_ptr = ptr->next;
 
if (last_bp_ptr == ptr)
last_bp_ptr = prev_ptr;
 
/* eliminate the offending bp struct */
#ifdef NO_MALLOC
ptr->next = free_bp_list;
free_bp_list = ptr;
#else
free (ptr);
#endif
}
return error;
}
 
#endif /* USE_ECOS_HAL_BREAKPOINTS */
/misc/generic_fmt32.c
0,0 → 1,98
//==========================================================================
//
// generic_fmt32.c
//
// Generic address conversion routines
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose: Generic address conversion routines
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
 
#include <string.h>
#ifdef HAVE_BSP
#include <bsp/bsp.h>
#include <bsp/cpu.h>
#endif
#include "monitor.h"
#include "fmt_util.h"
 
 
int
str2addr (char *string, mem_addr_t *res)
{
#ifdef HAVE_ASI
if (string[0] == '[')
{
char *ptr = ++string;
while (*ptr && *ptr != ']')
ptr++;
 
if (*ptr == 0)
return -1;
 
*(ptr++) = 0;
res->asi = str2int (string, 16);
string = ptr;
}
else
res->asi = ASI_DEFAULT;
#endif
res->addr = str2int (string, 16);
return 0;
}
 
void
addr2str (mem_addr_t *addr, char *dest)
{
#ifdef HAVE_ASI
if (addr->asi != ASI_DEFAULT)
xsprintf(dest, "[%x]", addr->asi);
else
#endif
dest[0] = 0;
strcat (dest, int2str (addr->addr, 16, sizeof (void *) * 2));
}
/misc/mips/mips-mon.c
0,0 → 1,183
//==========================================================================
//
// mips-mon.c
//
// Support code to extend the generic monitor code to support
// MIPS 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): dmoseley
// Contributors: dmoseley
// Date: 2000-06-07
// Purpose: Support code to extend the generic monitor code to support
// MIPS(R) processors.
// Description: Further board specific support is in other files.
// This file contains:
// register names lookup table
//
// Empty Stubs:
// Interval timer - This should really belong to the application
// operating system.
//
// Should not contain:
// low level uart getchar and putchar functions
// delay function to support uart
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include "monitor.h"
 
struct regstruct regtab[] =
{
{ "zero", REG_ZERO },
{ "at", REG_AT },
{ "v0", REG_V0 },
{ "v1", REG_V1 },
{ "a0", REG_A0 },
{ "a1", REG_A1 },
{ "a2", REG_A2 },
{ "a3", REG_A3 },
{ "t0", REG_T0 },
{ "t1", REG_T1 },
{ "t2", REG_T2 },
{ "t3", REG_T3 },
{ "t4", REG_T4 },
{ "t5", REG_T5 },
{ "t6", REG_T6 },
{ "t7", REG_T7 },
{ "s0", REG_S0 },
{ "s1", REG_S1 },
{ "s2", REG_S2 },
{ "s3", REG_S3 },
{ "s4", REG_S4 },
{ "s5", REG_S5 },
{ "s6", REG_S6 },
{ "s7", REG_S7 },
{ "t8", REG_T8 },
{ "t9", REG_T9 },
{ "k0", REG_K0 },
{ "k1", REG_K1 },
{ "gp", REG_GP },
{ "sp", REG_SP },
{ "s8", REG_S8 },
{ "ra", REG_RA },
 
{ "sr", REG_SR },
{ "lo", REG_LO },
{ "hi", REG_HI },
{ "badvr", REG_BAD },
{ "cause", REG_CAUSE },
{ "pc", REG_PC },
#ifdef CYGHWR_HAL_MIPS_FPU
{ "f0", REG_F0 },
{ "f1", REG_F1 },
{ "f2", REG_F2 },
{ "f3", REG_F3 },
{ "f4", REG_F4 },
{ "f5", REG_F5 },
{ "f6", REG_F6 },
{ "f7", REG_F7 },
{ "f8", REG_F8 },
{ "f9", REG_F9 },
{ "f10", REG_F10 },
{ "f11", REG_F11 },
{ "f12", REG_F12 },
{ "f13", REG_F13 },
{ "f14", REG_F14 },
{ "f15", REG_F15 },
{ "f16", REG_F16 },
{ "f17", REG_F17 },
{ "f18", REG_F18 },
{ "f19", REG_F19 },
{ "f20", REG_F20 },
{ "f21", REG_F21 },
{ "f22", REG_F22 },
{ "f23", REG_F23 },
{ "f24", REG_F24 },
{ "f25", REG_F25 },
{ "f26", REG_F26 },
{ "f27", REG_F27 },
{ "f28", REG_F28 },
{ "f29", REG_F29 },
{ "f30", REG_F30 },
{ "f31", REG_F31 },
{ "fcr31", REG_FCR31 },
#endif /* CYGHWR_HAL_MIPS_FPU */
{ 0, 0 }, /* Terminating element must be last */
} ;
 
void
initialize_mon(void)
{
} /* initialize_mon */
 
 
#include <cyg/hal/hal_arch.h>
#include <bsp/common/bsp_if.h>
int
machine_syscall(HAL_SavedRegisters *regs)
{
int res, err;
target_register_t a0, a1, a2, a3;
 
a0 = get_register(REG_A0);
a1 = get_register(REG_A1);
a2 = get_register(REG_A2);
a3 = get_register(REG_A3);
 
err = _bsp_do_syscall(a0, // Function
a1, a2, a3, 0, // arguments,
&res);
if (err)
{
// This was a syscall. It has now been handled, so update the registers appropriately
put_register(REG_V0, res);
bsp_skip_instruction(regs);
}
 
return err;
}
 
 
// Utility function for printing breakpoints
void bp_print(target_register_t bp_val)
{
bsp_printf("0x%08lx\n", (unsigned long)bp_val);
}
/misc/mips/cpu_info.h
0,0 → 1,90
#ifndef __MIPS_CPU_INFO_H__
#define __MIPS_CPU_INFO_H__
//==========================================================================
//
// cpu_info.h
//
// Architecture information for MIPS 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): dmoseley
// Contributors: dmoseley
// Date: 2000-06-07
// Purpose:
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#define IS_MIPS 1
 
/* Temporary as long a multiple protypes are copied in multiple files */
/* This variation does NOT clone the prototypes */
#define NO_MALLOC 1
 
#ifndef USE_ECOS_HAL_BREAKPOINTS
 
/* big enuf to store a trap in the BP structure */
 
#define BP_INST_T_DEFINED 1
typedef unsigned int bp_inst_t ;
 
#else /* USE_ECOS_HAL_BREAKPOINTS */
 
#define MEM_ADDR_DEFINED 1
typedef struct mem_addr {
unsigned long addr;
} mem_addr_t ;
 
#endif /* USE_ECOS_HAL_BREAKPOINTS */
 
typedef unsigned long target_register_t;
 
#include <cyg/infra/cyg_type.h>
#include <cyg/hal/basetype.h>
#if CYG_BYTEORDER == CYG_MSBFIRST
#define PRINT_INSN print_insn_big_mips
#else
#define PRINT_INSN print_insn_little_mips
#endif
 
#undef BFD_MACH
#define BFD_MACH 0
 
#endif // __MIPS_CPU_INFO_H__
/misc/mips/board.h
0,0 → 1,110
#ifndef __CYGMON_MIPS_BOARD_H__
#define __CYGMON_MIPS_BOARD_H__
//==========================================================================
//
// board.h
//
// Cygmon board/platform configuration file
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-07-11
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
// Hardware/platform/configuration specifics
 
// These defines are only necessary for using target_reg union in monitor.h
// It should be possible to remove that once the HAL integration is complete.
#define HAVE_FLOAT_REGS 0
#define HAVE_DOUBLE_REGS 0
 
#define HAVE_CACHE 0
#define HAVE_USAGE 0
#define USE_CYGMON_PROTOTYPES 1
#define NOMAIN 1
#define CYGMON_SYSTEM_SERVICES 0 // Not used, fall back to BSP/HAL support
 
#ifdef CYGDAT_CYGMON_USE_HELP
#define USE_HELP 1
#endif
 
#define USE_ECOS_HAL_EXCEPTIONS
#define USE_ECOS_HAL_BREAKPOINTS
#define USE_ECOS_HAL_SINGLESTEP
 
#include "cpu_info.h"
extern void bp_print (target_register_t bp_val);
extern int __set_breakpoint (target_register_t addr);
extern int __remove_breakpoint (target_register_t addr);
extern void __install_breakpoint_list (void);
extern void __clear_breakpoint_list (void);
extern int __display_breakpoint_list (void (*print_func)(target_register_t));
 
#define bsp_skip_instruction(regs) __skipinst()
#define install_breakpoints() __install_breakpoints()
#define add_mon_breakpoint(bpt) __set_breakpoint((bpt).addr)
#define clear_mon_breakpoint(bpt) __remove_breakpoint((bpt).addr)
#define show_breakpoints() __display_breakpoint_list(bp_print)
#define clear_breakpoints() __clear_breakpoint_list()
 
#define bsp_get_signal(exc_nr, regs) __computeSignal(exc_nr)
#define bsp_get_pc(regs) get_register(PC)
 
#define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS
#include <cyg/hal/mips-regs.h>
#include "monitor.h"
 
#ifdef __mips64
#define bsp_set_pc(pc, regs) \
put_register(PC, pc); \
if (regs->_sr & SR_ERL) \
put_register(EPC, pc); \
else \
put_register(EEPC, pc);
#else
#define bsp_set_pc(pc, regs) \
put_register(PC, pc);
#endif
 
#endif // __CYGMON_MIPS_BOARD_H__
/misc/mips/cpu.h
0,0 → 1,59
#ifndef __MIPS_CPU_H__
#define __MIPS_CPU_H__
//==========================================================================
//
// cpu.h
//
// MIPS specific processor defines
//
//==========================================================================
//####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): dmoseley
// Contributors: dmoseley
// Date: 2000-06-07
// Purpose: MIPS specific processor defines
// Description:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#include <cyg/hal/hal_intr.h>
 
#define BSP_MAX_EXCEPTIONS CYGNUM_HAL_VSR_COUNT
 
#endif // __MIPS_CPU_H__
/misc/monitor.c
0,0 → 1,494
//==========================================================================
//
// monitor.c
//
// Monitor shell and main routines for CygMON the Wonder Monitor
//
//==========================================================================
//####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):
// Contributors: gthomas, dmoseley
// Date: 1999-10-20
// Purpose: Monitor shell and main routines for CygMON the Wonder Monitor
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
/* Platform-independent code for cygmon */
 
#include <stdlib.h>
#include <unistd.h>
#ifdef HAVE_BSP
#include <bsp/bsp.h>
#include <bsp/cpu.h>
#include <bsp/hex-utils.h>
#endif
#include <monitor.h>
#ifdef HAVE_BSP
#include "cpu_info.h"
#endif
#include <ledit.h>
#include <signal.h>
#include <string.h>
#include <ctype.h>
 
#if USE_CYGMON_PROTOTYPES
/* Use common prototypes */
/* Some of the composed board.h files compose these
prototypes redundently, but if they dont,
these are the common definitions */
#include "fmt_util.h" /* Interface to string formatting utilities */
#include "tservice.h" /* Interface to target specific services */
#include "generic-stub.h" /* from libstub */
#endif /* USE_CYGMON_PROTOTYPES */
 
static int cygmon_handle_exception (int sigval);
static void monitor_take_control (void);
 
#if CYGMON_SYSTEM_SERVICES
extern int process_syscall (int syscall_num);
#elif defined (USE_ECOS_HAL_EXCEPTIONS)
static int cygmon_process_syscall (int sigval);
#endif
 
int stub_is_active = 0;
mem_addr_t last_pc;
 
#ifdef HAVE_BSP
 
#if !defined(USE_ECOS_HAL_EXCEPTIONS)
static int mon_dbg_handler(int exc_nr, void *regs);
static int mon_kill_handler(int exc_nr, void *regs);
#endif // USE_ECOS_HAL_EXCEPTIONS
 
#ifndef USE_ECOS_HAL_BREAKPOINTS
#define __is_breakpoint_function() (get_pc() == (target_register_t)bsp_breakinsn)
#endif
 
#ifdef __ECOS__
/*
* This global flag is used by generic-stub.c to communicate to us that we
* are processing the breakpoint function within Cygmon itself.
*/
extern int processing_breakpoint_function;
#endif
 
/* Global pointer to current set of saved registers. */
void *mon_saved_regs;
 
/* Original BSP debug vector replaced by monitor. */
#if !defined(USE_ECOS_HAL_EXCEPTIONS)
static bsp_handler_t old_dbg_vec;
#endif // !defined(USE_ECOS_HAL_EXCEPTIONS)
 
#else
static int handle_signal (int signal_val);
 
__PFI user_signal_handler = NULL;
#endif
 
#if defined(__ECOS__)
#include <cyg/hal/hal_stub.h>
#endif
 
#if defined(__ECOS__) && !defined(PROCESS_EXCEPTION_VEC_PROTOTYPE_EXISTS)
#define PROCESS_EXCEPTION_VEC_PROTOTYPE_EXISTS
extern volatile __PFI (*__process_exception_vec)(int);
#endif
 
 
#ifdef MONITOR_CONTROL_INTERRUPTS
/* This is set if the user wants interrupts enabled in the monitor. */
static int monitor_interrupts_enabled;
#endif
 
 
#if NOMAIN
int monitor_main (int argc, char **argv) /* Suppress default main() junk */
#else
int main (int argc, char **argv)
#endif
{
#ifdef HAVE_BSP
int cur_port;
struct bsp_comm_info comm_info;
#else
/* Set up exception handling traps */
initialize_stub ();
#endif
 
initialize_mon ();
 
#ifdef HAVE_BSP
/* get info on debug channel */
cur_port = bsp_set_debug_comm(-1);
bsp_sysinfo(BSP_INFO_COMM, cur_port, &comm_info);
 
/*
* If we're using a network interface, don't install
* the cygmon vectors. Currently, we only support stub
* mode over a network connection.
*/
if (comm_info.kind != BSP_COMM_ENET)
{
xprintf("\n");
version ();
 
/* replace original BSP debug and kill handler with ours */
#if !defined(USE_ECOS_HAL_EXCEPTIONS)
old_dbg_vec = bsp_install_dbg_handler(mon_dbg_handler);
(void)bsp_install_kill_handler(mon_kill_handler);
#else
/* replace original BSP debug and kill handler with ours using eCos stuff */
__process_exception_vec = (__PFI)cygmon_handle_exception;
__process_syscall_vec = cygmon_process_syscall;
__process_exit_vec = monitor_take_control;
#endif // __ECOS__
}
else
{
/* This forces the console to use the gdb channel. */
bsp_set_console_comm(cur_port);
}
#else
xprintf("\n");
version ();
 
__process_exception_vec = cygmon_handle_exception;
__process_exit_vec = monitor_take_control;
#if CYGMON_SYSTEM_SERVICES
__process_syscall_vec = process_syscall;
#endif
__process_signal_vec = handle_signal;
__init_vec = install_breakpoints;
__cleanup_vec = clear_breakpoints;
#endif
 
#if 0
#ifdef __ECOS__
__process_exception_vec = cygmon_handle_exception;
#endif
#endif
 
while (1)
{
breakpoint ();
if (switch_to_stub_flag)
{
xprintf("Switching to stub\n");
switch_to_stub_flag = 0;
}
}
 
/* never reached */
exit (0);
}
 
 
/* Transfer control to gdb stub */
int
transfer_to_stub ()
{
/* Return back to the exception handler, but the exception handler
should invoke the stub's exception handler instead of ours. */
#if defined(HAVE_BSP) && !defined(USE_ECOS_HAL_EXCEPTIONS)
(void)bsp_install_dbg_handler(old_dbg_vec);
#else
__switch_to_stub ();
#endif
 
/* The stub is now active. */
stub_is_active = 1;
return -1;
}
 
void
clear_user_state (void)
{
#ifdef HAS_TIMER
if (__timer_enabled ())
__settimer (0, 0);
#endif
 
clear_breakpoints ();
 
#ifndef HAVE_BSP
user_signal_handler = NULL;
#endif
 
__clear_single_step ();
}
 
static void
monitor_take_control (void)
{
stub_is_active = 0;
switch_to_stub_flag = 0;
 
// Flush the unget state. This is because the ecos stub and Cygmon track this
// stuff separately.
bsp_debug_ungetc('\0');
 
#ifdef INITIALIZE_MON_EACH_TIME
// Call the per-stop initialization routine if it is defined.
INITIALIZE_MON_EACH_TIME();
#endif
 
#if defined(HAVE_BSP) && !defined(USE_ECOS_HAL_EXCEPTIONS)
/* replace original BSP debug trap handler with ours */
(void)bsp_install_dbg_handler(mon_dbg_handler);
#else
clear_user_state ();
__process_exception_vec = cygmon_handle_exception;
#endif
}
 
 
#ifdef MONITOR_CONTROL_INTERRUPTS
void
monitor_enable_interrupts (void)
{
monitor_interrupts_enabled = 1;
enable_interrupts ();
}
 
void
monitor_disable_interrupts (void)
{
monitor_interrupts_enabled = 0;
disable_interrupts ();
}
 
int
monitor_interrupt_state (void)
{
return monitor_interrupts_enabled;
}
#endif
 
#if defined(USE_ECOS_HAL_EXCEPTIONS)
externC HAL_SavedRegisters *_hal_registers;
extern int machine_syscall(HAL_SavedRegisters *regs);
static int
cygmon_process_syscall (int sigval)
{
return machine_syscall(_hal_registers);
}
#endif
 
static int
cygmon_handle_exception (int sigval)
{
target_register_t pc;
 
#ifdef MONITOR_CONTROL_INTERRUPTS
if (monitor_interrupts_enabled)
{
if (! __in_interrupt)
enable_interrupts ();
}
#endif
 
#ifdef TARGET_EXCEPTION_CODE
TARGET_EXCEPTION_CODE
#endif
 
#ifndef HAVE_BSP
if (sigval != SIGKILL)
if (handle_signal (sigval) == 0)
return 0;
#endif
 
clear_user_state ();
 
/* We may want to tweak the PC to point at the faulting instruction,
for example. (breakpoints on x86). */
#ifdef TARGET_ADJUST_PC
TARGET_ADJUST_PC
#endif
 
pc = get_pc();
MAKE_STD_ADDR (pc, &last_pc);
 
#ifdef __ECOS__
if ((sigval == SIGTRAP) && (__is_breakpoint_function() || processing_breakpoint_function))
#else
if ((sigval == SIGTRAP) && __is_breakpoint_function())
#endif
{
/*
* This is the initial breakpoint inserted by the BSP
* Don't print anything for this as it is confusing
*/
}
else
{
if (sigval == SIGTRAP)
xprintf ("Hit breakpoint");
else
xprintf ("Got signal %d", sigval);
 
xprintf (" at 0x%s\n", int2str (pc, 16, sizeof (target_register_t) * 2));
 
#ifdef DISASSEMBLER
if (!__is_breakpoint_function ())
{
do_dis (&last_pc);
flush_dis ();
}
#endif
}
 
monitor_take_control ();
 
return monitor_loop ();
}
 
#ifndef HAVE_BSP
/* Returns 0 if the program should restart at the point at which the
signal was received, -1 otherwise. */
static int
handle_signal (int signal)
{
if (signal == SIGKILL)
return -1;
 
if (user_signal_handler != NULL)
{
int result = user_signal_handler (signal);
switch (result)
{
/* Don't ignore potential hardware signals. */
case 3:
if (signal == SIGSEGV || signal == SIGBUS || signal == SIGFPE
|| signal == SIGTRAP || signal == SIGILL)
return -1;
 
case 0:
return 0;
 
default:
case 1:
case 2:
return -1;
}
}
return -1;
}
#endif
 
 
void
version (void)
{
#ifdef HAVE_BSP
struct bsp_platform_info platform;
struct bsp_mem_info mem;
int i;
unsigned long u, totmem, topmem;
#endif
extern char *build_date;
 
xprintf ("Cygmon, the Cygnus ROM monitor.\n");
xprintf ("Copyright(c) 1997, 1998, 1999, 2000 Red Hat\n\n");
xprintf ("Version: %s\nThis image was built on %s\n\n",
VERSION, build_date);
 
#ifdef HAVE_BSP
bsp_sysinfo(BSP_INFO_PLATFORM, &platform);
 
totmem = topmem = 0;
i = 0;
while (bsp_sysinfo(BSP_INFO_MEMORY, i++, &mem) == 0)
{
if (mem.kind == BSP_MEM_RAM)
{
totmem += mem.nbytes;
u = (unsigned long)mem.virt_start + mem.nbytes;
if (u > topmem)
topmem = u;
}
}
 
xprintf("CPU: %s\n", platform.cpu);
xprintf("Board: %s\n", platform.board);
if (*(platform.extra))
xprintf("%s\n", platform.extra);
xprintf("Total RAM: %d bytes\n", totmem);
xprintf("Top of RAM: 0x%x\n", topmem);
#endif
}
 
 
#ifdef HAVE_BSP
#if !defined(USE_ECOS_HAL_EXCEPTIONS)
static int
mon_kill_handler(int exc_nr, void *regs)
{
monitor_take_control();
return 1;
}
#endif // !defined(USE_ECOS_HAL_EXCEPTIONS)
 
#if !defined(USE_ECOS_HAL_EXCEPTIONS)
static int
mon_dbg_handler(int exc_nr, void *regs)
{
int sig;
unsigned long cur_pc;
 
mon_saved_regs = regs;
sig = bsp_get_signal(exc_nr, regs);
 
cygmon_handle_exception(sig);
 
cur_pc = bsp_get_pc(regs);
if (cur_pc == (unsigned long)bsp_breakinsn)
bsp_skip_instruction(regs);
 
if (!stub_is_active)
install_breakpoints();
 
return 1;
}
#endif // !defined(USE_ECOS_HAL_EXCEPTIONS)
 
#endif
/misc/fmt_util.h
0,0 → 1,65
#ifndef __FMT_UTIL_H__
#define __FMT_UTIL_H__
//==========================================================================
//
// fmt_util.g
//
// Interface to generic string parsing and formatting utilities.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
/* Interface to generic string parsing and formatting utilities.
 
It is posible that these services need to be defined in
a platform dependent way. These will work for the majority of
processors. */
 
extern int str2addr (char *string, mem_addr_t *res);
extern void addr2str (mem_addr_t *addr, char *dest);
 
#endif // __FMT_UTIL_H__
/misc/tservice.h
0,0 → 1,84
#ifndef __TSERVICE_H__
#define __TSERVICE_H__
//==========================================================================
//
// tservice.h
//
// These are the core functions are expected to be provided by the
// target dependent services.
//
//==========================================================================
//####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):
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
/* These are the core functions are expected to be provided by the
target dependent services. They are used by both cygmon and by
libstub
*/
 
 
extern int read_memory (mem_addr_t *src, int size, int amt, char *dst);
 
extern int write_memory (mem_addr_t *dst, int size, int amt, char *src);
 
 
#ifndef USE_ECOS_HAL_BREAKPOINTS
extern void set_breakpoint (struct bp *bp);
extern void clear_breakpoint (struct bp *bp);
#endif // USE_ECOS_HAL_BREAKPOINTS
 
#ifndef HAVE_BSP
extern void set_pc (target_register_t pc);
#endif
 
extern target_register_t next_step_pc (void);
 
extern void enable_interrupts (void);
 
#endif // __TSERVICE_H__
 
 
extern void initialize_mon(void);
/misc/generic-stub.h
0,0 → 1,54
//==========================================================================
//
// generic-stub.h
//
//
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// Placeholder
/misc/board.h
0,0 → 1,72
#ifndef __CYGMON_BOARD_H__
#define __CYGMON_BOARD_H__
//==========================================================================
//
// board.h
//
// Cygmon board/platform configuration file
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas, dmoseley
// Date: 1999-10-20
// Purpose:
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
// Hardware/platform/configuration specifics
 
#include <pkgconf/hal.h>
#include <pkgconf/cygmon.h>
 
#ifdef CYGPKG_HAL_ARM
#include "arm/board.h"
#endif
 
#ifdef CYGPKG_HAL_MIPS
#include "mips/board.h"
#endif
 
#ifdef CYGPKG_HAL_MN10300
#include "mn10300/board.h"
#endif
 
#endif // __CYGMON_BOARD_H__
/misc/monitor.h
0,0 → 1,303
//==========================================================================
//
// monitor.h
//
// Main definitions for the CygMON ROM monitor
//
//==========================================================================
//####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):
// Contributors: gthomas, dmoseley
// Date: 1999-10-20
// Purpose: Main definitions for the CygMON ROM monitor
// Description:
//
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
#ifndef MONITOR_H
#define MONITOR_H
 
#if !defined(__ASSEMBLER__)
#include <stdarg.h>
#endif
 
#include <board.h>
#ifdef HAVE_BSP
#include "cpu_info.h"
#endif
#include <monitor_cmd.h>
 
#ifdef __ECOS__
#include <cyg/hal/plf_stub.h>
#endif
 
#ifndef ASM
 
#ifdef HAVE_BSP
#define xprintf bsp_dprintf
#define xsprintf bsp_sprintf
#define xvprintf bsp_dvprintf
#define xputchar bsp_debug_putc
#define xgetchar bsp_debug_getc
#define xungetchar bsp_debug_ungetc
#define __getTty() bsp_set_debug_comm(-1)
#define set_pc(x) bsp_set_pc((x), mon_saved_regs)
 
#ifndef USE_ECOS_HAL_SINGLESTEP
#define __single_step() bsp_singlestep_setup(mon_saved_regs)
#define __clear_single_step() bsp_singlestep_cleanup(mon_saved_regs)
#endif /* USE_ECOS_HAL_SINGLESTEP */
 
#ifndef USE_ECOS_HAL_BREAKPOINTS
#define breakpoint() bsp_breakpoint()
#endif /* USE_ECOS_HAL_BREAKPOINTS */
 
#if defined(__ECOS__) && defined(CYGHWR_HAL_RESET_DEFINED)
extern void __reset(void);
#else // defined(__ECOS__) && defined(CYGHWR_HAL_RESET_DEFINED)
# define __reset bsp_reset
#endif // defined(__ECOS__) && defined(CYGHWR_HAL_RESET_DEFINED)
 
#else
extern void xprintf(const char *fmt, ...);
extern void xsprintf(char *str, const char *fmt, ...);
extern void xvprintf(const char *fmt, va_list ap);
 
#ifdef HAS_USER_IO
#define xputchar putUserChar
#define xgetchar getUserChar
#else
extern void putDebugChar(int ch);
extern int getDebugChar(void);
#define xputchar putDebugChar
#define xgetchar getDebugChar
#endif
#define xungetchar ungetDebugChar
#endif
 
 
#ifndef USE_ECOS_HAL_BREAKPOINTS
struct bp {
mem_addr_t address;
bp_inst_t old_inst;
char in_memory;
struct bp *next;
};
#endif // USE_ECOS_HAL_BREAKPOINTS
 
struct regstruct
{
char *registername;
int registernumber;
#ifdef HAVE_BSP
#if defined(CYGPKG_HAL_ARM) || !defined(__ECOS__)
int registertype;
#endif // defined(CYGPKG_HAL_ARM) || !defined(__ECOS__)
#endif
#ifdef REG_VALID_FIELD_IN_REGSTRUCT
int registervalid;
#endif
};
 
 
 
#ifdef HAVE_BSP
#define REGTYPE_INT 1
#define REGTYPE_FLOAT 2
#define REGTYPE_DOUBLE 3
 
union target_reg
{
unsigned long i; /* integer register (32/64 bit) */
#if HAVE_FLOAT_REGS
float f; /* float register (32bit) */
#endif
#if HAVE_DOUBLE_REGS
double d; /* double register (64bit) */
#endif
};
 
typedef union target_reg target_regval_t;
 
 
/* This is a template for what should be defined in the board specific
header file composed, board.h */
#if ! defined(MEM_ADDR_DEFINED)
#define MEM_ADDR_DEFINED 1
typedef struct mem_addr {
unsigned long addr;
} mem_addr_t;
#endif
 
#if !defined(BP_INST_T_DEFINED)
#define BP_INST_T_DEFINED 1
typedef unsigned char bp_inst_t ;
#endif
 
#if ! defined(MAKE_STD_ADDR)
#define MAKE_STD_ADDR(SRC, DST) ((DST)->addr = (SRC))
#endif
 
 
#if ! defined(ADD_OFFSET)
#define ADD_OFFSET(SRC,DST,OFFSET) ((DST)->addr = (SRC)->addr + (OFFSET))
#endif
 
#if ! defined(ADD_ALIGN)
#define ADD_ALIGN(SRC,DST,ALIGN) \
((DST)->addr = (SRC)->addr - ((SRC)->addr % (ALIGN)))
#endif
 
#if ! defined(MEM_ADDR_EQ_P)
#define MEM_ADDR_EQ_P(A, B) ((A).addr == (B).addr)
#endif
 
#if ! defined(MEM_ADDR_DIFF)
#define MEM_ADDR_DIFF(A, B) ((A).addr - (B).addr)
#endif
 
#if ! defined(MEM_ADDR_ASI)
#define MEM_ADDR_ASI(A) -1
#endif
 
#endif /* HAVE_BSP */
 
#if defined(NO_MALLOC) && ! defined(MAX_NUM_BP)
#define MAX_NUM_BP 64
#endif
 
extern struct regstruct regtab[];
 
extern char **argvect;
 
#ifdef HAVE_BSP
#define VERSION "release 2.0"
#else
#define VERSION "release 1.2"
#endif
 
#define MAXLINELEN 80
#define PROMPT "cygmon> "
#if ! defined MAX_HIST_ENTS
#define MAX_HIST_ENTS 10
#endif
 
/*
* From monitor.c
*/
extern mem_addr_t last_pc;
extern int stub_is_active;
#ifdef HAVE_BSP
extern void *mon_saved_regs;
#else
extern int (*user_signal_handler)(int);
#endif
 
extern void clear_user_state (void);
extern int transfer_to_stub (void);
extern void version (void);
#ifdef MONITOR_CONTROL_INTERRUPTS
/* Enable interrupts within the monitor. */
extern void monitor_enable_interrupts (void);
 
/* Disable interrupts within the monitor. */
extern void monitor_disable_interrupts (void);
 
/* Returns 1 if interrupts have been enabled within the monitor, 0
otherwise. */
extern int monitor_interrupt_state (void);
#endif /* MONITOR_CONTROL_INTERRUPTS */
 
 
/*
* From utils.c
*/
extern int switch_to_stub_flag;
extern int input_char (void);
extern target_register_t str2int (char *str, int base);
#if HAVE_DOUBLE_REGS
extern double str2double (char *str, int base);
#endif
extern target_register_t str2intlen (char *str, int base, int len);
extern int hex2bytes(char *string, char *dest, int maxsize);
extern char *int2str (target_register_t number, int base, int numdigs);
#ifndef NO_MALLOC
extern char *strdup(const char *str);
#endif
extern target_register_t get_pc(void);
extern char *get_register_str (regnames_t which, int detail, int valid);
extern void store_register (regnames_t which, char *string);
 
#ifndef USE_ECOS_HAL_BREAKPOINTS
/*
* From breakpoints.c
*/
extern int add_mon_breakpoint (mem_addr_t location);
extern void install_breakpoints (void);
extern void clear_breakpoints (void);
extern int show_breakpoints (void);
extern int clear_mon_breakpoint (mem_addr_t location);
#endif /* USE_ECOS_HAL_BREAKPOINTS */
 
 
/*
* From do-dis.c
*/
extern mem_addr_t do_dis (mem_addr_t *addr);
extern void flush_dis (void);
 
 
/*
* From architecture-mon.c
*/
#ifdef HAVE_BSP
extern void initialize_mon(void);
extern target_register_t get_register(regnames_t reg);
extern void put_register (regnames_t which, target_register_t value);
#endif
 
 
/* Lame. */
#ifndef ITIMER_REAL
#define ITIMER_REAL 0
#endif
 
#endif /* ASM */
#endif
/misc/ecos_bsp.c
0,0 → 1,470
//==========================================================================
//
// ecos_bsp.c
//
// eCos BSP (for building Cygmon)
//
//==========================================================================
//####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): gthomas
// Contributors: gthomas, dmoseley
// Date: 1999-10-11
// Description: Wrapper functions which provide BSP environment for Cygmon
//####DESCRIPTIONEND####
 
#ifdef CYGPKG_KERNEL
#include <pkgconf/kernel.h> // Configuration headers
#endif
#include <pkgconf/hal.h>
#include <pkgconf/cygmon.h>
 
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_cache.h>
#ifdef CYGPKG_KERNEL
#include <cyg/kernel/kapi.h>
#else
#include <cyg/hal/drv_api.h>
#include <cyg/hal/hal_intr.h>
#endif
#include <cyg/infra/diag.h>
#include "bsp/common/bsp_if.h"
#include <cyg/hal/hal_if.h>
#include <signal.h>
#include CYGHWR_MEMORY_LAYOUT_H
#include <pkgconf/system.h>
#ifdef CYGPKG_IO
#include <cyg/io/io.h>
#include <cyg/io/serialio.h>
#endif
 
#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_MINIMUM
static char stack[STACK_SIZE];
#ifdef CYGPKG_KERNEL
static cyg_thread thread_data;
static cyg_handle_t thread_handle;
#endif
 
char *build_date = __DATE__;
 
extern void monitor_main(int, char *);
extern int stub_is_active;
 
void ecos_bsp_set_memsize(unsigned long size);
 
void
cygmon_main(void)
{
_bsp_init();
monitor_main(0, 0); // Null argument list
}
 
extern unsigned long cygmon_memsize;
 
externC void
cyg_start( void )
{
// Fill in the BSP memory info
if (cygmon_memsize != 0)
ecos_bsp_set_memsize(cygmon_memsize);
 
#ifdef CYGPKG_KERNEL
// Create a main thread, so we can run the scheduler and have time 'pass'
cyg_thread_create(10, // Priority - just a number
(cyg_thread_entry_t*)cygmon_main, // entry
0, // entry parameter
"Cygmon", // Name
&stack[0], // Stack
STACK_SIZE, // Size
&thread_handle, // Handle
&thread_data // Thread data structure
);
cyg_thread_resume(thread_handle); // Start it
cyg_scheduler_start();
#else
#ifdef HAL_ARCH_FUNCALL_NEW_STACK
HAL_ARCH_FUNCALL_NEW_STACK(cygmon_main, &stack[0], STACK_SIZE);
#else
#error Need to define HAL_ARCH_FUNCALL_NEW_STACK
#endif
#endif
} // cyg_package_start()
 
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
extern void *_hal_registers; // Used by eCos GDB stubs
extern void (*__init_vec)(void);
extern void (*__cleanup_vec)(void);
extern void __install_traps(void);
#endif
 
extern int machine_syscall(HAL_SavedRegisters *regs);
void
_bsp_handle_exception(cyg_addrword_t data, cyg_code_t num, cyg_addrword_t info)
{
if (num == CYGNUM_HAL_EXCEPTION_INTERRUPT) {
if (machine_syscall((HAL_SavedRegisters*)info)) {
return;
}
// Fall through to "normal" exception handling if system call failed
}
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
_hal_registers = (void *)info; // Used by eCos GDB stubs
__cleanup_vec();
#endif
bsp_invoke_dbg_handler(num, (void *)info);
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
__init_vec();
#endif
}
 
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
extern void __handle_exception(void);
#else
 
int
unhandled_exception(int num, void *args)
{
diag_printf("Unhandled exception: %d/%x\n", num, args);
while (1) ;
}
#endif
 
void
_bsp_cpu_init(void)
{
#ifdef CYGPKG_KERNEL
int d0;
cyg_exception_set_handler(CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION,
_bsp_handle_exception,
(cyg_addrword_t)&d0,
0,
0);
#endif
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
bsp_install_dbg_handler((bsp_handler_t)__handle_exception);
__install_traps();
#else
bsp_install_dbg_handler(unhandled_exception);
#endif
}
 
#define FAIL() diag_printf("fail: %s\n", __FUNCTION__); while (1) ;
 
#ifndef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
 
struct BSP_IO {
char *name;
cyg_io_handle_t chan;
};
 
static void
uart_putchar(void *base, char c)
{
char buf;
int len;
struct BSP_IO *io = (struct BSP_IO *)base;
if (io->chan) {
len = 1;
buf = c;
cyg_io_write(io->chan, &buf, &len);
}
}
 
extern int __output_gdb_string (const char *str, int string_len);
 
// This function is mostly used by the 'write()' system call
static void
uart_write(void *base, const char *buf, int len)
{
struct BSP_IO *io = (struct BSP_IO *)base;
if (io->chan) {
if (stub_is_active) {
// We are running in 'GDB' mode
__output_gdb_string(buf, len);
} else {
cyg_io_write(io->chan, buf, &len);
}
}
}
 
static int
uart_read(void *base, char *buf, int len)
{
struct BSP_IO *io = (struct BSP_IO *)base;
if (io->chan) {
cyg_io_read(io->chan, buf, &len);
return len;
}
return 0;
}
 
static int
uart_getchar(void *base)
{
char buf = '\0';
int len;
struct BSP_IO *io = (struct BSP_IO *)base;
if (io->chan) {
len = 1;
cyg_io_read(io->chan, &buf, &len);
}
return buf;
}
 
static int
uart_control(void *base, int func, ...)
{
int rc = 0;
va_list ap;
int arg;
struct BSP_IO *io = (struct BSP_IO *)base;
 
va_start(ap, func);
 
if (func == COMMCTL_SETBAUD)
{
cyg_serial_info_t buffer = {
CYG_SERIAL_BAUD_DEFAULT,
CYG_SERIAL_STOP_DEFAULT,
CYG_SERIAL_PARITY_DEFAULT,
CYG_SERIAL_WORD_LENGTH_DEFAULT,
CYG_SERIAL_FLAGS_DEFAULT
};
int len = sizeof(buffer);
arg = va_arg(ap, int);
 
switch (arg)
{
case 50: buffer.baud = CYG_SERIAL_BAUD_RATE(50); break;
case 75: buffer.baud = CYG_SERIAL_BAUD_RATE(75); break;
case 110: buffer.baud = CYG_SERIAL_BAUD_RATE(110); break;
case 134: buffer.baud = CYG_SERIAL_BAUD_RATE(134_5); break;
case 135: buffer.baud = CYG_SERIAL_BAUD_RATE(134_5); break;
case 150: buffer.baud = CYG_SERIAL_BAUD_RATE(150); break;
case 200: buffer.baud = CYG_SERIAL_BAUD_RATE(200); break;
case 300: buffer.baud = CYG_SERIAL_BAUD_RATE(300); break;
case 600: buffer.baud = CYG_SERIAL_BAUD_RATE(600); break;
case 1200: buffer.baud = CYG_SERIAL_BAUD_RATE(1200); break;
case 1800: buffer.baud = CYG_SERIAL_BAUD_RATE(1800); break;
case 2400: buffer.baud = CYG_SERIAL_BAUD_RATE(2400); break;
case 3600: buffer.baud = CYG_SERIAL_BAUD_RATE(3600); break;
case 4800: buffer.baud = CYG_SERIAL_BAUD_RATE(4800); break;
case 7200: buffer.baud = CYG_SERIAL_BAUD_RATE(7200); break;
case 9600: buffer.baud = CYG_SERIAL_BAUD_RATE(9600); break;
case 14400: buffer.baud = CYG_SERIAL_BAUD_RATE(14400); break;
case 19200: buffer.baud = CYG_SERIAL_BAUD_RATE(19200); break;
case 38400: buffer.baud = CYG_SERIAL_BAUD_RATE(38400); break;
case 57600: buffer.baud = CYG_SERIAL_BAUD_RATE(57600); break;
case 115200: buffer.baud = CYG_SERIAL_BAUD_RATE(115200); break;
case 230400: buffer.baud = CYG_SERIAL_BAUD_RATE(230400); break;
default: buffer.baud = -1; rc = -1; break;
}
 
if ((io->chan) && (buffer.baud != -1)) {
rc = cyg_io_set_config(io->chan, CYG_IO_SET_CONFIG_SERIAL_INFO, &buffer, &len);
}
}
 
va_end(ap);
return rc;
}
 
/*
* Setup the bsp_comm_channel data structure
*/
struct BSP_IO bsp_comm_io[] = {
{CYGDAT_CYGMON_CONSOLE_DEV, 0}, // Console device
};
 
struct bsp_comm_channel _bsp_comm_list[] =
{
{
{ "UART 0",
BSP_COMM_SERIAL,
BSP_PROTO_NONE },
{ (void*)&bsp_comm_io[0],
uart_write,
uart_read,
uart_putchar,
uart_getchar,
uart_control }
},
};
int _bsp_num_comms = sizeof(_bsp_comm_list)/sizeof(_bsp_comm_list[0]);
 
void
_bsp_init_board_comm(void)
{
int i;
for (i = 0; i < _bsp_num_comms; i++) {
Cyg_ErrNo err;
struct BSP_IO *io;
io = (struct BSP_IO *)_bsp_comm_list[i].procs.ch_data;
if ((err = cyg_io_lookup(io->name, &io->chan)) != ENOERR) {
diag_printf("Can't open '%s'\n", io->name);
}
}
}
 
#else // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
 
struct bsp_comm_channel _bsp_comm_list[1];
int _bsp_num_comms = 1;
 
// Yuck! Two things need doing:
 
// FIXME: Make bsp code use pointers in the bsp_comm_channel instead
// of sub-structures.
 
// FIXME: Make HAL provide the bsp_comm_info structure - I missed that
// initially because it cannot be accessed via the virtual table API.
void
_bsp_init_board_comm(void)
{
struct bsp_comm_channel* channel;
hal_virtual_comm_table_t* comm;
 
channel = &_bsp_comm_list[0];
channel->info.name = "fixme";
channel->info.kind = BSP_COMM_SERIAL;
channel->info.protocol = BSP_PROTO_NONE;
 
comm = CYGACC_CALL_IF_DEBUG_PROCS();
channel->procs = *(struct bsp_comm_procs*)comm;
}
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
 
/*
* Array of memory region descriptors. We just list RAM.
*/
#ifdef CYGMEM_REGION_ram
#define RAM_VIRTUAL_BASE CYGMEM_REGION_ram
#define RAM_TOTAL_SIZE CYGMEM_REGION_ram_SIZE
#else
#define RAM_VIRTUAL_BASE 0x00008000
#define RAM_TOTAL_SIZE 0x00FF8000
#endif
 
struct bsp_mem_info _bsp_memory_list[] =
{
{ (void *)RAM_VIRTUAL_BASE,
(void *)RAM_VIRTUAL_BASE,
0,
RAM_TOTAL_SIZE,
BSP_MEM_RAM
},
};
 
/*
* Number of memory region descriptors.
*/
int _bsp_num_mem_regions = sizeof(_bsp_memory_list)/sizeof(_bsp_memory_list[0]);
 
void
_bsp_install_cpu_irq_controllers(void)
{
}
 
void
_bsp_install_board_irq_controllers(void)
{
}
 
void
__init_irq_controllers(void)
{
}
 
void
_bsp_board_init(void)
{
/*
* Define platform info.
*/
#ifdef HAL_PLATFORM_CPU
_bsp_platform_info.cpu = HAL_PLATFORM_CPU;
#else
_bsp_platform_info.cpu = "Unknown CPU";
#endif
#ifdef HAL_PLATFORM_BOARD
_bsp_platform_info.board = HAL_PLATFORM_BOARD;
#else
_bsp_platform_info.board = "Unknown board";
#endif
#ifdef HAL_PLATFORM_EXTRA
_bsp_platform_info.extra = HAL_PLATFORM_EXTRA;
#else
_bsp_platform_info.extra = "";
#endif
}
 
extern char *strchr(char *, char);
char *
index(char *string, char key)
{
return strchr(string, key);
}
 
void
flush_i_cache(void)
{
HAL_ICACHE_SYNC();
}
 
void
ecos_bsp_console_putc(char c)
{
if (bsp_shared_data) {
bsp_console_putc(c);
}
}
 
char
ecos_bsp_console_getc(void)
{
if (bsp_shared_data) {
return bsp_console_getc();
} else {
return '?';
}
}
 
void
ecos_bsp_set_memsize(unsigned long size)
{
_bsp_memory_list[0].nbytes = size;
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.