diff options
author | Renato Botelho <renato@netgate.com> | 2017-07-03 16:41:30 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-07-03 16:41:30 -0300 |
commit | b91e8edec6ef973706ceba5985379a0aded6a5aa (patch) | |
tree | 92c1d3976fd61f447f3e62225141c02b6ef4c320 /sys/boot | |
parent | 5fa580e9c45b6668f134701651fa17cad722750e (diff) | |
parent | ff3a058c4f832f66c1a779cf9bd05f758ad411d8 (diff) | |
download | FreeBSD-src-b91e8edec6ef973706ceba5985379a0aded6a5aa.zip FreeBSD-src-b91e8edec6ef973706ceba5985379a0aded6a5aa.tar.gz |
Merge remote-tracking branch 'origin/releng/11.1' into RELENG_2_5
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/Makefile.inc | 7 | ||||
-rw-r--r-- | sys/boot/efi/boot1/Makefile | 5 | ||||
-rw-r--r-- | sys/boot/efi/boot1/boot1.c | 1 | ||||
-rw-r--r-- | sys/boot/efi/boot1/boot_module.h | 2 | ||||
-rw-r--r-- | sys/boot/efi/include/efichar.h | 35 | ||||
-rw-r--r-- | sys/boot/efi/libefi/efichar.c | 186 | ||||
-rw-r--r-- | sys/boot/efi/loader/main.c | 2 | ||||
-rw-r--r-- | sys/boot/i386/boot2/Makefile | 8 | ||||
-rw-r--r-- | sys/boot/i386/pxeldr/Makefile | 2 | ||||
-rw-r--r-- | sys/boot/i386/zfsboot/Makefile | 4 | ||||
-rw-r--r-- | sys/boot/pc98/boot0.5/Makefile | 2 | ||||
-rw-r--r-- | sys/boot/pc98/boot2/Makefile | 4 | ||||
-rw-r--r-- | sys/boot/pc98/pc98boot/Makefile | 2 | ||||
-rw-r--r-- | sys/boot/powerpc/boot1.chrp/Makefile | 4 | ||||
-rw-r--r-- | sys/boot/sparc64/boot1/Makefile | 6 |
15 files changed, 248 insertions, 22 deletions
diff --git a/sys/boot/Makefile.inc b/sys/boot/Makefile.inc index 9c39953..1f1ccc2 100644 --- a/sys/boot/Makefile.inc +++ b/sys/boot/Makefile.inc @@ -15,3 +15,10 @@ CFLAGS.clang+= -mno-movt .endif CFLAGS.clang+= -mfpu=none .endif + +# The boot loader build uses dd status=none, where possible, for reproducible +# build output (since performance varies from run to run). Trouble is that +# option was recently (10.3) added to FreeBSD and is non-standard. Only use it +# when this test succeeds rather than require dd to be a bootstrap tool. +DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true +DD=dd ${DD_NOSTATUS} diff --git a/sys/boot/efi/boot1/Makefile b/sys/boot/efi/boot1/Makefile index 11d604d..8ae1b76 100644 --- a/sys/boot/efi/boot1/Makefile +++ b/sys/boot/efi/boot1/Makefile @@ -107,7 +107,7 @@ boot1.o: ${.CURDIR}/../../common/ufsread.c BOOT1_MAXSIZE?= 131072 boot1.efifat: boot1.efi - @set -- `ls -l boot1.efi`; \ + @set -- `ls -l ${.ALLSRC}`; \ x=$$(($$5-${BOOT1_MAXSIZE})); \ if [ $$x -ge 0 ]; then \ echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ @@ -117,8 +117,7 @@ boot1.efifat: boot1.efi uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 bzip2 -f -d ${.TARGET}.bz2 - dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc \ - status=none + ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc CLEANFILES= boot1.efi boot1.efifat diff --git a/sys/boot/efi/boot1/boot1.c b/sys/boot/efi/boot1/boot1.c index 92eb345..d6293fe 100644 --- a/sys/boot/efi/boot1/boot1.c +++ b/sys/boot/efi/boot1/boot1.c @@ -47,7 +47,6 @@ static const boot_module_t *boot_modules[] = /* The initial number of handles used to query EFI for partitions. */ #define NUM_HANDLES_INIT 24 -void putchar(int c); EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab); EFI_SYSTEM_TABLE *systab; diff --git a/sys/boot/efi/boot1/boot_module.h b/sys/boot/efi/boot1/boot_module.h index 3a6b827..1917da2 100644 --- a/sys/boot/efi/boot1/boot_module.h +++ b/sys/boot/efi/boot1/boot_module.h @@ -105,8 +105,6 @@ extern const boot_module_t zfs_module; /* Functions available to modules. */ extern void add_device(dev_info_t **devinfop, dev_info_t *devinfo); -extern void panic(const char *fmt, ...) __dead2; -extern int printf(const char *fmt, ...); extern int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); extern EFI_SYSTEM_TABLE *systab; diff --git a/sys/boot/efi/include/efichar.h b/sys/boot/efi/include/efichar.h new file mode 100644 index 0000000..49952e9 --- /dev/null +++ b/sys/boot/efi/include/efichar.h @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2010 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 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$ + */ + +#ifndef _BOOT_EFI_EFICHAR_H_ +#define _BOOT_EFI_EFICHAR_H_ + +int ucs2_to_utf8(const efi_char *, char **); +int utf8_to_ucs2(const char *, efi_char **, size_t *); + +#endif /* _BOOT_EFI_EFICHAR_H_ */ diff --git a/sys/boot/efi/libefi/efichar.c b/sys/boot/efi/libefi/efichar.c new file mode 100644 index 0000000..2002271 --- /dev/null +++ b/sys/boot/efi/libefi/efichar.c @@ -0,0 +1,186 @@ +/*- + * Copyright (c) 2010 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 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/types.h> +#include <errno.h> +#include <stddef.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/efi.h> +#include <machine/efi.h> + +#include "efichar.h" + +/* + * If nm were converted to utf8, what what would strlen + * return on the resulting string? + */ +static size_t +utf8_len_of_ucs2(const efi_char *nm) +{ + size_t len; + efi_char c; + + len = 0; + while (*nm) { + c = *nm++; + if (c > 0x7ff) + len += 3; + else if (c > 0x7f) + len += 2; + else + len++; + } + + return (len); +} + +int +ucs2_to_utf8(const efi_char *nm, char **name) +{ + size_t len, sz; + efi_char c; + char *cp; + int freeit = *name == NULL; + + sz = utf8_len_of_ucs2(nm) + 1; + len = 0; + if (*name != NULL) + cp = *name; + else + cp = *name = malloc(sz); + if (*name == NULL) + return (ENOMEM); + + while (*nm) { + c = *nm++; + if (c > 0x7ff) { + if (len++ < sz) + *cp++ = (char)(0xE0 | (c >> 12)); + if (len++ < sz) + *cp++ = (char)(0x80 | ((c >> 6) & 0x3f)); + if (len++ < sz) + *cp++ = (char)(0x80 | (c & 0x3f)); + } else if (c > 0x7f) { + if (len++ < sz) + *cp++ = (char)(0xC0 | ((c >> 6) & 0x1f)); + if (len++ < sz) + *cp++ = (char)(0x80 | (c & 0x3f)); + } else { + if (len++ < sz) + *cp++ = (char)(c & 0x7f); + } + } + + if (len >= sz) { + /* Absent bugs, we'll never return EOVERFLOW */ + if (freeit) + free(*name); + return (EOVERFLOW); + } + *cp++ = '\0'; + + return (0); +} + +int +utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len) +{ + efi_char *nm; + size_t sz; + uint32_t ucs4; + int c, bytes; + int freeit = *nmp == NULL; + + sz = strlen(name) * 2 + 2; + if (*nmp == NULL) + *nmp = malloc(sz); + nm = *nmp; + *len = sz; + + ucs4 = 0; + bytes = 0; + while (sz > 1 && *name != '\0') { + c = *name++; + /* + * Conditionalize on the two major character types: + * initial and followup characters. + */ + if ((c & 0xc0) != 0x80) { + /* Initial characters. */ + if (bytes != 0) { + if (freeit) + free(nm); + return (EILSEQ); + } + if ((c & 0xf8) == 0xf0) { + ucs4 = c & 0x07; + bytes = 3; + } else if ((c & 0xf0) == 0xe0) { + ucs4 = c & 0x0f; + bytes = 2; + } else if ((c & 0xe0) == 0xc0) { + ucs4 = c & 0x1f; + bytes = 1; + } else { + ucs4 = c & 0x7f; + bytes = 0; + } + } else { + /* Followup characters. */ + if (bytes > 0) { + ucs4 = (ucs4 << 6) + (c & 0x3f); + bytes--; + } else if (bytes == 0) { + if (freeit) + free(nm); + return (EILSEQ); + } + } + if (bytes == 0) { + if (ucs4 > 0xffff) { + if (freeit) + free(nm); + return (EILSEQ); + } + *nm++ = (efi_char)ucs4; + sz -= 2; + } + } + if (sz < 2) { + if (freeit) + free(nm); + return (EDOOFUS); + } + sz -= 2; + *nm = 0; + *len -= sz; + return (0); +} diff --git a/sys/boot/efi/loader/main.c b/sys/boot/efi/loader/main.c index 0490d9b..2054955 100644 --- a/sys/boot/efi/loader/main.c +++ b/sys/boot/efi/loader/main.c @@ -314,7 +314,7 @@ main(int argc, CHAR16 *argv[]) } else { cpy16to8(&argv[i + 1][0], var, sizeof(var)); - setenv("comconsole_speedspeed", var, 1); + setenv("comconsole_speed", var, 1); } i++; break; diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index 16ed404..c524be0 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -69,17 +69,19 @@ boot1.out: boot1.o CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ boot2.s boot2.s.tmp boot2.h sio.o +BOOT2SIZE= 7680 + boot2: boot2.ld - @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ + @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \ echo "$$x bytes available"; test $$x -ge 0 - dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync status=none + ${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync boot2.ld: boot2.ldr boot2.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ -o ${.TARGET} -P 1 boot2.bin boot2.ldr: - dd if=/dev/zero of=${.TARGET} bs=512 count=1 status=none + ${DD} if=/dev/zero of=${.TARGET} bs=512 count=1 boot2.bin: boot2.out ${OBJCOPY} -S -O binary boot2.out ${.TARGET} diff --git a/sys/boot/i386/pxeldr/Makefile b/sys/boot/i386/pxeldr/Makefile index 8de2139..c0b7504 100644 --- a/sys/boot/i386/pxeldr/Makefile +++ b/sys/boot/i386/pxeldr/Makefile @@ -31,7 +31,7 @@ CLEANFILES+= ${BOOT}.tmp ${BOOT}: ${LDR} ${LOADER} cat ${LDR} ${LOADER} > ${.TARGET}.tmp - dd if=${.TARGET}.tmp of=${.TARGET} obs=2k conv=osync status=none + ${DD} if=${.TARGET}.tmp of=${.TARGET} obs=2k conv=osync rm ${.TARGET}.tmp LDFLAGS+=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile index ee83e04..d7b6636 100644 --- a/sys/boot/i386/zfsboot/Makefile +++ b/sys/boot/i386/zfsboot/Makefile @@ -63,9 +63,9 @@ CLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \ BOOT2SIZE= 65536 zfsboot2: zfsboot.ld - @set -- `ls -l zfsboot.ld`; x=$$((${BOOT2SIZE}-$$5)); \ + @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \ echo "$$x bytes available"; test $$x -ge 0 - dd if=zfsboot.ld of=${.TARGET} obs=${BOOT2SIZE} conv=osync status=none + ${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \ diff --git a/sys/boot/pc98/boot0.5/Makefile b/sys/boot/pc98/boot0.5/Makefile index 9a9d94f..ec40fe5 100644 --- a/sys/boot/pc98/boot0.5/Makefile +++ b/sys/boot/pc98/boot0.5/Makefile @@ -18,7 +18,7 @@ LDFLAGS=-e start -Ttext ${BOOT_BOOT0_ORG} -Wl,-N,-T,${.CURDIR}/ldscript # The size of boot0.5 must be 7168 bytes ${BOOT}: ${BOOT}.bin - cat ${BOOT}.bin /dev/zero | dd of=${BOOT} bs=1 count=7168 + cat ${BOOT}.bin /dev/zero | ${DD} of=${BOOT} bs=1 count=7168 ${BOOT}.bin: ${BOOT}.out ${OBJCOPY} -S -O binary ${BOOT}.out ${.TARGET} diff --git a/sys/boot/pc98/boot2/Makefile b/sys/boot/pc98/boot2/Makefile index 8d5e791..2c26468 100644 --- a/sys/boot/pc98/boot2/Makefile +++ b/sys/boot/pc98/boot2/Makefile @@ -78,14 +78,14 @@ CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ boot2: boot2.ld @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ echo "$$x bytes available"; test $$x -ge 0 - dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync + ${DD} if=boot2.ld of=${.TARGET} obs=7680 conv=osync boot2.ld: boot2.ldr boot2.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ -o ${.TARGET} -P 1 boot2.bin boot2.ldr: - dd if=/dev/zero of=${.TARGET} bs=276 count=1 + ${DD} if=/dev/zero of=${.TARGET} bs=276 count=1 boot2.bin: boot2.out ${OBJCOPY} -S -O binary boot2.out ${.TARGET} diff --git a/sys/boot/pc98/pc98boot/Makefile b/sys/boot/pc98/pc98boot/Makefile index 73bfba5..f33b15f 100644 --- a/sys/boot/pc98/pc98boot/Makefile +++ b/sys/boot/pc98/pc98boot/Makefile @@ -20,6 +20,6 @@ ${BOOT}: ${BOOT0} ${BOOT05} ${BOOT}.part cat ${BOOT0} ${BOOT}.part ${BOOT05} > ${.TARGET} ${BOOT}.part: - dd if=/dev/zero of=${.TARGET} bs=512 count=1 + ${DD} if=/dev/zero of=${.TARGET} bs=512 count=1 .include <bsd.prog.mk> diff --git a/sys/boot/powerpc/boot1.chrp/Makefile b/sys/boot/powerpc/boot1.chrp/Makefile index 381d2a8..a642f6c 100644 --- a/sys/boot/powerpc/boot1.chrp/Makefile +++ b/sys/boot/powerpc/boot1.chrp/Makefile @@ -30,8 +30,8 @@ boot1.hfs: boot1.elf bootinfo.txt uudecode ${.CURDIR}/hfs.tmpl.bz2.uu mv hfs.tmpl.bz2 ${.TARGET}.bz2 bzip2 -f -d ${.TARGET}.bz2 - dd if=boot1.elf of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc - dd if=${.CURDIR}/bootinfo.txt of=${.TARGET} seek=${BOOTINFO_OFFSET} \ + ${DD} if=boot1.elf of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc + ${DD} if=${.CURDIR}/bootinfo.txt of=${.TARGET} seek=${BOOTINFO_OFFSET} \ conv=notrunc CLEANFILES= boot1.hfs diff --git a/sys/boot/sparc64/boot1/Makefile b/sys/boot/sparc64/boot1/Makefile index 5150c3b..3453b28 100644 --- a/sys/boot/sparc64/boot1/Makefile +++ b/sys/boot/sparc64/boot1/Makefile @@ -17,10 +17,10 @@ LDFLAGS=-Ttext ${BOOTBLOCKBASE} -Wl,-N # Construct boot1. sunlabel expects it to contain zeroed-out space for the # label, and to be of the correct size. ${FILES}: boot1.aout - @set -- `ls -l boot1.aout`; x=$$((7680-$$5)); \ + @set -- `ls -l ${.ALLSRC}`; x=$$((7680-$$5)); \ echo "$$x bytes available"; test $$x -ge 0 - dd if=/dev/zero of=${.TARGET} bs=512 count=16 - dd if=boot1.aout of=${.TARGET} bs=512 oseek=1 conv=notrunc + ${DD} if=/dev/zero of=${.TARGET} bs=512 count=16 + ${DD} if=${.ALLSRC} of=${.TARGET} bs=512 oseek=1 conv=notrunc boot1.aout: boot1.elf elf2aout -o ${.TARGET} ${.ALLSRC} |