summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/shared
diff options
context:
space:
mode:
authorThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2008-07-24 14:52:55 +0000
committerThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2008-07-24 14:52:55 +0000
commitd4886a069506e9c69086d28c578db80abc37976d (patch)
tree4f35ea3a64cb9e1b743a32ea93606af940cfc3d2 /c/src/lib/libbsp/shared
parentNew function rtems_interrupt_handler_iterate() (diff)
downloadrtems-d4886a069506e9c69086d28c578db80abc37976d.tar.bz2
Changed bsp_get_workarea() to bsp_get_work_area() and
added support for an optional separate heap area.
Diffstat (limited to 'c/src/lib/libbsp/shared')
-rw-r--r--c/src/lib/libbsp/shared/ChangeLog7
-rw-r--r--c/src/lib/libbsp/shared/bootcard.c89
-rw-r--r--c/src/lib/libbsp/shared/bsppretaskinghook.c7
-rw-r--r--c/src/lib/libbsp/shared/include/bootcard.h75
4 files changed, 132 insertions, 46 deletions
diff --git a/c/src/lib/libbsp/shared/ChangeLog b/c/src/lib/libbsp/shared/ChangeLog
index 78d03a6c57..f6442f0926 100644
--- a/c/src/lib/libbsp/shared/ChangeLog
+++ b/c/src/lib/libbsp/shared/ChangeLog
@@ -1,5 +1,12 @@
2008-07-24 Sebastian Huber <sebastian.huber@embedded-brains.de>
+ * include/bootcard.h: New file.
+
+ * bootcard.c: Changed bsp_get_workarea() to bsp_get_work_area() and
+ added support for an optional separate heap area.
+
+ * bsppretaskinghook.c: Cleanup. Include bootcard.h.
+
* include/irq-generic.h, src/irq-generic.c, src/irq-legacy.c: Support
for new rtems_interrupt_handler_iterate() function.
diff --git a/c/src/lib/libbsp/shared/bootcard.c b/c/src/lib/libbsp/shared/bootcard.c
index e52ddf869c..4f461f6b3d 100644
--- a/c/src/lib/libbsp/shared/bootcard.c
+++ b/c/src/lib/libbsp/shared/bootcard.c
@@ -43,12 +43,9 @@
* $Id$
*/
-#include <stddef.h>
-#include <stdint.h>
-
#include <rtems.h>
-#include <bspopts.h> /* for BSP_BOOTCARD_HANDLES_RAM_ALLOCATION */
+#include <bsp/bootcard.h>
/*
* Since there is a forward reference
@@ -56,44 +53,41 @@
char *rtems_progname;
/*
- * Prototypes of external routines
- */
-extern void bsp_start( void );
-extern void bsp_cleanup( void );
-extern void bsp_pretasking_hook(void);
-extern void bsp_libc_init( void *, uint32_t, int );
-extern void bsp_predriver_hook(void);
-extern void bsp_postdriver_hook(void);
-
-/*
* These are the prototypes and helper routines which are used
* when the BSP lets the framework handle RAM allocation between
* the RTEMS Workspace and C Program Heap.
*/
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
- extern void bsp_get_workarea( void **, size_t *, size_t *);
-
- void bootcard_bsp_libc_helper(
- void *workarea_base,
- size_t workarea_size,
- size_t requested_heap_size
+ static void bootcard_bsp_libc_helper(
+ void *work_area_start,
+ size_t work_area_size,
+ void *heap_start,
+ size_t heap_size
)
{
- uint32_t heap_start;
- uint32_t heap_size;
-
- heap_start = (uint32_t) workarea_base;
- if (heap_start & (CPU_ALIGNMENT-1))
- heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
-
- if ( requested_heap_size == 0 ) {
- heap_size = Configuration.work_space_start - workarea_base;
- heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */
- } else {
- heap_size = requested_heap_size;
+ if (heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
+ /* Use the work area start as heap start */
+ heap_start = work_area_start;
+
+ /* Ensure proper alignement */
+ if ((uintptr_t) heap_start & (CPU_ALIGNMENT - 1)) {
+ heap_start = (void *) (((uintptr_t) heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT - 1));
+ }
+
+ /*
+ * Use the free space from the start of the work area up to the work
+ * space start as heap area.
+ */
+ if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
+ heap_size = (char *) Configuration.work_space_start
+ - (char *) work_area_start;
+
+ /* Keep it as a multiple of 16 bytes */
+ heap_size &= 0xfffffff0;
+ }
}
- bsp_libc_init((void *) heap_start, heap_size, 0);
+ bsp_libc_init( heap_start, (uint32_t) heap_size, 0);
}
#endif
@@ -115,9 +109,10 @@ int boot_card(
char **envp_p = &envp_pointer;
rtems_interrupt_level bsp_isr_level;
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
- void *workarea_base;
- size_t workarea_size;
- size_t heap_size;
+ void *work_area_start = NULL;
+ size_t work_area_size = 0;
+ void *heap_start = NULL;
+ size_t heap_size = 0;
#endif
/*
@@ -156,14 +151,19 @@ int boot_card(
*/
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
{
- unsigned char *work_space_start;
+ void *work_space_start = NULL;
- bsp_get_workarea( &workarea_base, &workarea_size, &heap_size );
+ bsp_get_work_area(
+ &work_area_start,
+ &work_area_size,
+ &heap_start,
+ &heap_size
+ );
- work_space_start = workarea_base + workarea_size
+ work_space_start = (char *) work_area_start + work_area_size
- rtems_configuration_get_work_space_size();
- if ( work_space_start <= (unsigned char *)workarea_base ) {
+ if ((uintptr_t) work_space_start <= (uintptr_t) work_area_start) {
printk( "bootcard: Not enough RAM!!!\n" );
bsp_cleanup();
return -1;
@@ -172,7 +172,7 @@ int boot_card(
Configuration.work_space_start = work_space_start;
#if (BSP_DIRTY_MEMORY == 1)
- memset(workarea_base, 0xCF, workarea_size);
+ memset( work_area_start, 0xCF, work_area_size);
#endif
}
@@ -193,7 +193,12 @@ int boot_card(
* framework.
*/
#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
- bootcard_bsp_libc_helper( workarea_base, workarea_size, heap_size );
+ bootcard_bsp_libc_helper(
+ work_area_start,
+ work_area_size,
+ heap_start,
+ heap_size
+ );
#endif
/*
diff --git a/c/src/lib/libbsp/shared/bsppretaskinghook.c b/c/src/lib/libbsp/shared/bsppretaskinghook.c
index 6a28bfdac3..8437ff933a 100644
--- a/c/src/lib/libbsp/shared/bsppretaskinghook.c
+++ b/c/src/lib/libbsp/shared/bsppretaskinghook.c
@@ -1,7 +1,7 @@
/*
* This is a shared BSP pretasking hook which does nothing.
* If all the BSP needs to do is initialize the C library,
- * then it can rely on bootcard.c and provide bsp_get_workarea().
+ * then it can rely on bootcard.c and provide bsp_get_work_area().
*
* COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
@@ -13,10 +13,9 @@
* $Id$
*/
-#include <rtems.h>
-#include <rtems/libio.h>
-#include <fcntl.h>
+#include <bsp/bootcard.h>
void bsp_pretasking_hook(void)
{
+ /* Do nothing */
}
diff --git a/c/src/lib/libbsp/shared/include/bootcard.h b/c/src/lib/libbsp/shared/include/bootcard.h
new file mode 100644
index 0000000000..a0720cda7f
--- /dev/null
+++ b/c/src/lib/libbsp/shared/include/bootcard.h
@@ -0,0 +1,75 @@
+/**
+ * @file
+ *
+ * @ingroup bsp_shared
+ *
+ * @brief Header file for basic BSP startup functions.
+ */
+
+/*
+ * Copyright (c) 2008
+ * Embedded Brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * rtems@embedded-brains.de
+ *
+ * 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$
+ */
+
+/**
+ * @defgroup bsp_shared Shared BSP Code
+ */
+
+#ifndef LIBBSP_SHARED_BOOTCARD_H
+#define LIBBSP_SHARED_BOOTCARD_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <bspopts.h> /* for BSP_BOOTCARD_HANDLES_RAM_ALLOCATION */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void bsp_start( void);
+
+void bsp_pretasking_hook( void);
+
+void bsp_predriver_hook( void);
+
+void bsp_postdriver_hook( void);
+
+void bsp_cleanup( void);
+
+#ifdef BSP_BOOTCARD_HANDLES_RAM_ALLOCATION
+ #define BSP_BOOTCARD_HEAP_USES_WORK_AREA NULL
+
+ #define BSP_BOOTCARD_HEAP_SIZE_DEFAULT 0
+
+ void bsp_get_work_area(
+ void **work_area_start,
+ size_t *work_area_size,
+ void **heap_start,
+ size_t *heap_size
+ );
+#endif
+
+int boot_card( int argc, char **argv, char **envp);
+
+/*
+ * FIXME: Nearly every BSP declares this function in the BSP startup file
+ * separately and uses the implementation in bsplibc.c.
+ * Why differ the parameter types from RTEMS_Malloc_Initialize()?
+ */
+void bsp_libc_init( void *heap_start, uint32_t heap_size, int use_sbrk);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LIBBSP_SHARED_BOOTCARD_H */