From fe27e20ff244de9028b9399b2efadabf5b2c1896 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 10 Sep 2008 20:32:47 +0000 Subject: 2008-09-10 Joel Sherrill * Makefile.am, configure.ac, startup/bspstart.c: Split out bsp_get_work_area() into its own file and user BSP Framework to perform more initialization. * startup/bspgetworkarea.c: New file. --- c/src/lib/libbsp/arm/edb7312/ChangeLog | 7 + c/src/lib/libbsp/arm/edb7312/Makefile.am | 10 +- c/src/lib/libbsp/arm/edb7312/configure.ac | 2 + .../libbsp/arm/edb7312/startup/bspgetworkarea.c | 43 ++++++ c/src/lib/libbsp/arm/edb7312/startup/bspstart.c | 156 ++++----------------- 5 files changed, 86 insertions(+), 132 deletions(-) create mode 100644 c/src/lib/libbsp/arm/edb7312/startup/bspgetworkarea.c (limited to 'c/src/lib/libbsp/arm') diff --git a/c/src/lib/libbsp/arm/edb7312/ChangeLog b/c/src/lib/libbsp/arm/edb7312/ChangeLog index 5d4f2cc00f..6703b887d9 100644 --- a/c/src/lib/libbsp/arm/edb7312/ChangeLog +++ b/c/src/lib/libbsp/arm/edb7312/ChangeLog @@ -1,3 +1,10 @@ +2008-09-10 Joel Sherrill + + * Makefile.am, configure.ac, startup/bspstart.c: Split out + bsp_get_work_area() into its own file and user BSP Framework to + perform more initialization. + * startup/bspgetworkarea.c: New file. + 2008-09-05 Ralf Corsepius * timer/timer.c: Use "true" instead of "1" for "bool"s. diff --git a/c/src/lib/libbsp/arm/edb7312/Makefile.am b/c/src/lib/libbsp/arm/edb7312/Makefile.am index ea8b66f38c..f7a83a1d84 100644 --- a/c/src/lib/libbsp/arm/edb7312/Makefile.am +++ b/c/src/lib/libbsp/arm/edb7312/Makefile.am @@ -27,10 +27,12 @@ project_lib_DATA = start.$(OBJEXT) dist_project_lib_DATA += startup/linkcmds include_HEADERS += ../../arm/shared/comm/uart.h -startup_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \ - ../../shared/bsppredriverhook.c \ - startup/bspstart.c startup/bspclean.c ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../shared/gnatinstallhandler.c +startup_SOURCES = ../../shared/bsppost.c ../../shared/bsplibc.c \ + startup/bspgetworkarea.c ../../shared/bsppretaskinghook.c \ + ../../shared/bsppredriverhook.c startup/bspstart.c \ + startup/bspclean.c ../../shared/bootcard.c ../../shared/sbrk.c \ + ../../shared/gnatinstallhandler.c + clock_SOURCES = clock/clockdrv.c console_SOURCES = console/uart.c ../../shared/console.c timer_SOURCES = timer/timer.c diff --git a/c/src/lib/libbsp/arm/edb7312/configure.ac b/c/src/lib/libbsp/arm/edb7312/configure.ac index 88b003d19e..9f81f27d74 100644 --- a/c/src/lib/libbsp/arm/edb7312/configure.ac +++ b/c/src/lib/libbsp/arm/edb7312/configure.ac @@ -18,6 +18,8 @@ RTEMS_PROG_CCAS RTEMS_CHECK_NETWORKING AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes") +RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION + # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/c/src/lib/libbsp/arm/edb7312/startup/bspgetworkarea.c b/c/src/lib/libbsp/arm/edb7312/startup/bspgetworkarea.c new file mode 100644 index 0000000000..d8f4be7095 --- /dev/null +++ b/c/src/lib/libbsp/arm/edb7312/startup/bspgetworkarea.c @@ -0,0 +1,43 @@ +/* + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include +#include +#include + +extern void *_sdram_size; +extern void *_sdram_base; +extern void *_bss_free_start; + +/* + * This method returns the base address and size of the area which + * is to be allocated between the RTEMS Workspace and the C Program + * Heap. + */ +void bsp_get_work_area( + void **work_area_start, + size_t *work_area_size, + void **heap_start, + size_t *heap_size +) +{ + uintptr_t size; + + /* + * Old code had hard-coded heap size of 0x20000 and a comment indicating + * something about the undefined symbol MEM_NOCACHE_SIZE. + */ + size = (uintptr_t)&_sdram_base + (uintptr_t)&_sdram_size + - (uintptr_t)&_bss_free_start; + + *work_area_start = (void *)&_bss_free_start; + *work_area_size = size; + *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA; + *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT; +} + diff --git a/c/src/lib/libbsp/arm/edb7312/startup/bspstart.c b/c/src/lib/libbsp/arm/edb7312/startup/bspstart.c index b03933c1c9..ca4b5327e7 100644 --- a/c/src/lib/libbsp/arm/edb7312/startup/bspstart.c +++ b/c/src/lib/libbsp/arm/edb7312/startup/bspstart.c @@ -5,12 +5,10 @@ * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at - * * http://www.rtems.com/license/LICENSE. * - * * $Id$ -*/ + */ #include #include @@ -18,139 +16,41 @@ #include #include -/*************************************************************/ -/* Macros */ -/*************************************************************/ - -/*************************************************************/ -/* Data Structures */ -/*************************************************************/ - -/*************************************************************/ -/* Global Variables */ -/*************************************************************/ -extern void *_flash_size; -extern void *_flash_base; -extern void *_sdram_size; -extern void *_sdram_base; -extern void *_bss_free_start; - -unsigned long free_mem_start; -unsigned long free_mem_end; - -/*************************************************************/ -/* Function prototypes */ -/*************************************************************/ +/* + * Function prototypes + */ extern void rtems_irq_mngt_init(void); -void bsp_libc_init( void *, uint32_t, int ); - -/**************************************************************************/ -/* */ -/* NAME: bps_pretasking_hook - Function to setup system before startup */ -/* */ -/* DESCRIPTION: */ -/* This function is called before drivers are initialized and used */ -/* to setup libc and BSP extensions. It configures non cacheable */ -/* SDRAM, SRAM, AIM, and ADM regions and sets up the CPU's memory */ -/* protection unit. */ -/* */ -/* GLOBALS USED: */ -/* free_mem_start */ -/* free_mem_end */ -/* */ -/* RESTRICTIONS/LIMITATIONS: */ -/* Since this function is setting up libc, it cannot use and libc */ -/* functions. */ -/* */ -/**************************************************************************/ -void bsp_pretasking_hook(void) -{ - uint32_t heap_start; - uint32_t heap_size; - - /* - * Set up the heap. It uses all free SDRAM except that reserved - * for non-cached uses. - */ - heap_start = free_mem_start; - - /* heap_size = (free_mem_end - heap_start - MEM_NOCACHE_SIZE); */ - heap_size = 0x200000; - - bsp_libc_init((void *)heap_start, heap_size, 0); - -} /* bsp_pretasking_hook */ -/**************************************************************************/ -/* */ -/* NAME: bsp_start_default - BSP initialization function */ -/* */ -/* DESCRIPTION: */ -/* This function is called before RTEMS is initialized and used */ -/* adjust the kernel's configuration. */ -/* */ -/* This function also configures the CPU's memory protection unit. */ -/* */ -/* GLOBALS USED: */ -/* CPU_table */ -/* Configuration */ -/* free_mem_start */ -/* free_mem_end */ -/* free_mem_nocache_start */ -/* _bss_free_start */ -/* mpu_region_tbl */ -/* */ -/* */ -/* */ -/* */ -/* RESTRICTIONS/LIMITATIONS: */ -/* Since RTEMS is not configured, no RTEMS functions can be called. */ -/* */ -/**************************************************************************/ +/* + * NAME: bsp_start_default - BSP initialization function + * + * This function is called before RTEMS is initialized + * This function also configures the CPU's memory protection unit. + * + * + * RESTRICTIONS/LIMITATIONS: + * Since RTEMS is not configured, no RTEMS functions can be called. + * + */ void bsp_start_default( void ) { - /* disable interrupts */ - *EP7312_INTMR1 = 0; - *EP7312_INTMR2 = 0; - - /* Place RTEMS workspace at beginning of free memory. */ - Configuration.work_space_start = (void *)&_bss_free_start; - - free_mem_start = ((uint32_t)&_bss_free_start + - rtems_configuration_get_work_space_size()); - - free_mem_end = ((uint32_t)&_sdram_base + (uint32_t)&_sdram_size); - - /* - * Init rtems exceptions management - */ - rtems_exception_init_mngt(); - - /* - * Init rtems interrupt management - */ - rtems_irq_mngt_init(); - - /* - * The following information is very useful when debugging. - */ -#if 0 - printk( "work_space_size = 0x%x\n", - rtems_configuration_get_work_space_size() ); - printk( "microseconds_per_tick = 0x%x\n", - rtems_configuration_get_microseconds_per_tick() ); - printk( "ticks_per_timeslice = 0x%x\n", - rtems_configuration_get_ticks_per_timeslice() ); - - /* printk( "_stack_size = 0x%x\n", _stack_size );*/ - printk( "work_space_start = 0x%x\n", Configuration.work_space_start ); - printk( "work_space_size = 0x%x\n", rtems_configuration_get_work_space_size() ); -#endif + /* disable interrupts */ + *EP7312_INTMR1 = 0; + *EP7312_INTMR2 = 0; + + /* + * Init rtems exceptions management + */ + rtems_exception_init_mngt(); + + /* + * Init rtems interrupt management + */ + rtems_irq_mngt_init(); } /* bsp_start */ /* * By making this a weak alias for bsp_start_default, a brave soul * can override the actual bsp_start routine used. */ - void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default"))); -- cgit v1.2.3