From 56f07d651878ec62f0807859f027ca557f54f8b7 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 26 Aug 2016 21:01:45 +0300 Subject: [PATCH] loader: updates from review --- usr/src/boot/lib/libstand/dosfs.c | 8 ++--- usr/src/boot/lib/libstand/gzipfs.c | 2 +- usr/src/boot/lib/libstand/tftp.c | 2 +- usr/src/boot/sys/boot/common/boot.c | 2 +- usr/src/boot/sys/boot/common/bootstrap.h | 10 +++--- usr/src/boot/sys/boot/common/console.c | 5 +-- usr/src/boot/sys/boot/common/help.common | 4 +-- usr/src/boot/sys/boot/common/interp.c | 10 +++--- usr/src/boot/sys/boot/common/interp_forth.c | 8 ++--- usr/src/boot/sys/boot/common/interp_parse.c | 9 ++--- usr/src/boot/sys/boot/common/load_elf.c | 7 ++-- usr/src/boot/sys/boot/common/load_elf_obj.c | 3 +- usr/src/boot/sys/boot/common/merge_help.awk | 18 ++++------ usr/src/boot/sys/boot/common/part.c | 16 ++++----- usr/src/boot/sys/boot/common/ufsread.c | 4 +-- usr/src/boot/sys/boot/efi/loader/main.c | 3 +- usr/src/boot/sys/boot/ficl/Makefile.inc | 14 ++++++++ usr/src/boot/sys/boot/forth/beadm.4th | 7 +++- usr/src/boot/sys/boot/forth/loader.4th | 14 ++++---- usr/src/boot/sys/boot/forth/support.4th | 6 ++-- usr/src/boot/sys/boot/i386/libi386/biosacpi.c | 34 +++++------------- usr/src/boot/sys/boot/i386/libi386/comconsole.c | 8 ++--- usr/src/boot/sys/boot/i386/libi386/libi386.h | 2 +- usr/src/boot/sys/boot/i386/libi386/linux.c | 7 ++-- usr/src/boot/sys/boot/i386/libi386/multiboot.c | 42 +++++++++++----------- usr/src/boot/sys/boot/i386/libi386/nullconsole.c | 2 +- usr/src/boot/sys/boot/i386/libi386/pxe.c | 2 +- .../boot/sys/boot/i386/libi386/relocater_tramp.S | 17 +++++---- usr/src/boot/sys/boot/i386/libi386/spinconsole.c | 2 +- usr/src/boot/sys/boot/i386/libi386/vidconsole.c | 4 +-- usr/src/boot/sys/boot/i386/loader/Makefile | 2 ++ usr/src/boot/sys/boot/i386/loader/loader.rc | 9 +++-- usr/src/boot/sys/boot/i386/loader/main.c | 2 +- usr/src/boot/sys/boot/i386/pmbr/pmbr.s | 2 +- usr/src/boot/sys/boot/zfs/zfsimpl.c | 2 +- 35 files changed, 144 insertions(+), 145 deletions(-) diff --git a/usr/src/boot/lib/libstand/dosfs.c b/usr/src/boot/lib/libstand/dosfs.c index 0ab5b97c21..652ac92cae 100644 --- a/usr/src/boot/lib/libstand/dosfs.c +++ b/usr/src/boot/lib/libstand/dosfs.c @@ -439,7 +439,7 @@ dos_readdir(struct open_file *fd, struct dirent *d) u_char fn[261]; DOS_DIR dd; size_t res; - u_int chk, i, x, xdn; + u_int chk, x, xdn; int err; x = chk = 0; @@ -598,7 +598,7 @@ lookup(DOS_FS *fs, u_int clus, const char *name, DOS_DE **dep) u_char lfn[261]; u_char sfn[13]; u_int nsec, lsec, xdn, chk, sec, ent, x; - int err, ok, i; + int err, ok; if (!clus) for (ent = 0; ent < 2; ent++) @@ -774,11 +774,11 @@ fatget(DOS_FS *fs, u_int *c) int err = 0; if (fat.unit != dd->d_unit) { - /* fat cache was changed to another device, dont use it */ + /* fat cache was changed to another device, don't use it */ err = ioread(fs, secbyt(fs->lsnfat) + fatoff(fs->fatsz, *c), buf, fs->fatsz != 32 ? 2 : 4); if (err) - return err; + return (err); } else { offset = fatoff(fs->fatsz, *c); nbyte = fs->fatsz != 32 ? 2 : 4; diff --git a/usr/src/boot/lib/libstand/gzipfs.c b/usr/src/boot/lib/libstand/gzipfs.c index df10d0a3d3..1db7ad095b 100644 --- a/usr/src/boot/lib/libstand/gzipfs.c +++ b/usr/src/boot/lib/libstand/gzipfs.c @@ -339,7 +339,7 @@ zf_stat(struct open_file *f, struct stat *sb) pos1 = lseek(zf->zf_rawfd, 0, SEEK_CUR); pos2 = lseek(zf->zf_rawfd, sb->st_size - 4, SEEK_SET); if (pos2 != -1) { - if(read(zf->zf_rawfd, &size, 4) == 4) + if (read(zf->zf_rawfd, &size, 4) == 4) sb->st_size = (off_t) size; else sb->st_size = -1; diff --git a/usr/src/boot/lib/libstand/tftp.c b/usr/src/boot/lib/libstand/tftp.c index 657dcfa2a4..cb84970910 100644 --- a/usr/src/boot/lib/libstand/tftp.c +++ b/usr/src/boot/lib/libstand/tftp.c @@ -731,7 +731,7 @@ tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len) } else if (strcasecmp(tftp_options[i], "tsize") == 0) { if (i + 1 < option_idx) tsize = strtol(tftp_options[i + 1], (char **)NULL, 10); - if (tsize) + if (tsize != 0) h->tftp_tsize = tsize; } else { /* Do not allow any options we did not expect to be ACKed. */ diff --git a/usr/src/boot/sys/boot/common/boot.c b/usr/src/boot/sys/boot/common/boot.c index fca7fe0f10..2f6b7f1f78 100644 --- a/usr/src/boot/sys/boot/common/boot.c +++ b/usr/src/boot/sys/boot/common/boot.c @@ -230,7 +230,7 @@ autoboot(int timeout, char *prompt) printf("\rBooting [%s]... ", kernelname); putchar('\n'); if (yes) { - argv[0] = (char *)(uintptr_t)"boot"; + argv[0] = "boot"; argv[1] = NULL; return(command_boot(1, argv)); } diff --git a/usr/src/boot/sys/boot/common/bootstrap.h b/usr/src/boot/sys/boot/common/bootstrap.h index 8fa2ecd5d9..9539180cb3 100644 --- a/usr/src/boot/sys/boot/common/bootstrap.h +++ b/usr/src/boot/sys/boot/common/bootstrap.h @@ -104,11 +104,11 @@ struct console #define C_ACTIVEIN (1<<2) /* user wants input from console */ #define C_ACTIVEOUT (1<<3) /* user wants output to console */ #define C_MODERAW (1<<4) /* raw mode */ - void (* c_probe)(struct console *); /* set c_flags to match hardware */ - int (* c_init)(struct console *, int); /* reinit XXX may need more args */ - void (* c_out)(struct console *, int); /* emit c */ - int (* c_in)(struct console *); /* wait for and return input */ - int (* c_ready)(struct console *); /* return nonzer if input waiting */ + void (*c_probe)(struct console *); /* set c_flags to match hardware */ + int (*c_init)(struct console *, int); /* reinit XXX may need more args */ + void (*c_out)(struct console *, int); /* emit c */ + int (*c_in)(struct console *); /* wait for and return input */ + int (*c_ready)(struct console *); /* return nonzer if input waiting */ void *private; /* private data */ }; extern struct console *consoles[]; diff --git a/usr/src/boot/sys/boot/common/console.c b/usr/src/boot/sys/boot/common/console.c index e95fb4b052..07e8aa4bc1 100644 --- a/usr/src/boot/sys/boot/common/console.c +++ b/usr/src/boot/sys/boot/common/console.c @@ -104,11 +104,12 @@ cons_mode(int raw) { int cons; - for (cons = 0; consoles[cons] != NULL; cons++) + for (cons = 0; consoles[cons] != NULL; cons++) { if (raw == 0) consoles[cons]->c_flags &= ~C_MODERAW; else consoles[cons]->c_flags |= C_MODERAW; + } } int @@ -151,7 +152,7 @@ putchar(int c) if (c == '\n' && (consoles[cons]->c_flags & C_MODERAW) == 0) consoles[cons]->c_out(consoles[cons], '\r'); consoles[cons]->c_out(consoles[cons], c); - } + } } /* diff --git a/usr/src/boot/sys/boot/common/help.common b/usr/src/boot/sys/boot/common/help.common index 06f0c239e2..ead8511faf 100644 --- a/usr/src/boot/sys/boot/common/help.common +++ b/usr/src/boot/sys/boot/common/help.common @@ -35,8 +35,8 @@ beadm activate beName [] beadm list [] - beadm activate does unset loaded configuration and modules, - sets currdev to device and loads configuration from new device. + beadm activate unloads the currently loaded configuration and modules, + sets currdev to and loads configuration from new device. Use lsdev to get available device names. ################################################################################ diff --git a/usr/src/boot/sys/boot/common/interp.c b/usr/src/boot/sys/boot/common/interp.c index ff7c5a3e22..cadd764814 100644 --- a/usr/src/boot/sys/boot/common/interp.c +++ b/usr/src/boot/sys/boot/common/interp.c @@ -179,8 +179,8 @@ struct includeline }; /* - * the PXE tftp service allows to open exactly one connection at the time, - * so we need to read included file to memory, then process line by line + * The PXE TFTP service allows opening exactly one connection at the time, + * so we need to read included file into memory, then process line by line * as it may contain embedded include commands. */ int @@ -277,12 +277,12 @@ include(const char *filename) * for embedding environment variables. */ static char * -prompt(void) +prompt(void) { static char promptbuf[20]; /* probably too large, but well... */ char *pr, *p, *cp, *ev; int n = 0; - + if ((cp = getenv("prompt")) == NULL) cp = (char *)(uintptr_t)">"; pr = p = strdup(cp); @@ -293,7 +293,7 @@ prompt(void) ; *cp = 0; ev = getenv(p + 2); - + if (ev != NULL) n = sprintf(promptbuf+n, "%s", ev); p = cp + 1; diff --git a/usr/src/boot/sys/boot/common/interp_forth.c b/usr/src/boot/sys/boot/common/interp_forth.c index 2332e322db..f241f405d5 100644 --- a/usr/src/boot/sys/boot/common/interp_forth.c +++ b/usr/src/boot/sys/boot/common/interp_forth.c @@ -25,7 +25,6 @@ */ #include -__FBSDID("$FreeBSD$"); #include /* to pick up __FreeBSD_version */ #include @@ -92,7 +91,7 @@ bf_command(ficlVm *vm) } if (cmd == NULL) panic("callout for unknown command '%s'", name); - + /* Check whether we have been compiled or are being interpreted */ if (ficlStackPopInteger(ficlVmGetDataStack(vm))) { /* @@ -121,7 +120,7 @@ bf_command(ficlVm *vm) for (cp = tail, len = 0; cp != vm->tib.end && *cp != 0 && *cp != '\n'; cp++, len++) ; - + line = malloc(strlen(name) + len + 2); strcpy(line, name); if (len > 0) { @@ -131,7 +130,7 @@ bf_command(ficlVm *vm) } } DEBUG("cmd '%s'", line); - + command_errmsg = command_errbuf; command_errbuf[0] = 0; if (!parse(&argc, &argv, line)) { @@ -249,7 +248,6 @@ bf_command(ficlVm *vm) "throw " /* throw stack-returned result */ \ "then ; " -extern int ficlExecFD(ficlVm *, int); /* * Initialise the Forth interpreter, create all our commands as words. */ diff --git a/usr/src/boot/sys/boot/common/interp_parse.c b/usr/src/boot/sys/boot/common/interp_parse.c index 92a46bf246..64ddadea21 100644 --- a/usr/src/boot/sys/boot/common/interp_parse.c +++ b/usr/src/boot/sys/boot/common/interp_parse.c @@ -114,17 +114,18 @@ parse(int *argc, char ***argv, char *str) if (dquote) { /* keep quote */ PARSE_FAIL(i == (PARSE_BUFSIZE - 1)); buf[i++] = *p++; - } else + } else { ++p; + } } else if (isdquote(*p)) { dquote = dquote ? 0 : *p; if (quote) { /* keep dquote */ PARSE_FAIL(i == (PARSE_BUFSIZE - 1)); buf[i++] = *p++; - } else + } else { ++p; - } - else if (isspace(*p) && !quote && !dquote) { + } + } else if (isspace(*p) && !quote && !dquote) { state = WHITE; if (i) { buf[i] = '\0'; diff --git a/usr/src/boot/sys/boot/common/load_elf.c b/usr/src/boot/sys/boot/common/load_elf.c index d5756f681f..287bfac56a 100644 --- a/usr/src/boot/sys/boot/common/load_elf.c +++ b/usr/src/boot/sys/boot/common/load_elf.c @@ -998,7 +998,7 @@ elf_hash(const char *name) static const char __elfN(bad_symtable)[] = "elf" __XSTRING(__ELF_WORD_SIZE) "_lookup_symbol: corrupt symbol table\n"; int -__elfN(lookup_symbol)(struct preloaded_file *fp, elf_file_t ef, +__elfN(lookup_symbol)(struct preloaded_file *fp __unused, elf_file_t ef, const char* name, Elf_Sym *symp) { Elf_Hashelt symnum; @@ -1006,7 +1006,6 @@ __elfN(lookup_symbol)(struct preloaded_file *fp, elf_file_t ef, char *strp; unsigned long hash; - (void)fp; hash = elf_hash(name); COPYOUT(&ef->buckets[hash % ef->nbuckets], &symnum, sizeof(symnum)); @@ -1084,10 +1083,8 @@ __elfN(reloc_ptr)(struct preloaded_file *mp, elf_file_t ef, } static Elf_Addr -__elfN(symaddr)(struct elf_file *ef, Elf_Size symidx) +__elfN(symaddr)(struct elf_file *ef __unused, Elf_Size symidx __unused) { - (void)ef; - (void)symidx; /* Symbol lookup by index not required here. */ return (0); } diff --git a/usr/src/boot/sys/boot/common/load_elf_obj.c b/usr/src/boot/sys/boot/common/load_elf_obj.c index bb28e81538..f32388e170 100644 --- a/usr/src/boot/sys/boot/common/load_elf_obj.c +++ b/usr/src/boot/sys/boot/common/load_elf_obj.c @@ -420,7 +420,7 @@ __elfN(obj_parse_modmetadata)(struct preloaded_file *fp, elf_file_t ef) } static int -__elfN(obj_lookup_set)(struct preloaded_file *fp, elf_file_t ef, +__elfN(obj_lookup_set)(struct preloaded_file *fp __unused, elf_file_t ef, const char* name, Elf_Addr *startp, Elf_Addr *stopp, int *countp) { Elf_Ehdr *hdr; @@ -429,7 +429,6 @@ __elfN(obj_lookup_set)(struct preloaded_file *fp, elf_file_t ef, vm_offset_t shstrtab; int i; - (void)fp; hdr = &ef->hdr; shdr = ef->e_shdr; shstrtab = shdr[ef->shstrindex].sh_addr; diff --git a/usr/src/boot/sys/boot/common/merge_help.awk b/usr/src/boot/sys/boot/common/merge_help.awk index afd818fe58..1070f73f1f 100644 --- a/usr/src/boot/sys/boot/common/merge_help.awk +++ b/usr/src/boot/sys/boot/common/merge_help.awk @@ -4,10 +4,6 @@ # # Merge two boot loader help files for FreeBSD 3.0 # Joe Abley -# -# Replaced character classes graph, print, blank with corresponding ranges -# to support nawk. When nawk will be teached to use proper regex(), this -# change can be reverted. BEGIN \ { @@ -24,14 +20,14 @@ BEGIN \ } # entry header -/^# T[!-~]+ (S[!-~]+ )*D[!-~][ -~]*$/ && (state == 1) \ +/^# T[[:graph:]]+ (S[[:graph:]]+ )*D[[:graph:]][[:print:]]*$/ && (state == 1) \ { - match($0, " T[!-~]+"); + match($0, " T[[:graph:]]+"); T = substr($0, RSTART + 2, RLENGTH - 2); - match($0, " S[!-~]+"); + match($0, " S[[:graph:]]+"); SSTART = RSTART S = (RLENGTH == -1) ? "" : substr($0, RSTART + 2, RLENGTH - 2); - match($0, " D[!-~][ -~]*$"); + match($0, " D[[:graph:]][[:print:]]*$"); D = substr($0, RSTART + 2); if (SSTART > RSTART) S = ""; @@ -83,8 +79,8 @@ BEGIN \ (state == 2) \ { - sub("[\t ]+$", ""); - if (help[ind, "text"] == 0 && $0 ~ /^[[\t ]]*$/) next; + sub("[[:blank:]]+$", ""); + if (help[ind, "text"] == 0 && $0 ~ /^[[:blank:]]*$/) next; help[ind, "text", help[ind, "text"]] = $0; help[ind, "text"]++; next; @@ -99,7 +95,7 @@ END \ printf "################################################################################\n"; printf "# T%s ", help[node, "T"]; if (help[node, "S"] != "") printf "S%s ", help[node, "S"]; - printf "D%s\n", help[node, "D"]; + printf "D%s\n\n", help[node, "D"]; for (i = 0; i < help[node, "text"]; i++) printf "%s\n", help[node, "text", i]; node = help[node, "link"]; diff --git a/usr/src/boot/sys/boot/common/part.c b/usr/src/boot/sys/boot/common/part.c index 3bf6d78dc4..0a5100f8b8 100644 --- a/usr/src/boot/sys/boot/common/part.c +++ b/usr/src/boot/sys/boot/common/part.c @@ -102,8 +102,8 @@ static struct parttypes { { PART_LINUX_SWAP, "Linux swap" }, { PART_DOS, "DOS/Windows" }, { PART_SOLARIS2, "Solaris 2" }, - { PART_ILLUMOS_UFS, "Illumos UFS" }, - { PART_ILLUMOS_ZFS, "Illumos ZFS" }, + { PART_ILLUMOS_UFS, "illumos UFS" }, + { PART_ILLUMOS_ZFS, "illumos ZFS" }, { PART_RESERVED, "Reserved" }, { PART_VTOC_BOOT, "boot" }, { PART_VTOC_ROOT, "root" }, @@ -724,7 +724,7 @@ ptable_open(void *dev, off_t sectors, uint16_t sectorsize, table = NULL; goto out; } else if (table->type == PTABLE_VTOC) - goto out; + goto out; #ifdef LOADER_VTOC8_SUPPORT if (be16dec(buf + offsetof(struct vtoc8, magic)) == VTOC_MAGIC) { @@ -874,8 +874,8 @@ ptable_getpart(const struct ptable *table, struct ptable_entry *part, int idx) * 6: non-active FAT/FAT32 slice */ #define PREF_RAWDISK 0 -#define PREF_FBSD_ACT 1 -#define PREF_FBSD 2 +#define PREF_ILLUMOS_ACT 1 +#define PREF_ILLUMOS 2 #define PREF_LINUX_ACT 3 #define PREF_LINUX 4 #define PREF_DOS_ACT 5 @@ -897,8 +897,8 @@ ptable_getbestpart(const struct ptable *table, struct ptable_entry *part) if (table->type == PTABLE_MBR) { switch (entry->type.mbr) { case DOSPTYP_SUNIXOS2: - pref = entry->flags & 0x80 ? PREF_FBSD_ACT: - PREF_FBSD; + pref = entry->flags & 0x80 ? PREF_ILLUMOS_ACT: + PREF_ILLUMOS; break; case DOSPTYP_LINUX: pref = entry->flags & 0x80 ? PREF_LINUX_ACT: @@ -923,7 +923,7 @@ ptable_getbestpart(const struct ptable *table, struct ptable_entry *part) if (entry->part.type == PART_DOS) pref = PREF_DOS; else if (entry->part.type == PART_ILLUMOS_ZFS) - pref = PREF_FBSD; + pref = PREF_ILLUMOS; else pref = PREF_NONE; } diff --git a/usr/src/boot/sys/boot/common/ufsread.c b/usr/src/boot/sys/boot/common/ufsread.c index c40245f3da..1ceb533352 100644 --- a/usr/src/boot/sys/boot/common/ufsread.c +++ b/usr/src/boot/sys/boot/common/ufsread.c @@ -187,11 +187,11 @@ inode_type(ufs_ino_t inode) indbuf = dmadat->indbuf; if (!inode) - return 0; + return (0); if (inomap != inode) { n = IPERVBLK(&fs); if (dskread(blkbuf, INO_TO_VBA(&fs, n, inode), DBPERVBLK)) - return -1; + return (-1); n = INO_TO_VBO(n, inode); #if defined(UFS1_ONLY) memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, diff --git a/usr/src/boot/sys/boot/efi/loader/main.c b/usr/src/boot/sys/boot/efi/loader/main.c index febf8ca4c4..5dc1099cdd 100644 --- a/usr/src/boot/sys/boot/efi/loader/main.c +++ b/usr/src/boot/sys/boot/efi/loader/main.c @@ -436,8 +436,7 @@ command_reboot(int argc __attribute((unused)), if (devsw[i]->dv_cleanup != NULL) (devsw[i]->dv_cleanup)(); - RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 23, - (CHAR16 *)(uintptr_t)msg); + RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 23, (CHAR16 *)msg); /* NOTREACHED */ return (CMD_ERROR); diff --git a/usr/src/boot/sys/boot/ficl/Makefile.inc b/usr/src/boot/sys/boot/ficl/Makefile.inc index 91920b49b9..37a3cc45af 100644 --- a/usr/src/boot/sys/boot/ficl/Makefile.inc +++ b/usr/src/boot/sys/boot/ficl/Makefile.inc @@ -1,4 +1,18 @@ # +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2016 Toomas Soome +# + CC= $(GCC_ROOT)/bin/gcc FICLDIR= $(SRC)/common/ficl diff --git a/usr/src/boot/sys/boot/forth/beadm.4th b/usr/src/boot/sys/boot/forth/beadm.4th index ad07775bb9..7a65e669b0 100644 --- a/usr/src/boot/sys/boot/forth/beadm.4th +++ b/usr/src/boot/sys/boot/forth/beadm.4th @@ -1,4 +1,3 @@ -\ Copyright 2015 Toomas Soome \ \ This file and its contents are supplied under the terms of the \ Common Development and Distribution License ("CDDL"), version 1.0. @@ -9,6 +8,12 @@ \ source. A copy of the CDDL is also available via the Internet at \ http://www.illumos.org/license/CDDL. +\ Copyright 2015 Toomas Soome + +\ This module is implementing the beadm user command to support listing +\ and switching Boot Environments (BE) from command line and +\ support words to provide data for BE menu in loader menu system. +\ Note: this module needs an update to provide proper BE vocabulary. only forth also support-functions also file-processing also file-processing definitions also parser diff --git a/usr/src/boot/sys/boot/forth/loader.4th b/usr/src/boot/sys/boot/forth/loader.4th index 4642b31bda..a7a2813d7d 100644 --- a/usr/src/boot/sys/boot/forth/loader.4th +++ b/usr/src/boot/sys/boot/forth/loader.4th @@ -230,7 +230,7 @@ only forth also support-functions also builtins definitions 0= if ( interpreted ) get_arguments then set-boot-args - \ Unload only if a path was passed. Path is starting with / + \ Unload only if a path was passed. Paths start with / dup if >r over r> swap c@ [char] / = if @@ -286,12 +286,12 @@ only forth definitions also support-functions \ -d to boot_debug=YES \ -r to boot_reconfigure=YES \ -B acpi-user-options=X to acpi-user-options=X -\ this is needed to provide menu an data to manage options above -\ to allow menu to manage those options. -\ unfortunately thos also means boot-args will override previously -\ set options, but we have no way to control the processing order here. -\ boot-args will be re-built at boot. -\ NOTE: the best way to address the order is *not* set any above options +\ +\ This is needed so that the menu can manage these options. Unfortunately, this +\ also means that boot-args will override previously set options, but we have no +\ way to control the processing order here. boot-args will be rebuilt at boot. +\ +\ NOTE: The best way to address the order is to *not* set any above options \ in boot-args. : parse-boot-args { | baddr blen -- } diff --git a/usr/src/boot/sys/boot/forth/support.4th b/usr/src/boot/sys/boot/forth/support.4th index aa826afd6e..2d2fe03426 100644 --- a/usr/src/boot/sys/boot/forth/support.4th +++ b/usr/src/boot/sys/boot/forth/support.4th @@ -1122,8 +1122,8 @@ string current_file_name_ref \ used to print the file name closedir ; -\ built in prefix directory name, it must end with / so we do not -\ need to checks and insert it. +\ built-in prefix directory name; it must end with /, so we don't +\ need to check and insert it. : make_cstring ( addr len -- addr' ) dup ( addr len len ) s" /boot/conf.d/" ( addr len len addr' len' ) @@ -1792,7 +1792,7 @@ also builtins then drop - \ we have xen kernel loaded, load unix as module + \ we have loaded the xen kernel, load unix as module s" bootfile" getenv dup -1 <> if s" kernel" s" -t " 3 1 load then diff --git a/usr/src/boot/sys/boot/i386/libi386/biosacpi.c b/usr/src/boot/sys/boot/i386/libi386/biosacpi.c index 7451899f59..18f8050783 100644 --- a/usr/src/boot/sys/boot/i386/libi386/biosacpi.c +++ b/usr/src/boot/sys/boot/i386/libi386/biosacpi.c @@ -25,16 +25,11 @@ */ #include -__FBSDID("$FreeBSD$"); #include #include #include -#ifdef EFI -#define PTOV(x) (x) -#else #include -#endif #include "libi386.h" #include "platform/acfreebsd.h" @@ -54,49 +49,36 @@ static ACPI_TABLE_RSDP *biosacpi_search_rsdp(char *base, int length); #define RSDP_CHECKSUM_LENGTH 20 void -acpi_detect(const caddr_t addr) +biosacpi_detect(void) { ACPI_TABLE_RSDP *rsdp; char buf[24]; int revision; - if (addr == NULL) - rsdp = biosacpi_find_rsdp(); - else - rsdp = (ACPI_TABLE_RSDP *)addr; - /* locate and validate the RSDP */ - if (rsdp == NULL) + if ((rsdp = biosacpi_find_rsdp()) == NULL) return; /* export values from the RSDP */ -#ifdef _LP64 - sprintf(buf, "0x%016llx", (unsigned long long)rsdp); -#else sprintf(buf, "0x%08x", (unsigned int)VTOP(rsdp)); -#endif - 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); -#ifdef _LP64 - sprintf(buf, "0x%016llx", (unsigned long long)rsdp->RsdtPhysicalAddress); -#else + setenv("acpi.oem", buf, 1); sprintf(buf, "0x%08x", rsdp->RsdtPhysicalAddress); -#endif - 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/usr/src/boot/sys/boot/i386/libi386/comconsole.c b/usr/src/boot/sys/boot/i386/libi386/comconsole.c index 4354519d45..a8ce7906a0 100644 --- a/usr/src/boot/sys/boot/i386/libi386/comconsole.c +++ b/usr/src/boot/sys/boot/i386/libi386/comconsole.c @@ -93,7 +93,7 @@ struct console ttya = { comc_putchar, comc_getchar, comc_ischar, - 0 + NULL }; struct console ttyb = { @@ -105,7 +105,7 @@ struct console ttyb = { comc_putchar, comc_getchar, comc_ischar, - 0 + NULL }; struct console ttyc = { @@ -117,7 +117,7 @@ struct console ttyc = { comc_putchar, comc_getchar, comc_ischar, - 0 + NULL }; struct console ttyd = { @@ -129,7 +129,7 @@ struct console ttyd = { comc_putchar, comc_getchar, comc_ischar, - 0 + NULL }; static void diff --git a/usr/src/boot/sys/boot/i386/libi386/libi386.h b/usr/src/boot/sys/boot/i386/libi386/libi386.h index 7a74218aab..f03346f117 100644 --- a/usr/src/boot/sys/boot/i386/libi386/libi386.h +++ b/usr/src/boot/sys/boot/i386/libi386/libi386.h @@ -139,7 +139,7 @@ int biospci_write_config(uint32_t locator, int offset, int width, uint32_t val); int biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val); uint32_t biospci_locator(int8_t bus, uint8_t device, uint8_t function); -void acpi_detect(const caddr_t); +void biosacpi_detect(void); int i386_autoload(void); diff --git a/usr/src/boot/sys/boot/i386/libi386/linux.c b/usr/src/boot/sys/boot/i386/libi386/linux.c index d6d5358ef8..5d0a6435d3 100644 --- a/usr/src/boot/sys/boot/i386/libi386/linux.c +++ b/usr/src/boot/sys/boot/i386/libi386/linux.c @@ -74,7 +74,7 @@ find_real_addr(struct preloaded_file *fp) printf("no memory smap\n"); return (candidate); } - entries = md->md_size / sizeof(struct bios_smap); + entries = md->md_size / sizeof (struct bios_smap); smap = (struct bios_smap *)md->md_data; for (i = 0; i < entries; i++) { if (smap[i].type != SMAP_TYPE_MEMORY) @@ -101,7 +101,7 @@ linux_loadkernel(char *filename, uint64_t dest, struct preloaded_file **result) /* * relocater_data is space allocated in relocater_tramp.S - * There is space for 3 instances + terminating zero for case + * There is space for 3 instances + terminating zero in case * all 3 entries are used. */ rdata = (struct relocate_data *)&relocater_data; @@ -356,7 +356,8 @@ linux_exec(struct preloaded_file *fp) if (moveto + mfp->f_size >= max_addr) moveto = (max_addr - mfp->f_size) & 0xfffff000; - /* XXX: Linux 2.3.xx has a bug in the memory range check, + /* + * XXX: Linux 2.3.xx has a bug in the memory range check, * so avoid the last page. * XXX: Linux 2.2.xx has a bug in the memory range check, * which is worse than that of Linux 2.3.xx, so avoid the diff --git a/usr/src/boot/sys/boot/i386/libi386/multiboot.c b/usr/src/boot/sys/boot/i386/libi386/multiboot.c index c09c6e188b..37c132e088 100644 --- a/usr/src/boot/sys/boot/i386/libi386/multiboot.c +++ b/usr/src/boot/sys/boot/i386/libi386/multiboot.c @@ -85,7 +85,7 @@ struct file_format multiboot_obj = extern void multiboot_tramp(); -static const char mbl_name[] = "Illumos Loader"; +static const char mbl_name[] = "illumos Loader"; static int num_modules(struct preloaded_file *kfp) @@ -226,7 +226,7 @@ multiboot_loadfile(char *filename, u_int64_t dest, error = elf32_loadfile_raw(filename, dest, result, 1); if (error != 0) { printf("elf32_loadfile_raw failed: %d unable to " - "load multiboot kernel\n", error); + "load multiboot kernel\n", error); goto out; } } @@ -253,16 +253,18 @@ mb_malloc(size_t n) } /* - * as for now we have no way to pass environment to kernel other than - * for arguments, we need to provide console setup. - * if console is in mirror mode, set kernel console from $os_console, - * if unset, use first item from console. - * if console is ttyX, pass also ttyX-mode, as it may have been set by user + * Since for now we have no way to pass the environment to the kernel other than + * through arguments, we need to take care of console setup. * - * in case of memory allocation errors, just return original command line, - * so we have chance for boot. + * If the console is in mirror mode, set the kernel console from $os_console. + * If it's unset, use first item from $console. + * If $console is "ttyX", also pass $ttyX-mode, since it may have been set by + * the user. * - * on success, cl will be freed and new allocated command line string is + * In case of memory allocation errors, just return original command line, + * so we have chance of booting. + * + * On success, cl will be freed and a new, allocated command line string is * returned. */ static char * @@ -281,10 +283,10 @@ update_cmdline(char *cl) os_console = strdup(os_console); if (os_console == NULL) - return(cl); + return (cl); - if (strstr(os_console, "tty") != NULL) { - snprintf(mode, 10, "%s-mode", os_console); + if (strncmp(os_console, "tty", 3) == 0) { + snprintf(mode, sizeof (mode), "%s-mode", os_console); ttymode = getenv(mode); /* never NULL */ } @@ -305,7 +307,7 @@ update_cmdline(char *cl) tmp = malloc(len); if (tmp == NULL) { free(os_console); - return(cl); + return (cl); } if (ttymode != NULL) sprintf(tmp, @@ -324,7 +326,7 @@ update_cmdline(char *cl) ttymode = getenv(mode); /* never NULL */ } else { /* nope */ free(os_console); - return(cl); + return (cl); } len = strlen(cl) + 1; len += 13; /* ",ttyX-mode=\"\"" */ @@ -332,7 +334,7 @@ update_cmdline(char *cl) tmp = malloc(len); if (tmp == NULL) { free(os_console); - return(cl); + return (cl); } sprintf(tmp, "%s,%s=\"%s\"", cl, mode, ttymode); } @@ -350,7 +352,7 @@ update_cmdline(char *cl) tmp = malloc(len); if (tmp == NULL) { free(os_console); - return(cl); + return (cl); } if (ttymode != NULL) sprintf(tmp, "%s -B console=%s,%s-mode=\"%s\"", cl, @@ -433,7 +435,7 @@ multiboot_exec(struct preloaded_file *fp) mb_info->flags = MULTIBOOT_INFO_MEMORY|MULTIBOOT_INFO_BOOT_LOADER_NAME; mb_info->mem_lower = bios_basemem / 1024; mb_info->mem_upper = bios_extmem / 1024; - mb_info->boot_loader_name = mb_malloc(strlen(mbl_name + 1)); + mb_info->boot_loader_name = mb_malloc(strlen(mbl_name) + 1); i386_copyin(mbl_name, mb_info->boot_loader_name, strlen(mbl_name)+1); @@ -585,9 +587,9 @@ multiboot_exec(struct preloaded_file *fp) goto error; } snprintf(cmdline, len, "%s %s", fp->f_name, fp->f_args); - } - else + } else { cmdline = strdup(fp->f_name); + } } else { cmdline = kernel_cmdline(fp, rootdev); } diff --git a/usr/src/boot/sys/boot/i386/libi386/nullconsole.c b/usr/src/boot/sys/boot/i386/libi386/nullconsole.c index 64c1e016be..cd9f3a514a 100644 --- a/usr/src/boot/sys/boot/i386/libi386/nullconsole.c +++ b/usr/src/boot/sys/boot/i386/libi386/nullconsole.c @@ -55,7 +55,7 @@ struct console nullconsole = { nullc_putchar, nullc_getchar, nullc_ischar, - 0 + NULL }; static void diff --git a/usr/src/boot/sys/boot/i386/libi386/pxe.c b/usr/src/boot/sys/boot/i386/libi386/pxe.c index a67ea61f48..cddf8d244e 100644 --- a/usr/src/boot/sys/boot/i386/libi386/pxe.c +++ b/usr/src/boot/sys/boot/i386/libi386/pxe.c @@ -377,7 +377,7 @@ pxe_print(int verbose) if (pxe_call == NULL) return (0); - snprintf(line, 255, " pxe0: %s:%s\n", inet_ntoa(rootip), + snprintf(line, sizeof (line), " pxe0: %s:%s\n", inet_ntoa(rootip), rootpath); return (pager_output(line)); } diff --git a/usr/src/boot/sys/boot/i386/libi386/relocater_tramp.S b/usr/src/boot/sys/boot/i386/libi386/relocater_tramp.S index 6c0036fe04..ad36b60873 100644 --- a/usr/src/boot/sys/boot/i386/libi386/relocater_tramp.S +++ b/usr/src/boot/sys/boot/i386/libi386/relocater_tramp.S @@ -8,20 +8,23 @@ * source. A copy of the CDDL is also available via the Internet at * http://www.illumos.org/license/CDDL. */ +/* + * Copyright 2016 Toomas Soome + */ /* - * relocate is needed to support loading code which has to be located + * Relocate is needed to support loading code which has to be located * below 1MB, as both BTX and loader are using low memory area. * - * relocate and start loaded code. Since loaded code may need to be - * placed to already occupied memory area, this code is moved to safe + * Relocate and start loaded code. Since loaded code may need to be + * placed in an already occupied memory area, the code is moved to a safe * memory area and then btx __exec will be called with physical pointer - * to this area. __exec will set pointer to %eax and use call *%eax, - * so on entry, we have new "base" address in %eax. + * to this area. __exec will set the pointer to %eax and call *%eax, + * so that on entry, we have the new "base" address in %eax. * * Relocate will first set up and load new safe GDT to shut down BTX, * then loaded code will be relocated to final memory location, - * then machine will be switched from 32bit protected mode to 16bit + * then machine will be switched from 32-bit protected mode to 16-bit * protected mode following by switch to real mode with A20 enabled or * disabled. Finally the loaded code will be started and it will take * over the whole system. @@ -106,7 +109,7 @@ loop.1: loop.2: movl %ebx, %esi /* restore esi */ /* - * data is relocated, switch to 16bit mode + * data is relocated, switch to 16-bit mode */ lea (relocater.3-relocater)(%esi), %eax movl %eax, (jump_vector-relocater) (%esi) diff --git a/usr/src/boot/sys/boot/i386/libi386/spinconsole.c b/usr/src/boot/sys/boot/i386/libi386/spinconsole.c index b1b895d980..762b88abd1 100644 --- a/usr/src/boot/sys/boot/i386/libi386/spinconsole.c +++ b/usr/src/boot/sys/boot/i386/libi386/spinconsole.c @@ -63,7 +63,7 @@ struct console spinconsole = { spinc_putchar, spinc_getchar, spinc_ischar, - 0 + NULL }; static void diff --git a/usr/src/boot/sys/boot/i386/libi386/vidconsole.c b/usr/src/boot/sys/boot/i386/libi386/vidconsole.c index 6807509ef8..edefda223c 100644 --- a/usr/src/boot/sys/boot/i386/libi386/vidconsole.c +++ b/usr/src/boot/sys/boot/i386/libi386/vidconsole.c @@ -81,7 +81,7 @@ struct console text = { vidc_putchar, vidc_getchar, vidc_ischar, - 0 + NULL }; static void @@ -598,7 +598,7 @@ vidc_getchar(struct console *cp) v86.addr = 0x16; v86.eax = 0x0; v86int(); - if (v86.eax & 0xff) { + if ((v86.eax & 0xff) != 0) { return (v86.eax & 0xff); } diff --git a/usr/src/boot/sys/boot/i386/loader/Makefile b/usr/src/boot/sys/boot/i386/loader/Makefile index 5c02069d44..1e967c9993 100644 --- a/usr/src/boot/sys/boot/i386/loader/Makefile +++ b/usr/src/boot/sys/boot/i386/loader/Makefile @@ -27,6 +27,8 @@ CPPFLAGS += -I../libi386 LIBZFSBOOT= ../../zfs/i386/libzfsboot.a LIBI386= ../libi386/libi386.a +# loader.help build needs better awk +AWK= /usr/xpg4/bin/awk LD= $(GNU_ROOT)/bin/gld CC= $(GCC_ROOT)/bin/gcc OBJCOPY= $(GNU_ROOT)/bin/gobjcopy diff --git a/usr/src/boot/sys/boot/i386/loader/loader.rc b/usr/src/boot/sys/boot/i386/loader/loader.rc index 429db85790..32f6bf8043 100644 --- a/usr/src/boot/sys/boot/i386/loader/loader.rc +++ b/usr/src/boot/sys/boot/i386/loader/loader.rc @@ -1,12 +1,11 @@ \ Loader.rc -\ $FreeBSD$ \ \ Includes additional commands include /boot/forth/loader.4th try-include /boot/loader.rc.local \ Reads and processes loader.conf variables -\ NOTE: Change to `initialize' if you enable the below boot menu +\ NOTE: Change to `start' if you disable the below boot menu \ also note that initialize will leave flag in stack from any_conf_read? \ start initialize drop @@ -14,8 +13,8 @@ initialize drop \ Tests for password -- executes autoboot first if a password was defined check-password -\ Uncomment to enable boot menu +\ Load in the boot menu include /boot/forth/beastie.4th -beastie-start -\ Unless set otherwise, autoboot is automatic at this point +\ Start the boot menu +beastie-start diff --git a/usr/src/boot/sys/boot/i386/loader/main.c b/usr/src/boot/sys/boot/i386/loader/main.c index 4586dd14dd..4cba1b9945 100644 --- a/usr/src/boot/sys/boot/i386/loader/main.c +++ b/usr/src/boot/sys/boot/i386/loader/main.c @@ -179,7 +179,7 @@ main(void) } /* detect ACPI for future reference */ - acpi_detect(NULL); + biosacpi_detect(); /* detect SMBIOS for future reference */ smbios_detect(NULL); diff --git a/usr/src/boot/sys/boot/i386/pmbr/pmbr.s b/usr/src/boot/sys/boot/i386/pmbr/pmbr.s index fded47ca7f..46088cc78c 100644 --- a/usr/src/boot/sys/boot/i386/pmbr/pmbr.s +++ b/usr/src/boot/sys/boot/i386/pmbr/pmbr.s @@ -31,7 +31,7 @@ # # Partly from: src/sys/boot/i386/mbr/mbr.s 1.7 -# A 512 byte PMBR boot manager to read boot program and run it. +# A 512 byte PMBR boot manager to read a boot program and run it. # The embedded MBR is set up for PMBR and default bootblock sector # is hardcoded to 256 and size 1. The actual values are supposed to be # updated by installboot. diff --git a/usr/src/boot/sys/boot/zfs/zfsimpl.c b/usr/src/boot/sys/boot/zfs/zfsimpl.c index 8d6afff224..d015617f3e 100644 --- a/usr/src/boot/sys/boot/zfs/zfsimpl.c +++ b/usr/src/boot/sys/boot/zfs/zfsimpl.c @@ -783,7 +783,7 @@ pager_printf(const char *fmt, ...) va_list args; va_start(args, fmt); - vsnprintf(line, 80, fmt, args); + vsnprintf(line, sizeof (line), fmt, args); va_end(args); return (pager_output(line)); } -- 2.11.4.GIT