summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc/shared
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/sparc/shared')
-rw-r--r--c/src/lib/libbsp/sparc/shared/amba/ambapp.c10
-rw-r--r--c/src/lib/libbsp/sparc/shared/startup/bspgetworkarea.c8
-rw-r--r--c/src/lib/libbsp/sparc/shared/startup/early_malloc.c47
3 files changed, 6 insertions, 59 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp.c
index dba56c1f48..e4f1aacbd1 100644
--- a/c/src/lib/libbsp/sparc/shared/amba/ambapp.c
+++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp.c
@@ -23,18 +23,16 @@
/* Allocate one AMBA device */
static struct ambapp_dev *ambapp_alloc_dev_struct(int dev_type)
{
- int size = sizeof(struct ambapp_dev);
struct ambapp_dev *dev;
+ size_t size = sizeof(*dev);
if (dev_type == DEV_APB_SLV)
size += sizeof(struct ambapp_apb_info);
else
size += sizeof(struct ambapp_ahb_info); /* AHB */
- dev = (struct ambapp_dev *)bsp_early_malloc(size);
- if (dev == NULL)
- return NULL;
- memset(dev, 0 , size);
- dev->dev_type = dev_type;
+ dev = (struct ambapp_dev *)calloc(1, size);
+ if (dev != NULL)
+ dev->dev_type = dev_type;
return dev;
}
diff --git a/c/src/lib/libbsp/sparc/shared/startup/bspgetworkarea.c b/c/src/lib/libbsp/sparc/shared/startup/bspgetworkarea.c
index a68d295826..b05113d9eb 100644
--- a/c/src/lib/libbsp/sparc/shared/startup/bspgetworkarea.c
+++ b/c/src/lib/libbsp/sparc/shared/startup/bspgetworkarea.c
@@ -20,9 +20,6 @@
/* Tells us where to put the workspace in case remote debugger is present. */
extern uint32_t rdb_start;
-/* Must be aligned to 8, _end is aligned to 8 */
-unsigned int early_mem = (unsigned int)&end;
-
/*
* This method returns the base address and size of the area which
* is to be allocated between the RTEMS Workspace and the C Program
@@ -34,10 +31,9 @@ void bsp_work_area_initialize(void)
#define STACK_SIZE (16 * 1024)
/* Early dynamic memory allocator is placed just above _end */
- void *work_area_start = (void *)early_mem;
+ void *work_area_start = (void *)&end;
uintptr_t work_area_size =
- (uintptr_t)rdb_start - (uintptr_t)early_mem - STACK_SIZE;
- early_mem = ~0; /* Signal bsp_early_malloc not to be used anymore */
+ (uintptr_t)rdb_start - (uintptr_t)&end - STACK_SIZE;
/*
* The following may be helpful in debugging what goes wrong when
diff --git a/c/src/lib/libbsp/sparc/shared/startup/early_malloc.c b/c/src/lib/libbsp/sparc/shared/startup/early_malloc.c
deleted file mode 100644
index 911a7b019b..0000000000
--- a/c/src/lib/libbsp/sparc/shared/startup/early_malloc.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Early dynamic memory allocation (not freeable) for BSP
- * boot routines. Minimum alignment 8 bytes. Memory is
- * allocated after _end, it will shrink the workspace.
- *
- * COPYRIGHT (c) 2011.
- * Aeroflex Gaisler AB
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <bsp.h>
-#include <stdlib.h>
-
-/* Tells us where to put the workspace in case remote debugger is present. */
-extern uint32_t rdb_start;
-
-/* Must be aligned to 8 */
-extern unsigned int early_mem;
-
-/* must be identical to STACK_SIZE in start.S */
-#define STACK_SIZE (16 * 1024)
-
-/* Allocate 8-byte aligned non-freeable pre-malloc() memory. The function
- * can be called at any time. The work-area will shrink when called before
- * bsp_work_area_initialize(). malloc() is called to get memory when this function
- * is called after bsp_work_area_initialize().
- */
-void *bsp_early_malloc(int size)
-{
- void *start;
-
- /* Not early anymore? */
- if (early_mem == ~0)
- return malloc(size);
-
- size = (size + 7) & ~0x7;
- if (rdb_start - STACK_SIZE - early_mem < size)
- return NULL;
-
- start = (void *)early_mem;
- early_mem += size;
-
- return start;
-}