Add BOOT_LEAVE_MEMORY (desired memory left unused) and BOOT_MIN_AVAIL_MEMORY

(minimum desired free memory), default them to 5M and 10M respectively.
On a machine with more than (BOOT_LEAVE_MEMORY + BOOT_MIN_AVAIL_MEMORY) free
BOOT_LEAVE_MEMORY will be left unused.
Allows a kernel to be booted from SparkFS on a machine with more than 15M
of free memory (SparkFS needs to be able to allocate memory for the
uncompressed kernel)
This commit is contained in:
abs 2004-06-13 20:50:14 +00:00
parent cc333b3dd7
commit 681718e784
1 changed files with 22 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: srt0.S,v 1.2 2004/05/18 23:29:30 gavan Exp $ */
/* $NetBSD: srt0.S,v 1.3 2004/06/13 20:50:14 abs Exp $ */
/*-
* Copyright (c) 2001 Ben Harris
@ -33,6 +33,23 @@
* (see srt1.c)
*/
/* Minimum desired free memory */
#ifndef BOOT_MIN_AVAIL_MEMORY
#define BOOT_MIN_AVAIL_MEMORY 10 * 1024 * 1024
#endif
/* If enough above BOOT_MIN_AVAIL_MEMORY, leave BOOT_LEAVE_MEMORY unused */
/* Avoids sparkfs failing on memory if we try to read a kernel from it */
#ifndef BOOT_LEAVE_MEMORY
#define BOOT_LEAVE_MEMORY 5 * 1024 * 1024
#endif
/*
* Both BOOT_LEAVE_MEMORY and BOOT_MIN_AVAIL_MEMORY + BOOT_LEAVE_MEMORY
* must fit into an immediate ATM constant - 8 bits with arbitrary rotation
*/
#include <machine/asm.h>
#include <riscoscalls.h>
@ -43,6 +60,10 @@ ENTRY(_start)
mvn r1, #0
swi Wimp_SlotSize
add r0, r0, r2
#if (BOOT_LEAVE_MEMORY > 0)
cmp r0, #BOOT_MIN_AVAIL_MEMORY + BOOT_LEAVE_MEMORY
subhi r0, r0, #BOOT_LEAVE_MEMORY
#endif
mvn r1, #0
swi Wimp_SlotSize
#endif