loader: Simplify build a little

Confine -DDISK_DEBUG to biosdisc.c, the only file it affects.
Use modern variable arrays instead of alloca and add a sanity
size minimum for biospnp nodes. These nodes are tiny enough that
we needn't do a malloc/free pair: the stack is fine.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D43914
This commit is contained in:
Warner Losh 2024-02-15 20:55:05 -07:00
parent e34fd722ca
commit 588ff0748f
2 changed files with 4 additions and 7 deletions

View file

@ -23,7 +23,7 @@ CFLAGS+= -DCOMSPEED=${BOOT_COMCONSOLE_SPEED}
.ifdef(BOOT_BIOSDISK_DEBUG)
# Make the disk code more talkative
CFLAGS+= -DDISK_DEBUG
CFLAGS.biosdisk.c+= -DDISK_DEBUG
.endif
# terminal emulation
@ -35,11 +35,7 @@ CFLAGS.teken.c+= -I${SRCTOP}/sys/teken
CFLAGS.bootinfo.c+= -I${SRCTOP}/sys/teken -I${SRCTOP}/contrib/pnglite
CFLAGS.vbe.c+= -I${SRCTOP}/sys/teken -I${SRCTOP}/contrib/pnglite
# XXX: make alloca() useable
CFLAGS+= -Dalloca=__builtin_alloca
CFLAGS+= -I${BOOTSRC}/ficl -I${BOOTSRC}/ficl/i386 \
-I${LDRSRC} -I${BOOTSRC}/i386/common \
CFLAGS+= -I${LDRSRC} -I${BOOTSRC}/i386/common \
-I${SYSDIR}/contrib/dev/acpica/include
# Handle FreeBSD specific %b and %D printf format specifiers

View file

@ -155,6 +155,7 @@ biospnp_enumerate(void)
{
uint8_t Node;
struct pnp_devNode *devNodeBuffer;
uint8_t buffer[max(pnp_NodeSize, sizeof(*devNodeBuffer))];
int result;
struct pnpinfo *pi;
int count;
@ -163,7 +164,7 @@ biospnp_enumerate(void)
if (biospnp_init())
return;
devNodeBuffer = (struct pnp_devNode *)alloca(pnp_NodeSize);
devNodeBuffer = (struct pnp_devNode *)buffer;
Node = 0;
count = 1000;
while((Node != 0xff) && (count-- > 0)) {