From 63447fc7187bf2278e78f05c658c5870ba1f8a4c Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 11 Dec 2009 23:46:08 +0000 Subject: [PATCH] Add banked and non-banked configurations git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2322 42af7a65-404d-4744-a932-0658087f49c3 --- arch/hc/src/mc9s12ne64/mc9s12ne64_start.S | 48 ++++--- arch/hc/src/mc9s12ne64/mc9s12ne64_vectors.S | 24 +--- configs/demo9s12ne64/README.txt | 12 +- configs/demo9s12ne64/ostest/Make.defs | 20 ++- configs/demo9s12ne64/ostest/defconfig | 37 ++++-- .../ostest/{ld.script => ld.script.banked} | 2 +- .../demo9s12ne64/ostest/ld.script.nonbanked | 117 ++++++++++++++++++ 7 files changed, 201 insertions(+), 59 deletions(-) rename configs/demo9s12ne64/ostest/{ld.script => ld.script.banked} (99%) create mode 100755 configs/demo9s12ne64/ostest/ld.script.nonbanked diff --git a/arch/hc/src/mc9s12ne64/mc9s12ne64_start.S b/arch/hc/src/mc9s12ne64/mc9s12ne64_start.S index c99ca3a15f..34823f307c 100755 --- a/arch/hc/src/mc9s12ne64/mc9s12ne64_start.S +++ b/arch/hc/src/mc9s12ne64/mc9s12ne64_start.S @@ -94,6 +94,15 @@ movb #INITRM_MAP, HCS12_MMC_INITRM /* Set RAM position to 0x2000-0x3fff */ movb #INITEE_EE, HCS12_MMC_INITEE /* Set EEPROM position to 0x0800 */ + + /* In the non-banked mode, PPAGE is set to 0x3d to create a contiguous, 48Kb + * .text address space. + */ + +#ifdef CONFIG_HCS12_NONBANKED + movb #0x3d, HCS12_MMC_PPAGE +#endif + movb #MMC_MISC_ROMON, HCS12_MMC_MISC /* MISC: EXSTR1=0 EXSTR0=0 ROMHM=0 ROMON=1 */ .endm @@ -188,7 +197,11 @@ __start: /* Now, start the OS */ showprogress '\n' +#ifdef CONFIG_HCS12_NONBANKED + jsr os_start +#else call os_start +#endif bra __start /* Variables: @@ -201,32 +214,37 @@ __start: */ .Lsbss: - .long _sbss + .hword _sbss .Lebss: - .long _ebss + .hword _ebss .Lstackbase: .hword _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 .Leronly: - .long _eronly /* Where .data defaults are stored in FLASH */ + .hword _eronly /* Where .data defaults are stored in FLASH */ .Lsdata: - .long _sdata /* Where .data needs to reside in SDRAM */ + .hword _sdata /* Where .data needs to reside in SDRAM */ .Ledata: - .long _edata + .hword _edata .size __start, .-__start - /* This global variable is unsigned long g_heapbase and is - * exported from here only because of its coupling to LCO - * above. - */ - .data - .align 4 +/************************************************************************************ + * .rodata + ************************************************************************************/ + + .section .rodata, "a" + +/* Variables: _sbss is the start of the BSS region (see ld.script) _ebss is the end + * of the BSS regsion (see ld.script). The idle task stack starts at the end of BSS + * and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is the thread that + * the system boots on and, eventually, becomes the idle, do nothing task that runs + * only when there is nothing else to run. The heap continues from there until the + * end of memory. See g_heapbase below. + */ + .globl g_heapbase .type g_heapbase, object g_heapbase: - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE + .hword _ebss+CONFIG_IDLETHREAD_STACKSIZE .size g_heapbase, .-g_heapbase - - .end - .end diff --git a/arch/hc/src/mc9s12ne64/mc9s12ne64_vectors.S b/arch/hc/src/mc9s12ne64/mc9s12ne64_vectors.S index 47d793ba00..b21f53b62d 100755 --- a/arch/hc/src/mc9s12ne64/mc9s12ne64_vectors.S +++ b/arch/hc/src/mc9s12ne64/mc9s12ne64_vectors.S @@ -196,6 +196,9 @@ handlers: vcommon: .size handlers, .-handlers +/************************************************************************************ + * .bss + ************************************************************************************/ /************************************************************************************ * Name: up_interruptstack/g_userstack * @@ -212,26 +215,5 @@ up_interruptstack: up_interruptstack_base: .size up_interruptstack, .-up_interruptstack #endif - -/************************************************************************************ - * .rodata - ************************************************************************************/ - - .section .rodata, "a" - -/* Variables: _sbss is the start of the BSS region (see ld.script) _ebss is the end - * of the BSS regsion (see ld.script). The idle task stack starts at the end of BSS - * and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is the thread that - * the system boots on and, eventually, becomes the idle, do nothing task that runs - * only when there is nothing else to run. The heap continues from there until the - * end of memory. See g_heapbase below. - */ - - .globl g_heapbase - .type g_heapbase, object -g_heapbase: - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase - .end diff --git a/configs/demo9s12ne64/README.txt b/configs/demo9s12ne64/README.txt index 54bfcb1d3a..0aceb49fc5 100755 --- a/configs/demo9s12ne64/README.txt +++ b/configs/demo9s12ne64/README.txt @@ -253,13 +253,19 @@ HCS12/DEMO9S12NEC64-specific Configuration Options the 100 second delay then adjust CONFIG_ARCH_LOOPSPERMSEC until the delay actually is 100 seconds. - HCS12 specific chip initialization - - HCS12 specific device driver settings + HCS12 build options: CONFIG_HCS12_SERIALMON - Indicates that the target systems uses the Freescale serial bootloader. + CONFIG_HCS12_NONBANKED - Indicates that the target systems does not + support banking. Only short calls are made; one fixed page is + presented the the paging window. Only 48Kb of FLASH is usable + in this configuration: pages 3e, 3d, then 3f will appear as a + contiguous address space in memory. + + HCS12 specific device driver settings: + CONFIG_SCIO_SERIAL_CONSOLE - selects the SCIO for the console and ttys0 (default is the UART0). diff --git a/configs/demo9s12ne64/ostest/Make.defs b/configs/demo9s12ne64/ostest/Make.defs index d125c36f9c..1068d30422 100755 --- a/configs/demo9s12ne64/ostest/Make.defs +++ b/configs/demo9s12ne64/ostest/Make.defs @@ -36,11 +36,19 @@ include ${TOPDIR}/.config # Setup for the selected toolchain +# NuttX buildroot under Linux or Cygwin - # NuttX buildroot under Linux or Cygwin - CROSSDEV = m68hc12-elf- - ARCHCPUFLAGS = -m68hcs12 -mshort - MAXOPTIMIZATION = -Os +CROSSDEV = m68hc12-elf- +MAXOPTIMIZATION = -Os +WINTOOL = n + +ifeq ($(CONFIG_HCS12_NONBANKED),y) + ARCHCPUFLAGS = -m68hcs12 -mshort -mnolong-calls + LDSCRIPT = ld.script.nonbanked +else + ARCHCPUFLAGS = -m68hcs12 -mshort -mlong-calls + LDSCRIPT = ld.script.banked +endif ifeq ($(WINTOOL),y) # Windows-native toolchains @@ -49,14 +57,14 @@ ifeq ($(WINTOOL),y) MKDEP = $(TOPDIR)/tools/mknulldeps.sh ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" - ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ostest/ld.script}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ostest/$(LDSCRIPT)}" MAXOPTIMIZATION = -O2 else # Linux/Cygwin-native toolchain MKDEP = $(TOPDIR)/tools/mkdeps.sh ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx - ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ostest/ld.script + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ostest/$(LDSCRIPT) endif CC = $(CROSSDEV)gcc diff --git a/configs/demo9s12ne64/ostest/defconfig b/configs/demo9s12ne64/ostest/defconfig index 6e24093607..82fa012a3d 100755 --- a/configs/demo9s12ne64/ostest/defconfig +++ b/configs/demo9s12ne64/ostest/defconfig @@ -89,12 +89,24 @@ CONFIG_ARCH_BUTTONS=n CONFIG_ARCH_CALIBRATION=n CONFIG_ARCH_DMA=n +# +# HCS12 build options: +# +# CONFIG_HCS12_SERIALMON - Indicates that the target systems uses +# the Freescale serial bootloader. +# CONFIG_HCS12_NONBANKED - Indicates that the target systems does not +# support banking. Only short calls are made; one fixed page is +# presented the the paging window. Only 48Kb of FLASH is usable +# in this configuration: pages 3e, 3d, then 3f will appear as a +# contiguous address space in memory. +# + +CONFIG_HCS12_SERIALMON=y +CONFIG_HCS12_NONBANKED=y # # MC9S12NEC64 specific serial device driver settings # -# CONFIG_HCS12_SERIALMON - Indicates that the target systems uses -# the Freescale serial bootloader. # CONFIG_SCIO_SERIAL_CONSOLE - selects the SCIO for the # console and ttys0 (default is the SCIO). # CONFIG_SCIO_RXBUFSIZE - Characters are buffered as received. @@ -106,10 +118,9 @@ CONFIG_ARCH_DMA=n # CONFIG_SCIO_PARTIY - 0=no parity, 1=odd parity, 2=even parity # CONFIG_SCIO_2STOP - Two stop bits # -CONFIG_HCS12_SERIALMON=y CONFIG_SCIO_SERIAL_CONSOLE=y -CONFIG_SCIO_TXBUFSIZE=256 -CONFIG_SCIO_RXBUFSIZE=256 +CONFIG_SCIO_TXBUFSIZE=32 +CONFIG_SCIO_RXBUFSIZE=32 CONFIG_SCIO_BAUD=115200 CONFIG_SCIO_BITS=8 CONFIG_SCIO_PARITY=0 @@ -257,8 +268,8 @@ CONFIG_RR_INTERVAL=200 CONFIG_SCHED_INSTRUMENTATION=n CONFIG_TASK_NAME_SIZE=0 CONFIG_START_YEAR=2009 -CONFIG_START_MONTH=9 -CONFIG_START_DAY=21 +CONFIG_START_MONTH=12 +CONFIG_START_DAY=11 CONFIG_GREGORIAN_TIME=n CONFIG_JULIAN_TIME=n CONFIG_DEV_CONSOLE=y @@ -274,7 +285,7 @@ CONFIG_NXFLAT=n CONFIG_SCHED_WORKQUEUE=n CONFIG_SCHED_WORKPRIORITY=50 CONFIG_SCHED_WORKPERIOD=(50*1000) -CONFIG_SCHED_WORKSTACKSIZE=1024 +CONFIG_SCHED_WORKSTACKSIZE=256 CONFIG_SIG_SIGWORK=4 # @@ -605,7 +616,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1) # Settings for examples/ostest # CONFIG_EXAMPLES_OSTEST_LOOPS=1 -CONFIG_EXAMPLES_OSTEST_STACKSIZE=2048 +CONFIG_EXAMPLES_OSTEST_STACKSIZE=512 CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # @@ -645,7 +656,7 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 CONFIG_EXAMPLES_NSH_FILEIOSIZE=512 CONFIG_EXAMPLES_NSH_STRERROR=n CONFIG_EXAMPLES_NSH_LINELEN=64 -CONFIG_EXAMPLES_NSH_STACKSIZE=2048 +CONFIG_EXAMPLES_NSH_STACKSIZE=512 CONFIG_EXAMPLES_NSH_NESTDEPTH=3 CONFIG_EXAMPLES_NSH_DISABLESCRIPT=n CONFIG_EXAMPLES_NSH_DISABLEBG=n @@ -724,9 +735,9 @@ CONFIG_BOOT_RUNFROMFLASH=n CONFIG_BOOT_COPYTORAM=n CONFIG_CUSTOM_STACK=n CONFIG_STACK_POINTER= -CONFIG_IDLETHREAD_STACKSIZE=1024 -CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_IDLETHREAD_STACKSIZE=256 +CONFIG_USERMAIN_STACKSIZE=512 CONFIG_PTHREAD_STACK_MIN=256 -CONFIG_PTHREAD_STACK_DEFAULT=2048 +CONFIG_PTHREAD_STACK_DEFAULT=256 CONFIG_HEAP_BASE= CONFIG_HEAP_SIZE= diff --git a/configs/demo9s12ne64/ostest/ld.script b/configs/demo9s12ne64/ostest/ld.script.banked similarity index 99% rename from configs/demo9s12ne64/ostest/ld.script rename to configs/demo9s12ne64/ostest/ld.script.banked index caf3ea4493..39d0631873 100755 --- a/configs/demo9s12ne64/ostest/ld.script +++ b/configs/demo9s12ne64/ostest/ld.script.banked @@ -45,7 +45,7 @@ MEMORY sram (rwx) : ORIGIN = 0x2000, LENGTH = 8K-256 - /* Two fixed text flash pages (corresponding to page 3e and 3f */ + /* Two fixed text flash pages (corresponding to page 3e and 3f) */ lowtext(rx) : ORIGIN = 0x4000, LENGTH = 16K /* Page 3e */ hitext (rx) : ORIGIN = 0xc000, LENGTH = 16K-2k /* Page 3f */ diff --git a/configs/demo9s12ne64/ostest/ld.script.nonbanked b/configs/demo9s12ne64/ostest/ld.script.nonbanked new file mode 100755 index 0000000000..d27ebff972 --- /dev/null +++ b/configs/demo9s12ne64/ostest/ld.script.nonbanked @@ -0,0 +1,117 @@ +/**************************************************************************** + * configs/demo9s12ne64/ostest/ld.script + * + * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* The DEMO9S12NE64 has 64Kb of FLASH and 8Kb of SRAM that are assumed to be + * paged and positioned as below: + */ + +MEMORY +{ + /* The 8Kb SRAM is mapped to 0x2000-0x2fff. The top 256 bytes are reserved + * for the serial monitor stack space. + */ + + sram (rwx) : ORIGIN = 0x2000, LENGTH = 8K-256 + + /* Three fixed text flash pages (corresponding to page 3e, 3d, and 3f) at + * 16Kb each (minus 2Kb at the end of page 3f that is reserved at the top for + * the serial boot loader + */ + + text (rx) : ORIGIN = 0x4000, LENGTH = 48K-2k /* Page 3e, 3d, and 3f */ + + /* Vectors. These get relocated to 0xf780-f7ff by the serial loader */ + + vectors (rx) : ORIGIN = 0xff80, LENGTH = 256 +} + +OUTPUT_ARCH(m68hc12) +ENTRY(_stext) +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > text + + _eronly = ABSOLUTE(.); /* See below */ + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > sram AT > text + + .bss : { /* BSS */ + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + _ebss = ABSOLUTE(.); + } > sram + + .vectors : { + _svectors = ABSOLUTE(.); + *(.vectors) + _evectors = ABSOLUTE(.); + } > vectors + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +}