paflof: Copy sbrk code from net-snk
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> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
This commit is contained in:
parent
4885692898
commit
9cb2fb0cd9
|
@ -42,7 +42,9 @@ DICT = $(SLOFCMNDIR)/prim.in $(SLOFCMNDIR)/engine.in \
|
||||||
$(BOARD_SLOF_IN) $(SLOFCMNDIR)/$(TARG).in
|
$(BOARD_SLOF_IN) $(SLOFCMNDIR)/$(TARG).in
|
||||||
|
|
||||||
# Source code files with automatic dependencies:
|
# 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:
|
# Flags for pre-processing Forth code with CPP:
|
||||||
FPPFLAGS = -nostdinc -traditional-cpp -undef -P -C $(FLAG)
|
FPPFLAGS = -nostdinc -traditional-cpp -undef -P -C $(FLAG)
|
||||||
|
@ -81,10 +83,10 @@ board.code:
|
||||||
echo > $@
|
echo > $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
paflof: $(SLOFCMNDIR)/OF.lds $(SLOFCMNDIR)/ofw.o paflof.o $(SLOFCMNDIR)/entry.o \
|
paflof: $(SLOFCMNDIR)/OF.lds $(SLOFCMNDIR)/ofw.o $(SLOFCMNDIR)/entry.o romfs.o \
|
||||||
helpers.o allocator.o romfs.o version.o OF.o nvramlog.o $(LLFWBRDDIR)/board_io.o \
|
$(SLOF_BUILD_OBJS) version.o OF.o nvramlog.o $(LLFWBRDDIR)/board_io.o \
|
||||||
$(LLFWBRDDIR)/io_generic_lib.o $(SLOF_LIBS)
|
$(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 \
|
$(SLOFCMNDIR)/entry.o romfs.o OF.o nvramlog.o $(LLFWBRDDIR)/board_io.o \
|
||||||
$(LLFWBRDDIR)/io_generic_lib.o $(LDFLAGS) $(SLOF_LIBS) -o $@
|
$(LLFWBRDDIR)/io_generic_lib.o $(LDFLAGS) $(SLOF_LIBS) -o $@
|
||||||
#save a copy of paflof before stripping
|
#save a copy of paflof before stripping
|
||||||
|
@ -100,6 +102,9 @@ helpers.o:
|
||||||
allocator.o:
|
allocator.o:
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/allocator.c
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/allocator.c
|
||||||
|
|
||||||
|
sbrk.o:
|
||||||
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/sbrk.c
|
||||||
|
|
||||||
$(SLOFCMNDIR)/xvect.bin: $(SLOFCMNDIR)/lowmem.o
|
$(SLOFCMNDIR)/xvect.bin: $(SLOFCMNDIR)/lowmem.o
|
||||||
$(CC) $(LDFLAGS) -Wl,--oformat,binary -Ttext=0x100 -o xvect.bin.tmp $<
|
$(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
|
dd if=xvect.bin.tmp of=$(SLOFCMNDIR)/xvect.bin bs=256 skip=1 2>/dev/null
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue