summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorTill Straumann <strauman@slac.stanford.edu>2011-05-18 05:26:53 +0000
committerTill Straumann <strauman@slac.stanford.edu>2011-05-18 05:26:53 +0000
commit4f599ed99fc0aa37bc4d100cf787880c1e1bb97a (patch)
tree56fa22232321006e3aa761e38495a786d0f3632d /c
parent2011-05-16 Yaakov Selkowitz <yselkowitz@users.sourceforge.net> (diff)
downloadrtems-4f599ed99fc0aa37bc4d100cf787880c1e1bb97a.tar.bz2
2011-05-18 Till Straumann <strauman@slac.stanford.edu>
PR1797/bsps: Applied cleaned-up version of Kate's patch. CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK is now a 'bspopts.h' setting and as such configurable.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/ChangeLog20
-rw-r--r--c/src/lib/libbsp/powerpc/ChangeLog18
-rw-r--r--c/src/lib/libbsp/powerpc/beatnik/ChangeLog6
-rw-r--r--c/src/lib/libbsp/powerpc/beatnik/configure.ac10
-rw-r--r--c/src/lib/libbsp/powerpc/beatnik/include/bsp.h2
-rw-r--r--c/src/lib/libbsp/powerpc/ep1a/ChangeLog6
-rw-r--r--c/src/lib/libbsp/powerpc/ep1a/configure.ac10
-rw-r--r--c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog6
-rw-r--r--c/src/lib/libbsp/powerpc/motorola_powerpc/configure.ac10
-rw-r--r--c/src/lib/libbsp/powerpc/motorola_powerpc/include/bsp.h1
-rw-r--r--c/src/lib/libbsp/powerpc/mvme3100/ChangeLog6
-rw-r--r--c/src/lib/libbsp/powerpc/mvme3100/configure.ac10
-rw-r--r--c/src/lib/libbsp/powerpc/mvme3100/include/bsp.h1
-rw-r--r--c/src/lib/libbsp/powerpc/mvme5500/ChangeLog6
-rw-r--r--c/src/lib/libbsp/powerpc/mvme5500/configure.ac10
-rw-r--r--c/src/lib/libbsp/powerpc/mvme5500/include/bsp.h2
-rw-r--r--c/src/lib/libbsp/powerpc/psim/ChangeLog6
-rw-r--r--c/src/lib/libbsp/powerpc/psim/configure.ac10
-rw-r--r--c/src/lib/libbsp/powerpc/score603e/ChangeLog6
-rw-r--r--c/src/lib/libbsp/powerpc/score603e/configure.ac10
-rw-r--r--c/src/lib/libbsp/powerpc/shared/startup/bspgetworkarea.c4
-rw-r--r--c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c2
-rw-r--r--c/src/lib/libbsp/powerpc/shared/startup/sbrk.c48
-rw-r--r--c/src/lib/libbsp/shared/bootcard.c60
-rw-r--r--c/src/lib/libbsp/shared/include/bootcard.h17
25 files changed, 238 insertions, 49 deletions
diff --git a/c/src/lib/libbsp/ChangeLog b/c/src/lib/libbsp/ChangeLog
index 80e1bd54b1..f17382dfa3 100644
--- a/c/src/lib/libbsp/ChangeLog
+++ b/c/src/lib/libbsp/ChangeLog
@@ -1,3 +1,23 @@
+2011-05-17 Till Straumann <strauman@slac.stanford.edu>
+
+ PR1797/bsps
+ * shared/bootcard.c, shared/include/bootcard.h: cleaned-up and
+ applied fixes proposed by PR#1797.
+
+2011-05-12 Joel Sherrill <joel.sherrill@OARcorp.com>
+
+ PR1797/bsps
+ * bootcard.c:
+ Added #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK to minimize code
+ for small targets.
+
+2011-05-12 Kate Feng <feng@bnl.gov>
+
+ PR1797/bsps
+ * bootcard.c:
+ Fixed the value of heap_start & heap_size for the single-heap case.
+ Added bsp_sbrk_init() to fix PPC memory allocation beyond 32 MB.
+
2010-04-14 Ralf Corsépius <ralf.corsepius@rtems.org>
* shared/umon/umoncons.c:
diff --git a/c/src/lib/libbsp/powerpc/ChangeLog b/c/src/lib/libbsp/powerpc/ChangeLog
index a50f0abdbf..ddedeef7a2 100644
--- a/c/src/lib/libbsp/powerpc/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/ChangeLog
@@ -1,3 +1,21 @@
+2011-05-17 Till Straumann <strauman@slac.stanford.edu>
+
+ PR1797/bsps
+ * shared/startup/sbrk.c: Cleanup; changed default
+ BSP_sbrk_policy to yield all memory to the heap.
+ App must specify a different policy if desired.
+
+2011-05-13 Gedare Bloom <gedare@gwmail.gwu.edu>
+
+ PR1797/bsps
+ * shared/startup/sbrk.c : Renamed bsp_sbrk_init().
+
+2011-05-07 Kate Feng <feng@bnl.gov>
+
+ PR1797/bsps
+ * shared/startup/bspgetworkarea.c: Removed _bsp_sbrk_init().
+ * shared/startup/pretaskinghook.c: Removed rtems/malloc.h.
+
2011-02-11 Ralf Corsépius <ralf.corsepius@rtems.org>
* shared/console/polled_io.c, shared/flash/spansionFlash.c,
diff --git a/c/src/lib/libbsp/powerpc/beatnik/ChangeLog b/c/src/lib/libbsp/powerpc/beatnik/ChangeLog
index b70df8ac5d..b8ea072898 100644
--- a/c/src/lib/libbsp/powerpc/beatnik/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/beatnik/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-17 Till Straumann <strauman@slac.stanford.edu>
+
+ PR1797/bsps
+ * configure.ac, include/bsp.h: Made
+ CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK a bspopts.h setting.
+
2011-05-16 Till Straumann <strauman@slac.stanford.edu>
* include/bsp.h: define CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
diff --git a/c/src/lib/libbsp/powerpc/beatnik/configure.ac b/c/src/lib/libbsp/powerpc/beatnik/configure.ac
index 883b5f404b..1f170a2020 100644
--- a/c/src/lib/libbsp/powerpc/beatnik/configure.ac
+++ b/c/src/lib/libbsp/powerpc/beatnik/configure.ac
@@ -32,6 +32,16 @@ RTEMS_BSPOPTS_HELP([PPC_USE_DATA_CACHE],
of PowerPC 603e revisions and emulator versions.
The BSP actually contains the call that enables this.])
+RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
+RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
+[If defined then the BSP may reduce the available memory size
+initially. This can be useful for debugging (reduce the core
+size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
+Note that the policy can still be defined by the application
+(see sbrk.c, BSP_sbrk_policy). By undefining
+CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
+and a little memory is saved.])
+
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile])
diff --git a/c/src/lib/libbsp/powerpc/beatnik/include/bsp.h b/c/src/lib/libbsp/powerpc/beatnik/include/bsp.h
index 1da9582e2d..2bb44ed6bc 100644
--- a/c/src/lib/libbsp/powerpc/beatnik/include/bsp.h
+++ b/c/src/lib/libbsp/powerpc/beatnik/include/bsp.h
@@ -63,8 +63,6 @@ BSP_getDiscoveryVersion(int assertion);
*/
#define BSP_INTERRUPT_STACK_SIZE (16 * 1024)
-#define CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
-
/*
* base address definitions for several devices
*/
diff --git a/c/src/lib/libbsp/powerpc/ep1a/ChangeLog b/c/src/lib/libbsp/powerpc/ep1a/ChangeLog
index 1171186c44..6cd1aa1b1b 100644
--- a/c/src/lib/libbsp/powerpc/ep1a/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/ep1a/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-17 Till Straumann <strauman@slac.stanford.edu>
+
+ PR1797/bsps
+ * configure.ac: Made CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
+ a bspopts.h setting.
+
2011-03-04 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1751/bsps
diff --git a/c/src/lib/libbsp/powerpc/ep1a/configure.ac b/c/src/lib/libbsp/powerpc/ep1a/configure.ac
index 0ffce65384..a5a006ded3 100644
--- a/c/src/lib/libbsp/powerpc/ep1a/configure.ac
+++ b/c/src/lib/libbsp/powerpc/ep1a/configure.ac
@@ -33,6 +33,16 @@ RTEMS_BSPOPTS_SET([CONSOLE_USE_INTERRUPTS],[*],[0])
RTEMS_BSPOPTS_HELP([CONSOLE_USE_INTERRUPTS],
[whether using console interrupts])
+RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
+RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
+[If defined then the BSP may reduce the available memory size
+initially. This can be useful for debugging (reduce the core
+size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
+Note that the policy can still be defined by the application
+(see sbrk.c, BSP_sbrk_policy). By undefining
+CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
+and a little memory is saved.])
+
RTEMS_CHECK_NETWORKING
AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
diff --git a/c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog b/c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog
index 8ec737f091..24d55f649d 100644
--- a/c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-17 Till Straumann <strauman@slac.stanford.edu>
+
+ PR1797/bsps
+ * configure.ac, include/bsp.h: Made
+ CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK a bspopts.h setting.
+
2011-02-11 Ralf Corsépius <ralf.corsepius@rtems.org>
* include/tm27.h:
diff --git a/c/src/lib/libbsp/powerpc/motorola_powerpc/configure.ac b/c/src/lib/libbsp/powerpc/motorola_powerpc/configure.ac
index 06411611ff..9c958a3ee8 100644
--- a/c/src/lib/libbsp/powerpc/motorola_powerpc/configure.ac
+++ b/c/src/lib/libbsp/powerpc/motorola_powerpc/configure.ac
@@ -31,6 +31,16 @@ RTEMS_BSPOPTS_HELP([PPC_USE_DATA_CACHE],
of PowerPC 603e revisions and emulator versions.
The BSP actually contains the call that enables this.])
+RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
+RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
+[If defined then the BSP may reduce the available memory size
+initially. This can be useful for debugging (reduce the core
+size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
+Note that the policy can still be defined by the application
+(see sbrk.c, BSP_sbrk_policy). By undefining
+CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
+and a little memory is saved.])
+
RTEMS_BSPOPTS_SET([mvme2100],[mvme2100],[1])
RTEMS_BSPOPTS_SET([mvme2100],[*],[])
RTEMS_BSPOPTS_HELP([mvme2100],
diff --git a/c/src/lib/libbsp/powerpc/motorola_powerpc/include/bsp.h b/c/src/lib/libbsp/powerpc/motorola_powerpc/include/bsp.h
index 04df058c93..5b7e5ff255 100644
--- a/c/src/lib/libbsp/powerpc/motorola_powerpc/include/bsp.h
+++ b/c/src/lib/libbsp/powerpc/motorola_powerpc/include/bsp.h
@@ -23,7 +23,6 @@
/*
* confdefs.h overrides for this BSP:
*/
-#define CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
/*
* diagram illustrating the role of the configuration
diff --git a/c/src/lib/libbsp/powerpc/mvme3100/ChangeLog b/c/src/lib/libbsp/powerpc/mvme3100/ChangeLog
index 01164adc95..9f94eeb8f5 100644
--- a/c/src/lib/libbsp/powerpc/mvme3100/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/mvme3100/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-17 Till Straumann <strauman@slac.stanford.edu>
+
+ PR1797/bsps
+ * configure.ac, include/bsp.h: Made
+ CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK a bspopts.h setting.
+
2011-02-11 Ralf Corsépius <ralf.corsepius@rtems.org>
* network/tsec.c:
diff --git a/c/src/lib/libbsp/powerpc/mvme3100/configure.ac b/c/src/lib/libbsp/powerpc/mvme3100/configure.ac
index bbb74392da..befda153d6 100644
--- a/c/src/lib/libbsp/powerpc/mvme3100/configure.ac
+++ b/c/src/lib/libbsp/powerpc/mvme3100/configure.ac
@@ -35,6 +35,16 @@ RTEMS_BSPOPTS_HELP([PPC_USE_DATA_CACHE],
of PowerPC 603e revisions and emulator versions.
The BSP actually contains the call that enables this.])
+RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
+RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
+[If defined then the BSP may reduce the available memory size
+initially. This can be useful for debugging (reduce the core
+size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
+Note that the policy can still be defined by the application
+(see sbrk.c, BSP_sbrk_policy). By undefining
+CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
+and a little memory is saved.])
+
RTEMS_BSP_CLEANUP_OPTIONS(0, 1)
# Explicitly list all Makefiles here
diff --git a/c/src/lib/libbsp/powerpc/mvme3100/include/bsp.h b/c/src/lib/libbsp/powerpc/mvme3100/include/bsp.h
index bb38a7b4da..b9310cea09 100644
--- a/c/src/lib/libbsp/powerpc/mvme3100/include/bsp.h
+++ b/c/src/lib/libbsp/powerpc/mvme3100/include/bsp.h
@@ -25,7 +25,6 @@
/*
* confdefs.h overrides for this BSP:
*/
-#define CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
#define BSP_INTERRUPT_STACK_SIZE (16 * 1024)
diff --git a/c/src/lib/libbsp/powerpc/mvme5500/ChangeLog b/c/src/lib/libbsp/powerpc/mvme5500/ChangeLog
index 7210ba77de..b728f48fc8 100644
--- a/c/src/lib/libbsp/powerpc/mvme5500/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/mvme5500/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-17 Till Straumann <strauman@slac.stanford.edu>
+
+ PR1797/bsps
+ * configure.ac, include/bsp.h: Made
+ CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK a bspopts.h setting.
+
2011-02-11 Ralf Corsépius <ralf.corsepius@rtems.org>
* include/bsp.h, include/tm27.h:
diff --git a/c/src/lib/libbsp/powerpc/mvme5500/configure.ac b/c/src/lib/libbsp/powerpc/mvme5500/configure.ac
index 61a55965b6..e12dba3d8c 100644
--- a/c/src/lib/libbsp/powerpc/mvme5500/configure.ac
+++ b/c/src/lib/libbsp/powerpc/mvme5500/configure.ac
@@ -31,6 +31,16 @@ RTEMS_BSPOPTS_HELP([PPC_USE_DATA_CACHE],
of PowerPC 603e revisions and emulator versions.
The BSP actually contains the call that enables this.])
+RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
+RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
+[If defined then the BSP may reduce the available memory size
+initially. This can be useful for debugging (reduce the core
+size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
+Note that the policy can still be defined by the application
+(see sbrk.c, BSP_sbrk_policy). By undefining
+CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
+and a little memory is saved.])
+
RTEMS_BSP_CLEANUP_OPTIONS(0, 0)
# Explicitly list all Makefiles here
diff --git a/c/src/lib/libbsp/powerpc/mvme5500/include/bsp.h b/c/src/lib/libbsp/powerpc/mvme5500/include/bsp.h
index e8ed3b9ee7..a107a54f2a 100644
--- a/c/src/lib/libbsp/powerpc/mvme5500/include/bsp.h
+++ b/c/src/lib/libbsp/powerpc/mvme5500/include/bsp.h
@@ -116,8 +116,6 @@ DiscoveryChipVersion BSP_getDiscoveryChipVersion();
*/
#define BSP_INTERRUPT_STACK_SIZE (16 * 1024) /* <skf> 2/09 wants it to be adjustable by BSP */
-#define CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK /* <skf> 4/09 see shared/startup/sbrk.c and rtems/confdefs.h */
-
/* uart.c uses out_8 instead of outb */
#define BSP_UART_IOBASE_COM1 GT64x60_DEV1_BASE + 0x20000
#define BSP_UART_IOBASE_COM2 GT64x60_DEV1_BASE + 0x21000
diff --git a/c/src/lib/libbsp/powerpc/psim/ChangeLog b/c/src/lib/libbsp/powerpc/psim/ChangeLog
index 8e1b4989e3..55f3b1eba1 100644
--- a/c/src/lib/libbsp/powerpc/psim/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/psim/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-17 Till Straumann <strauman@slac.stanford.edu>
+
+ PR1797/bsps
+ * configure.ac: Made CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
+ a bspopts.h setting.
+
2011-02-11 Ralf Corsépius <ralf.corsepius@rtems.org>
* include/bsp.h, include/tm27.h, startup/bspstart.c:
diff --git a/c/src/lib/libbsp/powerpc/psim/configure.ac b/c/src/lib/libbsp/powerpc/psim/configure.ac
index 4f7d4ecebe..9b9ca92ed1 100644
--- a/c/src/lib/libbsp/powerpc/psim/configure.ac
+++ b/c/src/lib/libbsp/powerpc/psim/configure.ac
@@ -39,6 +39,16 @@ RTEMS_BSPOPTS_HELP([CLOCK_DRIVER_USE_FAST_IDLE],
a clock ISR occurs while the IDLE thread is executing. This can
significantly reduce simulation times.])
+RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
+RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
+[If defined then the BSP may reduce the available memory size
+initially. This can be useful for debugging (reduce the core
+size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
+Note that the policy can still be defined by the application
+(see sbrk.c, BSP_sbrk_policy). By undefining
+CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
+and a little memory is saved.])
+
RTEMS_BSP_CLEANUP_OPTIONS(0, 0)
# Explicitly list all Makefiles here
diff --git a/c/src/lib/libbsp/powerpc/score603e/ChangeLog b/c/src/lib/libbsp/powerpc/score603e/ChangeLog
index b35a4b5d47..519b014d78 100644
--- a/c/src/lib/libbsp/powerpc/score603e/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/score603e/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-17 Till Straumann <strauman@slac.stanford.edu>
+
+ PR1797/bsps
+ * configure.ac: Made CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
+ a bspopts.h setting.
+
2011-02-11 Ralf Corsépius <ralf.corsepius@rtems.org>
* PCI_bus/PCI.c, console/console.c, include/bsp.h, include/tm27.h,
diff --git a/c/src/lib/libbsp/powerpc/score603e/configure.ac b/c/src/lib/libbsp/powerpc/score603e/configure.ac
index 44fe3d2073..82a8cd0422 100644
--- a/c/src/lib/libbsp/powerpc/score603e/configure.ac
+++ b/c/src/lib/libbsp/powerpc/score603e/configure.ac
@@ -61,6 +61,16 @@ RTEMS_BSPOPTS_HELP([PPC_USE_DATA_CACHE],
of PowerPC 603e revisions and emulator versions.
The BSP actually contains the call that enables this.])
+RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
+RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
+[If defined then the BSP may reduce the available memory size
+initially. This can be useful for debugging (reduce the core
+size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
+Note that the policy can still be defined by the application
+(see sbrk.c, BSP_sbrk_policy). By undefining
+CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
+and a little memory is saved.])
+
RTEMS_BSPOPTS_SET([PPC_VECTOR_FILE_BASE],[*],[0x0100])
RTEMS_BSPOPTS_HELP([PPC_VECTOR_FILE_BASE],
[This defines the base address of the exception table.
diff --git a/c/src/lib/libbsp/powerpc/shared/startup/bspgetworkarea.c b/c/src/lib/libbsp/powerpc/shared/startup/bspgetworkarea.c
index bf8e9e4103..aabf3555e8 100644
--- a/c/src/lib/libbsp/powerpc/shared/startup/bspgetworkarea.c
+++ b/c/src/lib/libbsp/powerpc/shared/startup/bspgetworkarea.c
@@ -16,7 +16,6 @@
#endif
extern void *__rtems_end;
-extern uintptr_t _bsp_sbrk_init(uintptr_t, uintptr_t*);
/*
* This method returns the base address and size of the area which
@@ -31,15 +30,12 @@ void bsp_get_work_area(
)
{
uintptr_t work_size;
- uintptr_t spared;
uintptr_t work_area;
work_area = (uintptr_t)&__rtems_end +
rtems_configuration_get_interrupt_stack_size();
work_size = (uintptr_t)BSP_mem_size - work_area;
- spared = _bsp_sbrk_init( work_area, &work_size );
-
*work_area_start = (void *)work_area,
*work_area_size = work_size;
*heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
diff --git a/c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c b/c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c
index 48f99186c9..7763612840 100644
--- a/c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c
+++ b/c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c
@@ -26,8 +26,6 @@
#include <rtems/bspIo.h>
#endif
-#include <rtems/malloc.h>
-
/*
* bsp_pretasking_hook
*
diff --git a/c/src/lib/libbsp/powerpc/shared/startup/sbrk.c b/c/src/lib/libbsp/powerpc/shared/startup/sbrk.c
index 5d352132bd..dc6b49c6ef 100644
--- a/c/src/lib/libbsp/powerpc/shared/startup/sbrk.c
+++ b/c/src/lib/libbsp/powerpc/shared/startup/sbrk.c
@@ -70,8 +70,8 @@
#include <sys/types.h>
#include <unistd.h>
-static uint32_t remaining_start=0;
-static uint32_t remaining_size=0;
+static void * remaining_start=(void*)-1LL;
+static uintptr_t remaining_size=0;
/* App. may provide a value by defining the BSP_sbrk_policy
* variable.
@@ -81,16 +81,17 @@ static uint32_t remaining_size=0;
* 0 -> limit memory effectively to 32M.
*
*/
-extern uint32_t BSP_sbrk_policy __attribute__((weak));
+extern uintptr_t BSP_sbrk_policy __attribute__((weak));
-#define LIMIT_32M 0x02000000
+#define LIMIT_32M ((void*)0x02000000)
-uintptr_t _bsp_sbrk_init(
- uintptr_t heap_start,
+uintptr_t bsp_sbrk_init(
+ void *heap_start,
uintptr_t *heap_size_p
)
{
uintptr_t rval=0;
+ uintptr_t policy;
remaining_start = heap_start;
remaining_size = *heap_size_p;
@@ -104,29 +105,22 @@ uintptr_t _bsp_sbrk_init(
remaining_size = rval;
}
- if ( 0 != &BSP_sbrk_policy ) {
- switch ( BSP_sbrk_policy ) {
- case (uint32_t)(-1):
- *heap_size_p += rval;
- remaining_start = heap_start + *heap_size_p;
- remaining_size = 0;
- /* return a nonzero sbrk_amount because the libsupport code
- * at some point divides by this number prior to trying an
- * sbrk() which will fail.
- */
- rval = 1;
- break;
+ policy = (0 == &BSP_sbrk_policy ? (uintptr_t)(-1) : BSP_sbrk_policy);
+ switch ( policy ) {
+ case (uintptr_t)(-1):
+ *heap_size_p += rval;
+ remaining_start = heap_start + *heap_size_p;
+ remaining_size = 0;
+ break;
case 0:
- remaining_size = 0;
- /* see above for why we return 1 */
- rval = 1;
- break;
+ remaining_size = 0;
+ break;
default:
- if ( rval > BSP_sbrk_policy )
- rval = BSP_sbrk_policy;
- break;
+ if ( rval > policy )
+ rval = policy;
+ break;
}
}
@@ -143,9 +137,9 @@ void *bsp_sbrk(ptrdiff_t incr)
void *rval=(void*)-1;
/* FIXME: BEWARE if size >2G */
- if (incr <= remaining_size) {
+ if ( remaining_start != (void*)-1LL && incr <= remaining_size) {
remaining_size-=incr;
- rval = (void*)remaining_start;
+ rval = remaining_start;
remaining_start += incr;
} else {
errno = ENOMEM;
diff --git a/c/src/lib/libbsp/shared/bootcard.c b/c/src/lib/libbsp/shared/bootcard.c
index f18c97e6e9..bbd4b9f149 100644
--- a/c/src/lib/libbsp/shared/bootcard.c
+++ b/c/src/lib/libbsp/shared/bootcard.c
@@ -53,6 +53,11 @@
#include <bsp/bootcard.h>
#include <rtems/bspIo.h>
+#include <rtems/malloc.h>
+
+#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
+#include <unistd.h> /* for sbrk() */
+#endif
/*
* At most a single pointer to the cmdline for those target
@@ -74,23 +79,30 @@ static void bootcard_bsp_libc_helper(
void *work_area_start,
uintptr_t work_area_size,
void *heap_start,
- uintptr_t heap_size
+ uintptr_t heap_size,
+ uintptr_t sbrk_amount
)
{
- if ( !rtems_unified_work_area &&
- heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
- uintptr_t work_space_size = rtems_configuration_get_work_space_size();
+ if ( heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA ) {
+ if ( rtems_unified_work_area ) {
+ uintptr_t work_space_size = rtems_configuration_get_work_space_size();
- heap_start = (char *) work_area_start + work_space_size;
+ heap_start = (char *) work_area_start + work_space_size;
- if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
- uintptr_t heap_size_default = work_area_size - work_space_size;
+ if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
+ uintptr_t heap_size_default = work_area_size - work_space_size;
- heap_size = heap_size_default;
+ heap_size = heap_size_default;
+ }
+ } else {
+ heap_start = work_area_start;
+ if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
+ heap_size = work_area_size;
+ }
}
}
- bsp_libc_init(heap_start, heap_size, 0);
+ bsp_libc_init(heap_start, heap_size, sbrk_amount);
}
/*
@@ -108,6 +120,7 @@ int boot_card(
uintptr_t work_area_size = 0;
void *heap_start = NULL;
uintptr_t heap_size = 0;
+ uintptr_t sbrk_amount = 0;
/*
* Special case for PowerPC: The interrupt disable mask is stored in SPRG0.
@@ -136,6 +149,32 @@ int boot_card(
bsp_get_work_area(&work_area_start, &work_area_size,
&heap_start, &heap_size);
+#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
+ /* This routine may reduce the work area size with the
+ * option to extend it later via sbrk(). If the application
+ * was configured w/o CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK then
+ * omit this step.
+ */
+ if ( rtems_malloc_sbrk_helpers ) {
+ sbrk_amount = bsp_sbrk_init(work_area_start, &work_area_size);
+ if ( work_area_size < Configuration.work_space_size && sbrk_amount > 0 ) {
+ /* Need to use sbrk right now */
+ uintptr_t sbrk_now;
+
+ sbrk_now = (Configuration.work_space_size - work_area_size) / sbrk_amount;
+ sbrk( sbrk_now * sbrk_amount );
+ }
+ }
+#else
+ if ( rtems_malloc_sbrk_helpers ) {
+ printk("Configuration error!\n"
+ "Application was configured with CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK\n"
+ "but BSP was configured w/o sbrk support\n");
+ bsp_cleanup();
+ return -1;
+ }
+#endif
+
if ( work_area_size <= Configuration.work_space_size ) {
printk(
"bootcard: work space too big for work area: %p > %p\n",
@@ -170,7 +209,8 @@ int boot_card(
work_area_start,
work_area_size,
heap_start,
- heap_size
+ heap_size,
+ sbrk_amount
);
/*
diff --git a/c/src/lib/libbsp/shared/include/bootcard.h b/c/src/lib/libbsp/shared/include/bootcard.h
index 441eb1972f..74ad6eec61 100644
--- a/c/src/lib/libbsp/shared/include/bootcard.h
+++ b/c/src/lib/libbsp/shared/include/bootcard.h
@@ -89,6 +89,23 @@ void bsp_get_work_area(
);
/**
+ * @brief Gives the BSP a chance to reduce the work area size with sbrk() adding more later.
+ *
+ * bsp_sbrk_init() may reduce the work area size passed in. The routine
+ * returns the 'sbrk_amount' to be used when extending the heap.
+ * Note that the return value may be zero.
+ *
+ */
+
+#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
+uintptr_t bsp_sbrk_init(
+ void *work_area_begin,
+ uintptr_t *work_area_size_p
+);
+#endif
+
+
+/**
* @brief Standard system initialization procedure.
*
* You may pass a command line in @a cmdline. It is later available via the