changeset 453:3de3d5e778f2

AM33 enhancements
author msalter
date Fri, 06 Dec 2002 18:25:54 +0000
parents cbb529764898
children 63ad56f95b9a
files packages/hal/mn10300/am33/current/ChangeLog packages/hal/mn10300/am33/current/include/variant.inc packages/hal/mn10300/am33/current/src/var_misc.c packages/hal/mn10300/arch/current/ChangeLog packages/hal/mn10300/arch/current/cdl/hal_mn10300.cdl packages/hal/mn10300/arch/current/include/hal_intr.h 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_fullram.h packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_fullram.ldi packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_fullram.mlt 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_FULLRAM.ecm packages/hal/mn10300/asb2305/current/ChangeLog packages/hal/mn10300/asb2305/current/cdl/hal_mn10300_am33_asb2305.cdl packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_fullram.h packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_fullram.ldi packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_fullram.mlt packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_ram.h packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_ram.ldi packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_ram.mlt packages/hal/mn10300/asb2305/current/include/platform.inc packages/hal/mn10300/asb2305/current/misc/redboot_FULLRAM.ecm
diffstat 24 files changed, 633 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/mn10300/am33/current/ChangeLog
+++ b/packages/hal/mn10300/am33/current/ChangeLog
@@ -1,3 +1,10 @@
+2002-12-06  Mark Salter  <msalter@redhat.com>
+
+	* src/var_misc.c (hal_mn10300_mem_real_region_top): New function.
+
+	* include/variant.inc: Don't set TBR for RAM startup if the RAM
+	base is not properly aligned.
+
 2002-11-19  Mark Salter  <msalter@redhat.com>
 
 	* cdl/hal_mn10300_am33.cdl: Add virtual vector comm support using
--- a/packages/hal/mn10300/am33/current/include/variant.inc
+++ b/packages/hal/mn10300/am33/current/include/variant.inc
@@ -63,6 +63,8 @@
 
 #include <cyg/hal/platform.inc>
 
+#include CYGHWR_MEMORY_LAYOUT_H
+
 #------------------------------------------------------------------------------
 # Register definitions
 
@@ -116,9 +118,15 @@
 #endif
 	mov	d0,epsw
 #ifndef CYGSEM_HAL_USE_ROM_MONITOR
+// Don't change TBR for RAM startup if RAM base is not aligned for TBR.
+// In that case, the only option is to rely on ROM startup TBR and patch
+// into vectors through the hal_vsr_table.
+//
+#if !(defined(CYG_HAL_STARTUP_RAM) && (CYGMEM_REGION_ram & 0xffffff))
 	mov	reset_vector,a0		# set TBR to vector table
 	mov	a0,(TBR)
 #endif
+#endif
 
 	# stop as many internal interrupt sources as possible
 	mov	0,d0
--- a/packages/hal/mn10300/am33/current/src/var_misc.c
+++ b/packages/hal/mn10300/am33/current/src/var_misc.c
@@ -60,6 +60,7 @@
 #include <cyg/hal/hal_cache.h>
 
 #include <cyg/hal/hal_intr.h>           // HAL_CLOCK_READ
+#include CYGHWR_MEMORY_LAYOUT_H
 
 /*------------------------------------------------------------------------*/
 /* Variant specific initialization routine.                               */
@@ -140,6 +141,37 @@ hal_delay_us(cyg_int32 delay)
 }
 
 
+/*------------------------------------------------------------------------*/
+/* Memory top support                                                     */
+
+#define SDBASE0       ((volatile unsigned *)0xDA000008)
+#define SDBASE1       ((volatile unsigned *)0xDA00000C)
+#define SDRAMBUS      ((volatile unsigned *)0xDA000000)
+
+#if CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP
+externC cyg_uint8 *
+hal_mn10300_mem_real_region_top( cyg_uint8 *regionend )
+{
+    unsigned dram_size, dram_base;
+
+    // Figure out actual DRAM size from memory controller config.
+    dram_size = 0x400000 << ((*SDRAMBUS >> 16) & 0x3);
+    if (*SDBASE1 & 1)
+	dram_size *= 2;
+    dram_base = (*SDBASE0 & ((*SDBASE0 & 0xfff0) << 16));
+
+    CYG_ASSERT( dram_size >= 8<<20, "Less than 8MB SDRAM reported!" );
+    CYG_ASSERT( dram_size <=  256<<20, "More than 256MB SDRAM reported!" );
+
+    // is it the "normal" end of the DRAM region? If so, it should be
+    // replaced by the real size
+    if ( regionend ==
+         ((cyg_uint8 *)CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE) ) {
+        regionend = (cyg_uint8 *)dram_base + dram_size;
+    }
+    return regionend;
+}
+#endif
 
 
 #ifdef CYGPKG_CYGMON
--- a/packages/hal/mn10300/arch/current/ChangeLog
+++ b/packages/hal/mn10300/arch/current/ChangeLog
@@ -1,3 +1,8 @@
+2002-12-06  Mark Salter  <msalter@redhat.com>
+
+	* cdl/hal_mn10300.cdl: Add CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP.
+	* include/hal_intr.h: Support CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP.
+
 2002-04-29  Jonathan Larmour  <jlarmour@redhat.com>
 
 	* src/vectors.S:
--- a/packages/hal/mn10300/arch/current/cdl/hal_mn10300.cdl
+++ b/packages/hal/mn10300/arch/current/cdl/hal_mn10300.cdl
@@ -66,6 +66,10 @@ cdl_package CYGPKG_HAL_MN10300 {
         requires 1 == CYGINT_HAL_MN10300_VARIANT
     }
 
+    cdl_interface CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP {
+        display  "Implementations of hal_mn10300_mem_real_region_top()"
+    }
+
     cdl_option CYGDBG_HAL_MN10300_DEBUG_GDB_CTRLC_SUPPORT {
         display "Architecture GDB CTRLC support"
         calculated { CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT || CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT }
--- a/packages/hal/mn10300/arch/current/include/hal_intr.h
+++ b/packages/hal/mn10300/arch/current/include/hal_intr.h
@@ -330,5 +330,17 @@ CYG_MACRO_END
 #endif
 
 //--------------------------------------------------------------------------
+// Memory region top
+//
+#if CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP
+
+externC cyg_uint8 *hal_mn10300_mem_real_region_top( cyg_uint8 *_regionend_ );
+                                                
+# define HAL_MEM_REAL_REGION_TOP( _regionend_ ) \
+    hal_mn10300_mem_real_region_top( _regionend_ )
+#endif
+
+
+//--------------------------------------------------------------------------
 #endif // ifndef CYGONCE_HAL_HAL_INTR_H
 // EOF hal_intr.h
--- a/packages/hal/mn10300/asb/current/ChangeLog
+++ b/packages/hal/mn10300/asb/current/ChangeLog
@@ -1,3 +1,19 @@
+2002-12-06  Mark Salter  <msalter@redhat.com>
+
+	* cdl/hal_mn10300_am33_asb.cdl (CYG_HAL_FULL_RAM): New option to
+	indicate if RAM startup should use all RAM. This allows a special
+	RAM startup to be built which may be loaded onto a bare board by
+	the MEI tools. This can be used to build an initial RedBoot which
+	is used to program the flash with the ROM startup RedBoot image.
+	Implements CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP.
+	
+	* misc/redboot_FULLRAM.ecm:
+	* include/pkgconf/mlt_mn10300_am33_asb_fullram.h:
+	* include/pkgconf/mlt_mn10300_am33_asb_fullram.ldi:
+	* include/pkgconf/mlt_mn10300_am33_asb_fullram.mlt: New files.
+
+	* include/platform.inc: Add runtime determination of SDRAM config.
+
 2002-11-19  Mark Salter  <msalter@redhat.com>
 
 	* cdl/hal_mn10300_am33_asb.cdl: Remove virtual vector comm support.
--- a/packages/hal/mn10300/asb/current/cdl/hal_mn10300_am33_asb.cdl
+++ b/packages/hal/mn10300/asb/current/cdl/hal_mn10300_am33_asb.cdl
@@ -65,6 +65,7 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB 
 
     implements    CYGINT_HAL_DEBUG_GDB_STUBS
     implements    CYGINT_HAL_DEBUG_GDB_STUBS_BREAK
+    implements    CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP
 
     requires CYGSEM_HAL_UNCACHED_FLASH_ACCESS == 1;
 
@@ -100,6 +101,16 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB 
             from."
     }
 
+    cdl_option CYG_HAL_FULL_RAM {
+        display       "Use all of RAM for RAM startup"
+        flavor        bool
+        default_value 0
+        description   "
+            This specifies whether or not RAM startup configurations use all of
+            RAM. This should be true when using the MEI debugger to load the RAM
+            startup program when no monitor is installed on the board."
+    }
+
     cdl_option CYGHWR_HAL_MN10300_PROCESSOR_OSC_DEFAULT {
         display       "Processor clock rate"
         calculated    33333333
@@ -211,7 +222,9 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB 
         display "Memory layout"
         flavor data
         no_define
-        calculated { CYG_HAL_STARTUP  == "RAM"      ? "mn10300_am33_asb_ram" : \
+        calculated { CYG_HAL_STARTUP  == "RAM"      ? \
+		         CYG_HAL_FULL_RAM ? "mn10300_am33_asb_fullram" : \
+                                            "mn10300_am33_asb_ram" : \
                      CYG_HAL_ROM_SLOT == "BootPROM" ? "mn10300_am33_asb_rom" : \
                                                       "mn10300_am33_asb_flash" }
 
@@ -220,7 +233,9 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB 
             flavor data
             no_define
             define -file system.h CYGHWR_MEMORY_LAYOUT_LDI
-            calculated { CYG_HAL_STARTUP == "RAM"       ? "<pkgconf/mlt_mn10300_am33_asb_ram.ldi>" : \
+            calculated { CYG_HAL_STARTUP == "RAM"       ? \
+                             CYG_HAL_FULL_RAM ? "<pkgconf/mlt_mn10300_am33_asb_fullram.ldi>" :  \
+                                                "<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>" }
         }
@@ -230,7 +245,9 @@ 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>" : \
+            calculated { CYG_HAL_STARTUP == "RAM"       ? \
+			     CYG_HAL_FULL_RAM ? "<pkgconf/mlt_mn10300_am33_asb_fullram.h>" : \
+                                                "<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>" }
         }
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_fullram.h
@@ -0,0 +1,17 @@
+// eCos memory layout - Fri Oct 20 08:28:43 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 (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_fullram.ldi
@@ -0,0 +1,27 @@
+// eCos memory layout - Fri Oct 20 08:28:43 2000
+
+// This is a generated file - do not edit
+
+#include <cyg/infra/cyg_type.inc>
+
+MEMORY
+{
+    ram : ORIGIN = 0x90000000, LENGTH = 0x4000000
+}
+
+SECTIONS
+{
+    SECTIONS_BEGIN
+    SECTION_rom_vectors (ram, 0x90000000, 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)
+    SECTION_rodata1 (ram, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_fixup (ram, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_gcc_except_table (ram, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_data (ram, ALIGN (0x4), LMA_EQ_VMA)
+    SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA)
+    CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
+    SECTIONS_END
+}
+
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb/current/include/pkgconf/mlt_mn10300_am33_asb_fullram.mlt
@@ -0,0 +1,12 @@
+version 0
+region ram 90000000 4000000 0 !
+section rom_vectors 0 1 0 1 1 1 1 1 90000000 90000000 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 1 0 1 data data !
+section data 0 4 0 1 0 1 0 1 bss 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_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 100000 1 !
-region ram 90000000 400000 0 !
+region ram 90000000 4000000 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 !
--- a/packages/hal/mn10300/asb/current/include/platform.inc
+++ b/packages/hal/mn10300/asb/current/include/platform.inc
@@ -247,17 +247,20 @@ 0:	mov	hal_diag_digits,a2
 #define SDBASE1                 0xDA00000C
 #define SDRAMBUS                0xDA000000
 
-#if 0
 // 16MB SDRAM
-#define SDBASE0_INIT            0x9000FF81
-#define SDBASE1_INIT            0x9080FF81
-#define SDRAMBUS_INIT           0xA8990654
-#else
+#define SDBASE0_8M_INIT         0x9000FF81
+#define SDBASE1_8M_INIT         0x9080FF81
+#define SDRAMBUS_8M_INIT        0xA8990654
+
+// 32MB SDRAM
+#define SDBASE0_16M_INIT        0x9000FF01
+#define SDBASE1_16M_INIT        0x9100FF01
+#define SDRAMBUS_16M_INIT       0xA89a0654
+
 // 64MB SDRAM
-#define SDBASE0_INIT            0x9000fe01
-#define SDBASE1_INIT            0x9200fe01
-#define SDRAMBUS_INIT           0xa89b0654
-#endif
+#define SDBASE0_32M_INIT        0x9000fe01
+#define SDBASE1_32M_INIT        0x9200fe01
+#define SDRAMBUS_32M_INIT       0xa89b0654
 
 	.macro	hal_memc_init
 	mov	BCCR,a0
@@ -398,17 +401,74 @@ 0:
 	mov	SBCTRL72_INIT,d0
 	mov	d0,(a0)
 
-	mov	SDBASE0,a0
-	mov	SDBASE0_INIT,d0
-	mov	d0,(a0)
+#ifndef CYG_HAL_STARTUP_RAM
+
+        // Setup for 64MB initially and determine final mem config below.
+        mov     SDRAMBUS,a0
+        mov     (a0),d0
+        and     0xfffffffb,d0  // disable refresh
+        mov     d0,(a0)
+
+        mov     SDBASE0,a0
+        mov     SDBASE0_32M_INIT,d0
+        mov     d0,(a0)
+        mov     SDBASE1,a0
+        mov     SDBASE1_32M_INIT,d0
+        mov     d0,(a0)
+        mov     SDRAMBUS,a0
+        mov     SDRAMBUS_32M_INIT,d0
+        mov     d0,(a0)
+
+        mov     0x1000,d0
+0:
+        sub     1,d0
+        bne     0b
+
+        // Check for 16MB and 32MB shadowing to determine actual amount of
+        // memory installed. This assumes 8M, 16M, or 32M configs.
+        mov     0,d0
+        mov     d0,(0x91000000)
+        mov     d0,(0x92000000)
+        mov     0xaaaaaaaa,d0
+        mov     d0,(0x90000000)
+        mov     (0x91000000),d1
+        cmp     d0,d1
+        bne     1f
 
-	mov	SDBASE1,a0
-	mov	SDBASE1_INIT,d0
-	mov	d0,(a0)
+        // 16MB installed
+        mov     SDRAMBUS,a0
+        mov     (a0),d0
+        and     0xfffffffb,d0  // disable refresh
+        mov     d0,(a0)
+        mov     SDBASE0,a1
+        mov     SDBASE0_8M_INIT,d1
+        mov     d1,(a1)
+        mov     SDBASE1,a1
+        mov     SDBASE1_8M_INIT,d1
+        mov     d1,(a1)
+        mov     SDRAMBUS_8M_INIT,d0
+        mov     d0,(a0)
+        jmp     2f
+1:
+        mov     (0x92000000),d1
+        cmp     d0,d1
+        bne     2f
 
-	mov	SDRAMBUS,a0
-	mov	SDRAMBUS_INIT,d0
-	mov	d0,(a0)
+        // 32MB installed
+        mov     SDRAMBUS,a0
+        mov     (a0),d0
+        and     0xfffffffb,d0  // disable refresh
+        mov     d0,(a0)
+        mov     SDBASE0,a1
+        mov     SDBASE0_16M_INIT,d1
+        mov     d1,(a1)
+        mov     SDBASE1,a1
+        mov     SDBASE1_16M_INIT,d1
+        mov     d1,(a1)
+        mov     SDRAMBUS_16M_INIT,d0
+        mov     d0,(a0)
+2:
+#endif // ! CYG_HAL_STARTUP_RAM
 
 	// now the ROMs need putting into the right place
 	// - this is tricky because when we're booting from the system flash,
@@ -417,10 +477,8 @@ 0:
 	//   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	pc,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
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb/current/misc/redboot_FULLRAM.ecm
@@ -0,0 +1,92 @@
+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_option CYG_HAL_FULL_RAM {
+    user_value 1
+};
+
+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
+};
--- a/packages/hal/mn10300/asb2305/current/ChangeLog
+++ b/packages/hal/mn10300/asb2305/current/ChangeLog
@@ -1,3 +1,23 @@
+2002-12-06  Mark Salter  <msalter@redhat.com>
+
+	* cdl/hal_mn10300_am33_asb2305.cdl (CYG_HAL_FULL_RAM): New option to
+	indicate if RAM startup should use all RAM. This allows a special
+	RAM startup to be built which may be loaded onto a bare board by
+	the MEI tools. This can be used to build an initial RedBoot which
+	is used to program the flash with the ROM startup RedBoot image.
+	Implement CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP.
+
+	* misc/redboot_FULLRAM.ecm:
+	* include/pkgconf/mlt_mn10300_am33_asb2305_fullram.h:
+	* include/pkgconf/mlt_mn10300_am33_asb2305_fullram.ldi:
+	* include/pkgconf/mlt_mn10300_am33_asb2305_fullram.mlt: New files.
+	* include/pkgconf/mlt_mn10300_am33_asb2305_ram.h:
+	* include/pkgconf/mlt_mn10300_am33_asb2305_ram.ldi:
+	* include/pkgconf/mlt_mn10300_am33_asb2305_ram.mlt: Move ram base
+	so that ROM based RedBoot can load it.
+
+	* include/platform.inc: Add SDRAM runtime sizing.
+
 2002-11-19  Mark Salter  <msalter@redhat.com>
 
 	* cdl/hal_mn10300_am33_asb2305.cdl: Remove virtual vector comm support.
--- a/packages/hal/mn10300/asb2305/current/cdl/hal_mn10300_am33_asb2305.cdl
+++ b/packages/hal/mn10300/asb2305/current/cdl/hal_mn10300_am33_asb2305.cdl
@@ -65,6 +65,7 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB2
 
     implements    CYGINT_HAL_DEBUG_GDB_STUBS
     implements    CYGINT_HAL_DEBUG_GDB_STUBS_BREAK
+    implements    CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP
 
     requires CYGSEM_HAL_UNCACHED_FLASH_ACCESS == 1;
 
@@ -100,6 +101,16 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB2
             from."
     }
 
+    cdl_option CYG_HAL_FULL_RAM {
+        display       "Use all of RAM for RAM startup"
+        flavor        bool
+        default_value 0
+        description   "
+            This specifies whether or not RAM startup configurations use all of
+            RAM. This should be true when using the MEI debugger to load the RAM
+            startup program when no monitor is installed on the board."
+    }
+
     cdl_option CYGHWR_HAL_MN10300_PROCESSOR_OSC_DEFAULT {
         display       "Processor clock rate"
         calculated    33333333
@@ -207,7 +218,9 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB2
         display "Memory layout"
         flavor data
         no_define
-        calculated { CYG_HAL_STARTUP  == "RAM"      ? "mn10300_am33_asb2305_ram" : \
+        calculated { CYG_HAL_STARTUP  == "RAM"      ? \
+		         CYG_HAL_FULL_RAM ? "mn10300_am33_asb2305_fullram" : \
+                                            "mn10300_am33_asb2305_ram" : \
                      CYG_HAL_ROM_SLOT == "BootPROM" ? "mn10300_am33_asb2305_rom" : \
                                                       "mn10300_am33_asb2305_flash" }
 
@@ -216,7 +229,9 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB2
             flavor data
             no_define
             define -file system.h CYGHWR_MEMORY_LAYOUT_LDI
-            calculated { CYG_HAL_STARTUP == "RAM"       ? "<pkgconf/mlt_mn10300_am33_asb2305_ram.ldi>" : \
+            calculated { CYG_HAL_STARTUP == "RAM"       ? \
+                             CYG_HAL_FULL_RAM ? "<pkgconf/mlt_mn10300_am33_asb2305_fullram.ldi>" :  \
+                                                "<pkgconf/mlt_mn10300_am33_asb2305_ram.ldi>" : \
                          CYG_HAL_ROM_SLOT == "BootPROM" ? "<pkgconf/mlt_mn10300_am33_asb2305_rom.ldi>" : \
                                                           "<pkgconf/mlt_mn10300_am33_asb2305_flash.ldi>" }
         }
@@ -226,7 +241,9 @@ cdl_package CYGPKG_HAL_MN10300_AM33_ASB2
             flavor data
             no_define
             define -file system.h CYGHWR_MEMORY_LAYOUT_H
-            calculated { CYG_HAL_STARTUP == "RAM"       ? "<pkgconf/mlt_mn10300_am33_asb2305_ram.h>" : \
+            calculated { CYG_HAL_STARTUP == "RAM"       ? \
+			     CYG_HAL_FULL_RAM ? "<pkgconf/mlt_mn10300_am33_asb2305_fullram.h>" : \
+                                                "<pkgconf/mlt_mn10300_am33_asb2305_ram.h>" : \
                          CYG_HAL_ROM_SLOT == "BootPROM" ? "<pkgconf/mlt_mn10300_am33_asb2305_rom.h>" : \
                                                           "<pkgconf/mlt_mn10300_am33_asb2305_flash.h>" }
         }
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_fullram.h
@@ -0,0 +1,22 @@
+// eCos memory layout - Fri Oct 20 08:28:43 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	(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))
+#ifndef __ASSEMBLER__
+extern char CYG_LABEL_NAME (__pci_window) [];
+#endif
+#define CYGMEM_SECTION_pci_window (CYG_LABEL_NAME (__pci_window))
+#define CYGMEM_SECTION_pci_window_SIZE (0x80000)
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_fullram.ldi
@@ -0,0 +1,28 @@
+// eCos memory layout - Fri Oct 20 08:28:43 2000 -*- c -*-
+
+// This is a generated file - do not edit
+
+#include <cyg/infra/cyg_type.inc>
+
+MEMORY
+{
+    ram : ORIGIN = 0x90000000, LENGTH = 0x04000000
+}
+
+SECTIONS
+{
+    SECTIONS_BEGIN
+    SECTION_rom_vectors (ram, 0x90000000, 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)
+    SECTION_rodata1 (ram, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_fixup (ram, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_gcc_except_table (ram, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_data (ram, ALIGN (0x4), LMA_EQ_VMA)
+    SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA)
+    CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
+    CYG_LABEL_DEFN(__pci_window) = 0x9C000000; . = CYG_LABEL_DEFN(__pci_window) + 0x80000;
+    SECTIONS_END
+}
+
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_fullram.mlt
@@ -0,0 +1,13 @@
+version 0
+region ram 90000000 4000000 0 !
+section rom_vectors 0 1 0 1 1 1 1 1 90000000 90000000 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 1 0 1 data data !
+section data 0 4 0 1 0 1 0 1 bss bss !
+section bss 0 4 0 1 0 1 0 1 heap1 heap1 !
+section heap1 0 8 0 0 0 0 0 0 !
+section pci_window 80000 1 0 0 1 0 1 0 9c000000 9c000000 !
--- a/packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_ram.h
+++ b/packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_ram.h
@@ -7,8 +7,8 @@
 #include <stddef.h>
 
 #endif
-#define CYGMEM_REGION_ram	(0x90000000)
-#define CYGMEM_REGION_ram_SIZE	(0x04000000)
+#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) [];
--- a/packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_ram.ldi
+++ b/packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_ram.ldi
@@ -6,13 +6,13 @@
 
 MEMORY
 {
-    ram : ORIGIN = 0x90000000, LENGTH = 0x04000000
+    ram : ORIGIN = 0x90020000, LENGTH = 0x03fe0000
 }
 
 SECTIONS
 {
     SECTIONS_BEGIN
-    SECTION_rom_vectors (ram, 0x90000000, 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)
--- a/packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_ram.mlt
+++ b/packages/hal/mn10300/asb2305/current/include/pkgconf/mlt_mn10300_am33_asb2305_ram.mlt
@@ -1,6 +1,6 @@
 version 0
-region ram 90000000 4000000 0 !
-section rom_vectors 0 1 0 1 1 1 1 1 90000000 90000000 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/asb2305/current/include/platform.inc
+++ b/packages/hal/mn10300/asb2305/current/include/platform.inc
@@ -258,11 +258,23 @@ 0:	mov	_hal_diag_digits,a2
 #define SBCTRL72_INIT				0x0000000F
 
 #define SDBASE0			0xDA000008
-#define SDBASE0_INIT				0x9000FE01
 #define SDBASE1			0xDA00000C
-#define SDBASE1_INIT				0x9200FE01
 #define SDRAMBUS		0xDA000000
-#define SDRAMBUS_INIT				0xA8990654
+
+// 16MB SDRAM
+#define SDBASE0_8M_INIT         0x9000FF81
+#define SDBASE1_8M_INIT         0x9080FF81
+#define SDRAMBUS_8M_INIT        0xA8990654
+
+// 32MB SDRAM
+#define SDBASE0_16M_INIT        0x9000FF01
+#define SDBASE1_16M_INIT        0x9100FF01
+#define SDRAMBUS_16M_INIT       0xA89a0654
+
+// 64MB SDRAM
+#define SDBASE0_32M_INIT        0x9000fe01
+#define SDBASE1_32M_INIT        0x9200fe01
+#define SDRAMBUS_32M_INIT       0xa89b0654
 
 	.macro	hal_memc_init
 	mov	BCCR,a0
@@ -349,18 +361,74 @@ 0:
 	mov	d0,(SBCTRL72)
 #endif
 
-	# SDRAM
-	mov	SDBASE0,a0
-	mov	SDBASE0_INIT,d0
-	mov	d0,(a0)
+#ifndef CYG_HAL_STARTUP_RAM
+
+        // Setup for 64MB initially and determine final mem config below.
+        mov     SDRAMBUS,a0
+        mov     (a0),d0
+        and     0xfffffffb,d0  // disable refresh
+        mov     d0,(a0)
+
+        mov     SDBASE0,a0
+        mov     SDBASE0_32M_INIT,d0
+        mov     d0,(a0)
+        mov     SDBASE1,a0
+        mov     SDBASE1_32M_INIT,d0
+        mov     d0,(a0)
+        mov     SDRAMBUS,a0
+        mov     SDRAMBUS_32M_INIT,d0
+        mov     d0,(a0)
+
+        mov     0x1000,d0
+0:
+        sub     1,d0
+        bne     0b
+
+        // Check for 16MB and 32MB shadowing to determine actual amount of
+        // memory installed. This assumes 8M, 16M, or 32M configs.
+        mov     0,d0
+        mov     d0,(0x91000000)
+        mov     d0,(0x92000000)
+        mov     0xaaaaaaaa,d0
+        mov     d0,(0x90000000)
+        mov     (0x91000000),d1
+        cmp     d0,d1
+        bne     1f
 
-	mov	SDBASE1,a0
-	mov	SDBASE1_INIT,d0
-	mov	d0,(a0)
+        // 16MB installed
+        mov     SDRAMBUS,a0
+        mov     (a0),d0
+        and     0xfffffffb,d0  // disable refresh
+        mov     d0,(a0)
+        mov     SDBASE0,a1
+        mov     SDBASE0_8M_INIT,d1
+        mov     d1,(a1)
+        mov     SDBASE1,a1
+        mov     SDBASE1_8M_INIT,d1
+        mov     d1,(a1)
+        mov     SDRAMBUS_8M_INIT,d0
+        mov     d0,(a0)
+        jmp     2f
+1:
+        mov     (0x92000000),d1
+        cmp     d0,d1
+        bne     2f
 
-	mov	SDRAMBUS,a0
-	mov	SDRAMBUS_INIT,d0
-	mov	d0,(a0)
+        // 32MB installed
+        mov     SDRAMBUS,a0
+        mov     (a0),d0
+        and     0xfffffffb,d0  // disable refresh
+        mov     d0,(a0)
+        mov     SDBASE0,a1
+        mov     SDBASE0_16M_INIT,d1
+        mov     d1,(a1)
+        mov     SDBASE1,a1
+        mov     SDBASE1_16M_INIT,d1
+        mov     d1,(a1)
+        mov     SDRAMBUS_16M_INIT,d0
+        mov     d0,(a0)
+2:
+#endif // ! CYG_HAL_STARTUP_RAM
 
 	// now the ROMs need putting into the right place
 	// - this is tricky because when we're booting from the system flash,
new file mode 100644
--- /dev/null
+++ b/packages/hal/mn10300/asb2305/current/misc/redboot_FULLRAM.ecm
@@ -0,0 +1,111 @@
+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    asb2305 ;
+    template    redboot ;
+    package -hardware CYGPKG_HAL_MN10300 current ;
+    package -hardware CYGPKG_HAL_MN10300_AM33_ASB2305 current ;
+    package -hardware CYGPKG_HAL_MN10300_AM33 current ;
+    package -hardware CYGPKG_IO_SERIAL_MN10300 current ;
+    package -hardware CYGPKG_IO_PCI current ;
+    package -hardware CYGPKG_DEVICES_WATCHDOG_MN10300_MN10300 current ;
+    package -template CYGPKG_HAL current ;
+    package -template CYGPKG_INFRA current ;
+    package -template CYGPKG_REDBOOT current ;
+
+    package CYGPKG_IO_ETH_DRIVERS current ;
+    package -hardware CYGPKG_DEVS_ETH_MN10300_ASB2305 current ;
+    package -hardware CYGPKG_DEVS_ETH_AMD_PCNET current ;
+
+    package CYGPKG_IO_FLASH current ;
+    package -hardware CYGPKG_DEVS_FLASH_MN10300_ASB2305 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_option CYG_HAL_FULL_RAM {
+    user_value 1
+};
+
+cdl_component CYGBLD_BUILD_REDBOOT {
+    user_value 1
+};
+
+cdl_option CYGOPT_REDBOOT_FIS {
+    user_value 1
+};
+
+cdl_option CYGHWR_DEVS_FLASH_MN10300_ASB2305_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_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_RTSCTS {
+    user_value 1
+};
+
+cdl_option CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT {
+    user_value 0
+};
+
+cdl_option CYGSEM_DEVS_ETH_AMD_PCNET_FORCE_10MBPS {
+  user_value 1
+};
+
+cdl_option CYGSEM_REDBOOT_BSP_SYSCALLS {
+  user_value 1
+};