aboutsummaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2022-09-16 15:09:41 +0000
committerWarner Losh <imp@FreeBSD.org>2023-01-24 21:49:35 +0000
commitf7f2e8226c52f2d38b09fc0a5b76c35c0f70b253 (patch)
tree4acced911de3beb2b1aab6a9b3d390305449f540 /stand
parent771751dc1591feb1369388561f473d032e475a1c (diff)
downloadsrc-f7f2e8226c52f2d38b09fc0a5b76c35c0f70b253.tar.gz
src-f7f2e8226c52f2d38b09fc0a5b76c35c0f70b253.zip
stand: Allocate bootinfo rather than have it be static
This saves 80 bytes (the new bootinfo structure was 84 bytes, and a pointer is 4 bytes). The bi_load32 code is the same size. Sponsored by: Netflix Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D36575 (cherry picked from commit 9758dd3de1cddc8271be8dd6fee69286c5c86535) stand: Pass in the proper size for bootinfo Missed one sizeof(bi) -> sizeof(*bi) in 9758dd3de1cdd conversion to allocating bootinfo. Noticed by: tijl@ Fixes: 9758dd3de1cdd Sponsored by: Netflix (cherry picked from commit 4a676571e382d0188b98134732f421df57a47a87)
Diffstat (limited to 'stand')
-rw-r--r--stand/i386/libi386/bootinfo32.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/stand/i386/libi386/bootinfo32.c b/stand/i386/libi386/bootinfo32.c
index 372bced917d6..169d2dfb81f4 100644
--- a/stand/i386/libi386/bootinfo32.c
+++ b/stand/i386/libi386/bootinfo32.c
@@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
#include "geliboot.h"
#endif
-static struct bootinfo bi;
+static struct bootinfo *bi;
/*
* Load the information expected by an i386 kernel.
@@ -91,11 +91,12 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t
/* XXX - use a default bootdev of 0. Is this ok??? */
bootdevnr = 0;
+ bi = calloc(sizeof(*bi), 1);
switch(rootdev->dd.d_dev->dv_type) {
case DEVT_CD:
case DEVT_DISK:
/* pass in the BIOS device number of the current disk */
- bi.bi_bios_dev = bd_unit2bios(rootdev);
+ bi->bi_bios_dev = bd_unit2bios(rootdev);
bootdevnr = bd_getdev(rootdev);
break;
@@ -172,22 +173,22 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t
/* legacy bootinfo structure */
kernelname = getenv("kernelname");
i386_getdev(NULL, kernelname, &kernelpath);
- bi.bi_version = BOOTINFO_VERSION;
- bi.bi_size = sizeof(bi);
- bi.bi_memsizes_valid = 1;
- bi.bi_basemem = bios_basemem / 1024;
- bi.bi_extmem = bios_extmem / 1024;
- bi.bi_envp = envp;
- bi.bi_modulep = *modulep;
- bi.bi_kernend = kernend;
- bi.bi_kernelname = VTOP(kernelpath);
- bi.bi_symtab = ssym; /* XXX this is only the primary kernel symtab */
- bi.bi_esymtab = esym;
+ bi->bi_version = BOOTINFO_VERSION;
+ bi->bi_size = sizeof(*bi);
+ bi->bi_memsizes_valid = 1;
+ bi->bi_basemem = bios_basemem / 1024;
+ bi->bi_extmem = bios_extmem / 1024;
+ bi->bi_envp = envp;
+ bi->bi_modulep = *modulep;
+ bi->bi_kernend = kernend;
+ bi->bi_kernelname = VTOP(kernelpath);
+ bi->bi_symtab = ssym; /* XXX this is only the primary kernel symtab */
+ bi->bi_esymtab = esym;
/* legacy boot arguments */
*howtop = howto | RB_BOOTINFO;
*bootdevp = bootdevnr;
- *bip = VTOP(&bi);
+ *bip = VTOP(bi);
return(0);
}