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

Subversion Repositories openrisc_me

Compare Revisions

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

Rev 27 → Rev 174

/v2_0/cdl/hal_calm32_ceb.cdl
0,0 → 1,270
# ====================================================================
#
# hal_calm32_ceb.cdl
#
# CalmRISC32 Core Eval Board HAL 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): msalter
# Original data: bartv
# Contributors:
# Date: 2001-02-12
#
#####DESCRIPTIONEND####
#
# ====================================================================
 
cdl_package CYGPKG_HAL_CALM32_CEB {
display "CalmRISC32 core evaluation board"
parent CYGPKG_HAL_CALM32
include_dir cyg/hal
description "
The Core eval board HAL package should be used when targetting the
actual hardware."
 
compile hal_diag.c platform.S plf_misc.c ser.c
 
implements CYGINT_HAL_DEBUG_GDB_STUBS
implements CYGINT_HAL_DEBUG_GDB_STUBS_BREAK
implements CYGINT_HAL_VIRTUAL_VECTOR_SUPPORT
implements CYGINT_HAL_VIRTUAL_VECTOR_SUPPORT_GUARANTEED
 
cdl_option CYGBLD_HAL_TARGET_H {
display "Variant header"
flavor data
no_define
calculated { "<pkgconf/hal_calm32_core.h>" }
define -file system.h CYGBLD_HAL_TARGET_H
description "Variant header."
 
define_proc {
puts $::cdl_system_header "#define CYGBLD_HAL_PLATFORM_H <pkgconf/hal_calm32_ceb.h>"
puts $::cdl_system_header ""
puts $::cdl_system_header "/* Make sure we get the CORE type definitions for HAL_PLATFORM_CPU */"
puts $::cdl_system_header "#include CYGBLD_HAL_TARGET_H"
puts $::cdl_system_header "#define HAL_PLATFORM_BOARD \"Core Eval Board\""
puts $::cdl_system_header "#define HAL_PLATFORM_EXTRA \"\""
puts $::cdl_system_header ""
}
}
 
cdl_component CYG_HAL_STARTUP {
display "Startup type"
flavor data
legal_values {"RAM" "ROM"}
default_value {"ROM"}
no_define
define -file system.h CYG_HAL_STARTUP
description "
Currently only ROM startup type is supported."
}
 
cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD {
display "Diagnostic serial port baud rate"
flavor data
legal_values 57600
default_value 57600
description "
This option selects the baud rate used for the diagnostic port.
Note: this should match the value chosen for the GDB port if the
diagnostic and GDB port are the same."
}
 
cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL_BAUD {
display "GDB serial port baud rate"
flavor data
legal_values 57600
default_value 57600
description "
This option controls the baud rate used for the GDB connection."
}
 
cdl_option CYGBLD_BUILD_GDB_STUBS {
display "Build GDB stub ROM image"
default_value 0
parent CYGBLD_GLOBAL_OPTIONS
requires { CYG_HAL_STARTUP == "ROM" }
requires CYGSEM_HAL_ROM_MONITOR
requires CYGBLD_BUILD_COMMON_GDB_STUBS
requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
requires ! CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
requires ! CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
requires ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT
requires ! CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM
no_define
description "
This option enables the building of the GDB stubs for the
board. The common HAL controls takes care of most of the
build process, but the final conversion from ELF image to
binary data is handled by the platform CDL, allowing
relocation of the data if necessary."
 
make -priority 320 {
<PREFIX>/bin/gdb_module.bin : <PREFIX>/bin/gdb_module.img
$(OBJCOPY) -O binary $< $@
}
}
 
 
cdl_option CYGNUM_HAL_BREAKPOINT_LIST_SIZE {
display "Number of breakpoints supported by the HAL."
flavor data
default_value 25
description "
This option determines the number of breakpoints supported by the HAL."
}
 
cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS {
display "Number of communication channels on the board"
flavor data
calculated 1
}
 
cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL {
display "Debug serial port"
flavor data
legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1
default_value 0
description "
The Atlas board has only one serial port. This option
chooses which port will be used to connect to a host
running GDB."
}
cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL {
display "Diagnostic serial port"
flavor data
legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1
default_value 0
description "
The Atlas board has only one serial port. This option
chooses which port will be used for diagnostic output."
}
 
cdl_component CYGHWR_MEMORY_LAYOUT {
display "Memory layout"
flavor data
no_define
calculated { CYG_HAL_STARTUP == "RAM" ? "calm32_ceb_ram" : \
"calm32_ceb_rom" }
 
cdl_option CYGHWR_MEMORY_LAYOUT_LDI {
display "Memory layout linker script fragment"
flavor data
no_define
define -file system.h CYGHWR_MEMORY_LAYOUT_LDI
calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_calm32_ceb_ram.ldi>" : \
"<pkgconf/mlt_calm32_ceb_rom.ldi>" }
}
 
cdl_option CYGHWR_MEMORY_LAYOUT_H {
display "Memory layout header file"
flavor data
no_define
define -file system.h CYGHWR_MEMORY_LAYOUT_H
calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_calm32_ceb_ram.h>" : \
"<pkgconf/mlt_calm32_ceb_rom.h>" }
}
}
 
cdl_option CYGSEM_HAL_USE_ROM_MONITOR {
display "Work with a ROM monitor"
flavor booldata
legal_values { "Generic" "GDB_stubs" }
default_value { CYG_HAL_STARTUP == "RAM" ? "Generic" : 0 }
parent CYGPKG_HAL_ROM_MONITOR
requires { CYG_HAL_STARTUP == "RAM" }
description "
Support can be enabled for three different varieties of ROM monitor.
This support changes various eCos semantics such as the encoding
of diagnostic output, or the overriding of hardware interrupt
vectors.
Firstly there is \"Generic\" support which prevents the HAL
from overriding the hardware vectors that it does not use, to
instead allow an installed ROM monitor to handle them. This is
the most basic support which is likely to be common to most
implementations of ROM monitor.
\"CygMon\" provides support for the Cygnus ROM Monitor.
And finally, \"GDB_stubs\" provides support when GDB stubs are
included in the ROM monitor or boot ROM."
}
 
cdl_option CYGSEM_HAL_ROM_MONITOR {
display "Behave as a ROM monitor"
flavor bool
default_value 1
parent CYGPKG_HAL_ROM_MONITOR
requires { CYG_HAL_STARTUP == "ROM" }
description "
Enable this option if this program is to be used as a ROM monitor,
i.e. applications will be loaded into RAM on the board, and this
ROM monitor may process exceptions or interrupts generated from the
application. This enables features such as utilizing a separate
interrupt stack when exceptions are generated."
}
 
cdl_component CYGPKG_REDBOOT_HAL_OPTIONS {
display "Redboot HAL options"
flavor none
no_define
parent CYGPKG_REDBOOT
active_if CYGPKG_REDBOOT
description "
This option lists the target's requirements for a valid Redboot
configuration."
cdl_option CYGBLD_BUILD_REDBOOT_BIN {
display "Build Redboot ROM binary image"
active_if CYGBLD_BUILD_REDBOOT
default_value 1
no_define
description "This option enables the conversion of the Redboot ELF
image to a binary image suitable for ROM programming."
compile -library=libextras.a
make -priority 325 {
<PREFIX>/bin/redboot.srec : <PREFIX>/bin/redboot.elf
$(OBJCOPY) --strip-all $< $(@:.srec=.img)
$(OBJCOPY) -O srec $< $@
}
}
}
 
}
/v2_0/include/plf_intr.h
0,0 → 1,123
#ifndef CYGONCE_HAL_PLF_INTR_H
#define CYGONCE_HAL_PLF_INTR_H
 
//==========================================================================
//
// plf_intr.h
//
// Atlas Interrupt and clock 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): nickg
// Contributors: nickg, jskov,
// gthomas, jlarmour, dmoseley
// Date: 2000-06-06
// Purpose: Define Interrupt support
// Description: The macros defined here provide the HAL APIs for handling
// interrupts and the clock for the Atlas board.
//
// Usage:
// #include <cyg/hal/plf_intr.h>
// ...
//
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#include <pkgconf/hal.h>
 
#include <cyg/infra/cyg_type.h>
#include <cyg/hal/plf_io.h>
 
//--------------------------------------------------------------------------
// Interrupt vectors.
 
#ifndef CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
 
// These are decoded via the IP bits of the cause
// register when an external interrupt is delivered.
 
#define CYGNUM_HAL_INTERRUPT_IRQ 0
#define CYGNUM_HAL_INTERRUPT_FIQ 1
 
// Min/Max ISR numbers and how many there are
#define CYGNUM_HAL_ISR_MIN 0
#define CYGNUM_HAL_ISR_MAX 1
#define CYGNUM_HAL_ISR_COUNT 2
 
#define CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
 
#endif
 
//--------------------------------------------------------------------------
// Interrupt controller access.
 
 
 
//--------------------------------------------------------------------------
// Control-C support.
 
#if defined(CYGDBG_HAL_MIPS_DEBUG_GDB_CTRLC_SUPPORT)
 
# define CYGHWR_HAL_GDB_PORT_VECTOR CYGNUM_HAL_INTERRUPT_SER
 
externC cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
 
# define HAL_CTRLC_ISR hal_ctrlc_isr
 
#endif
 
 
//----------------------------------------------------------------------------
// Reset.
#ifndef CYGHWR_HAL_RESET_DEFINED
#define CYGHWR_HAL_RESET_DEFINED
#define HAL_PLATFORM_RESET()
 
#define HAL_PLATFORM_RESET_ENTRY 0x00000000
 
#endif // CYGHWR_HAL_RESET_DEFINED
 
//---------------------------------------------------------------------------
// Delay
#define HAL_DELAY_US(x) hal_delay_us(x)
 
//--------------------------------------------------------------------------
#endif // ifndef CYGONCE_HAL_PLF_INTR_H
// End of plf_intr.h
/v2_0/include/plf_stub.h
0,0 → 1,94
#ifndef CYGONCE_HAL_PLF_STUB_H
#define CYGONCE_HAL_PLF_STUB_H
 
//=============================================================================
//
// plf_stub.h
//
// Platform header for GDB stub 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): msalter
// Contributors:msalter
// Date: 2001-02-12
// Purpose: Platform HAL stub support for CalmRISC32 eval boards.
// Usage: #include <cyg/hal/plf_stub.h>
//
//####DESCRIPTIONEND####
//
//=============================================================================
#include <pkgconf/hal.h>
 
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
 
#include <cyg/infra/cyg_type.h> // CYG_UNUSED_PARAM
 
#include <cyg/hal/calm32-stub.h> // architecture stub support
 
//----------------------------------------------------------------------------
// Define some platform specific communication details. This is mostly
// handled by hal_if now, but we need to make sure the comms tables are
// properly initialized.
 
externC void cyg_hal_plf_comms_init(void);
 
#define HAL_STUB_PLATFORM_INIT_SERIAL() cyg_hal_plf_comms_init()
 
#define HAL_STUB_PLATFORM_SET_BAUD_RATE(baud) CYG_UNUSED_PARAM(int, (baud))
#define HAL_STUB_PLATFORM_INTERRUPTIBLE 0
#define HAL_STUB_PLATFORM_INIT_BREAK_IRQ() CYG_EMPTY_STATEMENT
 
//----------------------------------------------------------------------------
// Stub initializer.
#define HAL_STUB_PLATFORM_INIT() CYG_EMPTY_STATEMENT
 
#endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
 
//-----------------------------------------------------------------------------
// Syscall support.
#ifdef CYGPKG_CYGMON
// Cygmon provides syscall handling for this board
#define SIGSYSCALL SIGSYS
extern int __get_syscall_num (void);
#endif
 
extern void hal_plf_write_prog_halfword(unsigned addr, unsigned short val);
 
//-----------------------------------------------------------------------------
#endif // CYGONCE_HAL_PLF_STUB_H
// End of plf_stub.h
/v2_0/include/pkgconf/mlt_calm32_ceb_rom.h
0,0 → 1,20
// eCos memory layout - Fri Oct 20 06:10:29 2000
 
// This is a generated file - do not edit
 
#ifndef __ASSEMBLER__
#include <cyg/infra/cyg_type.h>
#include <stddef.h>
 
#endif
#define CYGMEM_REGION_ram (0x00000000)
#define CYGMEM_REGION_ram_SIZE (0x80000)
#define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
#define CYGMEM_REGION_rom (0x100000000)
#define CYGMEM_REGION_rom_SIZE (0x80000)
#define CYGMEM_REGION_rom_ATTR (CYGMEM_REGION_ATTR_R)
#ifndef __ASSEMBLER__
extern char CYG_LABEL_NAME (__heap1) [];
#endif
#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1))
#define CYGMEM_SECTION_heap1_SIZE (0x80000 - (size_t) CYG_LABEL_NAME (__heap1))
/v2_0/include/pkgconf/mlt_calm32_ceb_rom.ldi
0,0 → 1,40
// eCos memory layout - Fri Oct 20 06:10:29 2000
 
// This is a generated file - do not edit
 
#include <cyg/infra/cyg_type.inc>
 
MEMORY
{
ram : ORIGIN = 0x000000, LENGTH = 0x80000
rom : ORIGIN = 0x100000000, LENGTH = 0x80000
}
 
SECTIONS
{
SECTIONS_BEGIN
SECTION_vectors (rom, 0x100000000, LMA_EQ_VMA)
SECTION_ROMISC (rom, ALIGN (0x40), LMA_EQ_VMA)
SECTION_RELOCS (rom, ALIGN (0x40), LMA_EQ_VMA)
SECTION_init (rom, ALIGN (0x40), LMA_EQ_VMA)
SECTION_text (rom, ALIGN (0x40), LMA_EQ_VMA)
SECTION_fini (rom, ALIGN (0x40), LMA_EQ_VMA)
SECTION_data (ram, 0x00000000, FOLLOWING (.fini))
SECTION_data1 (ram, ALIGN (0x40), FOLLOWING (.data))
SECTION_rodata (ram, ALIGN (0x40), FOLLOWING (.data1))
SECTION_rodata1 (ram, ALIGN (0x40), FOLLOWING (.rodata))
SECTION_eh_frame (ram, ALIGN (0x40), FOLLOWING (.rodata1))
SECTION_gcc_except_table (ram, ALIGN (0x40), FOLLOWING (.eh_frame))
SECTION_ctors (ram, ALIGN (0x40), FOLLOWING (.gcc_except_table))
SECTION_dtors (ram, ALIGN (0x40), FOLLOWING (.ctors))
SECTION_devtab (ram, ALIGN (0x40), FOLLOWING (.dtors))
SECTION_got (ram, ALIGN (0x40), FOLLOWING (.devtab))
SECTION_dynamic (ram, ALIGN (0x40), FOLLOWING (.got))
SECTION_sdata (ram, ALIGN (0x40), FOLLOWING (.dynamic))
SECTION_lit8 (ram, ALIGN (0x40), FOLLOWING (.sdata))
SECTION_lit4 (ram, ALIGN (0x40), FOLLOWING (.lit8))
SECTION_sbss (ram, ALIGN (0x40), LMA_EQ_VMA)
SECTION_bss (ram, ALIGN (0x40), LMA_EQ_VMA)
CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
SECTIONS_END
}
/v2_0/include/plf_cache.h
0,0 → 1,73
#ifndef CYGONCE_PLF_CACHE_H
#define CYGONCE_PLF_CACHE_H
 
//=============================================================================
//
// plf_cache.h
//
// HAL cache control API
//
//=============================================================================
//####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): nickg
// Contributors: nickg
// Date: 1998-02-17
// Purpose: Cache control API
// Description: The macros defined here provide the HAL APIs for handling
// cache control operations.
// Usage:
// #include <cyg/hal/plf_cache.h>
// ...
//
//
//####DESCRIPTIONEND####
//
//=============================================================================
 
#include <pkgconf/hal.h>
#include <cyg/infra/cyg_type.h>
 
#include <cyg/hal/plf_cache.h>
 
//=============================================================================
 
// Nothing here at present.
 
//-----------------------------------------------------------------------------
#endif // ifndef CYGONCE_PLF_CACHE_H
// End of plf_cache.h
 
/v2_0/include/platform.inc
0,0 → 1,96
#ifndef CYGONCE_HAL_PLATFORM_INC
#define CYGONCE_HAL_PLATFORM_INC
##=============================================================================
##
## platform.inc
##
## CalmRISC32 core eval board assembler header 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): msalter
## Contributors: msalter
## Date: 2001-02-12
## Purpose: Core eval board definitions.
## Description: This file contains various definitions and macros that are
## useful for writing assembly code for the core eval board.
## Usage:
## #include <cyg/hal/platform.inc>
## ...
##
##
######DESCRIPTIONEND####
##
##=============================================================================
 
#include <cyg/hal/calm32.inc>
 
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/plf_io.h>
 
#define CYGPKG_HAL_RESET_VECTOR_FIRST_CODE
.macro hal_reset_vector_first_code
.endm
 
#define CYGPKG_HAL_EARLY_INIT
.macro hal_early_init
.endm
 
#------------------------------------------------------------------------------
# Diagnostic macros
 
#ifndef CYGPKG_HAL_MIPS_DIAG_DEFINED
 
.macro hal_diag_init
.endm
 
.macro hal_diag_excpt_start
.endm
 
.macro hal_diag_intr_start
.endm
 
.macro hal_diag_restore
.endm
 
#define CYGPKG_HAL_MIPS_DIAG_DEFINED
 
#endif // ifndef CYGPKG_HAL_MIPS_DIAG_DEFINED
#------------------------------------------------------------------------------
#endif // ifndef CYGONCE_HAL_PLATFORM_INC
# end of platform.inc
/v2_0/include/plf_io.h
0,0 → 1,123
#ifndef CYGONCE_PLF_IO_H
#define CYGONCE_PLF_IO_H
 
//=============================================================================
//
// plf_io.h
//
// Platform specific IO 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): msalter
// Contributors: msalter
// Date: 2001-02-12
// Purpose: CalmRISC32 platform IO support
// Description:
// Usage: #include <cyg/hal/plf_io.h>
//
//####DESCRIPTIONEND####
//
//=============================================================================
 
#include <pkgconf/hal.h>
#include <cyg/hal/hal_misc.h>
 
// coprocessor regs
#define HAL_COP_SR_RBR 0x1c
#define HAL_COP_SR_TBR 0x1d
#define HAL_COP_TBR 0x1e
#define HAL_COP_RBR 0x1f
 
#ifndef __ASSEMBLER__
 
static inline void cyg_hal_plf_write_sr_rbr(int val)
{
asm volatile ("cld fr28,%0\n" : : "r"(val));
}
 
static inline void cyg_hal_plf_write_sr_tbr(int val)
{
asm volatile ("cld fr29,%0\n" : : "r"(val));
}
 
static inline void cyg_hal_plf_write_tbr(int val)
{
asm volatile ("cld fr30,%0\n" : : "r"(val));
}
 
static inline void cyg_hal_plf_write_rbr(int val)
{
asm volatile ("cld fr31,%0\n" : : "r"(val));
}
 
static inline int cyg_hal_plf_read_sr_rbr(void)
{
int val;
 
asm volatile ("cld %0,fr28\n" : "=r"(val) : );
return val;
}
 
static inline int cyg_hal_plf_read_sr_tbr(void)
{
int val;
 
asm volatile ("cld %0,fr29\n" : "=r"(val) : );
return val;
}
 
static inline int cyg_hal_plf_read_tbr(void)
{
int val;
 
asm volatile ("cld %0,fr30\n" : "=r"(val) : );
return val;
}
 
static inline int cyg_hal_plf_read_rbr(void)
{
int val;
 
asm volatile ("cld %0,fr31\n" : "=r"(val) : );
return val;
}
#endif
 
//-----------------------------------------------------------------------------
// end of plf_io.h
#endif // CYGONCE_PLF_IO_H
/v2_0/include/hal_diag.h
0,0 → 1,95
#ifndef CYGONCE_HAL_DIAG_H
#define CYGONCE_HAL_DIAG_H
 
/*=============================================================================
//
// hal_diag.h
//
// HAL Support for Kernel Diagnostic 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): nickg, gthomas
// Contributors: nickg, gthomas
// Date: 1998-09-11
// Purpose: HAL Support for Kernel Diagnostic Routines
// Description: Diagnostic routines for use during kernel development.
// Usage: #include <cyg/hal/hal_diag.h>
//
//####DESCRIPTIONEND####
//
//===========================================================================*/
 
#include <pkgconf/hal.h>
 
#include <cyg/infra/cyg_type.h>
 
#if defined(CYGSEM_HAL_VIRTUAL_VECTOR_DIAG)
 
#include <cyg/hal/hal_if.h>
 
#define HAL_DIAG_INIT() hal_if_diag_init()
#define HAL_DIAG_WRITE_CHAR(_c_) hal_if_diag_write_char(_c_)
#define HAL_DIAG_READ_CHAR(_c_) hal_if_diag_read_char(&_c_)
 
#else // everything by steam
 
/*---------------------------------------------------------------------------*/
/* functions implemented in hal_diag.c */
 
externC void hal_diag_init(void);
externC void hal_diag_write_char(char c);
externC void hal_diag_read_char(char *c);
 
/*---------------------------------------------------------------------------*/
 
#define HAL_DIAG_INIT() hal_diag_init()
 
#define HAL_DIAG_WRITE_CHAR(_c_) hal_diag_write_char(_c_)
 
#define HAL_DIAG_READ_CHAR(_c_) hal_diag_read_char(&_c_)
 
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
 
/*---------------------------------------------------------------------------*/
// LED
 
externC void hal_diag_led(int n);
 
/*---------------------------------------------------------------------------*/
/* end of hal_diag.h */
#endif /* CYGONCE_HAL_DIAG_H */
/v2_0/src/platform.S
0,0 → 1,86
##
#=============================================================================
## platform.S
##
## CalmRISC32 CEB platform 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####
##=============================================================================
#######DESCRIPTIONBEGIN####
##
## Author(s): msalter
## Contributors: msalter
## Date: 2001-02-12
## Purpose: CalmRISC32 platform code
## Description: Platform specific code for CalmRISC32 core evb
##
##
##
##
######DESCRIPTIONEND####
##
##=============================================================================
 
#include <pkgconf/system.h>
#include <pkgconf/hal.h>
 
#ifdef CYGPKG_KERNEL
# include <pkgconf/kernel.h>
#endif
 
#include <cyg/hal/arch.inc>
#include <cyg/hal/plf_io.h>
#include <cyg/hal/hal_arch.h>
 
##-----------------------------------------------------------------------------
 
##-----------------------------------------------------------------------------
# Platform Initialization.
# This code performs platform specific initialization.
 
##-----------------------------------------------------------------------------
## MEMC initialization.
##
 
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
 
#endif /* defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) */
 
 
##-----------------------------------------------------------------------------
# This code sets up a stack for applications running on redboot
 
##-----------------------------------------------------------------------------
## end of platform.S
/v2_0/src/hal_diag.c
0,0 → 1,183
/*=============================================================================
//
// hal_diag.c
//
// HAL diagnostic output 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####
//=============================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): nickg
// Contributors: nickg, dmoseley
// Date: 1998-03-02
// Purpose: HAL diagnostic output
// Description: Implementations of HAL diagnostic output support.
//
//####DESCRIPTIONEND####
//
//===========================================================================*/
 
#include <pkgconf/hal.h>
 
#include <cyg/infra/cyg_type.h> // base types
#include <cyg/infra/cyg_trac.h> // tracing macros
#include <cyg/infra/cyg_ass.h> // assertion macros
 
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_diag.h>
 
#include <cyg/hal/hal_intr.h>
 
#include <cyg/hal/hal_io.h>
 
//-----------------------------------------------------------------------------
// Select which diag channels to use
 
//#define CYG_KERNEL_DIAG_LCD
#define CYG_KERNEL_DIAG_SERIAL
 
/*---------------------------------------------------------------------------*/
 
void hal_diag_led(int x)
{
}
 
externC void diag_write_string (const char*);
 
#ifdef CYG_KERNEL_DIAG_SERIAL
extern void cyg_hal_plf_comms_init(void);
extern void cyg_hal_plf_serial_putc(void*, cyg_uint8);
extern cyg_uint8 cyg_hal_plf_serial_getc(void*);
#endif
 
void hal_diag_init(void)
{
#if defined(CYGSEM_HAL_ROM_MONITOR) && !defined(CYG_KERNEL_DIAG_SERIAL)
// It's handy to have the LCD initialized at reset when using it
// for debugging output.
// The serial port likely doesn't work yet. Let's wait.
diag_write_string ("eCos ROM " __TIME__ "\n");
diag_write_string (__DATE__ "\n");
#endif
 
#if defined(CYG_KERNEL_DIAG_SERIAL)
cyg_hal_plf_comms_init();
#endif
}
 
#if defined(CYG_KERNEL_DIAG_LCD)
static void hal_diag_clear_lcd(void)
{
volatile int i = 0x20000;
while (--i) ;
 
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS0, ' ');
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS1, ' ');
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS2, ' ');
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS3, ' ');
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS4, ' ');
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS5, ' ');
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS6, ' ');
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS7, ' ');
}
#endif /* defined(CYG_KERNEL_DIAG_LCD) */
 
void hal_diag_write_char(char c)
{
#if defined(CYG_KERNEL_DIAG_LCD)
static volatile CYG_WORD* reg = HAL_DISPLAY_ASCIIPOS0;
#endif
 
unsigned long __state;
 
HAL_DISABLE_INTERRUPTS(__state);
 
if(c == '\n')
{
#if defined(CYG_KERNEL_DIAG_LCD)
reg = HAL_DISPLAY_ASCIIPOS0;
hal_diag_clear_lcd();
#endif
#if defined (CYG_KERNEL_DIAG_SERIAL)
cyg_hal_plf_serial_putc(NULL, '\r');
cyg_hal_plf_serial_putc(NULL, '\n');
#endif
}
else if (c == '\r')
{
// Ignore '\r'
}
else
{
#if defined(CYG_KERNEL_DIAG_LCD)
if (reg == HAL_DISPLAY_ASCIIPOS0)
hal_diag_clear_lcd();
 
HAL_WRITE_UINT32(reg, c);
 
// Advance to next LED position.
if (reg == HAL_DISPLAY_ASCIIPOS0)
reg = HAL_DISPLAY_ASCIIPOS1;
else if (reg == HAL_DISPLAY_ASCIIPOS1)
reg = HAL_DISPLAY_ASCIIPOS2;
else if (reg == HAL_DISPLAY_ASCIIPOS2)
reg = HAL_DISPLAY_ASCIIPOS3;
else if (reg == HAL_DISPLAY_ASCIIPOS3)
reg = HAL_DISPLAY_ASCIIPOS4;
else if (reg == HAL_DISPLAY_ASCIIPOS4)
reg = HAL_DISPLAY_ASCIIPOS5;
else if (reg == HAL_DISPLAY_ASCIIPOS5)
reg = HAL_DISPLAY_ASCIIPOS6;
else if (reg == HAL_DISPLAY_ASCIIPOS6)
reg = HAL_DISPLAY_ASCIIPOS7;
else // reg == HAL_DISPLAY_ASCIIPOS7 or UNKNOWN
reg = HAL_DISPLAY_ASCIIPOS0;
#endif
#if defined(CYG_KERNEL_DIAG_SERIAL)
cyg_hal_plf_serial_putc(NULL, c);
#endif
}
 
HAL_RESTORE_INTERRUPTS(__state);
}
 
void hal_diag_read_char(char* c)
{
*c = cyg_hal_plf_serial_getc(NULL);
}
 
/*---------------------------------------------------------------------------*/
/* End of hal_diag.c */
/v2_0/src/ser.c
0,0 → 1,293
//=============================================================================
//
// ser.c
//
// Simple driver for the MDSChip serial port
//
//=============================================================================
//####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): msalter
// Contributors:msalter
// Date: 2001-02-12
// Description: Simple driver for the MDSChip serial port
//
//####DESCRIPTIONEND####
//
//=============================================================================
 
#include <pkgconf/hal.h>
#include <pkgconf/system.h>
#include CYGBLD_HAL_PLATFORM_H
 
#include <cyg/hal/hal_arch.h> // SAVE/RESTORE GP macros
#include <cyg/hal/hal_io.h> // IO macros
#include <cyg/hal/hal_if.h> // interface API
#include <cyg/hal/hal_intr.h> // HAL_ENABLE/MASK/UNMASK_INTERRUPTS
#include <cyg/hal/hal_misc.h> // Helper functions
#include <cyg/hal/drv_api.h> // CYG_ISR_HANDLED
 
// We have no control over baud rate
#if CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD==57600
#define CYG_DEV_SERIAL_BAUD_DIVISOR BAUD_57600
#endif
 
#ifndef CYG_DEV_SERIAL_BAUD_DIVISOR
#error Missing/incorrect serial baud rate defined - CDL error?
#endif
 
//-----------------------------------------------------------------------------
typedef struct {
cyg_uint8* base;
cyg_int32 msec_timeout;
int isr_vector;
} channel_data_t;
 
static channel_data_t channels[1] = {
{ (cyg_uint8*)0, 1000, 0}
};
 
//-----------------------------------------------------------------------------
// The minimal init, get and put functions. All by polling.
 
void
cyg_hal_plf_serial_init_channel(void* __ch_data)
{
cyg_hal_plf_write_sr_rbr(0);
cyg_hal_plf_write_sr_tbr(0);
cyg_hal_plf_write_tbr(0);
cyg_hal_plf_write_rbr(0);
}
 
void
cyg_hal_plf_serial_putc(void* __ch_data, cyg_uint8 __ch)
{
// wait for tx rdy
while (cyg_hal_plf_read_sr_tbr() != 0) ;
 
// Now, write it
cyg_hal_plf_write_tbr(__ch);
 
// and set TBR
cyg_hal_plf_write_sr_tbr(1);
}
 
static cyg_bool
cyg_hal_plf_serial_getc_nonblock(void* __ch_data, cyg_uint8* ch)
{
if (cyg_hal_plf_read_sr_rbr() == 0)
return false;
 
*ch = cyg_hal_plf_read_rbr();
 
cyg_hal_plf_write_sr_rbr(0);
 
return true;
}
 
cyg_uint8
cyg_hal_plf_serial_getc(void* __ch_data)
{
cyg_uint8 ch;
 
while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch));
 
return ch;
}
 
static void
cyg_hal_plf_serial_write(void* __ch_data, const cyg_uint8* __buf,
cyg_uint32 __len)
{
while(__len-- > 0)
cyg_hal_plf_serial_putc(__ch_data, *__buf++);
}
 
static void
cyg_hal_plf_serial_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len)
{
while(__len-- > 0)
*__buf++ = cyg_hal_plf_serial_getc(__ch_data);
}
 
 
cyg_bool
cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch)
{
int delay_count;
channel_data_t* chan;
cyg_bool res;
 
// Some of the diagnostic print code calls through here with no idea what the ch_data is.
// Go ahead and assume it is channels[0].
if (__ch_data == 0)
__ch_data = (void*)&channels[0];
 
chan = (channel_data_t*)__ch_data;
 
delay_count = chan->msec_timeout * 10; // delay in .1 ms steps
 
for(;;) {
res = cyg_hal_plf_serial_getc_nonblock(__ch_data, ch);
if (res || 0 == delay_count--)
break;
CYGACC_CALL_IF_DELAY_US(100);
}
 
return res;
}
 
static int
cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t __func, ...)
{
static int irq_state = 0;
channel_data_t* chan;
int ret = 0;
 
// Some of the diagnostic print code calls through here with no idea what the ch_data is.
// Go ahead and assume it is channels[0].
if (__ch_data == 0)
__ch_data = (void*)&channels[0];
 
chan = (channel_data_t*)__ch_data;
 
switch (__func) {
case __COMMCTL_IRQ_ENABLE:
irq_state = 1;
 
HAL_INTERRUPT_SET_LEVEL(chan->isr_vector, 1);
HAL_INTERRUPT_UNMASK(chan->isr_vector);
break;
case __COMMCTL_IRQ_DISABLE:
ret = irq_state;
irq_state = 0;
 
HAL_INTERRUPT_MASK(chan->isr_vector);
break;
case __COMMCTL_DBG_ISR_VECTOR:
ret = chan->isr_vector;
break;
case __COMMCTL_SET_TIMEOUT:
{
va_list ap;
 
va_start(ap, __func);
 
ret = chan->msec_timeout;
chan->msec_timeout = va_arg(ap, cyg_uint32);
 
va_end(ap);
}
break;
case __COMMCTL_SETBAUD:
{
cyg_uint32 baud_rate;
va_list ap;
 
va_start(ap, __func);
baud_rate = va_arg(ap, cyg_uint32);
va_end(ap);
 
switch (baud_rate)
{
case 57600: break;
default: return -1;
}
}
break;
 
case __COMMCTL_GETBAUD:
break;
default:
break;
}
return ret;
}
 
static int
cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc,
CYG_ADDRWORD __vector, CYG_ADDRWORD __data)
{
*__ctrlc = 0;
return 0;
}
 
static void
cyg_hal_plf_serial_init(void)
{
hal_virtual_comm_table_t* comm;
int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
 
// Disable interrupts.
HAL_INTERRUPT_MASK(channels[0].isr_vector);
 
// Init channels
cyg_hal_plf_serial_init_channel((void*)&channels[0]);
// Setup procs in the vector table
 
// Set channel 0
CYGACC_CALL_IF_SET_CONSOLE_COMM(0);
comm = CYGACC_CALL_IF_CONSOLE_PROCS();
CYGACC_COMM_IF_CH_DATA_SET(*comm, &channels[0]);
CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write);
CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read);
CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc);
CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc);
CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control);
CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_serial_isr);
CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout);
 
// Restore original console
CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
}
 
void
cyg_hal_plf_comms_init(void)
{
static int initialized = 0;
 
if (initialized)
return;
 
initialized = 1;
 
cyg_hal_plf_serial_init();
}
 
//-----------------------------------------------------------------------------
// end of ser16c550c.c
 
/v2_0/src/plf_misc.c
0,0 → 1,121
//==========================================================================
//
// plf_misc.c
//
// HAL platform miscellaneous functions
//
//==========================================================================
//####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): nickg
// Contributors: nickg, jlarmour, dmoseley, msalter
// Date: 2000-06-06
// Purpose: HAL miscellaneous functions
// Description: This file contains miscellaneous functions provided by the
// HAL.
//
//####DESCRIPTIONEND####
//
//========================================================================*/
 
#define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS
#include <pkgconf/hal.h>
 
#include <cyg/infra/cyg_type.h> // Base types
#include <cyg/infra/cyg_trac.h> // tracing macros
#include <cyg/infra/cyg_ass.h> // assertion macros
 
#include <cyg/hal/hal_arch.h> // architectural definitions
 
#include <cyg/hal/hal_intr.h> // Interrupt handling
 
#include <cyg/hal/hal_cache.h> // Cache handling
 
#include <cyg/hal/hal_if.h>
 
/*------------------------------------------------------------------------*/
 
#if defined(CYGPKG_CYGMON)
#include CYGHWR_MEMORY_LAYOUT_H
extern unsigned long cygmon_memsize;
#endif
 
void hal_platform_init(void)
{
// Set up eCos/ROM interfaces
hal_if_init();
}
 
 
/*------------------------------------------------------------------------*/
/* Delay for some number of useconds. */
void
hal_delay_us(int us)
{
us /= 20; // horrible code genration right now
while (us-- > 0) ;
}
 
/*------------------------------------------------------------------------*/
/* Reset support */
 
void hal_ceb_reset(void)
{
}
 
void hal_plf_write_prog_halfword(unsigned addr, unsigned short val)
{
unsigned short pch = addr >> 16;
unsigned short pcl = addr & 0xffff;
while(cyg_hal_plf_read_sr_tbr() & 1); // while TXD_FULL
cyg_hal_plf_write_tbr(pch);
cyg_hal_plf_write_sr_tbr(0x03); // addr_high short
 
while(cyg_hal_plf_read_sr_tbr() & 1); // while TXD_FULL
cyg_hal_plf_write_tbr(pcl);
cyg_hal_plf_write_sr_tbr(0x05); // addr_low short
 
while(cyg_hal_plf_read_sr_tbr() & 1); // while TXD_FULL
cyg_hal_plf_write_tbr(val);
cyg_hal_plf_write_sr_tbr(0x07); // program data value
 
while(cyg_hal_plf_read_sr_tbr() & 1); // while TXD_FULL
}
 
 
/*------------------------------------------------------------------------*/
/* End of plf_misc.c */
/v2_0/ChangeLog
0,0 → 1,48
2002-08-06 Gary Thomas <gary@chez-thomas.org>
2002-08-06 Motoya Kurotsu <kurotsu@allied-telesis.co.jp>
 
* src/ser.c: I/O channel data can't be constant - contains
timeout information which can be changed.
 
2001-03-26 Mark Salter <msalter@redhat.com>
 
* src/plf_misc.c (hal_delay_us): Fix loop count for better accuracy.
 
* src/platform.S: Remove unneeded ceb_program_new_stack.
 
* cdl/hal_calm32_ceb.cdl: Remove HAL_ARCH_PROGRAM_NEW_STACK.
 
//===========================================================================
//####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####
//===========================================================================
/v2_0/misc/readme.txt
0,0 → 1,80
RedBoot for the Samsung CalmRISC32 core evaluation board
May 7th 2001
README
========================================================================
 
This ReadMe contains instructions for running Redboot on the Samsung
calmRISC32 core evaluation board, and building RedBoot and ecosconfig.
 
You will need the GNUPro calmrisc32-elf toolchain which should be
installed in /usr/cygnus.
 
Overview
--------
This implementation of RedBoot supports the calmRISC32 core evaluation board.
The core board has no communication channel and requires an MDSChip board to
provide a serial channel for host communication. The calmRISC32 is a harvard
architecture with separate 32-bit program and data addresses. The instruction
set provides no instruction for writing to program memory. The MDSChip board
firmware (called CalmBreaker) provides a pseudo register interface so that
code running on the core has access to a serial channel and a mechanism to
write to program memory. The serial channel is fixed at 57600-8-N-1 by the
firmware. The CalmBreaker firmware also provides a serial protocol which
allows a host to download a program and to start or stop the core board.
 
 
Downloading and running RedBoot
--------------------------------
All storage on the core board is volatile, so RedBoot must be downloaded to
the board after every power cycle. Downloads require the use of a utility
program. The source file and build instructions for this utility are provided
in the RedBoot sources at:
 
.../packages/hal/calmrisc32/ceb/current/support
 
To download the RedBoot image, first press the reset button on the MDSChip
board. The green 'Run' LED on the core board should go off. Now, use the
utility to download the RedBoot image with:
 
% calmbreaker -p /dev/term/b --reset --srec-code -f redboot.elf
 
Note that the '-p /dev/term/b' specifies the serial port to use and will vary
from system to syetm. The download will take about two minutes. After it
finishes, start RedBoot with:
 
% calmbreaker -p /dev/term/b --run
 
The 'Run' LED on the core board should be on. Connecting to the MDSboard with
a terminal and typing enter should result in RedBoot reprinting the command
prompt.
 
Rebuilding RedBoot
------------------
 
Assuming that the provided RedBoot source tree is located in the current
directory, the build process is:
 
% export TOPDIR=`pwd`
% export ECOS_REPOSITORY=${TOPDIR}/packages
% mkdir ${TOPDIR}/build
% cd ${TOPDIR}/build
% ecosconfig new calm32_ceb redboot
% ecosconfig import ${ECOS_REPOSITORY}/hal/calmrisc32/current/misc/redboot_ROM.ecm
% ecosconfig tree
% make
 
 
Building ecosconfig
-------------------
 
An ecosconfig binary is supplied in the bin directory, but you may wish
to build it from source.
 
Detailed instructions for building the command-line tool ecosconfig
can be found in host/README. For example:
 
mkdir $TEMP/redboot-build
cd $TEMP/redboot-build
$TOPDIR/host/configure --prefix=$TEMP/redboot-build --with-tcl=/usr
make
 
/v2_0/misc/redboot_ROM.ecm
0,0 → 1,65
cdl_savefile_version 1;
cdl_savefile_command cdl_savefile_version {};
cdl_savefile_command cdl_savefile_command {};
cdl_savefile_command cdl_configuration { description hardware template package };
cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value };
cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value };
cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value };
cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value };
 
cdl_configuration eCos {
description "" ;
hardware ceb ;
template redboot ;
package -hardware CYGPKG_HAL_CALM32 v2_0 ;
package -hardware CYGPKG_HAL_CALM32_CORE v2_0 ;
package -template CYGPKG_HAL v2_0 ;
package -template CYGPKG_INFRA v2_0 ;
package -template CYGPKG_REDBOOT v2_0 ;
};
 
cdl_option CYGBLD_BUILD_GDB_STUBS {
user_value 0
};
 
cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT {
user_value 0
};
 
cdl_option CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM {
inferred_value 0
};
 
cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS {
inferred_value 1
};
 
cdl_option CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT {
inferred_value 1
};
 
cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT {
inferred_value 0
};
 
cdl_option CYGSEM_HAL_ROM_MONITOR {
user_value 1
};
 
cdl_option CYGSEM_HAL_USE_ROM_MONITOR {
inferred_value 0 0
};
 
cdl_component CYG_HAL_STARTUP {
user_value ROM
};
 
cdl_option CYGBLD_BUILD_REDBOOT {
user_value 1
};
 
cdl_option CYGSEM_REDBOOT_BSP_SYSCALLS {
user_value 1
};
 
 
/v2_0/support/calmbreaker.c
0,0 → 1,541
/*=============================================================================
//
// calmbreaker.c
//
// Host to CalmBreaker communication utility.
//
//=============================================================================
//####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): msalter
// Contributors: msalter
// Date: 2001-03-02
// Purpose:
// Description: Host to CalmBreaker communication utility.
//
//####DESCRIPTIONEND####
//
//===========================================================================*/
 
#include <termios.h>
#include <fcntl.h>
#include <stdio.h>
 
int ser_fd; // The com port
int is_risc16;
 
void
tty_setup(int fd)
{
struct termios t;
 
memset(&t, 0, sizeof(struct termios));
 
t.c_oflag = 0;
t.c_lflag = 0;
t.c_cflag &= ~(CSIZE | PARENB);
t.c_cflag |= CS8 | CREAD /*| CSTOPB*/;
t.c_cflag |= CLOCAL; // ignore modem status lines
 
t.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ;
 
t.c_lflag &= ~ICANON; // non-canonical mode
t.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE);
 
t.c_cc[VMIN] = 0;
t.c_cc[VTIME] = 10; // 1 second timeout
 
t.c_cflag &= ~CRTSCTS;
 
/* set speed */
cfsetispeed(&t, B57600);
cfsetospeed(&t, B57600);
 
tcdrain(fd);
 
if (tcsetattr(fd, TCSANOW, &t) < 0)
{
perror("tcssetattr");
exit(1);
}
}
 
static void
do_putc(unsigned char ch)
{
// keep retrying until sent or an error is returned
while (write(ser_fd, &ch, 1) == 0);
}
 
static int
do_getc(unsigned char *ucp)
{
return read(ser_fd, ucp, 1);
}
 
static int
wait_for_ack(void)
{
unsigned char ch;
int i;
 
// try for 5 seconds
for (i = 0; i < 5; i++) {
if (do_getc(&ch)) {
if (ch == '+')
return 1;
printf("Bad ack [0x%x]\n", ch);
}
}
printf("No ack\n");
return 0;
}
 
// Add prefix and checksum to packet and send to MDS board.
void
send_packet_noack(unsigned char *pkt, int len)
{
unsigned char cksum = 0;
 
do_putc(':');
 
while (len-- > 0) {
cksum += *pkt;
do_putc(*pkt++);
}
 
do_putc(0x100 - cksum);
}
 
// Add prefix and checksum to packet and send to MDS board.
void
send_packet(unsigned char *pkt, int len)
{
send_packet_noack(pkt, len);
wait_for_ack();
}
 
 
 
// Send a packet of code or data (max 0xff bytes)
int
send_data_packet(int is_data, unsigned addr, unsigned char *buf, int buflen)
{
unsigned char uc, cksum = 0;
int i;
do_putc(':');
// code or data?
uc = is_data ? 0x52 : 0x51;
cksum += uc;
do_putc(uc);
 
// code/data nwords?
uc = buflen >> 1;
cksum += uc;
do_putc(uc);
 
// code/data address
uc = (unsigned char)(addr >> 24);
cksum += uc;
do_putc(uc);
uc = (unsigned char)(addr >> 16);
cksum += uc;
do_putc(uc);
uc = (unsigned char)(addr >> 8);
cksum += uc;
do_putc(uc);
uc = (unsigned char)addr;
cksum += uc;
do_putc(uc);
 
while (buflen-- > 0) {
cksum += *buf;
do_putc(*buf++);
}
 
do_putc(0x100 - cksum);
 
return wait_for_ack();
}
 
 
void
send_command(unsigned char uc)
{
send_packet(&uc, 1);
}
 
void
send_command_noack(unsigned char uc)
{
send_packet_noack(&uc, 1);
}
 
// Simple single-byte commands
void target_reset(void) { send_command(0x20); }
void target_singlestep(void) { send_command(0x22); }
void target_singlecycle(void) { send_command(0x23); }
void target_stop(void) { send_command(0x24); }
void target_run(void) { send_command_noack(0x25); }
 
#define DOWNLOAD_CHUNK_SIZE 254
 
int
download_words(int is_data, unsigned addr, unsigned char *buf, int buflen)
{
while (buflen >= DOWNLOAD_CHUNK_SIZE) {
if (!send_data_packet(is_data, addr, buf, DOWNLOAD_CHUNK_SIZE)) {
printf("Error downloading %d bytes of %s to 0x%x\n",
DOWNLOAD_CHUNK_SIZE, (is_data ? "data" : "code"), addr);
return 0;
}
addr += DOWNLOAD_CHUNK_SIZE;
buf += DOWNLOAD_CHUNK_SIZE;
buflen -= DOWNLOAD_CHUNK_SIZE;
}
if (buflen && !send_data_packet(is_data, addr, buf, buflen)) {
printf("Error downloading %d bytes of %s to 0x%x\n",
buflen, (is_data ? "data" : "code"), addr);
return 0;
}
return 1;
}
 
static inline int
gethexnibble(FILE *fp)
{
int ch;
 
ch = getc(fp);
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);
 
if (ch == EOF)
fprintf(stderr, "Unexpected EOF\n");
else
fprintf(stderr, "Bad hex char\n");
 
return -1;
}
 
 
static inline int
gethexbyte(FILE *fp)
{
int nib;
unsigned char n;
 
if ((nib = gethexnibble(fp)) < 0)
return -1;
n = nib << 4;
if ((nib = gethexnibble(fp)) < 0)
return -1;
n |= nib;
return n;
}
 
static inline int
chk_cksum(FILE *fp, unsigned int cksum)
{
int n;
 
if ((n = gethexbyte(fp)) < 0)
return -1;
 
cksum = ~cksum & 0xff;
 
if (cksum != n) {
fprintf(stderr, "Bad cksum[%02x]\n", cksum);
return -1;
}
return 0;
}
 
int
load_srec(FILE *fp, int is_data)
{
int count, dcount, data, n, addr_bytes = 0, is_term, is_comment;
unsigned long address, cksum;
unsigned char data_buf[256];
 
is_comment = is_term = 0;
 
do {
if ((n = getc(fp)) == EOF)
return 1;
} while (n != 'S');
switch (n = gethexnibble(fp)) {
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:
if (n < 0)
return -1;
fprintf(stderr, "Bad record type: %d\n", n);
return -1;
}
 
if ((count = gethexbyte(fp)) < 0)
return -1;
 
cksum = count;
 
--count; // don't count chksum
 
if (is_comment) {
while (count > 0) {
if ((n = gethexbyte(fp)) < 0)
return -1;
cksum += n;
--count;
}
if (chk_cksum(fp,cksum) < 0)
return -1;
return 0;
}
 
address = 0;
while (count > 0 && addr_bytes) {
if ((n = gethexbyte(fp)) < 0)
return -1;
cksum += n;
address = (address << 8) | n;
--addr_bytes;
--count;
}
 
if (is_risc16 && (address & 0x400000))
address &= 0x3fffff;
 
if (is_term) {
if (count || addr_bytes) {
fprintf(stderr, "Malformed record cnt[%d] abytes[%d]\n",
count, addr_bytes);
return -1;
}
if (chk_cksum(fp, cksum) == 0) {
fprintf(stderr, "Setting start address: 0x%08x\n", address);
return 1;
}
return -1;
}
 
for (dcount = 0; dcount < count; dcount++) {
if ((data = gethexbyte(fp)) < 0)
return -1;
cksum += data;
data_buf[dcount] = data;
}
if (chk_cksum(fp, cksum) < 0)
return -1;
 
if (dcount & 1)
dcount++;
 
if (!download_words(is_data, address, data_buf, dcount))
return -1;
return 0;
}
 
 
int
load_hex(FILE *fp, int is_data)
{
int count, n, i;
unsigned long address;
unsigned char data_buf[256];
do {
if ((n = getc(fp)) == EOF)
return 1;
} while (n == '\r' || n == '\n');
 
if (n == '#') {
do {
if ((n = getc(fp)) == EOF)
return 1;
} while (n != '\r' && n != '\n');
return 0;
}
 
if (n != ':') {
fprintf(stderr, "Unrecognized HEX line start.\n");
return -1;
}
 
if ((count = gethexbyte(fp)) < 0)
return -1;
 
address = 0;
for (i = 0; i < 4; i++) {
if ((n = gethexbyte(fp)) < 0)
return -1;
address = (address << 8) | n;
}
 
// skip type byte
if ((n = gethexbyte(fp)) < 0)
return -1;
 
for (i = 0; i < count; i++) {
if ((n = gethexbyte(fp)) < 0)
return -1;
data_buf[i] = n;
}
 
// skip chksum byte
if ((n = gethexbyte(fp)) < 0)
return -1;
 
if (count & 1)
++count;
 
if (!download_words(is_data, address, data_buf, count))
return -1;
return 0;
}
 
 
int
main(int argc, char *argv[])
{
int i;
int do_download = 0, is_data, is_hex;
int do_run = 0, do_reset = 0;
char *filename = NULL;
char *portname = "/dev/ttyS0";
FILE *infile;
 
if (argc == 1) {
fprintf(stderr, "Usage: mds_talk [--run] [--reset] [--srec-code | --srec-date | --hex-code | --hex-data] [-f filename] [-p serial_dev]\n");
exit(1);
}
 
is_risc16 = 0;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--srec-code")) {
do_download = 1;
is_data = 0;
is_hex = 0;
} else if (!strcmp(argv[i], "--srec-data")) {
do_download = 1;
is_data = 1;
is_hex = 0;
} else if (!strcmp(argv[i], "--hex-code")) {
do_download = 1;
is_data = 0;
is_hex = 1;
} else if (!strcmp(argv[i], "--hex-data")) {
do_download = 1;
is_data = 1;
is_hex = 1;
} else if (!strcmp(argv[i], "--reset"))
do_reset = 1;
else if (!strcmp(argv[i], "--run"))
do_run = 1;
else if (!strcmp(argv[i], "-f")) {
if (++i >= argc) {
fprintf(stderr, "Missing filename\n");
exit(1);
}
filename = argv[i];
} else if (!strcmp(argv[i], "-p")) {
if (++i >= argc) {
fprintf(stderr, "Missing serial port name\n");
exit(1);
}
portname = argv[i];
} else if (!strcmp(argv[i], "--risc16")) {
is_risc16 = 1;
} else {
fprintf(stderr, "Unknown argument \"%s\"\n", argv[i]);
exit(1);
}
}
 
if ((ser_fd = open(portname, O_RDWR | O_NOCTTY)) < 0) {
fprintf(stderr, "Can't open port %s\n", portname);
exit(1);
}
tty_setup(ser_fd);
 
if (filename) {
if ((infile = fopen(filename, "r")) == NULL) {
fprintf(stderr, "Can't open file %s\n", filename);
exit(1);
}
} else
infile = stdin;
 
if (do_reset)
target_reset();
 
if (do_download) {
if (is_hex)
while (!load_hex(infile, is_data)) ;
else
while (!load_srec(infile, is_data)) ;
}
 
if (do_run)
target_run();
}
/v2_0/support/README
0,0 → 1,23
 
The support directory provides a tool for downloading code to the calmRISC
board. This simple application communicates over a serial line (57600-8-N-1)
with the MDSChip board which in turn controls the core eval board.
 
Building the tool:
 
% gcc -g -O2 calmbreaker.c -o calmbreaker
 
Using the tool:
 
calmbreaker [--reset] [--run] [-p serialdev] [--srec-code | --srec-data]
[-f filename]
 
--reset ==> Reset the board. Stops the core.
--run ==> Start the core running at the reset vector
-p ==> Specify the serial device
--srec-code ==> Download s-records to program memory
--srec-date ==> Download s-records to data memory
-f ==> Specify s-record file. If -f is missing, use
stdin.
 
 

powered by: WebSVN 2.1.0

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