diff options
Diffstat (limited to 'stand')
708 files changed, 7652 insertions, 6100 deletions
diff --git a/stand/Makefile b/stand/Makefile index 1597f6832c07..6d0d7a09672a 100644 --- a/stand/Makefile +++ b/stand/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <src.opts.mk> @@ -94,3 +93,8 @@ SUBDIR_DEPEND_uboot+= fdt SUBDIR_PARALLEL= yes .include <bsd.subdir.mk> + +# Simplified way to build-test the most important build combinations for the +# loader. +universe: + sh ${SRCTOP}/tools/boot/universe.sh diff --git a/stand/Makefile.amd64 b/stand/Makefile.amd64 index 9ee3649071b2..82b3f0def223 100644 --- a/stand/Makefile.amd64 +++ b/stand/Makefile.amd64 @@ -1,4 +1,3 @@ -# $FreeBSD$ S.yes+= userboot S.yes+= i386 diff --git a/stand/Makefile.inc b/stand/Makefile.inc index aa7cfa14542f..13b3f2a1f418 100644 --- a/stand/Makefile.inc +++ b/stand/Makefile.inc @@ -1,4 +1,3 @@ -# $FreeBSD$ SUBDIR_PARALLEL= yes diff --git a/stand/arm64/Makefile b/stand/arm64/Makefile index d4c9667d6b13..c378e5b10dfe 100644 --- a/stand/arm64/Makefile +++ b/stand/arm64/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ NO_OBJ=t diff --git a/stand/arm64/libarm64/cache.c b/stand/arm64/libarm64/cache.c index 105e08cb4257..291b55f3b250 100644 --- a/stand/arm64/libarm64/cache.c +++ b/stand/arm64/libarm64/cache.c @@ -1,6 +1,5 @@ /*- * Copyright (c) 2014 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Semihalf under * the sponsorship of the FreeBSD Foundation. @@ -27,15 +26,12 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <machine/armreg.h> #include <machine/atomic.h> #include <stand.h> -#include <efi.h> #include "bootstrap.h" #include "cache.h" diff --git a/stand/arm64/libarm64/cache.h b/stand/arm64/libarm64/cache.h index 5e560c4d578d..76e641b8115a 100644 --- a/stand/arm64/libarm64/cache.h +++ b/stand/arm64/libarm64/cache.h @@ -1,6 +1,5 @@ /*- * Copyright (c) 2014 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Semihalf under * the sponsorship of the FreeBSD Foundation. @@ -24,8 +23,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _CACHE_H_ diff --git a/stand/common/Makefile.depend b/stand/common/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/common/Makefile.depend +++ b/stand/common/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/common/bcache.c b/stand/common/bcache.c index 88dee8c7ce2d..2b4603525740 100644 --- a/stand/common/bcache.c +++ b/stand/common/bcache.c @@ -27,8 +27,6 @@ #include <sys/cdefs.h> #include <sys/param.h> -__FBSDID("$FreeBSD$"); - /* * Simple hashed block cache */ diff --git a/stand/common/boot.c b/stand/common/boot.c index 06f604f595df..db4bb4fc2ea8 100644 --- a/stand/common/boot.c +++ b/stand/common/boot.c @@ -25,15 +25,14 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Loading modules, booting the system */ #include <stand.h> -#include <sys/reboot.h> #include <sys/boot.h> +#include <sys/kenv.h> +#include <sys/reboot.h> #include <string.h> #include "bootstrap.h" @@ -321,14 +320,14 @@ getbootfile(int try) int getrootmount(char *rootdev) { - char lbuf[128], *cp, *ep, *dev, *fstyp, *options; + char lbuf[KENV_MVALLEN], *cp, *ep, *dev, *fstyp, *options; int fd, error; if (getenv("vfs.root.mountfrom") != NULL) return(0); error = 1; - sprintf(lbuf, "%s/etc/fstab", rootdev); + snprintf(lbuf, sizeof(lbuf), "%s/etc/fstab", rootdev); if ((fd = open(lbuf, O_RDONLY)) < 0) goto notfound; @@ -382,7 +381,7 @@ getrootmount(char *rootdev) *cp = 0; options = strdup(ep); /* Build the <fstype>:<device> and save it in vfs.root.mountfrom */ - sprintf(lbuf, "%s:%s", fstyp, dev); + snprintf(lbuf, sizeof(lbuf), "%s:%s", fstyp, dev); setenv("vfs.root.mountfrom", lbuf, 0); /* Don't override vfs.root.mountfrom.options if it is already set */ diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index 9c62a49b0da7..7387569ad65a 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _BOOTSTRAP_H_ @@ -52,6 +50,7 @@ extern char command_errbuf[COMMAND_ERRBUFSZ]; void interact(void); void interp_emit_prompt(void); int interp_builtin_cmd(int argc, char *argv[]); +bool interp_has_builtin_cmd(const char *cmd); /* Called by interp.c for interp_*.c embedded interpreters */ int interp_include(const char *); /* Execute commands from filename */ @@ -181,6 +180,7 @@ extern int isapnp_readport; * Version information */ extern char bootprog_info[]; +extern unsigned bootprog_rev; /* * Interpreter information @@ -200,6 +200,7 @@ struct file_metadata { size_t md_size; uint16_t md_type; + vm_offset_t md_addr; /* Valid after copied to kernel space */ struct file_metadata *md_next; char md_data[1]; /* data are immediately appended */ }; @@ -370,50 +371,16 @@ struct arch_switch /* Return the hypervisor name/type or NULL if not virtualized. */ const char *(*arch_hypervisor)(void); - - /* For kexec-type loaders, get ksegment structure */ - void (*arch_kexec_kseg_get)(int *nseg, void **kseg); }; extern struct arch_switch archsw; /* This must be provided by the MD code, but should it be in the archsw? */ void delay(int delay); -void dev_cleanup(void); - -/* - * nvstore API. - */ -typedef int (nvstore_getter_cb_t)(void *, const char *, void **); -typedef int (nvstore_setter_cb_t)(void *, int, const char *, - const void *, size_t); -typedef int (nvstore_setter_str_cb_t)(void *, const char *, const char *, - const char *); -typedef int (nvstore_unset_cb_t)(void *, const char *); -typedef int (nvstore_print_cb_t)(void *, void *); -typedef int (nvstore_iterate_cb_t)(void *, int (*)(void *, void *)); - -typedef struct nvs_callbacks { - nvstore_getter_cb_t *nvs_getter; - nvstore_setter_cb_t *nvs_setter; - nvstore_setter_str_cb_t *nvs_setter_str; - nvstore_unset_cb_t *nvs_unset; - nvstore_print_cb_t *nvs_print; - nvstore_iterate_cb_t *nvs_iterate; -} nvs_callbacks_t; - -int nvstore_init(const char *, nvs_callbacks_t *, void *); -int nvstore_fini(const char *); -void *nvstore_get_store(const char *); -int nvstore_print(void *); -int nvstore_get_var(void *, const char *, void **); -int nvstore_set_var(void *, int, const char *, void *, size_t); -int nvstore_set_var_from_string(void *, const char *, const char *, - const char *); -int nvstore_unset_var(void *, const char *); - /* common code to set currdev variable. */ -extern int mount_currdev(struct env_var *, int, const void *); +int gen_setcurrdev(struct env_var *ev, int flags, const void *value); +int mount_currdev(struct env_var *, int, const void *); +void set_currdev(const char *devname); #ifndef CTASSERT #define CTASSERT(x) _Static_assert(x, "compile-time assertion failed") diff --git a/stand/common/commands.c b/stand/common/commands.c index 0d21ed44c681..b09bb9604386 100644 --- a/stand/common/commands.c +++ b/stand/common/commands.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> @@ -123,7 +121,6 @@ help_emitsummary(char *topic, char *subtopic, char *desc) return (pager_output("\n")); } - static int command_help(int argc, char *argv[]) { @@ -132,7 +129,8 @@ command_help(int argc, char *argv[]) char *topic, *subtopic, *t, *s, *d; /* page the help text from our load path */ - snprintf(buf, sizeof(buf), "%s/boot/loader.help", getenv("loaddev")); + snprintf(buf, sizeof(buf), "%s/boot/%s", getenv("loaddev"), + HELP_FILENAME); if ((hfd = open(buf, O_RDONLY)) < 0) { printf("Verbose help not available, " "use '?' to list commands\n"); @@ -576,3 +574,12 @@ command_readtest(int argc, char *argv[]) } COMMAND_SET(readtest, "readtest", "Time a file read", command_readtest); + +static int +command_quit(int argc, char *argv[]) +{ + exit(0); + return (CMD_OK); +} + +COMMAND_SET(quit, "quit", "exit the loader", command_quit); diff --git a/stand/common/console.c b/stand/common/console.c index 0e8afb477ee8..d9d075ef7bde 100644 --- a/stand/common/console.c +++ b/stand/common/console.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <stand.h> #include <string.h> @@ -238,7 +236,7 @@ cons_check(const char *string) if (*curpos != '\0') { cons = cons_find(curpos); if (cons == -1) { - printf("console %s is invalid!\n", curpos); + printf("console %s is unavailable\n", curpos); failed++; } else { found++; @@ -251,7 +249,7 @@ cons_check(const char *string) if (found == 0) printf("no valid consoles!\n"); - if (found == 0 || failed != 0) { + if (found == 0 && failed != 0) { printf("Available consoles:\n"); for (cons = 0; consoles[cons] != NULL; cons++) printf(" %s\n", consoles[cons]->c_name); diff --git a/stand/common/dev_net.c b/stand/common/dev_net.c index 70b571047d56..b6880e894477 100644 --- a/stand/common/dev_net.c +++ b/stand/common/dev_net.c @@ -30,8 +30,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /*- * This module implements a "raw device" interface suitable for * use by the stand-alone I/O library NFS code. This interface @@ -86,15 +84,15 @@ static int net_print(int); static int net_getparams(int sock); struct devsw netdev = { - "net", - DEVT_NET, - net_init, - net_strategy, - net_open, - net_close, - noioctl, - net_print, - net_cleanup + .dv_name = "net", + .dv_type = DEVT_NET, + .dv_init = net_init, + .dv_strategy = net_strategy, + .dv_open = net_open, + .dv_close = net_close, + .dv_ioctl = noioctl, + .dv_print = net_print, + .dv_cleanup = net_cleanup, }; static struct uri_scheme { diff --git a/stand/common/dev_net.h b/stand/common/dev_net.h index 995b67241de8..189508854dc5 100644 --- a/stand/common/dev_net.h +++ b/stand/common/dev_net.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _BOOT_DEV_NET_H_ diff --git a/stand/common/devopen.c b/stand/common/devopen.c index 8fd2c1796555..a51ebaf0c9d7 100644 --- a/stand/common/devopen.c +++ b/stand/common/devopen.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> @@ -63,9 +61,7 @@ devopen(struct open_file *f, const char *fname, const char **file) * pw if needed), this will attach the geli code to the open_file by * replacing f->f_dev and f_devdata with pointers to a geli_devdesc. */ - if (f->f_dev->dv_type == DEVT_DISK) { - geli_probe_and_attach(f); - } + geli_probe_and_attach(f); #endif return (0); diff --git a/stand/common/disk.c b/stand/common/disk.c index 733b7b0d57e7..e1add50bd1fb 100644 --- a/stand/common/disk.c +++ b/stand/common/disk.c @@ -26,14 +26,13 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/disk.h> #include <sys/queue.h> #include <stand.h> #include <stdarg.h> #include <bootstrap.h> #include <part.h> +#include <assert.h> #include "disk.h" @@ -385,12 +384,14 @@ disk_close(struct disk_devdesc *dev) return (0); } -char* -disk_fmtdev(struct disk_devdesc *dev) +char * +disk_fmtdev(struct devdesc *vdev) { + struct disk_devdesc *dev = (struct disk_devdesc *)vdev; static char buf[128]; char *cp; + assert(vdev->d_dev->dv_type == DEVT_DISK); cp = buf + sprintf(buf, "%s%d", dev->dd.d_dev->dv_name, dev->dd.d_unit); if (dev->d_slice > D_SLICENONE) { #ifdef LOADER_GPT_SUPPORT @@ -410,13 +411,14 @@ disk_fmtdev(struct disk_devdesc *dev) } int -disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path) +disk_parsedev(struct devdesc **idev, const char *devspec, const char **path) { int unit, slice, partition; const char *np; char *cp; + struct disk_devdesc *dev; - np = devspec; + np = devspec + 4; /* Skip the leading 'disk' */ unit = -1; /* * If there is path/file info after the device info, then any missing @@ -467,9 +469,13 @@ disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path) if (*cp != '\0' && *cp != ':') return (EINVAL); + dev = malloc(sizeof(*dev)); + if (dev == NULL) + return (ENOMEM); dev->dd.d_unit = unit; dev->d_slice = slice; dev->d_partition = partition; + *idev = &dev->dd; if (path != NULL) *path = (*cp == '\0') ? cp: cp + 1; return (0); diff --git a/stand/common/disk.h b/stand/common/disk.h index 83109981e0a8..fa47ceaed6bd 100644 --- a/stand/common/disk.h +++ b/stand/common/disk.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ /* @@ -97,11 +95,6 @@ struct disk_devdesc { uint64_t d_offset; }; -enum disk_ioctl { - IOCTL_GET_BLOCKS, - IOCTL_GET_BLOCK_SIZE -}; - /* * Parse disk metadata and initialise dev->d_offset. */ @@ -116,7 +109,8 @@ extern int ptblread(void *, void *, size_t, uint64_t); * Print information about slices on a disk. */ extern int disk_print(struct disk_devdesc *, char *, int); -extern char* disk_fmtdev(struct disk_devdesc *); -extern int disk_parsedev(struct disk_devdesc *, const char *, const char **); +extern int disk_parsedev(struct devdesc **, const char *, const char **); + +char *disk_fmtdev(struct devdesc *vdev); #endif /* _DISK_H */ diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index b80e9c565944..27ac66f259b1 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ /* @@ -1190,7 +1188,7 @@ gfx_fb_copy_line(teken_gfx_t *state, int ncol, teken_pos_t *s, teken_pos_t *d) screen_buffer[doffset + x] = screen_buffer[soffset + x]; if (mark) { /* update end point */ - sr.tr_end.tp_col = s->tp_col + x;; + sr.tr_end.tp_col = s->tp_col + x; } else { /* set up new rectangle */ mark = true; diff --git a/stand/common/gfx_fb.h b/stand/common/gfx_fb.h index f5747e065daf..adb60c673ea9 100644 --- a/stand/common/gfx_fb.h +++ b/stand/common/gfx_fb.h @@ -24,8 +24,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _GFX_FB_H diff --git a/stand/common/gfx_fb_stub.c b/stand/common/gfx_fb_stub.c index e212bd2daa12..a4ebdeb8c388 100644 --- a/stand/common/gfx_fb_stub.c +++ b/stand/common/gfx_fb_stub.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Generic gfx stubs. */ diff --git a/stand/common/install.c b/stand/common/install.c index ea6eaaa7cebc..418799822e4e 100644 --- a/stand/common/install.c +++ b/stand/common/install.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> #include <net/if.h> diff --git a/stand/common/interp.c b/stand/common/interp.c index ab68694d61b7..b71e0858e702 100644 --- a/stand/common/interp.c +++ b/stand/common/interp.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Simple commandline interpreter, toplevel and misc. * @@ -39,6 +37,8 @@ __FBSDID("$FreeBSD$"); #define MAXARGS 20 /* maximum number of arguments allowed */ +const char * volatile interp_identifier; + /* * Interactive mode */ @@ -46,7 +46,6 @@ void interact(void) { static char input[256]; /* big enough? */ - const char * volatile interp_identifier; TSENTER(); @@ -151,6 +150,19 @@ interp_emit_prompt(void) free(pr); } +static struct bootblk_command * +interp_lookup_cmd(const char *cmd) +{ + struct bootblk_command **cmdp; + + /* search the command set for the command */ + SET_FOREACH(cmdp, Xcommand_set) { + if (((*cmdp)->c_name != NULL) && !strcmp(cmd, (*cmdp)->c_name)) + return (*cmdp); + } + return (NULL); +} + /* * Perform a builtin command */ @@ -158,27 +170,30 @@ int interp_builtin_cmd(int argc, char *argv[]) { int result; - struct bootblk_command **cmdp; - bootblk_cmd_t *cmd; + struct bootblk_command *cmd; if (argc < 1) - return(CMD_OK); + return (CMD_OK); /* set return defaults; a successful command will override these */ command_errmsg = command_errbuf; strcpy(command_errbuf, "no error message"); - cmd = NULL; result = CMD_ERROR; - /* search the command set for the command */ - SET_FOREACH(cmdp, Xcommand_set) { - if (((*cmdp)->c_name != NULL) && !strcmp(argv[0], (*cmdp)->c_name)) - cmd = (*cmdp)->c_fn; - } - if (cmd != NULL) { - result = (cmd)(argc, argv); + cmd = interp_lookup_cmd(argv[0]); + if (cmd != NULL && cmd->c_fn) { + result = cmd->c_fn(argc, argv); } else { command_errmsg = "unknown command"; } - return(result); + return (result); +} + +/* + * Return true if the builtin command exists + */ +bool +interp_has_builtin_cmd(const char *cmd) +{ + return (interp_lookup_cmd(cmd) != NULL); } diff --git a/stand/common/interp_backslash.c b/stand/common/interp_backslash.c index c75081beca56..6d650cd2e286 100644 --- a/stand/common/interp_backslash.c +++ b/stand/common/interp_backslash.c @@ -15,8 +15,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> #include "bootstrap.h" diff --git a/stand/common/interp_forth.c b/stand/common/interp_forth.c index 19f1c75dc191..0320e081d406 100644 --- a/stand/common/interp_forth.c +++ b/stand/common/interp_forth.c @@ -25,15 +25,12 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> /* to pick up __FreeBSD_version */ #include <string.h> #include <stand.h> #include "bootstrap.h" #include "ficl.h" -extern unsigned bootprog_rev; INTERP_DEFINE("4th"); /* #define BFORTH_DEBUG */ diff --git a/stand/common/interp_lua.c b/stand/common/interp_lua.c index 8a420660683e..db58d80b2048 100644 --- a/stand/common/interp_lua.c +++ b/stand/common/interp_lua.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include "bootstrap.h" diff --git a/stand/common/interp_parse.c b/stand/common/interp_parse.c index c46a497e240d..6e883a81e383 100644 --- a/stand/common/interp_parse.c +++ b/stand/common/interp_parse.c @@ -15,8 +15,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> #include "bootstrap.h" diff --git a/stand/common/interp_simple.c b/stand/common/interp_simple.c index e25743d4f01c..fa021c796308 100644 --- a/stand/common/interp_simple.c +++ b/stand/common/interp_simple.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Simple commandline interpreter, toplevel and misc. */ diff --git a/stand/common/isapnp.c b/stand/common/isapnp.c index 8a0cdfda2ace..3f554305c2e2 100644 --- a/stand/common/isapnp.c +++ b/stand/common/isapnp.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Machine-independent ISA PnP enumerator implementing a subset of the * ISA PnP specification. diff --git a/stand/common/isapnp.h b/stand/common/isapnp.h index a5b8f28304f7..e0bdb97dc048 100644 --- a/stand/common/isapnp.h +++ b/stand/common/isapnp.h @@ -28,8 +28,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _I386_ISA_PNP_H_ diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index fd9985f51bf9..9f3b015fef7e 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/endian.h> #include <sys/exec.h> @@ -98,6 +96,7 @@ const char *__elfN(moduletype) = "elf module"; uint64_t __elfN(relocation_offset) = 0; +#ifdef __powerpc__ extern void elf_wrong_field_size(void); #define CONVERT_FIELD(b, f, e) \ switch (sizeof((b)->f)) { \ @@ -203,7 +202,22 @@ static int elf_section_header_convert(const Elf_Ehdr *ehdr, Elf_Shdr *shdr) } #undef CONVERT_SWITCH #undef CONVERT_FIELD +#else +static int elf_header_convert(Elf_Ehdr *ehdr) +{ + return (0); +} +static int elf_program_header_convert(const Elf_Ehdr *ehdr, Elf_Phdr *phdr) +{ + return (0); +} + +static int elf_section_header_convert(const Elf_Ehdr *ehdr, Elf_Shdr *shdr) +{ + return (0); +} +#endif #ifdef __amd64__ static bool @@ -1246,9 +1260,8 @@ __elfN(lookup_symbol)(elf_file_t ef, const char* name, Elf_Sym *symp, strp = strdupout((vm_offset_t)(ef->strtab + sym.st_name)); if (strcmp(name, strp) == 0) { free(strp); - if (sym.st_shndx != SHN_UNDEF || - (sym.st_value != 0 && - ELF_ST_TYPE(sym.st_info) == type)) { + if (sym.st_shndx != SHN_UNDEF && sym.st_value != 0 && + ELF_ST_TYPE(sym.st_info) == type) { *symp = sym; return 0; } diff --git a/stand/common/load_elf32.c b/stand/common/load_elf32.c index 0c9f460d4863..5b942fd63444 100644 --- a/stand/common/load_elf32.c +++ b/stand/common/load_elf32.c @@ -1,6 +1,4 @@ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 32 #define _MACHINE_ELF_WANT_32BIT diff --git a/stand/common/load_elf32_obj.c b/stand/common/load_elf32_obj.c index 94b089618836..dffb0070b0c0 100644 --- a/stand/common/load_elf32_obj.c +++ b/stand/common/load_elf32_obj.c @@ -1,6 +1,4 @@ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 32 #define _MACHINE_ELF_WANT_32BIT diff --git a/stand/common/load_elf64.c b/stand/common/load_elf64.c index c29e8e3596a7..e3a913c0ce8c 100644 --- a/stand/common/load_elf64.c +++ b/stand/common/load_elf64.c @@ -1,6 +1,4 @@ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 64 #include "load_elf.c" diff --git a/stand/common/load_elf64_obj.c b/stand/common/load_elf64_obj.c index 3c9371ba0130..14d6e3dc3d4d 100644 --- a/stand/common/load_elf64_obj.c +++ b/stand/common/load_elf64_obj.c @@ -1,6 +1,4 @@ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 64 #include "load_elf_obj.c" diff --git a/stand/common/load_elf_obj.c b/stand/common/load_elf_obj.c index ed202e08b780..86e0fb2b5d22 100644 --- a/stand/common/load_elf_obj.c +++ b/stand/common/load_elf_obj.c @@ -27,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/exec.h> #include <sys/linker.h> diff --git a/stand/common/ls.c b/stand/common/ls.c index cd6b7c49ea5f..daeecfa488da 100644 --- a/stand/common/ls.c +++ b/stand/common/ls.c @@ -38,8 +38,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <ufs/ufs/dinode.h> #include <ufs/ufs/dir.h> diff --git a/stand/common/md.c b/stand/common/md.c index 5585218b3276..6b6e6303c898 100644 --- a/stand/common/md.c +++ b/stand/common/md.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/param.h> #include <sys/endian.h> @@ -66,15 +64,15 @@ static int md_close(struct open_file *); static int md_print(int); struct devsw md_dev = { - "md", - DEVT_DISK, - md_init, - md_strategy, - md_open, - md_close, - noioctl, - md_print, - NULL + .dv_name = "md", + .dv_type = DEVT_DISK, + .dv_init = md_init, + .dv_strategy = md_strategy, + .dv_open = md_open, + .dv_close = md_close, + .dv_ioctl = noioctl, + .dv_print = md_print, + .dv_cleanup = nullsys, }; static int diff --git a/stand/common/merge_help.awk b/stand/common/merge_help.awk index 1070f73f1fe9..aab8383c4c71 100644 --- a/stand/common/merge_help.awk +++ b/stand/common/merge_help.awk @@ -1,6 +1,5 @@ #!/usr/bin/awk -f # -# $FreeBSD$ # # Merge two boot loader help files for FreeBSD 3.0 # Joe Abley <jabley@patho.gen.nz> diff --git a/stand/common/metadata.c b/stand/common/metadata.c index a9c81added02..8d5003ec47bf 100644 --- a/stand/common/metadata.c +++ b/stand/common/metadata.c @@ -27,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/param.h> #include <sys/linker.h> @@ -44,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include <machine/metadata.h> #include "bootstrap.h" +#include "modinfo.h" #ifdef LOADER_GELI_SUPPORT #include "geliboot.h" @@ -65,136 +64,6 @@ md_getboothowto(char *kargs) } /* - * Copy the environment into the load area starting at (addr). - * Each variable is formatted as <name>=<value>, with a single nul - * separating each variable, and a double nul terminating the environment. - */ -static vm_offset_t -md_copyenv(vm_offset_t addr) -{ - struct env_var *ep; - - /* traverse the environment */ - for (ep = environ; ep != NULL; ep = ep->ev_next) { - archsw.arch_copyin(ep->ev_name, addr, strlen(ep->ev_name)); - addr += strlen(ep->ev_name); - archsw.arch_copyin("=", addr, 1); - addr++; - if (ep->ev_value != NULL) { - archsw.arch_copyin(ep->ev_value, addr, strlen(ep->ev_value)); - addr += strlen(ep->ev_value); - } - archsw.arch_copyin("", addr, 1); - addr++; - } - archsw.arch_copyin("", addr, 1); - addr++; - return(addr); -} - -/* - * Copy module-related data into the load area, where it can be - * used as a directory for loaded modules. - * - * Module data is presented in a self-describing format. Each datum - * is preceded by a 32-bit identifier and a 32-bit size field. - * - * Currently, the following data are saved: - * - * MOD_NAME (variable) module name (string) - * MOD_TYPE (variable) module type (string) - * MOD_ARGS (variable) module parameters (string) - * MOD_ADDR sizeof(vm_offset_t) module load address - * MOD_SIZE sizeof(size_t) module size - * MOD_METADATA (variable) type-specific metadata - */ - -static int align; - -#define COPY32(v, a, c) { \ - uint32_t x = (v); \ - if (c) \ - archsw.arch_copyin(&x, a, sizeof(x)); \ - a += sizeof(x); \ -} - -#define MOD_STR(t, a, s, c) { \ - COPY32(t, a, c); \ - COPY32(strlen(s) + 1, a, c) \ - if (c) \ - archsw.arch_copyin(s, a, strlen(s) + 1);\ - a += roundup(strlen(s) + 1, align); \ -} - -#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) -#define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c) -#define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c) - -#define MOD_VAR(t, a, s, c) { \ - COPY32(t, a, c); \ - COPY32(sizeof(s), a, c); \ - if (c) \ - archsw.arch_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), align); \ -} - -#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) -#define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c) - -#define MOD_METADATA(a, mm, c) { \ - COPY32(MODINFO_METADATA | mm->md_type, a, c);\ - COPY32(mm->md_size, a, c); \ - if (c) \ - archsw.arch_copyin(mm->md_data, a, mm->md_size);\ - a += roundup(mm->md_size, align); \ -} - -#define MOD_END(a, c) { \ - COPY32(MODINFO_END, a, c); \ - COPY32(0, a, c); \ -} - -static vm_offset_t -md_copymodules(vm_offset_t addr, int kern64) -{ - struct preloaded_file *fp; - struct file_metadata *md; - uint64_t scratch64; - uint32_t scratch32; - int c; - - c = addr != 0; - /* start with the first module on the list, should be the kernel */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - - MOD_NAME(addr, fp->f_name, c); /* this field must come first */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - if (kern64) { - scratch64 = fp->f_addr; - MOD_ADDR(addr, scratch64, c); - scratch64 = fp->f_size; - MOD_SIZE(addr, scratch64, c); - } else { - scratch32 = fp->f_addr; -#ifdef __arm__ - scratch32 -= __elfN(relocation_offset); -#endif - MOD_ADDR(addr, scratch32, c); - MOD_SIZE(addr, fp->f_size, c); - } - for (md = fp->f_metadata; md != NULL; md = md->md_next) { - if (!(md->md_type & MODINFOMD_NOCOPY)) { - MOD_METADATA(addr, md, c); - } - } - } - MOD_END(addr, c); - return(addr); -} - -/* * Load the information expected by a kernel. * * - The 'boothowto' argument is constructed @@ -235,7 +104,6 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64) }; #endif - align = kern64 ? 8 : 4; howto = md_getboothowto(args); /* diff --git a/stand/common/misc.c b/stand/common/misc.c index 9cb5550344ca..046094f868e0 100644 --- a/stand/common/misc.c +++ b/stand/common/misc.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <string.h> #include <stand.h> #include <bootstrap.h> @@ -169,17 +167,6 @@ alloc_pread(readin_handle_t fd, off_t off, size_t len) return (buf); } -void -dev_cleanup(void) -{ - int i; - - /* Call cleanup routines */ - for (i = 0; devsw[i] != NULL; ++i) - if (devsw[i]->dv_cleanup != NULL) - (devsw[i]->dv_cleanup)(); -} - /* * mount new rootfs and unmount old, set "currdev" environment variable. */ @@ -201,3 +188,36 @@ int mount_currdev(struct env_var *ev, int flags, const void *value) } return (rv); } + +/* + * Set currdev to suit the value being supplied in (value) + */ +int +gen_setcurrdev(struct env_var *ev, int flags, const void *value) +{ + struct devdesc *ncurr; + int rv; + + if ((rv = devparse(&ncurr, value, NULL)) != 0) + return (rv); + free(ncurr); + + return (mount_currdev(ev, flags, value)); +} + +/* + * Wrapper to set currdev and loaddev at the same time. + */ +void +set_currdev(const char *devname) +{ + + env_setenv("currdev", EV_VOLATILE, devname, gen_setcurrdev, + env_nounset); + /* + * Don't execute hook here; the loaddev hook makes it immutable + * once we've determined what the proper currdev is. + */ + env_setenv("loaddev", EV_VOLATILE | EV_NOHOOK, devname, env_noset, + env_nounset); +} diff --git a/stand/common/modinfo.c b/stand/common/modinfo.c new file mode 100644 index 000000000000..381bd9dfd719 --- /dev/null +++ b/stand/common/modinfo.c @@ -0,0 +1,191 @@ +/*- + * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: FreeBSD: src/sys/boot/sparc64/loader/metadata.c,v 1.6 + */ +#include <stand.h> +#include <sys/param.h> +#include <sys/linker.h> +#include <sys/boot.h> +#include <sys/reboot.h> +#if defined(LOADER_FDT_SUPPORT) +#include <fdt_platform.h> +#endif + +#ifdef __arm__ +#include <machine/elf.h> +#endif +#include <machine/metadata.h> + +#include "bootstrap.h" +#include "modinfo.h" + +/* + * Copy module-related data into the load area, where it can be + * used as a directory for loaded modules. + * + * Module data is presented in a self-describing format. Each datum + * is preceded by a 32-bit identifier and a 32-bit size field. + * + * Currently, the following data are saved: + * + * MOD_NAME (variable) module name (string) + * MOD_TYPE (variable) module type (string) + * MOD_ARGS (variable) module parameters (string) + * MOD_ADDR sizeof(vm_offset_t) module load address + * MOD_SIZE sizeof(size_t) module size + * MOD_METADATA (variable) type-specific metadata + * + * Clients are required to define a MOD_ALIGN(l) macro which rounds the passed + * in length to the required alignment for the kernel being booted. + */ + +#define COPY32(v, a, c) { \ + uint32_t x = (v); \ + if (c) \ + archsw.arch_copyin(&x, a, sizeof(x)); \ + a += sizeof(x); \ +} + +#define MOD_STR(t, a, s, c) { \ + COPY32(t, a, c); \ + COPY32(strlen(s) + 1, a, c) \ + if (c) \ + archsw.arch_copyin(s, a, strlen(s) + 1);\ + a += MOD_ALIGN(strlen(s) + 1); \ +} + +#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) +#define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c) +#define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c) + +#define MOD_VAR(t, a, s, c) { \ + COPY32(t, a, c); \ + COPY32(sizeof(s), a, c); \ + if (c) \ + archsw.arch_copyin(&s, a, sizeof(s)); \ + a += MOD_ALIGN(sizeof(s)); \ +} + +#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) +#define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c) + +#define MOD_METADATA(a, mm, c) { \ + COPY32(MODINFO_METADATA | mm->md_type, a, c);\ + COPY32(mm->md_size, a, c); \ + if (c) { \ + archsw.arch_copyin(mm->md_data, a, mm->md_size);\ + mm->md_addr = a; \ + } \ + a += MOD_ALIGN(mm->md_size); \ +} + +#define MOD_END(a, c) { \ + COPY32(MODINFO_END, a, c); \ + COPY32(0, a, c); \ +} + +#define MOD_ALIGN(l) roundup(l, align) + +vm_offset_t +md_copymodules(vm_offset_t addr, bool kern64) +{ + struct preloaded_file *fp; + struct file_metadata *md; + uint64_t scratch64; + uint32_t scratch32; + int c; + int align; + + align = kern64 ? sizeof(uint64_t) : sizeof(uint32_t); + c = addr != 0; + /* start with the first module on the list, should be the kernel */ + for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { + + MOD_NAME(addr, fp->f_name, c); /* this field must come first */ + MOD_TYPE(addr, fp->f_type, c); + if (fp->f_args) + MOD_ARGS(addr, fp->f_args, c); + if (kern64) { + scratch64 = fp->f_addr; + MOD_ADDR(addr, scratch64, c); + scratch64 = fp->f_size; + MOD_SIZE(addr, scratch64, c); + } else { + scratch32 = fp->f_addr; +#ifdef __arm__ + scratch32 -= __elfN(relocation_offset); +#endif + MOD_ADDR(addr, scratch32, c); + MOD_SIZE(addr, fp->f_size, c); + } + for (md = fp->f_metadata; md != NULL; md = md->md_next) { + if (!(md->md_type & MODINFOMD_NOCOPY)) { + MOD_METADATA(addr, md, c); + } + } + } + MOD_END(addr, c); + return(addr); +} + +/* + * Copy the environment into the load area starting at (addr). + * Each variable is formatted as <name>=<value>, with a single nul + * separating each variable, and a double nul terminating the environment. + */ +vm_offset_t +md_copyenv(vm_offset_t start) +{ + struct env_var *ep; + vm_offset_t addr, last; + size_t len; + + addr = last = start; + + /* Traverse the environment. */ + for (ep = environ; ep != NULL; ep = ep->ev_next) { + len = strlen(ep->ev_name); + if ((size_t)archsw.arch_copyin(ep->ev_name, addr, len) != len) + break; + addr += len; + if (archsw.arch_copyin("=", addr, 1) != 1) + break; + addr++; + if (ep->ev_value != NULL) { + len = strlen(ep->ev_value); + if ((size_t)archsw.arch_copyin(ep->ev_value, addr, len) != len) + break; + addr += len; + } + if (archsw.arch_copyin("", addr, 1) != 1) + break; + last = ++addr; + } + + if (archsw.arch_copyin("", last++, 1) != 1) + last = start; + return(last); +} diff --git a/stand/common/modinfo.h b/stand/common/modinfo.h new file mode 100644 index 000000000000..967367beeeb0 --- /dev/null +++ b/stand/common/modinfo.h @@ -0,0 +1,15 @@ +/*- + * Copyright (c) 2022, Netflix, Inc. + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef COMMON_MODINFO_H +#define COMMON_MODINFO_H + +int md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb); +int md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb); + +vm_offset_t md_copymodules(vm_offset_t addr, bool kern64); +vm_offset_t md_copyenv(vm_offset_t addr); + +#endif /* COMMON_MODINFO_H */ diff --git a/stand/common/module.c b/stand/common/module.c index 43c04728b4fa..289d174733da 100644 --- a/stand/common/module.c +++ b/stand/common/module.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * file/module function dispatcher, support, etc. */ @@ -114,10 +112,14 @@ command_load(int argc, char *argv[]) char *typestr; #ifdef LOADER_VERIEXEC char *prefix, *skip; + int dflag = 0; + char *args = "dkp:s:t:"; +#else + char *args = "kt:"; #endif - int dflag, dofile, dokld, ch, error; + int dofile, dokld, ch, error; - dflag = dokld = dofile = 0; + dokld = dofile = 0; optind = 1; optreset = 1; typestr = NULL; @@ -129,11 +131,13 @@ command_load(int argc, char *argv[]) prefix = NULL; skip = NULL; #endif - while ((ch = getopt(argc, argv, "dkp:s:t:")) != -1) { + while ((ch = getopt(argc, argv, args)) != -1) { switch(ch) { +#ifdef LOADER_VERIEXEC case 'd': dflag++; break; +#endif case 'k': dokld = 1; break; diff --git a/stand/common/newvers.sh b/stand/common/newvers.sh index 714adba6c9cb..610999bf7ace 100755 --- a/stand/common/newvers.sh +++ b/stand/common/newvers.sh @@ -1,6 +1,5 @@ #!/bin/sh - # -# $FreeBSD$ # $NetBSD: newvers.sh,v 1.1 1997/07/26 01:50:38 thorpej Exp $ # # Copyright (c) 1984, 1986, 1990, 1993 @@ -57,6 +56,6 @@ fi cat > $tempfile <<EOF char bootprog_info[] = "$bootprog_info"; -unsigned bootprog_rev = ${r%%.*}${r##*.}; +unsigned bootprog_rev = ${r%%.*} * 1000 + ${r##*.}; EOF mv $tempfile vers.c diff --git a/stand/common/nvstore.c b/stand/common/nvstore.c index c6d230584f9d..3cdb094c858f 100644 --- a/stand/common/nvstore.c +++ b/stand/common/nvstore.c @@ -29,138 +29,12 @@ * nvstore is abstraction layer to implement data read/write to different * types of non-volatile storage. * - * User interfaces: - * Provide mapping via environment: setenv/unsetenv/putenv. Access via - * environment functions/commands is available once nvstore has - * attached the backend and stored textual data is mapped to environment. - * - * Provide command "nvstore" to create new data instances. - * - * API: TBD. - * nvstore_init(): attach new backend and create the environment mapping. - * nvstore_fini: detach backend and unmap the related environment. - * - * The disk based storage, such as UFS file or ZFS bootenv label area, is - * only accessible after root file system is set. Root file system change - * will switch the back end storage. + * Provides cli command 'nvostre' */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stdbool.h> -#include <sys/queue.h> -#include <bootstrap.h> #include "stand.h" - -typedef struct nvstore { - char *nvs_name; - void *nvs_data; - nvs_callbacks_t *nvs_cb; - STAILQ_ENTRY(nvstore) nvs_next; -} nvstore_t; - -typedef STAILQ_HEAD(store_list, nvstore) nvstore_list_t; - -nvstore_list_t stores = STAILQ_HEAD_INITIALIZER(stores); - -void * -nvstore_get_store(const char *name) -{ - nvstore_t *st; - - st = NULL; - - STAILQ_FOREACH(st, &stores, nvs_next) { - if (strcmp(name, st->nvs_name) == 0) - break; - } - - return (st); -} - -int -nvstore_init(const char *name, nvs_callbacks_t *cb, void *data) -{ - nvstore_t *st; - - st = nvstore_get_store(name); - if (st != NULL) - return (EEXIST); - - if ((st = malloc(sizeof (*st))) == NULL) - return (ENOMEM); - - if ((st->nvs_name = strdup(name)) == NULL) { - free(st); - return (ENOMEM); - } - - st->nvs_data = data; - st->nvs_cb = cb; - - STAILQ_INSERT_TAIL(&stores, st, nvs_next); - return (0); -} - -int -nvstore_fini(const char *name) -{ - nvstore_t *st; - - st = nvstore_get_store(name); - if (st == NULL) - return (ENOENT); - - STAILQ_REMOVE(&stores, st, nvstore, nvs_next); - - free(st->nvs_name); - free(st->nvs_data); - free(st); - return (0); -} - -int -nvstore_print(void *ptr) -{ - nvstore_t *st = ptr; - - return (st->nvs_cb->nvs_iterate(st->nvs_data, st->nvs_cb->nvs_print)); -} - -int -nvstore_get_var(void *ptr, const char *name, void **data) -{ - nvstore_t *st = ptr; - - return (st->nvs_cb->nvs_getter(st->nvs_data, name, data)); -} - -int -nvstore_set_var(void *ptr, int type, const char *name, - void *data, size_t size) -{ - nvstore_t *st = ptr; - - return (st->nvs_cb->nvs_setter(st->nvs_data, type, name, data, size)); -} - -int -nvstore_set_var_from_string(void *ptr, const char *type, const char *name, - const char *data) -{ - nvstore_t *st = ptr; - - return (st->nvs_cb->nvs_setter_str(st->nvs_data, type, name, data)); -} - -int -nvstore_unset_var(void *ptr, const char *name) -{ - nvstore_t *st = ptr; - - return (st->nvs_cb->nvs_unset(st->nvs_data, name)); -} +#include "nvstore.h" +#include "bootstrap.h" COMMAND_SET(nvstore, "nvstore", "manage non-volatile data", command_nvstore); diff --git a/stand/common/part.c b/stand/common/part.c index 4ae38bfb7682..41c0eef95d7d 100644 --- a/stand/common/part.c +++ b/stand/common/part.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/param.h> #include <sys/diskmbr.h> @@ -35,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include <sys/gpt.h> #include <sys/stddef.h> #include <sys/queue.h> -#include <sys/vtoc.h> #include <fs/cd9660/iso.h> @@ -70,7 +67,6 @@ struct pentry { uint8_t bsd; uint8_t mbr; uuid_t gpt; - uint16_t vtoc8; } type; STAILQ_ENTRY(pentry) entry; }; @@ -519,88 +515,6 @@ out: return (table); } -#ifdef LOADER_VTOC8_SUPPORT -static enum partition_type -vtoc8_parttype(uint16_t type) -{ - - switch (type) { - case VTOC_TAG_FREEBSD_SWAP: - return (PART_FREEBSD_SWAP); - case VTOC_TAG_FREEBSD_UFS: - return (PART_FREEBSD_UFS); - case VTOC_TAG_FREEBSD_VINUM: - return (PART_FREEBSD_VINUM); - case VTOC_TAG_FREEBSD_ZFS: - return (PART_FREEBSD_ZFS); - } - return (PART_UNKNOWN); -} - -static struct ptable * -ptable_vtoc8read(struct ptable *table, void *dev, diskread_t dread) -{ - struct pentry *entry; - struct vtoc8 *dl; - uint8_t *buf; - uint16_t sum, heads, sectors; - int i; - - if (table->sectorsize != sizeof(struct vtoc8)) - return (table); - buf = malloc(table->sectorsize); - if (buf == NULL) - return (table); - if (dread(dev, buf, 1, 0) != 0) { - DPRINTF("read failed"); - ptable_close(table); - table = NULL; - goto out; - } - dl = (struct vtoc8 *)buf; - /* Check the sum */ - for (i = sum = 0; i < sizeof(struct vtoc8); i += sizeof(sum)) - sum ^= be16dec(buf + i); - if (sum != 0) { - DPRINTF("incorrect checksum"); - goto out; - } - if (be16toh(dl->nparts) != VTOC8_NPARTS) { - DPRINTF("invalid number of entries"); - goto out; - } - sectors = be16toh(dl->nsecs); - heads = be16toh(dl->nheads); - if (sectors * heads == 0) { - DPRINTF("invalid geometry"); - goto out; - } - DPRINTF("VTOC8 detected"); - for (i = 0; i < VTOC8_NPARTS; i++) { - dl->part[i].tag = be16toh(dl->part[i].tag); - if (i == VTOC_RAW_PART || - dl->part[i].tag == VTOC_TAG_UNASSIGNED) - continue; - entry = malloc(sizeof(*entry)); - if (entry == NULL) - break; - entry->part.start = be32toh(dl->map[i].cyl) * heads * sectors; - entry->part.end = be32toh(dl->map[i].nblks) + - entry->part.start - 1; - entry->part.type = vtoc8_parttype(dl->part[i].tag); - entry->part.index = i; /* starts from zero */ - entry->type.vtoc8 = dl->part[i].tag; - STAILQ_INSERT_TAIL(&table->entries, entry, entry); - DPRINTF("new VTOC8 partition added"); - } - table->type = PTABLE_VTOC8; -out: - free(buf); - return (table); - -} -#endif /* LOADER_VTOC8_SUPPORT */ - #define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / table->sectorsize) static struct ptable * @@ -678,16 +592,6 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, } else if (table->type == PTABLE_ISO9660) goto out; -#ifdef LOADER_VTOC8_SUPPORT - if (be16dec(buf + offsetof(struct vtoc8, magic)) == VTOC_MAGIC) { - if (ptable_vtoc8read(table, dev, dread) == NULL) { - /* Read error. */ - table = NULL; - goto out; - } else if (table->type == PTABLE_VTOC8) - goto out; - } -#endif /* Check the BSD label. */ if (ptable_bsdread(table, dev, dread) == NULL) { /* Read error. */ table = NULL; @@ -929,12 +833,6 @@ ptable_iterate(const struct ptable *table, void *arg, ptable_iterate_t *iter) sprintf(name, "p%d", entry->part.index); else #endif -#ifdef LOADER_VTOC8_SUPPORT - if (table->type == PTABLE_VTOC8) - sprintf(name, "%c", (uint8_t) 'a' + - entry->part.index); - else -#endif if (table->type == PTABLE_BSD) sprintf(name, "%c", (uint8_t) 'a' + entry->part.index); diff --git a/stand/common/part.h b/stand/common/part.h index b991ae3c381c..a38680e9573f 100644 --- a/stand/common/part.h +++ b/stand/common/part.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _PART_H_ @@ -36,7 +34,6 @@ enum ptable_type { PTABLE_BSD, PTABLE_MBR, PTABLE_GPT, - PTABLE_VTOC8, PTABLE_ISO9660 }; diff --git a/stand/common/paths.h b/stand/common/paths.h index ed30abda4903..81540b3f8c11 100644 --- a/stand/common/paths.h +++ b/stand/common/paths.h @@ -21,8 +21,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _PATHS_H_ diff --git a/stand/common/pnp.c b/stand/common/pnp.c index 4759c4417d19..8ee7f5f711b1 100644 --- a/stand/common/pnp.c +++ b/stand/common/pnp.c @@ -4,8 +4,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * "Plug and Play" functionality. * diff --git a/stand/common/rbx.h b/stand/common/rbx.h index 21371a563805..98d453967a47 100644 --- a/stand/common/rbx.h +++ b/stand/common/rbx.h @@ -11,8 +11,6 @@ * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. - * - * $FreeBSD$ */ #ifndef _RBX_H_ diff --git a/stand/common/readin.h b/stand/common/readin.h index 72e2de8f6087..919514fb2995 100644 --- a/stand/common/readin.h +++ b/stand/common/readin.h @@ -21,8 +21,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _READIN_H_ #define _READIN_H_ diff --git a/stand/common/reloc_elf.c b/stand/common/reloc_elf.c index 262091b9f6c6..a7243bc634fd 100644 --- a/stand/common/reloc_elf.c +++ b/stand/common/reloc_elf.c @@ -28,8 +28,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <machine/elf.h> @@ -56,7 +54,10 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata, __ELF_WORD_SIZE == 64 Elf64_Addr *where, val; Elf_Addr addend, addr; - Elf_Size rtype, symidx; + Elf_Size rtype; +#if defined(__amd64__) || defined(__i386__) + Elf_Size symidx; +#endif const Elf_Rel *rel; const Elf_Rela *rela; @@ -67,7 +68,9 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata, dataaddr); addend = 0; rtype = ELF_R_TYPE(rel->r_info); +#if defined(__amd64__) || defined(__i386__) symidx = ELF_R_SYM(rel->r_info); +#endif addend = 0; break; case ELF_RELOC_RELA: @@ -76,7 +79,9 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata, dataaddr); addend = rela->r_addend; rtype = ELF_R_TYPE(rela->r_info); +#if defined(__amd64__) || defined(__i386__) symidx = ELF_R_SYM(rela->r_info); +#endif break; default: return (EINVAL); diff --git a/stand/common/reloc_elf32.c b/stand/common/reloc_elf32.c index 03d9d73bab7f..ee2617b371c1 100644 --- a/stand/common/reloc_elf32.c +++ b/stand/common/reloc_elf32.c @@ -1,6 +1,4 @@ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 32 #include "reloc_elf.c" diff --git a/stand/common/reloc_elf64.c b/stand/common/reloc_elf64.c index c8dcf2a36b0d..c7b76ca6b265 100644 --- a/stand/common/reloc_elf64.c +++ b/stand/common/reloc_elf64.c @@ -1,6 +1,4 @@ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 64 #include "reloc_elf.c" diff --git a/stand/common/self_reloc.c b/stand/common/self_reloc.c index aee19cd8c574..39dad510b0b0 100644 --- a/stand/common/self_reloc.c +++ b/stand/common/self_reloc.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <elf.h> #include <bootstrap.h> diff --git a/stand/common/tslog.c b/stand/common/tslog.c index 3851e760daf1..6f27b9ebc316 100644 --- a/stand/common/tslog.c +++ b/stand/common/tslog.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <stand.h> diff --git a/stand/common/vdisk.c b/stand/common/vdisk.c index 521ad498b194..3bbb13d908c5 100644 --- a/stand/common/vdisk.c +++ b/stand/common/vdisk.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <stdarg.h> #include <machine/_inttypes.h> @@ -52,7 +50,9 @@ struct devsw vdisk_dev = { .dv_close = vdisk_close, .dv_ioctl = vdisk_ioctl, .dv_print = vdisk_print, - .dv_cleanup = NULL + .dv_cleanup = nullsys, + .dv_fmtdev = disk_fmtdev, + .dv_parsedev = disk_parsedev, }; typedef STAILQ_HEAD(vdisk_info_list, vdisk_info) vdisk_info_list_t; diff --git a/stand/common/zfs_cmd.c b/stand/common/zfs_cmd.c index cee5b8993210..9a4dc01f0159 100644 --- a/stand/common/zfs_cmd.c +++ b/stand/common/zfs_cmd.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * MD bootstrap main() and assorted miscellaneous * commands. diff --git a/stand/defaults/Makefile b/stand/defaults/Makefile index 131034dd8322..ae382b9af694 100644 --- a/stand/defaults/Makefile +++ b/stand/defaults/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> diff --git a/stand/defaults/loader.conf b/stand/defaults/loader.conf index 24a47e75c39a..08406aa43bc8 100644 --- a/stand/defaults/loader.conf +++ b/stand/defaults/loader.conf @@ -6,7 +6,6 @@ # # All arguments must be in double quotes. # -# $FreeBSD$ ### Basic configuration options ############################ exec="echo Loading /boot/defaults/loader.conf" @@ -101,7 +100,7 @@ efi_max_resolution="1x1" # Set the max resolution for EFI loader to use: #kernels="kernel kernel.old" # Kernels to display in the boot menu kernels_autodetect="YES" # Auto-detect kernel directories in /boot #loader_logo="orbbw" # Desired logo: orbbw, orb, fbsdbw, beastiebw, beastie, none -#comconsole_speed="9600" # Set the current serial console speed +#comconsole_speed="115200" # Set the current serial console speed #console="vidconsole" # A comma separated list of console(s) #currdev="disk1s1a" # Set the current device module_path="/boot/modules;/boot/dtb;/boot/dtb/overlays" # Set the module search path diff --git a/stand/defaults/loader.conf.5 b/stand/defaults/loader.conf.5 index 23a65935c95a..195b34e75fdd 100644 --- a/stand/defaults/loader.conf.5 +++ b/stand/defaults/loader.conf.5 @@ -21,8 +21,6 @@ .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ .Dd July 31, 2021 .Dt LOADER.CONF 5 .Os @@ -254,7 +252,7 @@ a bitmap will be loaded to be displayed on screen while booting. Name of the bitmap to be loaded. Any other name can be used. .It Va comconsole_speed -.Dq ( 9600 +.Dq ( 115200 or the value of the .Va BOOT_COMCONSOLE_SPEED variable when @@ -427,10 +425,13 @@ It is not available in the default Forth-based loader. default settings \(em do not change this file. .It Pa /boot/loader.conf user defined settings. +.It Pa /boot/loader.conf.lua +user defined settings written in lua. .It Pa /boot/loader.conf.local machine-specific settings for sites with a common loader.conf. .El .Sh SEE ALSO +.Xr loader.conf.lua 5 , .Xr rc.conf 5 , .Xr boot 8 , .Xr cpucontrol 8 , diff --git a/stand/defs.mk b/stand/defs.mk index e9c97f7720ab..e8480a8c2b1e 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -1,4 +1,3 @@ -# $FreeBSD$ .if !defined(__BOOT_DEFS_MK__) __BOOT_DEFS_MK__=${MFILE} diff --git a/stand/efi/Makefile b/stand/efi/Makefile index 94cb5bba5638..5177ea688ed1 100644 --- a/stand/efi/Makefile +++ b/stand/efi/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ NO_OBJ=t diff --git a/stand/efi/Makefile.inc b/stand/efi/Makefile.inc index c2d803ddc1ab..a27eb5d97484 100644 --- a/stand/efi/Makefile.inc +++ b/stand/efi/Makefile.inc @@ -1,4 +1,3 @@ -# $FreeBSD$ # Options used when building app-specific efi components # See conf/kern.mk for the correct set of these @@ -21,8 +20,6 @@ CFLAGS+= -fPIC .if ${MACHINE_CPUARCH} == "amd64" EFI_TARGET= efi-app-x86_64 -.elif ${MACHINE_CPUARCH} == "i386" -EFI_TARGET= efi-app-ia32 .else EFI_TARGET= binary .endif diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile index daedc627e5dc..e03b95d2276f 100644 --- a/stand/efi/boot1/Makefile +++ b/stand/efi/boot1/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -74,7 +73,7 @@ LDFLAGS+= -Wl,--no-dynamic-linker .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -mgeneral-regs-only .endif -.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" +.if ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -fPIC LDFLAGS+= -Wl,-znocombreloc .endif @@ -82,17 +81,18 @@ LDFLAGS+= -Wl,-znocombreloc LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a # -# Add libsa for the runtime functions used by the compiler - for example -# __aeabi_* (arm) or __divdi3 (i386). -# as well as required string and memory functions for all platforms. +# Add libsa for the runtime functions used by the compiler as well as required +# string and memory functions for all platforms. # DPADD+= ${LIBEFI} ${LIBSA} LDADD+= ${LIBEFI} ${LIBSA} DPADD+= ${LDSCRIPT} +CLEANFILES+= ${BOOT1}.efi + ${BOOT1}.efi: ${PROG} - if ${NM} ${.ALLSRC} | grep ' U '; then \ + @if ${NM} ${.ALLSRC} | grep ' U '; then \ echo "Undefined symbols in ${.ALLSRC}"; \ exit 1; \ fi diff --git a/stand/efi/boot1/Makefile.depend b/stand/efi/boot1/Makefile.depend index ffc5430cceec..9f7ade2e75eb 100644 --- a/stand/efi/boot1/Makefile.depend +++ b/stand/efi/boot1/Makefile.depend @@ -1,13 +1,8 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - include \ - include/xlocale \ - lib/libmd \ stand/efi/libefi \ stand/libsa \ - stand/zfs \ .include <dirdeps.mk> diff --git a/stand/efi/boot1/boot1.c b/stand/efi/boot1/boot1.c index 088821ecd1f8..19627e870201 100644 --- a/stand/efi/boot1/boot1.c +++ b/stand/efi/boot1/boot1.c @@ -20,8 +20,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <machine/elf.h> #include <machine/stdarg.h> @@ -96,6 +94,26 @@ try_boot(const boot_module_t *mod, dev_info_t *dev, void *loaderbuf, size_t load buf = NULL; } + /* + * See if there's any env variables the module wants to set. If so, + * append it to any config present. + */ + if (mod->extra_env != NULL) { + const char *env = mod->extra_env(); + if (env != NULL) { + size_t newlen = cmdsize + strlen(env) + 1; + + cmd = realloc(cmd, newlen); + if (cmd == NULL) + goto errout; + if (cmdsize > 0) + strlcat(cmd, " ", newlen); + strlcat(cmd, env, newlen); + cmdsize = strlen(cmd); + free(__DECONST(char *, env)); + } + } + if ((status = BS->LoadImage(TRUE, IH, efi_devpath_last_node(dev->devpath), loaderbuf, loadersize, &loaderhandle)) != EFI_SUCCESS) { printf("Failed to load image provided by %s, size: %zu, (%lu)\n", diff --git a/stand/efi/boot1/boot_module.h b/stand/efi/boot1/boot_module.h index 99046fb53577..dd86249fbe3e 100644 --- a/stand/efi/boot1/boot_module.h +++ b/stand/efi/boot1/boot_module.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _BOOT_MODULE_H_ @@ -94,6 +92,9 @@ typedef struct boot_module_t /* valid devices as found by probe. */ dev_info_t *(*devices)(void); + + /* return any environment variables to pass to next stage */ + const char *(*extra_env)(void); } boot_module_t; extern const boot_module_t *boot_modules[]; diff --git a/stand/efi/boot1/proto.c b/stand/efi/boot1/proto.c index eeb3cd9568a4..cec4e2d1942c 100644 --- a/stand/efi/boot1/proto.c +++ b/stand/efi/boot1/proto.c @@ -20,8 +20,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <machine/elf.h> #include <machine/stdarg.h> diff --git a/stand/efi/boot1/proto.h b/stand/efi/boot1/proto.h index 5d80f907a5a5..435da4714f12 100644 --- a/stand/efi/boot1/proto.h +++ b/stand/efi/boot1/proto.h @@ -21,8 +21,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ void choice_protocol(EFI_HANDLE *handles, UINTN nhandles, EFI_DEVICE_PATH *imgpath); diff --git a/stand/efi/boot1/ufs_module.c b/stand/efi/boot1/ufs_module.c index edd7918e00b6..6848dd79eec0 100644 --- a/stand/efi/boot1/ufs_module.c +++ b/stand/efi/boot1/ufs_module.c @@ -28,8 +28,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <stdarg.h> diff --git a/stand/efi/boot1/zfs_module.c b/stand/efi/boot1/zfs_module.c index 7aaca72e30f1..01b95e06e38f 100644 --- a/stand/efi/boot1/zfs_module.c +++ b/stand/efi/boot1/zfs_module.c @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <stddef.h> #include <stdarg.h> @@ -40,6 +38,8 @@ static dev_info_t *devices; +static char zfs_bootonce[VDEV_PAD_SIZE]; + uint64_t ldi_get_size(void *priv) { @@ -142,6 +142,7 @@ load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize) struct zfsmount zmount; dnode_phys_t dn; struct stat st; + uint64_t rootobj; int err; void *buf; @@ -160,8 +161,47 @@ load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize) return (EFI_NOT_FOUND); } - if ((err = zfs_mount_impl(spa, 0, &zmount)) != 0) { - DPRINTF("Failed to mount pool '%s' (%d)\n", spa->spa_name, err); + if (zfs_get_bootonce_spa(spa, OS_BOOTONCE, zfs_bootonce, + sizeof(zfs_bootonce)) == 0) { + /* + * If bootonce attribute is present, use it as root dataset. + * Any attempt to use it should clear the 'once' flag. Prior + * to now, we'd not be able to clear it anyway. We don't care + * if we can't find the files to boot, or if there's a problem + * with it: we've tried to use it once we're able to mount the + * ZFS dataset. + * + * Note: the attribute is prefixed with "zfs:" and suffixed + * with ":". + */ + char *dname, *end; + + if (zfs_bootonce[0] != 'z' || zfs_bootonce[1] != 'f' || + zfs_bootonce[2] != 's' || zfs_bootonce[3] != ':' || + (dname = strchr(&zfs_bootonce[4], '/')) == NULL || + (end = strrchr(&zfs_bootonce[4], ':')) == NULL) { + printf("INVALID zfs bootonce: %s\n", zfs_bootonce); + *zfs_bootonce = '\0'; + rootobj = 0; + } else { + dname += 1; + *end = '\0'; + if (zfs_lookup_dataset(spa, dname, &rootobj) != 0) { + printf("zfs bootonce dataset %s NOT FOUND\n", + dname); + *zfs_bootonce = '\0'; + rootobj = 0; + } else + printf("zfs bootonce: %s\n", zfs_bootonce); + *end = ':'; + } + } else { + *zfs_bootonce = '\0'; + rootobj = 0; + } + + if ((err = zfs_mount_impl(spa, rootobj, &zmount)) != 0) { + printf("Failed to mount pool '%s' (%d)\n", spa->spa_name, err); return (EFI_NOT_FOUND); } @@ -220,6 +260,18 @@ status(void) printf("\n"); } +static const char * +extra_env(void) +{ + char *rv = NULL; /* So we return NULL if asprintf fails */ + + if (*zfs_bootonce == '\0') + return NULL; + asprintf(&rv, "zfs-bootonce=%s", zfs_bootonce); + return (rv); +} + + static void init(void) { @@ -241,5 +293,6 @@ const boot_module_t zfs_module = .probe = probe, .load = load, .status = status, - .devices = _devices + .devices = _devices, + .extra_env = extra_env, }; diff --git a/stand/efi/fdt/Makefile b/stand/efi/fdt/Makefile index 7f69ce1b3f11..518d7a75dc68 100644 --- a/stand/efi/fdt/Makefile +++ b/stand/efi/fdt/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> diff --git a/stand/efi/fdt/Makefile.depend b/stand/efi/fdt/Makefile.depend index 18be76b0cb6f..15a1f9c07f7c 100644 --- a/stand/efi/fdt/Makefile.depend +++ b/stand/efi/fdt/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/efi/fdt/efi_fdt.c b/stand/efi/fdt/efi_fdt.c index cf3cbabee722..7010a272d9db 100644 --- a/stand/efi/fdt/efi_fdt.c +++ b/stand/efi/fdt/efi_fdt.c @@ -1,6 +1,5 @@ /*- * Copyright (c) 2014 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Andrew Turner under * sponsorship from the FreeBSD Foundation. @@ -28,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <stand.h> #include <efi.h> diff --git a/stand/efi/gptboot/Makefile b/stand/efi/gptboot/Makefile index 2dcf8dda8f59..82d4b3b8c464 100644 --- a/stand/efi/gptboot/Makefile +++ b/stand/efi/gptboot/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ # ZFS is not supported, we want debugging until this is vetted and # we don't want the gptboot.efifat thing created. diff --git a/stand/efi/gptboot/drv.h b/stand/efi/gptboot/drv.h index d7df6a10f1e4..aa58237180f0 100644 --- a/stand/efi/gptboot/drv.h +++ b/stand/efi/gptboot/drv.h @@ -21,8 +21,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _DRV_H_ diff --git a/stand/efi/gptboot/gptboot.efi.8 b/stand/efi/gptboot/gptboot.efi.8 index 134c5353e9f1..e520509e35e6 100644 --- a/stand/efi/gptboot/gptboot.efi.8 +++ b/stand/efi/gptboot/gptboot.efi.8 @@ -22,9 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd April 6, 2021 +.Dd April 13, 2023 .Dt GPTBOOT.EFI 8 .Os .Sh NAME @@ -274,7 +272,7 @@ gpart set -a bootonce -i 2 ada0 appeared in .Fx 13.0 .Sh AUTHORS -This manual page written by +This manual page was written by .An Warner Losh Aq imp@FreeBSD.org . It is based heavily on the .Xr gptboot 8 diff --git a/stand/efi/gptboot/proto.c b/stand/efi/gptboot/proto.c index 38ccb5023c16..54a229db7bca 100644 --- a/stand/efi/gptboot/proto.c +++ b/stand/efi/gptboot/proto.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <machine/elf.h> #include <machine/stdarg.h> diff --git a/stand/efi/include/Guid/MemoryTypeInformation.h b/stand/efi/include/Guid/MemoryTypeInformation.h index 50386b747d35..be9c4b5177a9 100644 --- a/stand/efi/include/Guid/MemoryTypeInformation.h +++ b/stand/efi/include/Guid/MemoryTypeInformation.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file This file defines: * Memory Type Information GUID for HOB and Variable. diff --git a/stand/efi/include/Guid/MtcVendor.h b/stand/efi/include/Guid/MtcVendor.h index 471e7df4d673..3aa774f55477 100644 --- a/stand/efi/include/Guid/MtcVendor.h +++ b/stand/efi/include/Guid/MtcVendor.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file GUID is for MTC variable. diff --git a/stand/efi/include/Guid/ZeroGuid.h b/stand/efi/include/Guid/ZeroGuid.h index a7502cb83534..6de8c3821f5f 100644 --- a/stand/efi/include/Guid/ZeroGuid.h +++ b/stand/efi/include/Guid/ZeroGuid.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file GUID has all zero values. diff --git a/stand/efi/include/Protocol/EdidActive.h b/stand/efi/include/Protocol/EdidActive.h index 88fc0c68ec37..1f6ff052a91c 100644 --- a/stand/efi/include/Protocol/EdidActive.h +++ b/stand/efi/include/Protocol/EdidActive.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file EDID Active Protocol from the UEFI 2.0 specification. diff --git a/stand/efi/include/Protocol/EdidDiscovered.h b/stand/efi/include/Protocol/EdidDiscovered.h index a521e90d0056..c10b6ee89a82 100644 --- a/stand/efi/include/Protocol/EdidDiscovered.h +++ b/stand/efi/include/Protocol/EdidDiscovered.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file EDID Discovered Protocol from the UEFI 2.0 specification. diff --git a/stand/efi/include/Protocol/EdidOverride.h b/stand/efi/include/Protocol/EdidOverride.h index d64d400e8c06..450c95641fce 100644 --- a/stand/efi/include/Protocol/EdidOverride.h +++ b/stand/efi/include/Protocol/EdidOverride.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file EDID Override Protocol from the UEFI 2.0 specification. diff --git a/stand/efi/include/Protocol/Http.h b/stand/efi/include/Protocol/Http.h index 54f49ab5e35c..c88cc9f78847 100644 --- a/stand/efi/include/Protocol/Http.h +++ b/stand/efi/include/Protocol/Http.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file This file defines the EFI HTTP Protocol interface. It is split into the following two main sections: diff --git a/stand/efi/include/Protocol/Ip4Config2.h b/stand/efi/include/Protocol/Ip4Config2.h index 47241d7ad7d4..41b5abaafa02 100644 --- a/stand/efi/include/Protocol/Ip4Config2.h +++ b/stand/efi/include/Protocol/Ip4Config2.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file This file provides a definition of the EFI IPv4 Configuration II Protocol. diff --git a/stand/efi/include/Protocol/ServiceBinding.h b/stand/efi/include/Protocol/ServiceBinding.h index 39602b086e5b..ac501515ac67 100644 --- a/stand/efi/include/Protocol/ServiceBinding.h +++ b/stand/efi/include/Protocol/ServiceBinding.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file UEFI Service Binding Protocol is defined in UEFI specification. diff --git a/stand/efi/include/README b/stand/efi/include/README index bf821fae7e60..126cfa752f69 100644 --- a/stand/efi/include/README +++ b/stand/efi/include/README @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /*- Files in this directory and subdirectories are subject to the following diff --git a/stand/efi/include/amd64/efibind.h b/stand/efi/include/amd64/efibind.h index 8cfce5bbc5f1..2f900786fb9d 100644 --- a/stand/efi/include/amd64/efibind.h +++ b/stand/efi/include/amd64/efibind.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /*++ Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved diff --git a/stand/efi/include/amd64/pe.h b/stand/efi/include/amd64/pe.h index f8033c55ac55..ad5985cc2740 100644 --- a/stand/efi/include/amd64/pe.h +++ b/stand/efi/include/amd64/pe.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* PE32+ header file */ diff --git a/stand/efi/include/arm/efibind.h b/stand/efi/include/arm/efibind.h index 177032adc01a..8bc9f4b56eb2 100644 --- a/stand/efi/include/arm/efibind.h +++ b/stand/efi/include/arm/efibind.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /*++ Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved. diff --git a/stand/efi/include/arm64/efibind.h b/stand/efi/include/arm64/efibind.h index 4751e2e944a8..4fdfd9f21386 100644 --- a/stand/efi/include/arm64/efibind.h +++ b/stand/efi/include/arm64/efibind.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /*++ Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved diff --git a/stand/efi/include/efi.h b/stand/efi/include/efi.h index 7e44a5b819fc..20776dcee2fc 100644 --- a/stand/efi/include/efi.h +++ b/stand/efi/include/efi.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /*++ Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved diff --git a/stand/efi/include/efi_driver_utils.h b/stand/efi/include/efi_driver_utils.h index 520cff128a27..9f0b6dfd638d 100644 --- a/stand/efi/include/efi_driver_utils.h +++ b/stand/efi/include/efi_driver_utils.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _EFI_DRIVER_UTILS_H_ diff --git a/stand/efi/include/efi_drivers.h b/stand/efi/include/efi_drivers.h index 8df9133f73d4..938e17b6863d 100644 --- a/stand/efi/include/efi_drivers.h +++ b/stand/efi/include/efi_drivers.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _EFI_DRIVERS_H_ diff --git a/stand/efi/include/efi_nii.h b/stand/efi/include/efi_nii.h index 561cbd46a3ea..069e318428ea 100644 --- a/stand/efi/include/efi_nii.h +++ b/stand/efi/include/efi_nii.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_NII_H #define _EFI_NII_H diff --git a/stand/efi/include/efiapi.h b/stand/efi/include/efiapi.h index 2347a4d9cf73..6c96c6f707ad 100644 --- a/stand/efi/include/efiapi.h +++ b/stand/efi/include/efiapi.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_API_H #define _EFI_API_H diff --git a/stand/efi/include/efichar.h b/stand/efi/include/efichar.h index 49ff43b3cb20..4460f5efdcef 100644 --- a/stand/efi/include/efichar.h +++ b/stand/efi/include/efichar.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _BOOT_EFI_EFICHAR_H_ diff --git a/stand/efi/include/eficon.h b/stand/efi/include/eficon.h index ba80114eb9be..39855b8b0725 100644 --- a/stand/efi/include/eficon.h +++ b/stand/efi/include/eficon.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_CON_H #define _EFI_CON_H diff --git a/stand/efi/include/eficonsctl.h b/stand/efi/include/eficonsctl.h index 68be3d69f4fd..c7f5a137045e 100644 --- a/stand/efi/include/eficonsctl.h +++ b/stand/efi/include/eficonsctl.h @@ -29,7 +29,6 @@ * Abstract: Abstraction of a Text mode or GOP/UGA screen */ -/* $FreeBSD$ */ #ifndef _EFI_CONS_CTL_H #define _EFI_CONS_CTL_H diff --git a/stand/efi/include/efidebug.h b/stand/efi/include/efidebug.h index 5576d5f4e48c..b43b62d1283c 100644 --- a/stand/efi/include/efidebug.h +++ b/stand/efi/include/efidebug.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_DEBUG_H #define _EFI_DEBUG_H diff --git a/stand/efi/include/efidef.h b/stand/efi/include/efidef.h index a8f88d41df24..54be3bb2a0ce 100644 --- a/stand/efi/include/efidef.h +++ b/stand/efi/include/efidef.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_DEF_H #define _EFI_DEF_H diff --git a/stand/efi/include/efidevp.h b/stand/efi/include/efidevp.h index b00b78f02c6a..409f2b23b9ef 100644 --- a/stand/efi/include/efidevp.h +++ b/stand/efi/include/efidevp.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _DEVPATH_H #define _DEVPATH_H diff --git a/stand/efi/include/efierr.h b/stand/efi/include/efierr.h index a8b655718599..2aa2622a3877 100644 --- a/stand/efi/include/efierr.h +++ b/stand/efi/include/efierr.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_ERR_H #define _EFI_ERR_H diff --git a/stand/efi/include/efifpswa.h b/stand/efi/include/efifpswa.h index 21823c5ff6f1..ed831d02e51b 100644 --- a/stand/efi/include/efifpswa.h +++ b/stand/efi/include/efifpswa.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_FPSWA_H #define _EFI_FPSWA_H diff --git a/stand/efi/include/efifs.h b/stand/efi/include/efifs.h index 76aa93d6d07f..3ba238496b23 100644 --- a/stand/efi/include/efifs.h +++ b/stand/efi/include/efifs.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_FS_H #define _EFI_FS_H diff --git a/stand/efi/include/efigop.h b/stand/efi/include/efigop.h index 104fa6e44b5a..e1d4b8163401 100644 --- a/stand/efi/include/efigop.h +++ b/stand/efi/include/efigop.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /*++ Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved diff --git a/stand/efi/include/efigpt.h b/stand/efi/include/efigpt.h index 045d49520b40..ac90a304f762 100644 --- a/stand/efi/include/efigpt.h +++ b/stand/efi/include/efigpt.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_GPT_H #define _EFI_GPT_H /*++ diff --git a/stand/efi/include/efiip.h b/stand/efi/include/efiip.h index ce0910a1b998..839507964f75 100644 --- a/stand/efi/include/efiip.h +++ b/stand/efi/include/efiip.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_IP_H #define _EFI_IP_H diff --git a/stand/efi/include/efilib.h b/stand/efi/include/efilib.h index 903e1f0d00e5..e1920430a7d1 100644 --- a/stand/efi/include/efilib.h +++ b/stand/efi/include/efilib.h @@ -23,8 +23,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _LOADER_EFILIB_H @@ -85,9 +83,6 @@ efi_exit_boot_services(UINTN key) } int efi_getdev(void **vdev, const char *devspec, const char **path); -char *efi_fmtdev(void *vdev); -int efi_setcurrdev(struct env_var *ev, int flags, const void *value); - int efi_register_handles(struct devsw *, EFI_HANDLE *, EFI_HANDLE *, int); EFI_HANDLE efi_find_handle(struct devsw *, int); @@ -100,6 +95,7 @@ void efi_close_devpath(EFI_HANDLE); EFI_HANDLE efi_devpath_handle(EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_last_node(EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_trim(EFI_DEVICE_PATH *); +EFI_DEVICE_PATH *efi_devpath_next_instance(EFI_DEVICE_PATH *); bool efi_devpath_match(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); bool efi_devpath_match_node(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); bool efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); diff --git a/stand/efi/include/efinet.h b/stand/efi/include/efinet.h index 3ac58b2431ca..9cd13f5a4653 100644 --- a/stand/efi/include/efinet.h +++ b/stand/efi/include/efinet.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFINET_H #define _EFINET_H diff --git a/stand/efi/include/efipart.h b/stand/efi/include/efipart.h index ef1a8709d91b..32a715c8781b 100644 --- a/stand/efi/include/efipart.h +++ b/stand/efi/include/efipart.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_PART_H #define _EFI_PART_H diff --git a/stand/efi/include/efipciio.h b/stand/efi/include/efipciio.h index b42fa59395a0..4e9ca153f721 100644 --- a/stand/efi/include/efipciio.h +++ b/stand/efi/include/efipciio.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file EFI PCI I/O Protocol provides the basic Memory, I/O, PCI configuration, and DMA interfaces that a driver uses to access its PCI controller. diff --git a/stand/efi/include/efipoint.h b/stand/efi/include/efipoint.h index 99944f720378..46e92ffd3b48 100644 --- a/stand/efi/include/efipoint.h +++ b/stand/efi/include/efipoint.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* Copyright (C) 2014 by John Cronin * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/stand/efi/include/efiprot.h b/stand/efi/include/efiprot.h index 351b2d347ad4..be11ea83b3a2 100644 --- a/stand/efi/include/efiprot.h +++ b/stand/efi/include/efiprot.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_PROT_H #define _EFI_PROT_H diff --git a/stand/efi/include/efipxebc.h b/stand/efi/include/efipxebc.h index ba0b2e9b6c5d..5d5c60a104b0 100644 --- a/stand/efi/include/efipxebc.h +++ b/stand/efi/include/efipxebc.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFIPXEBC_H #define _EFIPXEBC_H diff --git a/stand/efi/include/efiser.h b/stand/efi/include/efiser.h index e3d66e203a4b..9a13653453fb 100644 --- a/stand/efi/include/efiser.h +++ b/stand/efi/include/efiser.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_SER_H #define _EFI_SER_H diff --git a/stand/efi/include/efistdarg.h b/stand/efi/include/efistdarg.h index 25f556984112..f4cf0356563c 100644 --- a/stand/efi/include/efistdarg.h +++ b/stand/efi/include/efistdarg.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFISTDARG_H_ #define _EFISTDARG_H_ diff --git a/stand/efi/include/efitcp.h b/stand/efi/include/efitcp.h index 9f47b5ce8edc..6c5df7fd944d 100644 --- a/stand/efi/include/efitcp.h +++ b/stand/efi/include/efitcp.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_TCP_H #define _EFI_TCP_H diff --git a/stand/efi/include/efiudp.h b/stand/efi/include/efiudp.h index 82c8df79b59a..7c8b467eb9c4 100644 --- a/stand/efi/include/efiudp.h +++ b/stand/efi/include/efiudp.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _EFI_UDP_H #define _EFI_UDP_H diff --git a/stand/efi/include/efiuga.h b/stand/efi/include/efiuga.h index 00464b7cb4c0..b15c2176c32f 100644 --- a/stand/efi/include/efiuga.h +++ b/stand/efi/include/efiuga.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /** @file UGA Draw protocol from the EFI 1.1 specification. diff --git a/stand/efi/include/efizfs.h b/stand/efi/include/efizfs.h index 97f28097b2a1..b29fb8d1af7e 100644 --- a/stand/efi/include/efizfs.h +++ b/stand/efi/include/efizfs.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <stdint.h> diff --git a/stand/efi/include/i386/efibind.h b/stand/efi/include/i386/efibind.h index 0f1d4f115598..6123a98d1b9b 100644 --- a/stand/efi/include/i386/efibind.h +++ b/stand/efi/include/i386/efibind.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /*++ Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved diff --git a/stand/efi/include/i386/pe.h b/stand/efi/include/i386/pe.h index e2ae25c3ddf6..ede10814939f 100644 --- a/stand/efi/include/i386/pe.h +++ b/stand/efi/include/i386/pe.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* PE32+ header file */ diff --git a/stand/efi/include/riscv/efibind.h b/stand/efi/include/riscv/efibind.h index 4751e2e944a8..4fdfd9f21386 100644 --- a/stand/efi/include/riscv/efibind.h +++ b/stand/efi/include/riscv/efibind.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /*++ Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved diff --git a/stand/efi/libefi/Makefile b/stand/efi/libefi/Makefile index 8f1a30d86900..7bc0184e2062 100644 --- a/stand/efi/libefi/Makefile +++ b/stand/efi/libefi/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -11,6 +10,7 @@ SRCS= delay.c \ efi_console.c \ efi_driver_utils.c \ efichar.c \ + eficom.c \ efienv.c \ efihttp.c \ efinet.c \ @@ -25,7 +25,7 @@ SRCS= delay.c \ .PATH: ${SYSDIR}/teken SRCS+= teken.c -.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" +.if ${MACHINE_CPUARCH} == "amd64" SRCS+= time.c .elif ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "riscv" SRCS+= time_event.c diff --git a/stand/efi/libefi/Makefile.depend b/stand/efi/libefi/Makefile.depend index 73bc18c8c0fc..18537add9fe3 100644 --- a/stand/efi/libefi/Makefile.depend +++ b/stand/efi/libefi/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/efi/libefi/delay.c b/stand/efi/libefi/delay.c index 9bf40d28f96b..becdcb3fa267 100644 --- a/stand/efi/libefi/delay.c +++ b/stand/efi/libefi/delay.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <efi.h> #include <efilib.h> diff --git a/stand/efi/libefi/devicename.c b/stand/efi/libefi/devicename.c index cdf4830697fd..22844bbbd6ec 100644 --- a/stand/efi/libefi/devicename.c +++ b/stand/efi/libefi/devicename.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> #include <sys/disklabel.h> @@ -39,8 +37,6 @@ __FBSDID("$FreeBSD$"); #include <efilib.h> #include <efizfs.h> -static int efi_parsedev(struct devdesc **, const char *, const char **); - /* * Point (dev) at an allocated device specifier for the device matching the * path in (devspec). If it contains an explicit device specification, @@ -57,159 +53,11 @@ efi_getdev(void **vdev, const char *devspec, const char **path) * use the current device instead. */ if (devspec == NULL || *devspec == '/' || !strchr(devspec, ':')) { - rv = efi_parsedev(dev, getenv("currdev"), NULL); + rv = devparse(dev, getenv("currdev"), NULL); if (rv == 0 && path != NULL) *path = devspec; return (rv); } - /* Parse the device name off the beginning of the devspec. */ - return (efi_parsedev(dev, devspec, path)); -} - -/* - * Point (dev) at an allocated device specifier matching the string version - * at the beginning of (devspec). Return a pointer to the remaining - * text in (path). - * - * In all cases, the beginning of (devspec) is compared to the names - * of known devices in the device switch, and then any following text - * is parsed according to the rules applied to the device type. - * - * For disk-type devices, the syntax is: - * - * fs<unit>: - */ -static int -efi_parsedev(struct devdesc **dev, const char *devspec, const char **path) -{ - struct devdesc *idev; - struct devsw *dv; - int i, unit, err; - char *cp; - const char *np; - - /* minimum length check */ - if (strlen(devspec) < 2) - return (EINVAL); - - /* look for a device that matches */ - for (i = 0; devsw[i] != NULL; i++) { - dv = devsw[i]; - if (!strncmp(devspec, dv->dv_name, strlen(dv->dv_name))) - break; - } - if (devsw[i] == NULL) - return (ENOENT); - - np = devspec + strlen(dv->dv_name); - idev = NULL; - err = 0; - - switch (dv->dv_type) { - case DEVT_NONE: - break; - - case DEVT_DISK: - idev = malloc(sizeof(struct disk_devdesc)); - if (idev == NULL) - return (ENOMEM); - - err = disk_parsedev((struct disk_devdesc *)idev, np, path); - if (err != 0) - goto fail; - break; - -#ifdef EFI_ZFS_BOOT - case DEVT_ZFS: - idev = malloc(sizeof(struct zfs_devdesc)); - if (idev == NULL) - return (ENOMEM); - - err = zfs_parsedev((struct zfs_devdesc*)idev, np, path); - if (err != 0) - goto fail; - break; -#endif - default: - idev = malloc(sizeof(struct devdesc)); - if (idev == NULL) - return (ENOMEM); - - unit = 0; - cp = (char *)np; - - if (*np != '\0' && *np != ':') { - errno = 0; - unit = strtol(np, &cp, 0); - if (errno != 0 || cp == np) { - err = EUNIT; - goto fail; - } - } - if (*cp != '\0' && *cp != ':') { - err = EINVAL; - goto fail; - } - - idev->d_unit = unit; - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - } - - idev->d_dev = dv; - - if (dev != NULL) - *dev = idev; - else - free(idev); - return (0); - -fail: - free(idev); - return (err); -} - -char * -efi_fmtdev(void *vdev) -{ - struct devdesc *dev = (struct devdesc *)vdev; - static char buf[SPECNAMELEN + 1]; - - switch(dev->d_dev->dv_type) { - case DEVT_NONE: - strcpy(buf, "(no device)"); - break; - - case DEVT_DISK: - return (disk_fmtdev(vdev)); - -#ifdef EFI_ZFS_BOOT - case DEVT_ZFS: - return (zfs_fmtdev(dev)); -#endif - default: - sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); - break; - } - - return (buf); -} - -/* - * Set currdev to suit the value being supplied in (value) - */ -int -efi_setcurrdev(struct env_var *ev, int flags, const void *value) -{ - struct devdesc *ncurr; - int rv; - - rv = efi_parsedev(&ncurr, value, NULL); - if (rv != 0) - return (rv); - free(ncurr); - - return (mount_currdev(ev, flags, value)); + return (devparse(dev, devspec, path)); } diff --git a/stand/efi/libefi/devpath.c b/stand/efi/libefi/devpath.c index c25ae73e463c..6b4b8785a2dd 100644 --- a/stand/efi/libefi/devpath.c +++ b/stand/efi/libefi/devpath.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <efi.h> #include <efilib.h> #include <efichar.h> @@ -575,6 +573,23 @@ efi_devpath_last_node(EFI_DEVICE_PATH *devpath) return (devpath); } +/* + * Walk device path nodes, return next instance or end node. + */ +EFI_DEVICE_PATH * +efi_devpath_next_instance(EFI_DEVICE_PATH *devpath) +{ + while (!IsDevicePathEnd(devpath)) { + devpath = NextDevicePathNode(devpath); + if (IsDevicePathEndType(devpath) && + devpath->SubType == END_INSTANCE_DEVICE_PATH_SUBTYPE) { + devpath = NextDevicePathNode(devpath); + break; + } + } + return (devpath); +} + EFI_DEVICE_PATH * efi_devpath_trim(EFI_DEVICE_PATH *devpath) { diff --git a/stand/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c index 1aeb94344c58..1758cd9d4d6d 100644 --- a/stand/efi/libefi/efi_console.c +++ b/stand/efi/libefi/efi_console.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <efi.h> #include <efilib.h> diff --git a/stand/efi/libefi/efi_driver_utils.c b/stand/efi/libefi/efi_driver_utils.c index e5034c2e34d6..adb57f39fdce 100644 --- a/stand/efi/libefi/efi_driver_utils.c +++ b/stand/efi/libefi/efi_driver_utils.c @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <stdbool.h> diff --git a/stand/efi/libefi/efichar.c b/stand/efi/libefi/efichar.c index 233027f4e6ea..0703c167de47 100644 --- a/stand/efi/libefi/efichar.c +++ b/stand/efi/libefi/efichar.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <errno.h> #ifdef _STANDALONE diff --git a/stand/efi/loader/efiserialio.c b/stand/efi/libefi/eficom.c index 8b3f8e83e0b3..c84e040420e7 100644 --- a/stand/efi/loader/efiserialio.c +++ b/stand/efi/libefi/eficom.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/errno.h> #include <bootstrap.h> @@ -34,25 +32,20 @@ __FBSDID("$FreeBSD$"); #include <efi.h> #include <efilib.h> -#include "loader_efi.h" - static EFI_GUID serial = SERIAL_IO_PROTOCOL; #define COMC_TXWAIT 0x40000 /* transmit timeout */ -#ifndef COMSPEED -#define COMSPEED 9600 -#endif - #define PNP0501 0x501 /* 16550A-compatible COM port */ struct serial { + uint64_t newbaudrate; uint64_t baudrate; - uint8_t databits; + uint32_t timeout; + uint32_t receivefifodepth; + uint32_t databits; EFI_PARITY_TYPE parity; EFI_STOP_BITS_TYPE stopbits; - uint8_t ignore_cd; /* boolean */ - uint8_t rtsdtr_off; /* boolean */ int ioaddr; /* index in handles array */ EFI_HANDLE currdev; /* current serial device */ EFI_HANDLE condev; /* EFI Console device */ @@ -72,16 +65,30 @@ static int comc_speed_set(struct env_var *, int, const void *); static struct serial *comc_port; extern struct console efi_console; +struct console eficom = { + .c_name = "eficom", + .c_desc = "serial port", + .c_flags = 0, + .c_probe = comc_probe, + .c_init = comc_init, + .c_out = comc_putchar, + .c_in = comc_getchar, + .c_ready = comc_ischar, +}; + +#if defined(__aarch64__) && __FreeBSD_version < 1500000 +static void comc_probe_compat(struct console *); struct console comconsole = { .c_name = "comconsole", .c_desc = "serial port", .c_flags = 0, - .c_probe = comc_probe, + .c_probe = comc_probe_compat, .c_init = comc_init, .c_out = comc_putchar, .c_in = comc_getchar, .c_ready = comc_ischar, }; +#endif static EFI_STATUS efi_serial_init(EFI_HANDLE **handlep, int *nhandles) @@ -245,6 +252,11 @@ comc_get_con_serial_handle(const char *name) return (NULL); } +/* + * Called from cons_probe() to see if this device is available. + * Return immediately on x86, except for hyperv, since it interferes with + * common configurations otherwise (yes, this is just firewalling the bug). + */ static void comc_probe(struct console *sc) { @@ -256,19 +268,28 @@ comc_probe(struct console *sc) char *env, *buf, *ep; size_t sz; +#ifdef __amd64__ + /* + * This driver tickles issues on a number of different firmware loads. + * It is only required for HyperV, and is only known to work on HyperV, + * so only allow it on HyperV. + */ + env = getenv("smbios.bios.version"); + if (env == NULL || strncmp(env, "Hyper-V", 7) != 0) { + return; + } +#endif + if (comc_port == NULL) { - comc_port = malloc(sizeof (struct serial)); + comc_port = calloc(1, sizeof (struct serial)); if (comc_port == NULL) return; } - comc_port->baudrate = COMSPEED; - comc_port->ioaddr = 0; /* default port */ - comc_port->databits = 8; /* 8,n,1 */ - comc_port->parity = NoParity; /* 8,n,1 */ - comc_port->stopbits = OneStopBit; /* 8,n,1 */ - comc_port->ignore_cd = 1; /* ignore cd */ - comc_port->rtsdtr_off = 0; /* rts-dtr is on */ - comc_port->sio = NULL; + + /* Use defaults from firmware */ + comc_port->databits = 8; + comc_port->parity = DefaultParity; + comc_port->stopbits = DefaultStopBits; handle = NULL; env = getenv("efi_com_port"); @@ -292,8 +313,28 @@ comc_probe(struct console *sc) (void**)&comc_port->sio, IH, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (EFI_ERROR(status)) + if (EFI_ERROR(status)) { comc_port->sio = NULL; + } else { + comc_port->newbaudrate = + comc_port->baudrate = comc_port->sio->Mode->BaudRate; + comc_port->timeout = comc_port->sio->Mode->Timeout; + comc_port->receivefifodepth = + comc_port->sio->Mode->ReceiveFifoDepth; + comc_port->databits = comc_port->sio->Mode->DataBits; + comc_port->parity = comc_port->sio->Mode->Parity; + comc_port->stopbits = comc_port->sio->Mode->StopBits; + } + } + + /* + * If there's no sio, then the device isn't there, so just return since + * the present flags aren't yet set. + */ + if (comc_port->sio == NULL) { + free(comc_port); + comc_port = NULL; + return; } if (env != NULL) @@ -303,8 +344,12 @@ comc_probe(struct console *sc) comc_port_set, env_nounset); env = getenv("efi_com_speed"); + if (env == NULL) + /* fallback to comconsole setting */ + env = getenv("comconsole_speed"); + if (comc_parse_intval(env, &val) == CMD_OK) - comc_port->baudrate = val; + comc_port->newbaudrate = val; if (env != NULL) unsetenv("efi_com_speed"); @@ -312,19 +357,43 @@ comc_probe(struct console *sc) env_setenv("efi_com_speed", EV_VOLATILE, value, comc_speed_set, env_nounset); - comconsole.c_flags = 0; - if (comc_setup()) + if (comc_setup()) { sc->c_flags = C_PRESENTIN | C_PRESENTOUT; + } else { + sc->c_flags &= ~(C_PRESENTIN | C_PRESENTOUT); + free(comc_port); + comc_port = NULL; + } } +#if defined(__aarch64__) && __FreeBSD_version < 1500000 +static void +comc_probe_compat(struct console *sc) +{ + comc_probe(&eficom); + if (eficom.c_flags & (C_PRESENTIN | C_PRESENTOUT)) { + printf("comconsole: comconsole device name is deprecated, switch to eficom\n"); + } + /* + * Note: We leave the present bits unset in sc to avoid ghosting. + */ +} +#endif + +/* + * Called when the console is selected in cons_change. If we didn't detect the + * device, comc_port will be NULL, and comc_setup will fail. It may be called + * even when the device isn't present as a 'fallback' console or when listed + * specifically in console env, so we have to reset the c_flags in those case to + * say it's not present. + */ static int comc_init(int arg __unused) { - if (comc_setup()) return (CMD_OK); - comconsole.c_flags = 0; + eficom.c_flags &= ~(C_ACTIVEIN | C_ACTIVEOUT); return (CMD_ERROR); } @@ -426,7 +495,7 @@ comc_port_set(struct env_var *ev, int flags, const void *value) EFI_HANDLE handle; EFI_STATUS status; - if (value == NULL) + if (value == NULL || comc_port == NULL) return (CMD_ERROR); if (comc_parse_intval(value, &port) != CMD_OK) @@ -461,16 +530,15 @@ comc_speed_set(struct env_var *ev, int flags, const void *value) { unsigned speed; - if (value == NULL) + if (value == NULL || comc_port == NULL) return (CMD_ERROR); if (comc_parse_intval(value, &speed) != CMD_OK) return (CMD_ERROR); - comc_port->baudrate = speed; - (void) comc_setup(); - - env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); + comc_port->newbaudrate = speed; + if (comc_setup()) + env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); return (CMD_OK); } @@ -483,33 +551,52 @@ static bool comc_setup(void) { EFI_STATUS status; - UINT32 control; + char *ev; - /* port is not usable */ - if (comc_port->sio == NULL) + /* + * If the device isn't active, or there's no port present. + */ + if ((eficom.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0 || comc_port == NULL) return (false); - status = comc_port->sio->Reset(comc_port->sio); - if (EFI_ERROR(status)) - return (false); + if (comc_port->sio->Reset != NULL) { + status = comc_port->sio->Reset(comc_port->sio); + if (EFI_ERROR(status)) + return (false); + } - status = comc_port->sio->SetAttributes(comc_port->sio, - comc_port->baudrate, 0, 0, comc_port->parity, - comc_port->databits, comc_port->stopbits); - if (EFI_ERROR(status)) - return (false); + /* + * Avoid setting the baud rate on Hyper-V. Also, only set the baud rate + * if the baud rate has changed from the default. And pass in '0' or + * DefaultFoo when we're not changing those values. Some EFI + * implementations get cranky when you set things to the values reported + * back even when they are unchanged. + */ + if (comc_port->sio->SetAttributes != NULL && + comc_port->newbaudrate != comc_port->baudrate) { + ev = getenv("smbios.bios.version"); + if (ev != NULL && strncmp(ev, "Hyper-V", 7) != 0) { + status = comc_port->sio->SetAttributes(comc_port->sio, + comc_port->newbaudrate, 0, 0, DefaultParity, 0, + DefaultStopBits); + if (EFI_ERROR(status)) + return (false); + comc_port->baudrate = comc_port->newbaudrate; + } + } - status = comc_port->sio->GetControl(comc_port->sio, &control); - if (EFI_ERROR(status)) - return (false); - if (comc_port->rtsdtr_off) { - control &= ~(EFI_SERIAL_REQUEST_TO_SEND | - EFI_SERIAL_DATA_TERMINAL_READY); - } else { +#ifdef EFI_FORCE_RTS + if (comc_port->sio->GetControl != NULL && comc_port->sio->SetControl != NULL) { + UINT32 control; + + status = comc_port->sio->GetControl(comc_port->sio, &control); + if (EFI_ERROR(status)) + return (false); control |= EFI_SERIAL_REQUEST_TO_SEND; + (void) comc_port->sio->SetControl(comc_port->sio, control); } - (void) comc_port->sio->SetControl(comc_port->sio, control); +#endif /* Mark this port usable. */ - comconsole.c_flags |= (C_PRESENTIN | C_PRESENTOUT); + eficom.c_flags |= (C_PRESENTIN | C_PRESENTOUT); return (true); } diff --git a/stand/efi/libefi/efienv.c b/stand/efi/libefi/efienv.c index 04df6bc00fc3..031c144ee194 100644 --- a/stand/efi/libefi/efienv.c +++ b/stand/efi/libefi/efienv.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <efi.h> #include <efichar.h> diff --git a/stand/efi/libefi/efihttp.c b/stand/efi/libefi/efihttp.c index 05d338fbaf04..081b34336cb0 100644 --- a/stand/efi/libefi/efihttp.c +++ b/stand/efi/libefi/efihttp.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2019 Intel Corporation * @@ -23,13 +23,9 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <netinet/in.h> @@ -94,7 +90,7 @@ struct devsw efihttp_dev = { .dv_close = efihttp_dev_close, .dv_ioctl = noioctl, .dv_print = NULL, - .dv_cleanup = NULL, + .dv_cleanup = nullsys, }; struct fs_ops efihttp_fsops = { diff --git a/stand/efi/libefi/efinet.c b/stand/efi/libefi/efinet.c index c52b11d32ec8..ede8b7297f17 100644 --- a/stand/efi/libefi/efinet.c +++ b/stand/efi/libefi/efinet.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <net/ethernet.h> #include <netinet/in.h> @@ -351,7 +349,7 @@ struct devsw efinet_dev = { .dv_close = NULL, /* Will be set in efinet_dev_init */ .dv_ioctl = noioctl, .dv_print = efinet_dev_print, - .dv_cleanup = NULL + .dv_cleanup = nullsys, }; static int diff --git a/stand/efi/libefi/efipart.c b/stand/efi/libefi/efipart.c index 7807c17077a6..475a796b4da5 100644 --- a/stand/efi/libefi/efipart.c +++ b/stand/efi/libefi/efipart.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/disk.h> #include <sys/param.h> #include <sys/time.h> @@ -78,7 +76,7 @@ struct devsw efipart_fddev = { .dv_close = efipart_close, .dv_ioctl = efipart_ioctl, .dv_print = efipart_printfd, - .dv_cleanup = NULL + .dv_cleanup = nullsys, }; struct devsw efipart_cddev = { @@ -90,7 +88,7 @@ struct devsw efipart_cddev = { .dv_close = efipart_close, .dv_ioctl = efipart_ioctl, .dv_print = efipart_printcd, - .dv_cleanup = NULL + .dv_cleanup = nullsys, }; struct devsw efipart_hddev = { @@ -102,7 +100,9 @@ struct devsw efipart_hddev = { .dv_close = efipart_close, .dv_ioctl = efipart_ioctl, .dv_print = efipart_printhd, - .dv_cleanup = NULL + .dv_cleanup = nullsys, + .dv_fmtdev = disk_fmtdev, + .dv_parsedev = disk_parsedev, }; static pdinfo_list_t fdinfo = STAILQ_HEAD_INITIALIZER(fdinfo); diff --git a/stand/efi/libefi/efizfs.c b/stand/efi/libefi/efizfs.c index 7f3986d47140..83551596bb32 100644 --- a/stand/efi/libefi/efizfs.c +++ b/stand/efi/libefi/efizfs.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <stand.h> @@ -115,7 +113,7 @@ efi_zfs_probe(void) snprintf(devname, sizeof(devname), "%s%dp%d:", efipart_hddev.dv_name, hd->pd_unit, pd->pd_unit); guid = 0; - if (zfs_probe_dev(devname, &guid) == 0) { + if (zfs_probe_dev(devname, &guid, false) == 0) { insert_zfs(pd->pd_handle, guid); if (pd->pd_handle == boot_img->DeviceHandle) pool_guid = guid; diff --git a/stand/efi/libefi/env.c b/stand/efi/libefi/env.c index 77e232343040..6887038fe950 100644 --- a/stand/efi/libefi/env.c +++ b/stand/efi/libefi/env.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> #include <efi.h> @@ -537,7 +535,7 @@ efi_print_global(const CHAR16 *varnamearg, uint8_t *data, UINTN datasz) goto done; } if (strncmp("Boot", var, 4) == 0 || - strncmp("Driver", var, 5) == 0 || + strncmp("Driver", var, 6) == 0 || strncmp("SysPrep", var, 7) == 0 || strncmp("OsRecovery", var, 10) == 0) { UINT16 filepathlistlen; diff --git a/stand/efi/libefi/errno.c b/stand/efi/libefi/errno.c index 0f354c3f3c8f..e614824a2bed 100644 --- a/stand/efi/libefi/errno.c +++ b/stand/efi/libefi/errno.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <efi.h> #include <efilib.h> diff --git a/stand/efi/libefi/handles.c b/stand/efi/libefi/handles.c index a55239dbec8c..bc42ae144509 100644 --- a/stand/efi/libefi/handles.c +++ b/stand/efi/libefi/handles.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <efi.h> #include <efilib.h> diff --git a/stand/efi/libefi/libefi.c b/stand/efi/libefi/libefi.c index e7b1406839fe..c33c61cdef16 100644 --- a/stand/efi/libefi/libefi.c +++ b/stand/efi/libefi/libefi.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <efi.h> #include <eficonsctl.h> #include <efilib.h> diff --git a/stand/efi/libefi/time.c b/stand/efi/libefi/time.c index fe0d2ef2702b..bab8e4f73434 100644 --- a/stand/efi/libefi/time.c +++ b/stand/efi/libefi/time.c @@ -39,8 +39,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <efi.h> #include <efilib.h> diff --git a/stand/efi/libefi/time_arm64.c b/stand/efi/libefi/time_arm64.c index baa0f8bfa1ed..616d05adb806 100644 --- a/stand/efi/libefi/time_arm64.c +++ b/stand/efi/libefi/time_arm64.c @@ -29,8 +29,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <efi.h> #include <efilib.h> diff --git a/stand/efi/libefi/time_event.c b/stand/efi/libefi/time_event.c index f171bf997078..e6aad64342ce 100644 --- a/stand/efi/libefi/time_event.c +++ b/stand/efi/libefi/time_event.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <efi.h> #include <efilib.h> diff --git a/stand/efi/libefi/wchar.c b/stand/efi/libefi/wchar.c index d0c653514366..d67f1bf34cf8 100644 --- a/stand/efi/libefi/wchar.c +++ b/stand/efi/libefi/wchar.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <efi.h> #include <efilib.h> diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile index 1edb5674712e..3ce9ac169bd1 100644 --- a/stand/efi/loader/Makefile +++ b/stand/efi/loader/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ LOADER_NET_SUPPORT?= yes LOADER_MSDOS_SUPPORT?= yes @@ -39,6 +38,8 @@ CFLAGS.bootinfo.c += -I$(SRCTOP)/sys/teken CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite +CFLAGS.main.c += -I$(SRCTOP)/sys/teken +CFLAGS.main.c += -I${SRCTOP}/contrib/pnglite CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite @@ -66,6 +67,7 @@ CFLAGS+= -DEFI .if defined(HAVE_FDT) && ${MK_FDT} != "no" .include "${BOOTSRC}/fdt.mk" LIBEFI_FDT= ${BOOTOBJ}/efi/fdt/libefi_fdt.a +HELP_FILES+= ${FDTSRC}/help.fdt .endif # Include bcache code. @@ -81,6 +83,7 @@ CFLAGS+= -DEFI_SECUREBOOT NEWVERSWHAT= "EFI loader" ${MACHINE} VERSION_FILE= ${.CURDIR}/../loader/version +HELP_FILENAME= loader.help.efi # Always add MI sources .include "${BOOTSRC}/loader.mk" @@ -103,10 +106,10 @@ LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie LDFLAGS+= -Wl,--no-dynamic-linker .endif -CLEANFILES+= loader.efi +CLEANFILES+= ${LOADER}.efi ${LOADER}.efi: ${PROG} - if ${NM} ${.ALLSRC} | grep ' U '; then \ + @if ${NM} ${.ALLSRC} | grep ' U '; then \ echo "Undefined symbols in ${.ALLSRC}"; \ exit 1; \ fi diff --git a/stand/efi/loader/Makefile.depend b/stand/efi/loader/Makefile.depend index 06e5b772c214..96a148bee2d7 100644 --- a/stand/efi/loader/Makefile.depend +++ b/stand/efi/loader/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/efi/loader/arch/amd64/Makefile.inc b/stand/efi/loader/arch/amd64/Makefile.inc index 0d9e2648cb59..00658b3b8636 100644 --- a/stand/efi/loader/arch/amd64/Makefile.inc +++ b/stand/efi/loader/arch/amd64/Makefile.inc @@ -1,4 +1,3 @@ -# $FreeBSD$ SRCS+= amd64_tramp.S \ start.S \ diff --git a/stand/efi/loader/arch/amd64/amd64_tramp.S b/stand/efi/loader/arch/amd64/amd64_tramp.S index 877705407f92..515ffc5d784d 100644 --- a/stand/efi/loader/arch/amd64/amd64_tramp.S +++ b/stand/efi/loader/arch/amd64/amd64_tramp.S @@ -1,6 +1,5 @@ /*- * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Benno Rice under sponsorship from * the FreeBSD Foundation. @@ -24,8 +23,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <machine/asmacros.h> diff --git a/stand/efi/loader/arch/amd64/elf64_freebsd.c b/stand/efi/loader/arch/amd64/elf64_freebsd.c index 4bdf675cd5a3..196efb048064 100644 --- a/stand/efi/loader/arch/amd64/elf64_freebsd.c +++ b/stand/efi/loader/arch/amd64/elf64_freebsd.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 64 #include <sys/param.h> #include <sys/exec.h> @@ -119,12 +117,6 @@ elf64_exec(struct preloaded_file *fp) /* * Report the RSDP to the kernel. While this can be found with * a BIOS boot, the RSDP may be elsewhere when booted from UEFI. - * The old code used the 'hints' method to communite this to - * the kernel. However, while convenient, the 'hints' method - * is fragile and does not work when static hints are compiled - * into the kernel. Instead, move to setting different tunables - * that start with acpi. The old 'hints' can be removed before - * we branch for FreeBSD 12. */ rsdp = efi_get_table(&acpi20_guid); @@ -133,29 +125,23 @@ elf64_exec(struct preloaded_file *fp) } if (rsdp != NULL) { sprintf(buf, "0x%016llx", (unsigned long long)rsdp); - setenv("hint.acpi.0.rsdp", buf, 1); setenv("acpi.rsdp", buf, 1); revision = rsdp->Revision; if (revision == 0) revision = 1; sprintf(buf, "%d", revision); - setenv("hint.acpi.0.revision", buf, 1); setenv("acpi.revision", buf, 1); strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId)); buf[sizeof(rsdp->OemId)] = '\0'; - setenv("hint.acpi.0.oem", buf, 1); setenv("acpi.oem", buf, 1); sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress); - setenv("hint.acpi.0.rsdt", buf, 1); setenv("acpi.rsdt", buf, 1); if (revision >= 2) { /* XXX extended checksum? */ sprintf(buf, "0x%016llx", (unsigned long long)rsdp->XsdtPhysicalAddress); - setenv("hint.acpi.0.xsdt", buf, 1); setenv("acpi.xsdt", buf, 1); sprintf(buf, "%d", rsdp->Length); - setenv("hint.acpi.0.xsdt_length", buf, 1); setenv("acpi.xsdt_length", buf, 1); } } @@ -181,7 +167,7 @@ elf64_exec(struct preloaded_file *fp) trampoline = (void *)trampcode; if (copy_staging == COPY_STAGING_ENABLE) { - PT4 = (pml4_entry_t *)0x0000000040000000; + PT4 = (pml4_entry_t *)0x0000000040000000; /* 1G */ err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 3, (EFI_PHYSICAL_ADDRESS *)&PT4); if (EFI_ERROR(err)) { diff --git a/stand/efi/loader/arch/amd64/exc.S b/stand/efi/loader/arch/amd64/exc.S index 0035d4a37e20..940bfa160161 100644 --- a/stand/efi/loader/arch/amd64/exc.S +++ b/stand/efi/loader/arch/amd64/exc.S @@ -1,6 +1,5 @@ /*- * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Konstantin Belousov under sponsorship * from the FreeBSD Foundation. @@ -25,8 +24,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ .macro EH N, err=1 diff --git a/stand/efi/loader/arch/amd64/ldscript.amd64 b/stand/efi/loader/arch/amd64/ldscript.amd64 index 874df9b08f9e..57014aefc025 100644 --- a/stand/efi/loader/arch/amd64/ldscript.amd64 +++ b/stand/efi/loader/arch/amd64/ldscript.amd64 @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd") OUTPUT_ARCH(i386:x86-64) ENTRY(_start) diff --git a/stand/efi/loader/arch/amd64/start.S b/stand/efi/loader/arch/amd64/start.S index 774ef4fa7901..34bf166c6501 100644 --- a/stand/efi/loader/arch/amd64/start.S +++ b/stand/efi/loader/arch/amd64/start.S @@ -33,7 +33,6 @@ /* * crt0-efi-x86_64.S - x86_64 EFI startup code. - * $FreeBSD$ */ .text diff --git a/stand/efi/loader/arch/amd64/trap.c b/stand/efi/loader/arch/amd64/trap.c index e8cf188cf22f..56a3ee67da6f 100644 --- a/stand/efi/loader/arch/amd64/trap.c +++ b/stand/efi/loader/arch/amd64/trap.c @@ -1,6 +1,5 @@ /*- * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Konstantin Belousov under sponsorship * from the FreeBSD Foundation. @@ -28,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> #include <sys/param.h> @@ -79,11 +76,21 @@ static uint32_t loader_tss; /* Loader TSS segment */ static struct region_descriptor fw_gdt; /* Descriptor of pristine GDT */ static EFI_PHYSICAL_ADDRESS loader_gdt_pa; /* Address of loader shadow GDT */ +struct frame { + struct frame *fr_savfp; + uintptr_t fr_savpc; +}; + void report_exc(struct trapframe *tf); void report_exc(struct trapframe *tf) { + struct frame *fp; + uintptr_t pc, base; + char buf[80]; + int ret; + base = (uintptr_t)boot_img->ImageBase; /* * printf() depends on loader runtime and UEFI firmware health * to produce the console output, in case of exception, the @@ -109,6 +116,33 @@ report_exc(struct trapframe *tf) tf->tf_rdi, tf->tf_rsi, tf->tf_rdx, tf->tf_rcx, tf->tf_r8, tf->tf_r9, tf->tf_rax, tf->tf_rbx, tf->tf_rbp, tf->tf_r10, tf->tf_r11, tf->tf_r12, tf->tf_r13, tf->tf_r14, tf->tf_r15); + + fp = (struct frame *)tf->tf_rbp; + pc = tf->tf_rip; + + printf("Stack trace:\n"); + pager_open(); + while (fp != NULL || pc != 0) { + char *source = "PC"; + + if (pc >= base && pc < base + boot_img->ImageSize) { + pc -= base; + source = "loader PC"; + } + (void) snprintf(buf, sizeof (buf), "FP %016lx: %s 0x%016lx\n", + (uintptr_t)fp, source, pc); + if (pager_output(buf)) + break; + + if (fp != NULL) + fp = fp->fr_savfp; + + if (fp != NULL) + pc = fp->fr_savpc; + else + pc = 0; + } + pager_close(); printf("Machine stopped.\n"); } diff --git a/stand/efi/loader/arch/arm/Makefile.inc b/stand/efi/loader/arch/arm/Makefile.inc index 284e517bfbb8..5761c8062117 100644 --- a/stand/efi/loader/arch/arm/Makefile.inc +++ b/stand/efi/loader/arch/arm/Makefile.inc @@ -1,7 +1,5 @@ -# $FreeBSD$ SRCS+= exec.c \ - efiserialio.c \ start.S HAVE_FDT=yes diff --git a/stand/efi/loader/arch/arm/exec.c b/stand/efi/loader/arch/arm/exec.c index a110f3d07cbc..99ee498b1b65 100644 --- a/stand/efi/loader/arch/arm/exec.c +++ b/stand/efi/loader/arch/arm/exec.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/linker.h> @@ -43,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" #include "loader_efi.h" -extern vm_offset_t md_load(char *, vm_offset_t *); extern int bi_load(char *, vm_offset_t *, vm_offset_t *, bool); static int diff --git a/stand/efi/loader/arch/arm/ldscript.arm b/stand/efi/loader/arch/arm/ldscript.arm index 68775a88a9cd..13affe12bbba 100644 --- a/stand/efi/loader/arch/arm/ldscript.arm +++ b/stand/efi/loader/arch/arm/ldscript.arm @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ OUTPUT_ARCH(arm) ENTRY(_start) SECTIONS diff --git a/stand/efi/loader/arch/arm/start.S b/stand/efi/loader/arch/arm/start.S index 5b6182d67d0a..5e4301ec7141 100644 --- a/stand/efi/loader/arch/arm/start.S +++ b/stand/efi/loader/arch/arm/start.S @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <machine/asm.h> @@ -140,6 +138,7 @@ section_table: _end_header: .text + .globl _start _start: /* Save the boot params to the stack */ push {r0, r1} diff --git a/stand/efi/loader/arch/arm64/Makefile.inc b/stand/efi/loader/arch/arm64/Makefile.inc index 9978d9c4ea9c..d19a23af0e9e 100644 --- a/stand/efi/loader/arch/arm64/Makefile.inc +++ b/stand/efi/loader/arch/arm64/Makefile.inc @@ -1,9 +1,7 @@ -# $FreeBSD$ HAVE_FDT=yes SRCS+= exec.c \ - efiserialio.c \ start.S .PATH: ${BOOTSRC}/arm64/libarm64 diff --git a/stand/efi/loader/arch/arm64/exec.c b/stand/efi/loader/arch/arm64/exec.c index 6cf4a4fd8e4d..09be15b2b6f3 100644 --- a/stand/efi/loader/arch/arm64/exec.c +++ b/stand/efi/loader/arch/arm64/exec.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> @@ -81,6 +79,13 @@ elf64_exec(struct preloaded_file *fp) int err, revision; void (*entry)(vm_offset_t); + /* + * Report the RSDP to the kernel. The old code used the 'hints' method + * to communicate this to the kernel, but this is now considered legacy. + * Instead, move to setting different tunables that start with acpi. + * The old 'hints' can be removed before we branch for FreeBSD 15. + */ + rsdp = efi_get_table(&acpi20_guid); if (rsdp == NULL) { rsdp = efi_get_table(&acpi_guid); @@ -88,23 +93,29 @@ elf64_exec(struct preloaded_file *fp) if (rsdp != NULL) { sprintf(buf, "0x%016llx", (unsigned long long)rsdp); setenv("hint.acpi.0.rsdp", buf, 1); + setenv("acpi.rsdp", buf, 1); revision = rsdp->Revision; if (revision == 0) revision = 1; sprintf(buf, "%d", revision); setenv("hint.acpi.0.revision", buf, 1); + setenv("acpi.revision", buf, 1); strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId)); buf[sizeof(rsdp->OemId)] = '\0'; setenv("hint.acpi.0.oem", buf, 1); + setenv("acpi.oem", buf, 1); sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress); setenv("hint.acpi.0.rsdt", buf, 1); + setenv("acpi.rsdt", buf, 1); if (revision >= 2) { /* XXX extended checksum? */ sprintf(buf, "0x%016llx", (unsigned long long)rsdp->XsdtPhysicalAddress); setenv("hint.acpi.0.xsdt", buf, 1); + setenv("acpi.xsdt", buf, 1); sprintf(buf, "%d", rsdp->Length); setenv("hint.acpi.0.xsdt_length", buf, 1); + setenv("acpi.xsdt_length", buf, 1); } } diff --git a/stand/efi/loader/arch/arm64/ldscript.arm64 b/stand/efi/loader/arch/arm64/ldscript.arm64 index d0ed320a319c..bacb81b5032f 100644 --- a/stand/efi/loader/arch/arm64/ldscript.arm64 +++ b/stand/efi/loader/arch/arm64/ldscript.arm64 @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* OUTPUT_FORMAT("elf64-aarch64-freebsd", "elf64-aarch64-freebsd", "elf64-aarch64-freebsd") */ @@ -16,7 +15,9 @@ SECTIONS *(.gnu.warning) *(.plt) } =0xD4200000 - . = ALIGN(16); + . = ALIGN(4096); + _etext = .; + __data_start = .; .data : { *(.rodata .rodata.* .gnu.linkonce.r.*) *(.rodata1) @@ -78,6 +79,7 @@ SECTIONS . = ALIGN(16); .dynsym : { *(.dynsym) } _edata = .; + __data_size = . - __data_start; /* Unused sections */ .interp : { *(.interp) } diff --git a/stand/efi/loader/arch/arm64/start.S b/stand/efi/loader/arch/arm64/start.S index 675d4e153f36..6e30287453c5 100644 --- a/stand/efi/loader/arch/arm64/start.S +++ b/stand/efi/loader/arch/arm64/start.S @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ /* @@ -34,11 +32,14 @@ #define IMAGE_FILE_MACHINE_ARM64 0xaa64 +#define IMAGE_FILE_EXECUTABLE 0x0002 + #define IMAGE_SCN_CNT_CODE 0x00000020 #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 #define IMAGE_SCN_MEM_EXECUTE 0x20000000 #define IMAGE_SCN_MEM_READ 0x40000000 +#define IMAGE_SCN_MEM_WRITE 0x80000000 .section .peheader,"a" efi_start: @@ -60,22 +61,22 @@ coff_head: .long 0 /* No symbol table */ .long 0 /* No symbols */ .short section_table - optional_header /* Optional header size */ - .short 0 /* Characteristics TODO: Fill in */ + .short IMAGE_FILE_EXECUTABLE /* Characteristics */ optional_header: .short 0x020b /* PE32+ (64-bit addressing) */ .byte 0 /* Major linker version */ .byte 0 /* Minor linker version */ - .long _edata - _end_header /* Code size */ - .long 0 /* No initialized data */ + .long _etext - _end_header /* Code size */ + .long __data_size /* Initialized data size */ .long 0 /* No uninitialized data */ .long _start - efi_start /* Entry point */ .long _end_header - efi_start /* Start of code */ optional_windows_header: .quad 0 /* Image base */ - .long 32 /* Section Alignment */ - .long 8 /* File alignment */ + .long 4096 /* Section Alignment */ + .long 512 /* File alignment */ .short 0 /* Major OS version */ .short 0 /* Minor OS version */ .short 0 /* Major image version */ @@ -104,36 +105,37 @@ optional_windows_header: .quad 0 section_table: - /* We need a .reloc section for EFI */ - .ascii ".reloc" + .ascii ".text" + .byte 0 .byte 0 .byte 0 /* Pad to 8 bytes */ - .long 0 /* Virtual size */ - .long 0 /* Virtual address */ - .long 0 /* Size of raw data */ - .long 0 /* Pointer to raw data */ + .long _etext - _end_header /* Virtual size */ + .long _end_header - efi_start /* Virtual address */ + .long _etext - _end_header /* Size of raw data */ + .long _end_header - efi_start /* Pointer to raw data */ .long 0 /* Pointer to relocations */ .long 0 /* Pointer to line numbers */ .short 0 /* Number of relocations */ .short 0 /* Number of line numbers */ - .long (IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | \ - IMAGE_SCN_MEM_DISCARDABLE) /* Characteristics */ + .long (IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | \ + IMAGE_SCN_MEM_READ) /* Characteristics */ - /* The contents of the loader */ - .ascii ".text" + .ascii ".data" .byte 0 .byte 0 .byte 0 /* Pad to 8 bytes */ - .long _edata - _end_header /* Virtual size */ - .long _end_header - efi_start /* Virtual address */ - .long _edata - _end_header /* Size of raw data */ - .long _end_header - efi_start /* Pointer to raw data */ + .long __data_size /* Virtual size */ + .long __data_start - efi_start /* Virtual address */ + .long __data_size /* Size of raw data */ + .long __data_start - efi_start /* Pointer to raw data */ .long 0 /* Pointer to relocations */ .long 0 /* Pointer to line numbers */ .short 0 /* Number of relocations */ .short 0 /* Number of line numbers */ - .long (IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | \ - IMAGE_SCN_MEM_READ) /* Characteristics */ + .long (IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | \ + IMAGE_SCN_MEM_WRITE) /* Characteristics */ + + .align 12 _end_header: .text diff --git a/stand/efi/loader/arch/i386/Makefile.inc b/stand/efi/loader/arch/i386/Makefile.inc deleted file mode 100644 index fcdb6324b2f0..000000000000 --- a/stand/efi/loader/arch/i386/Makefile.inc +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ - -SRCS+= start.S \ - elf32_freebsd.c \ - exec.c - -.PATH: ${BOOTSRC}/i386/libi386 -SRCS+= nullconsole.c \ - comconsole.c \ - spinconsole.c - -CFLAGS+= -fPIC -LDFLAGS+= -Wl,-znocombreloc diff --git a/stand/efi/loader/arch/i386/elf32_freebsd.c b/stand/efi/loader/arch/i386/elf32_freebsd.c deleted file mode 100644 index 97d114f09610..000000000000 --- a/stand/efi/loader/arch/i386/elf32_freebsd.c +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/exec.h> -#include <sys/linker.h> -#include <string.h> -#include <machine/bootinfo.h> -#include <machine/elf.h> -#include <stand.h> - -#include <efi.h> -#include <efilib.h> - -#include "bootstrap.h" -#include "../libi386/libi386.h" -#include "../btx/lib/btxv86.h" - -extern void __exec(caddr_t addr, ...); -extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, - bool exit_bs); - -static int elf32_exec(struct preloaded_file *amp); -static int elf32_obj_exec(struct preloaded_file *amp); - -struct file_format i386_elf = { elf32_loadfile, elf32_exec }; -struct file_format i386_elf_obj = { elf32_obj_loadfile, elf32_obj_exec }; - -struct file_format *file_formats[] = { - &i386_elf, - &i386_elf_obj, - NULL -}; - -/* - * There is an ELF kernel and one or more ELF modules loaded. - * We wish to start executing the kernel image, so make such - * preparations as are required, and do so. - */ -static int -elf32_exec(struct preloaded_file *fp) -{ - struct file_metadata *md; - Elf_Ehdr *ehdr; - vm_offset_t entry, bootinfop, modulep, kernend; - int boothowto, err, bootdev; - - if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) - return(EFTYPE); - ehdr = (Elf_Ehdr *)&(md->md_data); - - efi_time_fini(); - - entry = ehdr->e_entry & 0xffffff; - - printf("Start @ 0x%x ...\n", entry); - - err = bi_load(fp->f_args, &modulep, &kernend, true); - if (err != 0) { - efi_time_init(); - return(err); - } - - /* At this point we've called ExitBootServices, so we can't call - * printf or any other function that uses Boot Services */ - - dev_cleanup(); - __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop, modulep, kernend); - - panic("exec returned"); -} - -static int -elf32_obj_exec(struct preloaded_file *fp) -{ - return (EFTYPE); -} diff --git a/stand/efi/loader/arch/i386/exec.c b/stand/efi/loader/arch/i386/exec.c deleted file mode 100644 index 579f5593b24b..000000000000 --- a/stand/efi/loader/arch/i386/exec.c +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * Copyright (c) 2010 Rui Paulo <rpaulo@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stand.h> -#include <machine/elf.h> -#include "../btx/lib/btxv86.h" - -#include "../../common/bootstrap.h" - -uint32_t __base; -struct __v86 __v86; - -void -__v86int() -{ - printf("%s\n", __func__); - exit(1); -} - -void -__exec(caddr_t addr, ...) -{ -} diff --git a/stand/efi/loader/arch/i386/i386_copy.c b/stand/efi/loader/arch/i386/i386_copy.c deleted file mode 100644 index 2c4b0deb49cf..000000000000 --- a/stand/efi/loader/arch/i386/i386_copy.c +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -/* - * MD primitives supporting placement of module data - * - * XXX should check load address/size against memory top. - */ -#include <stand.h> - -#include "libi386.h" -#include "btxv86.h" - -ssize_t -i386_copyin(const void *src, vm_offset_t dest, const size_t len) -{ - bcopy(src, PTOV(dest), len); - return(len); -} - -ssize_t -i386_copyout(const vm_offset_t src, void *dest, const size_t len) -{ - bcopy(PTOV(src), dest, len); - return(len); -} - -ssize_t -i386_readin(readin_handle_t fd, vm_offset_t dest, const size_t len) -{ - return (VECTX_READ(fd, PTOV(dest), len)); -} diff --git a/stand/efi/loader/arch/i386/start.S b/stand/efi/loader/arch/i386/start.S deleted file mode 100644 index b597f419d4a1..000000000000 --- a/stand/efi/loader/arch/i386/start.S +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 2008-2010 Rui Paulo <rpaulo@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - - .text - -#include <machine/asm.h> - -#define EFI_SUCCESS 0 - -/* - * EFI entry point. - * _start(EFI_IMAGE image_handle, EFI_SYSTEM_TABLE *system_table); - * - * We calculate the base address along with _DYNAMIC, relocate us and finally - * pass control to efi_main. - */ - -ENTRY(_start) - pushl %ebp - movl %esp, %ebp - - pushl 12(%ebp) /* image_handle */ - pushl 8(%ebp) /* system_table */ - call 0f -0: popl %eax - movl %eax, %ebx - addl $ImageBase-0b, %eax - addl $_DYNAMIC-0b, %ebx - pushl %ebx /* dynamic */ - pushl %eax /* ImageBase */ - call self_reloc - popl %ebx /* remove ImageBase from the stack */ - popl %ebx /* remove dynamic from the stack */ - call efi_main -1: leave - ret -END(_start) - - .data - .section .reloc, "a" - .long 0 - .long 10 - .word 0 diff --git a/stand/efi/loader/arch/riscv/Makefile.inc b/stand/efi/loader/arch/riscv/Makefile.inc index 333b789e935d..c25f63c0b3b7 100644 --- a/stand/efi/loader/arch/riscv/Makefile.inc +++ b/stand/efi/loader/arch/riscv/Makefile.inc @@ -1,7 +1,5 @@ -# $FreeBSD$ HAVE_FDT=yes SRCS+= exec.c \ - efiserialio.c \ start.S diff --git a/stand/efi/loader/arch/riscv/exec.c b/stand/efi/loader/arch/riscv/exec.c index c7d90a4f31d0..686a42028608 100644 --- a/stand/efi/loader/arch/riscv/exec.c +++ b/stand/efi/loader/arch/riscv/exec.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/linker.h> diff --git a/stand/efi/loader/arch/riscv/ldscript.riscv b/stand/efi/loader/arch/riscv/ldscript.riscv index aa736f0d9b2a..342ec62cf03e 100644 --- a/stand/efi/loader/arch/riscv/ldscript.riscv +++ b/stand/efi/loader/arch/riscv/ldscript.riscv @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") OUTPUT_ARCH(riscv64) ENTRY(_start) diff --git a/stand/efi/loader/arch/riscv/start.S b/stand/efi/loader/arch/riscv/start.S index e63ce68d86ba..fb7d65f17c99 100644 --- a/stand/efi/loader/arch/riscv/start.S +++ b/stand/efi/loader/arch/riscv/start.S @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2020 Mitchell Horne <mhorne@FreeBSD.org> * @@ -23,8 +23,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <machine/asm.h> diff --git a/stand/efi/loader/autoload.c b/stand/efi/loader/autoload.c index d409285834c3..a7a5f8212e9c 100644 --- a/stand/efi/loader/autoload.c +++ b/stand/efi/loader/autoload.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #if defined(LOADER_FDT_SUPPORT) #include <sys/param.h> #include <fdt_platform.h> diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c index c7b682819a98..f47d81e23591 100644 --- a/stand/efi/loader/bootinfo.c +++ b/stand/efi/loader/bootinfo.c @@ -27,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> #include <sys/param.h> @@ -40,17 +38,24 @@ __FBSDID("$FreeBSD$"); #include <machine/metadata.h> #include <machine/psl.h> +#ifdef EFI #include <efi.h> #include <efilib.h> +#else +#include "kboot.h" +#endif #include "bootstrap.h" -#include "loader_efi.h" +#include "modinfo.h" #if defined(__amd64__) #include <machine/specialreg.h> #endif +#ifdef EFI +#include "loader_efi.h" #include "gfx_fb.h" +#endif #if defined(LOADER_FDT_SUPPORT) #include <fdt_platform.h> @@ -66,11 +71,14 @@ int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, static int bi_getboothowto(char *kargs) { +#ifdef EFI const char *sw, *tmp; char *opts; - char *console; - int howto, speed, port; + int speed, port; char buf[50]; +#endif + char *console; + int howto; howto = boot_parse_cmdline(kargs); howto |= boot_env_to_howto(); @@ -81,6 +89,7 @@ bi_getboothowto(char *kargs) howto |= RB_SERIAL; if (strcmp(console, "nullconsole") == 0) howto |= RB_MUTE; +#ifdef EFI #if defined(__i386__) || defined(__amd64__) if (strcmp(console, "efi") == 0 && getenv("efi_8250_uid") != NULL && @@ -108,10 +117,17 @@ bi_getboothowto(char *kargs) if (tmp != NULL) speed = strtol(tmp, NULL, 0); tmp = getenv("efi_com_port"); - if (tmp == NULL) - tmp = getenv("comconsole_port"); if (tmp != NULL) port = strtol(tmp, NULL, 0); + if (port <= 0) { + tmp = getenv("comconsole_port"); + if (tmp != NULL) + port = strtol(tmp, NULL, 0); + else { + if (port == 0) + port = 0x3f8; + } + } if (speed != -1 && port != -1) { snprintf(buf, sizeof(buf), "io:%d,br:%d", port, speed); @@ -120,139 +136,13 @@ bi_getboothowto(char *kargs) } } #endif +#endif } return (howto); } -/* - * Copy the environment into the load area starting at (addr). - * Each variable is formatted as <name>=<value>, with a single nul - * separating each variable, and a double nul terminating the environment. - */ -static vm_offset_t -bi_copyenv(vm_offset_t start) -{ - struct env_var *ep; - vm_offset_t addr, last; - size_t len; - - addr = last = start; - - /* Traverse the environment. */ - for (ep = environ; ep != NULL; ep = ep->ev_next) { - len = strlen(ep->ev_name); - if ((size_t)archsw.arch_copyin(ep->ev_name, addr, len) != len) - break; - addr += len; - if (archsw.arch_copyin("=", addr, 1) != 1) - break; - addr++; - if (ep->ev_value != NULL) { - len = strlen(ep->ev_value); - if ((size_t)archsw.arch_copyin(ep->ev_value, addr, len) != len) - break; - addr += len; - } - if (archsw.arch_copyin("", addr, 1) != 1) - break; - last = ++addr; - } - - if (archsw.arch_copyin("", last++, 1) != 1) - last = start; - return(last); -} - -/* - * Copy module-related data into the load area, where it can be - * used as a directory for loaded modules. - * - * Module data is presented in a self-describing format. Each datum - * is preceded by a 32-bit identifier and a 32-bit size field. - * - * Currently, the following data are saved: - * - * MOD_NAME (variable) module name (string) - * MOD_TYPE (variable) module type (string) - * MOD_ARGS (variable) module parameters (string) - * MOD_ADDR sizeof(vm_offset_t) module load address - * MOD_SIZE sizeof(size_t) module size - * MOD_METADATA (variable) type-specific metadata - */ -#define COPY32(v, a, c) { \ - uint32_t x = (v); \ - if (c) \ - archsw.arch_copyin(&x, a, sizeof(x)); \ - a += sizeof(x); \ -} - -#define MOD_STR(t, a, s, c) { \ - COPY32(t, a, c); \ - COPY32(strlen(s) + 1, a, c); \ - if (c) \ - archsw.arch_copyin(s, a, strlen(s) + 1); \ - a += roundup(strlen(s) + 1, sizeof(u_long)); \ -} - -#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) -#define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c) -#define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c) - -#define MOD_VAR(t, a, s, c) { \ - COPY32(t, a, c); \ - COPY32(sizeof(s), a, c); \ - if (c) \ - archsw.arch_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), sizeof(u_long)); \ -} - -#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) -#define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c) - -#define MOD_METADATA(a, mm, c) { \ - COPY32(MODINFO_METADATA | mm->md_type, a, c); \ - COPY32(mm->md_size, a, c); \ - if (c) \ - archsw.arch_copyin(mm->md_data, a, mm->md_size); \ - a += roundup(mm->md_size, sizeof(u_long)); \ -} - -#define MOD_END(a, c) { \ - COPY32(MODINFO_END, a, c); \ - COPY32(0, a, c); \ -} - -static vm_offset_t -bi_copymodules(vm_offset_t addr) -{ - struct preloaded_file *fp; - struct file_metadata *md; - int c; - uint64_t v; - - c = addr != 0; - /* Start with the first module on the list, should be the kernel. */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - MOD_NAME(addr, fp->f_name, c); /* This must come first. */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - v = fp->f_addr; -#if defined(__arm__) - v -= __elfN(relocation_offset); -#endif - MOD_ADDR(addr, v, c); - v = fp->f_size; - MOD_SIZE(addr, v, c); - for (md = fp->f_metadata; md != NULL; md = md->md_next) - if (!(md->md_type & MODINFOMD_NOCOPY)) - MOD_METADATA(addr, md, c); - } - MOD_END(addr, c); - return(addr); -} - +#ifdef EFI static EFI_STATUS efi_do_vmap(EFI_MEMORY_DESCRIPTOR *mm, UINTN sz, UINTN mmsz, UINT32 mmver) { @@ -309,16 +199,19 @@ bi_load_efi_data(struct preloaded_file *kfp, bool exit_bs) efifb.fb_mask_blue = gfx_state.tg_fb.fb_mask_blue; efifb.fb_mask_reserved = gfx_state.tg_fb.fb_mask_reserved; - printf("EFI framebuffer information:\n"); - printf("addr, size 0x%jx, 0x%jx\n", efifb.fb_addr, efifb.fb_size); - printf("dimensions %d x %d\n", efifb.fb_width, efifb.fb_height); - printf("stride %d\n", efifb.fb_stride); - printf("masks 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", - efifb.fb_mask_red, efifb.fb_mask_green, efifb.fb_mask_blue, - efifb.fb_mask_reserved); + if (efifb.fb_addr != 0) { + printf("EFI framebuffer information:\n"); + printf("addr, size 0x%jx, 0x%jx\n", + efifb.fb_addr, efifb.fb_size); + printf("dimensions %d x %d\n", + efifb.fb_width, efifb.fb_height); + printf("stride %d\n", efifb.fb_stride); + printf("masks 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", + efifb.fb_mask_red, efifb.fb_mask_green, efifb.fb_mask_blue, + efifb.fb_mask_reserved); - if (efifb.fb_addr != 0) file_addmetadata(kfp, MODINFOMD_EFI_FB, sizeof(efifb), &efifb); + } #endif do_vmap = true; @@ -421,6 +314,7 @@ bi_load_efi_data(struct preloaded_file *kfp, bool exit_bs) return (0); } +#endif /* * Load the information expected by an amd64 kernel. @@ -438,11 +332,15 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) struct devdesc *rootdev; struct file_metadata *md; vm_offset_t addr; - uint64_t kernend, module; + uint64_t kernend; +#ifdef MODINFOMD_MODULEP + uint64_t module; +#endif uint64_t envp; vm_offset_t size; char *rootdevname; int howto; + bool is64 = sizeof(long) == 8; #if defined(LOADER_FDT_SUPPORT) vm_offset_t dtbp; int dtb_size; @@ -462,7 +360,6 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) #endif }; #endif - howto = bi_getboothowto(args); /* @@ -478,11 +375,11 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) } /* Try reading the /etc/fstab file to select the root device */ - getrootmount(efi_fmtdev((void *)rootdev)); + getrootmount(devformat(rootdev)); addr = 0; for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) { - if (addr < (xp->f_addr + xp->f_size)) + if (addr < xp->f_addr + xp->f_size) addr = xp->f_addr + xp->f_size; } @@ -496,7 +393,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) /* Copy our environment. */ envp = addr; - addr = bi_copyenv(addr); + addr = md_copyenv(addr); /* Pad to a page boundary. */ addr = roundup(addr, PAGE_SIZE); @@ -519,7 +416,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) kernend = 0; /* fill it in later */ /* Figure out the size and location of the metadata. */ - module = *modulep = addr; + *modulep = addr; file_addmetadata(kfp, MODINFOMD_HOWTO, sizeof(howto), &howto); file_addmetadata(kfp, MODINFOMD_ENVP, sizeof(envp), &envp); @@ -532,15 +429,22 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) #endif file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof(kernend), &kernend); #ifdef MODINFOMD_MODULEP + module = *modulep; file_addmetadata(kfp, MODINFOMD_MODULEP, sizeof(module), &module); #endif +#ifdef EFI file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof(ST), &ST); +#endif #ifdef LOADER_GELI_SUPPORT geli_export_key_metadata(kfp); #endif +#ifdef EFI bi_load_efi_data(kfp, exit_bs); +#else + bi_loadsmap(kfp); +#endif - size = bi_copymodules(0); + size = md_copymodules(0, is64); /* Find the size of the modules */ kernend = roundup(addr + size, PAGE_SIZE); *kernendp = kernend; @@ -565,7 +469,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) #endif /* Copy module list and metadata. */ - (void)bi_copymodules(addr); + (void)md_copymodules(addr, is64); return (0); } diff --git a/stand/efi/loader/conf.c b/stand/efi/loader/conf.c index 863c9188c72c..389489726d84 100644 --- a/stand/efi/loader/conf.c +++ b/stand/efi/loader/conf.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <bootstrap.h> #include <efi.h> @@ -80,16 +78,25 @@ struct netif_driver *netif_drivers[] = { }; extern struct console efi_console; +extern struct console eficom; +#if defined(__aarch64__) && __FreeBSD_version < 1500000 +/* Hack for backward compatibility -- but only for a while */ +extern struct console comconsole; +#endif +#if defined(__amd64__) extern struct console comconsole; -#if defined(__amd64__) || defined(__i386__) extern struct console nullconsole; extern struct console spinconsole; #endif struct console *consoles[] = { &efi_console, + &eficom, +#if defined(__aarch64__) && __FreeBSD_version < 1500000 + &comconsole, +#endif +#if defined(__amd64__) &comconsole, -#if defined(__amd64__) || defined(__i386__) &nullconsole, &spinconsole, #endif diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index 47e613ccc2f3..12f7273edacd 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -1,6 +1,5 @@ /*- * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Benno Rice under sponsorship from * the FreeBSD Foundation. @@ -27,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <stand.h> @@ -42,7 +39,7 @@ __FBSDID("$FreeBSD$"); #define M(x) ((x) * 1024 * 1024) #define G(x) (1UL * (x) * 1024 * 1024 * 1024) -#if defined(__i386__) || defined(__amd64__) +#if defined(__amd64__) #include <machine/cpufunc.h> #include <machine/specialreg.h> #include <machine/vmparam.h> @@ -174,7 +171,7 @@ efi_verify_staging_size(unsigned long *nr_pages) out: free(map); } -#endif /* __i386__ || __amd64__ */ +#endif /* __amd64__ */ #if defined(__arm__) #define DEFAULT_EFI_STAGING_SIZE 32 @@ -201,7 +198,7 @@ out: static u_long staging_slop = EFI_STAGING_SLOP; EFI_PHYSICAL_ADDRESS staging, staging_end, staging_base; -int stage_offset_set = 0; +bool stage_offset_set = false; ssize_t stage_offset; static void @@ -209,7 +206,7 @@ efi_copy_free(void) { BS->FreePages(staging_base, (staging_end - staging_base) / EFI_PAGE_SIZE); - stage_offset_set = 0; + stage_offset_set = false; stage_offset = 0; } @@ -285,9 +282,9 @@ command_staging_slop(int argc, char *argv[]) COMMAND_SET(staging_slop, "staging_slop", "set staging slop", command_staging_slop); -#if defined(__i386__) || defined(__amd64__) +#if defined(__amd64__) /* - * The staging area must reside in the the first 1GB or 4GB physical + * The staging area must reside in the first 1GB or 4GB physical * memory: see elf64_exec() in * boot/efi/loader/arch/amd64/elf64_freebsd.c. */ @@ -296,11 +293,7 @@ get_staging_max(void) { EFI_PHYSICAL_ADDRESS res; -#if defined(__i386__) - res = G(1); -#elif defined(__amd64__) res = copy_staging == COPY_STAGING_ENABLE ? G(1) : G(4); -#endif return (res); } #define EFI_ALLOC_METHOD AllocateMaxAddress @@ -320,7 +313,7 @@ efi_copy_init(void) ess = DEFAULT_EFI_STAGING_SIZE; nr_pages = EFI_SIZE_TO_PAGES(M(1) * ess); -#if defined(__i386__) || defined(__amd64__) +#if defined(__amd64__) /* * We'll decrease nr_pages, if it's too big. Currently we only * apply this to FreeBSD VM running on Hyper-V. Why? Please see @@ -331,7 +324,7 @@ efi_copy_init(void) staging = get_staging_max(); #endif - status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderData, + status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderCode, nr_pages, &staging); if (EFI_ERROR(status)) { printf("failed to allocate staging area: %lu\n", @@ -388,9 +381,8 @@ efi_check_space(vm_offset_t end) end += staging_slop; nr_pages = EFI_SIZE_TO_PAGES(end - staging_end); -#if defined(__i386__) || defined(__amd64__) +#if defined(__amd64__) /* - * i386 needs all memory to be allocated under the 1G boundary. * amd64 needs all memory to be allocated under the 1G or 4G boundary. */ if (end > get_staging_max()) @@ -399,7 +391,7 @@ efi_check_space(vm_offset_t end) /* Try to allocate more space after the previous allocation */ addr = staging_end; - status = BS->AllocatePages(AllocateAddress, EfiLoaderData, nr_pages, + status = BS->AllocatePages(AllocateAddress, EfiLoaderCode, nr_pages, &addr); if (!EFI_ERROR(status)) { staging_end = staging_end + nr_pages * EFI_PAGE_SIZE; @@ -416,7 +408,7 @@ before_staging: addr = rounddown2(addr, M(2)); #endif nr_pages = EFI_SIZE_TO_PAGES(staging_base - addr); - status = BS->AllocatePages(AllocateAddress, EfiLoaderData, nr_pages, + status = BS->AllocatePages(AllocateAddress, EfiLoaderCode, nr_pages, &addr); if (!EFI_ERROR(status)) { /* @@ -436,10 +428,10 @@ expand: #if EFI_STAGING_2M_ALIGN nr_pages += M(2) / EFI_PAGE_SIZE; #endif -#if defined(__i386__) || defined(__amd64__) +#if defined(__amd64__) new_base = get_staging_max(); #endif - status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderData, + status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderCode, nr_pages, &new_base); if (!EFI_ERROR(status)) { #if EFI_STAGING_2M_ALIGN @@ -479,7 +471,7 @@ efi_copyin(const void *src, vm_offset_t dest, const size_t len) if (!stage_offset_set) { stage_offset = (vm_offset_t)staging - dest; - stage_offset_set = 1; + stage_offset_set = true; } /* XXX: Callers do not check for failure. */ @@ -510,7 +502,7 @@ efi_readin(readin_handle_t fd, vm_offset_t dest, const size_t len) if (!stage_offset_set) { stage_offset = (vm_offset_t)staging - dest; - stage_offset_set = 1; + stage_offset_set = true; } if (!efi_check_space(dest + stage_offset + len)) { diff --git a/stand/efi/loader/efi_main.c b/stand/efi/loader/efi_main.c index 3e1fa06638e9..25b13d5d3728 100644 --- a/stand/efi/loader/efi_main.c +++ b/stand/efi/loader/efi_main.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <bootstrap.h> #include <efi.h> #include <eficonsctl.h> diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c index d5504c9cff35..b8e61dc73acf 100644 --- a/stand/efi/loader/framebuffer.c +++ b/stand/efi/loader/framebuffer.c @@ -1,6 +1,5 @@ /*- * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Benno Rice under sponsorship from * the FreeBSD Foundation. @@ -27,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <bootstrap.h> #include <sys/endian.h> #include <sys/param.h> @@ -536,6 +533,21 @@ efifb_get_edid(edid_res_list_t *res) return (rv); } +bool +efi_has_gop(void) +{ + EFI_STATUS status; + EFI_HANDLE *hlist; + UINTN hsize; + + hsize = 0; + hlist = NULL; + status = BS->LocateHandle(ByProtocol, &gop_guid, NULL, &hsize, hlist); + + return (status == EFI_BUFFER_TOO_SMALL); +} + + int efi_find_framebuffer(teken_gfx_t *gfx_state) { diff --git a/stand/efi/loader/framebuffer.h b/stand/efi/loader/framebuffer.h index 008df7f6c167..c6015f4ccbd3 100644 --- a/stand/efi/loader/framebuffer.h +++ b/stand/efi/loader/framebuffer.h @@ -1,6 +1,5 @@ /*- * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Benno Rice under sponsorship from * the FreeBSD Foundation. @@ -24,15 +23,15 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include <teken.h> #include <gfx_fb.h> #ifndef _EFIFB_H_ #define _EFIFB_H_ +bool efi_has_gop(void); int efi_find_framebuffer(teken_gfx_t *gfx_state); #endif /* _EFIFB_H_ */ diff --git a/stand/efi/loader/loader_efi.h b/stand/efi/loader/loader_efi.h index 8254d16b1592..249860aa5e91 100644 --- a/stand/efi/loader/loader_efi.h +++ b/stand/efi/loader/loader_efi.h @@ -1,6 +1,5 @@ /*- * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Benno Rice under sponsorship from * the FreeBSD Foundation. @@ -24,8 +23,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _LOADER_EFI_COPY_H_ @@ -33,6 +30,7 @@ #include <stand.h> #include <readin.h> +#include <efi.h> #ifdef __amd64__ enum { @@ -43,6 +41,8 @@ enum { extern int copy_staging; #endif +extern EFI_LOADED_IMAGE *boot_img; + int efi_autoload(void); int efi_copy_init(void); diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index eb143989190d..11b10dd44d5e 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -28,8 +28,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/disk.h> @@ -60,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include <smbios.h> #include "efizfs.h" +#include "framebuffer.h" #include "loader_efi.h" @@ -185,25 +184,11 @@ out: } static void -set_currdev(const char *devname) -{ - - env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev, - env_nounset); - /* - * Don't execute hook here; the loaddev hook makes it immutable - * once we've determined what the proper currdev is. - */ - env_setenv("loaddev", EV_VOLATILE | EV_NOHOOK, devname, env_noset, - env_nounset); -} - -static void set_currdev_devdesc(struct devdesc *currdev) { const char *devname; - devname = efi_fmtdev(currdev); + devname = devformat(currdev); printf("Setting currdev to %s\n", devname); set_currdev(devname); } @@ -263,34 +248,26 @@ sanity_check_currdev(void) static bool probe_zfs_currdev(uint64_t guid) { + char buf[VDEV_PAD_SIZE]; char *devname; struct zfs_devdesc currdev; - char *buf = NULL; - bool rv; currdev.dd.d_dev = &zfs_dev; currdev.dd.d_unit = 0; currdev.pool_guid = guid; currdev.root_guid = 0; set_currdev_devdesc((struct devdesc *)&currdev); - devname = efi_fmtdev(&currdev); + devname = devformat(&currdev.dd); init_zfs_boot_options(devname); - rv = sanity_check_currdev(); - if (rv) { - buf = malloc(VDEV_PAD_SIZE); - if (buf != NULL) { - if (zfs_get_bootonce(&currdev, OS_BOOTONCE, buf, - VDEV_PAD_SIZE) == 0) { - printf("zfs bootonce: %s\n", buf); - set_currdev(buf); - setenv("zfs-bootonce", buf, 1); - } - free(buf); - (void) zfs_attach_nvstore(&currdev); - } + if (zfs_get_bootonce(&currdev, OS_BOOTONCE, buf, sizeof(buf)) == 0) { + printf("zfs bootonce: %s\n", buf); + set_currdev(buf); + setenv("zfs-bootonce", buf, 1); } - return (rv); + (void)zfs_attach_nvstore(&currdev); + + return (sanity_check_currdev()); } #endif @@ -701,8 +678,7 @@ interactive_interrupt(const char *msg) static int parse_args(int argc, CHAR16 *argv[]) { - int i, j, howto; - bool vargood; + int i, howto; char var[128]; /* @@ -719,7 +695,7 @@ parse_args(int argc, CHAR16 *argv[]) * method is flawed for non-ASCII characters). */ howto = 0; - for (i = 1; i < argc; i++) { + for (i = 0; i < argc; i++) { cpy16to8(argv[i], var, sizeof(var)); howto |= boot_parse_arg(var); } @@ -760,8 +736,20 @@ parse_uefi_con_out(void) if (rv != EFI_SUCCESS) rv = efi_global_getenv("ConOutDev", buf, &sz); if (rv != EFI_SUCCESS) { - /* If we don't have any ConOut default to serial */ - how = RB_SERIAL; + /* + * If we don't have any ConOut default to both. If we have GOP + * make video primary, otherwise just make serial primary. In + * either case, try to use both the 'efi' console which will use + * the GOP, if present and serial. If there's an EFI BIOS that + * omits this, but has a serial port redirect, we'll + * unavioidably get doubled characters (but we'll be right in + * all the other more common cases). + */ + if (efi_has_gop()) + how = RB_MULTIPLE; + else + how = RB_MULTIPLE | RB_SERIAL; + setenv("console", "efi,comconsole", 1); goto out; } ep = buf + sz; @@ -935,6 +923,22 @@ main(int argc, CHAR16 *argv[]) archsw.arch_readin = efi_readin; archsw.arch_zfs_probe = efi_zfs_probe; +#if !defined(__arm__) + for (k = 0; k < ST->NumberOfTableEntries; k++) { + guid = &ST->ConfigurationTable[k].VendorGuid; + if (!memcmp(guid, &smbios, sizeof(EFI_GUID)) || + !memcmp(guid, &smbios3, sizeof(EFI_GUID))) { + char buf[40]; + + snprintf(buf, sizeof(buf), "%p", + ST->ConfigurationTable[k].VendorTable); + setenv("hint.smbios.0.mem", buf, 1); + smbios_detect(ST->ConfigurationTable[k].VendorTable); + break; + } + } +#endif + /* Get our loaded image protocol interface structure. */ (void) OpenProtocolByHandle(IH, &imgid, (void **)&boot_img); @@ -949,13 +953,16 @@ main(int argc, CHAR16 *argv[]) setenv("console", "efi", 1); uhowto = parse_uefi_con_out(); #if defined(__riscv) + /* + * This workaround likely is papering over a real issue + */ if ((uhowto & RB_SERIAL) != 0) setenv("console", "comconsole", 1); #endif cons_probe(); /* Set up currdev variable to have hooks in place. */ - env_setenv("currdev", EV_VOLATILE, "", efi_setcurrdev, env_nounset); + env_setenv("currdev", EV_VOLATILE, "", gen_setcurrdev, env_nounset); /* Init the time source */ efi_time_init(); @@ -975,9 +982,7 @@ main(int argc, CHAR16 *argv[]) "failures\n", i); } - for (i = 0; devsw[i] != NULL; i++) - if (devsw[i]->dv_init != NULL) - (devsw[i]->dv_init)(); + devinit(); /* * Detect console settings two different ways: one via the command @@ -1055,10 +1060,8 @@ main(int argc, CHAR16 *argv[]) */ boot_howto_to_env(howto); - if (efi_copy_init()) { - printf("failed to allocate staging area\n"); + if (efi_copy_init()) return (EFI_BUFFER_TOO_SMALL); - } if ((s = getenv("fail_timeout")) != NULL) fail_timeout = strtol(s, NULL, 10); @@ -1185,21 +1188,6 @@ main(int argc, CHAR16 *argv[]) autoload_font(false); /* Set up the font list for console. */ efi_init_environment(); -#if !defined(__arm__) - for (k = 0; k < ST->NumberOfTableEntries; k++) { - guid = &ST->ConfigurationTable[k].VendorGuid; - if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { - char buf[40]; - - snprintf(buf, sizeof(buf), "%p", - ST->ConfigurationTable[k].VendorTable); - setenv("hint.smbios.0.mem", buf, 1); - smbios_detect(ST->ConfigurationTable[k].VendorTable); - break; - } - } -#endif - interact(); /* doesn't return */ return (EFI_SUCCESS); /* keep compiler happy */ @@ -1280,15 +1268,6 @@ command_reboot(int argc, char *argv[]) return (CMD_ERROR); } -COMMAND_SET(quit, "quit", "exit the loader", command_quit); - -static int -command_quit(int argc, char *argv[]) -{ - exit(0); - return (CMD_OK); -} - COMMAND_SET(memmap, "memmap", "print memory map", command_memmap); static int diff --git a/stand/efi/loader/version b/stand/efi/loader/version index 3a4c47c5efb1..2bed97c231d2 100644 --- a/stand/efi/loader/version +++ b/stand/efi/loader/version @@ -1,4 +1,3 @@ -$FreeBSD$ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this file is important. Make sure the current version number is on line 6. diff --git a/stand/efi/loader_4th/Makefile b/stand/efi/loader_4th/Makefile index 3659f7efe673..3ca078668437 100644 --- a/stand/efi/loader_4th/Makefile +++ b/stand/efi/loader_4th/Makefile @@ -1,6 +1,6 @@ -# $FreeBSD$ LOADER_INTERP=4th +INSTALL_LOADER_HELP_FILE=no .include "../loader/Makefile" diff --git a/stand/efi/loader_4th/Makefile.depend b/stand/efi/loader_4th/Makefile.depend new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/stand/efi/loader_4th/Makefile.depend diff --git a/stand/efi/loader_lua/Makefile b/stand/efi/loader_lua/Makefile index 3a4268440cf6..6866e742290a 100644 --- a/stand/efi/loader_lua/Makefile +++ b/stand/efi/loader_lua/Makefile @@ -1,6 +1,6 @@ -# $FreeBSD$ LOADER_INTERP=lua +INSTALL_LOADER_HELP_FILE=no .include "../loader/Makefile" diff --git a/stand/efi/loader_simp/Makefile b/stand/efi/loader_simp/Makefile index 0c27d5673941..ac873c1a3033 100644 --- a/stand/efi/loader_simp/Makefile +++ b/stand/efi/loader_simp/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ LOADER_INTERP=simp diff --git a/stand/fdt.mk b/stand/fdt.mk index 4d4794d980f2..56c9ff95b5ad 100644 --- a/stand/fdt.mk +++ b/stand/fdt.mk @@ -1,4 +1,3 @@ -# $FreeBSD$ .if ${MK_FDT} == "yes" CFLAGS+= -I${FDTSRC} diff --git a/stand/fdt/Makefile b/stand/fdt/Makefile index e0fd2dbb4e8d..b0090be108aa 100644 --- a/stand/fdt/Makefile +++ b/stand/fdt/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> diff --git a/stand/fdt/Makefile.depend b/stand/fdt/Makefile.depend index 18be76b0cb6f..15a1f9c07f7c 100644 --- a/stand/fdt/Makefile.depend +++ b/stand/fdt/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/fdt/fdt_loader_cmd.c b/stand/fdt/fdt_loader_cmd.c index c14b99768d70..a27ac53cb13b 100644 --- a/stand/fdt/fdt_loader_cmd.c +++ b/stand/fdt/fdt_loader_cmd.c @@ -1,6 +1,5 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation - * All rights reserved. * * This software was developed by Semihalf under sponsorship from * the FreeBSD Foundation. @@ -28,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <libfdt.h> #include <fdt.h> diff --git a/stand/fdt/fdt_platform.h b/stand/fdt/fdt_platform.h index 7bd1c977b4d6..41f03ff17f98 100644 --- a/stand/fdt/fdt_platform.h +++ b/stand/fdt/fdt_platform.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef FDT_PLATFORM_H diff --git a/stand/fdt/help.fdt b/stand/fdt/help.fdt index 665f63c260c6..32681d93be33 100644 --- a/stand/fdt/help.fdt +++ b/stand/fdt/help.fdt @@ -1,4 +1,3 @@ -$FreeBSD$ ############################################################################### # Tfdt Dfdt manipulation commands diff --git a/stand/ficl.mk b/stand/ficl.mk index e9fa1eb84f4b..a2cfca9fc3bb 100644 --- a/stand/ficl.mk +++ b/stand/ficl.mk @@ -1,4 +1,3 @@ -# $FreeBSD$ # Common flags to build FICL related files diff --git a/stand/ficl/Makefile b/stand/ficl/Makefile index 0f70286ff7df..a9b384024667 100644 --- a/stand/ficl/Makefile +++ b/stand/ficl/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ # .include <bsd.init.mk> diff --git a/stand/ficl/Makefile.depend b/stand/ficl/Makefile.depend index 73bc18c8c0fc..18537add9fe3 100644 --- a/stand/ficl/Makefile.depend +++ b/stand/ficl/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/ficl/aarch64/sysdep.c b/stand/ficl/aarch64/sysdep.c index 43e7c3c91f1d..87bed142d684 100644 --- a/stand/ficl/aarch64/sysdep.c +++ b/stand/ficl/aarch64/sysdep.c @@ -7,7 +7,6 @@ ** *******************************************************************/ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdio.h> diff --git a/stand/ficl/aarch64/sysdep.h b/stand/ficl/aarch64/sysdep.h index 3726b9ef838f..1bb45efcae26 100644 --- a/stand/ficl/aarch64/sysdep.h +++ b/stand/ficl/aarch64/sysdep.h @@ -46,7 +46,6 @@ ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) diff --git a/stand/ficl/amd64/sysdep.c b/stand/ficl/amd64/sysdep.c index 147c4683b6c2..41a5c679e9b3 100644 --- a/stand/ficl/amd64/sysdep.c +++ b/stand/ficl/amd64/sysdep.c @@ -7,7 +7,6 @@ ** *******************************************************************/ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdio.h> diff --git a/stand/ficl/amd64/sysdep.h b/stand/ficl/amd64/sysdep.h index 08bc0e1f4d0b..0e9a8bb0c788 100644 --- a/stand/ficl/amd64/sysdep.h +++ b/stand/ficl/amd64/sysdep.h @@ -48,7 +48,6 @@ ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ */ -/* $FreeBSD$ */ #if !defined (__SYSDEP_H__) #define __SYSDEP_H__ diff --git a/stand/ficl/arm/sysdep.c b/stand/ficl/arm/sysdep.c index 43e7c3c91f1d..87bed142d684 100644 --- a/stand/ficl/arm/sysdep.c +++ b/stand/ficl/arm/sysdep.c @@ -7,7 +7,6 @@ ** *******************************************************************/ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdio.h> diff --git a/stand/ficl/arm/sysdep.h b/stand/ficl/arm/sysdep.h index 00718eedd35c..e376aa9d334b 100644 --- a/stand/ficl/arm/sysdep.h +++ b/stand/ficl/arm/sysdep.h @@ -46,7 +46,6 @@ ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) diff --git a/stand/ficl/dict.c b/stand/ficl/dict.c index b76d92559f8f..7a6fc7568236 100644 --- a/stand/ficl/dict.c +++ b/stand/ficl/dict.c @@ -51,7 +51,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdio.h> diff --git a/stand/ficl/ficl.c b/stand/ficl/ficl.c index 219cf84b2225..3731b42b2a32 100644 --- a/stand/ficl/ficl.c +++ b/stand/ficl/ficl.c @@ -55,7 +55,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdlib.h> diff --git a/stand/ficl/ficl.h b/stand/ficl/ficl.h index 97cf00b0dff3..bdade26eee09 100644 --- a/stand/ficl/ficl.h +++ b/stand/ficl/ficl.h @@ -41,7 +41,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #if !defined (__FICL_H__) #define __FICL_H__ diff --git a/stand/ficl/fileaccess.c b/stand/ficl/fileaccess.c index 9dd23f9d34b8..a66262fb2bf3 100644 --- a/stand/ficl/fileaccess.c +++ b/stand/ficl/fileaccess.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #include <errno.h> #include <stdlib.h> diff --git a/stand/ficl/float.c b/stand/ficl/float.c index dfd1456c8dac..895252b60f20 100644 --- a/stand/ficl/float.c +++ b/stand/ficl/float.c @@ -41,7 +41,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #include "ficl.h" diff --git a/stand/ficl/i386/sysdep.c b/stand/ficl/i386/sysdep.c index 147c4683b6c2..41a5c679e9b3 100644 --- a/stand/ficl/i386/sysdep.c +++ b/stand/ficl/i386/sysdep.c @@ -7,7 +7,6 @@ ** *******************************************************************/ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdio.h> diff --git a/stand/ficl/i386/sysdep.h b/stand/ficl/i386/sysdep.h index 94fda2047ede..8eebbe9e7177 100644 --- a/stand/ficl/i386/sysdep.h +++ b/stand/ficl/i386/sysdep.h @@ -46,7 +46,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #if !defined (__SYSDEP_H__) #define __SYSDEP_H__ diff --git a/stand/ficl/loader.c b/stand/ficl/loader.c index fca2b7421ffb..edde4f477d55 100644 --- a/stand/ficl/loader.c +++ b/stand/ficl/loader.c @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ /******************************************************************* diff --git a/stand/ficl/math64.c b/stand/ficl/math64.c index 6e50458151bc..2122a02629f0 100644 --- a/stand/ficl/math64.c +++ b/stand/ficl/math64.c @@ -42,7 +42,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #include "ficl.h" #include "math64.h" diff --git a/stand/ficl/math64.h b/stand/ficl/math64.h index a4e56369564f..3acbbffec75f 100644 --- a/stand/ficl/math64.h +++ b/stand/ficl/math64.h @@ -40,7 +40,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #if !defined (__MATH64_H__) #define __MATH64_H__ diff --git a/stand/ficl/mips/sysdep.c b/stand/ficl/mips/sysdep.c index 43e7c3c91f1d..87bed142d684 100644 --- a/stand/ficl/mips/sysdep.c +++ b/stand/ficl/mips/sysdep.c @@ -7,7 +7,6 @@ ** *******************************************************************/ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdio.h> diff --git a/stand/ficl/mips/sysdep.h b/stand/ficl/mips/sysdep.h index 3ae748e259c7..9c2f1d2140b9 100644 --- a/stand/ficl/mips/sysdep.h +++ b/stand/ficl/mips/sysdep.h @@ -46,7 +46,6 @@ ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) diff --git a/stand/ficl/mips64/sysdep.c b/stand/ficl/mips64/sysdep.c index 43e7c3c91f1d..87bed142d684 100644 --- a/stand/ficl/mips64/sysdep.c +++ b/stand/ficl/mips64/sysdep.c @@ -7,7 +7,6 @@ ** *******************************************************************/ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdio.h> diff --git a/stand/ficl/mips64/sysdep.h b/stand/ficl/mips64/sysdep.h index 5c9e163acb70..6c1d8486137c 100644 --- a/stand/ficl/mips64/sysdep.h +++ b/stand/ficl/mips64/sysdep.h @@ -46,7 +46,6 @@ ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) diff --git a/stand/ficl/powerpc/sysdep.c b/stand/ficl/powerpc/sysdep.c index 43e7c3c91f1d..87bed142d684 100644 --- a/stand/ficl/powerpc/sysdep.c +++ b/stand/ficl/powerpc/sysdep.c @@ -7,7 +7,6 @@ ** *******************************************************************/ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdio.h> diff --git a/stand/ficl/powerpc/sysdep.h b/stand/ficl/powerpc/sysdep.h index b31625e18649..405d4c38176d 100644 --- a/stand/ficl/powerpc/sysdep.h +++ b/stand/ficl/powerpc/sysdep.h @@ -46,7 +46,6 @@ ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) diff --git a/stand/ficl/prefix.c b/stand/ficl/prefix.c index a34fc6c78240..f78ee597480f 100644 --- a/stand/ficl/prefix.c +++ b/stand/ficl/prefix.c @@ -41,7 +41,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #include <string.h> #include <ctype.h> diff --git a/stand/ficl/riscv/sysdep.c b/stand/ficl/riscv/sysdep.c index 43e7c3c91f1d..87bed142d684 100644 --- a/stand/ficl/riscv/sysdep.c +++ b/stand/ficl/riscv/sysdep.c @@ -7,7 +7,6 @@ ** *******************************************************************/ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdio.h> diff --git a/stand/ficl/riscv/sysdep.h b/stand/ficl/riscv/sysdep.h index 3726b9ef838f..1bb45efcae26 100644 --- a/stand/ficl/riscv/sysdep.h +++ b/stand/ficl/riscv/sysdep.h @@ -46,7 +46,6 @@ ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) diff --git a/stand/ficl/search.c b/stand/ficl/search.c index d445cb32d93a..2fa0d39ed36e 100644 --- a/stand/ficl/search.c +++ b/stand/ficl/search.c @@ -41,7 +41,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #include <string.h> #include "ficl.h" diff --git a/stand/ficl/softwords/classes.fr b/stand/ficl/softwords/classes.fr index b56da378e970..72524b0b9fa5 100644 --- a/stand/ficl/softwords/classes.fr +++ b/stand/ficl/softwords/classes.fr @@ -4,7 +4,6 @@ \ john sadler 1 sep 98 \ Needs oop.fr \ -\ $FreeBSD$ also oop definitions diff --git a/stand/ficl/softwords/ficlclass.fr b/stand/ficl/softwords/ficlclass.fr index 6d75efb0d3c5..471820c1ac8f 100644 --- a/stand/ficl/softwords/ficlclass.fr +++ b/stand/ficl/softwords/ficlclass.fr @@ -7,7 +7,6 @@ \ ** C - W O R D \ Models a FICL_WORD \ -\ $FreeBSD$ object subclass c-word c-word ref: .link diff --git a/stand/ficl/softwords/ficllocal.fr b/stand/ficl/softwords/ficllocal.fr index c916089696c1..86de6f9b6ea5 100644 --- a/stand/ficl/softwords/ficllocal.fr +++ b/stand/ficl/softwords/ficllocal.fr @@ -7,7 +7,6 @@ \ locstate: 0 = looking for -- or }} \ 1 = found -- \ -\ $FreeBSD$ hide 0 constant zero diff --git a/stand/ficl/softwords/fileaccess.fr b/stand/ficl/softwords/fileaccess.fr index 7297df681cf3..137058572f47 100644 --- a/stand/ficl/softwords/fileaccess.fr +++ b/stand/ficl/softwords/fileaccess.fr @@ -4,7 +4,6 @@ \ ** submitted by Larry Hastings, larry@hastings.org \ ** \ -\ $FreeBSD$ : r/o 1 ; : r/w 3 ; diff --git a/stand/ficl/softwords/forml.fr b/stand/ficl/softwords/forml.fr index 1144ef536792..3e7e56ca2ec1 100644 --- a/stand/ficl/softwords/forml.fr +++ b/stand/ficl/softwords/forml.fr @@ -1,7 +1,6 @@ \ examples from FORML conference paper Nov 98 \ sadler \ -\ $FreeBSD$ .( loading FORML examples ) cr object --> sub c-example diff --git a/stand/ficl/softwords/freebsd.fr b/stand/ficl/softwords/freebsd.fr index 96205c0808dd..948398b4e462 100644 --- a/stand/ficl/softwords/freebsd.fr +++ b/stand/ficl/softwords/freebsd.fr @@ -22,7 +22,6 @@ \ ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ ** SUCH DAMAGE. \ ** -\ ** $FreeBSD$ \ Words for use in scripts: \ % ignore errors here diff --git a/stand/ficl/softwords/ifbrack.fr b/stand/ficl/softwords/ifbrack.fr index a8c60626c4f8..b29b8fa08433 100644 --- a/stand/ficl/softwords/ifbrack.fr +++ b/stand/ficl/softwords/ifbrack.fr @@ -2,7 +2,6 @@ \ ** ANS conditional compile directives [if] [else] [then] \ ** Requires ficl 2.0 or greater... \ -\ $FreeBSD$ hide diff --git a/stand/ficl/softwords/jhlocal.fr b/stand/ficl/softwords/jhlocal.fr index 12ccb9fea753..3cbeb78ff9a1 100644 --- a/stand/ficl/softwords/jhlocal.fr +++ b/stand/ficl/softwords/jhlocal.fr @@ -14,7 +14,6 @@ \ \ revised 2 June 2000 - { | a -- } now works correctly \ -\ $FreeBSD$ hide diff --git a/stand/ficl/softwords/marker.fr b/stand/ficl/softwords/marker.fr index ee3c9bdf2f64..3b9e86acaaf0 100644 --- a/stand/ficl/softwords/marker.fr +++ b/stand/ficl/softwords/marker.fr @@ -3,7 +3,6 @@ \ John Sadler, 4 Oct 98 \ Requires ficl 2.02 FORGET-WID !! \ -\ $FreeBSD$ : marker ( "name" -- ) create diff --git a/stand/ficl/softwords/oo.fr b/stand/ficl/softwords/oo.fr index b1c8e214e5bd..0857cbe4b9fb 100644 --- a/stand/ficl/softwords/oo.fr +++ b/stand/ficl/softwords/oo.fr @@ -3,7 +3,6 @@ \ ** F I C L O - O E X T E N S I O N S \ ** john sadler aug 1998 \ -\ $FreeBSD$ 17 ficl-vocabulary oop also oop definitions diff --git a/stand/ficl/softwords/prefix.fr b/stand/ficl/softwords/prefix.fr index ae1727fc00bc..b1491a384425 100644 --- a/stand/ficl/softwords/prefix.fr +++ b/stand/ficl/softwords/prefix.fr @@ -5,7 +5,6 @@ \ (jws) To make a prefix, simply create a new definition in the <prefixes> \ wordlist. start-prefixes and end-prefixes handle the bookkeeping \ -\ $FreeBSD$ variable save-current diff --git a/stand/ficl/softwords/softcore.awk b/stand/ficl/softwords/softcore.awk index 5a97999a9823..4b736ad46734 100644 --- a/stand/ficl/softwords/softcore.awk +++ b/stand/ficl/softwords/softcore.awk @@ -10,7 +10,6 @@ # Note! This script uses strftime() which is a gawk-ism, and the # POSIX [[:space:]] character class. # -# $FreeBSD$ BEGIN \ { diff --git a/stand/ficl/softwords/softcore.fr b/stand/ficl/softwords/softcore.fr index 3ec74d8cbece..1350f859f3a2 100644 --- a/stand/ficl/softwords/softcore.fr +++ b/stand/ficl/softwords/softcore.fr @@ -3,7 +3,6 @@ \ ** John Sadler (john_sadler@alum.mit.edu) \ ** September, 1998 \ -\ $FreeBSD$ \ ** Ficl USER variables \ ** See words.c for primitive def'n of USER diff --git a/stand/ficl/softwords/string.fr b/stand/ficl/softwords/string.fr index dabb3900892f..bf6c997c70a7 100644 --- a/stand/ficl/softwords/string.fr +++ b/stand/ficl/softwords/string.fr @@ -11,7 +11,6 @@ \ s" woof woof woof " str --> cat \ str --> type cr \ -\ $FreeBSD$ also oop definitions diff --git a/stand/ficl/stack.c b/stand/ficl/stack.c index f98a3b61db7d..366e0adc3cf0 100644 --- a/stand/ficl/stack.c +++ b/stand/ficl/stack.c @@ -40,7 +40,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdlib.h> diff --git a/stand/ficl/testmain.c b/stand/ficl/testmain.c index 7167f30a2561..42c8edf4efa5 100644 --- a/stand/ficl/testmain.c +++ b/stand/ficl/testmain.c @@ -37,7 +37,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #include <stdlib.h> #include <stdio.h> diff --git a/stand/ficl/tools.c b/stand/ficl/tools.c index db1e94850f5e..2e5d3cd3b55b 100644 --- a/stand/ficl/tools.c +++ b/stand/ficl/tools.c @@ -54,7 +54,6 @@ ** Specify breakpoint default action */ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdlib.h> diff --git a/stand/ficl/unix.c b/stand/ficl/unix.c index 5b5644079ba9..77ab3a405d70 100644 --- a/stand/ficl/unix.c +++ b/stand/ficl/unix.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #include <string.h> #include <netinet/in.h> diff --git a/stand/ficl/vm.c b/stand/ficl/vm.c index 97a4f04e3b3b..b435e1b6069c 100644 --- a/stand/ficl/vm.c +++ b/stand/ficl/vm.c @@ -47,7 +47,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdlib.h> diff --git a/stand/ficl/words.c b/stand/ficl/words.c index 3f781c6d2ff4..8d06bedf8375 100644 --- a/stand/ficl/words.c +++ b/stand/ficl/words.c @@ -41,7 +41,6 @@ ** SUCH DAMAGE. */ -/* $FreeBSD$ */ #ifdef TESTMAIN #include <stdlib.h> diff --git a/stand/ficl/x86/sysdep.c b/stand/ficl/x86/sysdep.c index f45c115f7fca..eed3db8ad4c3 100644 --- a/stand/ficl/x86/sysdep.c +++ b/stand/ficl/x86/sysdep.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef TESTMAIN #include <machine/cpufunc.h> diff --git a/stand/ficl32/Makefile b/stand/ficl32/Makefile index 09499464ac89..c231b51cac8a 100644 --- a/stand/ficl32/Makefile +++ b/stand/ficl32/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ DO32=1 diff --git a/stand/ficl32/Makefile.depend b/stand/ficl32/Makefile.depend index 73bc18c8c0fc..393612bb1e79 100644 --- a/stand/ficl32/Makefile.depend +++ b/stand/ficl32/Makefile.depend @@ -1,8 +1,7 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - stand/libsa \ + stand/libsa32 \ .include <dirdeps.mk> diff --git a/stand/fonts/INDEX.fonts b/stand/fonts/INDEX.fonts index 44aa6a3c81cc..fc035c6b2e4e 100644 --- a/stand/fonts/INDEX.fonts +++ b/stand/fonts/INDEX.fonts @@ -1,5 +1,4 @@ # -# $FreeBSD$ # # database for vidfont(8) # diff --git a/stand/fonts/Makefile b/stand/fonts/Makefile index cf45c7ce5e30..88e7d0f91046 100644 --- a/stand/fonts/Makefile +++ b/stand/fonts/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> diff --git a/stand/forth/Makefile b/stand/forth/Makefile index a21661d01934..0fcee14fcdf5 100644 --- a/stand/forth/Makefile +++ b/stand/forth/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> diff --git a/stand/forth/Makefile.depend b/stand/forth/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/forth/Makefile.depend +++ b/stand/forth/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/forth/beastie.4th b/stand/forth/beastie.4th index f64cf9f8720b..8aab8214d37e 100644 --- a/stand/forth/beastie.4th +++ b/stand/forth/beastie.4th @@ -24,7 +24,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-beastie.4th diff --git a/stand/forth/beastie.4th.8 b/stand/forth/beastie.4th.8 index 97a5624d5a93..4a5365d981a0 100644 --- a/stand/forth/beastie.4th.8 +++ b/stand/forth/beastie.4th.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd January 6, 2016 .Dt BEASTIE.4TH 8 .Os diff --git a/stand/forth/brand-fbsd.4th b/stand/forth/brand-fbsd.4th index 84245ef232b6..ba84ae0d509a 100644 --- a/stand/forth/brand-fbsd.4th +++ b/stand/forth/brand-fbsd.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ 2 brandX ! 1 brandY ! \ Initialize brand placement defaults diff --git a/stand/forth/brand.4th b/stand/forth/brand.4th index 034e4eb40445..6c7cea584eba 100644 --- a/stand/forth/brand.4th +++ b/stand/forth/brand.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-brand.4th diff --git a/stand/forth/brand.4th.8 b/stand/forth/brand.4th.8 index 7e574d8d96f8..ac02b7feb311 100644 --- a/stand/forth/brand.4th.8 +++ b/stand/forth/brand.4th.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd May 18, 2011 .Dt BRAND.4TH 8 .Os diff --git a/stand/forth/check-password.4th b/stand/forth/check-password.4th index e7996227c5f9..cb938625f4d0 100644 --- a/stand/forth/check-password.4th +++ b/stand/forth/check-password.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-check-password.4th diff --git a/stand/forth/check-password.4th.8 b/stand/forth/check-password.4th.8 index 3c27edd0cf23..83119570d695 100644 --- a/stand/forth/check-password.4th.8 +++ b/stand/forth/check-password.4th.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd June 24, 2018 .Dt CHECK-PASSWORD.4TH 8 .Os diff --git a/stand/forth/color.4th b/stand/forth/color.4th index e73e8b725c31..d3371c17884a 100644 --- a/stand/forth/color.4th +++ b/stand/forth/color.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-color.4th diff --git a/stand/forth/color.4th.8 b/stand/forth/color.4th.8 index 9191da0f0457..8641210613cc 100644 --- a/stand/forth/color.4th.8 +++ b/stand/forth/color.4th.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd August 6, 2013 .Dt COLOR.4TH 8 .Os diff --git a/stand/forth/delay.4th b/stand/forth/delay.4th index 28cfa5c26eb9..45c1c5064827 100644 --- a/stand/forth/delay.4th +++ b/stand/forth/delay.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-delay.4th diff --git a/stand/forth/delay.4th.8 b/stand/forth/delay.4th.8 index af31fd04bad6..74a656ffe11e 100644 --- a/stand/forth/delay.4th.8 +++ b/stand/forth/delay.4th.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd May 18, 2011 .Dt DELAY.4TH 8 .Os diff --git a/stand/forth/efi.4th b/stand/forth/efi.4th index abcf12cffccd..5d4ed912281d 100644 --- a/stand/forth/efi.4th +++ b/stand/forth/efi.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ only forth definitions diff --git a/stand/forth/frames.4th b/stand/forth/frames.4th index 8d2421c758d9..9103f0f0aa3e 100644 --- a/stand/forth/frames.4th +++ b/stand/forth/frames.4th @@ -23,7 +23,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-frames.4th diff --git a/stand/forth/loader.4th b/stand/forth/loader.4th index 89ea9efc4171..574077ea5710 100644 --- a/stand/forth/loader.4th +++ b/stand/forth/loader.4th @@ -23,7 +23,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ only forth definitions diff --git a/stand/forth/loader.4th.8 b/stand/forth/loader.4th.8 index af8dbfca1b8e..36ba07941a7c 100644 --- a/stand/forth/loader.4th.8 +++ b/stand/forth/loader.4th.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd November 13, 2013 .Dt LOADER.4TH 8 .Os diff --git a/stand/forth/loader.rc b/stand/forth/loader.rc index c15b0f5ce23b..06f2edbd787d 100644 --- a/stand/forth/loader.rc +++ b/stand/forth/loader.rc @@ -1,5 +1,4 @@ \ Loader.rc -\ $FreeBSD$ \ \ You should not edit this file! Put any overrides in loader.rc.local \ instead as this file can be replaced during system updates. diff --git a/stand/forth/logo-beastie.4th b/stand/forth/logo-beastie.4th index 671eb5e496b2..cd049089a44d 100644 --- a/stand/forth/logo-beastie.4th +++ b/stand/forth/logo-beastie.4th @@ -24,7 +24,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ 46 logoX ! 4 logoY ! \ Initialize logo placement defaults diff --git a/stand/forth/logo-beastiebw.4th b/stand/forth/logo-beastiebw.4th index 197099cda0bc..f465dd3d3aa9 100644 --- a/stand/forth/logo-beastiebw.4th +++ b/stand/forth/logo-beastiebw.4th @@ -23,7 +23,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ 46 logoX ! 4 logoY ! \ Initialize logo placement defaults diff --git a/stand/forth/logo-fbsdbw.4th b/stand/forth/logo-fbsdbw.4th index d4a532b78f4f..67c16930c750 100644 --- a/stand/forth/logo-fbsdbw.4th +++ b/stand/forth/logo-fbsdbw.4th @@ -23,7 +23,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ 52 logoX ! 9 logoY ! \ Initialize logo placement defaults diff --git a/stand/forth/logo-orb.4th b/stand/forth/logo-orb.4th index 289353a46926..51efdeaec826 100644 --- a/stand/forth/logo-orb.4th +++ b/stand/forth/logo-orb.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ 46 logoX ! 7 logoY ! \ Initialize logo placement defaults diff --git a/stand/forth/logo-orbbw.4th b/stand/forth/logo-orbbw.4th index 11dc11cabb77..9e49a979f911 100644 --- a/stand/forth/logo-orbbw.4th +++ b/stand/forth/logo-orbbw.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ 46 logoX ! 7 logoY ! \ Initialize logo placement defaults diff --git a/stand/forth/menu-commands.4th b/stand/forth/menu-commands.4th index 9adf30a46b66..decf3fdf6fa4 100644 --- a/stand/forth/menu-commands.4th +++ b/stand/forth/menu-commands.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-menu-commands.4th diff --git a/stand/forth/menu.4th b/stand/forth/menu.4th index 75e75e3e3654..87b4efb8c185 100644 --- a/stand/forth/menu.4th +++ b/stand/forth/menu.4th @@ -24,7 +24,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-menu.4th diff --git a/stand/forth/menu.4th.8 b/stand/forth/menu.4th.8 index 3673eec74aa7..bd066a8b706f 100644 --- a/stand/forth/menu.4th.8 +++ b/stand/forth/menu.4th.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd August 6, 2013 .Dt MENU.4TH 8 .Os diff --git a/stand/forth/menu.rc b/stand/forth/menu.rc index d640e803e61f..da9ef49c84cd 100644 --- a/stand/forth/menu.rc +++ b/stand/forth/menu.rc @@ -1,5 +1,4 @@ \ Menu.rc -\ $FreeBSD$ \ \ You should not edit this file! Put any overrides in menu.rc.local \ instead as this file can be replaced during system updates. diff --git a/stand/forth/menusets.4th b/stand/forth/menusets.4th index 9335b80d511a..c3a4f8e8adb2 100644 --- a/stand/forth/menusets.4th +++ b/stand/forth/menusets.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-menusets.4th diff --git a/stand/forth/menusets.4th.8 b/stand/forth/menusets.4th.8 index f785ae18eabe..ddc0bc02ac41 100644 --- a/stand/forth/menusets.4th.8 +++ b/stand/forth/menusets.4th.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd November 5, 2012 .Dt MENUSETS.4TH 8 .Os diff --git a/stand/forth/screen.4th b/stand/forth/screen.4th index e27482248b57..02eff4dd1b5b 100644 --- a/stand/forth/screen.4th +++ b/stand/forth/screen.4th @@ -23,7 +23,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-screen.4th diff --git a/stand/forth/shortcuts.4th b/stand/forth/shortcuts.4th index 33a1cf678988..6ea885102140 100644 --- a/stand/forth/shortcuts.4th +++ b/stand/forth/shortcuts.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ \ FICL words intended to be used as shortcuts for carrying out common tasks or \ producing common results. Generally, words defined here are simply groupings diff --git a/stand/forth/support.4th b/stand/forth/support.4th index 999ac5005f5d..49318e067678 100644 --- a/stand/forth/support.4th +++ b/stand/forth/support.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ \ Loader.rc support functions: \ diff --git a/stand/forth/version.4th b/stand/forth/version.4th index a5311b4442ac..e92d77b321c8 100644 --- a/stand/forth/version.4th +++ b/stand/forth/version.4th @@ -22,7 +22,6 @@ \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ -\ $FreeBSD$ marker task-version.4th diff --git a/stand/forth/version.4th.8 b/stand/forth/version.4th.8 index 256df1ee5f87..6d888df0878e 100644 --- a/stand/forth/version.4th.8 +++ b/stand/forth/version.4th.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd August 6, 2013 .Dt VERSION.4TH 8 .Os diff --git a/stand/i386/Makefile b/stand/i386/Makefile index 9aa33462f309..e323a2cef9cd 100644 --- a/stand/i386/Makefile +++ b/stand/i386/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ NO_OBJ=t @@ -8,7 +7,6 @@ NO_OBJ=t # before everything else proceeds so we don't end up building against a stale # btxldr and ending up with a build-during-install scenario. SUBDIR.yes+= btx libi386 -SUBDIR.${MK_LOADER_FIREWIRE}+= libfirewire SUBDIR.yes+= .WAIT SUBDIR.yes+= mbr pmbr boot0 boot0sio boot2 cdboot gptboot \ diff --git a/stand/i386/Makefile.inc b/stand/i386/Makefile.inc index d12434487877..324c211420ae 100644 --- a/stand/i386/Makefile.inc +++ b/stand/i386/Makefile.inc @@ -1,6 +1,5 @@ # Common defines for all of stand/i386/ # -# $FreeBSD$ .include "bsd.linker.mk" @@ -33,9 +32,4 @@ LD_FLAGS_BIN= -static -N --gc-sections DO32=1 .endif -.if defined(LOADER_FIREWIRE_SUPPORT) -MK_LOADER_FIREWIRE=yes -.warning LOADER_FIREWIRE_SUPPORT deprecated, please move to WITH_LOADER_FIREWIRE -.endif - .include "../Makefile.inc" diff --git a/stand/i386/boot.ldscript b/stand/i386/boot.ldscript index 2f2a2d3e936e..6d2eb71ba465 100644 --- a/stand/i386/boot.ldscript +++ b/stand/i386/boot.ldscript @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* Simplified linker script for the boot loaders. */ OUTPUT_FORMAT("elf32-i386-freebsd") OUTPUT_ARCH(i386) diff --git a/stand/i386/boot0/Makefile b/stand/i386/boot0/Makefile index 82eb9eefee76..bfd566dfa45c 100644 --- a/stand/i386/boot0/Makefile +++ b/stand/i386/boot0/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ PROG?= boot0 STRIP= @@ -36,19 +35,27 @@ BOOT_BOOT0_FLAGS?= 0x8f # 0xb6 (182d) corresponds to 10 seconds. BOOT_BOOT0_TICKS?= 0xb6 -# The base address that we the boot0 code to to run it. Don't change this -# unless you are glutton for punishment. -BOOT_BOOT0_ORG?= 0x600 -ORG=${BOOT_BOOT0_ORG} +# The BIOS loads boot0 to the hardcoded address 0x7c00. boot0 copies +# itself to this alternate base address before continuing execution so +# that next level boot blocks can be loaded at the 0x7c00 address they +# expect. +ORG= 0x600 # Comm settings for boot0sio. +# +# boot0sio uses BIOS INT $0x14 for serial ports, we can only support these +# baudrates due to INT14's limited interface. In addition, if +# BOOT_BOOT0_COMCONSOLE_SPEED=0, then the baud rate and frame format will remain +# unchanged. Some BIOSes initialize the serial ports to 115200, and this may +# allow boot0sio access at that rate if so. +# # Bit(s) Description # 7-5 data rate (110,150,300,600,1200,2400,4800,9600 bps) # 4-3 parity (00 or 10 = none, 01 = odd, 11 = even) # 2 stop bits (set = 2, clear = 1) # 1-0 data bits (00 = 5, 01 = 6, 10 = 7, 11 = 8) .if !defined(BOOT_BOOT0_COMCONSOLE_SPEED) -BOOT_COMCONSOLE_SPEED?= 9600 +BOOT_COMCONSOLE_SPEED?= 9600 # BIOS interfaces do not support higher rates. .if ${BOOT_COMCONSOLE_SPEED} == 9600 BOOT_BOOT0_COMCONSOLE_SPEED= "7 << 5 + 3" .elif ${BOOT_COMCONSOLE_SPEED} == 4800 diff --git a/stand/i386/boot0/Makefile.depend b/stand/i386/boot0/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/i386/boot0/Makefile.depend +++ b/stand/i386/boot0/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/boot0/boot0.S b/stand/i386/boot0/boot0.S index 708f0934c427..d92f8dcb05f1 100644 --- a/stand/i386/boot0/boot0.S +++ b/stand/i386/boot0/boot0.S @@ -13,8 +13,6 @@ * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. - * - * $FreeBSD$ */ /* build options: */ diff --git a/stand/i386/boot0sio/Makefile b/stand/i386/boot0sio/Makefile index 1321dd330c4d..1725a11ec328 100644 --- a/stand/i386/boot0sio/Makefile +++ b/stand/i386/boot0sio/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .PATH: ${.CURDIR}/../boot0 diff --git a/stand/i386/boot0sio/Makefile.depend b/stand/i386/boot0sio/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/i386/boot0sio/Makefile.depend +++ b/stand/i386/boot0sio/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/boot2/Makefile b/stand/i386/boot2/Makefile index d5ad0f6bd12c..6d6a05cf228f 100644 --- a/stand/i386/boot2/Makefile +++ b/stand/i386/boot2/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -8,7 +7,7 @@ FILES= boot boot1 boot2 BOOT_BOOT1_FLAGS?= 0x80 BOOT_COMCONSOLE_PORT?= 0x3f8 -BOOT_COMCONSOLE_SPEED?= 9600 +BOOT_COMCONSOLE_SPEED?= 115200 B2SIOFMT?= 0x3 REL1= 0x700 diff --git a/stand/i386/boot2/Makefile.depend b/stand/i386/boot2/Makefile.depend index bc9b1b7bddc9..177fb5979700 100644 --- a/stand/i386/boot2/Makefile.depend +++ b/stand/i386/boot2/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/boot2/boot1.S b/stand/i386/boot2/boot1.S index 984ab52a816f..559c11e86c7f 100644 --- a/stand/i386/boot2/boot1.S +++ b/stand/i386/boot2/boot1.S @@ -11,8 +11,6 @@ * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. - * - * $FreeBSD$ */ /* Memory Locations */ diff --git a/stand/i386/boot2/boot2.c b/stand/i386/boot2/boot2.c index 898a8c27df19..da699b58b3b4 100644 --- a/stand/i386/boot2/boot2.c +++ b/stand/i386/boot2/boot2.c @@ -14,8 +14,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/disklabel.h> #include <sys/diskmbr.h> @@ -355,7 +353,7 @@ load(void) } static int -parse() +parse(void) { char *arg, *ep, *p, *q; const char *cp; diff --git a/stand/i386/boot2/lib.h b/stand/i386/boot2/lib.h index d8d3317e5aa0..d25dd0f7d28f 100644 --- a/stand/i386/boot2/lib.h +++ b/stand/i386/boot2/lib.h @@ -14,7 +14,6 @@ */ /* - * $FreeBSD$ */ int sio_init(int) __attribute__((regparm (3))); diff --git a/stand/i386/boot2/sio.S b/stand/i386/boot2/sio.S index ca9d0a2406aa..de554efb5b3e 100644 --- a/stand/i386/boot2/sio.S +++ b/stand/i386/boot2/sio.S @@ -11,8 +11,6 @@ * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. - * - * $FreeBSD$ */ .set SIO_PRT,SIOPRT # Base port diff --git a/stand/i386/btx/Makefile b/stand/i386/btx/Makefile index 39f78ed639b9..8ab9e72c5488 100644 --- a/stand/i386/btx/Makefile +++ b/stand/i386/btx/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ SUBDIR= btx btxldr lib diff --git a/stand/i386/btx/Makefile.inc b/stand/i386/btx/Makefile.inc index 265f86d1ed55..d3b5cbd3a79b 100644 --- a/stand/i386/btx/Makefile.inc +++ b/stand/i386/btx/Makefile.inc @@ -1,3 +1,2 @@ -# $FreeBSD$ .include "../Makefile.inc" diff --git a/stand/i386/btx/btx/Makefile b/stand/i386/btx/btx/Makefile index ce74e4067c9a..bfb9edcd1d31 100644 --- a/stand/i386/btx/btx/Makefile +++ b/stand/i386/btx/btx/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -17,7 +16,7 @@ CFLAGS+=-I${BOOTSRC}/i386/common .if defined(BTX_SERIAL) BOOT_COMCONSOLE_PORT?= 0x3f8 -BOOT_COMCONSOLE_SPEED?= 9600 +BOOT_COMCONSOLE_SPEED?= 115200 B2SIOFMT?= 0x3 CFLAGS+=-DBTX_SERIAL -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ diff --git a/stand/i386/btx/btx/Makefile.depend b/stand/i386/btx/btx/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/i386/btx/btx/Makefile.depend +++ b/stand/i386/btx/btx/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/btx/btx/btx.S b/stand/i386/btx/btx/btx.S index 87d09a5a1e17..d85ddd04ba4d 100644 --- a/stand/i386/btx/btx/btx.S +++ b/stand/i386/btx/btx/btx.S @@ -11,8 +11,6 @@ * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. - * - * $FreeBSD$ */ #include <bootargs.h> diff --git a/stand/i386/btx/btxldr/Makefile b/stand/i386/btx/btxldr/Makefile index d494a5a83201..83eaf7d2beb7 100644 --- a/stand/i386/btx/btxldr/Makefile +++ b/stand/i386/btx/btxldr/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> diff --git a/stand/i386/btx/btxldr/Makefile.depend b/stand/i386/btx/btxldr/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/i386/btx/btxldr/Makefile.depend +++ b/stand/i386/btx/btxldr/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/btx/btxldr/btxldr.S b/stand/i386/btx/btxldr/btxldr.S index 1a0f5f40ff07..f3174c3a27e0 100644 --- a/stand/i386/btx/btxldr/btxldr.S +++ b/stand/i386/btx/btxldr/btxldr.S @@ -11,8 +11,6 @@ * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. - * - * $FreeBSD$ */ #include <bootargs.h> diff --git a/stand/i386/btx/lib/Makefile b/stand/i386/btx/lib/Makefile index a9e2e4350a55..11d8e05b7f66 100644 --- a/stand/i386/btx/lib/Makefile +++ b/stand/i386/btx/lib/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> diff --git a/stand/i386/btx/lib/Makefile.depend b/stand/i386/btx/lib/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/i386/btx/lib/Makefile.depend +++ b/stand/i386/btx/lib/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/btx/lib/btxcsu.S b/stand/i386/btx/lib/btxcsu.S index c46f8097dbe3..8de4ffb43300 100644 --- a/stand/i386/btx/lib/btxcsu.S +++ b/stand/i386/btx/lib/btxcsu.S @@ -13,8 +13,6 @@ # purpose. # -# $FreeBSD$ - #include <bootargs.h> # diff --git a/stand/i386/btx/lib/btxsys.S b/stand/i386/btx/lib/btxsys.S index 9c77b4295e7c..fa1434d25aea 100644 --- a/stand/i386/btx/lib/btxsys.S +++ b/stand/i386/btx/lib/btxsys.S @@ -13,8 +13,6 @@ # purpose. # -# $FreeBSD$ - # # BTX system calls. # diff --git a/stand/i386/btx/lib/btxv86.S b/stand/i386/btx/lib/btxv86.S index 0d7d1116322d..718406aa96f2 100644 --- a/stand/i386/btx/lib/btxv86.S +++ b/stand/i386/btx/lib/btxv86.S @@ -13,8 +13,6 @@ # purpose. # -# $FreeBSD$ - # # BTX V86 interface. # diff --git a/stand/i386/btx/lib/btxv86.h b/stand/i386/btx/lib/btxv86.h index 0dca768cc2ac..567fdf4690f3 100644 --- a/stand/i386/btx/lib/btxv86.h +++ b/stand/i386/btx/lib/btxv86.h @@ -14,7 +14,6 @@ */ /* - * $FreeBSD$ */ #ifndef _BTXV86_H_ diff --git a/stand/i386/cdboot/Makefile b/stand/i386/cdboot/Makefile index 0598d5d80dce..7923e258fb66 100644 --- a/stand/i386/cdboot/Makefile +++ b/stand/i386/cdboot/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> diff --git a/stand/i386/cdboot/Makefile.depend b/stand/i386/cdboot/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/i386/cdboot/Makefile.depend +++ b/stand/i386/cdboot/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/cdboot/cdboot.S b/stand/i386/cdboot/cdboot.S index 951b07f209d3..dcac93a9805b 100644 --- a/stand/i386/cdboot/cdboot.S +++ b/stand/i386/cdboot/cdboot.S @@ -23,8 +23,6 @@ # SUCH DAMAGE. # -# $FreeBSD$ - # # This program is a freestanding boot program to load an a.out binary # from a CD-ROM booted with no emulation mode as described by the El diff --git a/stand/i386/common/bootargs.h b/stand/i386/common/bootargs.h index 5a6fef85a8c8..dafcf6a55554 100644 --- a/stand/i386/common/bootargs.h +++ b/stand/i386/common/bootargs.h @@ -11,8 +11,6 @@ * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. - * - * $FreeBSD$ */ #ifndef _BOOT_I386_ARGS_H_ diff --git a/stand/i386/common/cons.c b/stand/i386/common/cons.c index 25dda1ce7405..c3a44499b5b4 100644 --- a/stand/i386/common/cons.c +++ b/stand/i386/common/cons.c @@ -14,8 +14,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <machine/psl.h> diff --git a/stand/i386/common/cons.h b/stand/i386/common/cons.h index 73474fbe9c76..de1b11291771 100644 --- a/stand/i386/common/cons.h +++ b/stand/i386/common/cons.h @@ -11,8 +11,6 @@ * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. - * - * $FreeBSD$ */ #ifndef _CONS_H_ diff --git a/stand/i386/common/drv.c b/stand/i386/common/drv.c index e2e4d55e533c..bc8927dc6c5e 100644 --- a/stand/i386/common/drv.c +++ b/stand/i386/common/drv.c @@ -15,8 +15,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <btxv86.h> diff --git a/stand/i386/common/drv.h b/stand/i386/common/drv.h index c0995df45ea9..d67fd34a04e6 100644 --- a/stand/i386/common/drv.h +++ b/stand/i386/common/drv.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _DRV_H_ diff --git a/stand/i386/common/edd.h b/stand/i386/common/edd.h index 57607be0ebf2..2a8017dd2118 100644 --- a/stand/i386/common/edd.h +++ b/stand/i386/common/edd.h @@ -23,8 +23,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _EDD_H_ diff --git a/stand/i386/gptboot/Makefile b/stand/i386/gptboot/Makefile index ee8f4797f3d6..cce5e2e88d5d 100644 --- a/stand/i386/gptboot/Makefile +++ b/stand/i386/gptboot/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -8,7 +7,7 @@ FILES= gptboot MAN= gptboot.8 BOOT_COMCONSOLE_PORT?= 0x3f8 -BOOT_COMCONSOLE_SPEED?= 9600 +BOOT_COMCONSOLE_SPEED?= 115200 B2SIOFMT?= 0x3 REL1= 0x700 diff --git a/stand/i386/gptboot/Makefile.depend b/stand/i386/gptboot/Makefile.depend index 89aa3261d133..e7f0ac936f3a 100644 --- a/stand/i386/gptboot/Makefile.depend +++ b/stand/i386/gptboot/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/gptboot/gptboot.8 b/stand/i386/gptboot/gptboot.8 index 78e55fb1cb2c..c12d160f06de 100644 --- a/stand/i386/gptboot/gptboot.8 +++ b/stand/i386/gptboot/gptboot.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd March 18, 2022 .Dt GPTBOOT 8 .Os diff --git a/stand/i386/gptboot/gptboot.c b/stand/i386/gptboot/gptboot.c index 78d876554c86..7cae837f9a56 100644 --- a/stand/i386/gptboot/gptboot.c +++ b/stand/i386/gptboot/gptboot.c @@ -14,8 +14,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/gpt.h> #include <sys/dirent.h> diff --git a/stand/i386/gptboot/gptldr.S b/stand/i386/gptboot/gptldr.S index ca01082391f2..0c8291586281 100644 --- a/stand/i386/gptboot/gptldr.S +++ b/stand/i386/gptboot/gptldr.S @@ -27,8 +27,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * * Partly from: src/sys/boot/i386/boot2/boot1.S 1.31 */ diff --git a/stand/i386/gptzfsboot/Makefile b/stand/i386/gptzfsboot/Makefile index 09615c5f97c1..03f891912886 100644 --- a/stand/i386/gptzfsboot/Makefile +++ b/stand/i386/gptzfsboot/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -10,7 +9,7 @@ FILES= gptzfsboot MAN= gptzfsboot.8 BOOT_COMCONSOLE_PORT?= 0x3f8 -BOOT_COMCONSOLE_SPEED?= 9600 +BOOT_COMCONSOLE_SPEED?= 115200 B2SIOFMT?= 0x3 REL1= 0x700 diff --git a/stand/i386/gptzfsboot/Makefile.depend b/stand/i386/gptzfsboot/Makefile.depend index ce86c7a5535c..ba3ad3a00d92 100644 --- a/stand/i386/gptzfsboot/Makefile.depend +++ b/stand/i386/gptzfsboot/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/gptzfsboot/gptzfsboot.8 b/stand/i386/gptzfsboot/gptzfsboot.8 index 460178efc577..2a3b6f483c80 100644 --- a/stand/i386/gptzfsboot/gptzfsboot.8 +++ b/stand/i386/gptzfsboot/gptzfsboot.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd September 15, 2014 .Dt GPTZFSBOOT 8 .Os diff --git a/stand/i386/isoboot/Makefile b/stand/i386/isoboot/Makefile index 7732882b1e5c..12be31b52bc4 100644 --- a/stand/i386/isoboot/Makefile +++ b/stand/i386/isoboot/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -9,7 +8,7 @@ FILES= isoboot MAN= isoboot.8 BOOT_COMCONSOLE_PORT?= 0x3f8 -BOOT_COMCONSOLE_SPEED?= 9600 +BOOT_COMCONSOLE_SPEED?= 115200 B2SIOFMT?= 0x3 REL1= 0x700 diff --git a/stand/i386/isoboot/isoboot.8 b/stand/i386/isoboot/isoboot.8 index e6971313f9f3..f7e281f5479f 100644 --- a/stand/i386/isoboot/isoboot.8 +++ b/stand/i386/isoboot/isoboot.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd March 30, 2018 .Dt ISOBOOT 8 .Os diff --git a/stand/i386/isoboot/isoboot.c b/stand/i386/isoboot/isoboot.c index f7da4c7d3101..4c3f7af8537a 100644 --- a/stand/i386/isoboot/isoboot.c +++ b/stand/i386/isoboot/isoboot.c @@ -14,8 +14,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/gpt.h> #include <sys/dirent.h> diff --git a/stand/i386/libfirewire/Makefile b/stand/i386/libfirewire/Makefile deleted file mode 100644 index bf42c26a918f..000000000000 --- a/stand/i386/libfirewire/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ - -.include <bsd.init.mk> - -LIB= firewire - -.PATH: ${SYSDIR}/dev/dcons ${SYSDIR}/dev/firewire -SRCS+= firewire.c fwohci.c dconsole.c -SRCS+= dcons.c fwcrom.c - -.include "${BOOTSRC}/veriexec.mk" - -CFLAGS+= -D_BOOT - -CFLAGS+= -I${LDRSRC} -CFLAGS+= -I${BOOTSRC}/i386/libi386 - -CFLAGS+= -Wformat -Wall - -.include <bsd.lib.mk> diff --git a/stand/i386/libfirewire/Makefile.depend b/stand/i386/libfirewire/Makefile.depend deleted file mode 100644 index 18be76b0cb6f..000000000000 --- a/stand/i386/libfirewire/Makefile.depend +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - - -.include <dirdeps.mk> - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/stand/i386/libfirewire/dconsole.c b/stand/i386/libfirewire/dconsole.c deleted file mode 100644 index 338ed26aa417..000000000000 --- a/stand/i386/libfirewire/dconsole.c +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * Copyright (c) 2004 Hidetoshi Shimokawa - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stand.h> -#include <bootstrap.h> -#include <sys/param.h> -#include <btxv86.h> -#include <dev/dcons/dcons.h> - -void fw_enable(void); -void fw_poll(void); - -static void dconsole_probe(struct console *cp); -static int dconsole_init(int arg); -static void dconsole_putchar(int c); -static int dconsole_getchar(void); -static int dconsole_ischar(void); - -static int dcons_started = 0; - -#define DCONS_BUF_SIZE (64*1024) -static struct dcons_softc sc[DCONS_NPORT]; -uint32_t dcons_paddr; - -/* The buffer must be allocated in BSS because: - * - The dcons driver in the kernel is initialized before VM/pmap is - * initialized, so that the buffer must be allocate in the region - * that is mapped at the very early boot state. - * - We expect identiy map only for regions before KERNLOAD - * (i386:4MB amd64:1MB). - * - It seems that heap in conventional memory(640KB) is not sufficient - * and we move it to high address as LOADER_SUPPORT_BZIP2. - * - BSS is placed in conventional memory. - */ -static char dcons_buffer[DCONS_BUF_SIZE + PAGE_SIZE]; - -struct console dconsole = { - "dcons", - "dumb console port", - 0, - dconsole_probe, - dconsole_init, - dconsole_putchar, - dconsole_getchar, - dconsole_ischar -}; - -#define DCONSOLE_AS_MULTI_CONSOLE 1 - -static void -dconsole_probe(struct console *cp) -{ - /* XXX check the BIOS equipment list? */ - cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); -#if DCONSOLE_AS_MULTI_CONSOLE - dconsole_init(0); - cp->c_flags |= (C_ACTIVEIN | C_ACTIVEOUT); -#endif -} - -static int -dconsole_init(int arg) -{ - char buf[16], *dbuf; - int size; - - if (dcons_started && arg == 0) - return 0; - dcons_started = 1; - - size = DCONS_BUF_SIZE; - dbuf = (char *)round_page((vm_offset_t)&dcons_buffer[0]); - dcons_paddr = VTOP(dbuf); - sprintf(buf, "0x%08x", dcons_paddr); - setenv("dcons.addr", buf, 1); - - dcons_init((struct dcons_buf *)dbuf, size, sc); - sprintf(buf, "%d", size); - setenv("dcons.size", buf, 1); - fw_enable(); - return(0); -} - -static void -dconsole_putchar(int c) -{ - dcons_putc(&sc[0], c); -} - -static int -dconsole_getchar(void) -{ - fw_poll(); - return (dcons_checkc(&sc[0])); -} - -static int -dconsole_ischar(void) -{ - fw_poll(); - return (dcons_ischar(&sc[0])); -} diff --git a/stand/i386/libfirewire/firewire.c b/stand/i386/libfirewire/firewire.c deleted file mode 100644 index b9cb1ec0b19a..000000000000 --- a/stand/i386/libfirewire/firewire.c +++ /dev/null @@ -1,485 +0,0 @@ -/*- - * Copyright (c) 2004 Hidetoshi Shimokawa <simokawa@FreeBSD.ORG> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -/* - * FireWire disk device handling. - * - */ - -#include <stand.h> - -#include <machine/bootinfo.h> - -#include <stdarg.h> - -#include <bootstrap.h> -#include <btxv86.h> -#include <libi386.h> -#include <dev/firewire/firewire.h> -#include "fwohci.h" -#include <dev/dcons/dcons.h> - -/* XXX */ -#define BIT4x2(x,y) uint8_t y:4, x:4 -#define BIT16x2(x,y) uint32_t y:16, x:16 -#define _KERNEL -#include <dev/firewire/iec13213.h> - -extern uint32_t dcons_paddr; -extern struct console dconsole; - -struct crom_src_buf { - struct crom_src src; - struct crom_chunk root; - struct crom_chunk vendor; - struct crom_chunk hw; - /* for dcons */ - struct crom_chunk unit; - struct crom_chunk spec; - struct crom_chunk ver; -}; - -static int fw_init(void); -static int fw_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, char *buf, size_t *rsize); -static int fw_open(struct open_file *f, ...); -static int fw_close(struct open_file *f); -static int fw_print(int verbose); -static void fw_cleanup(void); - -void fw_enable(void); - -struct devsw fwohci = { - "FW1394", /* 7 chars at most */ - DEVT_NET, - fw_init, - fw_strategy, - fw_open, - fw_close, - noioctl, - fw_print, - fw_cleanup -}; - -static struct fwohci_softc fwinfo[MAX_OHCI]; -static int fw_initialized = 0; - -static void -fw_probe(int index, struct fwohci_softc *sc) -{ - int err; - - sc->state = FWOHCI_STATE_INIT; - err = biospci_find_devclass( - 0x0c0010 /* Serial:FireWire:OHCI */, - index /* index */, - &sc->locator); - - if (err != 0) { - sc->state = FWOHCI_STATE_DEAD; - return; - } - - biospci_write_config(sc->locator, - 0x4 /* command */, - BIOSPCI_16BITS, - 0x6 /* enable bus master and memory mapped I/O */); - - biospci_read_config(sc->locator, 0x00 /*devid*/, BIOSPCI_32BITS, - &sc->devid); - biospci_read_config(sc->locator, 0x10 /*base_addr*/, BIOSPCI_32BITS, - &sc->base_addr); - - sc->handle = (uint32_t)PTOV(sc->base_addr); - sc->bus_id = OREAD(sc, OHCI_BUS_ID); - - return; -} - -static int -fw_init(void) -{ - int i, avail; - struct fwohci_softc *sc; - - if (fw_initialized) - return (0); - - avail = 0; - for (i = 0; i < MAX_OHCI; i ++) { - sc = &fwinfo[i]; - fw_probe(i, sc); - if (sc->state == FWOHCI_STATE_DEAD) - break; - avail ++; - break; - } - fw_initialized = 1; - - return (0); -} - - -/* - * Print information about OHCI chips - */ -static int -fw_print(int verbose) -{ - char line[80]; - int i, ret = 0; - struct fwohci_softc *sc; - - printf("%s devices:", fwohci.dv_name); - if ((ret = pager_output("\n")) != 0) - return (ret); - - for (i = 0; i < MAX_OHCI; i ++) { - sc = &fwinfo[i]; - if (sc->state == FWOHCI_STATE_DEAD) - break; - snprintf(line, sizeof(line), "%d: locator=0x%04x devid=0x%08x" - " base_addr=0x%08x handle=0x%08x bus_id=0x%08x\n", - i, sc->locator, sc->devid, - sc->base_addr, sc->handle, sc->bus_id); - ret = pager_output(line); - if (ret != 0) - break; - } - return (ret); -} - -static int -fw_open(struct open_file *f, ...) -{ -#if 0 - va_list ap; - struct i386_devdesc *dev; - struct open_disk *od; - int error; - - va_start(ap, f); - dev = va_arg(ap, struct i386_devdesc *); - va_end(ap); -#endif - - return (ENXIO); -} - -static int -fw_close(struct open_file *f) -{ - return (0); -} - -static void -fw_cleanup() -{ - struct dcons_buf *db; - - /* invalidate dcons buffer */ - if (dcons_paddr) { - db = (struct dcons_buf *)PTOV(dcons_paddr); - db->magic = 0; - } -} - -static int -fw_strategy(void *devdata, int rw, daddr_t dblk, size_t size, - char *buf, size_t *rsize) -{ - return (EIO); -} - -static void -fw_init_crom(struct fwohci_softc *sc) -{ - struct crom_src *src; - - printf("fw_init_crom\n"); - sc->crom_src_buf = (struct crom_src_buf *) - malloc(sizeof(struct crom_src_buf)); - if (sc->crom_src_buf == NULL) - return; - - src = &sc->crom_src_buf->src; - bzero(src, sizeof(struct crom_src)); - - /* BUS info sample */ - src->hdr.info_len = 4; - - src->businfo.bus_name = CSR_BUS_NAME_IEEE1394; - - src->businfo.irmc = 1; - src->businfo.cmc = 1; - src->businfo.isc = 1; - src->businfo.bmc = 1; - src->businfo.pmc = 0; - src->businfo.cyc_clk_acc = 100; - src->businfo.max_rec = sc->maxrec; - src->businfo.max_rom = MAXROM_4; -#define FW_GENERATION_CHANGEABLE 2 - src->businfo.generation = FW_GENERATION_CHANGEABLE; - src->businfo.link_spd = sc->speed; - - src->businfo.eui64.hi = sc->eui.hi; - src->businfo.eui64.lo = sc->eui.lo; - - STAILQ_INIT(&src->chunk_list); - - sc->crom_src = src; - sc->crom_root = &sc->crom_src_buf->root; -} - -static void -fw_reset_crom(struct fwohci_softc *sc) -{ - struct crom_src_buf *buf; - struct crom_src *src; - struct crom_chunk *root; - - printf("fw_reset\n"); - if (sc->crom_src_buf == NULL) - fw_init_crom(sc); - - buf = sc->crom_src_buf; - src = sc->crom_src; - root = sc->crom_root; - - STAILQ_INIT(&src->chunk_list); - - bzero(root, sizeof(struct crom_chunk)); - crom_add_chunk(src, NULL, root, 0); - crom_add_entry(root, CSRKEY_NCAP, 0x0083c0); /* XXX */ - /* private company_id */ - crom_add_entry(root, CSRKEY_VENDOR, CSRVAL_VENDOR_PRIVATE); -#ifdef __DragonFly__ - crom_add_simple_text(src, root, &buf->vendor, "DragonFly Project"); -#else - crom_add_simple_text(src, root, &buf->vendor, "FreeBSD Project"); -#endif -} - - -#define ADDR_HI(x) (((x) >> 24) & 0xffffff) -#define ADDR_LO(x) ((x) & 0xffffff) - -static void -dcons_crom(struct fwohci_softc *sc) -{ - struct crom_src_buf *buf; - struct crom_src *src; - struct crom_chunk *root; - - buf = sc->crom_src_buf; - src = sc->crom_src; - root = sc->crom_root; - - bzero(&buf->unit, sizeof(struct crom_chunk)); - - crom_add_chunk(src, root, &buf->unit, CROM_UDIR); - crom_add_entry(&buf->unit, CSRKEY_SPEC, CSRVAL_VENDOR_PRIVATE); - crom_add_simple_text(src, &buf->unit, &buf->spec, "FreeBSD"); - crom_add_entry(&buf->unit, CSRKEY_VER, DCONS_CSR_VAL_VER); - crom_add_simple_text(src, &buf->unit, &buf->ver, "dcons"); - crom_add_entry(&buf->unit, DCONS_CSR_KEY_HI, ADDR_HI(dcons_paddr)); - crom_add_entry(&buf->unit, DCONS_CSR_KEY_LO, ADDR_LO(dcons_paddr)); -} - -void -fw_crom(struct fwohci_softc *sc) -{ - struct crom_src *src; - void *newrom; - - fw_reset_crom(sc); - dcons_crom(sc); - - newrom = malloc(CROMSIZE); - src = &sc->crom_src_buf->src; - crom_load(src, (uint32_t *)newrom, CROMSIZE); - if (bcmp(newrom, sc->config_rom, CROMSIZE) != 0) { - /* Bump generation and reload. */ - src->businfo.generation++; - - /* Handle generation count wraps. */ - if (src->businfo.generation < 2) - src->businfo.generation = 2; - - /* Recalculate CRC to account for generation change. */ - crom_load(src, (uint32_t *)newrom, CROMSIZE); - bcopy(newrom, (void *)sc->config_rom, CROMSIZE); - } - free(newrom); -} - -static int -fw_busreset(struct fwohci_softc *sc) -{ - int count; - - if (sc->state < FWOHCI_STATE_ENABLED) { - printf("fwohci not enabled\n"); - return(CMD_OK); - } - fw_crom(sc); - fwohci_ibr(sc); - count = 0; - while (sc->state< FWOHCI_STATE_NORMAL) { - fwohci_poll(sc); - count ++; - if (count > 1000) { - printf("give up to wait bus initialize\n"); - return (-1); - } - } - printf("poll count = %d\n", count); - return (0); -} - -void -fw_enable(void) -{ - struct fwohci_softc *sc; - int i; - - if (fw_initialized == 0) - fw_init(); - - for (i = 0; i < MAX_OHCI; i ++) { - sc = &fwinfo[i]; - if (sc->state != FWOHCI_STATE_INIT) - break; - - sc->config_rom = (uint32_t *) - (((uint32_t)sc->config_rom_buf - + (CROMSIZE - 1)) & ~(CROMSIZE - 1)); -#if 0 - printf("configrom: %08p %08p\n", - sc->config_rom_buf, sc->config_rom); -#endif - if (fwohci_init(sc, 0) == 0) { - sc->state = FWOHCI_STATE_ENABLED; - fw_busreset(sc); - } else - sc->state = FWOHCI_STATE_DEAD; - } -} - -void -fw_poll(void) -{ - struct fwohci_softc *sc; - int i; - - if (fw_initialized == 0) - return; - - for (i = 0; i < MAX_OHCI; i ++) { - sc = &fwinfo[i]; - if (sc->state < FWOHCI_STATE_ENABLED) - break; - fwohci_poll(sc); - } -} - -#if 0 /* for debug */ -static int -fw_busreset_cmd(int argc, char *argv[]) -{ - struct fwohci_softc *sc; - int i; - - for (i = 0; i < MAX_OHCI; i ++) { - sc = &fwinfo[i]; - if (sc->state < FWOHCI_STATE_INIT) - break; - fw_busreset(sc); - } - return(CMD_OK); -} - -static int -fw_poll_cmd(int argc, char *argv[]) -{ - fw_poll(); - return(CMD_OK); -} - -static int -fw_enable_cmd(int argc, char *argv[]) -{ - fw_print(0); - fw_enable(); - return(CMD_OK); -} - - -static int -dcons_enable(int argc, char *argv[]) -{ - dconsole.c_init(0); - fw_enable(); - dconsole.c_flags |= C_ACTIVEIN | C_ACTIVEOUT; - return(CMD_OK); -} - -static int -dcons_read(int argc, char *argv[]) -{ - char c; - while (dconsole.c_ready()) { - c = dconsole.c_in(); - printf("%c", c); - } - printf("\r\n"); - return(CMD_OK); -} - -static int -dcons_write(int argc, char *argv[]) -{ - int len, i; - if (argc < 2) - return(CMD_OK); - - len = strlen(argv[1]); - for (i = 0; i < len; i ++) - dconsole.c_out(argv[1][i]); - dconsole.c_out('\r'); - dconsole.c_out('\n'); - return(CMD_OK); -} -COMMAND_SET(firewire, "firewire", "enable firewire", fw_enable_cmd); -COMMAND_SET(fwbusreset, "fwbusreset", "firewire busreset", fw_busreset_cmd); -COMMAND_SET(fwpoll, "fwpoll", "firewire poll", fw_poll_cmd); -COMMAND_SET(dcons, "dcons", "enable dcons", dcons_enable); -COMMAND_SET(dread, "dread", "read from dcons", dcons_read); -COMMAND_SET(dwrite, "dwrite", "write to dcons", dcons_write); -#endif diff --git a/stand/i386/libfirewire/fwohci.c b/stand/i386/libfirewire/fwohci.c deleted file mode 100644 index 85e6173dc9be..000000000000 --- a/stand/i386/libfirewire/fwohci.c +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Copyright (c) 2003 Hidetoshi Shimokawa - * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the acknowledgement as bellow: - * - * This product includes software developed by K. Kobayashi and H. Shimokawa - * - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - * - */ - -#include <stand.h> -#include <btxv86.h> -#include <bootstrap.h> - -#include <dev/firewire/firewire.h> -#include "fwohci.h" -#include <dev/firewire/fwohcireg.h> -#include <dev/firewire/firewire_phy.h> - -static uint32_t fwphy_wrdata ( struct fwohci_softc *, uint32_t, uint32_t); -static uint32_t fwphy_rddata ( struct fwohci_softc *, uint32_t); -int firewire_debug=0; - -#if 0 -#define device_printf(a, x, ...) printf("FW1394: " x, ## __VA_ARGS__) -#else -#define device_printf(a, x, ...) -#endif - -#define device_t int -#define DELAY(x) delay(x) - -#define MAX_SPEED 3 -#define MAXREC(x) (2 << (x)) -char *linkspeed[] = { - "S100", "S200", "S400", "S800", - "S1600", "S3200", "undef", "undef" -}; - -/* - * Communication with PHY device - */ -static uint32_t -fwphy_wrdata( struct fwohci_softc *sc, uint32_t addr, uint32_t data) -{ - uint32_t fun; - - addr &= 0xf; - data &= 0xff; - - fun = (PHYDEV_WRCMD | (addr << PHYDEV_REGADDR) | (data << PHYDEV_WRDATA)); - OWRITE(sc, OHCI_PHYACCESS, fun); - DELAY(100); - - return(fwphy_rddata( sc, addr)); -} - -static uint32_t -fwphy_rddata(struct fwohci_softc *sc, u_int addr) -{ - uint32_t fun, stat; - u_int i, retry = 0; - - addr &= 0xf; -#define MAX_RETRY 100 -again: - OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_REG_FAIL); - fun = PHYDEV_RDCMD | (addr << PHYDEV_REGADDR); - OWRITE(sc, OHCI_PHYACCESS, fun); - for ( i = 0 ; i < MAX_RETRY ; i ++ ){ - fun = OREAD(sc, OHCI_PHYACCESS); - if ((fun & PHYDEV_RDCMD) == 0 && (fun & PHYDEV_RDDONE) != 0) - break; - DELAY(100); - } - if(i >= MAX_RETRY) { - if (firewire_debug) - device_printf(sc->fc.dev, "phy read failed(1).\n"); - if (++retry < MAX_RETRY) { - DELAY(100); - goto again; - } - } - /* Make sure that SCLK is started */ - stat = OREAD(sc, FWOHCI_INTSTAT); - if ((stat & OHCI_INT_REG_FAIL) != 0 || - ((fun >> PHYDEV_REGADDR) & 0xf) != addr) { - if (firewire_debug) - device_printf(sc->fc.dev, "phy read failed(2).\n"); - if (++retry < MAX_RETRY) { - DELAY(100); - goto again; - } - } - if (firewire_debug || retry >= MAX_RETRY) - device_printf(sc->fc.dev, - "fwphy_rddata: 0x%x loop=%d, retry=%d\n", addr, i, retry); -#undef MAX_RETRY - return((fun >> PHYDEV_RDDATA )& 0xff); -} - - -static int -fwohci_probe_phy(struct fwohci_softc *sc, device_t dev) -{ - uint32_t reg, reg2; - int e1394a = 1; - int nport, speed; -/* - * probe PHY parameters - * 0. to prove PHY version, whether compliance of 1394a. - * 1. to probe maximum speed supported by the PHY and - * number of port supported by core-logic. - * It is not actually available port on your PC . - */ - OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_LPS); - DELAY(500); - - reg = fwphy_rddata(sc, FW_PHY_SPD_REG); - - if((reg >> 5) != 7 ){ - nport = reg & FW_PHY_NP; - speed = reg & FW_PHY_SPD >> 6; - if (speed > MAX_SPEED) { - device_printf(dev, "invalid speed %d (fixed to %d).\n", - speed, MAX_SPEED); - speed = MAX_SPEED; - } - device_printf(dev, - "Phy 1394 only %s, %d ports.\n", - linkspeed[speed], nport); - }else{ - reg2 = fwphy_rddata(sc, FW_PHY_ESPD_REG); - nport = reg & FW_PHY_NP; - speed = (reg2 & FW_PHY_ESPD) >> 5; - if (speed > MAX_SPEED) { - device_printf(dev, "invalid speed %d (fixed to %d).\n", - speed, MAX_SPEED); - speed = MAX_SPEED; - } - device_printf(dev, - "Phy 1394a available %s, %d ports.\n", - linkspeed[speed], nport); - - /* check programPhyEnable */ - reg2 = fwphy_rddata(sc, 5); -#if 0 - if (e1394a && (OREAD(sc, OHCI_HCCCTL) & OHCI_HCC_PRPHY)) { -#else /* XXX force to enable 1394a */ - if (e1394a) { -#endif - if (firewire_debug) - device_printf(dev, - "Enable 1394a Enhancements\n"); - /* enable EAA EMC */ - reg2 |= 0x03; - /* set aPhyEnhanceEnable */ - OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_PHYEN); - OWRITE(sc, OHCI_HCCCTLCLR, OHCI_HCC_PRPHY); - } else { - /* for safe */ - reg2 &= ~0x83; - } - reg2 = fwphy_wrdata(sc, 5, reg2); - } - sc->speed = speed; - - reg = fwphy_rddata(sc, FW_PHY_SPD_REG); - if((reg >> 5) == 7 ){ - reg = fwphy_rddata(sc, 4); - reg |= 1 << 6; - fwphy_wrdata(sc, 4, reg); - reg = fwphy_rddata(sc, 4); - } - return 0; -} - - -void -fwohci_reset(struct fwohci_softc *sc, device_t dev) -{ - int i, max_rec, speed; - uint32_t reg, reg2; - - /* Disable interrupts */ - OWRITE(sc, FWOHCI_INTMASKCLR, ~0); - - /* FLUSH FIFO and reset Transmitter/Receiver */ - OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_RESET); - if (firewire_debug) - device_printf(dev, "resetting OHCI..."); - i = 0; - while(OREAD(sc, OHCI_HCCCTL) & OHCI_HCC_RESET) { - if (i++ > 100) break; - DELAY(1000); - } - if (firewire_debug) - printf("done (loop=%d)\n", i); - - /* Probe phy */ - fwohci_probe_phy(sc, dev); - - /* Probe link */ - reg = OREAD(sc, OHCI_BUS_OPT); - reg2 = reg | OHCI_BUSFNC; - max_rec = (reg & 0x0000f000) >> 12; - speed = (reg & 0x00000007); - device_printf(dev, "Link %s, max_rec %d bytes.\n", - linkspeed[speed], MAXREC(max_rec)); - /* XXX fix max_rec */ - sc->maxrec = sc->speed + 8; - if (max_rec != sc->maxrec) { - reg2 = (reg2 & 0xffff0fff) | (sc->maxrec << 12); - device_printf(dev, "max_rec %d -> %d\n", - MAXREC(max_rec), MAXREC(sc->maxrec)); - } - if (firewire_debug) - device_printf(dev, "BUS_OPT 0x%x -> 0x%x\n", reg, reg2); - OWRITE(sc, OHCI_BUS_OPT, reg2); - - /* Initialize registers */ - OWRITE(sc, OHCI_CROMHDR, sc->config_rom[0]); - OWRITE(sc, OHCI_CROMPTR, VTOP(sc->config_rom)); -#if 0 - OWRITE(sc, OHCI_SID_BUF, sc->sid_dma.bus_addr); -#endif - OWRITE(sc, OHCI_HCCCTLCLR, OHCI_HCC_BIGEND); - OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_POSTWR); -#if 0 - OWRITE(sc, OHCI_LNKCTL, OHCI_CNTL_SID); -#endif - - /* Enable link */ - OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_LINKEN); -} - -int -fwohci_init(struct fwohci_softc *sc, device_t dev) -{ - int i, mver; - uint32_t reg; - uint8_t ui[8]; - -/* OHCI version */ - reg = OREAD(sc, OHCI_VERSION); - mver = (reg >> 16) & 0xff; - device_printf(dev, "OHCI version %x.%x (ROM=%d)\n", - mver, reg & 0xff, (reg>>24) & 1); - if (mver < 1 || mver > 9) { - device_printf(dev, "invalid OHCI version\n"); - return (ENXIO); - } - -/* Available Isochronous DMA channel probe */ - OWRITE(sc, OHCI_IT_MASK, 0xffffffff); - OWRITE(sc, OHCI_IR_MASK, 0xffffffff); - reg = OREAD(sc, OHCI_IT_MASK) & OREAD(sc, OHCI_IR_MASK); - OWRITE(sc, OHCI_IT_MASKCLR, 0xffffffff); - OWRITE(sc, OHCI_IR_MASKCLR, 0xffffffff); - for (i = 0; i < 0x20; i++) - if ((reg & (1 << i)) == 0) - break; - device_printf(dev, "No. of Isochronous channels is %d.\n", i); - if (i == 0) - return (ENXIO); - -#if 0 -/* SID receive buffer must align 2^11 */ -#define OHCI_SIDSIZE (1 << 11) - sc->sid_buf = fwdma_malloc(&sc->fc, OHCI_SIDSIZE, OHCI_SIDSIZE, - &sc->sid_dma, BUS_DMA_WAITOK); - if (sc->sid_buf == NULL) { - device_printf(dev, "sid_buf alloc failed."); - return ENOMEM; - } -#endif - - sc->eui.hi = OREAD(sc, FWOHCIGUID_H); - sc->eui.lo = OREAD(sc, FWOHCIGUID_L); - for( i = 0 ; i < 8 ; i ++) - ui[i] = FW_EUI64_BYTE(&sc->eui,i); - device_printf(dev, "EUI64 %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", - ui[0], ui[1], ui[2], ui[3], ui[4], ui[5], ui[6], ui[7]); - fwohci_reset(sc, dev); - - return 0; -} - -void -fwohci_ibr(struct fwohci_softc *sc) -{ - uint32_t fun; - - device_printf(sc->dev, "Initiate bus reset\n"); - - /* - * Make sure our cached values from the config rom are - * initialised. - */ - OWRITE(sc, OHCI_CROMHDR, ntohl(sc->config_rom[0])); - OWRITE(sc, OHCI_BUS_OPT, ntohl(sc->config_rom[2])); - - /* - * Set root hold-off bit so that non cyclemaster capable node - * shouldn't became the root node. - */ -#if 1 - fun = fwphy_rddata(sc, FW_PHY_IBR_REG); - fun |= FW_PHY_IBR; - fun = fwphy_wrdata(sc, FW_PHY_IBR_REG, fun); -#else /* Short bus reset */ - fun = fwphy_rddata(sc, FW_PHY_ISBR_REG); - fun |= FW_PHY_ISBR; - fun = fwphy_wrdata(sc, FW_PHY_ISBR_REG, fun); -#endif -} - - -void -fwohci_sid(struct fwohci_softc *sc) -{ - uint32_t node_id; - int plen; - - node_id = OREAD(sc, FWOHCI_NODEID); - if (!(node_id & OHCI_NODE_VALID)) { -#if 0 - printf("Bus reset failure\n"); -#endif - return; - } - - /* Enable bus reset interrupt */ - OWRITE(sc, FWOHCI_INTMASK, OHCI_INT_PHY_BUS_R); - /* Allow async. request to us */ - OWRITE(sc, OHCI_AREQHI, 1 << 31); - /* XXX insecure ?? */ - OWRITE(sc, OHCI_PREQHI, 0x7fffffff); - OWRITE(sc, OHCI_PREQLO, 0xffffffff); - OWRITE(sc, OHCI_PREQUPPER, 0x10000); - /* Set ATRetries register */ - OWRITE(sc, OHCI_ATRETRY, 1<<(13+16) | 0xfff); -/* -** Checking whether the node is root or not. If root, turn on -** cycle master. -*/ - plen = OREAD(sc, OHCI_SID_CNT); - device_printf(fc->dev, "node_id=0x%08x, gen=%d, ", - node_id, (plen >> 16) & 0xff); - if (node_id & OHCI_NODE_ROOT) { - device_printf(sc->dev, "CYCLEMASTER mode\n"); - OWRITE(sc, OHCI_LNKCTL, - OHCI_CNTL_CYCMTR | OHCI_CNTL_CYCTIMER); - } else { - device_printf(sc->dev, "non CYCLEMASTER mode\n"); - OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCMTR); - OWRITE(sc, OHCI_LNKCTL, OHCI_CNTL_CYCTIMER); - } - if (plen & OHCI_SID_ERR) { - device_printf(fc->dev, "SID Error\n"); - return; - } - device_printf(sc->dev, "bus reset phase done\n"); - sc->state = FWOHCI_STATE_NORMAL; -} - -static void -fwohci_intr_body(struct fwohci_softc *sc, uint32_t stat, int count) -{ -#undef OHCI_DEBUG -#ifdef OHCI_DEBUG -#if 0 - if(stat & OREAD(sc, FWOHCI_INTMASK)) -#else - if (1) -#endif - device_printf(fc->dev, "INTERRUPT < %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s> 0x%08x, 0x%08x\n", - stat & OHCI_INT_EN ? "DMA_EN ":"", - stat & OHCI_INT_PHY_REG ? "PHY_REG ":"", - stat & OHCI_INT_CYC_LONG ? "CYC_LONG ":"", - stat & OHCI_INT_ERR ? "INT_ERR ":"", - stat & OHCI_INT_CYC_ERR ? "CYC_ERR ":"", - stat & OHCI_INT_CYC_LOST ? "CYC_LOST ":"", - stat & OHCI_INT_CYC_64SECOND ? "CYC_64SECOND ":"", - stat & OHCI_INT_CYC_START ? "CYC_START ":"", - stat & OHCI_INT_PHY_INT ? "PHY_INT ":"", - stat & OHCI_INT_PHY_BUS_R ? "BUS_RESET ":"", - stat & OHCI_INT_PHY_SID ? "SID ":"", - stat & OHCI_INT_LR_ERR ? "DMA_LR_ERR ":"", - stat & OHCI_INT_PW_ERR ? "DMA_PW_ERR ":"", - stat & OHCI_INT_DMA_IR ? "DMA_IR ":"", - stat & OHCI_INT_DMA_IT ? "DMA_IT " :"", - stat & OHCI_INT_DMA_PRRS ? "DMA_PRRS " :"", - stat & OHCI_INT_DMA_PRRQ ? "DMA_PRRQ " :"", - stat & OHCI_INT_DMA_ARRS ? "DMA_ARRS " :"", - stat & OHCI_INT_DMA_ARRQ ? "DMA_ARRQ " :"", - stat & OHCI_INT_DMA_ATRS ? "DMA_ATRS " :"", - stat & OHCI_INT_DMA_ATRQ ? "DMA_ATRQ " :"", - stat, OREAD(sc, FWOHCI_INTMASK) - ); -#endif -/* Bus reset */ - if(stat & OHCI_INT_PHY_BUS_R ){ - device_printf(fc->dev, "BUS reset\n"); - if (sc->state == FWOHCI_STATE_BUSRESET) - goto busresetout; - sc->state = FWOHCI_STATE_BUSRESET; - /* Disable bus reset interrupt until sid recv. */ - OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R); - - OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); - OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCSRC); - - OWRITE(sc, OHCI_CROMHDR, ntohl(sc->config_rom[0])); - OWRITE(sc, OHCI_BUS_OPT, ntohl(sc->config_rom[2])); - } else if (sc->state == FWOHCI_STATE_BUSRESET) { - fwohci_sid(sc); - } -busresetout: - return; -} - -static uint32_t -fwochi_check_stat(struct fwohci_softc *sc) -{ - uint32_t stat; - - stat = OREAD(sc, FWOHCI_INTSTAT); - if (stat == 0xffffffff) { - device_printf(sc->fc.dev, - "device physically ejected?\n"); - return(stat); - } - if (stat) - OWRITE(sc, FWOHCI_INTSTATCLR, stat); - return(stat); -} - -void -fwohci_poll(struct fwohci_softc *sc) -{ - uint32_t stat; - - stat = fwochi_check_stat(sc); - if (stat != 0xffffffff) - fwohci_intr_body(sc, stat, 1); -} diff --git a/stand/i386/libfirewire/fwohci.h b/stand/i386/libfirewire/fwohci.h deleted file mode 100644 index 3c1d29013cda..000000000000 --- a/stand/i386/libfirewire/fwohci.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2007 Hidetoshi Shimokawa - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the acknowledgement as bellow: - * - * This product includes software developed by K. Kobayashi and H. Shimokawa - * - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - * - */ - -#define MAX_OHCI 5 -#define CROMSIZE 0x400 - -struct fwohci_softc { - uint32_t locator; - uint32_t devid; - uint32_t base_addr; - uint32_t bus_id; - uint32_t handle; - int32_t state; - struct crom_src_buf *crom_src_buf; - struct crom_src *crom_src; - struct crom_chunk *crom_root; - struct fw_eui64 eui; - int speed; - int maxrec; - uint32_t *config_rom; - char config_rom_buf[CROMSIZE*2]; /* double size for alignment */ -}; - -int fwohci_init(struct fwohci_softc *, int); -void fwohci_ibr(struct fwohci_softc *); -void fwohci_poll(struct fwohci_softc *); - -#define FWOHCI_STATE_DEAD (-1) -#define FWOHCI_STATE_INIT 0 -#define FWOHCI_STATE_ENABLED 1 -#define FWOHCI_STATE_BUSRESET 2 -#define FWOHCI_STATE_NORMAL 3 - -#define OREAD(f, o) (*(volatile uint32_t *)((f)->handle + (o))) -#define OWRITE(f, o, v) (*(volatile uint32_t *)((f)->handle + (o)) = (v)) - -#define OHCI_VERSION 0x00 -#define OHCI_ATRETRY 0x08 -#define OHCI_CROMHDR 0x18 -#define OHCI_BUS_ID 0x1c -#define OHCI_BUS_OPT 0x20 -#define OHCI_BUSIRMC (1U << 31) -#define OHCI_BUSCMC (1 << 30) -#define OHCI_BUSISC (1 << 29) -#define OHCI_BUSBMC (1 << 28) -#define OHCI_BUSPMC (1 << 27) -#define OHCI_BUSFNC OHCI_BUSIRMC | OHCI_BUSCMC | OHCI_BUSISC |\ - OHCI_BUSBMC | OHCI_BUSPMC - -#define OHCI_EUID_HI 0x24 -#define OHCI_EUID_LO 0x28 - -#define OHCI_CROMPTR 0x34 -#define OHCI_HCCCTL 0x50 -#define OHCI_HCCCTLCLR 0x54 -#define OHCI_AREQHI 0x100 -#define OHCI_AREQHICLR 0x104 -#define OHCI_AREQLO 0x108 -#define OHCI_AREQLOCLR 0x10c -#define OHCI_PREQHI 0x110 -#define OHCI_PREQHICLR 0x114 -#define OHCI_PREQLO 0x118 -#define OHCI_PREQLOCLR 0x11c -#define OHCI_PREQUPPER 0x120 - -#define OHCI_SID_BUF 0x64 -#define OHCI_SID_CNT 0x68 -#define OHCI_SID_ERR (1U << 31) -#define OHCI_SID_CNT_MASK 0xffc - -#define OHCI_IT_STAT 0x90 -#define OHCI_IT_STATCLR 0x94 -#define OHCI_IT_MASK 0x98 -#define OHCI_IT_MASKCLR 0x9c - -#define OHCI_IR_STAT 0xa0 -#define OHCI_IR_STATCLR 0xa4 -#define OHCI_IR_MASK 0xa8 -#define OHCI_IR_MASKCLR 0xac - -#define OHCI_LNKCTL 0xe0 -#define OHCI_LNKCTLCLR 0xe4 - -#define OHCI_PHYACCESS 0xec -#define OHCI_CYCLETIMER 0xf0 - -#define OHCI_DMACTL(off) (off) -#define OHCI_DMACTLCLR(off) (off + 4) -#define OHCI_DMACMD(off) (off + 0xc) -#define OHCI_DMAMATCH(off) (off + 0x10) - -#define OHCI_ATQOFF 0x180 -#define OHCI_ATQCTL OHCI_ATQOFF -#define OHCI_ATQCTLCLR (OHCI_ATQOFF + 4) -#define OHCI_ATQCMD (OHCI_ATQOFF + 0xc) -#define OHCI_ATQMATCH (OHCI_ATQOFF + 0x10) - -#define OHCI_ATSOFF 0x1a0 -#define OHCI_ATSCTL OHCI_ATSOFF -#define OHCI_ATSCTLCLR (OHCI_ATSOFF + 4) -#define OHCI_ATSCMD (OHCI_ATSOFF + 0xc) -#define OHCI_ATSMATCH (OHCI_ATSOFF + 0x10) - -#define OHCI_ARQOFF 0x1c0 -#define OHCI_ARQCTL OHCI_ARQOFF -#define OHCI_ARQCTLCLR (OHCI_ARQOFF + 4) -#define OHCI_ARQCMD (OHCI_ARQOFF + 0xc) -#define OHCI_ARQMATCH (OHCI_ARQOFF + 0x10) - -#define OHCI_ARSOFF 0x1e0 -#define OHCI_ARSCTL OHCI_ARSOFF -#define OHCI_ARSCTLCLR (OHCI_ARSOFF + 4) -#define OHCI_ARSCMD (OHCI_ARSOFF + 0xc) -#define OHCI_ARSMATCH (OHCI_ARSOFF + 0x10) - -#define OHCI_ITOFF(CH) (0x200 + 0x10 * (CH)) -#define OHCI_ITCTL(CH) (OHCI_ITOFF(CH)) -#define OHCI_ITCTLCLR(CH) (OHCI_ITOFF(CH) + 4) -#define OHCI_ITCMD(CH) (OHCI_ITOFF(CH) + 0xc) - -#define OHCI_IROFF(CH) (0x400 + 0x20 * (CH)) -#define OHCI_IRCTL(CH) (OHCI_IROFF(CH)) -#define OHCI_IRCTLCLR(CH) (OHCI_IROFF(CH) + 4) -#define OHCI_IRCMD(CH) (OHCI_IROFF(CH) + 0xc) -#define OHCI_IRMATCH(CH) (OHCI_IROFF(CH) + 0x10) diff --git a/stand/i386/libi386/Makefile b/stand/i386/libi386/Makefile index 1b23cd53d137..0bc0efd35f22 100644 --- a/stand/i386/libi386/Makefile +++ b/stand/i386/libi386/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -10,9 +9,6 @@ SRCS= bio.c biosacpi.c biosdisk.c biosmem.c biospnp.c \ elf64_freebsd.c multiboot.c multiboot_tramp.S relocater_tramp.S \ i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.S \ time.c vidconsole.c vbe.c amd64_tramp.S spinconsole.c -.PATH: ${ZFSSRC} -SRCS+= devicename_stubs.c -CFLAGS+= -I${ZFSSRC} .PATH: ${SYSDIR}/teken SRCS+= teken.c @@ -22,7 +18,7 @@ SRCS+= teken.c BOOT_COMCONSOLE_PORT?= 0x3f8 CFLAGS+= -DCOMPORT=${BOOT_COMCONSOLE_PORT} -BOOT_COMCONSOLE_SPEED?= 9600 +BOOT_COMCONSOLE_SPEED?= 115200 CFLAGS+= -DCOMSPEED=${BOOT_COMCONSOLE_SPEED} .ifdef(BOOT_BIOSDISK_DEBUG) @@ -44,8 +40,6 @@ CFLAGS+= -Dalloca=__builtin_alloca CFLAGS+= -I${BOOTSRC}/ficl -I${BOOTSRC}/ficl/i386 \ -I${LDRSRC} -I${BOOTSRC}/i386/common \ - -I${SYSDIR}/cddl/boot/zfs \ - -I${SYSDIR}/cddl/contrib/opensolaris/uts/common \ -I${SYSDIR}/contrib/dev/acpica/include # Handle FreeBSD specific %b and %D printf format specifiers diff --git a/stand/i386/libi386/Makefile.depend b/stand/i386/libi386/Makefile.depend index df20c96b20e1..18537add9fe3 100644 --- a/stand/i386/libi386/Makefile.depend +++ b/stand/i386/libi386/Makefile.depend @@ -1,10 +1,7 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - include \ - include/xlocale \ - lib/libmd \ + stand/libsa \ .include <dirdeps.mk> diff --git a/stand/i386/libi386/amd64_tramp.S b/stand/i386/libi386/amd64_tramp.S index 6359b90d5c9f..3ecdce528622 100644 --- a/stand/i386/libi386/amd64_tramp.S +++ b/stand/i386/libi386/amd64_tramp.S @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ /* diff --git a/stand/i386/libi386/bio.c b/stand/i386/libi386/bio.c index 1bcb35f77aa1..e3b17ccc2a44 100644 --- a/stand/i386/libi386/bio.c +++ b/stand/i386/libi386/bio.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include "libi386.h" diff --git a/stand/i386/libi386/biosacpi.c b/stand/i386/libi386/biosacpi.c index 236c3fc45e7b..f94e8684c970 100644 --- a/stand/i386/libi386/biosacpi.c +++ b/stand/i386/libi386/biosacpi.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <machine/stdarg.h> #include <bootstrap.h> @@ -63,36 +61,24 @@ biosacpi_detect(void) /* * Report the RSDP to the kernel. While this can be found with * a BIOS boot, the RSDP may be elsewhere when booted from UEFI. - * The old code used the 'hints' method to communite this to - * the kernel. However, while convenient, the 'hints' method - * is fragile and does not work when static hints are compiled - * into the kernel. Instead, move to setting different tunables - * that start with acpi. The old 'hints' can be removed before - * we branch for FreeBSD 12. */ sprintf(buf, "0x%08x", VTOP(rsdp)); - setenv("hint.acpi.0.rsdp", buf, 1); setenv("acpi.rsdp", buf, 1); revision = rsdp->Revision; if (revision == 0) revision = 1; sprintf(buf, "%d", revision); - setenv("hint.acpi.0.revision", buf, 1); setenv("acpi.revision", buf, 1); strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId)); buf[sizeof(rsdp->OemId)] = '\0'; - setenv("hint.acpi.0.oem", buf, 1); setenv("acpi.oem", buf, 1); sprintf(buf, "0x%08x", rsdp->RsdtPhysicalAddress); - setenv("hint.acpi.0.rsdt", buf, 1); setenv("acpi.rsdt", buf, 1); if (revision >= 2) { /* XXX extended checksum? */ sprintf(buf, "0x%016llx", rsdp->XsdtPhysicalAddress); - setenv("hint.acpi.0.xsdt", buf, 1); setenv("acpi.xsdt", buf, 1); sprintf(buf, "%d", rsdp->Length); - setenv("hint.acpi.0.xsdt_length", buf, 1); setenv("acpi.xsdt_length", buf, 1); } } diff --git a/stand/i386/libi386/biosdisk.c b/stand/i386/libi386/biosdisk.c index 2c52617f255d..29cd39e157b8 100644 --- a/stand/i386/libi386/biosdisk.c +++ b/stand/i386/libi386/biosdisk.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * BIOS disk device handling. * @@ -165,7 +163,7 @@ struct devsw biosfd = { .dv_close = bd_close, .dv_ioctl = bd_ioctl, .dv_print = fd_print, - .dv_cleanup = NULL + .dv_cleanup = nullsys, }; struct devsw bioscd = { @@ -177,7 +175,7 @@ struct devsw bioscd = { .dv_close = bd_close, .dv_ioctl = bd_ioctl, .dv_print = cd_print, - .dv_cleanup = NULL + .dv_cleanup = nullsys, }; struct devsw bioshd = { @@ -189,7 +187,9 @@ struct devsw bioshd = { .dv_close = bd_close, .dv_ioctl = bd_ioctl, .dv_print = bd_print, - .dv_cleanup = NULL + .dv_cleanup = nullsys, + .dv_fmtdev = disk_fmtdev, + .dv_parsedev = disk_parsedev, }; static bdinfo_list_t * @@ -1031,7 +1031,8 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size, d_offset = dev->d_offset; } if (disk_blocks == 0) - disk_blocks = bd->bd_sectors - d_offset; + disk_blocks = bd->bd_sectors * (bd->bd_sectorsize / + BIOSDISK_SECSIZE) - d_offset; /* Validate source block address. */ if (dblk < d_offset || dblk >= d_offset + disk_blocks) @@ -1285,35 +1286,6 @@ bd_io(struct disk_devdesc *dev, bdinfo_t *bd, daddr_t dblk, int blks, } /* - * Return the BIOS geometry of a given "fixed drive" in a format - * suitable for the legacy bootinfo structure. Since the kernel is - * expecting raw int 0x13/0x8 values for N_BIOS_GEOM drives, we - * prefer to get the information directly, rather than rely on being - * able to put it together from information already maintained for - * different purposes and for a probably different number of drives. - * - * For valid drives, the geometry is expected in the format (31..0) - * "000000cc cccccccc hhhhhhhh 00ssssss"; and invalid drives are - * indicated by returning the geometry of a "1.2M" PC-format floppy - * disk. And, incidentally, what is returned is not the geometry as - * such but the highest valid cylinder, head, and sector numbers. - */ -uint32_t -bd_getbigeom(int bunit) -{ - - v86.ctl = V86_FLAGS; - v86.addr = DISK_BIOS; - v86.eax = CMD_READ_PARAM; - v86.edx = 0x80 + bunit; - v86int(); - if (V86_CY(v86.efl)) - return (0x4f010f); - return (((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) | - (v86.edx & 0xff00) | (v86.ecx & 0x3f)); -} - -/* * Return a suitable dev_t value for (dev). * * In the case where it looks like (dev) is a SCSI disk, we allow the number of diff --git a/stand/i386/libi386/biosmem.c b/stand/i386/libi386/biosmem.c index 8596ce6abf44..eaf41743bb1f 100644 --- a/stand/i386/libi386/biosmem.c +++ b/stand/i386/libi386/biosmem.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Obtain memory configuration information from the BIOS */ diff --git a/stand/i386/libi386/biospci.c b/stand/i386/libi386/biospci.c index 968533e210c4..1003e368043d 100644 --- a/stand/i386/libi386/biospci.c +++ b/stand/i386/libi386/biospci.c @@ -27,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * PnP enumerator using the PCI BIOS. */ diff --git a/stand/i386/libi386/biospnp.c b/stand/i386/libi386/biospnp.c index 6cd381b2ee11..7e3bc97a35ee 100644 --- a/stand/i386/libi386/biospnp.c +++ b/stand/i386/libi386/biospnp.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * PnP BIOS enumerator. */ diff --git a/stand/i386/libi386/biossmap.c b/stand/i386/libi386/biossmap.c index e95ea64517d0..a2ad83cafdba 100644 --- a/stand/i386/libi386/biossmap.c +++ b/stand/i386/libi386/biossmap.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Obtain memory configuration information from the BIOS */ diff --git a/stand/i386/libi386/bootinfo.c b/stand/i386/libi386/bootinfo.c index bdf409b00ec0..cc9a42164ed3 100644 --- a/stand/i386/libi386/bootinfo.c +++ b/stand/i386/libi386/bootinfo.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/param.h> #include <sys/reboot.h> @@ -103,31 +101,3 @@ bi_setboothowto(int howto) boot_howto_to_env(howto); } - -/* - * Copy the environment into the load area starting at (addr). - * Each variable is formatted as <name>=<value>, with a single nul - * separating each variable, and a double nul terminating the environment. - */ -vm_offset_t -bi_copyenv(vm_offset_t addr) -{ - struct env_var *ep; - - /* traverse the environment */ - for (ep = environ; ep != NULL; ep = ep->ev_next) { - i386_copyin(ep->ev_name, addr, strlen(ep->ev_name)); - addr += strlen(ep->ev_name); - i386_copyin("=", addr, 1); - addr++; - if (ep->ev_value != NULL) { - i386_copyin(ep->ev_value, addr, strlen(ep->ev_value)); - addr += strlen(ep->ev_value); - } - i386_copyin("", addr, 1); - addr++; - } - i386_copyin("", addr, 1); - addr++; - return(addr); -} diff --git a/stand/i386/libi386/bootinfo32.c b/stand/i386/libi386/bootinfo32.c index 23b02693cf48..1b038ff6b245 100644 --- a/stand/i386/libi386/bootinfo32.c +++ b/stand/i386/libi386/bootinfo32.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/param.h> #include <sys/reboot.h> @@ -34,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include <machine/bootinfo.h> #include <machine/metadata.h> #include "bootstrap.h" +#include "modinfo.h" #include "libi386.h" #include "btxv86.h" @@ -41,91 +40,7 @@ __FBSDID("$FreeBSD$"); #include "geliboot.h" #endif -static struct bootinfo bi; - -/* - * Copy module-related data into the load area, where it can be - * used as a directory for loaded modules. - * - * Module data is presented in a self-describing format. Each datum - * is preceded by a 32-bit identifier and a 32-bit size field. - * - * Currently, the following data are saved: - * - * MOD_NAME (variable) module name (string) - * MOD_TYPE (variable) module type (string) - * MOD_ARGS (variable) module parameters (string) - * MOD_ADDR sizeof(vm_offset_t) module load address - * MOD_SIZE sizeof(size_t) module size - * MOD_METADATA (variable) type-specific metadata - */ -#define COPY32(v, a, c) { \ - uint32_t x = (v); \ - if (c) \ - i386_copyin(&x, a, sizeof(x)); \ - a += sizeof(x); \ -} - -#define MOD_STR(t, a, s, c) { \ - COPY32(t, a, c); \ - COPY32(strlen(s) + 1, a, c); \ - if (c) \ - i386_copyin(s, a, strlen(s) + 1); \ - a += roundup(strlen(s) + 1, sizeof(u_long));\ -} - -#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) -#define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c) -#define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c) - -#define MOD_VAR(t, a, s, c) { \ - COPY32(t, a, c); \ - COPY32(sizeof(s), a, c); \ - if (c) \ - i386_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), sizeof(u_long)); \ -} - -#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) -#define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c) - -#define MOD_METADATA(a, mm, c) { \ - COPY32(MODINFO_METADATA | mm->md_type, a, c); \ - COPY32(mm->md_size, a, c); \ - if (c) \ - i386_copyin(mm->md_data, a, mm->md_size); \ - a += roundup(mm->md_size, sizeof(u_long));\ -} - -#define MOD_END(a, c) { \ - COPY32(MODINFO_END, a, c); \ - COPY32(0, a, c); \ -} - -static vm_offset_t -bi_copymodules32(vm_offset_t addr) -{ - struct preloaded_file *fp; - struct file_metadata *md; - int c; - - c = addr != 0; - /* start with the first module on the list, should be the kernel */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - - MOD_NAME(addr, fp->f_name, c); /* this field must come first */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - MOD_ADDR(addr, fp->f_addr, c); - MOD_SIZE(addr, fp->f_size, c); - for (md = fp->f_metadata; md != NULL; md = md->md_next) - if (!(md->md_type & MODINFOMD_NOCOPY)) - MOD_METADATA(addr, md, c); - } - MOD_END(addr, c); - return(addr); -} +static struct bootinfo *bi; /* * Load the information expected by an i386 kernel. @@ -167,18 +82,19 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t } /* Try reading the /etc/fstab file to select the root device */ - getrootmount(i386_fmtdev((void *)rootdev)); + getrootmount(devformat(&rootdev->dd)); /* Do legacy rootdev guessing */ /* 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; @@ -191,7 +107,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t rootdev->dd.d_dev->dv_type); } if (bootdevnr == -1) { - printf("root device %s invalid\n", i386_fmtdev(rootdev)); + printf("root device %s invalid\n", devformat(&rootdev->dd)); return (EINVAL); } free(rootdev); @@ -209,7 +125,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t /* copy our environment */ envp = addr; - addr = bi_copyenv(addr); + addr = md_copyenv(addr); /* pad to a page boundary */ addr = roundup(addr, PAGE_SIZE); @@ -231,7 +147,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t /* Figure out the size and location of the metadata */ *modulep = addr; - size = bi_copymodules32(0); + size = md_copymodules(0, false); kernend = roundup(addr + size, PAGE_SIZE); *kernendp = kernend; @@ -240,7 +156,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t bcopy(&kernend, md->md_data, sizeof kernend); /* copy module list and metadata */ - (void)bi_copymodules32(addr); + (void)md_copymodules(addr, false); ssym = esym = 0; md = file_findmetadata(kfp, MODINFOMD_SSYM); @@ -255,27 +171,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_kernelname = 0; /* XXX char * -> kernel name */ - bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */ - bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */ - for (i = 0; i < N_BIOS_GEOM; i++) - bi.bi_bios_geom[i] = bd_getbigeom(i); - 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); } diff --git a/stand/i386/libi386/bootinfo64.c b/stand/i386/libi386/bootinfo64.c index 1ffa4188d926..2a62eba4fc09 100644 --- a/stand/i386/libi386/bootinfo64.c +++ b/stand/i386/libi386/bootinfo64.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/param.h> #include <sys/reboot.h> @@ -37,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <machine/psl.h> #include <machine/specialreg.h> #include "bootstrap.h" +#include "modinfo.h" #include "libi386.h" #include "btxv86.h" @@ -45,93 +44,6 @@ __FBSDID("$FreeBSD$"); #endif /* - * Copy module-related data into the load area, where it can be - * used as a directory for loaded modules. - * - * Module data is presented in a self-describing format. Each datum - * is preceded by a 32-bit identifier and a 32-bit size field. - * - * Currently, the following data are saved: - * - * MOD_NAME (variable) module name (string) - * MOD_TYPE (variable) module type (string) - * MOD_ARGS (variable) module parameters (string) - * MOD_ADDR sizeof(vm_offset_t) module load address - * MOD_SIZE sizeof(size_t) module size - * MOD_METADATA (variable) type-specific metadata - */ -#define COPY32(v, a, c) { \ - uint32_t x = (v); \ - if (c) \ - i386_copyin(&x, a, sizeof(x)); \ - a += sizeof(x); \ -} - -#define MOD_STR(t, a, s, c) { \ - COPY32(t, a, c); \ - COPY32(strlen(s) + 1, a, c); \ - if (c) \ - i386_copyin(s, a, strlen(s) + 1); \ - a += roundup(strlen(s) + 1, sizeof(uint64_t));\ -} - -#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) -#define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c) -#define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c) - -#define MOD_VAR(t, a, s, c) { \ - COPY32(t, a, c); \ - COPY32(sizeof(s), a, c); \ - if (c) \ - i386_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), sizeof(uint64_t)); \ -} - -#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) -#define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c) - -#define MOD_METADATA(a, mm, c) { \ - COPY32(MODINFO_METADATA | mm->md_type, a, c); \ - COPY32(mm->md_size, a, c); \ - if (c) \ - i386_copyin(mm->md_data, a, mm->md_size); \ - a += roundup(mm->md_size, sizeof(uint64_t));\ -} - -#define MOD_END(a, c) { \ - COPY32(MODINFO_END, a, c); \ - COPY32(0, a, c); \ -} - -static vm_offset_t -bi_copymodules64(vm_offset_t addr) -{ - struct preloaded_file *fp; - struct file_metadata *md; - int c; - uint64_t v; - - c = addr != 0; - /* start with the first module on the list, should be the kernel */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - - MOD_NAME(addr, fp->f_name, c); /* this field must come first */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - v = fp->f_addr; - MOD_ADDR(addr, v, c); - v = fp->f_size; - MOD_SIZE(addr, v, c); - for (md = fp->f_metadata; md != NULL; md = md->md_next) - if (!(md->md_type & MODINFOMD_NOCOPY)) - MOD_METADATA(addr, md, c); - } - MOD_END(addr, c); - return(addr); -} - -/* * Check to see if this CPU supports long mode. */ static int @@ -216,7 +128,7 @@ bi_load64(char *args, vm_offset_t *modulep, } /* Try reading the /etc/fstab file to select the root device */ - getrootmount(i386_fmtdev((void *)rootdev)); + getrootmount(devformat(&rootdev->dd)); addr = 0; /* find the last module in the chain */ @@ -249,11 +161,11 @@ bi_load64(char *args, vm_offset_t *modulep, #endif bi_load_vbe_data(kfp); - size = bi_copymodules64(0); + size = md_copymodules(0, true); /* copy our environment */ envp = roundup(addr + size, PAGE_SIZE); - addr = bi_copyenv(envp); + addr = md_copyenv(envp); /* set kernend */ kernend = roundup(addr, PAGE_SIZE); @@ -268,7 +180,7 @@ bi_load64(char *args, vm_offset_t *modulep, bcopy(&envp, md->md_data, sizeof envp); /* copy module list and metadata */ - (void)bi_copymodules64(*modulep); + (void)md_copymodules(*modulep, true); return(0); } diff --git a/stand/i386/libi386/comconsole.c b/stand/i386/libi386/comconsole.c index ed1f1aa08ed7..6fff811bd34c 100644 --- a/stand/i386/libi386/comconsole.c +++ b/stand/i386/libi386/comconsole.c @@ -24,8 +24,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <bootstrap.h> #include <machine/cpufunc.h> @@ -42,7 +40,7 @@ __FBSDID("$FreeBSD$"); #define COMPORT 0x3f8 #endif #ifndef COMSPEED -#define COMSPEED 9600 +#define COMSPEED 115200 #endif static void comc_probe(struct console *cp); @@ -324,12 +322,13 @@ comc_setup(int speed, int port) char intbuf[64]; int tries; - unsetenv("hw.uart.console"); comc_curspeed = speed; comc_port = port; if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0) return; + unsetenv("hw.uart.console"); + #define COMC_TEST 0xbb /* * Write byte to scratch register and read it out. diff --git a/stand/i386/libi386/devicename.c b/stand/i386/libi386/devicename.c index 061f2ba9ce9f..c6125ba7a78b 100644 --- a/stand/i386/libi386/devicename.c +++ b/stand/i386/libi386/devicename.c @@ -25,16 +25,11 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <string.h> #include "bootstrap.h" #include "disk.h" #include "libi386.h" -#include "libzfs.h" - -static int i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path); /* * Point (dev) at an allocated device specifier for the device matching the @@ -44,7 +39,7 @@ static int i386_parsedev(struct i386_devdesc **dev, const char *devspec, const c int i386_getdev(void **vdev, const char *devspec, const char **path) { - struct i386_devdesc **dev = (struct i386_devdesc **)vdev; + struct devdesc **dev = (struct devdesc **)vdev; int rv; /* @@ -55,7 +50,7 @@ i386_getdev(void **vdev, const char *devspec, const char **path) (devspec[0] == '/') || (strchr(devspec, ':') == NULL)) { - if (((rv = i386_parsedev(dev, getenv("currdev"), NULL)) == 0) && + if (((rv = devparse(dev, getenv("currdev"), NULL)) == 0) && (path != NULL)) *path = devspec; return(rv); @@ -64,152 +59,5 @@ i386_getdev(void **vdev, const char *devspec, const char **path) /* * Try to parse the device name off the beginning of the devspec */ - return(i386_parsedev(dev, devspec, path)); -} - -/* - * Point (dev) at an allocated device specifier matching the string version - * at the beginning of (devspec). Return a pointer to the remaining - * text in (path). - * - * In all cases, the beginning of (devspec) is compared to the names - * of known devices in the device switch, and then any following text - * is parsed according to the rules applied to the device type. - * - * For disk-type devices, the syntax is: - * - * disk<unit>[s<slice>][<partition>]: - * - */ -static int -i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) -{ - struct i386_devdesc *idev; - struct devsw *dv; - int i, unit, err; - char *cp; - const char *np; - - /* minimum length check */ - if (strlen(devspec) < 2) - return(EINVAL); - - /* look for a device that matches */ - for (i = 0, dv = NULL; devsw[i] != NULL; i++) { - if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) { - dv = devsw[i]; - break; - } - } - if (dv == NULL) - return(ENOENT); - - np = (devspec + strlen(dv->dv_name)); - idev = NULL; - err = 0; - - switch(dv->dv_type) { - case DEVT_NONE: - break; - - case DEVT_DISK: - idev = malloc(sizeof(struct i386_devdesc)); - if (idev == NULL) - return (ENOMEM); - - err = disk_parsedev((struct disk_devdesc *)idev, np, path); - if (err != 0) - goto fail; - break; - - case DEVT_ZFS: - idev = malloc(sizeof (struct zfs_devdesc)); - if (idev == NULL) - return (ENOMEM); - - err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); - if (err != 0) - goto fail; - break; - - default: - idev = malloc(sizeof (struct devdesc)); - if (idev == NULL) - return (ENOMEM); - - unit = 0; - cp = (char *)np; - - if (*np && (*np != ':')) { - unit = strtol(np, &cp, 0); /* get unit number if present */ - if (cp == np) { - err = EUNIT; - goto fail; - } - } - - if (*cp && (*cp != ':')) { - err = EINVAL; - goto fail; - } - - idev->dd.d_unit = unit; - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - } - idev->dd.d_dev = dv; - if (dev != NULL) - *dev = idev; - else - free(idev); - - return(0); - - fail: - free(idev); - return(err); -} - - -char * -i386_fmtdev(void *vdev) -{ - struct i386_devdesc *dev = (struct i386_devdesc *)vdev; - static char buf[128]; /* XXX device length constant? */ - - switch(dev->dd.d_dev->dv_type) { - case DEVT_NONE: - strcpy(buf, "(no device)"); - break; - - case DEVT_CD: - case DEVT_NET: - sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit); - break; - - case DEVT_DISK: - return (disk_fmtdev(vdev)); - - case DEVT_ZFS: - return(zfs_fmtdev(vdev)); - } - return(buf); -} - - -/* - * Set currdev to suit the value being supplied in (value) - */ -int -i386_setcurrdev(struct env_var *ev, int flags, const void *value) -{ - struct i386_devdesc *ncurr; - int rv; - - if ((rv = i386_parsedev(&ncurr, value, NULL)) != 0) - return (rv); - free(ncurr); - - return (mount_currdev(ev, flags, value)); + return(devparse(dev, devspec, path)); } diff --git a/stand/i386/libi386/elf32_freebsd.c b/stand/i386/libi386/elf32_freebsd.c index 641e2733c3a2..185dc0c08d0f 100644 --- a/stand/i386/libi386/elf32_freebsd.c +++ b/stand/i386/libi386/elf32_freebsd.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/exec.h> #include <sys/linker.h> diff --git a/stand/i386/libi386/elf64_freebsd.c b/stand/i386/libi386/elf64_freebsd.c index 1108a9e4d713..da034437c6e0 100644 --- a/stand/i386/libi386/elf64_freebsd.c +++ b/stand/i386/libi386/elf64_freebsd.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 64 #include <sys/param.h> #include <sys/exec.h> diff --git a/stand/i386/libi386/i386_copy.c b/stand/i386/libi386/i386_copy.c index a1e7c734ebf3..3fcf9d09b280 100644 --- a/stand/i386/libi386/i386_copy.c +++ b/stand/i386/libi386/i386_copy.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * MD primitives supporting placement of module data * diff --git a/stand/i386/libi386/i386_module.c b/stand/i386/libi386/i386_module.c index 78ab61ba9a59..8c6300b3ad98 100644 --- a/stand/i386/libi386/i386_module.c +++ b/stand/i386/libi386/i386_module.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * i386-specific module functionality. * diff --git a/stand/i386/libi386/libi386.h b/stand/i386/libi386/libi386.h index a52a1190e7ec..d456ef58d7c2 100644 --- a/stand/i386/libi386/libi386.h +++ b/stand/i386/libi386/libi386.h @@ -22,30 +22,26 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include "disk.h" +#ifdef LOADER_ZFS_SUPPORT +#include "libzfs.h" +#endif /* * i386 fully-qualified device descriptor. */ -struct i386_devdesc { - struct devdesc dd; /* Must be first. */ - union - { - struct - { - int slice; - int partition; - off_t offset; - } biosdisk; - struct +struct i386_devdesc +{ + union { - uint64_t pool_guid; - uint64_t root_guid; - } zfs; - } d_kind; + struct devdesc dd; + struct disk_devdesc disk; +#ifdef LOADER_ZFS_SUPPORT + struct zfs_devdesc zfs; +#endif + }; }; /* @@ -82,7 +78,6 @@ extern uint16_t relocator_a20_enabled; int i386_getdev(void **vdev, const char *devspec, const char **path); char *i386_fmtdev(void *vdev); -int i386_setcurrdev(struct env_var *ev, int flags, const void *value); extern struct devdesc currdev; /* our current device */ @@ -148,7 +143,6 @@ int i386_autoload(void); void bi_load_vbe_data(struct preloaded_file *kfp); int bi_getboothowto(char *kargs); void bi_setboothowto(int howto); -vm_offset_t bi_copyenv(vm_offset_t addr); int bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t *modulep, vm_offset_t *kernend); int bi_load64(char *args, vm_offset_t *modulep, diff --git a/stand/i386/libi386/multiboot.c b/stand/i386/libi386/multiboot.c index 2d0a4a9b2274..1ac5aefebf38 100644 --- a/stand/i386/libi386/multiboot.c +++ b/stand/i386/libi386/multiboot.c @@ -35,8 +35,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/exec.h> #include <sys/linker.h> diff --git a/stand/i386/libi386/multiboot.h b/stand/i386/libi386/multiboot.h index 819fa2e5019f..d68f17b52810 100644 --- a/stand/i386/libi386/multiboot.h +++ b/stand/i386/libi386/multiboot.h @@ -18,7 +18,6 @@ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * -* $FreeBSD$ */ #ifndef MULTIBOOT_HEADER diff --git a/stand/i386/libi386/multiboot_tramp.S b/stand/i386/libi386/multiboot_tramp.S index 0bd604365f23..b9c4a43fe1e6 100644 --- a/stand/i386/libi386/multiboot_tramp.S +++ b/stand/i386/libi386/multiboot_tramp.S @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #define ASM_FILE diff --git a/stand/i386/libi386/nullconsole.c b/stand/i386/libi386/nullconsole.c index ebb1e7edd2b6..b39e52630c9d 100644 --- a/stand/i386/libi386/nullconsole.c +++ b/stand/i386/libi386/nullconsole.c @@ -36,8 +36,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <bootstrap.h> diff --git a/stand/i386/libi386/pread.c b/stand/i386/libi386/pread.c index 870e2540150f..854f28068ab0 100644 --- a/stand/i386/libi386/pread.c +++ b/stand/i386/libi386/pread.c @@ -34,8 +34,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* read into destination in flat addr space */ #include <stand.h> diff --git a/stand/i386/libi386/pxe.c b/stand/i386/libi386/pxe.c index e80a1961e191..895e8fc5ff51 100644 --- a/stand/i386/libi386/pxe.c +++ b/stand/i386/libi386/pxe.c @@ -27,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <errno.h> #include <stdbool.h> @@ -119,7 +117,7 @@ struct devsw pxedisk = { .dv_close = NULL, /* Will be set in pxe_init */ .dv_ioctl = noioctl, .dv_print = pxe_print, - .dv_cleanup = pxe_cleanup + .dv_cleanup = pxe_cleanup, }; /* diff --git a/stand/i386/libi386/pxe.h b/stand/i386/libi386/pxe.h index a51d72dae650..26c182c9ee88 100644 --- a/stand/i386/libi386/pxe.h +++ b/stand/i386/libi386/pxe.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ /* @@ -62,7 +60,7 @@ typedef struct { uint16_t Seg_Addr; uint32_t Phy_Addr; uint16_t Seg_Size; -} SEGDESC_t; +} PACKED SEGDESC_t; typedef uint16_t SEGSEL_t; typedef uint16_t PXENV_STATUS_t; @@ -151,7 +149,6 @@ typedef struct { #define MAXNUM_MCADDR 8 typedef struct { - PXENV_STATUS_t Status; uint16_t MCastAddrCount; MAC_ADDR McastAddr[MAXNUM_MCADDR]; } PACKED t_PXENV_UNDI_MCAST_ADDRESS; diff --git a/stand/i386/libi386/pxetramp.S b/stand/i386/libi386/pxetramp.S index dcf1441aeb24..8654e3cb9979 100644 --- a/stand/i386/libi386/pxetramp.S +++ b/stand/i386/libi386/pxetramp.S @@ -12,7 +12,6 @@ # warranties of merchantability and fitness for a particular # purpose. # -# $FreeBSD$ # ph33r this diff --git a/stand/i386/libi386/relocater_tramp.S b/stand/i386/libi386/relocater_tramp.S index 6db4a7509b2c..a6ba42830f54 100644 --- a/stand/i386/libi386/relocater_tramp.S +++ b/stand/i386/libi386/relocater_tramp.S @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ diff --git a/stand/i386/libi386/spinconsole.c b/stand/i386/libi386/spinconsole.c index 1daac3586939..05ce33bfc5a8 100644 --- a/stand/i386/libi386/spinconsole.c +++ b/stand/i386/libi386/spinconsole.c @@ -36,8 +36,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <bootstrap.h> diff --git a/stand/i386/libi386/time.c b/stand/i386/libi386/time.c index 5b8a9c9017a7..74d0fecda4de 100644 --- a/stand/i386/libi386/time.c +++ b/stand/i386/libi386/time.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <btxv86.h> #include "bootstrap.h" diff --git a/stand/i386/libi386/vbe.c b/stand/i386/libi386/vbe.c index 3caba3081f06..8fbfaa9a3475 100644 --- a/stand/i386/libi386/vbe.c +++ b/stand/i386/libi386/vbe.c @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <sys/cdefs.h> diff --git a/stand/i386/libi386/vidconsole.c b/stand/i386/libi386/vidconsole.c index 1ec6b4f5393a..aec41a6373d6 100644 --- a/stand/i386/libi386/vidconsole.c +++ b/stand/i386/libi386/vidconsole.c @@ -28,15 +28,12 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/param.h> #include <bootstrap.h> #include <btxv86.h> #include <gfx_fb.h> #include <teken.h> -#include <stdbool.h> #include "vbe.h" #include <dev/vt/hw/vga/vt_vga_reg.h> diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile index 571e3b2cb653..de96e1329b2f 100644 --- a/stand/i386/loader/Makefile +++ b/stand/i386/loader/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ HAVE_ZFS= ${MK_LOADER_ZFS} @@ -19,6 +18,22 @@ PROG= ${LOADER}.sym INTERNALPROG= NEWVERSWHAT?= "bootstrap loader" x86 VERSION_FILE= ${.CURDIR}/../loader/version +# +# There's 640k - 40k maximum space, less however much memory the BIOS uses. A +# non-random survey suggests that 20k-25k is a good value for 'most' machines. +# We also need to subtract maximum stack usage (20-25k). +# +# So 640k - 40k - 25k - 25k = 550k = 563,200 bytes, but use 550,000 below for +# some extra buffer for more complex setups and/or wider BIOS lomem variation. +# +# Some systems use more stack or have BIOS reserve more RAM (or both), and will +# need to set this lower in /etc/src.conf if the above buffer is too small. +# +# sudo dd if=/dev/mem bs=1 iseek=0x413 count=2 | hd -d +# +# will tell you how many kiB of lomem are available. +# +LOADERSIZE?= 550000 # Largest known safe size for loader.bin .PATH: ${BOOTSRC}/i386/loader @@ -38,11 +53,6 @@ HAVE_BCACHE= yes HAVE_PNP= yes HAVE_ISABUS= yes -.if ${MK_LOADER_FIREWIRE} == "yes" -CFLAGS+= -DLOADER_FIREWIRE_SUPPORT -LIBFIREWIRE= ${BOOTOBJ}/i386/libfirewire/libfirewire.a -.endif - .if ${MK_LOADER_ZFS} == "yes" CFLAGS.main.c+= -I${SYSDIR}/contrib/openzfs/include CFLAGS.main.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs @@ -51,6 +61,7 @@ CFLAGS.main.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs .if exists(${.CURDIR}/help.i386) HELP_FILES= ${.CURDIR}/help.i386 .endif +HELP_FILENAME= loader.help.bios # Always add MI sources .include "${BOOTSRC}/loader.mk" @@ -79,12 +90,15 @@ CFLAGS+= -I${BOOTSRC}/i386 8x16.c: ${SRCTOP}/contrib/terminus/ter-u16b.bdf vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC} + ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN} btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ -b ${BTXKERN} ${LOADER}.bin ${LOADER}.bin: ${LOADER}.sym ${STRIPBIN} -R .comment -R .note -o ${.TARGET} ${.ALLSRC} + @set -- `ls -l ${.TARGET}` ; x=$$((${LOADERSIZE}-$$5)); \ + echo "$$x bytes available"; test $$x -ge 0 .if ${MK_LOADER_ZFS} == "yes" && ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP} LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/zfsloader @@ -98,8 +112,8 @@ FILESMODE_${LOADER}= ${BINMODE} -b # Note: crt0.o needs to be first for pxeboot(8) to work. It assumes that the # startup code is located at the start of the loader and will jump # there. Although btx is more flexible than this, the emulated boot2 environment -# that pxeloader provides has none of that flexibility because it lacks access -# to the a.out/elf headers and assumes an entry point of 0. +# that pxeldr provides has none of that flexibility assumes an entry point of +# 0. In addition, pxeldr and cdboot assume that it is loading an a.out file. # # We must add it to the LDFLAGS instead of the OBJS because the former won't try # to clean it. When it is in OBJS, this cleaning can lead to races where @@ -108,8 +122,8 @@ FILESMODE_${LOADER}= ${BINMODE} -b # files. LDFLAGS+= ${BTXCRT} -DPADD= ${LDR_INTERP32} ${LIBFIREWIRE} ${LIBI386} ${LIBSA32} -LDADD= ${LDR_INTERP32} ${LIBFIREWIRE} ${LIBI386} ${LIBSA32} +DPADD= ${LDR_INTERP32} ${LIBI386} ${LIBSA32} +LDADD= ${LDR_INTERP32} ${LIBI386} ${LIBSA32} .if ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -DLOADER_PREFER_AMD64 diff --git a/stand/i386/loader/Makefile.depend b/stand/i386/loader/Makefile.depend index 8807f64e88d6..9262a05207b6 100644 --- a/stand/i386/loader/Makefile.depend +++ b/stand/i386/loader/Makefile.depend @@ -1,12 +1,11 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - stand/${MACHINE_CPUARCH}/btx/btx \ - stand/${MACHINE_CPUARCH}/btx/btxldr \ - stand/${MACHINE_CPUARCH}/btx/lib \ - stand/${MACHINE_CPUARCH}/libi386 \ stand/ficl \ + stand/i386/btx/btx \ + stand/i386/btx/btxldr \ + stand/i386/btx/lib \ + stand/i386/libi386 \ stand/libsa \ diff --git a/stand/i386/loader/chain.c b/stand/i386/loader/chain.c index d4e3936e13df..5fab9183ccc3 100644 --- a/stand/i386/loader/chain.c +++ b/stand/i386/loader/chain.c @@ -32,8 +32,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/param.h> #include <sys/linker.h> diff --git a/stand/i386/loader/conf.c b/stand/i386/loader/conf.c index 35052b5423cd..329bcd577fbe 100644 --- a/stand/i386/loader/conf.c +++ b/stand/i386/loader/conf.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <bootstrap.h> #include "libi386/libi386.h" @@ -45,9 +43,6 @@ __FBSDID("$FreeBSD$"); * XXX as libi386 and biosboot merge, some of these can become linker sets. */ -#if defined(LOADER_FIREWIRE_SUPPORT) -extern struct devsw fwohci; -#endif extern struct devsw vdisk_dev; /* Exported for libsa */ @@ -58,9 +53,6 @@ struct devsw *devsw[] = { #if defined(LOADER_NFS_SUPPORT) || defined(LOADER_TFTP_SUPPORT) &pxedisk, #endif -#if defined(LOADER_FIREWIRE_SUPPORT) - &fwohci, -#endif &vdisk_dev, #if defined(LOADER_ZFS_SUPPORT) &zfs_dev, @@ -138,18 +130,12 @@ struct file_format *file_formats[] = { */ extern struct console vidconsole; extern struct console comconsole; -#if defined(LOADER_FIREWIRE_SUPPORT) -extern struct console dconsole; -#endif extern struct console nullconsole; extern struct console spinconsole; struct console *consoles[] = { &vidconsole, &comconsole, -#if defined(LOADER_FIREWIRE_SUPPORT) - &dconsole, -#endif &nullconsole, &spinconsole, NULL diff --git a/stand/i386/loader/loader.rc b/stand/i386/loader/loader.rc index 9f1ebe635971..4bac6ef6801d 100644 --- a/stand/i386/loader/loader.rc +++ b/stand/i386/loader/loader.rc @@ -1,5 +1,4 @@ \ Loader.rc -\ $FreeBSD$ \ \ Includes additional commands include /boot/loader.4th diff --git a/stand/i386/loader/main.c b/stand/i386/loader/main.c index cb716d7a9f21..97c4448afdc3 100644 --- a/stand/i386/loader/main.c +++ b/stand/i386/loader/main.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * MD bootstrap main() and assorted miscellaneous * commands. @@ -96,8 +94,6 @@ ptov(uintptr_t x) int main(void) { - int i; - /* Pick up arguments */ kargs = (void *)__args; initial_howto = kargs->howto; @@ -115,7 +111,7 @@ main(void) */ bios_getmem(); -#if defined(LOADER_BZIP2_SUPPORT) || defined(LOADER_FIREWIRE_SUPPORT) || \ +#if defined(LOADER_BZIP2_SUPPORT) || \ defined(LOADER_GPT_SUPPORT) || defined(LOADER_ZFS_SUPPORT) if (high_heap_size > 0) { heap_top = PTOV(high_heap_base + high_heap_size); @@ -166,7 +162,7 @@ main(void) /* Set up currdev variable to have hooks in place. */ env_setenv("currdev", EV_VOLATILE | EV_NOHOOK, "", - i386_setcurrdev, env_nounset); + gen_setcurrdev, env_nounset); /* * Initialise the block cache. Set the upper limit. @@ -244,12 +240,7 @@ main(void) import_geli_boot_data(gbdata); #endif /* LOADER_GELI_SUPPORT */ - /* - * March through the device switch probing for things. - */ - for (i = 0; devsw[i] != NULL; i++) - if (devsw[i]->dv_init != NULL) - (devsw[i]->dv_init)(); + devinit(); printf("BIOS %dkB/%dkB available memory\n", bios_basemem / 1024, bios_extmem / 1024); @@ -308,8 +299,8 @@ extract_currdev(void) new_currdev.dd.d_unit = 0; } else { /* we don't know what our boot device is */ - new_currdev.d_kind.biosdisk.slice = -1; - new_currdev.d_kind.biosdisk.partition = 0; + new_currdev.disk.d_slice = -1; + new_currdev.disk.d_partition = 0; biosdev = -1; } #ifdef LOADER_ZFS_SUPPORT @@ -322,8 +313,8 @@ extract_currdev(void) zargs->size >= offsetof(struct zfs_boot_args, primary_pool)) { /* sufficient data is provided */ - new_currdev.d_kind.zfs.pool_guid = zargs->pool; - new_currdev.d_kind.zfs.root_guid = zargs->root; + new_currdev.zfs.pool_guid = zargs->pool; + new_currdev.zfs.root_guid = zargs->root; if (zargs->size >= sizeof(*zargs) && zargs->primary_vdev != 0) { sprintf(buf, "%llu", zargs->primary_pool); @@ -333,8 +324,8 @@ extract_currdev(void) } } else { /* old style zfsboot block */ - new_currdev.d_kind.zfs.pool_guid = kargs->zfspool; - new_currdev.d_kind.zfs.root_guid = 0; + new_currdev.zfs.pool_guid = kargs->zfspool; + new_currdev.zfs.root_guid = 0; } new_currdev.dd.d_dev = &zfs_dev; @@ -350,14 +341,12 @@ extract_currdev(void) #endif } else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) { /* The passed-in boot device is bad */ - new_currdev.d_kind.biosdisk.slice = -1; - new_currdev.d_kind.biosdisk.partition = 0; + new_currdev.disk.d_slice = -1; + new_currdev.disk.d_partition = 0; biosdev = -1; } else { - new_currdev.d_kind.biosdisk.slice = - B_SLICE(initial_bootdev) - 1; - new_currdev.d_kind.biosdisk.partition = - B_PARTITION(initial_bootdev); + new_currdev.disk.d_slice = B_SLICE(initial_bootdev) - 1; + new_currdev.disk.d_partition = B_PARTITION(initial_bootdev); biosdev = initial_bootinfo->bi_bios_dev; /* @@ -389,13 +378,10 @@ extract_currdev(void) #ifdef LOADER_ZFS_SUPPORT if (new_currdev.dd.d_dev->dv_type == DEVT_ZFS) - init_zfs_boot_options(zfs_fmtdev(&new_currdev)); + init_zfs_boot_options(devformat(&new_currdev.dd)); #endif - env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev), - i386_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev), - env_noset, env_nounset); + set_currdev(devformat(&new_currdev.dd)); } COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); @@ -462,7 +448,7 @@ i386_zfs_probe(void) for (dev.dd.d_unit = 0; bd_unit2bios(&dev) >= 0; dev.dd.d_unit++) { snprintf(devname, sizeof(devname), "%s%d:", bioshd.dv_name, dev.dd.d_unit); - zfs_probe_dev(devname, NULL); + zfs_probe_dev(devname, NULL, true); } } #endif diff --git a/stand/i386/loader/version b/stand/i386/loader/version index 7a2acaf1859a..ea8067efa243 100644 --- a/stand/i386/loader/version +++ b/stand/i386/loader/version @@ -1,4 +1,3 @@ -$FreeBSD$ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this file is important. Make sure the current version number is on line 6. diff --git a/stand/i386/loader_4th/Makefile b/stand/i386/loader_4th/Makefile index 3659f7efe673..3ca078668437 100644 --- a/stand/i386/loader_4th/Makefile +++ b/stand/i386/loader_4th/Makefile @@ -1,6 +1,6 @@ -# $FreeBSD$ LOADER_INTERP=4th +INSTALL_LOADER_HELP_FILE=no .include "../loader/Makefile" diff --git a/stand/i386/loader_4th/Makefile.depend b/stand/i386/loader_4th/Makefile.depend index 8807f64e88d6..1d7ca65bf9ef 100644 --- a/stand/i386/loader_4th/Makefile.depend +++ b/stand/i386/loader_4th/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/loader_lua/Makefile b/stand/i386/loader_lua/Makefile index 3a4268440cf6..6866e742290a 100644 --- a/stand/i386/loader_lua/Makefile +++ b/stand/i386/loader_lua/Makefile @@ -1,6 +1,6 @@ -# $FreeBSD$ LOADER_INTERP=lua +INSTALL_LOADER_HELP_FILE=no .include "../loader/Makefile" diff --git a/stand/i386/loader_simp/Makefile b/stand/i386/loader_simp/Makefile index 0c27d5673941..ac873c1a3033 100644 --- a/stand/i386/loader_simp/Makefile +++ b/stand/i386/loader_simp/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ LOADER_INTERP=simp diff --git a/stand/i386/mbr/Makefile b/stand/i386/mbr/Makefile index dca202cb815b..ce38590bf859 100644 --- a/stand/i386/mbr/Makefile +++ b/stand/i386/mbr/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ PROG= mbr STRIP= diff --git a/stand/i386/mbr/Makefile.depend b/stand/i386/mbr/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/i386/mbr/Makefile.depend +++ b/stand/i386/mbr/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/mbr/mbr.S b/stand/i386/mbr/mbr.S index 3cfc20dd58e1..02843d84e6c2 100644 --- a/stand/i386/mbr/mbr.S +++ b/stand/i386/mbr/mbr.S @@ -13,8 +13,6 @@ # purpose. # -# $FreeBSD$ - # A 512 byte MBR boot manager that simply boots the active partition. .set LOAD,0x7c00 # Load address diff --git a/stand/i386/pmbr/Makefile b/stand/i386/pmbr/Makefile index e09bb610fc18..30a5e37b0e44 100644 --- a/stand/i386/pmbr/Makefile +++ b/stand/i386/pmbr/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ PROG= pmbr STRIP= diff --git a/stand/i386/pmbr/Makefile.depend b/stand/i386/pmbr/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/stand/i386/pmbr/Makefile.depend +++ b/stand/i386/pmbr/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/pmbr/pmbr.S b/stand/i386/pmbr/pmbr.S index c394835757af..c61acbe261bd 100644 --- a/stand/i386/pmbr/pmbr.S +++ b/stand/i386/pmbr/pmbr.S @@ -27,7 +27,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD$ # # Partly from: src/sys/boot/i386/mbr/mbr.s 1.7 diff --git a/stand/i386/pxeldr/Makefile b/stand/i386/pxeldr/Makefile index 2184d391937f..b2ecedd45940 100644 --- a/stand/i386/pxeldr/Makefile +++ b/stand/i386/pxeldr/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -38,6 +37,8 @@ LDFLAGS+=${LDFLAGS_BIN} CLEANFILES+= ${LOADER} +# Note: pxeldr.S assumes a.out and will require changes for ELF if the output +# format is changed to ELF. ${LOADER}: ${LOADERBIN} ${BTXLDR} ${BTXKERN} btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ -b ${BTXKERN} ${LOADERBIN} diff --git a/stand/i386/pxeldr/Makefile.depend b/stand/i386/pxeldr/Makefile.depend index 35b75b1ca42b..c3043b1105df 100644 --- a/stand/i386/pxeldr/Makefile.depend +++ b/stand/i386/pxeldr/Makefile.depend @@ -1,12 +1,9 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ include \ - stand/i386/btx/btx \ - stand/i386/btx/btxldr \ - stand/i386/loader \ - + ${BOOT_MACHINE_DIR}/btx/btx \ + ${BOOT_MACHINE_DIR}/btx/btxldr \ .include <dirdeps.mk> diff --git a/stand/i386/pxeldr/Makefile.depend.options b/stand/i386/pxeldr/Makefile.depend.options new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/stand/i386/pxeldr/Makefile.depend.options diff --git a/stand/i386/pxeldr/pxeboot.8 b/stand/i386/pxeldr/pxeboot.8 index 58b1f06bcd0f..e10e570edf54 100644 --- a/stand/i386/pxeldr/pxeboot.8 +++ b/stand/i386/pxeldr/pxeboot.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd February 15, 2021 .Dt PXEBOOT 8 .Os diff --git a/stand/i386/pxeldr/pxeldr.S b/stand/i386/pxeldr/pxeldr.S index 09e9fda7aa61..92824acea2be 100644 --- a/stand/i386/pxeldr/pxeldr.S +++ b/stand/i386/pxeldr/pxeldr.S @@ -21,8 +21,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ /* diff --git a/stand/i386/zfsboot/Makefile b/stand/i386/zfsboot/Makefile index 243b5e99287c..dcfac140231a 100644 --- a/stand/i386/zfsboot/Makefile +++ b/stand/i386/zfsboot/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> @@ -8,7 +7,7 @@ FILES= zfsboot MAN= zfsboot.8 BOOT_COMCONSOLE_PORT?= 0x3f8 -BOOT_COMCONSOLE_SPEED?= 9600 +BOOT_COMCONSOLE_SPEED?= 115200 B2SIOFMT?= 0x3 REL1= 0x700 diff --git a/stand/i386/zfsboot/Makefile.depend b/stand/i386/zfsboot/Makefile.depend index 58b2754996b4..92ab022283fd 100644 --- a/stand/i386/zfsboot/Makefile.depend +++ b/stand/i386/zfsboot/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/stand/i386/zfsboot/zfsboot.8 b/stand/i386/zfsboot/zfsboot.8 index 7ed8ea7df010..a8411bc065d0 100644 --- a/stand/i386/zfsboot/zfsboot.8 +++ b/stand/i386/zfsboot/zfsboot.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd March 27, 2018 .Dt ZFSBOOT 8 .Os diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c index 8dd3066f15e5..14464eeda567 100644 --- a/stand/i386/zfsboot/zfsboot.c +++ b/stand/i386/zfsboot/zfsboot.c @@ -14,8 +14,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stand.h> #include <sys/param.h> @@ -168,7 +166,7 @@ main(void) { unsigned i; int auto_boot, fd, nextboot = 0; - struct disk_devdesc devdesc; + struct disk_devdesc *devdesc; bios_getmem(); @@ -208,25 +206,25 @@ main(void) bd_bios2unit(bootinfo.bi_bios_dev)); /* Set up currdev variable to have hooks in place. */ - env_setenv("currdev", EV_VOLATILE, "", i386_setcurrdev, + env_setenv("currdev", EV_VOLATILE, "", gen_setcurrdev, env_nounset); - for (i = 0; devsw[i] != NULL; i++) - if (devsw[i]->dv_init != NULL) - (devsw[i]->dv_init)(); + devinit(); - disk_parsedev(&devdesc, boot_devname + 4, NULL); + /* XXX assumes this will be a disk, but it looks likely give above */ + disk_parsedev((struct devdesc **)&devdesc, boot_devname, NULL); - bootdev = MAKEBOOTDEV(dev_maj[DEVT_DISK], devdesc.d_slice + 1, - devdesc.dd.d_unit, - devdesc.d_partition >= 0 ? devdesc.d_partition : 0xff); + bootdev = MAKEBOOTDEV(dev_maj[DEVT_DISK], devdesc->d_slice + 1, + devdesc->dd.d_unit, + devdesc->d_partition >= 0 ? devdesc->d_partition : 0xff); + free(devdesc); /* - * zfs_fmtdev() can be called only after dv_init + * devformat() can be called only after dv_init */ if (bdev != NULL && bdev->dd.d_dev->dv_type == DEVT_ZFS) { /* set up proper device name string for ZFS */ - strncpy(boot_devname, zfs_fmtdev(bdev), sizeof (boot_devname)); + strncpy(boot_devname, devformat(&bdev->dd), sizeof (boot_devname)); if (zfs_get_bootonce(bdev, OS_BOOTONCE, cmd, sizeof(cmd)) == 0) { nvlist_t *benv; @@ -256,7 +254,7 @@ main(void) free(bdev); i386_getdev((void **)&bdev, boot_devname, NULL); - env_setenv("currdev", EV_VOLATILE, boot_devname, i386_setcurrdev, + env_setenv("currdev", EV_VOLATILE, boot_devname, gen_setcurrdev, env_nounset); /* Process configuration file */ @@ -467,8 +465,8 @@ load(void) if (bdev->dd.d_dev->dv_type == DEVT_ZFS) { zfsargs.size = sizeof(zfsargs); - zfsargs.pool = bdev->d_kind.zfs.pool_guid; - zfsargs.root = bdev->d_kind.zfs.root_guid; + zfsargs.pool = bdev->zfs.pool_guid; + zfsargs.root = bdev->zfs.root_guid; #ifdef LOADER_GELI_SUPPORT export_geli_boot_data(&zfsargs.gelidata); #endif @@ -481,8 +479,8 @@ load(void) __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), bootdev, KARGS_FLAGS_ZFS | KARGS_FLAGS_EXTARG, - (uint32_t)bdev->d_kind.zfs.pool_guid, - (uint32_t)(bdev->d_kind.zfs.pool_guid >> 32), + (uint32_t)bdev->zfs.pool_guid, + (uint32_t)(bdev->zfs.pool_guid >> 32), VTOP(&bootinfo), zfsargs); } else { @@ -528,13 +526,12 @@ mount_root(char *arg) free(bdev); bdev = ddesc; if (bdev->dd.d_dev->dv_type == DEVT_DISK) { - if (bdev->d_kind.biosdisk.partition == -1) + if (bdev->disk.d_partition == -1) part = 0xff; else - part = bdev->d_kind.biosdisk.partition; + part = bdev->disk.d_partition; bootdev = MAKEBOOTDEV(dev_maj[bdev->dd.d_dev->dv_type], - bdev->d_kind.biosdisk.slice + 1, - bdev->dd.d_unit, part); + bdev->disk.d_slice + 1, bdev->dd.d_unit, part); bootinfo.bi_bios_dev = bd_unit2bios(bdev); } strncpy(boot_devname, root, sizeof (boot_devname)); @@ -707,15 +704,15 @@ i386_zfs_probe(void) dev.dd.d_unit); /* If this is not boot disk, use generic probe. */ if (dev.dd.d_unit != boot_unit) - zfs_probe_dev(devname, NULL); + zfs_probe_dev(devname, NULL, true); else - zfs_probe_dev(devname, &pool_guid); + zfs_probe_dev(devname, &pool_guid, true); if (pool_guid != 0 && bdev == NULL) { bdev = malloc(sizeof (struct i386_devdesc)); bzero(bdev, sizeof (struct i386_devdesc)); - bdev->dd.d_dev = &zfs_dev; - bdev->d_kind.zfs.pool_guid = pool_guid; + bdev->zfs.dd.d_dev = &zfs_dev; + bdev->zfs.pool_guid = pool_guid; } } } diff --git a/stand/i386/zfsboot/zfsldr.S b/stand/i386/zfsboot/zfsldr.S index bf43a5cbc364..cd8289f952fd 100644 --- a/stand/i386/zfsboot/zfsldr.S +++ b/stand/i386/zfsboot/zfsldr.S @@ -11,8 +11,6 @@ * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. - * - * $FreeBSD$ */ /* Memory Locations */ diff --git a/stand/images/Makefile b/stand/images/Makefile index 432b1daa851b..44d2faf36e5f 100644 --- a/stand/images/Makefile +++ b/stand/images/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ .include <bsd.init.mk> diff --git a/stand/kboot/Makefile b/stand/kboot/Makefile index 24ab77af66db..f5049a1c19c0 100644 --- a/stand/kboot/Makefile +++ b/stand/kboot/Makefile @@ -1,13 +1,14 @@ -# $FreeBSD$ +LOADER_DISK_SUPPORT?= yes LOADER_CD9660_SUPPORT?= yes LOADER_MSDOS_SUPPORT?= no LOADER_EXT2FS_SUPPORT?= yes LOADER_UFS_SUPPORT?= yes -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes +LOADER_ZFS_SUPPORT?= yes +LOADER_NET_SUPPORT?= no +LOADER_NFS_SUPPORT?= no LOADER_TFTP_SUPPORT?= no -LOADER_GZIP_SUPPORT?= yes +LOADER_GZIP_SUPPORT?= no LOADER_BZIP2_SUPPORT?= no .include <bsd.init.mk> @@ -17,12 +18,41 @@ NEWVERSWHAT= "kboot loader" ${MACHINE_ARCH} INSTALLFLAGS= -b # Architecture-specific loader code -SRCS= vers.c main.c host_syscalls.c hostcons.c hostdisk.c kbootfdt.c gfx_fb_stub.c +SRCS= \ + bootinfo.c \ + conf.c \ + crt1.c \ + gfx_fb_stub.c \ + host_syscalls.c \ + hostcons.c \ + hostdisk.c \ + hostfs.c \ + init.c \ + kbootfdt.c \ + main.c \ + seg.c \ + termios.c \ + util.c \ + vers.c CFLAGS.gfx_fb_stub.c += -I${SRCTOP}/contrib/pnglite -I${SRCTOP}/sys/teken +.if ${MK_LOADER_ZFS} != "no" +CFLAGS+= -I${ZFSSRC} +CFLAGS+= -I${SYSDIR}/contrib/openzfs/include +CFLAGS+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs +HAVE_ZFS=yes +.endif + +HELP_FILENAME= loader.help.kboot .include "${BOOTSRC}/fdt.mk" +# We share bootinfo.c with efi +.PATH: ${BOOTSRC}/efi/loader + +# Note: Since we're producing a userland binary, we key off of MACHINE_ARCH +# instead of the more normal MACHINE since the changes between different flavors +# of MACHINE_ARCH are large enough in Linux that it's easier that way. .PATH: ${.CURDIR}/arch/${MACHINE_ARCH} .include "${.CURDIR}/arch/${MACHINE_ARCH}/Makefile.inc" diff --git a/stand/kboot/README b/stand/kboot/README new file mode 100644 index 000000000000..ad390a023bb9 --- /dev/null +++ b/stand/kboot/README @@ -0,0 +1,48 @@ +So to make a Linux initrd: + +(1) mkdir .../initrd +(2) mkdir -p .../initrd/boot/defaults +(3) cd src/stand; make install DESTDIR=.../initrd +(4) Copy kernel to .../initrd/boot/kernel +(5) cd .../initrd +(6) cp boot/loader.kboot init +(7) find . | sort | cpio -o -H newc | gzip > /tmp/initrd.cpio +(8) download or build your linux kernel +(9) qemu-system-x86_64 -kernel ~/vmlinuz-5.19.0-051900-generic \ + -initrd /tmp/initrd.cpio \ + -m 256m -nographic \ + -monitor telnet::4444,server,nowait -serial stdio \ + -append "console=ttyS0" + (though you may need more than 256M of ram to actually boot FreeBSD and do + anything interesting with it and the serial console to stdio bit hasn't + been the most stable recipe lately). + +Notes: +For #6 you might need to strip loader.kboot if you copy it directly and don't + use make install. +For #7 the sort is important, and you may need LC_ALL=C for its invocation +For #7 gzip is but one of many methods, but it's the simplest to do. +For #9, this means we can automate it using methods from + src/tools/boot/rootgen.sh when the time comes. +#9 also likely generalizes to other architectures +For #8, see https://kernel.ubuntu.com/~kernel-ppa/mainline/ to download + a kernel suitable for testing... For arm, I've been using the + non 64k page kernels and 5.19 seems to not suck. + +aarch64: +qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt \ + -kernel ~/linuxboot/arm64/kernel/boot/vmlinuz-5.19.0-051900-generic \ + -initrd ~/linuxboot/arm64/initrd.img -m 256m -nographic \ + -monitor telnet::4444,server,nowait -serial stdio \ + -append "console=ttyAMA0" + +General + +Add -g -G to have gdb stop and wait for the debugger. This is useful for +debugging the trampoline (hbreak will set a hardware break that's durable across +code changes). If you set the breakpoint for the trampoline and it never hits, +then there's likely no RAM there and you got the PA to load to wrong. When +debugging the trampiline and up to that, use gdb /boot/loader. When debugging +the kernel, use kernel.full to get all the debugging. hbreak panic() is useful +on the latter since you'll see the original panic, not the panic you get from +there not being an early console. diff --git a/stand/kboot/arch/aarch64/Makefile.inc b/stand/kboot/arch/aarch64/Makefile.inc new file mode 100644 index 000000000000..50388d38dbf2 --- /dev/null +++ b/stand/kboot/arch/aarch64/Makefile.inc @@ -0,0 +1,12 @@ +SRCS+= host_syscall.S tramp.S exec.c load_addr.c fdt_arch.c + +.PATH: ${BOOTSRC}/arm64/libarm64 +CFLAGS+=-I${BOOTSRC}/arm64/libarm64 +SRCS+= cache.c + +CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include +# load address. set in linker script +RELOC?= 0x0 +CFLAGS+= -DRELOC=${RELOC} + +LDFLAGS= -nostdlib -static -T ${.CURDIR}/arch/${MACHINE_ARCH}/ldscript.${MACHINE_ARCH} diff --git a/stand/kboot/arch/aarch64/exec.c b/stand/kboot/arch/aarch64/exec.c new file mode 100644 index 000000000000..5ea45226bd3e --- /dev/null +++ b/stand/kboot/arch/aarch64/exec.c @@ -0,0 +1,292 @@ +/*- + * Copyright (c) 2006 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +#include <stand.h> +#include <string.h> + +#include <sys/param.h> +#include <sys/linker.h> +#include <machine/elf.h> + +#ifdef EFI +#include <efi.h> +#include <efilib.h> +#include "loader_efi.h" +#else +#include "host_syscall.h" +#endif +#include <machine/metadata.h> + +#include "bootstrap.h" +#include "kboot.h" +#include "bootstrap.h" + +#include "platform/acfreebsd.h" +#include "acconfig.h" +#define ACPI_SYSTEM_XFACE +#include "actypes.h" +#include "actbl.h" + +#include "cache.h" + +#ifndef EFI +#define LOADER_PAGE_SIZE PAGE_SIZE +#endif + +#ifdef EFI +static EFI_GUID acpi_guid = ACPI_TABLE_GUID; +static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID; +#endif + +static int elf64_exec(struct preloaded_file *amp); +static int elf64_obj_exec(struct preloaded_file *amp); + +bool do_mem_map = false; + +extern uint32_t efi_map_size; +extern vm_paddr_t efi_map_phys_src; /* From DTB */ +extern vm_paddr_t efi_map_phys_dst; /* From our memory map metadata module */ + +int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, + bool exit_bs); + +static struct file_format arm64_elf = { + elf64_loadfile, + elf64_exec +}; + +struct file_format *file_formats[] = { + &arm64_elf, + NULL +}; + +#ifndef EFI +extern uintptr_t tramp; +extern uint32_t tramp_size; +extern uint32_t tramp_data_offset; + +struct trampoline_data { + uint64_t entry; // 0 (PA where kernel loaded) + uint64_t modulep; // 8 module metadata + uint64_t memmap_src; // 16 Linux-provided memory map PA + uint64_t memmap_dst; // 24 Module data copy PA + uint64_t memmap_len; // 32 Length to copy +}; +#endif + +static int +elf64_exec(struct preloaded_file *fp) +{ + vm_offset_t modulep, kernendp; +#ifdef EFI + vm_offset_t clean_addr; + size_t clean_size; + void (*entry)(vm_offset_t); +#else + vm_offset_t trampolinebase; + vm_offset_t staging; + void *trampcode; + uint64_t *trampoline; + struct trampoline_data *trampoline_data; + int nseg; + void *kseg; +#endif + struct file_metadata *md; + Elf_Ehdr *ehdr; + int error; +#ifdef EFI + ACPI_TABLE_RSDP *rsdp; + char buf[24]; + int revision; + + /* + * Report the RSDP to the kernel. The old code used the 'hints' method + * to communite this to the kernel. However, while convenient, the + * 'hints' method is fragile and does not work when static hints are + * compiled into the kernel. Instead, move to setting different tunables + * that start with acpi. The old 'hints' can be removed before we branch + * for FreeBSD 15. + */ + rsdp = efi_get_table(&acpi20_guid); + if (rsdp == NULL) { + rsdp = efi_get_table(&acpi_guid); + } + if (rsdp != NULL) { + sprintf(buf, "0x%016llx", (unsigned long long)rsdp); + setenv("hint.acpi.0.rsdp", buf, 1); + setenv("acpi.rsdp", buf, 1); + revision = rsdp->Revision; + if (revision == 0) + revision = 1; + sprintf(buf, "%d", revision); + setenv("hint.acpi.0.revision", buf, 1); + setenv("acpi.revision", buf, 1); + strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId)); + buf[sizeof(rsdp->OemId)] = '\0'; + setenv("hint.acpi.0.oem", buf, 1); + setenv("acpi.oem", buf, 1); + sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress); + setenv("hint.acpi.0.rsdt", buf, 1); + setenv("acpi.rsdt", buf, 1); + if (revision >= 2) { + /* XXX extended checksum? */ + sprintf(buf, "0x%016llx", + (unsigned long long)rsdp->XsdtPhysicalAddress); + setenv("hint.acpi.0.xsdt", buf, 1); + setenv("acpi.xsdt", buf, 1); + sprintf(buf, "%d", rsdp->Length); + setenv("hint.acpi.0.xsdt_length", buf, 1); + setenv("acpi.xsdt_length", buf, 1); + } + } +#else + vm_offset_t rsdp; + rsdp = acpi_rsdp(); + if (rsdp != 0) { + char buf[24]; + + printf("Found ACPI 2.0 at %#016lx\n", rsdp); + sprintf(buf, "0x%016llx", (unsigned long long)rsdp); + setenv("hint.acpi.0.rsdp", buf, 1); /* For 13.1R bootability */ + setenv("acpi.rsdp", buf, 1); + /* Nobody uses the rest of that stuff */ + } + + + // XXX Question: why not just use malloc? + trampcode = host_getmem(LOADER_PAGE_SIZE); + if (trampcode == NULL) { + printf("Unable to allocate trampoline\n"); + return (ENOMEM); + } + bzero((void *)trampcode, LOADER_PAGE_SIZE); + bcopy((void *)&tramp, (void *)trampcode, tramp_size); + trampoline = (void *)trampcode; + + /* + * Figure out where to put it. + * + * Linux does not allow us to kexec_load into any part of memory. Ask + * arch_loadaddr to resolve the first available chunk of physical memory + * where loading is possible (load_addr). + * + * The kernel is loaded at the 'base' address in continguous physical + * memory. We use the 2MB in front of the kernel as a place to put our + * trampoline, but that's really overkill since we only need ~100 bytes. + * The arm64 kernel's entry requirements are only 'load the kernel at a + * 2MB alignment' and it figures out the rest, creates the right page + * tables, etc. + */ + staging = kboot_get_phys_load_segment(); + printf("Load address at %#jx\n", (uintmax_t)staging); + printf("Relocation offset is %#jx\n", (uintmax_t)elf64_relocation_offset); +#endif + + if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) + return(EFTYPE); + + ehdr = (Elf_Ehdr *)&(md->md_data); +#ifdef EFI + entry = efi_translate(ehdr->e_entry); + + efi_time_fini(); +#endif + error = bi_load(fp->f_args, &modulep, &kernendp, true); + if (error != 0) { +#ifdef EFI + efi_time_init(); +#endif + return (error); + } + + dev_cleanup(); + +#ifdef EFI + /* Clean D-cache under kernel area and invalidate whole I-cache */ + clean_addr = (vm_offset_t)efi_translate(fp->f_addr); + clean_size = (vm_offset_t)efi_translate(kernendp) - clean_addr; + + cpu_flush_dcache((void *)clean_addr, clean_size); + cpu_inval_icache(); + + (*entry)(modulep); + +#else + /* Linux will flush the caches, just pass this data into our trampoline and go */ + trampoline_data = (void *)trampoline + tramp_data_offset; + memset(trampoline_data, 0, sizeof(*trampoline_data)); + trampoline_data->entry = ehdr->e_entry - fp->f_addr + staging; + trampoline_data->modulep = modulep; + printf("Modulep = %jx\n", (uintmax_t)modulep); + if (efi_map_phys_src != 0) { + md = file_findmetadata(fp, MODINFOMD_EFI_MAP); + if (md == NULL || md->md_addr == 0) { + printf("Need to copy EFI MAP, but EFI MAP not found. %p\n", md); + } else { + printf("Metadata EFI map loaded at VA %lx\n", md->md_addr); + efi_map_phys_dst = md->md_addr + staging + + roundup2(sizeof(struct efi_map_header), 16) - fp->f_addr; + trampoline_data->memmap_src = efi_map_phys_src; + trampoline_data->memmap_dst = efi_map_phys_dst; + trampoline_data->memmap_len = efi_map_size - roundup2(sizeof(struct efi_map_header), 16); + printf("Copying UEFI Memory Map data from %#lx to %#lx %ld bytes\n", + efi_map_phys_src, + trampoline_data->memmap_dst, + trampoline_data->memmap_len); + } + } + /* + * Copy the trampoline to the ksegs. Since we're just bouncing off of + * this into the kernel, no need to preserve the pages. On arm64, the + * kernel sets up the initial page table, so we don't have to preserve + * the memory used for the trampoline past when it calls the kernel. + */ + printf("kernendp = %#llx\n", (long long)kernendp); + trampolinebase = staging + (kernendp - fp->f_addr); + printf("trampolinebase = %#llx\n", (long long)trampolinebase); + archsw.arch_copyin((void *)trampcode, kernendp, tramp_size); + printf("Trampoline bouncing to %#llx\n", (long long)trampoline_data->entry); + + kboot_kseg_get(&nseg, &kseg); + error = host_kexec_load(trampolinebase, nseg, kseg, HOST_KEXEC_ARCH_AARCH64); + if (error != 0) + panic("kexec_load returned error: %d", error); + host_reboot(HOST_REBOOT_MAGIC1, HOST_REBOOT_MAGIC2, HOST_REBOOT_CMD_KEXEC, 0); +#endif + + panic("exec returned"); +} + +static int +elf64_obj_exec(struct preloaded_file *fp) +{ + + printf("%s called for preloaded file %p (=%s):\n", __func__, fp, + fp->f_name); + return (ENOSYS); +} + diff --git a/stand/kboot/arch/aarch64/fdt_arch.c b/stand/kboot/arch/aarch64/fdt_arch.c new file mode 100644 index 000000000000..bc480808d14f --- /dev/null +++ b/stand/kboot/arch/aarch64/fdt_arch.c @@ -0,0 +1,14 @@ +/*- + * Copyright (c) 2022 Netflix, Inc + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <sys/types.h> +#include "kboot.h" + +void +fdt_arch_fixups(void *fdtp) +{ + /* Unsure what to pass fixup */ +} diff --git a/stand/kboot/arch/aarch64/host_syscall.S b/stand/kboot/arch/aarch64/host_syscall.S new file mode 100644 index 000000000000..db3ecf0f885d --- /dev/null +++ b/stand/kboot/arch/aarch64/host_syscall.S @@ -0,0 +1,18 @@ +#include <machine/asm.h> + +/* + * Emulate the Linux system call interface. System call number in x8. + * Args in x0, x1, x2, x3, x4 and x5. Return in x0. + */ +ENTRY(host_syscall) + mov x8, x0 + mov x0, x1 + mov x1, x2 + mov x2, x3 + mov x3, x4 + mov x4, x5 + mov x5, x6 + svc 0 + ret +/* Note: We're exposing the raw return value to the caller */ +END(host_syscall) diff --git a/stand/efi/loader/arch/i386/ldscript.i386 b/stand/kboot/arch/aarch64/ldscript.aarch64 index e17212a1bddd..62b7d2b6be01 100644 --- a/stand/efi/loader/arch/i386/ldscript.i386 +++ b/stand/kboot/arch/aarch64/ldscript.aarch64 @@ -1,13 +1,17 @@ -/* $FreeBSD$ */ -OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd", "elf32-i386-freebsd") -OUTPUT_ARCH(i386) +OUTPUT_FORMAT("elf64-aarch64", "elf64-aarch64", "elf64-aarch64") +OUTPUT_ARCH(aarch64) ENTRY(_start) SECTIONS { /* Read-only sections, merged into text segment: */ - . = 0; + . = 0x401000; ImageBase = .; - . = SIZEOF_HEADERS; + .hash : { *(.hash) } /* this MUST come first! */ + . = ALIGN(4096); + .eh_frame : + { + *(.eh_frame) + } . = ALIGN(4096); .text : { *(.text .stub .text.* .gnu.linkonce.t.*) @@ -52,25 +56,15 @@ SECTIONS . = ALIGN(4096); .dynamic : { *(.dynamic) } . = ALIGN(4096); - .rel.dyn : { - *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) - *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) - *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) - *(.rel.got) - *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) - *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) - *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) - *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) - *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) - *(.rel.plt) - *(.relset_*) - *(.rel.dyn .rel.dyn.*) + .rela.dyn : { + *(.rela.data*) + *(.rela.got) + *(.rela.stab) + *(.relaset_*) } . = ALIGN(4096); .reloc : { *(.reloc) } . = ALIGN(4096); - .hash : { *(.hash) } - . = ALIGN(4096); .dynsym : { *(.dynsym) } . = ALIGN(4096); .dynstr : { *(.dynstr) } diff --git a/stand/kboot/arch/aarch64/load_addr.c b/stand/kboot/arch/aarch64/load_addr.c new file mode 100644 index 000000000000..4cbbd5192f5b --- /dev/null +++ b/stand/kboot/arch/aarch64/load_addr.c @@ -0,0 +1,210 @@ +/*- + * Copyright (c) 2022 Netflix, Inc + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <sys/param.h> +#include <sys/efi.h> +#include <machine/metadata.h> +#include <sys/linker.h> +#include <fdt_platform.h> +#include <libfdt.h> + +#include "kboot.h" +#include "bootstrap.h" + +/* + * Info from dtb about the EFI system + */ +vm_paddr_t efi_systbl_phys; +struct efi_map_header *efi_map_hdr; +uint32_t efi_map_size; +vm_paddr_t efi_map_phys_src; /* From DTB */ +vm_paddr_t efi_map_phys_dst; /* From our memory map metadata module */ + +static bool +do_memory_from_fdt(int fd) +{ + struct stat sb; + char *buf = NULL; + int len, offset, fd2 = -1; + uint32_t sz, ver, esz, efisz; + uint64_t mmap_pa; + const uint32_t *u32p; + const uint64_t *u64p; + struct efi_map_header *efihdr; + struct efi_md *map; + + if (fstat(fd, &sb) < 0) + return false; + buf = malloc(sb.st_size); + if (buf == NULL) + return false; + len = read(fd, buf, sb.st_size); + /* NB: we're reading this from sysfs, so mismatch OK */ + if (len <= 0) + goto errout; + + /* + * Look for /chosen to find these values: + * linux,uefi-system-table PA of the UEFI System Table. + * linux,uefi-mmap-start PA of the UEFI memory map + * linux,uefi-mmap-size Size of mmap + * linux,uefi-mmap-desc-size Size of each entry of mmap + * linux,uefi-mmap-desc-ver Format version, should be 1 + */ + offset = fdt_path_offset(buf, "/chosen"); + if (offset <= 0) + goto errout; + u64p = fdt_getprop(buf, offset, "linux,uefi-system-table", &len); + if (u64p == NULL) + goto errout; + efi_systbl_phys = fdt64_to_cpu(*u64p); + u32p = fdt_getprop(buf, offset, "linux,uefi-mmap-desc-ver", &len); + if (u32p == NULL) + goto errout; + ver = fdt32_to_cpu(*u32p); + u32p = fdt_getprop(buf, offset, "linux,uefi-mmap-desc-size", &len); + if (u32p == NULL) + goto errout; + esz = fdt32_to_cpu(*u32p); + u32p = fdt_getprop(buf, offset, "linux,uefi-mmap-size", &len); + if (u32p == NULL) + goto errout; + sz = fdt32_to_cpu(*u32p); + u64p = fdt_getprop(buf, offset, "linux,uefi-mmap-start", &len); + if (u64p == NULL) + goto errout; + mmap_pa = fdt64_to_cpu(*u64p); + free(buf); + + printf("UEFI MMAP: Ver %d Ent Size %d Tot Size %d PA %#lx\n", + ver, esz, sz, mmap_pa); + + /* + * We may have no ability to read the PA that this map is in, so pass + * the address to FreeBSD via a rather odd flag entry as the first map + * so early boot can copy the memory map into this space and have the + * rest of the code cope. + */ + efisz = (sizeof(*efihdr) + 0xf) & ~0xf; + buf = malloc(sz + efisz); + if (buf == NULL) + return false; + efihdr = (struct efi_map_header *)buf; + map = (struct efi_md *)((uint8_t *)efihdr + efisz); + bzero(map, sz); + efihdr->memory_size = sz; + efihdr->descriptor_size = esz; + efihdr->descriptor_version = ver; + + /* + * Save EFI table. Either this will be an empty table filled in by the trampoline, + * or we'll read it below. Either way, set these two variables so we share the best + * UEFI memory map with the kernel. + */ + efi_map_hdr = efihdr; + efi_map_size = sz + efisz; + + /* + * Try to read in the actual UEFI map. + */ + fd2 = open("host:/dev/mem", O_RDONLY); + if (fd2 < 0) { + printf("Will read UEFI mem map in tramp: no /dev/mem, need CONFIG_DEVMEM=y\n"); + goto no_read; + } + if (lseek(fd2, mmap_pa, SEEK_SET) < 0) { + printf("Will read UEFI mem map in tramp: lseek failed\n"); + goto no_read; + } + len = read(fd2, map, sz); + if (len != sz) { + if (len < 0 && errno == EPERM) + printf("Will read UEFI mem map in tramp: kernel needs CONFIG_STRICT_DEVMEM=n\n"); + else + printf("Will read UEFI mem map in tramp: lean = %d errno = %d\n", len, errno); + goto no_read; + } + printf("Read UEFI mem map from physmem\n"); + efi_map_phys_src = 0; /* Mark MODINFOMD_EFI_MAP as valid */ + close(fd2); + return true; /* OK, we really have the memory map */ + +no_read: + efi_map_phys_src = mmap_pa; + close(fd2); + return true; /* We can get it the trampoline */ + +errout: + free(buf); + return false; +} + +bool +enumerate_memory_arch(void) +{ + int fd = -1; + bool rv = false; + + fd = open("host:/sys/firmware/fdt", O_RDONLY); + if (fd != -1) { + rv = do_memory_from_fdt(fd); + close(fd); + /* + * So, we have physaddr to the memory table. However, we can't + * open /dev/mem on some platforms to get the actual table. So + * we have to fall through to get it from /proc/iomem. + */ + } + if (!rv) { + printf("Could not obtain UEFI memory tables, expect failure\n"); + } + + populate_avail_from_iomem(); + + print_avail(); + + return true; +} + +uint64_t +kboot_get_phys_load_segment(void) +{ +#define HOLE_SIZE (64ul << 20) +#define KERN_ALIGN (2ul << 20) + static uint64_t s = 0; + + if (s != 0) + return (s); + + s = first_avail(KERN_ALIGN, HOLE_SIZE, SYSTEM_RAM); + if (s != 0) + return (s); + s = 0x40000000 | 0x4200000; /* should never get here */ + printf("Falling back to crazy address %#lx\n", s); + return (s); +} + +void +bi_loadsmap(struct preloaded_file *kfp) +{ + + /* + * Make a note of a systbl. This is nearly mandatory on AARCH64. + */ + if (efi_systbl_phys) + file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof(efi_systbl_phys), &efi_systbl_phys); + + /* + * If we have efi_map_hdr, then it's a pointer to the PA where this + * memory map lives. The trampoline code will copy it over. If we don't + * have it, we use whatever we found in /proc/iomap. + */ + if (efi_map_hdr != NULL) { + file_addmetadata(kfp, MODINFOMD_EFI_MAP, efi_map_size, efi_map_hdr); + return; + } + panic("Can't get UEFI memory map, nor a pointer to it, can't proceed.\n"); +} diff --git a/stand/kboot/arch/aarch64/start_arch.h b/stand/kboot/arch/aarch64/start_arch.h new file mode 100644 index 000000000000..467ba054c9f0 --- /dev/null +++ b/stand/kboot/arch/aarch64/start_arch.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022, Netflix, Inc. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +/* + * Provides a _start routine that calls a _start_c routine that takes a pointer + * to the stack as documented in crt1.c. We skip the pointer to _DYNAMIC since + * we don't support dynamic libraries, at all. And while _start_c is our own + * thing and doesn't have a second arg, we comport to the calling conventions + * that glibc and musl have by passing x1 as 0 for the dynamic pointer. We + * likely could call main directly with only a few more lines of code, but this + * is simple enough and concentrates all the expressable in C stuff there. We + * also generate eh_frames should we need to debug things (it doesn't change the + * genreated code, but leaves enough breadcrumbs to keep gdb happy) + */ + +__asm__( +".text\n" /* ENTRY(_start) -- can't expand and stringify, so by hand */ +".align 2\n" +".global _start\n" +".type _start, #function\n" +"_start:\n" +".cfi_startproc\n" +/* + * Linux zeros all registers so x29 (frame pointer) and x30 (link register) are 0. + */ +" mov x0, sp\n" /* Pointer to argc, etc kernel left on the stack */ +" and sp, x0, #-16\n" /* Align stack to 16-byte boundary */ +" b _start_c\n" /* Our MI code takes it from here */ +/* NORETURN */ +".ltorg\n" /* END(_start) */ +".cfi_endproc\n" +".size _start, .-_start\n" +); diff --git a/stand/kboot/arch/aarch64/stat_arch.h b/stand/kboot/arch/aarch64/stat_arch.h new file mode 100644 index 000000000000..9b52fe60c449 --- /dev/null +++ b/stand/kboot/arch/aarch64/stat_arch.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2005-2020 Rich Felker, et al. + * + * SPDX-License-Identifier: MIT + * + * Note: From the musl project + */ + +typedef int host_nlink_t; + +struct host_kstat { + host_dev_t st_dev; + host_ino_t st_ino; + host_mode_t st_mode; + host_nlink_t st_nlink; + host_uid_t st_uid; + host_gid_t st_gid; + host_dev_t st_rdev; + unsigned long __pad; + host_off_t st_size; + host_blksize_t st_blksize; + int __pad2; + host_blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + unsigned __pad_for_future[2]; +}; diff --git a/stand/kboot/arch/aarch64/syscall_nr.h b/stand/kboot/arch/aarch64/syscall_nr.h new file mode 100644 index 000000000000..83069dd8dc76 --- /dev/null +++ b/stand/kboot/arch/aarch64/syscall_nr.h @@ -0,0 +1,22 @@ +#define SYS_close 57 +#define SYS_dup 23 +#define SYS_exit 93 +#define SYS_fstat 80 +#define SYS_getdents64 61 +#define SYS_getpid 172 +#define SYS_gettimeofday 169 +#define SYS_ioctl 29 +#define SYS_lseek 62 +#define SYS_kexec_load 104 +#define SYS_mkdirat 34 +#define SYS_mmap 222 +#define SYS_mount 40 +#define SYS_munmap 215 +#define SYS_newfstatat 79 +#define SYS_openat 56 +#define SYS_pselect6 72 +#define SYS_read 63 +#define SYS_reboot 142 +#define SYS_symlinkat 36 +#define SYS_uname 160 +#define SYS_write 64 diff --git a/stand/kboot/arch/aarch64/termios_arch.h b/stand/kboot/arch/aarch64/termios_arch.h new file mode 100644 index 000000000000..5db0b9831cdb --- /dev/null +++ b/stand/kboot/arch/aarch64/termios_arch.h @@ -0,0 +1,7 @@ +/*- + * Copyright (c) 2022, Netflix, Inc. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include "termios_gen.h" diff --git a/stand/kboot/arch/aarch64/tramp.S b/stand/kboot/arch/aarch64/tramp.S new file mode 100644 index 000000000000..9304ca325299 --- /dev/null +++ b/stand/kboot/arch/aarch64/tramp.S @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2022, Netflix, Inc. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +/* + * This is the trampoline that starts the FreeBSD kernel. Since the Linux kernel + * calls this routine with no args, and has a different environment than the boot + * loader provides and that the kernel expects, this code is responsible for setting + * all that up and calling the normal kernel entry point. It's analogous ot the + * "purgatory" code in the linux kernel. Details about these operations are + * contained in comments below. On aarch64, the kernel will start all the APs so + * we don't have to worry about them here. + */ + +/* + * Keep in sync with exec.c. Kexec starts aarch64_tramp w/o any + * parameters, so store them here. + * + * struct trampoline_data { + * uint64_t entry; // 0 (PA where kernel loaded) + * uint64_t modulep; // 8 module metadata + * uint64_t memmap_src; // 16 Linux-provided memory map PA + * uint64_t memmap_dst; // 24 Module data copy PA + * uint64_t memmap_len; // 32 Length to copy + * }; + * + * FreeBSD's arm64 entry point is _start which assumes: + * MMU on with an identity map, or off + * D-Cache: off + * I-Cache: on or off + * We are loaded at a 2MiB aligned address + * Module data (modulep) pointer in x0 + * + * The rest of the boot loader tells Linux to land the kernel in its final + * location with the needed alignment, etc. It does this, and then we take over. + * + * The linux kernel will helpfully turn off the MMU, flush the caches, disables + * them, etc. It calls the tramp with two args: FDT blob addresss in x0 and the + * EL2 vectors in x1. Currently, we make use of neither of these parameters: we + * pass whatever dtb we think we need as part of the module data and we're a bit + * weak on hypervisor support at the moment. _start's requirements are all + * satisifed. + * + * This trampoline sets up the arguments the kernel expects and jumps to the + * kernel _start address. We pass the modulep pointer in x0, as _start + * expects. We assume that the various cache flushing, invalidation, etc that + * linux did during or after copying the data down is sufficient, though we may + * need to be mindful of cache flushing if we run in EL2 (TBD). + * + * Note, if TRAMP_MEMMAP_SRC is non-zero, then we have to copy the Linux + * provided UEFI memory map. It's easier to do that here. In kboot we couldn't + * access the physical memory, and it's a chicken and egg problem later in the + * kernel. + */ + +#define TRAMP_ENTRY 0 +#define TRAMP_MODULEP 8 +#define TRAMP_MEMMAP_SRC 16 +#define TRAMP_MEMMAP_DST 24 +#define TRAMP_MEMMAP_LEN 32 +#define TRAMP_TOTAL 40 + + .text + .globl tramp +tramp: + adr x8, trampoline_data + ldr x10, [x8, #TRAMP_MEMMAP_SRC] + cmp x10, xzr + b.eq 9f + + /* + * Copy over the memory map into area we have reserved for it. Assume + * the copy is a multiple of 8, since we know table entries are made up + * of several 64-bit quantities. + */ + ldp x11, x12, [x8, #TRAMP_MEMMAP_DST] /* x12 = len */ +1: + ldr x13, [x10], #8 + str x13, [x11], #8 + subs x12, x12, #8 + b.hi 1b +9: + ldp x9, x0, [x8, #TRAMP_ENTRY] /* x0 = modulep */ + br x9 + + .p2align 4 +trampoline_data: + .space TRAMP_TOTAL +#define TMPSTACKSIZE 48 /* 16 bytes for args +8 for pushq/popfq + 24 spare */ + .space TMPSTACKSIZE +tramp_end: /* padding doubles as stack */ + + .data + .globl tramp_size +tramp_size: + .long tramp_end-tramp + .globl tramp_data_offset +tramp_data_offset: + .long trampoline_data-tramp diff --git a/stand/kboot/arch/amd64/Makefile.inc b/stand/kboot/arch/amd64/Makefile.inc index fb954e798599..fdd40fe9bc5a 100644 --- a/stand/kboot/arch/amd64/Makefile.inc +++ b/stand/kboot/arch/amd64/Makefile.inc @@ -1,8 +1,5 @@ -SRCS+= conf.c host_syscall.S amd64_tramp.S elf64_freebsd.c +SRCS+= host_syscall.S amd64_tramp.S elf64_freebsd.c load_addr.c fdt_arch.c CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include -# load address. set in linker script -RELOC?= 0x0 -CFLAGS+= -DRELOC=${RELOC} LDFLAGS= -nostdlib -static -T ${.CURDIR}/arch/${MACHINE_ARCH}/ldscript.amd64 diff --git a/stand/kboot/arch/amd64/amd64_tramp.S b/stand/kboot/arch/amd64/amd64_tramp.S index 877705407f92..b95e99cbaf0f 100644 --- a/stand/kboot/arch/amd64/amd64_tramp.S +++ b/stand/kboot/arch/amd64/amd64_tramp.S @@ -1,9 +1,6 @@ /*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. + * Copyright (c) 2022 Netflix, Inc * - * This software was developed by Benno Rice under sponsorship from - * the FreeBSD Foundation. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -24,53 +21,87 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ -#include <machine/asmacros.h> - -#define ASM_FILE -#include "multiboot2.h" +/* + * This is the trampoline that starts the FreeBSD kernel. Since the Linux kernel + * calls this routine with no args, and has a different environment than the + * boot loader provides and that the kernel expects, this code is responsible + * for setting all that up and calling the normal kernel entry point. It's + * analogous to the "purgatory" code in the linux kernel. Details about these + * operations are contained in comments below. On amd64, the kernel starts all + * the APs so we don't have to worry about them here. + */ +/* + * Keep in sync with elf64_freebsd.c. Kexec starts tramp w/o any parameters, so + * store them here. This is constructed to be a useful stack: + * + * struct trampoline_data { + * uint64_t pt4; // Page table address to pop + * uint64_t entry; // return address to jump to kernel + * uint32_t fill1; // 0 + * uint32_t modulep; // 4 module metadata + * uint32_t kernend; // 8 kernel end + * uint32_t fill2; // 12 + * }; + * + * loader.kboot will construct a stack that btext expects, which is arguments on + * the stack, not in registers, and these args are 32-bit not 64 + * + * Processor is already in long mode when we're called, paging is enabled and + * boot loader loads things such that: + * - kernel mapped at KERNBASE, aligned to 2MB, below 4GB, contiguous memory + * - there is a 2M hole at KERNBASE (KERNSTART = KERNBASE + 2M) + * - kernel is mapped with 2M superpages + * - The kernel, modules and metadata is in first 4GB which is unity mapped + * - There's additional memory after loader provided data for early allocations + * + * Unlike EFI, we don't support copying the staging area. We tell Linux to land + * the kernel in its final location with the needed alignment, etc. We copy the + * trampoline code to 1MB offset above KERNBASE since that memory is otherwise + * free and safely above the lower 1MB swamp we inherited from IBM PC, though + * this code makes no assumptions about where that might. + * + * Thus, the trampoline just needs to set %rsp to that stack pop the %cr3 value, + * set it and then retq to jump to the kernel with its stack args filled in. + * Since the handoff to this code used to be from 32-bit code, it uses the i386 + * calling conventions which put the arguments on the stack. The kernel's btext + * routine expects this setup. + */ .text - .globl amd64_tramp - + .globl tramp +tramp: + cli /* Make sure we don't get interrupted. */ + leaq tramp_pt4(%rip), %rsp /* Setup our pre-filled-in stack */ + popq %rax /* Pop off the PT4 ptr for %cr3 */ + movq %rax, %cr3 /* set the page table */ + retq /* Return addr and args already on stack */ /* - * void amd64_tramp(uint64_t stack, void *copy_finish, uint64_t kernend, - * uint64_t modulep, uint64_t pagetable, uint64_t entry) + * The following is the stack for the above code. The stack will increase in + * address as things are popped off of it, so we start with the stack pointing + * to tramp_pt4. */ -amd64_tramp: - cli /* Make sure we don't get interrupted. */ - movq %rdi,%rsp /* Switch to our temporary stack. */ - - movq %rdx,%r12 /* Stash the kernel values for later. */ - movq %rcx,%r13 - movq %r8,%r14 - movq %r9,%r15 - - callq *%rsi /* Call copy_finish so we're all ready to go. */ - - pushq %r12 /* Push kernend. */ - salq $32,%r13 /* Shift modulep and push it. */ - pushq %r13 - pushq %r15 /* Push the entry address. */ - movq %r14,%cr3 /* Switch page tables. */ - ret /* "Return" to kernel entry. */ - - ALIGN_TEXT -amd64_tramp_end: - -/* void multiboot2_exec(uint64_t entry, uint64_t multiboot_info, uint64_t stack) */ - .globl multiboot2_exec -multiboot2_exec: - movq %rdx,%rsp - pushq %rdi - movq %rsi,%rbx - movq $MULTIBOOT2_BOOTLOADER_MAGIC,%rax - ret + .p2align 3 /* Stack has to be 8 byte aligned */ +trampoline_data: +tramp_pt4: .quad 0 /* New %cr3 value */ +tramp_entry: .quad 0 /* Entry to kernel (btext) */ + /* %rsp points here on entry to amd64 kernel's btext */ + .long 0 /* 0 filler, ignored (current loaders set to 0) */ +tramp_modulep: .long 0 /* 4 moudlep */ +tramp_kernend: .long 0 /* 8 kernend */ + .long 0 /* 12 alignment filler (also 0) */ +tramp_end: .data - .globl amd64_tramp_size -amd64_tramp_size: - .long amd64_tramp_end-amd64_tramp + .type tramp_size,@object + .globl tramp_size +tramp_size: + .long tramp_end-tramp + .size tramp_size, 4 + + .type tramp_data_offset,@object + .globl tramp_data_offset +tramp_data_offset: + .long trampoline_data-tramp + .size tramp_data_offset, 4 diff --git a/stand/kboot/arch/amd64/elf64_freebsd.c b/stand/kboot/arch/amd64/elf64_freebsd.c index a45a0db32e44..4da5a7177a33 100644 --- a/stand/kboot/arch/amd64/elf64_freebsd.c +++ b/stand/kboot/arch/amd64/elf64_freebsd.c @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 64 #include <sys/param.h> #include <sys/exec.h> @@ -41,9 +39,12 @@ __FBSDID("$FreeBSD$"); #ifdef EFI #include <efi.h> #include <efilib.h> +#else +#include "host_syscall.h" #endif #include "bootstrap.h" +#include "kboot.h" #include "platform/acfreebsd.h" #include "acconfig.h" @@ -53,9 +54,7 @@ __FBSDID("$FreeBSD$"); #ifdef EFI #include "loader_efi.h" -#endif -#ifdef EFI static EFI_GUID acpi_guid = ACPI_TABLE_GUID; static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID; #endif @@ -63,7 +62,7 @@ static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID; #ifdef EFI #define LOADER_PAGE_SIZE EFI_PAGE_SIZE #else -#define LOADER_PAGE_SIZE 8192 +#define LOADER_PAGE_SIZE PAGE_SIZE #endif extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, @@ -81,13 +80,13 @@ static struct file_format amd64_elf_obj = { .l_exec = elf64_obj_exec, }; -#if 0 +#ifdef EFI extern struct file_format multiboot2; extern struct file_format multiboot2_obj; #endif struct file_format *file_formats[] = { -#if 0 +#ifdef EFI &multiboot2, &multiboot2_obj, #endif @@ -96,21 +95,44 @@ struct file_format *file_formats[] = { NULL }; -#ifdef EFI +#ifndef EFI +/* + * We create the stack that we want. We have the address of the page tables + * we make on top (so we pop that off and set %cr3). We have the entry point + * to the kernel (which retq pops off) This leaves the stack that the btext + * wants: offset 4 is modulep and offset8 is kernend, with the filler bytes + * to keep this aligned. This makes the trampoline very simple. + */ +struct trampoline_data { + uint64_t pt4; // Page table address to pop + uint64_t entry; // return address to jump to kernel + uint32_t fill1; // 0 + uint32_t modulep; // 4 module metadata + uint32_t kernend; // 8 kernel end + uint32_t fill2; // 12 +}; +_Static_assert(sizeof(struct trampoline_data) == 32, "Bad size for trampoline data"); +#endif + static pml4_entry_t *PT4; -static pdp_entry_t *PT3; static pdp_entry_t *PT3_l, *PT3_u; -static pd_entry_t *PT2; static pd_entry_t *PT2_l0, *PT2_l1, *PT2_l2, *PT2_l3, *PT2_u0, *PT2_u1; +#ifdef EFI +static pdp_entry_t *PT3; +static pd_entry_t *PT2; + extern EFI_PHYSICAL_ADDRESS staging; static void (*trampoline)(uint64_t stack, void *copy_finish, uint64_t kernend, uint64_t modulep, pml4_entry_t *pagetable, uint64_t entry); #endif -extern uintptr_t amd64_tramp; -extern uint32_t amd64_tramp_size; +extern uintptr_t tramp; +extern uint32_t tramp_size; +#ifndef EFI +extern uint32_t tramp_data_offset; +#endif /* * There is an ELF kernel and one or more ELF modules loaded. @@ -120,15 +142,27 @@ extern uint32_t amd64_tramp_size; static int elf64_exec(struct preloaded_file *fp) { -#ifdef EFI struct file_metadata *md; Elf_Ehdr *ehdr; - vm_offset_t modulep, kernend, trampcode, trampstack; + vm_offset_t modulep, kernend; int err, i; - ACPI_TABLE_RSDP *rsdp; char buf[24]; +#ifdef EFI + ACPI_TABLE_RSDP *rsdp = NULL; int revision; - bool copy_auto; + int copy_auto; + vm_offset_t trampstack, trampcode; +#else + vm_offset_t rsdp = 0; + void *trampcode; + int nseg; + void *kseg; + vm_offset_t trampolinebase; + uint64_t *trampoline; + struct trampoline_data *trampoline_data; + vm_offset_t staging; + int error; +#endif #ifdef EFI copy_auto = copy_staging == COPY_STAGING_AUTO; @@ -136,66 +170,49 @@ elf64_exec(struct preloaded_file *fp) copy_staging = fp->f_kernphys_relocatable ? COPY_STAGING_DISABLE : COPY_STAGING_ENABLE; #else - copy_auto = COPY_STAGING_DISABLE; /* XXX */ + /* + * Figure out where to put it. + * + * Linux does not allow to do kexec_load into any part of memory. Ask + * arch_loadaddr to resolve the first available chunk of physical memory + * where loading is possible (load_addr). + * + * The kernel is loaded at the 'base' address in continguous physical + * pages (using 2MB super pages). The first such page is unused by the + * kernel and serves as a good place to put not only the trampoline, but + * the page table pages that the trampoline needs to setup the proper + * kernel starting environment. + */ + staging = trampolinebase = kboot_get_phys_load_segment(); + trampolinebase += 1ULL << 20; /* Copy trampoline to base + 1MB, kernel will wind up at 2MB */ + printf("Load address at %#jx\n", (uintmax_t)trampolinebase); + printf("Relocation offset is %#jx\n", (uintmax_t)elf64_relocation_offset); #endif /* * Report the RSDP to the kernel. While this can be found with * a BIOS boot, the RSDP may be elsewhere when booted from UEFI. - * The old code used the 'hints' method to communite this to - * the kernel. However, while convenient, the 'hints' method - * is fragile and does not work when static hints are compiled - * into the kernel. Instead, move to setting different tunables - * that start with acpi. The old 'hints' can be removed before - * we branch for FreeBSD 12. */ - #ifdef EFI rsdp = efi_get_table(&acpi20_guid); if (rsdp == NULL) { rsdp = efi_get_table(&acpi_guid); } #else - rsdp = NULL; -#warning "write me" + rsdp = acpi_rsdp(); #endif - if (rsdp != NULL) { + if (rsdp != 0) { sprintf(buf, "0x%016llx", (unsigned long long)rsdp); - setenv("hint.acpi.0.rsdp", buf, 1); setenv("acpi.rsdp", buf, 1); - revision = rsdp->Revision; - if (revision == 0) - revision = 1; - sprintf(buf, "%d", revision); - setenv("hint.acpi.0.revision", buf, 1); - setenv("acpi.revision", buf, 1); - strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId)); - buf[sizeof(rsdp->OemId)] = '\0'; - setenv("hint.acpi.0.oem", buf, 1); - setenv("acpi.oem", buf, 1); - sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress); - setenv("hint.acpi.0.rsdt", buf, 1); - setenv("acpi.rsdt", buf, 1); - if (revision >= 2) { - /* XXX extended checksum? */ - sprintf(buf, "0x%016llx", - (unsigned long long)rsdp->XsdtPhysicalAddress); - setenv("hint.acpi.0.xsdt", buf, 1); - setenv("acpi.xsdt", buf, 1); - sprintf(buf, "%d", rsdp->Length); - setenv("hint.acpi.0.xsdt_length", buf, 1); - setenv("acpi.xsdt_length", buf, 1); - } } - if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) return (EFTYPE); ehdr = (Elf_Ehdr *)&(md->md_data); +#ifdef EFI trampcode = copy_staging == COPY_STAGING_ENABLE ? (vm_offset_t)0x0000000040000000 /* 1G */ : (vm_offset_t)0x0000000100000000; /* 4G */; -#ifdef EFI err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 1, (EFI_PHYSICAL_ADDRESS *)&trampcode); if (EFI_ERROR(err)) { @@ -204,17 +221,22 @@ elf64_exec(struct preloaded_file *fp) copy_staging = COPY_STAGING_AUTO; return (ENOMEM); } + trampstack = trampcode + LOADER_PAGE_SIZE - 8; #else -#warning "Write me" + // XXX Question: why not just use malloc? + trampcode = host_getmem(LOADER_PAGE_SIZE); + if (trampcode == NULL) { + printf("Unable to allocate trampoline\n"); + return (ENOMEM); + } #endif bzero((void *)trampcode, LOADER_PAGE_SIZE); - trampstack = trampcode + LOADER_PAGE_SIZE - 8; - bcopy((void *)&amd64_tramp, (void *)trampcode, amd64_tramp_size); + bcopy((void *)&tramp, (void *)trampcode, tramp_size); trampoline = (void *)trampcode; - if (copy_staging == COPY_STAGING_ENABLE) { - PT4 = (pml4_entry_t *)0x0000000040000000; #ifdef EFI + if (copy_staging == COPY_STAGING_ENABLE) { + PT4 = (pml4_entry_t *)0x0000000040000000; /* 1G */ err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 3, (EFI_PHYSICAL_ADDRESS *)&PT4); if (EFI_ERROR(err)) { @@ -224,9 +246,6 @@ elf64_exec(struct preloaded_file *fp) copy_staging = COPY_STAGING_AUTO; return (ENOMEM); } -#else -#warning "Write me" -#endif bzero(PT4, 3 * LOADER_PAGE_SIZE); PT3 = &PT4[512]; PT2 = &PT3[512]; @@ -259,7 +278,6 @@ elf64_exec(struct preloaded_file *fp) } } else { PT4 = (pml4_entry_t *)0x0000000100000000; /* 4G */ -#ifdef EFI err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 9, (EFI_PHYSICAL_ADDRESS *)&PT4); if (EFI_ERROR(err)) { @@ -269,10 +287,6 @@ elf64_exec(struct preloaded_file *fp) copy_staging = COPY_STAGING_AUTO; return (ENOMEM); } -#else -#warning "Write me" -#endif - bzero(PT4, 9 * LOADER_PAGE_SIZE); PT3_l = &PT4[NPML4EPG * 1]; @@ -308,10 +322,84 @@ elf64_exec(struct preloaded_file *fp) PG_V | PG_RW | PG_PS; } } +#else + { + vm_offset_t pabase, pa_pt3_l, pa_pt3_u, pa_pt2_l0, pa_pt2_l1, pa_pt2_l2, pa_pt2_l3, pa_pt2_u0, pa_pt2_u1; + /* We'll find a place for these later */ + PT4 = (pml4_entry_t *)host_getmem(9 * LOADER_PAGE_SIZE); + bzero(PT4, 9 * LOADER_PAGE_SIZE); + + PT3_l = &PT4[NPML4EPG * 1]; + PT3_u = &PT4[NPML4EPG * 2]; + PT2_l0 = &PT4[NPML4EPG * 3]; + PT2_l1 = &PT4[NPML4EPG * 4]; + PT2_l2 = &PT4[NPML4EPG * 5]; + PT2_l3 = &PT4[NPML4EPG * 6]; + PT2_u0 = &PT4[NPML4EPG * 7]; + PT2_u1 = &PT4[NPML4EPG * 8]; + + pabase = trampolinebase + LOADER_PAGE_SIZE; + pa_pt3_l = pabase + LOADER_PAGE_SIZE * 1; + pa_pt3_u = pabase + LOADER_PAGE_SIZE * 2; + pa_pt2_l0 = pabase + LOADER_PAGE_SIZE * 3; + pa_pt2_l1 = pabase + LOADER_PAGE_SIZE * 4; + pa_pt2_l2 = pabase + LOADER_PAGE_SIZE * 5; + pa_pt2_l3 = pabase + LOADER_PAGE_SIZE * 6; + pa_pt2_u0 = pabase + LOADER_PAGE_SIZE * 7; + pa_pt2_u1 = pabase + LOADER_PAGE_SIZE * 8; + + /* 1:1 mapping of lower 4G */ + PT4[0] = (pml4_entry_t)pa_pt3_l | PG_V | PG_RW; + PT3_l[0] = (pdp_entry_t)pa_pt2_l0 | PG_V | PG_RW; + PT3_l[1] = (pdp_entry_t)pa_pt2_l1 | PG_V | PG_RW; + PT3_l[2] = (pdp_entry_t)pa_pt2_l2 | PG_V | PG_RW; + PT3_l[3] = (pdp_entry_t)pa_pt2_l3 | PG_V | PG_RW; + for (i = 0; i < 4 * NPDEPG; i++) { /* we overflow PT2_l0 into _l1, etc */ + PT2_l0[i] = ((pd_entry_t)i << PDRSHIFT) | PG_V | + PG_RW | PG_PS; + } + + /* mapping of kernel 2G below top */ + PT4[NPML4EPG - 1] = (pml4_entry_t)pa_pt3_u | PG_V | PG_RW; + PT3_u[NPDPEPG - 2] = (pdp_entry_t)pa_pt2_u0 | PG_V | PG_RW; + PT3_u[NPDPEPG - 1] = (pdp_entry_t)pa_pt2_u1 | PG_V | PG_RW; + /* compat mapping of phys @0 */ + PT2_u0[0] = PG_PS | PG_V | PG_RW; + /* this maps past staging area */ + /* + * Kernel uses the KERNSTART (== KERNBASE + 2MB) entry to figure + * out where we loaded the kernel. This is PT2_u0[1] (since + * these map 2MB pages. So the PA that this maps has to be + * kboot's staging + 2MB. For UEFI we do 'i - 1' since we load + * the kernel right at staging (and assume the first address we + * load is 2MB in efi_copyin). However for kboot, staging + 1 * + * NBPDR == staging + 2MB which is where the kernel starts. Our + * trampoline need not be mapped into the kernel space since we + * execute PA==VA for that, and the trampoline can just go away + * once the kernel is called. + * + * Staging should likely be as low as possible, though, because + * all the 'early' allocations are at kernend (which the kernel + * calls physfree). + */ + for (i = 1; i < 2 * NPDEPG; i++) { /* we overflow PT2_u0 into _u1 */ + PT2_u0[i] = ((pd_entry_t)staging + + ((pd_entry_t)i) * NBPDR) | + PG_V | PG_RW | PG_PS; + if (i < 10) printf("Mapping %d to %#lx staging %#lx\n", i, PT2_u0[i], staging); + } + } +#endif + +#ifdef EFI printf("staging %#lx (%scopying) tramp %p PT4 %p\n", staging, copy_staging == COPY_STAGING_ENABLE ? "" : "not ", trampoline, PT4); +#else + printf("staging %#lx tramp %p PT4 %p\n", staging, (void *)trampolinebase, + (void *)trampolinebase + LOADER_PAGE_SIZE); +#endif printf("Start @ 0x%lx ...\n", ehdr->e_entry); #ifdef EFI @@ -321,17 +409,44 @@ elf64_exec(struct preloaded_file *fp) if (err != 0) { #ifdef EFI efi_time_init(); -#endif if (copy_auto) copy_staging = COPY_STAGING_AUTO; +#endif return (err); } dev_cleanup(); +#ifdef EFI trampoline(trampstack, copy_staging == COPY_STAGING_ENABLE ? efi_copy_finish : efi_copy_finish_nop, kernend, modulep, PT4, ehdr->e_entry); +#else + trampoline_data = (void *)trampoline + tramp_data_offset; + trampoline_data->entry = ehdr->e_entry; + trampoline_data->pt4 = trampolinebase + LOADER_PAGE_SIZE; + /* + * So we compute the VA of the module data by modulep + KERNBASE.... + * need to make sure that that address is mapped right. We calculate + * the start of available memory to allocate via kernend (which is + * calculated with a phyaddr of "kernend + PA(PT_u0[1])"), so we better + * make sure we're not overwriting the last 2MB of the kernel :). + */ + trampoline_data->modulep = modulep; /* Offset from KERNBASE */ + trampoline_data->kernend = kernend; /* Offset from the load address */ + trampoline_data->fill1 = trampoline_data->fill2 = 0; + printf("Modulep = %lx kernend %lx\n", modulep, kernend); + /* NOTE: when copyting in, it's relative to the start of our 'area' not an abs addr */ + /* Copy the trampoline to the ksegs */ + archsw.arch_copyin((void *)trampcode, trampolinebase - staging, tramp_size); + /* Copy the page table to the ksegs */ + archsw.arch_copyin(PT4, trampoline_data->pt4 - staging, 9 * LOADER_PAGE_SIZE); + + kboot_kseg_get(&nseg, &kseg); + error = host_kexec_load(trampolinebase, nseg, kseg, HOST_KEXEC_ARCH_X86_64); + if (error != 0) + panic("kexec_load returned error: %d", error); + host_reboot(HOST_REBOOT_MAGIC1, HOST_REBOOT_MAGIC2, HOST_REBOOT_CMD_KEXEC, 0); #endif panic("exec returned"); diff --git a/stand/kboot/arch/amd64/fdt_arch.c b/stand/kboot/arch/amd64/fdt_arch.c new file mode 100644 index 000000000000..eefb76b1f92c --- /dev/null +++ b/stand/kboot/arch/amd64/fdt_arch.c @@ -0,0 +1,32 @@ +/*- + * Copyright (c) 2022 Netflix, Inc + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/types.h> +#include "kboot.h" + +void +fdt_arch_fixups(void *fdtp) +{ + /* amd64 doesn't pass in a FDT, so nothing to fix */ +} diff --git a/stand/kboot/arch/amd64/ldscript.amd64 b/stand/kboot/arch/amd64/ldscript.amd64 index bbfe47cd4ef5..4009ba5fa81c 100644 --- a/stand/kboot/arch/amd64/ldscript.amd64 +++ b/stand/kboot/arch/amd64/ldscript.amd64 @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") OUTPUT_ARCH(i386:x86-64) ENTRY(_start) diff --git a/stand/kboot/arch/amd64/load_addr.c b/stand/kboot/arch/amd64/load_addr.c new file mode 100644 index 000000000000..4bd2a19dab48 --- /dev/null +++ b/stand/kboot/arch/amd64/load_addr.c @@ -0,0 +1,181 @@ +/*- + * Copyright (c) 2022 Netflix, Inc + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <machine/pc/bios.h> +#include <machine/metadata.h> + +#include "stand.h" +#include "host_syscall.h" +#include "kboot.h" +#include "bootstrap.h" + +/* Refactor when we do arm64 */ + +enum types { + system_ram = 1, + acpi_tables, + acpi_nv_storage, + unusable, + persistent_old, + persistent, + soft_reserved, + reserved, +}; + +struct kv +{ + uint64_t type; + char * name; +} str2type_kv[] = { + { system_ram, "System RAM" }, + { acpi_tables, "ACPI Tables" }, + { acpi_nv_storage, "ACPI Non-volatile Storage" }, + { unusable, "Unusable memory" }, + { persistent_old, "Persistent Memory (legacy)" }, + { persistent, "Persistent Memory" }, + { soft_reserved, "Soft Reserved" }, + { reserved, "reserved" }, + { 0, NULL }, +}; + +#define MEMMAP "/sys/firmware/memmap" + +static struct memory_segments segs[64]; /* make dynamic later */ +static int nr_seg; + +static bool +str2type(struct kv *kv, const char *buf, uint64_t *value) +{ + while (kv->name != NULL) { + if (strcmp(kv->name, buf) == 0) { + *value = kv->type; + return true; + } + kv++; + } + + return false; +} + +bool +enumerate_memory_arch(void) +{ + int n; + char name[MAXPATHLEN]; + char buf[80]; + + for (n = 0; n < nitems(segs); n++) { + snprintf(name, sizeof(name), "%s/%d/start", MEMMAP, n); + if (!file2u64(name, &segs[n].start)) + break; + snprintf(name, sizeof(name), "%s/%d/end", MEMMAP, n); + if (!file2u64(name, &segs[n].end)) + break; + snprintf(name, sizeof(name), "%s/%d/type", MEMMAP, n); + if (!file2str(name, buf, sizeof(buf))) + break; + if (!str2type(str2type_kv, buf, &segs[n].type)) + break; + } + + nr_seg = n; + + return true; +} + +#define BAD_SEG ~0ULL + +#define SZ(s) (((s).end - (s).start) + 1) + +static uint64_t +find_ram(struct memory_segments *segs, int nr_seg, uint64_t minpa, uint64_t align, + uint64_t sz, uint64_t maxpa) +{ + uint64_t start; + + printf("minpa %#jx align %#jx sz %#jx maxpa %#jx\n", + (uintmax_t)minpa, + (uintmax_t)align, + (uintmax_t)sz, + (uintmax_t)maxpa); + /* XXX assume segs are sorted in numeric order -- assumed not ensured */ + for (int i = 0; i < nr_seg; i++) { + if (segs[i].type != system_ram || + SZ(segs[i]) < sz || + minpa + sz > segs[i].end || + maxpa < segs[i].start) + continue; + start = roundup(segs[i].start, align); + if (start < minpa) /* Too small, round up and try again */ + start = (roundup(minpa, align)); + if (start + sz > segs[i].end) /* doesn't fit in seg */ + continue; + if (start > maxpa || /* Over the edge */ + start + sz > maxpa) /* on the edge */ + break; /* No hope to continue */ + return start; + } + + return BAD_SEG; +} + +uint64_t +kboot_get_phys_load_segment(void) +{ + static uint64_t base_seg = BAD_SEG; + + if (base_seg != BAD_SEG) + return (base_seg); + + if (nr_seg > 0) + base_seg = find_ram(segs, nr_seg, 2ULL << 20, 2ULL << 20, + 64ULL << 20, 4ULL << 30); + if (base_seg == BAD_SEG) { + /* XXX Should fall back to using /proc/iomem maybe? */ + /* XXX PUNT UNTIL I NEED SOMETHING BETTER */ + base_seg = 300ULL * (1 << 20); + } + return (base_seg); +} + +void +bi_loadsmap(struct preloaded_file *kfp) +{ + struct bios_smap smap[32], *sm; + struct memory_segments *s; + int smapnum, len; + + for (smapnum = 0; smapnum < min(32, nr_seg); smapnum++) { + sm = &smap[smapnum]; + s = &segs[smapnum]; + sm->base = s->start; + sm->length = s->end - s->start + 1; + sm->type = SMAP_TYPE_MEMORY; + } + + len = smapnum * sizeof(struct bios_smap); + file_addmetadata(kfp, MODINFOMD_SMAP, len, &smap[0]); +} diff --git a/stand/kboot/arch/amd64/start_arch.h b/stand/kboot/arch/amd64/start_arch.h new file mode 100644 index 000000000000..818a5b277c10 --- /dev/null +++ b/stand/kboot/arch/amd64/start_arch.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Netflix, Inc. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +/* + * Provides a _start routine that calls a _start_c routine that takes a pointer + * to the stack as documented in crt1.c. We skip the pointer to _DYNAMIC since + * we don't support dynamic libraries, at all. And while _start_c is our own + * thing, we comport to the calling conventions that glibc and musl have and + * make sure the second argument (%esi) is 0 for _DYNAMIC placeholder. We + * likely could call main directly with only a few more lines of code, but this + * is simple enough and concentrates all the expressable in C stuff there. We + * also generate eh_frames should we need to debug things (it doesn't change the + * genreated code, but leaves enough breadcrumbs to keep gdb happy). + */ + +__asm__( +".text\n" /* ENTRY(_start) */ +".p2align 4,0x90\n" +".global _start\n" +".type _start, @function\n" +"_start:\n" +".cfi_startproc\n" +" xor %rbp, %rbp\n" /* Clear out the stack frame pointer */ +" mov %rsp, %rdi\n" /* Pass pointer to current stack with argc, argv and envp on it */ +" xor %rsi, %rsi\n" /* No dynamic pointer for us, to keep it simple */ +" andq $-16, %rsp\n" /* Align stack to 16-byte boundary */ +" call _start_c\n" /* Our MI code takes it from here and won't return */ +/* NORETURN */ +".size _start, . - _start\n" /* END(_start) */ +".cfi_endproc" +); diff --git a/stand/kboot/arch/amd64/stat_arch.h b/stand/kboot/arch/amd64/stat_arch.h new file mode 100644 index 000000000000..74946abd2cda --- /dev/null +++ b/stand/kboot/arch/amd64/stat_arch.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2005-2020 Rich Felker, et al. + * + * SPDX-License-Identifier: MIT + * + * Note: From the musl project + */ + +typedef uint64_t host_nlink_t; + +struct host_kstat { + host_dev_t st_dev; + host_ino_t st_ino; + host_nlink_t st_nlink; + + host_mode_t st_mode; + host_uid_t st_uid; + host_gid_t st_gid; + unsigned int __pad0; + host_dev_t st_rdev; + host_off_t st_size; + host_blksize_t st_blksize; + host_blkcnt_t st_blocks; + + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + long __pad_for_future[3]; +}; + diff --git a/stand/kboot/arch/amd64/syscall_nr.h b/stand/kboot/arch/amd64/syscall_nr.h index 193368364bf3..2cf26d7ca4dc 100644 --- a/stand/kboot/arch/amd64/syscall_nr.h +++ b/stand/kboot/arch/amd64/syscall_nr.h @@ -1,15 +1,22 @@ -#define SYS_read 0 -#define SYS_write 1 -#define SYS_open 2 #define SYS_close 3 +#define SYS_dup 32 +#define SYS_exit 60 +#define SYS_getdents64 217 +#define SYS_getpid 39 #define SYS_gettimeofday 96 -#define SYS_reboot 169 +#define SYS_ioctl 16 +#define SYS_kexec_load 246 +#define SYS_lseek 8 +#define SYS_mkdirat 258 #define SYS_mmap 9 +#define SYS_mount 165 +#define SYS_munmap 11 +#define SYS_newfstat 5 +#define SYS_newfstatat 262 +#define SYS_openat 257 +#define SYS_pselect6 270 +#define SYS_read 0 +#define SYS_reboot 169 +#define SYS_symlinkat 266 #define SYS_uname 63 -#define SYS_lseek 8 -#define SYS_getdents 78 -#define SYS_select 23 -#define __NR_kexec_load 246 - -#define KEXEC_ARCH_X86_64 62 -#define KEXEC_ARCH KEXEC_ARCH_X86_64 +#define SYS_write 1 diff --git a/stand/kboot/arch/amd64/termios_arch.h b/stand/kboot/arch/amd64/termios_arch.h new file mode 100644 index 000000000000..5db0b9831cdb --- /dev/null +++ b/stand/kboot/arch/amd64/termios_arch.h @@ -0,0 +1,7 @@ +/*- + * Copyright (c) 2022, Netflix, Inc. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include "termios_gen.h" diff --git a/stand/kboot/arch/powerpc64/Makefile.inc b/stand/kboot/arch/powerpc64/Makefile.inc index 3c2fb6e18a16..c29e69970505 100644 --- a/stand/kboot/arch/powerpc64/Makefile.inc +++ b/stand/kboot/arch/powerpc64/Makefile.inc @@ -1,14 +1,8 @@ CFLAGS+= -mcpu=powerpc64 -SRCS+= conf.c ppc64_elf_freebsd.c host_syscall.S kerneltramp.S +SRCS+= ppc64_elf_freebsd.c host_syscall.S kerneltramp.S load_addr.c fdt_arch.c SRCS+= ucmpdi2.c -# load address. set in linker script -RELOC?= 0x0 -CFLAGS+= -DRELOC=${RELOC} - LDFLAGS= -nostdlib -static -T ${.CURDIR}/arch/${MACHINE_ARCH}/ldscript.powerpc MK_PIE= no -# Maybe bogus? -CFLAGS+= -DAIM diff --git a/stand/kboot/arch/powerpc64/conf.c b/stand/kboot/arch/powerpc64/conf.c deleted file mode 100644 index 9862611c68d8..000000000000 --- a/stand/kboot/arch/powerpc64/conf.c +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * Copyright (C) 1999 Michael Smith <msmith@freebsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stand.h> -#include "bootstrap.h" - -#if defined(LOADER_NET_SUPPORT) -#include "dev_net.h" -#endif - -extern struct devsw hostdisk; - -/* - * We could use linker sets for some or all of these, but - * then we would have to control what ended up linked into - * the bootstrap. So it's easier to conditionalise things - * here. - * - * XXX rename these arrays to be consistent and less namespace-hostile - */ - -/* Exported for libsa */ -struct devsw *devsw[] = { -#if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CD9660_SUPPORT) - &hostdisk, -#endif -#if defined(LOADER_NET_SUPPORT) - &netdev, -#endif - NULL -}; - -struct fs_ops *file_system[] = { -#if defined(LOADER_UFS_SUPPORT) - &ufs_fsops, -#endif -#if defined(LOADER_CD9660_SUPPORT) - &cd9660_fsops, -#endif -#if defined(LOADER_EXT2FS_SUPPORT) - &ext2fs_fsops, -#endif -#if defined(LOADER_NFS_SUPPORT) - &nfs_fsops, -#endif -#if defined(LOADER_TFTP_SUPPORT) - &tftp_fsops, -#endif -#if defined(LOADER_GZIP_SUPPORT) - &gzipfs_fsops, -#endif -#if defined(LOADER_BZIP2_SUPPORT) - &bzipfs_fsops, -#endif - &dosfs_fsops, - NULL -}; - -extern struct netif_driver kbootnet; - -struct netif_driver *netif_drivers[] = { -#if 0 /* XXX */ -#if defined(LOADER_NET_SUPPORT) - &kbootnet, -#endif -#endif - NULL, -}; - -/* Exported for PowerPC only */ -/* - * Sort formats so that those that can detect based on arguments - * rather than reading the file go first. - */ - -extern struct file_format ppc_elf64; - -struct file_format *file_formats[] = { - &ppc_elf64, - NULL -}; - -/* - * Consoles - */ -extern struct console hostconsole; - -struct console *consoles[] = { - &hostconsole, - NULL -}; - diff --git a/stand/kboot/arch/powerpc64/fdt_arch.c b/stand/kboot/arch/powerpc64/fdt_arch.c new file mode 100644 index 000000000000..dc5f0fbd8fb6 --- /dev/null +++ b/stand/kboot/arch/powerpc64/fdt_arch.c @@ -0,0 +1,89 @@ +/*- + * Copyright (C) 2014 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/types.h> +#include <fdt_platform.h> +#include <libfdt.h> +#include "kboot.h" + +/* Fix up wrong values added to the device tree by prom_init() in Linux */ + +void +fdt_arch_fixups(void *fdtp) +{ + int offset, len; + const void *prop; + + /* + * Remove /memory/available properties, which reflect long-gone OF + * state + */ + + offset = fdt_path_offset(fdtp, "/memory@0"); + if (offset > 0) + fdt_delprop(fdtp, offset, "available"); + + /* + * Add reservations for OPAL and RTAS state if present + */ + + offset = fdt_path_offset(fdtp, "/ibm,opal"); + if (offset > 0) { + const uint64_t *base, *size; + base = fdt_getprop(fdtp, offset, "opal-base-address", + &len); + size = fdt_getprop(fdtp, offset, "opal-runtime-size", + &len); + if (base != NULL && size != NULL) + fdt_add_mem_rsv(fdtp, fdt64_to_cpu(*base), + fdt64_to_cpu(*size)); + } + offset = fdt_path_offset(fdtp, "/rtas"); + if (offset > 0) { + const uint32_t *base, *size; + base = fdt_getprop(fdtp, offset, "linux,rtas-base", &len); + size = fdt_getprop(fdtp, offset, "rtas-size", &len); + if (base != NULL && size != NULL) + fdt_add_mem_rsv(fdtp, fdt32_to_cpu(*base), + fdt32_to_cpu(*size)); + } + + /* + * Patch up /chosen nodes so that the stored handles mean something, + * where possible. + */ + offset = fdt_path_offset(fdtp, "/chosen"); + if (offset > 0) { + fdt_delprop(fdtp, offset, "cpu"); /* This node not meaningful */ + + offset = fdt_path_offset(fdtp, "/chosen"); + prop = fdt_getprop(fdtp, offset, "linux,stdout-package", &len); + if (prop != NULL) { + fdt_setprop(fdtp, offset, "stdout", prop, len); + offset = fdt_path_offset(fdtp, "/chosen"); + fdt_setprop(fdtp, offset, "stdin", prop, len); + } + } +} diff --git a/stand/kboot/arch/powerpc64/kerneltramp.S b/stand/kboot/arch/powerpc64/kerneltramp.S index 15fdfc26bd90..211a6e474d2a 100644 --- a/stand/kboot/arch/powerpc64/kerneltramp.S +++ b/stand/kboot/arch/powerpc64/kerneltramp.S @@ -9,7 +9,6 @@ * to the absolute address 0x60. Here we implement a loop waiting on the release * of a lock by the kernel at 0x40. * - * $FreeBSD$ */ #include <machine/asm.h> diff --git a/stand/kboot/arch/powerpc64/ldscript.powerpc b/stand/kboot/arch/powerpc64/ldscript.powerpc index 729113695105..662871eb7c09 100644 --- a/stand/kboot/arch/powerpc64/ldscript.powerpc +++ b/stand/kboot/arch/powerpc64/ldscript.powerpc @@ -10,15 +10,7 @@ SECTIONS { /* Read-only sections, merged into text segment: */ . = 0x100000; - .text : - { - *(.text) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.gnu.linkonce.t*) - } =0 - _etext = .; - .interp : { *(.interp) } + .interp : { *(.interp) } :text .hash : { *(.hash) } .dynsym : { *(.dynsym) } .dynstr : { *(.dynstr) } @@ -40,7 +32,9 @@ SECTIONS .rela.fini : { *(.rela.fini) } .rela.bss : { *(.rela.bss) } .rela.plt : { *(.rela.plt) } + .rela.sdata : { *(.rela.sdata) } .rela.sbss : { *(.rela.sbss) } + .rela.sdata2 : { *(.rela.sdata2) } .rela.sbss2 : { *(.rela.sbss2) } .text : { @@ -55,9 +49,11 @@ SECTIONS .fini : { *(.fini) } =0 .rodata : { *(.rodata) *(.gnu.linkonce.r*) } .rodata1 : { *(.rodata1) } + .sdata2 : { *(.sdata2) } .sbss2 : { *(.sbss2) } /* Adjust the address for the data segment to the next page up. */ . = ((. + 0x1000) & ~(0x1000 - 1)); + .data.rel.ro : { *(.data.rel.ro*) } .data : { *(.data) @@ -86,6 +82,10 @@ SECTIONS .got : { *(.got) } .got.plt : { *(.got.plt) } PROVIDE (_GOT_END_ = .); + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata : { *(.sdata) } _edata = .; PROVIDE (edata = .); .sbss : @@ -107,5 +107,33 @@ SECTIONS . = ALIGN(4096); _end = . ; PROVIDE (end = .); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* These must appear regardless of . */ } - diff --git a/stand/kboot/arch/powerpc64/load_addr.c b/stand/kboot/arch/powerpc64/load_addr.c new file mode 100644 index 000000000000..71662796f284 --- /dev/null +++ b/stand/kboot/arch/powerpc64/load_addr.c @@ -0,0 +1,228 @@ +/*- + * Copyright (C) 2010-2014 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/endian.h> + +#include "stand.h" +#include "host_syscall.h" +#include "kboot.h" + +struct region_desc { + uint64_t start; + uint64_t end; +}; + +/* + * Find a good place to load the kernel, subject to the PowerPC's constraints + * + * This excludes ranges that are marked as reserved. + * And 0..end of kernel + * + * It then tries to find the memory exposed from the DTB, which it assumes is one + * contiguous range. It adds everything not in that list to the excluded list. + * + * Sort, dedup, and it finds the first region and uses that as the load_segment + * and returns that. All addresses are offset by this amount. + */ +uint64_t +kboot_get_phys_load_segment(void) +{ + int fd; + uint64_t entry[2]; + static uint64_t load_segment = ~(0UL); + uint64_t val_64; + uint32_t val_32; + struct region_desc rsvd_reg[32]; + int rsvd_reg_cnt = 0; + int ret, a, b; + uint64_t start, end; + + if (load_segment == ~(0UL)) { + + /* Default load address is 0x00000000 */ + load_segment = 0UL; + + /* Read reserved regions */ + fd = host_open("/proc/device-tree/reserved-ranges", O_RDONLY, 0); + if (fd >= 0) { + while (host_read(fd, &entry[0], sizeof(entry)) == sizeof(entry)) { + rsvd_reg[rsvd_reg_cnt].start = be64toh(entry[0]); + rsvd_reg[rsvd_reg_cnt].end = + be64toh(entry[1]) + rsvd_reg[rsvd_reg_cnt].start - 1; + rsvd_reg_cnt++; + } + host_close(fd); + } + /* Read where the kernel ends */ + fd = host_open("/proc/device-tree/chosen/linux,kernel-end", O_RDONLY, 0); + if (fd >= 0) { + ret = host_read(fd, &val_64, sizeof(val_64)); + + if (ret == sizeof(uint64_t)) { + rsvd_reg[rsvd_reg_cnt].start = 0; + rsvd_reg[rsvd_reg_cnt].end = be64toh(val_64) - 1; + } else { + memcpy(&val_32, &val_64, sizeof(val_32)); + rsvd_reg[rsvd_reg_cnt].start = 0; + rsvd_reg[rsvd_reg_cnt].end = be32toh(val_32) - 1; + } + rsvd_reg_cnt++; + + host_close(fd); + } + /* Read memory size (SOCKET0 only) */ + fd = host_open("/proc/device-tree/memory@0/reg", O_RDONLY, 0); + if (fd < 0) + fd = host_open("/proc/device-tree/memory/reg", O_RDONLY, 0); + if (fd >= 0) { + ret = host_read(fd, &entry, sizeof(entry)); + + /* Memory range in start:length format */ + entry[0] = be64toh(entry[0]); + entry[1] = be64toh(entry[1]); + + /* Reserve everything what is before start */ + if (entry[0] != 0) { + rsvd_reg[rsvd_reg_cnt].start = 0; + rsvd_reg[rsvd_reg_cnt].end = entry[0] - 1; + rsvd_reg_cnt++; + } + /* Reserve everything what is after end */ + if (entry[1] != 0xffffffffffffffffUL) { + rsvd_reg[rsvd_reg_cnt].start = entry[0] + entry[1]; + rsvd_reg[rsvd_reg_cnt].end = 0xffffffffffffffffUL; + rsvd_reg_cnt++; + } + + host_close(fd); + } + + /* Sort entries in ascending order (bubble) */ + for (a = rsvd_reg_cnt - 1; a > 0; a--) { + for (b = 0; b < a; b++) { + if (rsvd_reg[b].start > rsvd_reg[b + 1].start) { + struct region_desc tmp; + tmp = rsvd_reg[b]; + rsvd_reg[b] = rsvd_reg[b + 1]; + rsvd_reg[b + 1] = tmp; + } + } + } + + /* Join overlapping/adjacent regions */ + for (a = 0; a < rsvd_reg_cnt - 1; ) { + + if ((rsvd_reg[a + 1].start >= rsvd_reg[a].start) && + ((rsvd_reg[a + 1].start - 1) <= rsvd_reg[a].end)) { + /* We have overlapping/adjacent regions! */ + rsvd_reg[a].end = + MAX(rsvd_reg[a].end, rsvd_reg[a + a].end); + + for (b = a + 1; b < rsvd_reg_cnt - 1; b++) + rsvd_reg[b] = rsvd_reg[b + 1]; + rsvd_reg_cnt--; + } else + a++; + } + + /* Find the first free region */ + if (rsvd_reg_cnt > 0) { + start = 0; + end = rsvd_reg[0].start; + for (a = 0; a < rsvd_reg_cnt - 1; a++) { + if ((start >= rsvd_reg[a].start) && + (start <= rsvd_reg[a].end)) { + start = rsvd_reg[a].end + 1; + end = rsvd_reg[a + 1].start; + } else + break; + } + + if (start != end) { + uint64_t align = 64UL*1024UL*1024UL; + + /* Align both to 64MB boundary */ + start = (start + align - 1UL) & ~(align - 1UL); + end = ((end + 1UL) & ~(align - 1UL)) - 1UL; + + if (start < end) + load_segment = start; + } + } + } + + return (load_segment); +} + +#if 0 +/* + * XXX this appears to be unused, but may have been for selecting the allowed + * kernels ABIs. It's been unused since the first commit, which suggests an + * error in bringing this into the tree. + */ +uint8_t +kboot_get_kernel_machine_bits(void) +{ + static uint8_t bits = 0; + struct old_utsname utsname; + int ret; + + if (bits == 0) { + /* Default is 32-bit kernel */ + bits = 32; + + /* Try to get system type */ + memset(&utsname, 0, sizeof(utsname)); + ret = host_uname(&utsname); + if (ret == 0) { + if (strcmp(utsname.machine, "ppc64") == 0) + bits = 64; + else if (strcmp(utsname.machine, "ppc64le") == 0) + bits = 64; + } + } + + return (bits); +} +#endif + +/* Need to transition from current hacky FDT way to this code */ +bool enumerate_memory_arch(void) +{ + /* + * For now, we dig it out of the FDT, plus we need to pass all data into + * the kernel via the (adjusted) FDT we find. + */ + setenv("usefdt", "1", 1); + + return true; +} + +void +bi_loadsmap(struct preloaded_file *kfp) +{ + /* passed in via the DTB */ +} diff --git a/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c b/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c index adbdc7fca915..ebf35dc72ba0 100644 --- a/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c +++ b/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c @@ -25,8 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __ELF_WORD_SIZE 64 #include <sys/param.h> @@ -39,7 +37,10 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include "bootstrap.h" +#include "syscall_nr.h" #include "host_syscall.h" +#include "modinfo.h" +#include "kboot.h" extern char end[]; extern void *kerneltramp; @@ -54,8 +55,6 @@ struct trampoline_data { uint32_t mdp_size; }; -vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb); - int ppc64_elf_loadfile(char *filename, uint64_t dest, struct preloaded_file **result) @@ -148,16 +147,14 @@ ppc64_elf_exec(struct preloaded_file *fp) archsw.arch_copyin(trampoline, trampolinebase, szkerneltramp); free(trampoline); - if (archsw.arch_kexec_kseg_get == NULL) - panic("architecture did not provide kexec segment mapping"); - archsw.arch_kexec_kseg_get(&nseg, &kseg); + kboot_kseg_get(&nseg, &kseg); - error = kexec_load(trampolinebase, nseg, (uintptr_t)kseg); + error = host_kexec_load(trampolinebase, nseg, kseg, HOST_KEXEC_ARCH_PPC64); if (error != 0) panic("kexec_load returned error: %d", error); - error = host_reboot(0xfee1dead, 672274793, - 0x45584543 /* LINUX_REBOOT_CMD_KEXEC */, (uintptr_t)NULL); + error = host_reboot(HOST_REBOOT_MAGIC1, HOST_REBOOT_MAGIC2, HOST_REBOOT_CMD_KEXEC, + (uintptr_t)NULL); if (error != 0) panic("reboot returned error: %d", error); @@ -169,3 +166,13 @@ struct file_format ppc_elf64 = ppc64_elf_loadfile, ppc64_elf_exec }; + +/* + * Sort formats so that those that can detect based on arguments rather than + * reading the file first. + */ + +struct file_format *file_formats[] = { + &ppc_elf64, + NULL +}; diff --git a/stand/kboot/arch/powerpc64/start_arch.h b/stand/kboot/arch/powerpc64/start_arch.h new file mode 100644 index 000000000000..498de29ad0fe --- /dev/null +++ b/stand/kboot/arch/powerpc64/start_arch.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022 Netflix, Inc + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +/* + * Due to the PowerPC ABI, We can call main directly from here, so do so. + * + * Note: there may be some static initializers that aren't called, but we don't + * worry about that elsewhere. This is a stripped down environment. + * + * I think we could also do something like + * + * mflr r0 + * stw r0,4(r1) + * stwu r1,-16(r1) + * b _start_c + * + * But my powerpc assembler fu is quite lacking... + */ + +#define __unused __attribute__((__unused__)) + +void +_start(int argc, const char **argv, char **env, void *obj __unused, + void (*cleanup)(void) __unused) +{ + main(argc, argv, env); +} diff --git a/stand/kboot/arch/powerpc64/stat_arch.h b/stand/kboot/arch/powerpc64/stat_arch.h new file mode 100644 index 000000000000..103849b0e82b --- /dev/null +++ b/stand/kboot/arch/powerpc64/stat_arch.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2005-2020 Rich Felker, et al. + * + * SPDX-License-Identifier: MIT + * + * Note: From the musl project + */ + +typedef uint64_t host_nlink_t; + +struct host_kstat { + host_dev_t st_dev; + host_ino_t st_ino; + host_nlink_t st_nlink; + host_mode_t st_mode; + host_uid_t st_uid; + host_gid_t st_gid; + host_dev_t st_rdev; + host_off_t st_size; + host_blksize_t st_blksize; + host_blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + long __pad_for_future[3]; +}; diff --git a/stand/kboot/arch/powerpc64/syscall_nr.h b/stand/kboot/arch/powerpc64/syscall_nr.h index 2854124153a2..735e79a09158 100644 --- a/stand/kboot/arch/powerpc64/syscall_nr.h +++ b/stand/kboot/arch/powerpc64/syscall_nr.h @@ -1,15 +1,22 @@ -#define SYS_read 3 -#define SYS_write 4 -#define SYS_open 5 #define SYS_close 6 +#define SYS_dup 41 +#define SYS_exit 1 +#define SYS_fstat 108 +#define SYS_getdents64 202 +#define SYS_getpid 20 #define SYS_gettimeofday 78 -#define SYS_reboot 88 +#define SYS_ioctl 54 +#define SYS_kexec_load 268 +#define SYS_llseek 140 +#define SYS_mkdirat 287 #define SYS_mmap 90 +#define SYS_mount 21 +#define SYS_munmap 91 +#define SYS_newfstatat 291 +#define SYS_openat 286 +#define SYS_pselect6 280 +#define SYS_read 3 +#define SYS_reboot 88 +#define SYS_symlinkat 295 #define SYS_uname 120 -#define SYS_llseek 140 -#define SYS_getdents 141 -#define SYS_select 142 -#define __NR_kexec_load 268 - -#define KEXEC_ARCH_PPC64 21 -#define KEXEC_ARCH KEXEC_ARCH_PPC64 +#define SYS_write 4 diff --git a/stand/kboot/arch/powerpc64/termios_arch.h b/stand/kboot/arch/powerpc64/termios_arch.h new file mode 100644 index 000000000000..7b9e8f15a8ca --- /dev/null +++ b/stand/kboot/arch/powerpc64/termios_arch.h @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2005-2020 Rich Felker, et al. + * + * SPDX-License-Identifier: MIT + * + * Note: From the musl project, stripped down and repackaged with HOST_/host_ prepended + */ + +#undef HOST_NCCS +#define HOST_NCCS 19 +struct host_termios { + host_tcflag_t c_iflag; + host_tcflag_t c_oflag; + host_tcflag_t c_cflag; + host_tcflag_t c_lflag; + host_cc_t c_cc[HOST_NCCS]; + host_cc_t c_line; + host_speed_t __c_ispeed; + host_speed_t __c_ospeed; +}; + +#define HOST_VINTR 0 +#define HOST_VQUIT 1 +#define HOST_VERASE 2 +#define HOST_VKILL 3 +#define HOST_VEOF 4 +#define HOST_VMIN 5 +#define HOST_VEOL 6 +#define HOST_VTIME 7 +#define HOST_VEOL2 8 +#define HOST_VSWTC 9 +#define HOST_VWERASE 10 +#define HOST_VREPRINT 11 +#define HOST_VSUSP 12 +#define HOST_VSTART 13 +#define HOST_VSTOP 14 +#define HOST_VLNEXT 15 +#define HOST_VDISCARD 16 + +#define HOST_IGNBRK 0000001 +#define HOST_BRKINT 0000002 +#define HOST_IGNPAR 0000004 +#define HOST_PARMRK 0000010 +#define HOST_INPCK 0000020 +#define HOST_ISTRIP 0000040 +#define HOST_INLCR 0000100 +#define HOST_IGNCR 0000200 +#define HOST_ICRNL 0000400 +#define HOST_IXON 0001000 +#define HOST_IXOFF 0002000 +#define HOST_IXANY 0004000 +#define HOST_IUCLC 0010000 +#define HOST_IMAXBEL 0020000 +#define HOST_IUTF8 0040000 + +#define HOST_OPOST 0000001 +#define HOST_ONLCR 0000002 +#define HOST_OLCUC 0000004 +#define HOST_OCRNL 0000010 +#define HOST_ONOCR 0000020 +#define HOST_ONLRET 0000040 +#define HOST_OFILL 0000100 +#define HOST_OFDEL 0000200 +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE) +#define HOST_NLDLY 0001400 +#define HOST_NL0 |