From 3bdbf640b7bcdc40a2d5171b67e50f92bbd588f6 Mon Sep 17 00:00:00 2001 From: weety Date: Sun, 21 Jul 2013 17:19:30 +0800 Subject: [PATCH] update at91sam9260 project directory structure. --- bsp/at91sam9260/SConscript | 30 ++++------- bsp/at91sam9260/applications/SConscript | 11 ++++ .../{ => applications}/application.c | 0 bsp/at91sam9260/{ => applications}/startup.c | 0 bsp/at91sam9260/drivers/SConscript | 31 +++++++++++ bsp/at91sam9260/{ => drivers}/at91_i2c_gpio.c | 0 bsp/at91sam9260/{ => drivers}/at91_mci.c | 0 bsp/at91sam9260/{ => drivers}/at91_mci.h | 0 bsp/at91sam9260/{ => drivers}/board.c | 13 ++++- bsp/at91sam9260/{ => drivers}/board.h | 0 bsp/at91sam9260/{ => drivers}/led.c | 0 bsp/at91sam9260/{ => drivers}/led.h | 0 bsp/at91sam9260/{ => drivers}/macb.c | 0 bsp/at91sam9260/{ => drivers}/macb.h | 0 bsp/at91sam9260/{ => drivers}/mii.h | 0 bsp/at91sam9260/{ => drivers}/usart.c | 0 bsp/at91sam9260/platform/SConscript | 26 +++++++++ .../at91sam9260/platform}/at91_aic.h | 0 .../at91sam9260/platform}/at91_pdc.h | 0 .../at91sam9260/platform}/at91_pio.h | 0 .../at91sam9260/platform}/at91_pit.h | 0 .../at91sam9260/platform}/at91_pmc.h | 0 .../at91sam9260/platform}/at91_rstc.h | 0 .../at91sam9260/platform}/at91_serial.h | 0 .../at91sam9260/platform}/at91_shdwc.h | 0 .../at91sam9260/platform}/at91_tc.h | 0 .../platform}/at91sam9260_matrix.h | 0 .../at91sam9260/platform}/at91sam926x.h | 0 .../at91sam9260/platform}/gpio.h | 0 .../at91sam9260/platform}/interrupt.c | 0 .../at91sam9260/platform}/io.h | 0 .../at91sam9260/platform}/irq.h | 0 bsp/at91sam9260/platform/reset.c | 34 ++++++++++++ .../at91sam9260/platform}/start_gcc.S | 0 .../at91sam9260/platform}/start_rvds.S | 0 .../at91sam9260/platform}/system_clock.c | 0 .../at91sam9260/platform}/trap.c | 1 - bsp/at91sam9260/rtconfig.py | 2 +- .../arm/{at91sam926x => arm926}/context_gcc.S | 0 .../{at91sam926x => arm926}/context_rvds.S | 0 .../{at91sam926x/cpu.c => arm926/cpuport.c} | 23 ++------ libcpu/arm/{at91sam926x => arm926}/mmu.c | 39 +++----------- libcpu/arm/arm926/mmu.h | 53 +++++++++++++++++++ libcpu/arm/{at91sam926x => arm926}/stack.c | 0 44 files changed, 190 insertions(+), 73 deletions(-) create mode 100644 bsp/at91sam9260/applications/SConscript rename bsp/at91sam9260/{ => applications}/application.c (100%) mode change 100755 => 100644 rename bsp/at91sam9260/{ => applications}/startup.c (100%) mode change 100755 => 100644 create mode 100644 bsp/at91sam9260/drivers/SConscript rename bsp/at91sam9260/{ => drivers}/at91_i2c_gpio.c (100%) rename bsp/at91sam9260/{ => drivers}/at91_mci.c (100%) mode change 100755 => 100644 rename bsp/at91sam9260/{ => drivers}/at91_mci.h (100%) rename bsp/at91sam9260/{ => drivers}/board.c (85%) mode change 100755 => 100644 rename bsp/at91sam9260/{ => drivers}/board.h (100%) mode change 100755 => 100644 rename bsp/at91sam9260/{ => drivers}/led.c (100%) mode change 100755 => 100644 rename bsp/at91sam9260/{ => drivers}/led.h (100%) mode change 100755 => 100644 rename bsp/at91sam9260/{ => drivers}/macb.c (100%) mode change 100755 => 100644 rename bsp/at91sam9260/{ => drivers}/macb.h (100%) mode change 100755 => 100644 rename bsp/at91sam9260/{ => drivers}/mii.h (100%) rename bsp/at91sam9260/{ => drivers}/usart.c (100%) create mode 100644 bsp/at91sam9260/platform/SConscript rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91_aic.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91_pdc.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91_pio.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91_pit.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91_pmc.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91_rstc.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91_serial.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91_shdwc.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91_tc.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91sam9260_matrix.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/at91sam926x.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/gpio.h (100%) rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/interrupt.c (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/io.h (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/irq.h (100%) mode change 100755 => 100644 create mode 100644 bsp/at91sam9260/platform/reset.c rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/start_gcc.S (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/start_rvds.S (100%) rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/system_clock.c (100%) mode change 100755 => 100644 rename {libcpu/arm/at91sam926x => bsp/at91sam9260/platform}/trap.c (98%) mode change 100755 => 100644 rename libcpu/arm/{at91sam926x => arm926}/context_gcc.S (100%) mode change 100755 => 100644 rename libcpu/arm/{at91sam926x => arm926}/context_rvds.S (100%) rename libcpu/arm/{at91sam926x/cpu.c => arm926/cpuport.c} (91%) mode change 100755 => 100644 rename libcpu/arm/{at91sam926x => arm926}/mmu.c (85%) create mode 100644 libcpu/arm/arm926/mmu.h rename libcpu/arm/{at91sam926x => arm926}/stack.c (100%) mode change 100755 => 100644 diff --git a/bsp/at91sam9260/SConscript b/bsp/at91sam9260/SConscript index c754911e9..fe0ae941a 100755 --- a/bsp/at91sam9260/SConscript +++ b/bsp/at91sam9260/SConscript @@ -1,24 +1,14 @@ -import rtconfig +# for module compiling +import os Import('RTT_ROOT') -from building import * -src_bsp = ['application.c', 'startup.c', 'board.c'] -src_drv = ['usart.c'] +cwd = str(Dir('#')) +objs = [] +list = os.listdir(cwd) -if GetDepend('RT_USING_LED'): - src_drv += ['led.c'] +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(d, 'SConscript')) -if GetDepend('RT_USING_SDIO'): - src_drv += ['at91_mci.c'] - -if GetDepend('RT_USING_LWIP'): - src_drv += ['macb.c'] - -if GetDepend('RT_USING_I2C') and GetDepend('RT_USING_I2C_BITOPS'): - src_drv += ['at91_i2c_gpio.c'] - -src = File(src_bsp + src_drv) -CPPPATH = [RTT_ROOT + '/bsp/at91sam9260'] -group = DefineGroup('Startup', src, depend = [''], CPPPATH = CPPPATH) - -Return('group') +Return('objs') diff --git a/bsp/at91sam9260/applications/SConscript b/bsp/at91sam9260/applications/SConscript new file mode 100644 index 000000000..01eb940df --- /dev/null +++ b/bsp/at91sam9260/applications/SConscript @@ -0,0 +1,11 @@ +Import('RTT_ROOT') +Import('rtconfig') +from building import * + +cwd = os.path.join(str(Dir('#')), 'applications') +src = Glob('*.c') +CPPPATH = [cwd, str(Dir('#'))] + +group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/at91sam9260/application.c b/bsp/at91sam9260/applications/application.c old mode 100755 new mode 100644 similarity index 100% rename from bsp/at91sam9260/application.c rename to bsp/at91sam9260/applications/application.c diff --git a/bsp/at91sam9260/startup.c b/bsp/at91sam9260/applications/startup.c old mode 100755 new mode 100644 similarity index 100% rename from bsp/at91sam9260/startup.c rename to bsp/at91sam9260/applications/startup.c diff --git a/bsp/at91sam9260/drivers/SConscript b/bsp/at91sam9260/drivers/SConscript new file mode 100644 index 000000000..d0470f904 --- /dev/null +++ b/bsp/at91sam9260/drivers/SConscript @@ -0,0 +1,31 @@ +Import('RTT_ROOT') +Import('rtconfig') +from building import * + +cwd = os.path.join(str(Dir('#')), 'drivers') + +# add the general drvers. +src = Split(""" +board.c +usart.c +""") + +# add Ethernet drvers. +if GetDepend('RT_USING_LED'): + src += ['led.c'] + +if GetDepend('RT_USING_SDIO'): + src += ['at91_mci.c'] + +if GetDepend('RT_USING_LWIP'): + src += ['macb.c'] + +if GetDepend('RT_USING_I2C') and GetDepend('RT_USING_I2C_BITOPS'): + src += ['at91_i2c_gpio.c'] + + +CPPPATH = [cwd] + +group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/at91sam9260/at91_i2c_gpio.c b/bsp/at91sam9260/drivers/at91_i2c_gpio.c similarity index 100% rename from bsp/at91sam9260/at91_i2c_gpio.c rename to bsp/at91sam9260/drivers/at91_i2c_gpio.c diff --git a/bsp/at91sam9260/at91_mci.c b/bsp/at91sam9260/drivers/at91_mci.c old mode 100755 new mode 100644 similarity index 100% rename from bsp/at91sam9260/at91_mci.c rename to bsp/at91sam9260/drivers/at91_mci.c diff --git a/bsp/at91sam9260/at91_mci.h b/bsp/at91sam9260/drivers/at91_mci.h similarity index 100% rename from bsp/at91sam9260/at91_mci.h rename to bsp/at91sam9260/drivers/at91_mci.h diff --git a/bsp/at91sam9260/board.c b/bsp/at91sam9260/drivers/board.c old mode 100755 new mode 100644 similarity index 85% rename from bsp/at91sam9260/board.c rename to bsp/at91sam9260/drivers/board.c index 81f156d15..a9ac7f07e --- a/bsp/at91sam9260/board.c +++ b/bsp/at91sam9260/drivers/board.c @@ -16,6 +16,7 @@ #include #include "board.h" +#include /** * @addtogroup at91sam9260 @@ -24,13 +25,21 @@ extern void rt_hw_clock_init(void); -extern void rt_hw_mmu_init(void); extern void rt_hw_get_clock(void); extern void rt_hw_set_dividor(rt_uint8_t hdivn, rt_uint8_t pdivn); extern void rt_hw_set_clock(rt_uint8_t sdiv, rt_uint8_t pdiv, rt_uint8_t mdiv); extern void rt_dbgu_isr(void); +static struct mem_desc at91_mem_desc[] = { + { 0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB }, /* None cached for 4G memory */ + { 0x20000000, 0x24000000-1, 0x20000000, RW_CB }, /* 64M cached SDRAM memory */ + { 0x00000000, 0x100000, 0x20000000, RW_CB }, /* isr vector table */ + { 0x90000000, 0x90400000 - 1, 0x00200000, RW_NCNB }, /* 4K SRAM0 + 4k SRAM1 */ + { 0xA0000000, 0xA4000000-1, 0x20000000, RW_NCNB } /* 64M none-cached SDRAM memory */ +}; + + #define PIT_CPIV(x) ((x) & AT91_PIT_CPIV) #define PIT_PICNT(x) (((x) & AT91_PIT_PICNT) >> 20) @@ -132,7 +141,7 @@ void rt_hw_board_init() rt_console_set_device(RT_CONSOLE_DEVICE_NAME); /* initialize mmu */ - rt_hw_mmu_init(); + rt_hw_mmu_init(at91_mem_desc, sizeof(at91_mem_desc)/sizeof(at91_mem_desc[0])); /* initialize timer0 */ rt_hw_timer_init(); diff --git a/bsp/at91sam9260/board.h b/bsp/at91sam9260/drivers/board.h old mode 100755 new mode 100644 similarity index 100% rename from bsp/at91sam9260/board.h rename to bsp/at91sam9260/drivers/board.h diff --git a/bsp/at91sam9260/led.c b/bsp/at91sam9260/drivers/led.c old mode 100755 new mode 100644 similarity index 100% rename from bsp/at91sam9260/led.c rename to bsp/at91sam9260/drivers/led.c diff --git a/bsp/at91sam9260/led.h b/bsp/at91sam9260/drivers/led.h old mode 100755 new mode 100644 similarity index 100% rename from bsp/at91sam9260/led.h rename to bsp/at91sam9260/drivers/led.h diff --git a/bsp/at91sam9260/macb.c b/bsp/at91sam9260/drivers/macb.c old mode 100755 new mode 100644 similarity index 100% rename from bsp/at91sam9260/macb.c rename to bsp/at91sam9260/drivers/macb.c diff --git a/bsp/at91sam9260/macb.h b/bsp/at91sam9260/drivers/macb.h old mode 100755 new mode 100644 similarity index 100% rename from bsp/at91sam9260/macb.h rename to bsp/at91sam9260/drivers/macb.h diff --git a/bsp/at91sam9260/mii.h b/bsp/at91sam9260/drivers/mii.h similarity index 100% rename from bsp/at91sam9260/mii.h rename to bsp/at91sam9260/drivers/mii.h diff --git a/bsp/at91sam9260/usart.c b/bsp/at91sam9260/drivers/usart.c similarity index 100% rename from bsp/at91sam9260/usart.c rename to bsp/at91sam9260/drivers/usart.c diff --git a/bsp/at91sam9260/platform/SConscript b/bsp/at91sam9260/platform/SConscript new file mode 100644 index 000000000..1f5de6e77 --- /dev/null +++ b/bsp/at91sam9260/platform/SConscript @@ -0,0 +1,26 @@ +Import('RTT_ROOT') +Import('rtconfig') +from building import * + +cwd = GetCurrentDir() +CPPPATH = [cwd] + +# The set of source files associated with this SConscript file. +if rtconfig.PLATFORM == 'armcc': + src = Glob('*.c') + Glob('*_rvds.S') + +if rtconfig.PLATFORM == 'gcc': + src = Glob('*.c') + Glob('*_gcc.S') + Glob('*_init.S') + +if rtconfig.PLATFORM == 'iar': + src = Glob('*.c') + Glob('*_iar.S') + +if rtconfig.PLATFORM == 'cl': + src = Glob('*.c') + +if rtconfig.PLATFORM == 'mingw': + src = Glob('*.c') + +group = DefineGroup('platform', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/libcpu/arm/at91sam926x/at91_aic.h b/bsp/at91sam9260/platform/at91_aic.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91_aic.h rename to bsp/at91sam9260/platform/at91_aic.h diff --git a/libcpu/arm/at91sam926x/at91_pdc.h b/bsp/at91sam9260/platform/at91_pdc.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91_pdc.h rename to bsp/at91sam9260/platform/at91_pdc.h diff --git a/libcpu/arm/at91sam926x/at91_pio.h b/bsp/at91sam9260/platform/at91_pio.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91_pio.h rename to bsp/at91sam9260/platform/at91_pio.h diff --git a/libcpu/arm/at91sam926x/at91_pit.h b/bsp/at91sam9260/platform/at91_pit.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91_pit.h rename to bsp/at91sam9260/platform/at91_pit.h diff --git a/libcpu/arm/at91sam926x/at91_pmc.h b/bsp/at91sam9260/platform/at91_pmc.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91_pmc.h rename to bsp/at91sam9260/platform/at91_pmc.h diff --git a/libcpu/arm/at91sam926x/at91_rstc.h b/bsp/at91sam9260/platform/at91_rstc.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91_rstc.h rename to bsp/at91sam9260/platform/at91_rstc.h diff --git a/libcpu/arm/at91sam926x/at91_serial.h b/bsp/at91sam9260/platform/at91_serial.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91_serial.h rename to bsp/at91sam9260/platform/at91_serial.h diff --git a/libcpu/arm/at91sam926x/at91_shdwc.h b/bsp/at91sam9260/platform/at91_shdwc.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91_shdwc.h rename to bsp/at91sam9260/platform/at91_shdwc.h diff --git a/libcpu/arm/at91sam926x/at91_tc.h b/bsp/at91sam9260/platform/at91_tc.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91_tc.h rename to bsp/at91sam9260/platform/at91_tc.h diff --git a/libcpu/arm/at91sam926x/at91sam9260_matrix.h b/bsp/at91sam9260/platform/at91sam9260_matrix.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91sam9260_matrix.h rename to bsp/at91sam9260/platform/at91sam9260_matrix.h diff --git a/libcpu/arm/at91sam926x/at91sam926x.h b/bsp/at91sam9260/platform/at91sam926x.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/at91sam926x.h rename to bsp/at91sam9260/platform/at91sam926x.h diff --git a/libcpu/arm/at91sam926x/gpio.h b/bsp/at91sam9260/platform/gpio.h similarity index 100% rename from libcpu/arm/at91sam926x/gpio.h rename to bsp/at91sam9260/platform/gpio.h diff --git a/libcpu/arm/at91sam926x/interrupt.c b/bsp/at91sam9260/platform/interrupt.c old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/interrupt.c rename to bsp/at91sam9260/platform/interrupt.c diff --git a/libcpu/arm/at91sam926x/io.h b/bsp/at91sam9260/platform/io.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/io.h rename to bsp/at91sam9260/platform/io.h diff --git a/libcpu/arm/at91sam926x/irq.h b/bsp/at91sam9260/platform/irq.h old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/irq.h rename to bsp/at91sam9260/platform/irq.h diff --git a/bsp/at91sam9260/platform/reset.c b/bsp/at91sam9260/platform/reset.c new file mode 100644 index 000000000..e116304dd --- /dev/null +++ b/bsp/at91sam9260/platform/reset.c @@ -0,0 +1,34 @@ +/* + * File : reset.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006, RT-Thread Develop Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://openlab.rt-thread.com/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2011-01-13 weety modified from mini2440 + */ + +#include +#include +#include "at91sam926x.h" + +/** + * @addtogroup AT91SAM926X + */ +/*@{*/ + +void machine_reset(void) +{ + at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); +} + +void machine_shutdown(void) +{ + at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); +} + +/*@}*/ diff --git a/libcpu/arm/at91sam926x/start_gcc.S b/bsp/at91sam9260/platform/start_gcc.S old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/start_gcc.S rename to bsp/at91sam9260/platform/start_gcc.S diff --git a/libcpu/arm/at91sam926x/start_rvds.S b/bsp/at91sam9260/platform/start_rvds.S similarity index 100% rename from libcpu/arm/at91sam926x/start_rvds.S rename to bsp/at91sam9260/platform/start_rvds.S diff --git a/libcpu/arm/at91sam926x/system_clock.c b/bsp/at91sam9260/platform/system_clock.c old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/system_clock.c rename to bsp/at91sam9260/platform/system_clock.c diff --git a/libcpu/arm/at91sam926x/trap.c b/bsp/at91sam9260/platform/trap.c old mode 100755 new mode 100644 similarity index 98% rename from libcpu/arm/at91sam926x/trap.c rename to bsp/at91sam9260/platform/trap.c index 9be71ddca..6735ffd23 --- a/libcpu/arm/at91sam926x/trap.c +++ b/bsp/at91sam9260/platform/trap.c @@ -156,7 +156,6 @@ void rt_hw_trap_irq() at91_sys_write(AT91_AIC_EOICR, 0); return; } - //at91_sys_write(AT91_AIC_EOICR, 0x55555555); /* get interrupt service routine */ isr_func = irq_desc[irq].handler; diff --git a/bsp/at91sam9260/rtconfig.py b/bsp/at91sam9260/rtconfig.py index 07432cedc..10870f880 100755 --- a/bsp/at91sam9260/rtconfig.py +++ b/bsp/at91sam9260/rtconfig.py @@ -2,7 +2,7 @@ import os # toolchains options ARCH = 'arm' -CPU = 'at91sam926x' +CPU = 'arm926' TextBase = '0x20000000' CROSS_TOOL = 'gcc' diff --git a/libcpu/arm/at91sam926x/context_gcc.S b/libcpu/arm/arm926/context_gcc.S old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/context_gcc.S rename to libcpu/arm/arm926/context_gcc.S diff --git a/libcpu/arm/at91sam926x/context_rvds.S b/libcpu/arm/arm926/context_rvds.S similarity index 100% rename from libcpu/arm/at91sam926x/context_rvds.S rename to libcpu/arm/arm926/context_rvds.S diff --git a/libcpu/arm/at91sam926x/cpu.c b/libcpu/arm/arm926/cpuport.c old mode 100755 new mode 100644 similarity index 91% rename from libcpu/arm/at91sam926x/cpu.c rename to libcpu/arm/arm926/cpuport.c index dce573c83..caddf45a9 --- a/libcpu/arm/at91sam926x/cpu.c +++ b/libcpu/arm/arm926/cpuport.c @@ -14,16 +14,13 @@ #include #include -#include "at91sam926x.h" - -/** - * @addtogroup AT91SAM926X - */ -/*@{*/ #define ICACHE_MASK (rt_uint32_t)(1 << 12) #define DCACHE_MASK (rt_uint32_t)(1 << 2) +extern void machine_reset(void); +extern void machine_shutdown(void); + #ifdef __GNUC__ rt_inline rt_uint32_t cp15_rd(void) { @@ -148,16 +145,6 @@ rt_base_t rt_hw_cpu_dcache_status() return (cp15_rd() & DCACHE_MASK); } -static void at91sam9260_reset(void) -{ - at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); -} - -static void at91sam9260_poweroff(void) -{ - at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); -} - /** * reset cpu by dog's time-out * @@ -166,7 +153,7 @@ void rt_hw_cpu_reset() { rt_kprintf("Restarting system...\n"); - at91sam9260_reset(); + machine_reset(); while(1); /* loop forever and wait for reset to happen */ @@ -183,7 +170,7 @@ void rt_hw_cpu_shutdown() rt_kprintf("shutdown...\n"); level = rt_hw_interrupt_disable(); - at91sam9260_poweroff(); + machine_shutdown(); while (level) { RT_ASSERT(0); diff --git a/libcpu/arm/at91sam926x/mmu.c b/libcpu/arm/arm926/mmu.c similarity index 85% rename from libcpu/arm/at91sam926x/mmu.c rename to libcpu/arm/arm926/mmu.c index 5b88eee27..c14f22bd8 100644 --- a/libcpu/arm/at91sam926x/mmu.c +++ b/libcpu/arm/arm926/mmu.c @@ -11,31 +11,7 @@ * Date Author Notes */ -#include - -#define CACHE_LINE_SIZE 32 - -#define DESC_SEC (0x2|(1<<4)) -#define CB (3<<2) //cache_on, write_back -#define CNB (2<<2) //cache_on, write_through -#define NCB (1<<2) //cache_off,WR_BUF on -#define NCNB (0<<2) //cache_off,WR_BUF off -#define AP_RW (3<<10) //supervisor=RW, user=RW -#define AP_RO (2<<10) //supervisor=RW, user=RO - -#define DOMAIN_FAULT (0x0) -#define DOMAIN_CHK (0x1) -#define DOMAIN_NOTCHK (0x3) -#define DOMAIN0 (0x0<<5) -#define DOMAIN1 (0x1<<5) - -#define DOMAIN0_ATTR (DOMAIN_CHK<<0) -#define DOMAIN1_ATTR (DOMAIN_FAULT<<2) - -#define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC) /* Read/Write, cache, write back */ -#define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC) /* Read/Write, cache, write through */ -#define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */ -#define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */ +#include "mmu.h" #ifdef __CC_ARM void mmu_setttbase(rt_uint32_t i) @@ -459,7 +435,7 @@ void mmu_setmtt(rt_uint32_t vaddrStart, rt_uint32_t vaddrEnd, rt_uint32_t paddrS } } -void rt_hw_mmu_init(void) +void rt_hw_mmu_init(struct mem_desc *mdesc, rt_uint32_t size) { /* disable I/D cache */ mmu_disable_dcache(); @@ -468,11 +444,12 @@ void rt_hw_mmu_init(void) mmu_invalidate_tlb(); /* set page table */ - mmu_setmtt(0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB); /* None cached for 4G memory */ - mmu_setmtt(0x20000000, 0x24000000-1, 0x20000000, RW_CB); /* 64M cached SDRAM memory */ - mmu_setmtt(0x00000000, 0x100000, 0x20000000, RW_CB); /* isr vector table */ - mmu_setmtt(0x90000000, 0x90400000 - 1, 0x00200000, RW_NCNB); /* 4K SRAM0 + 4k SRAM1 */ - mmu_setmtt(0xA0000000, 0xA4000000-1, 0x20000000, RW_NCNB); /* 64M none-cached SDRAM memory */ + for (; size > 0; size--) + { + mmu_setmtt(mdesc->vaddr_start, mdesc->vaddr_end, + mdesc->paddr_start, mdesc->attr); + mdesc++; + } /* set MMU table address */ mmu_setttbase((rt_uint32_t)_page_table); diff --git a/libcpu/arm/arm926/mmu.h b/libcpu/arm/arm926/mmu.h new file mode 100644 index 000000000..e45d3b023 --- /dev/null +++ b/libcpu/arm/arm926/mmu.h @@ -0,0 +1,53 @@ +/* + * File : mmu.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + */ + +#ifndef __MMU_H__ +#define __MMU_H__ + +#include + +#define CACHE_LINE_SIZE 32 + +#define DESC_SEC (0x2|(1<<4)) +#define CB (3<<2) //cache_on, write_back +#define CNB (2<<2) //cache_on, write_through +#define NCB (1<<2) //cache_off,WR_BUF on +#define NCNB (0<<2) //cache_off,WR_BUF off +#define AP_RW (3<<10) //supervisor=RW, user=RW +#define AP_RO (2<<10) //supervisor=RW, user=RO + +#define DOMAIN_FAULT (0x0) +#define DOMAIN_CHK (0x1) +#define DOMAIN_NOTCHK (0x3) +#define DOMAIN0 (0x0<<5) +#define DOMAIN1 (0x1<<5) + +#define DOMAIN0_ATTR (DOMAIN_CHK<<0) +#define DOMAIN1_ATTR (DOMAIN_FAULT<<2) + +#define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC) /* Read/Write, cache, write back */ +#define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC) /* Read/Write, cache, write through */ +#define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */ +#define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */ + +struct mem_desc { + rt_uint32_t vaddr_start; + rt_uint32_t vaddr_end; + rt_uint32_t paddr_start; + rt_uint32_t attr; +}; + +void rt_hw_mmu_init(struct mem_desc *mdesc, rt_uint32_t size); + +#endif + diff --git a/libcpu/arm/at91sam926x/stack.c b/libcpu/arm/arm926/stack.c old mode 100755 new mode 100644 similarity index 100% rename from libcpu/arm/at91sam926x/stack.c rename to libcpu/arm/arm926/stack.c