changeset 421:9352d202f4b1

Upgrade mn10300/asb2303 from cygmon to RedBoot
author msalter
date Thu, 14 Nov 2002 17:53:24 +0000
parents d35f86833a7c
children 645053dc2f10
files packages/ChangeLog packages/devs/flash/mn10300/asb2303/current/ChangeLog packages/devs/flash/mn10300/asb2303/current/cdl/flash_asb2303.cdl packages/devs/flash/mn10300/asb2303/current/src/mn10300_asb2303_flash.c packages/ecos.db packages/hal/mn10300/am33/current/ChangeLog packages/hal/mn10300/am33/current/cdl/hal_mn10300_am33.cdl packages/hal/mn10300/am33/current/include/var_intr.h packages/hal/mn10300/am33/current/src/redboot_linux_exec.c packages/hal/mn10300/am33/current/src/var_misc.c packages/hal/mn10300/asb/current/ChangeLog packages/hal/mn10300/asb/current/cdl/hal_mn10300_am33_asb.cdl packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_flash.h packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_flash.ldi packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_flash.mlt packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_ram.h packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_ram.ldi packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_ram.mlt packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_rom.h packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_rom.ldi packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_rom.mlt packages/hal/mn10300/asb/current/include/platform.inc packages/hal/mn10300/asb/current/misc/redboot_FLASH.ecm packages/hal/mn10300/asb/current/misc/redboot_RAM.ecm packages/hal/mn10300/asb/current/misc/redboot_ROM.ecm packages/hal/mn10300/asb/current/src/plf_misc.c packages/hal/mn10300/asb/current/src/plf_stub.c packages/hal/mn10300/asb/current/src/ser_asb.c packages/hal/mn10300/asb2305/current/ChangeLog packages/hal/mn10300/asb2305/current/cdl/hal_mn10300_am33_asb2305.cdl packages/hal/mn10300/asb2305/current/src/plf_misc.c packages/hal/mn10300/asb2305/current/src/redboot_cmds.c
diffstat 32 files changed, 1173 insertions(+), 474 deletions(-) [+]
line wrap: on
line diff
--- a/packages/ChangeLog
+++ b/packages/ChangeLog
@@ -1,3 +1,7 @@
+2002-11-14  Mark Salter  <msalter@redhat.com>
+
+	* ecos.db: Add flash package for AM33 ASB2303.
+
 2002-11-12  Gary Thomas  <gary@mlbassoc.com>
 
 	* ecos.db: Add NPWR (Xscale from Team ASA).  Reorganize Xscale
new file mode 100644
--- /dev/null
+++ b/packages/devs/flash/mn10300/asb2303/current/ChangeLog
@@ -0,0 +1,35 @@
+
+//===========================================================================
+//####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####
+//===========================================================================
new file mode 100644
--- /dev/null
+++ b/packages/devs/flash/mn10300/asb2303/current/cdl/flash_asb2303.cdl
@@ -0,0 +1,81 @@
+# ====================================================================
+#
+#      flash_asb2303.cdl
+#
+#      FLASH memory - Hardware support on Matsushita ASB2303
+#
+# ====================================================================
+#####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:  dhowells
+# Contributors:
+# Date:           2002-11-08
+#
+#####DESCRIPTIONEND####
+#
+# ====================================================================
+
+cdl_package CYGPKG_DEVS_FLASH_MN10300_ASB2303 {
+    display       "Matsushita MN10300 ASB2303 FLASH memory support"
+
+    parent        CYGPKG_IO_FLASH
+    active_if     CYGPKG_IO_FLASH
+    requires      CYGPKG_HAL_MN10300_AM33_ASB
+
+    implements    CYGHWR_IO_FLASH_DEVICE
+
+    compile       mn10300_asb2303_flash.c
+
+    # Arguably this should do in the generic package
+    # but then there is a logic loop so you can never enable it.
+    cdl_interface CYGINT_DEVS_FLASH_AMD_AM29XXXXX_REQUIRED {
+        display   "Generic AMD AM29XXXXX driver required"
+    }
+
+    cdl_option CYGHWR_DEVS_FLASH_MN10300_ASB2303_BANK {
+        display       "Which flash bank to program"
+        flavor        data
+        legal_values  { "BootPROM" "SysFlash" }
+        default_value { "SysFlash" }
+        description   "
+           This option controls which bank of flash will be programmable."
+    }
+
+    implements    CYGINT_DEVS_FLASH_AMD_AM29XXXXX_REQUIRED
+    requires      CYGHWR_DEVS_FLASH_AMD_AM29DL324D
+    requires      CYGHWR_DEVS_FLASH_AMD_AM29LV800
+}
new file mode 100644
--- /dev/null
+++ b/packages/devs/flash/mn10300/asb2303/current/src/mn10300_asb2303_flash.c
@@ -0,0 +1,88 @@
+//==========================================================================
+//
+//      mn10300_asb2303_flash.c
+//
+//      Flash programming for Matsushita ASB2303
+//
+//==========================================================================
+//####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:         2002-11-08
+// Purpose:      
+// Description:  
+//              
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+#include <pkgconf/devs_flash_mn10300_asb2303.h>
+
+//--------------------------------------------------------------------------
+// Device properties
+
+#if defined(CYGHWR_DEVS_FLASH_MN10300_ASB2303_BANK_SysFlash)
+// We use a four chip parallel AM29DL324BE module plugged into the System Flash socket
+// on the ASB2303 board.
+#define CYGNUM_FLASH_INTERLEAVE	(4)
+#define CYGNUM_FLASH_SERIES	(1)
+#define CYGNUM_FLASH_WIDTH	(8)
+#define CYGNUM_FLASH_16AS8
+#define CYGNUM_FLASH_BASE 	(0x84000000u)	/* cached flash chip address */
+
+#elif defined(CYGHWR_DEVS_FLASH_MN10300_ASB2303_BANK_BootPROM)
+// We have a single AM29LV800TA soldered onto the board as the boot PROM
+#define CYGNUM_FLASH_INTERLEAVE	(1)
+#define CYGNUM_FLASH_SERIES	(1)
+#define CYGNUM_FLASH_WIDTH	(16)
+#define CYGNUM_FLASH_BASE 	(0x80000000u)	/* cached flash chip address */
+
+#else
+#error unknown flash bank selected
+#endif
+
+//--------------------------------------------------------------------------
+// Platform specific extras
+
+// Offset of uncached shadow region
+#define FLASH_P2V( _a_ ) ((volatile flash_data_t *)((CYG_ADDRWORD)(_a_)+0x20000000))
+
+//--------------------------------------------------------------------------
+// Now include the driver code.
+#include "cyg/io/flash_am29xxxxx.inl"
+
+// ------------------------------------------------------------------------
+// EOF mn10300_asb2303_flash.c
--- a/packages/ecos.db
+++ b/packages/ecos.db
@@ -492,6 +492,17 @@ package CYGPKG_DEVS_FLASH_MN10300_STB {
            This package contains hardware support for FLASH memory
 	   on the Matsushita MN10300 STB platform (SRAM2 socket)."
 }
+
+package CYGPKG_DEVS_FLASH_MN10300_ASB2303 {
+	alias 		{ "FLASH memory support for Matsushita ASB2303" flash_asb2303 }
+	directory	devs/flash/mn10300/asb2303
+	script		flash_asb2303.cdl
+	hardware
+        description "
+           This package contains hardware support for FLASH memory
+	   on the Matsushita MN10300 ASB2303 platform (system flash socket)."
+}
+
 package CYGPKG_DEVS_FLASH_MN10300_ASB2305 {
 	alias 		{ "FLASH memory support for Matsushita ASB2305" flash_asb2305 }
 	directory	devs/flash/mn10300/asb2305
@@ -3907,6 +3918,8 @@ target asb {
 	packages        { CYGPKG_HAL_MN10300
                           CYGPKG_HAL_MN10300_AM33_ASB
                           CYGPKG_HAL_MN10300_AM33
+                          CYGPKG_DEVS_FLASH_AMD_AM29XXXXX
+                          CYGPKG_DEVS_FLASH_MN10300_ASB2303
         }
         description "
            The asb target provides the packages needed to run
--- a/packages/hal/mn10300/am33/current/ChangeLog
+++ b/packages/hal/mn10300/am33/current/ChangeLog
@@ -1,3 +1,11 @@
+2002-11-14  Mark Salter  <msalter@redhat.com>
+
+	* include/var_intr.h (HAL_CLOCK_INITIALIZE): Save _period_ for
+	use by other code.
+
+	* src/redboot_cmds.c: New file.
+	* cdl/hal_mn10300_am33.cdl: Add support for RedBoot exec command.
+
 2001-10-18  David Howells  <dhowells@redhat.com>
 
 	* include/variant.inc: Suppress as many interrupt sources as
--- a/packages/hal/mn10300/am33/current/cdl/hal_mn10300_am33.cdl
+++ b/packages/hal/mn10300/am33/current/cdl/hal_mn10300_am33.cdl
@@ -81,6 +81,68 @@ cdl_package CYGPKG_HAL_MN10300_AM33 {
 
     compile       var_misc.c variant.S
 
+    cdl_option CYGHWR_HAL_MN10300_PROCESSOR_OSC {
+        display       "Processor Oscillator input"
+        flavor        data
+        legal_values  16666667 to 33333333
+        default_value { CYGHWR_HAL_MN10300_PROCESSOR_OSC_DEFAULT ?
+                        CYGHWR_HAL_MN10300_PROCESSOR_OSC_DEFAULT : 25000000}
+        description   "
+           The MN10300 processor can run at various frequencies. These
+           values are expressed in Hz.  Note that there are several
+           steppings of the MN10300 rated to run at different maximum
+           frequencies.  Check the specs to make sure that your
+           particular processor can run at the rate you select here."
+    }
+
+    # Real-time clock/counter specifics
+    cdl_component CYGNUM_HAL_RTC_CONSTANTS {
+        display       "Real-time clock constants."
+        description   "
+            The NUMERATOR divided by the DENOMINATOR gives the number of
+            nanoseconds per tick. The PERIOD is the divider to be programmed
+            into a hardware timer that is driven from an appropriate hardware
+            clock, such that the timer overflows once per tick (normally
+            generating a CPU interrupt to mark the end of a tick). The tick
+            rate is typically 100Hz.
+            The clock is generated with onboard 16-bit timers TM4 and TM5
+            cascaded together to form a 32-bit timer."
+        flavor none
+
+        cdl_option CYGHWR_HAL_MN10300_IOCLK_SPEED {
+            display          "Processor I/O clock speed (Hz)"
+            flavor           data
+            calculated       CYGHWR_HAL_MN10300_PROCESSOR_OSC
+            description      "
+                The processor I/O clock speed, from which onboard timers can
+                draw their sources."
+        }
+
+        cdl_option CYGNUM_HAL_RTC_NUMERATOR {
+            display       "Real-time clock numerator"
+            flavor        data
+            calculated    (1000 * 1000 * 1000)
+        }
+
+        cdl_option CYGNUM_HAL_RTC_DENOMINATOR {
+            display       "Real-time clock denominator"
+            flavor        data
+            calculated    100
+            description   "
+              This option selects the heartbeat rate for the real-time clock.
+              The rate is specified in ticks per second.  Change this value
+              with caution - too high and your system will become saturated
+              just handling clock interrupts, too low and some operations
+              such as thread scheduling may become sluggish."
+        }
+
+        cdl_option CYGNUM_HAL_RTC_PERIOD {
+            display       "Real-time clock divisor"
+            flavor        data
+            calculated    (CYGHWR_HAL_MN10300_IOCLK_SPEED / CYGNUM_HAL_RTC_DENOMINATOR)
+        }
+    }
+
     make {
         <PREFIX>/lib/target.ld: <PACKAGE>/src/mn10300_am33.ld
         $(CC) -E -P -Wp,-MD,target.tmp -DEXTRAS=1 -xc $(INCLUDE_PATH) $(CFLAGS) -o $@ $<
@@ -106,4 +168,37 @@ cdl_package CYGPKG_HAL_MN10300_AM33 {
             without turning off CPU data caching."
     }
 
+    cdl_component CYGPKG_REDBOOT_MN10300_AM33_OPTIONS {
+        display       "Redboot for AM33 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_component CYGPKG_REDBOOT_AM33_LINUX_EXEC {
+            display        "Provide the exec command in RedBoot"
+            flavor         none
+            parent         CYGPKG_REDBOOT_MN10300_AM33_OPTIONS
+            active_if      CYGBLD_BUILD_REDBOOT_WITH_EXEC
+            description    "
+                This option contains requirements for booting linux
+                from RedBoot. The component is enabled/disabled from
+                RedBoots CDL."
+            compile -library=libextras.a redboot_linux_exec.c
+
+            cdl_option CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS {
+                display       "Base address of linux kernel command line"
+                flavor        data
+                default_value 0x8C001000
+                description   "
+                   This is the base address of the area of memory used to
+                   pass a command line to the Linux kernel. This should be
+                   chosen to avoid overlap with the kernel and any ramdisk
+                   image."
+            }
+        }
+    }
 }
--- a/packages/hal/mn10300/am33/current/include/var_intr.h
+++ b/packages/hal/mn10300/am33/current/include/var_intr.h
@@ -513,6 +513,7 @@ CYG_MACRO_END
 
 //--------------------------------------------------------------------------
 // Clock control.
+extern cyg_uint32 __hal_period__;
 
 #define HAL_CLOCK_INITIALIZE( _period_ )                                \
 {                                                                       \
@@ -532,6 +533,8 @@ CYG_MACRO_END
                                                                         \
     *timer4_md = 0x40;                                                  \
     *timer4_md = 0x80;                                                  \
+                                                                        \
+    __hal_period__ = _period_;                                          \
 }
 
 #define HAL_CLOCK_RESET( _vector_, _period_ )
@@ -552,12 +555,12 @@ CYG_MACRO_END
         t4 = *timer4_cr;                                                \
     } while( t5 != *timer5_cr );                                        \
                                                                         \
-    *(_pvalue_) = CYGNUM_KERNEL_COUNTERS_RTC_PERIOD - ((t5<<16) + t4);  \
+    *(_pvalue_) = __hal_period__ - ((t5<<16) + t4);                     \
 }
 
-// FIXME: above line should not use CYGNUM_KERNEL_COUNTERS_RTC_PERIOD since
-// this means the HAL gets configured by kernel options even when the
-// kernel is disabled!
+extern void hal_delay_us(cyg_int32 usecs);
+
+#define HAL_DELAY_US(n)          hal_delay_us(n);
 
 
 //--------------------------------------------------------------------------
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/am33/current/src/redboot_linux_exec.c
@@ -0,0 +1,132 @@
+//==========================================================================
+//
+//      redboot_linux_exec.c
+//
+//      AM33 Linux specific RedBoot exec command
+//
+//==========================================================================
+//####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):    dhowells
+// Contributors: gthomas, jskov, msalter
+// Date:         2001-07-19
+// Purpose:      
+// Description:  
+//              
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+
+#include <cyg/hal/hal_intr.h>
+#include <cyg/hal/hal_cache.h>
+
+// Exported CLI function(s)
+
+// The exec command works like the go command in YAMON - that is,
+// providing callee with argc, argv, and env. In addition to the
+// information provided by the user, 
+
+static void do_exec(int argc, char *argv[]);
+
+static char exec_usage[] =
+            "[-w timeout] [-c \"kernel command line\"] [<entry_point>]";
+
+RedBoot_cmd("exec", 
+            "Execute an image - with MMU off", 
+            exec_usage,
+            do_exec
+	    );
+
+typedef void (*code_fun)(void) __attribute__((noreturn));
+
+static void 
+do_exec(int argc, char *argv[])
+{
+    unsigned long oldints;
+    bool wait_time_set;
+    int  wait_time, res;
+    bool cmd_line_set;
+    struct option_info opts[4];
+    code_fun entry;
+    char line[8];
+    char *cmd_line;
+    int num_options;
+
+    entry = (code_fun)entry_address;  // Default from last 'load' operation
+    init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM, 
+              (void **)&wait_time, (bool *)&wait_time_set, "wait timeout");
+    init_opts(&opts[1], 'c', true, OPTION_ARG_TYPE_STR, 
+              (void **)&cmd_line, (bool *)&cmd_line_set, "kernel command line");
+    num_options = 2;
+
+    if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry, 
+                   OPTION_ARG_TYPE_NUM, "starting address"))
+    {
+        return;
+    }
+    if (cmd_line_set) {
+	memcpy((char*)CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS,"cmdline:",8);
+        strncpy((char*)CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+8,cmd_line,256);
+	*(char*)(CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+8+256) = 0;
+    }
+    else {
+	*(char*)(CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+256) = 0;
+    }
+
+    if (wait_time_set) {
+        diag_printf("About to start execution at %p - abort with ^C within %d seconds\n",
+                    (void *)entry, wait_time);
+        res = _rb_gets(line, sizeof(line), wait_time*1000);
+        if (res == _GETS_CTRLC) {
+            return;
+        }
+    }
+
+    HAL_DISABLE_INTERRUPTS(oldints);
+    HAL_DCACHE_SYNC();
+    HAL_ICACHE_DISABLE();
+    HAL_DCACHE_DISABLE();
+    HAL_DCACHE_SYNC();
+    HAL_ICACHE_INVALIDATE_ALL();
+    HAL_DCACHE_INVALIDATE_ALL();
+    (*entry)();
+}
+
+// EOF redboot_linux_exec.c
--- a/packages/hal/mn10300/am33/current/src/var_misc.c
+++ b/packages/hal/mn10300/am33/current/src/var_misc.c
@@ -59,11 +59,15 @@
 
 #include <cyg/hal/hal_cache.h>
 
+#include <cyg/hal/hal_intr.h>           // HAL_CLOCK_READ
+
 /*------------------------------------------------------------------------*/
 /* Variant specific initialization routine.                               */
 
 void hal_variant_init(void)
 {
+    // Let the timer run at a default rate (for delays)
+    HAL_CLOCK_INITIALIZE(CYGNUM_HAL_RTC_PERIOD);
 }
 
 /*------------------------------------------------------------------------*/
@@ -103,6 +107,41 @@ void cyg_hal_dcache_store(CYG_ADDRWORD b
 }
 #endif
 
+/*------------------------------------------------------------------------*/
+/* Clock functions.                                                       */
+
+cyg_uint32 __hal_period__;
+
+// Delay for some usecs.
+void
+hal_delay_us(cyg_int32 delay)
+{
+#define _TICKS_PER_USEC (CYGHWR_HAL_MN10300_PROCESSOR_OSC/1000000)
+    cyg_uint32 now, prev, diff, usecs;
+
+    diff = usecs = 0;
+    HAL_CLOCK_READ(&prev);
+
+    while (delay > usecs) {
+	HAL_CLOCK_READ(&now);
+
+	if (now < prev)
+	    diff += (now + (__hal_period__ - prev));
+	else
+	    diff += (now - prev);
+
+	prev = now;
+
+	if (diff >= _TICKS_PER_USEC) {
+	    usecs += (diff / _TICKS_PER_USEC);
+	    diff %= _TICKS_PER_USEC;
+	}
+    }
+}
+
+
+
+
 #ifdef CYGPKG_CYGMON
 /*------------------------------------------------------------------------*/
 /* GDB Register functions.                                                */
--- a/packages/hal/mn10300/asb/current/ChangeLog
+++ b/packages/hal/mn10300/asb/current/ChangeLog
@@ -1,3 +1,14 @@
+2002-11-14  Mark Salter  <msalter@redhat.com>
+
+	* src/plf_misc.c: Don't mess with TBR.
+	* src/plf_stub.c: Tweak for RedBoot support.
+	* src/ser_asb.c:  Calculate baudrate divisor based on IOCLK. Register
+	getc_timeout_set handler.
+	* include/pkgconf/mlt*: Updated for flash support and adjusted RAM
+	addresses
+	* include/platform.inc: Always place boot flash at 0x80000000 and
+	system flash at 0x84000000.
+
 2002-08-06  Gary Thomas  <gary@chez-thomas.org>
 2002-08-06  Motoya Kurotsu <kurotsu@allied-telesis.co.jp>	
 
--- a/packages/hal/mn10300/asb/current/cdl/hal_mn10300_am33_asb.cdl
+++ b/packages/hal/mn10300/asb/current/cdl/hal_mn10300_am33_asb.cdl
@@ -68,6 +68,8 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB 
     implements    CYGINT_HAL_VIRTUAL_VECTOR_SUPPORT
     implements    CYGINT_HAL_VIRTUAL_VECTOR_COMM_BAUD_SUPPORT
 
+    requires CYGSEM_HAL_UNCACHED_FLASH_ACCESS == 1;
+
     define_proc {
         puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H   <pkgconf/hal_mn10300_am33.h>"
         puts $::cdl_system_header "#define CYGBLD_HAL_PLATFORM_H <pkgconf/hal_mn10300_am33_asb.h>"
@@ -87,49 +89,78 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB 
             Currently only ROM startup type is supported."
     }
 
-    cdl_option CYGHWR_HAL_MN10300_AM33_ASB_DIAG_PORT {
-        display          "Diagnostic Serial Port"
+    cdl_component CYG_HAL_ROM_SLOT {
+        display       "ROM slot in which residing"
+        flavor        data
+        legal_values  {"BootPROM" "SysFlash"}
+        default_value {"BootPROM"}
+        no_define
+        define -file system.h CYG_HAL_ROM_SLOT
+        description   "
+            This specifies which ROM slot the program resides in (and is booted
+            from."
+    }
+
+    cdl_option CYGHWR_HAL_MN10300_PROCESSOR_OSC_DEFAULT {
+        display       "Processor clock rate"
+        calculated    33333333
+        flavor        data
+    }
+
+    cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT {
+        display      "Default console channel."
+        flavor       data
+        legal_values     0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1
+        calculated   0
+    }
+ 
+    cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS {
+        display      "Number of communication channels on the board"
+        flavor       data
+        calculated   2
+    }
+ 
+    cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL {
+        display          "Debug serial port"
+        active_if        CYGPRI_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL_CONFIGURABLE
         flavor data
-        legal_values     0 1
+        legal_values     0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1
         default_value    0
         description      "
-           The ASB2303 board has two serial ports. This option
-           chooses which of these ports will be used for diagnostic output.
-           At present only port 0 is supported."
-   }
-
-   cdl_option CYGHWR_HAL_MN10300_AM33_ASB_DIAG_BAUD {
-       display          "Diagnostic Serial Port Baud Rate"
-       flavor data
-       legal_values     9600 19200 38400 115200
-       default_value    38400
-       define           CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD
-       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."
-   }
+            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"
+         active_if        CYGPRI_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_CONFIGURABLE
+         flavor data
+         legal_values     0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1
+         default_value    CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT
+         description      "
+            The ASB2303 board has two serial ports.  This option
+            chooses which port will be used for diagnostic output."
+     }
 
-   cdl_option CYGHWR_HAL_MN10300_AM33_ASB_GDB_PORT {
-       display          "GDB Serial Port"
-       flavor data
-       legal_values     0 1
-       default_value    0
-       description      "
-           The ASB2303 board has two separate serial ports.  This option
-           chooses which of these ports will be used to connect to a host
-           running GDB.
-           At present only port 0 is supported."
-   }
+    cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD {
+        display       "Diagnostic serial port baud rate"
+        flavor        data
+        legal_values  9600 19200 38400 57600 115200
+        default_value 115200
+        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 CYGHWR_HAL_MN10300_AM33_ASB_GDB_BAUD {
-       display          "GDB Serial Port Baud Rate"
-       flavor data
-       legal_values     9600 19200 38400 115200
-       default_value    38400
-       description      "
-           This option controls the baud rate used for the GDB connection."
-   }
+    cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL_BAUD {
+        display       "GDB serial port baud rate"
+        flavor        data
+        legal_values  9600 19200 38400 57600 115200
+        default_value 115200
+        description   "
+            This option selects the baud rate used for the GDB port."
+    }
 
     cdl_component CYGBLD_GLOBAL_OPTIONS {
         display "Global build options"
@@ -206,49 +237,22 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB 
             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 ASB2303 board has two serial ports.  Currently,
-           only the first serial port is supported. 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 ASB2303 board has two serial ports. Currently,
-           only the first serial port is supported. 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" ? "mn10300_am33_asb_ram" : \
-	                                        "mn10300_am33_asb_rom" }
+        calculated { CYG_HAL_STARTUP  == "RAM"      ? "mn10300_am33_asb_ram" : \
+                     CYG_HAL_ROM_SLOT == "BootPROM" ? "mn10300_am33_asb_rom" : \
+                                                      "mn10300_am33_asb_flash" }
 
         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_mn10300_am33_asb_ram.ldi>" : \
-                                                    "<pkgconf/mlt_mn10300_am33_asb_rom.ldi>" }
+            calculated { CYG_HAL_STARTUP == "RAM"       ? "<pkgconf/mlt_mn10300_am33_asb_ram.ldi>" : \
+                         CYG_HAL_ROM_SLOT == "BootPROM" ? "<pkgconf/mlt_mn10300_am33_asb_rom.ldi>" : \
+                                                          "<pkgconf/mlt_mn10300_am33_asb_flash.ldi>" }
         }
 
         cdl_option CYGHWR_MEMORY_LAYOUT_H {
@@ -256,16 +260,31 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB 
             flavor data
             no_define
             define -file system.h CYGHWR_MEMORY_LAYOUT_H
-            calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_mn10300_am33_asb_ram.h>" : \
-                                                    "<pkgconf/mlt_mn10300_am33_asb_rom.h>" }
+            calculated { CYG_HAL_STARTUP == "RAM"       ? "<pkgconf/mlt_mn10300_am33_asb_ram.h>" : \
+                         CYG_HAL_ROM_SLOT == "BootPROM" ? "<pkgconf/mlt_mn10300_am33_asb_rom.h>" : \
+                                                          "<pkgconf/mlt_mn10300_am33_asb_flash.h>" }
         }
     }
 
+    cdl_option CYGSEM_HAL_ROM_MONITOR {
+        display       "Behave as a ROM monitor"
+        flavor        bool
+        default_value 0
+        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_option CYGSEM_HAL_USE_ROM_MONITOR {
         display       "Work with a ROM monitor"
         flavor        booldata
-        legal_values  { "Generic" "CygMon" "GDB_stubs" }
-        default_value { CYG_HAL_STARTUP == "RAM" ? "CygMon" : 0 }
+        legal_values  { "Generic" "GDB_stubs" }
+        default_value { CYG_HAL_STARTUP == "RAM" ? "GDB_stubs" : 0 }
         parent        CYGPKG_HAL_ROM_MONITOR
         requires      { CYG_HAL_STARTUP == "RAM" }
         description   "
@@ -278,45 +297,30 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB 
             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."
+             \"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_CYGMON_HAL_OPTIONS {
-        display       "CygMon HAL options"
+    cdl_component CYGPKG_REDBOOT_HAL_OPTIONS {
+        display       "Redboot HAL options"
         flavor        none
         no_define
-        parent        CYGPKG_CYGMON
-        active_if     CYGPKG_CYGMON
+        parent        CYGPKG_REDBOOT
+        active_if     CYGPKG_REDBOOT
         description   "
-            This option also lists the target's requirements for a valid CygMon
+            This option lists the target's requirements for a valid Redboot
             configuration."
-
-        cdl_option CYGBLD_BUILD_CYGMON_BIN {
-            display       "Build CygMon ROM binary image"
-            active_if     CYGBLD_BUILD_CYGMON
+            
+        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 CygMon ELF
+            description "This option enables the conversion of the Redboot ELF
                          image to a binary image suitable for ROM programming."
     
             make -priority 325 {
-                <PREFIX>/bin/cygmon.bin : <PREFIX>/bin/cygmon.elf
+                <PREFIX>/bin/redboot.bin : <PREFIX>/bin/redboot.elf
                 $(OBJCOPY) --strip-debug $< $(@:.bin=.img) 
                 $(OBJCOPY) -O srec $< $(@:.bin=.srec)
                 $(OBJCOPY) -O binary $< $@
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_flash.h
@@ -0,0 +1,20 @@
+// eCos memory layout - Fri Oct 20 08:28:05 2000
+
+// This is a generated file - do not edit
+
+#ifndef __ASSEMBLER__
+#include <cyg/infra/cyg_type.h>
+#include <stddef.h>
+
+#endif
+#define CYGMEM_REGION_rom	(0x84000000)
+#define CYGMEM_REGION_rom_SIZE	(0x1000000)
+#define CYGMEM_REGION_rom_ATTR	(CYGMEM_REGION_ATTR_R)
+#define CYGMEM_REGION_ram	(0x90000000)
+#define CYGMEM_REGION_ram_SIZE	(0x04000000)
+#define CYGMEM_REGION_ram_ATTR	(CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
+#ifndef __ASSEMBLER__
+extern char CYG_LABEL_NAME (__heap1) [];
+#endif
+#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1))
+#define CYGMEM_SECTION_heap1_SIZE (0x94000000 - (size_t) CYG_LABEL_NAME (__heap1))
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_flash.ldi
@@ -0,0 +1,32 @@
+// eCos memory layout - Fri Oct 20 08:28:05 2000 -*- c -*-
+
+// This is a generated file - do not edit
+
+#include <cyg/infra/cyg_type.inc>
+
+MEMORY
+{
+    rom : ORIGIN = 0x84000000, LENGTH = 0x01000000
+    ram : ORIGIN = 0x90000000, LENGTH = 0x04000000
+}
+
+SECTIONS
+{
+    SECTIONS_BEGIN
+    SECTION_rom_vectors (rom, 0x84000000, LMA_EQ_VMA)
+    SECTION_text (rom, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_fini (rom, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_rodata (rom, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_rodata1 (rom, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_fixup (rom, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_gcc_except_table (rom, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_data (ram, 0x90000000, FOLLOWING (.gcc_except_table))
+    SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA)
+    CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
+    SECTIONS_END
+}
+
+#define CYG_HAL_PLATFORM_HAL_VSR_TABLE_DEFINED
+
+_hal_vsr_table = 0x8C000000;
+_hal_virtual_vector_table = 0x8C000100;
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_flash.mlt
@@ -0,0 +1,13 @@
+version 0
+region rom 84000000 1000000 1 !
+region ram 90000000 4000000 0 !
+section rom_vectors 0 1 0 1 1 1 1 1 84000000 84000000 text text !
+section text 0 1 0 1 0 1 0 1 fini fini !
+section fini 0 1 0 1 0 1 0 1 rodata rodata !
+section rodata 0 1 0 1 0 1 0 1 rodata1 rodata1 !
+section rodata1 0 1 0 1 0 1 0 1 fixup fixup !
+section fixup 0 1 0 1 0 1 0 1 gcc_except_table gcc_except_table !
+section gcc_except_table 0 1 0 1 0 0 0 1 data !
+section data 0 1 1 1 1 1 0 0 90000000 bss !
+section bss 0 4 0 1 0 1 0 1 heap1 heap1 !
+section heap1 0 8 0 0 0 0 0 0 !
--- a/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_ram.h
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_ram.h
@@ -7,11 +7,11 @@
 #include <stddef.h>
 
 #endif
-#define CYGMEM_REGION_ram (0x90080000)
-#define CYGMEM_REGION_ram_SIZE (0xf80000)
+#define CYGMEM_REGION_ram (0x90020000)
+#define CYGMEM_REGION_ram_SIZE (0x03fe0000)
 #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
 #ifndef __ASSEMBLER__
 extern char CYG_LABEL_NAME (__heap1) [];
 #endif
 #define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1))
-#define CYGMEM_SECTION_heap1_SIZE (0x91000000 - (size_t) CYG_LABEL_NAME (__heap1))
+#define CYGMEM_SECTION_heap1_SIZE (0x94000000 - (size_t) CYG_LABEL_NAME (__heap1))
--- a/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_ram.ldi
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_ram.ldi
@@ -6,13 +6,13 @@
 
 MEMORY
 {
-    ram : ORIGIN = 0x90080000, LENGTH = 0xf80000
+    ram : ORIGIN = 0x90020000, LENGTH = 0x3fe0000
 }
 
 SECTIONS
 {
     SECTIONS_BEGIN
-    SECTION_rom_vectors (ram, 0x90080000, LMA_EQ_VMA)
+    SECTION_rom_vectors (ram, 0x90020000, LMA_EQ_VMA)
     SECTION_text (ram, ALIGN (0x1), LMA_EQ_VMA)
     SECTION_fini (ram, ALIGN (0x1), LMA_EQ_VMA)
     SECTION_rodata (ram, ALIGN (0x1), LMA_EQ_VMA)
@@ -24,3 +24,8 @@ SECTIONS
     CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
     SECTIONS_END
 }
+
+#define CYG_HAL_PLATFORM_HAL_VSR_TABLE_DEFINED
+
+_hal_vsr_table = 0x8C000000;
+_hal_virtual_vector_table = 0x8C000100;
--- a/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_ram.mlt
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_ram.mlt
@@ -1,6 +1,6 @@
 version 0
-region ram 90080000 f80000 0 !
-section rom_vectors 0 1 0 1 1 1 1 1 90080000 90080000 text text !
+region ram 90020000 3fe0000 0 !
+section rom_vectors 0 1 0 1 1 1 1 1 90020000 90020000 text text !
 section text 0 1 0 1 0 1 0 1 fini fini !
 section fini 0 1 0 1 0 1 0 1 rodata rodata !
 section rodata 0 1 0 1 0 1 0 1 rodata1 rodata1 !
--- a/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_rom.h
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_rom.h
@@ -8,13 +8,13 @@
 
 #endif
 #define CYGMEM_REGION_rom (0x80000000)
-#define CYGMEM_REGION_rom_SIZE (0x400000)
+#define CYGMEM_REGION_rom_SIZE (0x100000)
 #define CYGMEM_REGION_rom_ATTR (CYGMEM_REGION_ATTR_R)
-#define CYGMEM_REGION_ram (0x90000200)
-#define CYGMEM_REGION_ram_SIZE (0x7fe00)
+#define CYGMEM_REGION_ram (0x90000000)
+#define CYGMEM_REGION_ram_SIZE (0x4000000)
 #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
 #ifndef __ASSEMBLER__
 extern char CYG_LABEL_NAME (__heap1) [];
 #endif
 #define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1))
-#define CYGMEM_SECTION_heap1_SIZE (0x90080000 - (size_t) CYG_LABEL_NAME (__heap1))
+#define CYGMEM_SECTION_heap1_SIZE (0x94000000 - (size_t) CYG_LABEL_NAME (__heap1))
--- a/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_rom.ldi
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_rom.ldi
@@ -6,8 +6,8 @@
 
 MEMORY
 {
-    rom : ORIGIN = 0x80000000, LENGTH = 0x400000
-    ram : ORIGIN = 0x90000200, LENGTH = 0x7fe00
+    rom : ORIGIN = 0x80000000, LENGTH = 0x00100000
+    ram : ORIGIN = 0x90000000, LENGTH = 0x04000000
 }
 
 SECTIONS
@@ -20,8 +20,13 @@ SECTIONS
     SECTION_rodata1 (rom, ALIGN (0x1), LMA_EQ_VMA)
     SECTION_fixup (rom, ALIGN (0x1), LMA_EQ_VMA)
     SECTION_gcc_except_table (rom, ALIGN (0x1), LMA_EQ_VMA)
-    SECTION_data (ram, 0x90000200, FOLLOWING (.gcc_except_table))
+    SECTION_data (ram, 0x90000000, FOLLOWING (.gcc_except_table))
     SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA)
     CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
     SECTIONS_END
 }
+
+#define CYG_HAL_PLATFORM_HAL_VSR_TABLE_DEFINED
+
+_hal_vsr_table = 0x8C000000;
+_hal_virtual_vector_table = 0x8C000100;
--- a/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_rom.mlt
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_rom.mlt
@@ -1,6 +1,6 @@
 version 0
-region rom 80000000 400000 1 !
-region ram 90000200 7fe00 0 !
+region rom 80000000 100000 1 !
+region ram 90000000 400000 0 !
 section rom_vectors 0 1 0 1 1 1 1 1 80000000 80000000 text text !
 section text 0 1 0 1 0 1 0 1 fini fini !
 section fini 0 1 0 1 0 1 0 1 rodata rodata !
@@ -8,6 +8,6 @@ section rodata 0 1 0 1 0 1 0 1 rodata1 r
 section rodata1 0 1 0 1 0 1 0 1 fixup fixup !
 section fixup 0 1 0 1 0 1 0 1 gcc_except_table gcc_except_table !
 section gcc_except_table 0 1 0 1 0 0 0 1 data !
-section data 0 1 1 1 1 1 0 0 90000200 bss !
+section data 0 1 1 1 1 1 0 0 90000000 bss !
 section bss 0 4 0 1 0 1 0 1 heap1 heap1 !
 section heap1 0 8 0 0 0 0 0 0 !
--- a/packages/hal/mn10300/asb/current/include/platform.inc
+++ b/packages/hal/mn10300/asb/current/include/platform.inc
@@ -170,93 +170,114 @@ 0:	mov	hal_diag_digits,a2
 #define BCCR_INIT               0x12040580
 
 #define SBBASE0                 0xD8C00100
-#define SBBASE0_INIT            0x8000FC01
 #define SBBASE1                 0xD8C00110
-#define SBBASE1_INIT            0x8400FC01
 #define SBBASE2                 0xD8C00120
-#define SBBASE2_INIT            0x8600FFF1
 #define SBBASE3                 0xD8C00130
+#define SBBASE4                 0xD8C00140
+#define SBBASE5                 0xD8C00150
+#define SBBASE6                 0xD8C00160
+#define SBBASE7                 0xD8C00170
+
+#define SBBASE0_INIT_SYSFL	0x8000FE01
+#define SBBASE0_INIT_BPROM	0x8400FE01
+#define SBBASE1_INIT_SYSFL	0x8400FE01
+#define SBBASE1_INIT_BPROM	0x8000FE01
+#define SBBASE2_INIT            0x8600FF81
 #define SBBASE3_INIT            0x00000000
-#define SBBASE4                 0xD8C00140
 #define SBBASE4_INIT            0x00000000
-#define SBBASE5                 0xD8C00150
 #define SBBASE5_INIT            0x00000000
-#define SBBASE6                 0xD8C00160
 #define SBBASE6_INIT            0x00000000
-#define SBBASE7                 0xD8C00170
 #define SBBASE7_INIT            0x00000000
 
 #define SBCTRL00                0xD8C00200
+#define SBCTRL10                0xD8C00210
+#define SBCTRL20                0xD8C00220
+#define SBCTRL30                0xD8C00230
+#define SBCTRL40                0xD8C00240
+#define SBCTRL50                0xD8C00250
+#define SBCTRL60                0xD8C00260
+#define SBCTRL70                0xD8C00270
+
 #define SBCTRL00_INIT           0x21111000
-#define SBCTRL10                0xD8C00210
 #define SBCTRL10_INIT           0x21111000
-#define SBCTRL20                0xD8C00220
 #define SBCTRL20_INIT           0x21111000
-#define SBCTRL30                0xD8C00230
 #define SBCTRL30_INIT           0x00000000
-#define SBCTRL40                0xD8C00240
 #define SBCTRL40_INIT           0x00000000
-#define SBCTRL50                0xD8C00250
-#define SBCTRL50_INIT           0x00000000
-#define SBCTRL60                0xD8C00260
-#define SBCTRL60_INIT           0x00000000
-#define SBCTRL70                0xD8C00270
+#define SBCTRL50_INIT           0x00000000 // 0x21111100
+#define SBCTRL60_INIT           0x00000000 // 0x11110000
 #define SBCTRL70_INIT           0x00000000
 
 #define SBCTRL01                0xD8C00204
+#define SBCTRL11                0xD8C00214
+#define SBCTRL21                0xD8C00224
+#define SBCTRL31                0xD8C00234
+#define SBCTRL41                0xD8C00244
+#define SBCTRL51                0xD8C00254
+#define SBCTRL61                0xD8C00264
+#define SBCTRL71                0xD8C00274
+
 #define SBCTRL01_INIT           0x00100200
-#define SBCTRL11                0xD8C00214
 #define SBCTRL11_INIT           0x00100200
-#define SBCTRL21                0xD8C00224
 #define SBCTRL21_INIT           0x00100200
-#define SBCTRL31                0xD8C00234
 #define SBCTRL31_INIT           0x00000000
-#define SBCTRL41                0xD8C00244
 #define SBCTRL41_INIT           0x00000000
-#define SBCTRL51                0xD8C00254
 #define SBCTRL51_INIT           0x00000000
-#define SBCTRL61                0xD8C00264
 #define SBCTRL61_INIT           0x00000000
-#define SBCTRL71                0xD8C00274
 #define SBCTRL71_INIT           0x00000000
 
-#define SBCTRL02                0xD8C00208
-#define SBCTRL02_INIT           0x00000004
+#define SBCTRL02                0xD8C00208 
 #define SBCTRL12                0xD8C00218
-#define SBCTRL12_INIT           0x00000004
 #define SBCTRL22                0xD8C00228
+#define SBCTRL32                0xD8C00238
+#define SBCTRL42                0xD8C00248
+#define SBCTRL52                0xD8C00258
+#define SBCTRL62                0xD8C00268
+#define SBCTRL72                0xD8C00278
+
+#define SBCTRL02_INIT           0x00000004
+#define SBCTRL12_INIT           0x04000004
 #define SBCTRL22_INIT           0x00000004
-#define SBCTRL32                0xD8C00238
 #define SBCTRL32_INIT           0x00000000
-#define SBCTRL42                0xD8C00248
 #define SBCTRL42_INIT           0x00000000
-#define SBCTRL52                0xD8C00258
 #define SBCTRL52_INIT           0x00000000
-#define SBCTRL62                0xD8C00268
 #define SBCTRL62_INIT           0x00000000
-#define SBCTRL72                0xD8C00278
 #define SBCTRL72_INIT           0x00000000
 
 #define SDBASE0                 0xDA000008
+#define SDBASE1                 0xDA00000C
+#define SDRAMBUS                0xDA000000
+
+#if 0
+// 16MB SDRAM
 #define SDBASE0_INIT            0x9000FF81
-#define SDBASE1                 0xDA00000C
 #define SDBASE1_INIT            0x9080FF81
-#define SDRAMBUS                0xDA000000
 #define SDRAMBUS_INIT           0xA8990654
+#else
+// 64MB SDRAM
+#define SDBASE0_INIT            0x9000fe01
+#define SDBASE1_INIT            0x9200fe01
+#define SDRAMBUS_INIT           0xa89b0654
+#endif
 
 	.macro	hal_memc_init
 	mov	BCCR,a0
 	mov	BCCR_INIT,d0
 	mov	d0,(a0)
 
-	mov	SBBASE0,a0
-	mov	SBBASE0_INIT,d0
-	mov	d0,(a0)
-
-	mov	SBBASE1,a0
-	mov	SBBASE1_INIT,d0
-	mov	d0,(a0)
-
+	// reduce the span of the ROM banks first
+	mov	(SBBASE0),d0
+	btst	1,d0
+	beq	0f
+	mov	0x8000FE01,d0
+	mov	d0,(SBBASE0)
+0:
+	mov	(SBBASE1),d0
+	btst	1,d0
+	beq	0f
+	mov	0x8000FE01,d0
+	mov	d0,(SBBASE1)
+0:
+	
 	mov	SBBASE2,a0
 	mov	SBBASE2_INIT,d0
 	mov	d0,(a0)
@@ -389,10 +410,71 @@ 0:	mov	hal_diag_digits,a2
 	mov	SDRAMBUS_INIT,d0
 	mov	d0,(a0)
 
-	# Jump forward so we start running from the 80000000 base address
-        mov     0f,a0
+	// now the ROMs need putting into the right place
+	// - this is tricky because when we're booting from the system flash,
+	//   it has had its base address pre-swapped by the CPU
+	// - we need to copy a small piece of code to the SRAM and execute it
+	//   there
+
+	// copy the ROM address adjustor to the SRAM
+	add	-4,sp
+	call	__hal_plf_base_ref,[],0		// note we can't address ourselves directly yet
+__hal_plf_base_ref:
+	movm	(sp),[a3]
+	mov	a3,a0
+	add	__hal_plf_rom_swap_start-__hal_plf_base_ref,a0
+	add	__hal_plf_rom_swap_end-__hal_plf_base_ref,a3
+	mov	0x8C000000,a1
+0:	movbu	(a0),d0
+	movbu	d0,(a1)
+	inc	a0
+	inc	a1
+	cmp	a0,a3
+	bcc	0b
+	mov	0x8C000000,a1
+	jmp	(a1)	
+
+	////////////////////////////////////////////////////////////////
+__hal_plf_rom_swap_start:
+	// put boot PROM at 0x80000000, and system flash at 0x84000000
+	mov	SBBASE0_INIT_BPROM,d0
+	mov	d0,(SBBASE0)
+
+	mov	SBBASE1_INIT_BPROM,d0
+	mov	d0,(SBBASE1)
+
+	// memory bank 0
+	mov	SBCTRL00_INIT,d0
+	mov	d0,(SBCTRL00)
+	mov	SBCTRL01_INIT,d0
+	mov	d0,(SBCTRL01)
+	mov	SBCTRL02_INIT,d0
+	mov	d0,(SBCTRL02)
+
+	// memory bank 1
+	mov	SBCTRL10_INIT,d0
+	mov	d0,(SBCTRL10)
+	mov	SBCTRL11_INIT,d0
+	mov	d0,(SBCTRL11)
+	mov	SBCTRL12_INIT,d0
+	mov	d0,(SBCTRL12)
+
+	// jump forward so we start running from the 80000000/84000000 base address
+        mov     __hal_plf_rom_swap_reentry,a0
 	jmp	(a0)
+__hal_plf_rom_swap_end:
+	////////////////////////////////////////////////////////////////
+
+__hal_plf_rom_swap_reentry:
+	// clear the on-CPU 16Kb SRAM
+	clr	d0
+	mov	16384/4-4,d1
+	mov	0x8C000000,a0
 0:
+	mov	d0,(a0,d1)
+	sub	4,d1
+	bnc	0b
+
 	.endm
 
 #define CYGPKG_HAL_MN10300_MEMC_DEFINED
@@ -402,12 +484,10 @@ 0:
 
 //-----------------------------------------------------------------------------
 // Syscall support.
-#ifdef CYGPKG_CYGMON
-// Cygmon provides syscall handling for this board
+// RedBoot provides syscall handling for this board
 // These must be kept in sync with the rest of the tree.
 #define SIGSYS     12
 #define SIGSYSCALL SIGSYS
-#endif
 
 #------------------------------------------------------------------------------
 #endif // ifndef CYGONCE_HAL_PLATFORM_INC
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb/current/misc/redboot_FLASH.ecm
@@ -0,0 +1,93 @@
+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    asb ;
+    template    redboot ;
+    package -hardware CYGPKG_HAL_MN10300 current ;
+    package -hardware CYGPKG_HAL_MN10300_AM33_ASB current ;
+    package -hardware CYGPKG_HAL_MN10300_AM33 current ;
+    package -template CYGPKG_HAL current ;
+    package -template CYGPKG_INFRA current ;
+    package -template CYGPKG_REDBOOT current ;
+
+    package CYGPKG_IO_FLASH current ;
+    package -hardware CYGPKG_DEVS_FLASH_MN10300_ASB2303 current ;
+    package CYGPKG_DEVS_FLASH_AMD_AM29XXXXX current ;
+};
+
+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_USE_ROM_MONITOR {
+    inferred_value 0 0
+};
+
+cdl_option CYGSEM_HAL_ROM_MONITOR {
+    inferred_value 1
+};
+
+cdl_component CYG_HAL_STARTUP {
+    user_value ROM
+};
+
+cdl_component CYG_HAL_ROM_SLOT {
+    user_value "SysFlash"
+};
+
+cdl_component CYGBLD_BUILD_REDBOOT {
+    user_value 1
+};
+
+cdl_option CYGOPT_REDBOOT_FIS {
+    user_value 1
+};
+
+cdl_option CYGHWR_DEVS_FLASH_MN10300_ASB2303_BANK {
+    user_value "BootPROM"
+};
+
+cdl_option CYGHWR_DEVS_FLASH_AMD_AM29DL324D {
+    user_value 1
+};
+
+cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV800 {
+    user_value 1
+};
+
+cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD {
+    user_value 115200
+};
+
+cdl_option CYGSEM_REDBOOT_BSP_SYSCALLS {
+  user_value 1
+};
+
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb/current/misc/redboot_RAM.ecm
@@ -0,0 +1,88 @@
+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    asb ;
+    template    redboot ;
+    package -hardware CYGPKG_HAL_MN10300 current ;
+    package -hardware CYGPKG_HAL_MN10300_AM33_ASB current ;
+    package -hardware CYGPKG_HAL_MN10300_AM33 current ;
+    package -template CYGPKG_HAL current ;
+    package -template CYGPKG_INFRA current ;
+    package -template CYGPKG_REDBOOT current ;
+
+    package CYGPKG_IO_FLASH current ;
+    package -hardware CYGPKG_DEVS_FLASH_MN10300_ASB2303 current ;
+    package CYGPKG_DEVS_FLASH_AMD_AM29XXXXX current ;
+};
+
+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_USE_ROM_MONITOR {
+    inferred_value 0 0
+};
+
+cdl_option CYGSEM_HAL_ROM_MONITOR {
+    inferred_value 1
+};
+
+cdl_component CYG_HAL_STARTUP {
+    user_value RAM
+};
+
+cdl_component CYGBLD_BUILD_REDBOOT {
+    user_value 1
+};
+
+cdl_option CYGOPT_REDBOOT_FIS {
+    user_value 1
+};
+
+cdl_option CYGHWR_DEVS_FLASH_MN10300_ASB2303_BANK {
+    user_value "BootPROM"
+};
+
+cdl_option CYGHWR_DEVS_FLASH_AMD_AM29DL324D {
+    user_value 1
+};
+
+cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV800 {
+    user_value 1
+};
+
+cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD {
+    user_value 115200
+};
+
+cdl_option CYGSEM_REDBOOT_BSP_SYSCALLS {
+  user_value 1
+};
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb/current/misc/redboot_ROM.ecm
@@ -0,0 +1,88 @@
+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    asb ;
+    template    redboot ;
+    package -hardware CYGPKG_HAL_MN10300 current ;
+    package -hardware CYGPKG_HAL_MN10300_AM33_ASB current ;
+    package -hardware CYGPKG_HAL_MN10300_AM33 current ;
+    package -template CYGPKG_HAL current ;
+    package -template CYGPKG_INFRA current ;
+    package -template CYGPKG_REDBOOT current ;
+
+    package CYGPKG_IO_FLASH current ;
+    package -hardware CYGPKG_DEVS_FLASH_MN10300_ASB2303 current ;
+    package CYGPKG_DEVS_FLASH_AMD_AM29XXXXX current ;
+};
+
+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_USE_ROM_MONITOR {
+    inferred_value 0 0
+};
+
+cdl_option CYGSEM_HAL_ROM_MONITOR {
+    inferred_value 1
+};
+
+cdl_component CYG_HAL_STARTUP {
+    user_value ROM
+};
+
+cdl_component CYGBLD_BUILD_REDBOOT {
+    user_value 1
+};
+
+cdl_option CYGOPT_REDBOOT_FIS {
+    user_value 1
+};
+
+cdl_option CYGHWR_DEVS_FLASH_MN10300_ASB2303_BANK {
+    user_value "SysFlash"
+};
+
+cdl_option CYGHWR_DEVS_FLASH_AMD_AM29DL324D {
+    user_value 1
+};
+
+cdl_option CYGHWR_DEVS_FLASH_AMD_AM29LV800 {
+    user_value 1
+};
+
+cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD {
+    user_value 115200
+};
+
+cdl_option CYGSEM_REDBOOT_BSP_SYSCALLS {
+  user_value 1
+};
--- a/packages/hal/mn10300/asb/current/src/plf_misc.c
+++ b/packages/hal/mn10300/asb/current/src/plf_misc.c
@@ -142,6 +142,7 @@ void hal_platform_init(void)
     }
 #endif    
 
+#if 0
     // Make sure the TBR points at the base of ROM
     {
         #define TBR 0xC0000024
@@ -159,6 +160,7 @@ void hal_platform_init(void)
         mTBR_val = (mTBR_val & 0x00FFFFFF) | (CYGMEM_REGION_rom & 0xFF000000);
         HAL_WRITE_UINT32(mTBR, mTBR_val);
     }
+#endif
 }
 
 /*------------------------------------------------------------------------*/
--- a/packages/hal/mn10300/asb/current/src/plf_stub.c
+++ b/packages/hal/mn10300/asb/current/src/plf_stub.c
@@ -62,6 +62,11 @@
 //---------------------------------------------------------------------------
 
 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
+
+#define ASB2303_SER0_BASE      0xD4002000
+#define _SERIAL_RXR      0x09
+#define SERIAL0_RXR      ((volatile cyg_uint8 *) (ASB2303_SER0_BASE + _SERIAL_RXR))
+
 // This ISR is called from the interrupt handler. This should only
 // happen when there is no serial driver, so the code shouldn't mess
 // anything up.
@@ -91,6 +96,7 @@ int cyg_hal_gdb_isr(cyg_uint32 vector, t
     return 1;
 }
 
+#ifndef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
 int hal_asb_interruptible(int state)
 {
     if (state) {
@@ -112,6 +118,7 @@ void hal_asb_init_break_irq( void )
     HAL_ENABLE_INTERRUPTS();
 }
 #endif
+#endif
 
 //-----------------------------------------------------------------------------
 
--- a/packages/hal/mn10300/asb/current/src/ser_asb.c
+++ b/packages/hal/mn10300/asb/current/src/ser_asb.c
@@ -105,76 +105,17 @@
 
 #define SIO_INT_ENABLE  0x11
 
-// These values are calculated based on the MN103E010 LSI Manual
-#define PRESCALAR_BASE_1200          198
-#define PRESCALAR_BASE_2400          198
-#define PRESCALAR_BASE_4800          198
-#define PRESCALAR_BASE_9600          198
-#define PRESCALAR_BASE_96002         198
-#define PRESCALAR_BASE_14400         66
-#define PRESCALAR_BASE_19200         0
-#define PRESCALAR_BASE_38400         0
-#define PRESCALAR_BASE_56000         0
-#define PRESCALAR_BASE_57600         0
-#define PRESCALAR_BASE_115200        0
-#define PRESCALAR_BASE_230400        0
-
-#define TIMER_BASE_1200              15
-#define TIMER_BASE_2400              7
-#define TIMER_BASE_4800              3
-#define TIMER_BASE_9600              1
-#define TIMER_BASE_96002             2
-#define TIMER_BASE_14400             3
-#define TIMER_BASE_19200             198
-#define TIMER_BASE_38400             99
-#define TIMER_BASE_56000             68
-#define TIMER_BASE_57600             66
-#define TIMER_BASE_115200            33
-#define TIMER_BASE_230400            16
-
 #define TMR_ENABLE                   0x80
 #define TMR_SRC_IOCLOCK              0x00
 #define TMR_SRC_TMR0_UNDERFLOW       0x04
 
-#define PRESCALAR_MODE_1200          (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define PRESCALAR_MODE_2400          (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define PRESCALAR_MODE_4800          (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define PRESCALAR_MODE_9600          (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define PRESCALAR_MODE_96002         (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define PRESCALAR_MODE_14400         (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define PRESCALAR_MODE_19200         0
-#define PRESCALAR_MODE_38400         0
-#define PRESCALAR_MODE_56000         0
-#define PRESCALAR_MODE_57600         0
-#define PRESCALAR_MODE_115200        0
-#define PRESCALAR_MODE_230400        0
-
-#define TIMER_MODE_1200              (TMR_ENABLE | TMR_SRC_TMR0_UNDERFLOW)
-#define TIMER_MODE_2400              (TMR_ENABLE | TMR_SRC_TMR0_UNDERFLOW)
-#define TIMER_MODE_4800              (TMR_ENABLE | TMR_SRC_TMR0_UNDERFLOW)
-#define TIMER_MODE_9600              (TMR_ENABLE | TMR_SRC_TMR0_UNDERFLOW)
-#define TIMER_MODE_96002             (TMR_ENABLE | TMR_SRC_TMR0_UNDERFLOW)
-#define TIMER_MODE_14400             (TMR_ENABLE | TMR_SRC_TMR0_UNDERFLOW)
-#define TIMER_MODE_19200             (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define TIMER_MODE_38400             (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define TIMER_MODE_56000             (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define TIMER_MODE_57600             (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define TIMER_MODE_115200            (TMR_ENABLE | TMR_SRC_IOCLOCK)
-#define TIMER_MODE_230400            (TMR_ENABLE | TMR_SRC_IOCLOCK)
-
-#define BAUD_CASE(num)                                   \
-    case num:                                            \
-        prescalar_base_value = PRESCALAR_BASE_ ## num;   \
-        prescalar_mode_value = PRESCALAR_MODE_ ## num;   \
-        timer_base_value = TIMER_BASE_ ## num;           \
-        timer_mode_value = TIMER_MODE_ ## num;           \
-        break;
 
 //-----------------------------------------------------------------------------
 typedef struct {
     cyg_uint8* base;
     cyg_int32 msec_timeout;
     int isr_vector;
+    cyg_int32 baud_rate;
 } channel_data_t;
 
 static channel_data_t channels[2] = {
@@ -185,17 +126,27 @@ static channel_data_t channels[2] = {
 //-----------------------------------------------------------------------------
 // Set the baud rate
 
+static cyg_uint32
+baud_divisor(int baud, int prescaler)
+{
+    cyg_uint32 divisor;
+
+    // divisor == INT(IOCLK/baud/8 + 0.5)
+    divisor = CYGHWR_HAL_MN10300_IOCLK_SPEED * 10;
+    divisor /= (baud / 100);
+    divisor /= prescaler;
+    divisor /= 8;
+    divisor += 500;
+    divisor /= 1000;
+    return divisor;
+}
+
 static int
 cyg_hal_plf_serial_set_baud(cyg_uint8* port, cyg_uint32 baud_rate)
 {
-    volatile cyg_uint8 *prescalar_base_reg = 0, prescalar_base_value = 0;
-    volatile cyg_uint8 *prescalar_mode_reg = 0, prescalar_mode_value = 0;
-    volatile cyg_uint8 *timer_base_reg = 0,     timer_base_value = 0;
-    volatile cyg_uint8 *timer_mode_reg = 0,     timer_mode_value = 0;
-
-    // Always use TMR0 as the prescalar
-    prescalar_base_reg = TIMER0_BR;
-    prescalar_mode_reg = TIMER0_MD;
+    volatile cyg_uint8 *timer_base_reg;
+    volatile cyg_uint8 *timer_mode_reg;
+    cyg_uint32 divisor, prescaler;
 
     if (port == (cyg_uint8*)ASB2303_SER0_BASE)
     {
@@ -213,28 +164,41 @@ cyg_hal_plf_serial_set_baud(cyg_uint8* p
 
     switch (baud_rate)
     {
-        BAUD_CASE(1200);
-        BAUD_CASE(2400);
-        BAUD_CASE(4800);
-        BAUD_CASE(9600);
-        BAUD_CASE(96002);
-        BAUD_CASE(14400);
-        BAUD_CASE(19200);
-        BAUD_CASE(38400);
-        BAUD_CASE(56000);
-        BAUD_CASE(57600);
-        BAUD_CASE(115200);
-        BAUD_CASE(230400);
+    case 1200:
+    case 2400:
+    case 4800:
+    case 9600:
+    case 19200:
+    case 38400:
+    case 57600:
+    case 115200:
+    case 230400:
+	break;
 
     default:
         // Unknown baud.  Don't change anything
         return -1;
     }
 
-    HAL_WRITE_UINT8(prescalar_base_reg, prescalar_base_value);
-    HAL_WRITE_UINT8(prescalar_mode_reg, prescalar_mode_value);
-    HAL_WRITE_UINT8(timer_base_reg,     timer_base_value);
-    HAL_WRITE_UINT8(timer_mode_reg,     timer_mode_value);
+    for (prescaler = 1; prescaler <= 256; prescaler++) {
+	divisor = baud_divisor(baud_rate, prescaler);
+	if (divisor <= 256)
+	    break;
+    }
+    --divisor;
+    --prescaler;
+
+    if (prescaler) {
+	HAL_WRITE_UINT8(TIMER0_BR, prescaler);
+	HAL_WRITE_UINT8(TIMER0_MD, TMR_ENABLE | TMR_SRC_IOCLOCK);
+    } else {
+	HAL_WRITE_UINT8(TIMER0_BR, 0);
+	HAL_WRITE_UINT8(TIMER0_MD, 0);
+    }
+
+    HAL_WRITE_UINT8(timer_base_reg, divisor);
+    HAL_WRITE_UINT8(timer_mode_reg, TMR_ENABLE |
+		    (prescaler ? TMR_SRC_TMR0_UNDERFLOW : TMR_SRC_IOCLOCK));
 
     return 0;
 }
@@ -357,7 +321,6 @@ cyg_hal_plf_serial_read(void* __ch_data,
     CYGARC_HAL_RESTORE_GP();
 }
 
-#if 0
 cyg_bool
 cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch)
 {
@@ -385,7 +348,6 @@ cyg_hal_plf_serial_getc_timeout(void* __
     CYGARC_HAL_RESTORE_GP();
     return res;
 }
-#endif
 
 static int
 cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t __func, ...)
@@ -525,10 +487,10 @@ cyg_hal_plf_serial_init(void)
 
     // Init channels
     cyg_hal_plf_serial_init_channel((void*)&channels[0]);
-    cyg_hal_plf_serial_set_baud(channels[0].base, CYGHWR_HAL_MN10300_AM33_ASB_DIAG_BAUD);
+    cyg_hal_plf_serial_set_baud(channels[0].base, CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD);
 
     cyg_hal_plf_serial_init_channel((void*)&channels[1]);
-    cyg_hal_plf_serial_set_baud(channels[1].base, CYGHWR_HAL_MN10300_AM33_ASB_GDB_BAUD);
+    cyg_hal_plf_serial_set_baud(channels[1].base, CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD);
     
     // Setup procs in the vector table
 
@@ -542,9 +504,7 @@ cyg_hal_plf_serial_init(void)
     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);
-#if 0
     CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout);
-#endif
 
     // Set channel 1
     CYGACC_CALL_IF_SET_CONSOLE_COMM(1);
@@ -556,9 +516,7 @@ cyg_hal_plf_serial_init(void)
     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);
-#if 0
     CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout);
-#endif
 
     // Restore original console
     CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
--- a/packages/hal/mn10300/asb2305/current/ChangeLog
+++ b/packages/hal/mn10300/asb2305/current/ChangeLog
@@ -1,3 +1,10 @@
+2002-11-14  Mark Salter  <msalter@redhat.com>
+
+	* cdl/hal_mn10300_am33_asb2305.cdl: Remove RedBoot exec option. Now
+	provided in generic AM33 code. Ditto for RTC support.
+	* src/plf_misc.c: hal_delay_us now provided by AM33 package.
+	* src/redboot_cmds.c: Remove.
+
 2002-08-02  Andrew Lunn <Andrew.Lunn@ascom.ch>
 
 	* cdl/hal_mn10300_am33_asb2305.cdl: Redboot exec command can now
--- a/packages/hal/mn10300/asb2305/current/cdl/hal_mn10300_am33_asb2305.cdl
+++ b/packages/hal/mn10300/asb2305/current/cdl/hal_mn10300_am33_asb2305.cdl
@@ -101,48 +101,6 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB2
             from."
     }
 
-    # Real-time clock/counter specifics
-    cdl_component CYGNUM_HAL_RTC_CONSTANTS {
-        display       "Real-time clock constants."
-        description   "
-            The NUMERATOR divided by the DENOMINATOR gives the number of
-            nanoseconds per tick. The PERIOD is the divider to be programmed
-            into a hardware timer that is driven from an appropriate hardware
-            clock, such that the timer overflows once per tick (normally
-            generating a CPU interrupt to mark the end of a tick). The tick
-            rate is typically 100Hz.
-            The clock is generated with onboard 16-bit timers TM4 and TM5
-            cascaded together to form a 32-bit timer."
-        flavor none
-
-        cdl_option CYGHWR_HAL_MN10300_IOCLK_SPEED {
-            display          "Processor I/O clock speed (Hz)"
-            flavor           data
-            calculated       (25 * 1000 * 1000)
-            description      "
-                The processor I/O clock speed, from which onboard timers can
-                draw their sources."
-        }
-
-        cdl_option CYGNUM_HAL_RTC_NUMERATOR {
-            display       "Real-time clock numerator"
-            flavor        data
-            calculated    (1000 * 1000 * 1000)
-        }
-
-        cdl_option CYGNUM_HAL_RTC_DENOMINATOR {
-            display       "Real-time clock denominator"
-            flavor        data
-            calculated    100
-        }
-
-        cdl_option CYGNUM_HAL_RTC_PERIOD {
-            display       "Real-time clock divisor"
-            flavor        data
-            calculated    (CYGHWR_HAL_MN10300_IOCLK_SPEED * CYGNUM_HAL_RTC_NUMERATOR) / (1000000000 * CYGNUM_HAL_RTC_DENOMINATOR)
-        }
-    }
-
     cdl_option CYGHWR_HAL_MN10300_AM33_ASB_DIAG_PORT {
         display          "Diagnostic Serial Port"
         flavor data
@@ -374,19 +332,6 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB2
             This option lists the target's requirements for a valid Redboot
             configuration."
             
-        cdl_component CYGPKG_REDBOOT_HAL_LINUX_EXEC {
-            display       "Provide the exec command in RedBoot"
-            flavor        none
-            no_define
-            parent        CYGPKG_REDBOOT_HAL_OPTIONS
-            active_if     CYGBLD_BUILD_REDBOOT_WITH_EXEC
-            description "
-                This option contains requirements for booting linux
-                from RedBoot. The component is enabled/disabled from
-                RedBoots CDL."
-            compile -library=libextras.a redboot_cmds.c
-        }
-
         cdl_option CYGBLD_BUILD_REDBOOT_BIN {
             display       "Build Redboot ROM binary image"
             active_if     CYGBLD_BUILD_REDBOOT
--- a/packages/hal/mn10300/asb2305/current/src/plf_misc.c
+++ b/packages/hal/mn10300/asb2305/current/src/plf_misc.c
@@ -172,31 +172,6 @@ void hal_platform_init(void)
 }
 
 /*------------------------------------------------------------------------*/
-/* microsecond resolution delay    */
-void cyg_plf_hal_delay_us(cyg_int32 usecs)
-{
-	cyg_uint8 last, val;
-
-#define TM0MD 0xD4003000
-#define TM0BR 0xD4003010
-#define TM0BC 0xD4003020
-
-	HAL_WRITE_UINT8(TM0BR,25); // IOCLK is 25MHz
-	HAL_WRITE_UINT8(TM0MD,0x40); // stop and load
-	HAL_WRITE_UINT8(TM0MD,0x80); // set source to be IOCLK and go
-
-	HAL_READ_UINT8(TM0BC,last);
-	for (; usecs>0;) {
-		HAL_READ_UINT8(TM0BC,val);
-		if (val==last) continue;
-		if (val>last)
-			usecs--; // count the underflows
-		last = val;
-	}
-	HAL_WRITE_UINT8(TM0MD,0x00); // stop
-}
-
-/*------------------------------------------------------------------------*/
 /* Functions to support the detection and execution of a user provoked    */
 /* program break. These are usually called from interrupt routines.       */
 
deleted file mode 100644
--- a/packages/hal/mn10300/asb2305/current/src/redboot_cmds.c
+++ /dev/null
@@ -1,132 +0,0 @@
-//==========================================================================
-//
-//      redboot_cmds.c
-//
-//      ASB2305 [platform] specific RedBoot commands
-//
-//==========================================================================
-//####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):    dhowells
-// Contributors: gthomas, jskov
-// Date:         2001-07-19
-// Purpose:      
-// Description:  
-//              
-// This code is part of RedBoot (tm).
-//
-//####DESCRIPTIONEND####
-//
-//==========================================================================
-
-#include <redboot.h>
-
-#include <cyg/hal/hal_intr.h>
-#include <cyg/hal/hal_cache.h>
-
-// Exported CLI function(s)
-
-// The exec command works like the go command in YAMON - that is,
-// providing callee with argc, argv, and env. In addition to the
-// information provided by the user, 
-
-static void do_exec(int argc, char *argv[]);
-
-static char exec_usage[] =
-            "[-w timeout] [-c \"kernel command line\"] [<entry_point>]";
-
-RedBoot_cmd("exec", 
-            "Execute an image - with MMU off", 
-            exec_usage,
-            do_exec
-	    );
-
-typedef void (*code_fun)(void) __attribute__((noreturn));
-
-static void 
-do_exec(int argc, char *argv[])
-{
-    unsigned long oldints;
-    bool wait_time_set;
-    int  wait_time, res;
-    bool cmd_line_set;
-    struct option_info opts[4];
-    code_fun entry;
-    char line[8];
-    char *cmd_line;
-    int num_options;
-
-    entry = (code_fun)entry_address;  // Default from last 'load' operation
-    init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM, 
-              (void **)&wait_time, (bool *)&wait_time_set, "wait timeout");
-    init_opts(&opts[1], 'c', true, OPTION_ARG_TYPE_STR, 
-              (void **)&cmd_line, (bool *)&cmd_line_set, "kernel command line");
-    num_options = 2;
-
-    if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry, 
-                   OPTION_ARG_TYPE_NUM, "starting address"))
-    {
-        return;
-    }
-    if (cmd_line_set) {
-	memcpy((char*)0x8C001000,"cmdline:",8);
-        strncpy((char*)0x8C001008,cmd_line,256);
-	*(char*)(0x8C001008+256) = 0;
-    }
-    else {
-	*(char*)(0x8C001000+256) = 0;
-    }
-
-    if (wait_time_set) {
-        diag_printf("About to start execution at %p - abort with ^C within %d seconds\n",
-                    (void *)entry, wait_time);
-        res = _rb_gets(line, sizeof(line), wait_time*1000);
-        if (res == _GETS_CTRLC) {
-            return;
-        }
-    }
-
-    HAL_DISABLE_INTERRUPTS(oldints);
-    HAL_DCACHE_SYNC();
-    HAL_ICACHE_DISABLE();
-    HAL_DCACHE_DISABLE();
-    HAL_DCACHE_SYNC();
-    HAL_ICACHE_INVALIDATE_ALL();
-    HAL_DCACHE_INVALIDATE_ALL();
-    (*entry)();
-}
-
-// EOF redboot_cmds.c