@@ -42,7 +42,9 @@ DICT = $(SLOFCMNDIR)/prim.in $(SLOFCMNDIR)/engine.in \
$(BOARD_SLOF_IN) $(SLOFCMNDIR)/$(TARG).in
# Source code files with automatic dependencies:
-SLOF_BUILD_SRCS = paflof.c helpers.c allocator.c
+SLOF_BUILD_SRCS = paflof.c helpers.c allocator.c sbrk.c
+
+SLOF_BUILD_OBJS = $(SLOF_BUILD_SRCS:%.c=%.o)
# Flags for pre-processing Forth code with CPP:
FPPFLAGS = -nostdinc -traditional-cpp -undef -P -C $(FLAG)
@@ -81,10 +83,10 @@ board.code:
echo > $@
endif
-paflof: $(SLOFCMNDIR)/OF.lds $(SLOFCMNDIR)/ofw.o paflof.o $(SLOFCMNDIR)/entry.o \
- helpers.o allocator.o romfs.o version.o OF.o nvramlog.o $(LLFWBRDDIR)/board_io.o \
+paflof: $(SLOFCMNDIR)/OF.lds $(SLOFCMNDIR)/ofw.o $(SLOFCMNDIR)/entry.o romfs.o \
+ $(SLOF_BUILD_OBJS) version.o OF.o nvramlog.o $(LLFWBRDDIR)/board_io.o \
$(LLFWBRDDIR)/io_generic_lib.o $(SLOF_LIBS)
- $(CC) -T$(SLOFCMNDIR)/OF.lds $(SLOFCMNDIR)/ofw.o version.o paflof.o helpers.o allocator.o \
+ $(CC) -T$(SLOFCMNDIR)/OF.lds $(SLOFCMNDIR)/ofw.o version.o $(SLOF_BUILD_OBJS) \
$(SLOFCMNDIR)/entry.o romfs.o OF.o nvramlog.o $(LLFWBRDDIR)/board_io.o \
$(LLFWBRDDIR)/io_generic_lib.o $(LDFLAGS) $(SLOF_LIBS) -o $@
#save a copy of paflof before stripping
@@ -100,6 +102,9 @@ helpers.o:
allocator.o:
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/allocator.c
+sbrk.o:
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/sbrk.c
+
$(SLOFCMNDIR)/xvect.bin: $(SLOFCMNDIR)/lowmem.o
$(CC) $(LDFLAGS) -Wl,--oformat,binary -Ttext=0x100 -o xvect.bin.tmp $<
dd if=xvect.bin.tmp of=$(SLOFCMNDIR)/xvect.bin bs=256 skip=1 2>/dev/null
new file mode 100644
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#include <unistd.h>
+
+#define HEAP_SIZE 0x200000
+
+
+static char heap[HEAP_SIZE];
+static char *actptr;
+
+void *sbrk(int increment)
+{
+ char *oldptr;
+
+ /* Called for the first time? Then init the actual pointer */
+ if (!actptr) {
+ actptr = heap;
+ }
+
+ if (actptr + increment > heap + HEAP_SIZE) {
+ /* Out of memory */
+ return (void *)-1;
+ }
+
+ oldptr = actptr;
+ actptr += increment;
+
+ return oldptr;
+}
sbrk() is needed for the malloc() implementation of our libc, so to be able to use malloc() from the Paflof code, we need to provide sbrk() here, too. Signed-off-by: Thomas Huth <thuth@redhat.com> --- slof/Makefile.inc | 13 +++++++++---- slof/sbrk.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 slof/sbrk.c