Module Name: src Committed By: uwe Date: Wed Jun 6 22:56:25 UTC 2018
Modified Files: src/sys/arch/macppc/stand/ofwboot: Locore.c Makefile boot.c Log Message: Provide an option to use libsa allocator. Not yet enabled. Same binary code is generated. To enable uncomment -DHEAP_VARIABLE and comment out alloc.c in the makefile. PR port-macppc/44895 To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/arch/macppc/stand/ofwboot/Locore.c cvs rdiff -u -r1.58 -r1.59 src/sys/arch/macppc/stand/ofwboot/Makefile cvs rdiff -u -r1.28 -r1.29 src/sys/arch/macppc/stand/ofwboot/boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/macppc/stand/ofwboot/Locore.c diff -u src/sys/arch/macppc/stand/ofwboot/Locore.c:1.29 src/sys/arch/macppc/stand/ofwboot/Locore.c:1.30 --- src/sys/arch/macppc/stand/ofwboot/Locore.c:1.29 Fri Apr 22 18:25:41 2016 +++ src/sys/arch/macppc/stand/ofwboot/Locore.c Wed Jun 6 22:56:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: Locore.c,v 1.29 2016/04/22 18:25:41 christos Exp $ */ +/* $NetBSD: Locore.c,v 1.30 2018/06/06 22:56:25 uwe Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -31,6 +31,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/param.h> #include <lib/libsa/stand.h> #include <machine/cpu.h> @@ -43,6 +44,13 @@ static void startup(void *, int, int (*) __attribute__((__used__)); static void setup(void); +#ifdef HEAP_VARIABLE +#ifndef HEAP_SIZE +#define HEAP_SIZE 0x20000 +#endif +char *heapspace; +#endif + static int stack[8192/4 + 4] __attribute__((__used__)); #ifdef XCOFF_GLUE @@ -621,6 +629,15 @@ setup(void) OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) != sizeof(stdout)) OF_exit(); + +#ifdef HEAP_VARIABLE + heapspace = OF_claim(0, HEAP_SIZE, NBPG); + if (heapspace == (char *)-1) { + panic("Failed to allocate heap"); + } + + setheap(heapspace, heapspace + HEAP_SIZE); +#endif /* HEAP_VARIABLE */ } void Index: src/sys/arch/macppc/stand/ofwboot/Makefile diff -u src/sys/arch/macppc/stand/ofwboot/Makefile:1.58 src/sys/arch/macppc/stand/ofwboot/Makefile:1.59 --- src/sys/arch/macppc/stand/ofwboot/Makefile:1.58 Thu Apr 20 19:09:29 2017 +++ src/sys/arch/macppc/stand/ofwboot/Makefile Wed Jun 6 22:56:25 2018 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.58 2017/04/20 19:09:29 uwe Exp $ +# $NetBSD: Makefile,v 1.59 2018/06/06 22:56:25 uwe Exp $ S= ${.CURDIR}/../../../.. PROG= ofwboot FILES= ${PROG}.elf ${PROG}.xcf -SRCS= Locore.c boot.c ofdev.c hfs.c net.c netif_of.c alloc.c +SRCS= Locore.c boot.c ofdev.c hfs.c net.c netif_of.c XCOFFXTRA= Xcoffxtra.c XCOFFXTRAOBJ= Xcoffxtra.o CFLAGS+= -ffreestanding @@ -16,6 +16,10 @@ CPPFLAGS+= -D_STANDALONE -DSUPPORT_DHCP CPPFLAGS+= -DSUPPORT_USTARFS -DHAVE_CHANGEDISK_HOOK DBG= -Os +# PR port-macppc/44895 +SRCS+= alloc.c # use ./alloc.c +#CPPFLAGS+= -DHEAP_VARIABLE # use libsa alloc.c + LIBCRT0= # nothing LIBCRTI= # nothing LIBCRTBEGIN= # nothing Index: src/sys/arch/macppc/stand/ofwboot/boot.c diff -u src/sys/arch/macppc/stand/ofwboot/boot.c:1.28 src/sys/arch/macppc/stand/ofwboot/boot.c:1.29 --- src/sys/arch/macppc/stand/ofwboot/boot.c:1.28 Sat Jun 11 06:32:45 2016 +++ src/sys/arch/macppc/stand/ofwboot/boot.c Wed Jun 6 22:56:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.28 2016/06/11 06:32:45 dholland Exp $ */ +/* $NetBSD: boot.c,v 1.29 2018/06/06 22:56:25 uwe Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -181,7 +181,9 @@ chain(boot_entry_t entry, char *args, vo extern char end[]; int l; +#if !defined(HEAP_VARIABLE) freeall(); +#endif /* * Stash pointer to end of symbol table after the argument