Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 May 2025 15:33:32 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 62d1ec7889a8 - main - stand/i386: Initialize archsw at compile time
Message-ID:  <202505261533.54QFXWEP045041@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=62d1ec7889a864a4c50f727f913384ea50e8a88e

commit 62d1ec7889a864a4c50f727f913384ea50e8a88e
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-05-25 15:17:53 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-05-26 15:30:37 +0000

    stand/i386: Initialize archsw at compile time
    
    No need to initialize this at runtime. This trades .bss space + code in
    .text for just .data and is net smaller by 4 bytes.
    
    Sponsored by:           Netflix
---
 stand/i386/loader/main.c | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/stand/i386/loader/main.c b/stand/i386/loader/main.c
index e7a42c194326..a7dfb2dde762 100644
--- a/stand/i386/loader/main.c
+++ b/stand/i386/loader/main.c
@@ -61,21 +61,35 @@ static uint32_t		initial_howto;
 static uint32_t		initial_bootdev;
 static struct bootinfo	*initial_bootinfo;
 
-struct arch_switch	archsw;		/* MI/MD interface boundary */
-
-static void		extract_currdev(void);
 static int		isa_inb(int port);
 static void		isa_outb(int port, int value);
+
+#ifdef LOADER_ZFS_SUPPORT
+struct zfs_boot_args	*zargs;
+static void		i386_zfs_probe(void);
+#endif
+
+struct arch_switch	archsw = {		/* MI/MD interface boundary */
+	.arch_autoload = i386_autoload,
+	.arch_getdev = i386_getdev,
+	.arch_copyin = i386_copyin,
+	.arch_copyout = i386_copyout,
+	.arch_readin = i386_readin,
+	.arch_isainb = isa_inb,
+	.arch_isaoutb = isa_outb,
+	.arch_hypervisor = x86_hypervisor,
+#ifdef LOADER_ZFS_SUPPORT
+	.arch_zfs_probe = i386_zfs_probe,
+#endif
+};
+
+static void		extract_currdev(void);
 void			exit(int code);
 #ifdef LOADER_GELI_SUPPORT
 #include "geliboot.h"
 struct geli_boot_args	*gargs;
 struct geli_boot_data	*gbdata;
 #endif
-#ifdef LOADER_ZFS_SUPPORT
-struct zfs_boot_args	*zargs;
-static void		i386_zfs_probe(void);
-#endif
 
 /* XXX debugging */
 extern char end[];
@@ -182,17 +196,7 @@ main(void)
 			bc_add(initial_bootdev);
 	}
 
-	archsw.arch_autoload = i386_autoload;
-	archsw.arch_getdev = i386_getdev;
-	archsw.arch_copyin = i386_copyin;
-	archsw.arch_copyout = i386_copyout;
-	archsw.arch_readin = i386_readin;
-	archsw.arch_isainb = isa_inb;
-	archsw.arch_isaoutb = isa_outb;
-	archsw.arch_hypervisor = x86_hypervisor;
 #ifdef LOADER_ZFS_SUPPORT
-	archsw.arch_zfs_probe = i386_zfs_probe;
-
 	/*
 	 * zfsboot and gptzfsboot have always passed KARGS_FLAGS_ZFS,
 	 * so if that is set along with KARGS_FLAGS_EXTARG we know we



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505261533.54QFXWEP045041>