History log of /freebsd-11-stable/stand/i386/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
370511 04-Sep-2021 git2svn

pxeboot: improve and simplify rx handling

This pushes the bulk of the rx servicing into a single loop that's only
slightly convoluted, and it addresses a problem with rx handling in the
process. If we hit a tx interrupt while we're processing, we'd
previously drop the frame on the floor completely and ultimately
timeout, increasing boot time on particularly busy hosts as we keep
having to backoff and resend.

After this patch, we don't seem to hit timeouts at all on zoo anymore
though loading a 27M kernel is still relatively slow (~1m20s).

Sponsored By: National Bureau of Economic Research
Sponsored by: Klara, Inc.

(cherry picked from commit 3daa8e165c661c1b45e759f4997f447384c15446)

Git Hash: c0674b71720bb333cbc2da823e2f67412dc00e78
Git Author: kevans@FreeBSD.org

367457 07-Nov-2020 dim

MFC r344855 (by jhb):

Drop "All rights reserved" from my copyright statements.

Reviewed by: rgrimes
Differential Revision: https://reviews.freebsd.org/D19485


/freebsd-11-stable/contrib/elftoolchain/libelf/gelf_mips64el.c
/freebsd-11-stable/lib/libdevctl/devctl.3
/freebsd-11-stable/lib/libdevctl/devctl.c
/freebsd-11-stable/lib/libdevctl/devctl.h
/freebsd-11-stable/lib/libkvm/kvm_aarch64.h
/freebsd-11-stable/lib/libkvm/kvm_amd64.h
/freebsd-11-stable/lib/libkvm/kvm_arm.h
/freebsd-11-stable/lib/libkvm/kvm_i386.h
/freebsd-11-stable/lib/libkvm/kvm_mips.h
/freebsd-11-stable/lib/libkvm/kvm_native.3
/freebsd-11-stable/lib/libkvm/kvm_sparc64.h
/freebsd-11-stable/lib/libsysdecode/errno.c
/freebsd-11-stable/lib/libsysdecode/signal.c
/freebsd-11-stable/lib/libsysdecode/syscallnames.c
/freebsd-11-stable/lib/libsysdecode/sysdecode.3
/freebsd-11-stable/lib/libsysdecode/sysdecode.h
/freebsd-11-stable/lib/libsysdecode/sysdecode_abi_to_freebsd_errno.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_cap_rights.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_enum.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_fcntl_arg.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_ioctlname.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_kevent.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_mask.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_quotactl_cmd.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_sigcode.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_socket_protocol.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_sockopt_name.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_syscallnames.3
/freebsd-11-stable/lib/libsysdecode/sysdecode_utrace.3
/freebsd-11-stable/lib/libutil/kinfo_getvmobject.3
/freebsd-11-stable/sbin/hastd/refcnt.h
/freebsd-11-stable/share/man/man3/sigevent.3
/freebsd-11-stable/share/man/man4/ktr.4
/freebsd-11-stable/share/man/man4/witness.4
/freebsd-11-stable/share/man/man9/BUS_GET_CPUS.9
/freebsd-11-stable/share/man/man9/BUS_RESCAN.9
/freebsd-11-stable/share/man/man9/atomic.9
/freebsd-11-stable/share/man/man9/bus_map_resource.9
/freebsd-11-stable/share/man/man9/critical_enter.9
/freebsd-11-stable/share/man/man9/ithread.9
/freebsd-11-stable/share/man/man9/ktr.9
/freebsd-11-stable/share/man/man9/runqueue.9
/freebsd-11-stable/share/man/man9/scheduler.9
/freebsd-11-stable/share/man/man9/sleepqueue.9
/freebsd-11-stable/share/man/man9/swi.9
/freebsd-11-stable/stand/efi/libefi/devpath.c
cdboot/cdboot.S
libi386/pxe.c
libi386/pxe.h
pxeldr/pxeldr.S
/freebsd-11-stable/sys/amd64/include/intr_machdep.h
/freebsd-11-stable/sys/arm/arm/ptrace_machdep.c
/freebsd-11-stable/sys/dev/acpica/acpi_isab.c
/freebsd-11-stable/sys/dev/acpica/acpi_pcivar.h
/freebsd-11-stable/sys/dev/pci/vga_pci.c
/freebsd-11-stable/sys/dev/rc/rc.c
/freebsd-11-stable/sys/dev/rc/rcreg.h
/freebsd-11-stable/sys/i386/pci/pci_pir.c
/freebsd-11-stable/sys/kern/kern_ktr.c
/freebsd-11-stable/sys/kern/kern_rwlock.c
/freebsd-11-stable/sys/kern/subr_lock.c
/freebsd-11-stable/sys/kern/subr_sleepqueue.c
/freebsd-11-stable/sys/kern/subr_smp.c
/freebsd-11-stable/sys/sys/_rwlock.h
/freebsd-11-stable/sys/sys/refcount.h
/freebsd-11-stable/sys/sys/rwlock.h
/freebsd-11-stable/sys/sys/sleepqueue.h
/freebsd-11-stable/sys/sys/turnstile.h
/freebsd-11-stable/sys/x86/acpica/madt.c
/freebsd-11-stable/sys/x86/include/apicvar.h
/freebsd-11-stable/sys/x86/include/intr_machdep.h
/freebsd-11-stable/sys/x86/isa/atpic.c
/freebsd-11-stable/sys/x86/isa/elcr.c
/freebsd-11-stable/sys/x86/x86/intr_machdep.c
/freebsd-11-stable/sys/x86/x86/io_apic.c
/freebsd-11-stable/sys/x86/x86/local_apic.c
/freebsd-11-stable/sys/x86/x86/mptable.c
/freebsd-11-stable/sys/x86/x86/mptable_pci.c
/freebsd-11-stable/sys/x86/xen/pvcpu_enum.c
/freebsd-11-stable/tests/sys/capsicum/ioctls_test.c
/freebsd-11-stable/tests/sys/kern/ptrace_test.c
/freebsd-11-stable/tools/tools/decioctl/decioctl.c
/freebsd-11-stable/usr.sbin/devctl/devctl.8
/freebsd-11-stable/usr.sbin/devctl/devctl.c
360838 09-May-2020 dim

MFC r358643:

Link stand/i386 components using a linker script

LLD 10.0.0 changed the behavior of the -Ttext option, so that using
-Ttext=0x0 now causes linking of the loaders to fail with:

ld: error: output file too large: 18446744073707016908 bytes

I reported this in https://bugs.llvm.org/show_bug.cgi?id=44715, and
initially reverted the upstream change in r357259 to work around it.

However, after some discussion with Fangrui Song in the upstream ticket,
I think we can classify this as an unfortunate interaction between using
-Ttext=0 in combination with --no-rosegment. (We added the latter
in r332090, because btxld does not correctly handle input with more
than 2 PT_LOAD segments.)

Fangrui suggested to use a linker script instead, and Warner was already
attempting this in r305353, but had to revert it due to "crypto-using
boot problems" (not sure what those were :).

This review updates the stand/i386/boot.ldscript to handle more
sections, inserts some symbols like _edata and such that we use in
libsa, and also discards any .interp section.

It uses ORG which is defined on the linker command line using
--defsym ORG=value to set the start of all the sections.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D23952

360660 05-May-2020 dim

MFC r355940:

Move all sources from the llvm project into contrib/llvm-project.

This uses the new layout of the upstream repository, which was recently
migrated to GitHub, and converted into a "monorepo". That is, most of
the earlier separate sub-projects with their own branches and tags were
consolidated into one top-level directory, and are now branched and
tagged together.

Updating the vendor area to match this layout is next.


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libunwind
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm-project
/freebsd-11-stable/contrib/llvm-project/clang
/freebsd-11-stable/contrib/llvm-project/compiler-rt
/freebsd-11-stable/contrib/llvm-project/libcxx
/freebsd-11-stable/contrib/llvm-project/libcxx/include/__errc
/freebsd-11-stable/contrib/llvm-project/libcxx/include/errno.h
/freebsd-11-stable/contrib/llvm-project/libunwind
/freebsd-11-stable/contrib/llvm-project/lld
/freebsd-11-stable/contrib/llvm-project/lldb
/freebsd-11-stable/contrib/llvm-project/llvm
/freebsd-11-stable/contrib/llvm-project/openmp
/freebsd-11-stable/contrib/openmp
/freebsd-11-stable/gnu/usr.bin/cc/include/Makefile
/freebsd-11-stable/lib/clang/clang.build.mk
/freebsd-11-stable/lib/clang/clang.pre.mk
/freebsd-11-stable/lib/clang/libclang/Makefile
/freebsd-11-stable/lib/clang/liblldb/Makefile
/freebsd-11-stable/lib/clang/libllvm/Makefile
/freebsd-11-stable/lib/clang/libllvmminimal/Makefile
/freebsd-11-stable/lib/clang/lldb.pre.mk
/freebsd-11-stable/lib/clang/llvm.build.mk
/freebsd-11-stable/lib/clang/llvm.pre.mk
/freebsd-11-stable/lib/libblocksruntime/Makefile
/freebsd-11-stable/lib/libc++/Makefile
/freebsd-11-stable/lib/libc++experimental/Makefile
/freebsd-11-stable/lib/libc/arm/aeabi/Makefile.inc
/freebsd-11-stable/lib/libclang_rt/Makefile.inc
/freebsd-11-stable/lib/libcompiler_rt/Makefile.inc
/freebsd-11-stable/lib/libexecinfo/Makefile
/freebsd-11-stable/lib/libgcc_eh/Makefile.inc
/freebsd-11-stable/lib/libomp/Makefile
/freebsd-11-stable/share/doc/llvm/Makefile
/freebsd-11-stable/share/doc/llvm/clang/Makefile
/freebsd-11-stable/share/mk/bsd.clang-analyze.mk
boot2/Makefile
/freebsd-11-stable/stand/libsa/Makefile
/freebsd-11-stable/usr.bin/clang/bugpoint/Makefile
/freebsd-11-stable/usr.bin/clang/clang-format/Makefile
/freebsd-11-stable/usr.bin/clang/clang-tblgen/Makefile
/freebsd-11-stable/usr.bin/clang/clang/Makefile
/freebsd-11-stable/usr.bin/clang/llc/Makefile
/freebsd-11-stable/usr.bin/clang/lld/Makefile
/freebsd-11-stable/usr.bin/clang/lldb-tblgen/Makefile
/freebsd-11-stable/usr.bin/clang/lldb/Makefile
/freebsd-11-stable/usr.bin/clang/lli/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-ar/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-as/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-bcanalyzer/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-cov/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-cxxdump/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-cxxfilt/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-diff/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-dis/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-dwarfdump/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-extract/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-link/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-lto/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-lto2/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-mc/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-mca/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-modextract/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-nm/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-objcopy/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-objdump/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-pdbutil/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-profdata/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-rtdyld/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-symbolizer/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-tblgen/Makefile
/freebsd-11-stable/usr.bin/clang/llvm-xray/Makefile
/freebsd-11-stable/usr.bin/clang/opt/Makefile
360614 03-May-2020 dim

Revert r360605, as it is actually the cause for the linker set errors:

Un-MFC r352032 (by tsoome):

loader: --gc-sections needs sections to work with

--gc-sections is not really useful unless we generate sections with
-ffunction-sections -fdata-sections

While there, i386/loader would win from --gc-sections too.

360605 03-May-2020 dim

MFC r352032 (by tsoome):

loader: --gc-sections needs sections to work with

--gc-sections is not really useful unless we generate sections with
-ffunction-sections -fdata-sections

While there, i386/loader would win from --gc-sections too.

357496 04-Feb-2020 tsoome

MFC r357442:

loader: bc_add can not use any other probes than ah=0x4b

CD boot is broken for some systems since bioscd and biosdisk merge. The issue is that we can not use anything else than int 13 ah=0x4b to query cd information.

The patch does restore the same probe as was originally used in bioscd.c. Additionally extra buffer padding is used to avoid memory corruption caused by some systems.

PR: 234031
Reported by: ultramage and others

357354 31-Jan-2020 dim

MFC r357232:

Merge r357231 from the clang1000-import branch:

Work around assembler error from clang 10.0.0 in gptboot:

stand/i386/gptboot/gptldr.S:141:3: error: value of 36878 is too large for field of 2 bytes.
jmp MEM_JMP # Start BTX
^

Use the same construct as in stand/i386/boot2/boot1.S, which ensures the
jump distance does not become too large.

356572 09-Jan-2020 tsoome

MFC r356570:
loader: bioscd probe can get sector size 0

With buggy BIOS, it may happen we get sector size reported 0 for cd, and then
the default 512 is used, which is quite wrong.

PR: 238749

351515 26-Aug-2019 kevans

MFC r351119, r351135-r351136, r351412: stand xtoolchain-llvm90 fixes

r351119:
stand: push LIBC_SRC up into defs.mk

Other parts of stand/ that don't use libsa will need to grab bits from libc
shortly. Push LIBC_SRC up to defs.mk in advance of this so that they can use
it, and rename it to LIBCSRC to match the convention of the rest of the *SRC
variables in this file.

r351135:
stand: boot2: fix build with xtoolchain-llvm90

ufsread.c grows a dependency on __ashldi3 with llvm90. Grab ashldi3.c out of
compiler-rt rather than trying to link against libsa (for now).
-Wno-missing-prototypes is necessary to compile ashldi3.c standalone.

r351136:
stand: gptboot: fix build with xtoolchain-llvm90

ufsread.c grows a dependency on __ashldi3 with llvm90. For gptboot, just
start pulling in ashldi3.c ashrdi3.c lshrdi3.c into libsa for all archs as
the number of archs requiring one or more of them keeps growing. qdivrem.c
and quad.h can be trivially kicked out of libsa if we start pulling these
from compiler-rt as qdivrem was only used to implement umoddi3, divdi3,
moddi3 (also in qdivrem.c).

r351412:
stand: boot2: fix amd64-xtoolchain-gcc build

-Wno-missing-declarations is the GCC equivalent of
-Wno-missing-prototypes... this was overlooked in r351135.

348866 10-Jun-2019 kevans

MFC r348569: [zfsboot] Fix boot env back compat (#190)

* Fix boot env back compat

zfsboot must try zfsloader before loader in order to remain compatible
with boot environments created prior to zfs functionality being rolled
into loader proper.

* Improve comments in zfsboot

Explain the significance of the load path order, and put the comment
about looping through the paths in the appropriate scope.

Approved by: re (gjb)

347705 16-May-2019 ian

MFC r346968, r346973

r346968:
Update the manpage text to show the output generated by the first-stage
bootloader these days (x86 instead of i386).

r346973:
Add a paragraph that mentions gptboot having an interactive mode, and
direct the user to the boot(8) manpage, which provides the details on that.

346482 21-Apr-2019 kevans

MFC r341101, r341231, r341276, r341329, r341433, r341780, r342054-r342055,
r342721, r342742, r342840, r343008, r343225

r341101:
powerpcspe: Don't crash the loader on ubldr with SPE instructions.

-msoft-float seems to be insufficient for disabling the SPE on powerpcspe.
Force it off with -mno-spe as well. This prevents a crash in ubldr on
powerpcspe.

r341231:
loader: command_bcache() should print unsigned values

All bcache counters are unsigned.

r341276:
When handling CMD_CRIT error set command_errmsg to NULL after we dump it out,
so that it does not result in error message printed twice.

OK load doodoo
can't find 'doodoo'
can't find 'doodoo'
OK

r341329:
loader.efi: fix EFI getchar() for multiple consoles

This fix is ported from illumos (issue #9970), the analysis and initial
implementation was done by John Levon.

See also: https://www.illumos.org/issues/9970

Currently, efi_cons_getchar() will wait for a key. While this seems to make
sense, the implementation of getchar() in common/console.c will loop across
getchar() for all consoles without doing ischar() first.

This means that if we've configured multiple consoles, we can't input into
the serial, as getchar() will be sat waiting for input only from efi_console.c

This patch does implement a bit more generic key buffer to support
translation of input keys, and we use generic efi_readkey() to reduce
duplication from calls from getchar() and poll().

r341433:
Move inclusion of src.opts.mk later.

src.opts.mk includes bsd.own.mk. This in turn defines CTFCONVERT_CMD
depending on the MK_CTF value. We then set MK_CTF to no, which has no
real effect. The solution is to set all the MK_foo values before
including src.opts.mk.

This should stop the cdboot binary from exploding in size for releases
built WITH_CTF=yes in src.conf.

r341780:
powerpc/ubldr: Teach powerpc's ubldr to boot 64-bit kernels

This is just a copy of powerpc/ofw's ppc64_elf_freebsd.c modified to fit
ubldr's boot format.

r342054:
Print an error message in efi_main.c if we can't allocate memory for the heap

With the default Qemu parameters, only 128MB RAM gets given to a VM. This causes
the loader to be unable to allocate the 64MB it needs for the heap. This change
makes the cause of the error more obvious.

r342055:
Cast error message in efi_main.c to CHAR16* to avoid build error

r342721:
loader.efi: update memmap command to recognize new attributes

Also move memory type to string translation to libefi for later use.

r342742:
loader.efi: efi variable rework and lsefi command added

This update does add diag and debug capabilities to interpret the efi
variables, configuration and protocols (lsefi).

The side effect is that we add/update bunch of related headers.

r342840:
Create MK_LOADER_VERBOSE and connect it to ELF_VERBOSE in the loader
code.

r343008:
Add Dell Chromebook to the list of devices with E820 extmem quirk enabled

Just like for Acer C270 chromebook the E820 extmem workaround is required for
FreeBSD to boot on Dell chromebook.

r343225:
Unbreak mip64 build after r328437

Add exit and getchar functions to beri/boot2 code. They are required by
panic_action functin introduced in r328437

PR: 18498, 204916

346480 21-Apr-2019 kevans

MFC r338262, r339334, r339796, r340240, r340857, r340917, r341007

r338262:
stand: fdt: Drop some write-only assignments/variables and leaked bits

Generally straightforward enough; a copy of argv[1] was being made in
command_fdt_internal, solely used for a comparison within the
handler-search, then promptly leaked.

r339334:
loader.efi: add poweroff command

Add poweroff command to make life a bit easier.

r339796:
Simplify the EFI delay() function by calling BS->Stall()

r340240:
loader: ptable_open() check for ptable_cd9660read result is wrong

The ptable_*read() functions return NULL on read errors (and partition table
closed as an side effect). The ptable_open must check the return value and
act properly.

r340857:
Nuke out buffer overflow safety marker code, it duplicates similar code in
the malloc()/free() as well as having potential of softening the handling
in case error is detected down to a mere warning as compared to hard panic
in free().

r340917:
Update pxeboot(8) manual page to reflect the next-server change in the ISC DHCP v3 server.

r341007:
Bump the date of pxeboot(8) manual page for r340917.

PR: 123484, 232483

346476 21-Apr-2019 kevans

MFC r341253, r341328, r342619, r342626, r342707, r342785, r342865

r341253:
The libstand's panic() appends its own '\n' to the message, so that users of the API
don't need to supply one.

r341328:
loader: create separate lists for fd, cd and hd, merge bioscd with biosdisk

Create unified block IO implementation in BIOS version, like it is done in UEFI
side. Implement fd, disk and cd device lists, this will split floppy devices
from disks and will allow us to have consistent, predictable device naming
(modulo BIOS issues).

r342619:
loader: create bio_alloc and bio_free for bios bounce buffer

We do have 16KB buffer space defined in pxe.c, move it to bio.c and implement
bio_alloc()/bio_free() interface to make it possible to use this space for
other BIOS calls (notably, from biosdisk.c).

r342626:
Add Copyright.

r342707:
i386_parsedev() needs to support fd devices

r342785:
With buggy int13 ah=15, we can mis-identify the floppy devices.

We have no option than trust INT13 ah=08 return code during the init phase.

r342865:
biospci_write_config args were backwards

biospci_write_config args swapped length and value to write. Some
hardware coped just fine, while other hardware had issues.

PR: 155441, 234460

346475 21-Apr-2019 kevans

MFC r339658, r339959, r340047, r340049, r340215

r339658:
loader: biosdisk interface should be able to cope with 4k sectors

The 4kn support in current bios specific biosdisk.c is broken, as the code
is only implementing the support for the 512B sector size.

This work is building the support for custom size sectors, we still do assume
the requested data to be multiple of 512B blocks and we only do address the
biosdisk.c interface here.

For reference, see also:
https://www.illumos.org/issues/8303
https://www.illumos.org/rb/r/547

As the GELI is moved above biosdisk "layer", the GELI should just work

r339959:
loader: issue edd probe before legacy ah=08 and detect no media

while probing for drives, use int13 extended info before standard one and
provide workaround for case we are not getting needed information in case
of floppy drive.

In case of INT13 errors, there are (at least) 3 error codes appearing in case
of missin media - 20h, 31h and 80h. Flag the no media and do not print an
error.

r340047:
loader: do not probe floppy devices for zfs

The subject is telling it all.

r340049:
loader: biosdisk should check if the media is present

The bd_print/bd_open/bd_strategy need to make sure the device does have
media, before getting into performing IO operations. Some systems can
hung if the device without a media is accessed.

r340215:
loader: always set media size from partition.

The disk access is validated by using partition table definitions, therefore
we have no need for if statements, just set the disk size.

Of course the partition table itself may be incorrect/inconsistent, but if
so, we are in trouble anyhow.

346474 21-Apr-2019 kevans

MFC i386 stand cleanup: r337353-r337354, r337356, r337872, r337878, r337881,
r337890-r337891, r338188

r337353:
loader: cstyle cleanup for biosdisk.c

Also switch u_int to uint32_t. Also replace "write" by "dowrite".
No functional changes intended.

r337354:
loader: 337353 did miss to rename 2 write instances

2 write instances got somehow missed.

r337356:
loader: bd_open() should cleanup from disk_open() error

Since bd_open() does early increment for reference counter and bcache
allocation, it also should undo those in case of the error.

Also remove unused variables rdev, g_err.

r337872:
libi386: remove BD_SUPPORT_FRAGS

BD_SUPPORT_FRAGS is preprocessor knob to allow partial reads in bioscd/biosdisk
level. However, we already have support for partial reads in bcache, and there
is no need to have duplication via preprocessor controls.

Note that bioscd/biosdisk interface is assumed to perform IO in 512B blocks,
so the only translation we have to do is 512 <-> native block size.

r337878:
libi386: remove bd_read() and bd_write() wrappers

Those wroappers are nice, but do not really add much value.

r337881:
libi386: use BD_RD and BR_WR constants

Use BD_RD and BD_WR instead of 0 and 1.

r337890:
libi386: small style updates in biosdisk

Use break instead of return in for loop, as done earlier. Insert and remove
some blank lines. No functional changes intended.

r337891:
libi386: bd_io_workaround() is to be called for reads only

bd_io() can perform either reads or writes, we only need bd_io_workaround()
for reads.

r338188:
loader: bios loader should allow to chain load a file

The current chain command does accept only device, allow also a file to be used,
such as /boot/pmbr or /boot/mbr (or stored third party MBR/VBR block).

Also fix file descriptor leak.

346473 21-Apr-2019 kevans

MFC r337271, r337317: stand: i386: sector calculation fixes

r337271:
Some drives report a geometry that is inconsisetent with the total
number of sectors reported through the BIOS. Cylinders * heads *
sectors may not necessarily be equal to the total number of sectors
reported through int13h function 48h.

An example of this is when a Mediasonic HD3-U2B PATA to USB enclosure
with a 80 GB disk is attached. Loader hangs at line 506 of
stand/i386/libi386/biosdisk.c while attempting to read sectors beyond
the end of the disk, sector 156906855. I discovered that the Mediasonic
enclosure was reporting the disk with 9767 cylinders, 255 heads, 63
sectors/track. That's 156906855 sectors. However camcontrol and
Windows 10 both report report the disk having 156301488 sectors, not
the calculated value. At line 280 biosdisk.c sets the sectors to the
higher of either bd->bd_sectors or the total calculated at line 276
(156906855) instead of the lower and correct value of 156301488 reported
by int 13h 48h.

This was tested on all three of my Mediasonic HD3-U2B PATA to USB
enclosures.

Instead of using the higher of bd_sectors (returned by int13h) or the
calculated value, this patch uses the lower and safer of the values.

r337317:
In r337271, we limited the sector number to the lower of calculated
number and CHS based number. However, on some systems, BIOS would
report 0 in CHS fields, making the system to think there is 0 sectors.

Add a check before comparing the calculated total with bd_sectors.

344413 21-Feb-2019 kevans

MFC Loader Interpreter Coexistance: r337806, r337868, r337914, r337927,
r337989, r338052, r338064, r338407, r338418, r338474

r337806:
Create a loader for each interpreter for x86 BIOS and all EFI

Create loader_{4th,lua,simp}{,.efi}. All of these are installed by
default. Create LOADER_DEFAULT_INTERP to specify the default
interpreter when no other is specified. LOADER_INTERP is the current
interpreter language building. Turn building of lua on by default to
match 4th. simploader is a simplified loader build w/o any interpreter
language (but with a simple loader). This is the historic behavir you
got with WITHOUT_FORTH. Make a hard link to the default loader. This
has to be a hard link rather than the more desirable soft link because
older zfsboot blocks don't support symlinks.

r337868:
stand: Use -Oz/-Os for all loader/stand builds.

While we're not super size constrained, the x86 BIOS /boot/loader has
to be less than about 520k-530k to be reliable. The LUA loader is at
this size today. -Oz saves 15-20% on the size, keeping us safely small
enough (comparable to where we were with the 4th loader). This will
also help with sjg's work on bringing in bearssl, though we may again
be looking for space in the LUA loader.

Size table for clang 6.0.0:
default -O1 -Os -Oz
4th 442368 417792 389120 376832
lua 524288 479232 446464 430080

r337914:
Install links for loader.efi.

r337927:
Add ashldi3 and ashrdi3 to mips.

Now that we're using -Os, mips needs these routines.

r337989:
Copy the boot loader from the new location for the co-existing
loaders.

r338052:
libsa: Add lshrdi3.c for powerpc* and mips

r338064:
Turn back the clock just a little: make userboot.so always be 4th

Turns out there was a hidden dependency we hasn't counted upon. The
host load /boot/userboot.so to boot the VMs it runs. This means that
the change to lua meant suddently that nobody could run their older
VMs because LUA wasn't in 10.0, last month's HardenedBSD, 11.2 or
whatever. Even more than for the /boot/loader* binaries, we need a
good coexistance strategy for this. While that's being designed and
implemented, drop back to always 4th for userboot.so. This will fail
safe in all but the most extreme environments (but lua-only hacks
to .lua files won't be processes in VMs until we fix it).

r338407:
lualoader: Print error messages from command failures at the prompt

Previously lualoader would remain silent, rather than printing
command_errmsg or noting that a command had failed or was not found.

r338418:
userboot: handle guest interpreter mismatches more intelligently

The switch to lualoader creates a problem with userboot: the host is
inclined to build userboot with Lua, but the host userboot's interpreter
must match what's available on the guest. For almost all FreeBSD guests in
the wild, Lua is not yet available and a Lua-based userboot will fail.

This revision updates userboot protocol to version 5, which adds a
swap_interpreter callback to request a different interpreter, and tries to
determine the proper interpreter to be used based on how the guest
/boot/loader is compiled. This is still a bit of a guess, but it's likely
the best possible guess we can make in order to get it right. The
interpreter is now embedded in the resulting executable, so we can open
/boot/loader on the guest and hunt that down to derive the interpreter it
was built with.

Using -l with bhyveload will not allow an intepreter swap, even if the
loader specified happens to be a userboot with the wrong interpreter. We'll
simply complain about the mismatch and bail out.

For legacy guests without the interpreter marker, we assume they're 4th.
For new guests with the interpreter marker, we'll read it and swap over
to the proper interpreter if it doesn't match what the userboot we're using
was compiled with.

Both flavors of userboot are installed by default, userboot_4th.so and
userboot_lua.so. This fixes the build WITHOUT_FORTH as a coincidence, which
was broken by userboot being forced to 4th.

r338474:
Be a little conservative about when to force size optimizations.

Reports have come in that there's issue with powerpc and sparc64 since
we've switched to using -Oz / -Os. We don't strictly need them for
!x86, so be conservative about when we enable them.

344399 21-Feb-2019 kevans

MFC GELI Loader Improvements: r336252, r336254, r336256, r336354,
r336532-r336534, r336537, r336626, r337326, r337349, r341071, r341160,
r341420, r341473, r341651, r342793

Note that this MFC contains some seemingly unrelated zfsloader bits -- this
was needed in order to pull in some later fixes for GELI hand-off w/ ZFS
bits included.

r336252:
Extend loader(8) geli support to all architectures and all disk-like devices.

This moves the bulk of the geli support from lib386/biosdisk.c into a new
geli/gelidev.c which implements a devsw-type device whose dv_strategy()
function handles geli decryption. Support for all arches comes from moving
the taste-and-attach code to the devopen() function in libsa.

After opening any DEVT_DISK device, devopen() calls the new function
geli_probe_and_attach(), which will "attach" the geli code to the open_file
struct by creating a geli_devdesc instance to replace the disk_devdesc
instance in the open_file. That routes all IO for the device through the
geli code.

A new public geli_add_key() function is added, to allow arch/vendor-specific
code to add keys obtained from custom hardware or other sources.

With these changes, geli support will be compiled into all variations of
loader(8) on all arches because the default is WITH_LOADER_GELI.

r336254:
Use if rather than case for a simple boolean. gcc thinks blks is
undefined sometimes with the case, but enc is always 0 or 1, so
and if / else is better anyway.

r336256:
Fix glitched indentation (and rewrap as needed due to deeper indent).
No functional changes.

r336354:
zfsboot: fix build with WITHOUT_LOADER_GELI

r336532:
Collapse zfsloader functionality back down into loader.

We no longer really need a separate zfsloader. It was useful when we
were first supporting ZFS and had limited ability to properly boot off
of ZFS without the special boot loader. Now that the boot loader has
matured, go the way loader.efi pioneered and just build one
binary. Change the name of the loader to load in the secondary boot
blocks to be just /boot/loader. Provide a symbolic link from zfsloader
to loader so people who have not upgraded their boot blocks are not
affected. This has the happy benefit of making coexistence easier as
well (fewer binaries in the matrix).

r336533:
Eliminate zfsloader man page.

Remove all cross references to zfsloader.8 and /boot/zfsloader.
Move ZFS specific info into loader.8.

r336534:
NM and OBJCOPY are already defined for all builds. There's no need to
conditionally define them here.

r336537:
Mention zfsloader being folded into loader in UPDATING.

r336626:
Older zfs boot blocks don't support symlinks. install the link to
zfsloader as a hard link. While newer ones do, the whole point of the
link was to transition to the new world order smoothly. A hard link is
less flexible, but it works and will result in fewer bumps. Adjust
UPDATING entry to match.

r337326:
loader: biosdisk.c has leftover geli header.

A small cleanup, remove unneeded #include.

r337349:
zfsboot: Fix startup crash

On a FreeNAS mini XL, with geli encrypted drives the loader crashed in
geli_read().

When we iterate over the list of disks and allocate the zfsdsk structures we
don’t zero out the gdev pointer. In one case that resulted in geli_read()
(called on the bogus pointer) dividing by zero.

Use calloc() to ensure the zfsdsk structure is always zeroed, so the pointer is
initialised to NULL. As a side benefit it gets rid of one #ifdef
LOADER_GELI_SUPPORT.

r341071:
Restore the ability to override the disk unit/partition at the boot: prompt
in gptboot.

When arch-independent geli support was added, a new static 'gdsk' struct
was added, but there was still a static 'dsk' struct, and when you typed
in an alternate disk/partition, the string was parsed into that struct,
which was then never used for anything. Now the string gets parsed into
gdsk.dsk, the struct that's actually used.

r341160:
Add comments describing the bootargs handoff between loader(8) and gptboot
or zfsboot, when loader(8) is the BTX loader. No functional changes.

r341420:
Eliminate duplicated code and struct member definitions in the handoff
of args data between gptboot/zfsboot and loader(8).

Despite what seems like a lot of changes here, there are no actual
changes in behavior, or in the data layout in the structures involved.
This is just eliminating identical code pasted into multiple locations.

In detail, the changes are...

- Move struct zfs_boot_args definition from libsa/zfs/libzfs.h to
i386/common/bootargs.h because it is specific to x86 booting and the
handoff between zfsboot and loader, and has no relation to the zfs
library code in general.

- The geli_boot_args and zfs_boot_args structs both contain an identical
set of member variables containing geli information. Extract this out
to a new geli_boot_data struct, and embed it in the arg-passing structs.

- Provide new routines geli_import_boot_data() and geli_export_boot_data()
that can be shared between gptboot, zfsboot, and loader instead of
pasting identical code into several different .c files.

- Remove some checks for a NULL pointer that can never be true because the
pointer being tested was set using pointer math (kargs + 1) and that can
never result in NULL in this code.

r341473:
Fix args cross-threading between gptboot(8) and loader(8) with zfs support.

When loader(8) is built with zfs support enabled, it assumes that any extarg
data present is a zfs_boot_args struct, but if the first-stage loader was
gptboot(8) the extarg data is actually a geli_boot_args struct. Luckily,
zfsboot(8) and gptzfsboot(8) have always passed KARGS_FLAGS_ZFS along with
KARGS_FLAGS_EXTARG, so we can use KARGS_FLAGS_ZFS to decide whether the
extarg data is a zfs_boot_args struct.

To avoid similar problems in the future, gptboot(8) now passes a new
KARGS_FLAGS_GELI to indicate that extarg data is geli_boot_args. In
loader(8), if the neither KARGS_FLAGS_ZFS nor KARGS_FLAGS_GELI is set but
extarg data is present (which will be the case for gptboot compiled before
this change), we now check for the known size of the geli_boot_args struct
passed by the older versions of gptboot as a way of confirming what type of
extarg data is present.

In a semi-related tidying up, since loader's main() has already decided
what type of extarg data is present and set the global 'zargs' var
accordingly, don't repeat the check in extract_currdev, just check whether
zargs is NULL or not.

r341651:
Don't reference zfs-specific variables if LOADER_ZFS_SUPPORT is undefined
because the variables will be undefined too.

r342793:
MK_ZFS -> {MK_ZFS|MK_LOADER_ZFS}, this is so we can diable userland / kernel
ZFS but keep the boot-loaders when using ZoL port.

Relnotes: yes (GELI support extended)
Relnotes: yes (zfsloader has been collapsed into loader and may be
removed after boot blocks have been updated)


/freebsd-11-stable/.gitattributes
/freebsd-11-stable/UPDATING
/freebsd-11-stable/share/mk/src.opts.mk
/freebsd-11-stable/stand/common/devopen.c
/freebsd-11-stable/stand/common/metadata.c
/freebsd-11-stable/stand/common/paths.h
/freebsd-11-stable/stand/defs.mk
/freebsd-11-stable/stand/efi/boot1/Makefile
/freebsd-11-stable/stand/efi/libefi/Makefile
/freebsd-11-stable/stand/efi/loader/Makefile
/freebsd-11-stable/stand/efi/loader/bootinfo.c
Makefile
boot2/Makefile
common/bootargs.h
gptboot/Makefile
gptboot/gptboot.c
gptzfsboot/Makefile
gptzfsboot/gptzfsboot.8
isoboot/Makefile
libi386/Makefile
libi386/biosdisk.c
libi386/bootinfo32.c
libi386/bootinfo64.c
loader/Makefile
loader/main.c
zfsboot/Makefile
zfsboot/zfsboot.8
zfsboot/zfsboot.c
zfsloader/Makefile
/freebsd-11-stable/stand/libsa/Makefile
/freebsd-11-stable/stand/libsa/geli/Makefile.inc
/freebsd-11-stable/stand/libsa/geli/geli_metadata.c
/freebsd-11-stable/stand/libsa/geli/geliboot.c
/freebsd-11-stable/stand/libsa/geli/geliboot.h
/freebsd-11-stable/stand/libsa/geli/geliboot_crypto.c
/freebsd-11-stable/stand/libsa/geli/geliboot_internal.h
/freebsd-11-stable/stand/libsa/geli/gelidev.c
/freebsd-11-stable/stand/libsa/zfs/libzfs.h
/freebsd-11-stable/stand/loader.mk
/freebsd-11-stable/stand/lua/core.lua.8
/freebsd-11-stable/stand/man/Makefile
/freebsd-11-stable/stand/man/loader.8
/freebsd-11-stable/stand/man/zfsloader.8
/freebsd-11-stable/stand/sparc64/Makefile
/freebsd-11-stable/stand/sparc64/loader/Makefile
/freebsd-11-stable/stand/sparc64/zfsloader/Makefile
/freebsd-11-stable/stand/userboot/userboot/Makefile
/freebsd-11-stable/stand/userboot/userboot/bootinfo32.c
/freebsd-11-stable/tools/build/options/WITHOUT_LOADER_ZFS
/freebsd-11-stable/tools/build/options/WITHOUT_ZFS
344379 20-Feb-2019 kevans

MFC r306681, r336249-r336250, r336261: remove inflate conflict

r306681:
ANSIfy inflate.c

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D8143

r336249:
Fix sparc64 builds

gcc is complaining about struct infate being defined in a parameter
list. It's inclear how long this has been broken, but the fix is
simple enough.

r336250:
There's two files in the sys tree named inflate.c, in addition
to it being a common name elsewhere. Rename the old kzip one
to subr_inflate.c.

This actually fixes the build issues on sparc64 that my inclusion of
.PATH ${SYSDIR}/kern created in r336244, so also revert the broken
workaround I committed in r336249.

This slipped passed me because apparently, I never did a clean build.

r336261:
Catch up to the inflate renaming.

344378 20-Feb-2019 kevans

MFC r336244, r336246-r336247: Standardize boot arg parsing

r336244:
Create helper functions for parsing boot args.

boot_parse_arg to parse a single arg
boot_parse_cmdline to parse a command line string
boot_parse_args to parse all the args in a vector
boot_howto_to_env Convert howto bits to env vars
boot_env_to_howto Return howto mask mased on what's set in the environment.

All these routines return an int that's the bitmask of the args
translated to RB_* flags. As a special case, the 'S' flag sets the
comconsole_speed env var. Any arg that looks like a=b will set the env
key 'a' to value 'b'. If =b is omitted, 'a' is set to '1'. This
should help us reduce the number of redundant copies of these routines
in the tree. It should also give a more uniform experience between
platforms.

Also, invent a new flag RB_PROBE that's set when 'P' is parsed. On
x86 + BIOS, this means 'probe for the keyboard, and if it's not there
set both RB_MULTIPLE and RB_SERIAL (which means show the output on
both video and serial consoles, but make serial primary). Others it
may be some similar concept of probing, but it's loader dependent
what, exactly, it means.

These routines are suitable for /boot/loader and/or the kernel,
though they may not be suitable for the tightly hand-rolled-for-space
environments like boot2.

r336246:
Eliminate boot loader copies of boot arg parsing.

Eliminate 4 of the copies of the arg parsing in /boot/laoder
by using boot_parse_cmdline.

r336247:
Transition to boot_env_to_howto and boot_howto_to_env in the boot
loader.

344377 20-Feb-2019 kevans

MFC r336084-r336085, r336118: Move zfs impl into libsa

r336084:
Move ZFS files into libsa

Move the libzfs stuff into libsa. There's no need for it to be a
separate library. The separate library adds to the issues of build
ordering that we see from time to time. Move the filesystem support
into libsa, like all the other filesystem support rather than making
zfs the odd-duck out.

Discussed with: allanjude@

r336085:
Stop using ../zfs/libzfs.h but instead use libzfs.h.

While ../zfs/libzfs.h mostly works, there are a few situations where
it does not. Eliminate the problem by using plain libzfs.h, like we do
for ufs support. This fixes the weird cases, and is easier to
understand. It also follows the general style convetion of avoiding
../ in #includes.

r336118:
Remove dirs that git svn should have removed but didn't.

344373 20-Feb-2019 kevans

MFC r335321, r335336: stand: move libgeliboot into libsa

r335321:
stand: move libgeliboot into libsa.

Reduce by 1 the number of crazy libraries we need in stand by moving
geli into libsa (where architecturally it belonged all along). This
just moves things around without any code changes.

r335336:
Remove now-empty geli directory

344295 19-Feb-2019 kevans

MFC r335245-r335248, r335254, r335276, r335298, r335398, r335868, r335883

r335245:
Correct logic error in biosdisk.c:bd_realstrategy()

The wrong condition is used when evaluating the return of disk_ioctl()
This results in reaching the 'We should not get here' branch in most casts

r335246:
biosdisk.c remove redundant variable

`rdev` and `disk` serve the same purpose, read the partition table without
the `d_offset` or `d_slice` set, so the read is relative to the start of
the disk. Reuse the already initialized `disk` instead of making another
copy later.

r335247:
biosdisk.c: add missing \n to error message

r335248:
biosdisk.c: fix type in debug printf

r335254:
Avoid reading past the end of the disk in zfsboot.c and biosdisk.c

The GELI boot code rounds reads up to 4k, since the encrypted sectors are
4k, and must be decrypted as a unit. With oddball sized disks (almost
always virtual), this can lead to reading past the end of the disk.

r335276:
gptboot, zfsboot, gptzfsboot: Enable the video and serial consoles early

Normally the serial console is not enabled until /boot.config is read and
we know how the serial console should be configured. Initialize the
consoles early in 'dual' mode (serial & keyboard) with a default serial
rate of 115200. Then serial is re-initialized once the disk is decrypted
and the /boot.config file can be read.

This allows the GELIBoot passphrase to be provided via the serial console.

r335298:
stand/common/disk.c: Update debug printf

This was missed in r330809 because it is compiled out by default

r335398:
Revert r335276

This was causing issues for people booting.
I will likely bring this back as an optional feature, similar to
boot0sio, like gptboot-serial or something.

r335868:
stand/common/disk.c: Read partition table relative to the start of the disk

If a disk is of an oddball size, like the 200mb + 512b used in rootgen.sh,
when disk_open() is called on a GELI encrypted partition, attempts to read
the partition table fail, as they pass through the decryption process which
turns the already plaintext data into jibberish.

When reading the partition table, always pass a slice and partition setting
of -1, and an offset of 0. Setting the slice to -1 prevents a false
positive when checking the slice against the cache of GELI encrypted
slices.

r335883:
stand/common/disk.c: dev->d_offset still needs to be set to 0

With r335868, I thought this was no longer necessary. I was wrong.

344290 19-Feb-2019 kevans

MFC r335117: stand bootprog_info consolidation

bootprog_info is generated in vers.c. Move it's definition to
bootstrap.h and remove all the redundant copies.

338078 20-Aug-2018 kevans

MFC r337524: libi386: Fix typo in pxe.h

PR: 207337

337816 14-Aug-2018 kevans

MFC r337520: Fix WITHOUT_LOADER_GELI (gptboot) and isoboot in general

gptboot was broken when r316078 added the LOADER_GELI_SUPPORT #ifdef to
not pass geliargs via __exec. KARGS_FLAGS_EXTARG must not be used if we're
not going to pass an additional argument to __exec.

PR: 228151

335755 28-Jun-2018 kevans

MFC r334882, r334884-r334885: loader(8) boot flag <-> environment fixes

r334882:
stand: Consolidate checking for boot flags driven by environment vars

e.g. boot_mute, boot_single, boot_verbose, and friends; we checked for these
in multiple places, consolidate into common/ and allow a setting of "NO" for
any of these to turn them off. This allows systems with multiple
loader.conf(5) or loader.conf(5) overlay systems to easily turn off
variables in later processed files by setting it to NO.

Reported by: Nick Wolff @ iXsystems
Reviewed by: imp

r334884:
stand: Fix build after r334882

Not sure how this was not caught in Universe.

r334885:
stand: One more trivial consolidation (setting environment from howto)

334935 10-Jun-2018 ian

MFC r334656, r334665, r334695

r334656:
Add vsnprintf() to libsa. Alpha-sort the printf prototypes in stand.h.

r334665:
Make the v*printf() functions in libsa return int instead of void.
This makes them compatible with the C standard signatures, avoiding
spurious mismatch errors in the places where the oddball requirements
of standalone code end up putting two declarations of the same function
in play.

r334695:
Remove comments and assertions that are no longer valid after r330809.

r330809 replaced duplication of devdesc struct fields with an embedded copy
of the devdesc struct, to avoid fragility. That means all the scattered
comments indicating that structs must match are no longer valid. Likewise
asserts that attempted to mitigate some of the old fragility.

Reviewed by: imp@

334572 03-Jun-2018 dim

MFC r334432:

Fix build of stand with base gcc

* Make autoboot() a static function in stand/common/boot.c, so it does
not shadow local variables in gptboot.c and zfsboot.c.
* Remove -Winline from the Makefiles for gptboot, gptzfsboot and
zfsboot, as gcc will always fail to inline some functions, and there
is nothing we can do about it.
* For gcc <= 4.2.1, silence -Wuninitialized for isoboot, as it produces
a false positive warning.
* Remove deprecated and unnecessary -mcpu=i386 flag from stand/defs.mk,
as there is already a -march=i386 flag further in the file.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D15628

333048 27-Apr-2018 emaste

MFC r332090: stand: pass --no-rosegment for i386 bits when linking with lld

btxld does not correctly handle input with other than 2 PT_LOAD
segments. Passing --no-rosegment lets lld produce output eqivalent to
ld.bfd: 2 PT_LOAD segments and no PT_GNU_RELRO.

PR: 225775
Sponsored by: The FreeBSD Foundation

332955 24-Apr-2018 benno

MFC r332084

Add isoboot(8) for booting BIOS systems from HDDs containing ISO images.

This is part of a project for adding the ability to create hybrid CD/USB boot
images. In the BIOS case when booting from something that isn't a CD we need
some extra boot code to actually find our next stage (loader) within an
ISO9660 filesystem. This code will reside in a GPT partition (similar to
gptboot(8) from which it is derived) and looks for /boot/loader in an
ISO9660 filesystem on the image.

Sponsored by: iXsystems, Inc.

332954 24-Apr-2018 benno

MFC r332083:

Various style(9) fixes.

Sponsored by: iXsystems, Inc.

332953 24-Apr-2018 benno

MFC r332082

Use consistent whitespace.

Sponsored by: iXsystems, Inc.

332156 06-Apr-2018 kevans

MFC r330970, r331067, r331767, r331852, r331858

r330970:
libefi: UEFI_BOOT_VAR_GUID duplicates EFI_GLOBAL_VARIABLE

Drop UEFI_BOOT_VAR_GUID and use EFI_GLOBAL_VARIABLE.

r331067:
Only print boot order / boot current if we can get the variables from
the loader. Some UEFI implementations don't return all of them.

Sponsored by: Netflix

r331767:
efinet: Do not return only if ReceiveFilter fails

If the network interface or the uefi implementation do not support the
ReceiveFilter interface do not return only and just print a message.
U-Boot doesn't support is and likely never will. Also even if this fails
it doesn't mean that network in EFI isn't supported.

r331852:
fwohcireg.h is 99% the same between the boot loader and the
kernel. Delete it and fix up the 1% difference because there's no need
for them to be different.

r331858:
The Uninorth ID was really for Uninorth 2.

332154 06-Apr-2018 kevans

MFC r330806-r330815, r330837, r330864, r330883

pc98 changes associated with the named commits are also included in this
commit, despite not having been made with the original commits due to its
removal in head.

r330806:
Minor cosmetic changes.

Make sure { on the same line as struct for all struct *devdesc. Move
some type definitions to next to the dv_type define, since that's what
sets the d_type.

r330807:
We can't use d_opendata for blkio storage.

open_disk uses d_opendata for it's own purpse. We can't store blkio
there. Fortunately, blkio is stored elsewhere and we never actually
retrieve blkio from d_opendata. Eliminate it as a source of confusion.
Eliminate all stores of d_opendata in efi since this layer doesn't own
that field.

r330808:
Make struct libi386_devdesc match the struct devdesc better

Move data to top and call it d_opendata.

r330809:
Use the actual struct devdesc at the start of all *_devdesc structs

The current system is fragile and requires very careful layout of all
*_devdesc structures. It also makes it hard to change the base
devdesc. Take a page from CAM and put the 'header' in all the derived
classes and adjust the code to match.

For OFW, move the iHandle h_handle out of a slot conflicting with
d_opendata. Due to quirks in the alignment rules, this worked.
However changing the code to use d_opendata storage now that it's a
pointer is hard, so just have a separate field for it.

All other cleanups were to make the *_devdesc structures match where
they'd taken some liberties that were none-the-less compatible enough
to work.

r330810:
Remove d_type from devdesc. It's not needed as we can fetch it from
d_dev->dv_type when we need it.

r330811:
GC unused routines.

Sponsored by: Netflix

r330812:
Use the one-line-per-file pattern here, and sort the file names.

Sponsored by: Netflix

r330813:
Move the env convenience routines out of boot1.c.

These routines are more generally useful. Even though boot1 is on its
way out, it's better to make these common during the transition than
copy them.

r330814:
Star BootCurrent entry when booting.

Sponsored by: Netflix

r330815:
Print the load and device path as well as BootCurrent and BootOrder

Sponsored by: Netflix

r330837:
biosdisk.c should not set d_opendata.

Same as 330807, d_opendata is owned by open_disk and we should not
set it.

M stand/i386/libi386/biosdisk.c

r330864:
Prefer uintXX_t to u_intXX_t

A foolish consistency is the hobgoblin of little minds, adored by
little statesmen and philosophers and divines. With consistency a
great soul has simply nothing to do. -- Ralph Waldo Emerson

r330883:
Fix typo that misteriously passes compilation.


/freebsd-11-stable/stand/common/bootstrap.h
/freebsd-11-stable/stand/common/disk.c
/freebsd-11-stable/stand/common/disk.h
/freebsd-11-stable/stand/common/isapnp.c
/freebsd-11-stable/stand/common/load_elf.c
/freebsd-11-stable/stand/common/load_elf_obj.c
/freebsd-11-stable/stand/common/metadata.c
/freebsd-11-stable/stand/common/misc.c
/freebsd-11-stable/stand/common/pnp.c
/freebsd-11-stable/stand/efi/boot1/boot1.c
/freebsd-11-stable/stand/efi/boot1/ufs_module.c
/freebsd-11-stable/stand/efi/include/efilib.h
/freebsd-11-stable/stand/efi/libefi/Makefile
/freebsd-11-stable/stand/efi/libefi/devicename.c
/freebsd-11-stable/stand/efi/libefi/efienv.c
/freebsd-11-stable/stand/efi/libefi/efipart.c
/freebsd-11-stable/stand/efi/libefi/efizfs.c
/freebsd-11-stable/stand/efi/libefi/env.c
/freebsd-11-stable/stand/efi/loader/arch/arm/exec.c
/freebsd-11-stable/stand/efi/loader/main.c
/freebsd-11-stable/stand/ficl/aarch64/sysdep.c
/freebsd-11-stable/stand/ficl/amd64/sysdep.c
/freebsd-11-stable/stand/ficl/arm/sysdep.c
/freebsd-11-stable/stand/ficl/i386/sysdep.c
/freebsd-11-stable/stand/ficl/mips/sysdep.c
/freebsd-11-stable/stand/ficl/mips64/sysdep.c
/freebsd-11-stable/stand/ficl/powerpc/sysdep.c
/freebsd-11-stable/stand/ficl/riscv/sysdep.c
/freebsd-11-stable/stand/ficl/sparc64/sysdep.c
btx/lib/btxv86.h
libi386/biosacpi.c
libi386/bioscd.c
libi386/biosdisk.c
libi386/biospnp.c
libi386/bootinfo32.c
libi386/bootinfo64.c
libi386/devicename.c
libi386/elf64_freebsd.c
libi386/libi386.h
libi386/multiboot.c
libi386/pxe.c
loader/chain.c
loader/main.c
/freebsd-11-stable/stand/libsa/arp.c
/freebsd-11-stable/stand/libsa/bootp.c
/freebsd-11-stable/stand/libsa/bootparam.c
/freebsd-11-stable/stand/libsa/dosfs.h
/freebsd-11-stable/stand/libsa/ext2fs.c
/freebsd-11-stable/stand/libsa/net.h
/freebsd-11-stable/stand/libsa/rpc.c
/freebsd-11-stable/stand/libsa/stand.h
/freebsd-11-stable/stand/mips/beri/loader/beri_disk_cfi.c
/freebsd-11-stable/stand/mips/beri/loader/beri_disk_sdcard.c
/freebsd-11-stable/stand/mips/beri/loader/devicename.c
/freebsd-11-stable/stand/ofw/libofw/devicename.c
/freebsd-11-stable/stand/ofw/libofw/libofw.h
/freebsd-11-stable/stand/ofw/libofw/openfirm.c
/freebsd-11-stable/stand/pc98/libpc98/bioscd.c
/freebsd-11-stable/stand/pc98/libpc98/biosdisk.c
/freebsd-11-stable/stand/pc98/loader/main.c
/freebsd-11-stable/stand/powerpc/boot1.chrp/boot1.c
/freebsd-11-stable/stand/powerpc/kboot/ppc64_elf_freebsd.c
/freebsd-11-stable/stand/powerpc/ofw/elf_freebsd.c
/freebsd-11-stable/stand/powerpc/ofw/main.c
/freebsd-11-stable/stand/powerpc/ofw/ppc64_elf_freebsd.c
/freebsd-11-stable/stand/sparc64/boot1/boot1.c
/freebsd-11-stable/stand/sparc64/loader/main.c
/freebsd-11-stable/stand/uboot/common/main.c
/freebsd-11-stable/stand/uboot/lib/devicename.c
/freebsd-11-stable/stand/uboot/lib/disk.c
/freebsd-11-stable/stand/uboot/lib/elf_freebsd.c
/freebsd-11-stable/stand/uboot/lib/libuboot.h
/freebsd-11-stable/stand/userboot/userboot/bootinfo32.c
/freebsd-11-stable/stand/userboot/userboot/bootinfo64.c
/freebsd-11-stable/stand/userboot/userboot/devicename.c
/freebsd-11-stable/stand/userboot/userboot/elf64_freebsd.c
/freebsd-11-stable/stand/userboot/userboot/main.c
/freebsd-11-stable/stand/userboot/userboot/userboot_disk.c
/freebsd-11-stable/stand/zfs/libzfs.h
/freebsd-11-stable/stand/zfs/zfs.c
332148 06-Apr-2018 kevans

MFC r330249-r330250

r330249:
stand: Makefile SUBDIR cleanup

Use SUBDIR.${MK_*} where appropriate. r330248 eliminated most of the
offenders, sweep the rest under the rug.

Differential Revision: https://reviews.freebsd.org/D14545

r330250:
stand: Fix build after r330249

One does not simply convert to SUBDIR.yes in stand without making everything
else in the affected files SUBDIR.yes -- there are better ways to do this.

332130 06-Apr-2018 kevans

MFC r329726, r329737, r329740

r329726:
Honor settings for including / excluding cd9660, ufs, ext2fs and msdos.

The Makefile gives the impression that ext2fs and msdos were excluded
(they weren't) and that you could exclude cd9660 and ufs support (you
couldn't). Allow those to be excluded.

We need to look, in the future, at trimming the number of supported
filesystems, and this will make that easier.

r329737:
Purely whitespace changes bringing this file closer to style(9).

Curiously, changing whitespace seems to cause the md5 of the .o files to differ
these days hence the following testing strategy:

Tested by: objdump -d | md5 (both in-tree clang and lang/gcc6)

r329740:
Further style(9) changes.

Tested by: objdump -d | md5 (both in-tree clang and lang/gcc6)

332128 06-Apr-2018 kevans

MFC r329725, r329831

r329725:
Consolidate three copies of ZFS commands into a central location.

There's no reason to have multiple copies of lszfs and
reloadbe. Consolidate them into one location. Also ldi_get_size is the
same everywhere (except sparc64). Make it the same everywhere as the
common definition is more general and will work on spar64.

r329831:
Fix userboot w/ ZFS after r329725

r329725 cleaned up ZFS commands duplicated in multiple places, but userboot
was not setting HAVE_ZFS when MK_ZFS != "no". This resulted in a failure to
boot (as seen in PR 226118) in bhyve, with the following message:

/boot/userboot.so: Undefined symbol "ldi_get_size"

332056 05-Apr-2018 kevans

MFC r331718: stand: Add workaround for HP BIOS issues

hrs@ and kuriyama@ have found that on some HP BIOS, a system will fail to
boot immediately after installation with the claim that it can't work out
which disk they are booting from.

They tracked it down to a buffer overrun, and found that it could be
alleviated by doing a dummy read before-hand.

331927 03-Apr-2018 eugen

MFC r331630: Fix instructions in the zfsboot manual page.

zfsloader(8) fails to probe a slice containing ZFS pool if its second sector
contains traces of BSD label (DISKMAGIC == 0x82564557).
Fix manual page to show working example erasing such traces.

PR: 226714
Approved by: avg (mentor)

_M .
M stand/i386/zfsboot/zfsboot.8

331615 27-Mar-2018 kevans

MFC r331475: loader consoles: Implement SGR 24, 25

Mostly for completeness sake- implement 24 (no underline) and 25 (no blink)

331539 26-Mar-2018 kevans

MFC r331416, r331440: Loader consoles: Implement SGR 22, reste intensity

r331416:
Loader consoles: Implement SGR 22, reset intensity

r331440:
Match broken style of vidconsole.c

This particular function uses a broken mix of indentation styles. Match it
for the newly added SGR 22 bits.

330123 28-Feb-2018 kevans

MFC r330004: Add NO_OBJ to those directories that don't make anything.

For directories that don't many anything, add NO_OBJ=t just before we
include bsd.init.mk. This prevents them from creating an OBJ
directory. In addition, prevent defs.mk from creating the machine
related links in these cases. They aren't needed and break, at least
on stable, the read-only src tree build.

PR: 226074

329192 13-Feb-2018 kevans

stand: Clean up some unintentional inconsistencies

This is a direct commit to stable/11 to address the following final
unintended inconsistencies between stable/11 and head:

- Some unused LIBSTAND= cruft left in efi/loader/Makefie
- A comment that flew in with unrelated changes
- An #include that may go away now that stand is basically self-contained

329183 12-Feb-2018 kevans

MFC Loader Fixes Final: r327612,r327703,r327704,r327878,r327879,r327881,
r328007,r328029,r328030,r328031,r328061,r328156,r328169,r328288,r328289,
r328290,r328291,r328292,r328411,r328536,r328603,r328614,r328642,r328769,
r328779,r328780,r328781,r328782,r328783,r328806,r328808,r328826,r328835,
r328911,r328986,r328987,r328990,r328999,r329000,r329019,r329050,r329054,
r329060

r327612: Invent new #defines for the biospci_{read,write}_config function

r327703: Define __dmadat after #include'ing ufsread.c.

r327704: Fix printf missing format variables warnings.

r327878: Add GUID for UEFI boot manager variables.

r327879: Report the boot order and where we are in that boot order.

r327881: Allow this file to be included

r328007: Fix booting on some arm64 systems after r327879 by fixing the call
to utf8_to_ucs2

r328029: When returning an error and freeing allocated memory from
ucs2_to_utf8, NULL the return pointer.

r328030: Check the return value from utf8_to_ucs2 instead of whether or not
uv is NULL.

r328031: Need to free uv after we're done using it.

r328061: utf8_to_ucs2() should check for malloc failure

r328156: stand: Move sections around to fix stand/ build with ld.lld on
armv7

r328169: Remove extra copy of bootinfo.c. It's a bit rotted copy of the one
in efi/loader.

r328288: Fix some resource leaks.

r328289: Don't leak memory when displaying help.

r328290: On malloc failure, be sure to close the include file that triggered
it.

r328291: getenv does not return tainted data in the boot loader. Attempt to
clue Coverity into that fact.

r328292: There's no tainted data here, tag it as such to avoid false
positives.

r328411: loader.efi: add missing EFI GUIDs

r328536: loader: support for mixed-endianness ELF/loader and POWER8

r328603: Add missing non-POWERPC case to give the scr value something
non-zero.

r328614: Move libstand.3 to libsa.3. Update libsa.3 to include functions

r328642: Break out the interpreters (simple and forth) w/o ifdefs.

r328769: Centralize several variables.

r328779: Retire pnp.4th and the code needed only for 4th words used here.

r328780: These 4th words were an attempt to allow integration into the boot
loader scripts. However, that path won't be taken after all it
seems.

r328781: Remove pcibios forth support.

r328782: Now that we no longer conditionally compile some files outside of
ficl

r328783: Invent new LDR_INTERP for the loader interpreter to use.

r328806: We need more heap space to properly load newer powerpc kernels.

r328808: Implement strcoll as strcmp.

r328826: Make cross-endian loader changes apply only to powerpc

r328835: Fix regression introduced in r328806, preventing boot on many
platforms.

r328911: Ignore relocation tables for non-memory-resident sections.

r328986: Fix relative location of USB sources after recent move.

r328987: A more definitions to kernel emulation shim in order to build
stand/usb.

r328990: Move the stand/usb test loader into its own directory.

r328999: Fix indentation to FreeBSD standard for interp files

r329000: Move simple interpreter 'perform' into interp.c and call it

r329019: Move to tabs for indentation and to 8-space notches, per style(9).

r329050: Fix build of userboot.so

r329054: Set script.lang in the environment to either 'forth' or 'simple' to
reflect what scripting language was compiled into the loader.

r329060: loader: fix endianness conversion

PR: 225323


/freebsd-11-stable/ObsoleteFiles.inc
/freebsd-11-stable/stand/arm/uboot/Makefile
/freebsd-11-stable/stand/arm/uboot/ldscript.arm
/freebsd-11-stable/stand/common/boot.c
/freebsd-11-stable/stand/common/bootstrap.h
/freebsd-11-stable/stand/common/commands.c
/freebsd-11-stable/stand/common/install.c
/freebsd-11-stable/stand/common/interp.c
/freebsd-11-stable/stand/common/interp_backslash.c
/freebsd-11-stable/stand/common/interp_forth.c
/freebsd-11-stable/stand/common/interp_parse.c
/freebsd-11-stable/stand/common/interp_simple.c
/freebsd-11-stable/stand/common/load_elf.c
/freebsd-11-stable/stand/common/load_elf_obj.c
/freebsd-11-stable/stand/common/misc.c
/freebsd-11-stable/stand/common/pnp.c
/freebsd-11-stable/stand/defs.mk
/freebsd-11-stable/stand/efi/boot1/Makefile
/freebsd-11-stable/stand/efi/boot1/boot1.c
/freebsd-11-stable/stand/efi/fdt/Makefile
/freebsd-11-stable/stand/efi/include/efi.h
/freebsd-11-stable/stand/efi/include/efiapi.h
/freebsd-11-stable/stand/efi/libefi/Makefile
/freebsd-11-stable/stand/efi/libefi/efichar.c
/freebsd-11-stable/stand/efi/libefi/env.c
/freebsd-11-stable/stand/efi/loader/Makefile
/freebsd-11-stable/stand/efi/loader/arch/arm/ldscript.arm
/freebsd-11-stable/stand/efi/loader/arch/i386/bootinfo.c
/freebsd-11-stable/stand/efi/loader/main.c
/freebsd-11-stable/stand/fdt/Makefile
/freebsd-11-stable/stand/ficl.mk
/freebsd-11-stable/stand/ficl/Makefile
/freebsd-11-stable/stand/forth/Makefile
/freebsd-11-stable/stand/forth/loader.4th
/freebsd-11-stable/stand/forth/pcibios.4th
/freebsd-11-stable/stand/forth/pnp.4th
/freebsd-11-stable/stand/geli/Makefile
boot0/Makefile
btx/btx/Makefile
btx/btxldr/Makefile
btx/lib/Makefile
cdboot/Makefile
kgzldr/Makefile
libfirewire/Makefile
libfirewire/firewire.c
libi386/Makefile
libi386/biospci.c
libi386/comconsole.c
libi386/libi386.h
loader/Makefile
mbr/Makefile
pmbr/Makefile
/freebsd-11-stable/stand/kshim/bsd_kernel.h
/freebsd-11-stable/stand/libsa/Makefile
/freebsd-11-stable/stand/libsa/environment.c
/freebsd-11-stable/stand/libsa/libsa.3
/freebsd-11-stable/stand/libsa/libstand.3
/freebsd-11-stable/stand/libsa/stand.h
/freebsd-11-stable/stand/loader.mk
/freebsd-11-stable/stand/mips/beri/boot2/Makefile
/freebsd-11-stable/stand/mips/beri/boot2/boot2.c
/freebsd-11-stable/stand/mips/beri/loader/Makefile
/freebsd-11-stable/stand/mips/beri/loader/exec.c
/freebsd-11-stable/stand/mips/uboot/Makefile
/freebsd-11-stable/stand/ofw/common/main.c
/freebsd-11-stable/stand/ofw/libofw/Makefile
/freebsd-11-stable/stand/ofw/libofw/elf_freebsd.c
/freebsd-11-stable/stand/ofw/libofw/libofw.h
/freebsd-11-stable/stand/ofw/libofw/ofw_copy.c
/freebsd-11-stable/stand/ofw/libofw/ofw_memory.c
/freebsd-11-stable/stand/ofw/libofw/ppc64_elf_freebsd.c
/freebsd-11-stable/stand/powerpc/boot1.chrp/Makefile
/freebsd-11-stable/stand/powerpc/kboot/Makefile
/freebsd-11-stable/stand/powerpc/kboot/conf.c
/freebsd-11-stable/stand/powerpc/kboot/host_syscall.S
/freebsd-11-stable/stand/powerpc/kboot/host_syscall.h
/freebsd-11-stable/stand/powerpc/kboot/hostdisk.c
/freebsd-11-stable/stand/powerpc/kboot/kerneltramp.S
/freebsd-11-stable/stand/powerpc/kboot/main.c
/freebsd-11-stable/stand/powerpc/kboot/metadata.c
/freebsd-11-stable/stand/powerpc/kboot/ppc64_elf_freebsd.c
/freebsd-11-stable/stand/powerpc/ofw/Makefile
/freebsd-11-stable/stand/powerpc/ofw/ldscript.powerpc
/freebsd-11-stable/stand/powerpc/uboot/Makefile
/freebsd-11-stable/stand/sparc64/boot1/Makefile
/freebsd-11-stable/stand/sparc64/loader/Makefile
/freebsd-11-stable/stand/uboot/fdt/Makefile
/freebsd-11-stable/stand/uboot/lib/Makefile
/freebsd-11-stable/stand/usb/Makefile.test
/freebsd-11-stable/stand/usb/bsd_usbloader_test.c
/freebsd-11-stable/stand/usb/test
/freebsd-11-stable/stand/usb/usbcore.mk
/freebsd-11-stable/stand/userboot/test/Makefile
/freebsd-11-stable/stand/userboot/userboot/Makefile
/freebsd-11-stable/stand/zfs/Makefile
/freebsd-11-stable/sys/kern/link_elf_obj.c
329175 12-Feb-2018 kevans

MFC Loader Fixes 2017q4p7: r324844,r326089,r326926,r326440,r326484,r326494,
r326588,r326708,r326784,r326914,r327390,r328446,r326090,r326143,r326144,
r326182,r326384,r326421,r326440,r326441,r326442,r326443,r326444,r326445,
r326446,r326447,r326448,r326484,r326485,r326486,r326487,r326488,r326490,
r326491,r326492,r326493,r326494,r326495,r326504,r326507,r326509,r326584,
r326585,r326586,r326587,r326588,r326589,r326590,r326591,r326592,r326593,
r326594,r326600,r326616,r326671,r326707,r326708,r326709,r326710,r326711,
r326712,r326714,r326720,r326768,r326772,r326784,r326792,r326812,r326854,
r326855,r326856,r326858,r326886,r326887,r326914,r326926,r326927,r326960,
r326961,r326962,r326963,r327351,r327453,r327390,r327523,r327524,r326489,
r327880,r328437,r328438,r328439,r328441,r328446,r328448,r328449,r328612,
r328613,r328615

While here, undo our libfdt hack of not including <stdlib.h> if we're
compiling _STANDALONE.

r324844: When building standalone, don't define errno. Let the definition from
stand.h override. This is similar to what we do in the kernel.

r326089: loader.efi: efipart does not recognize partitionless disks

r326090: net_parse_rootpath() has no parameters

r326143: Fix theoretical integer overflow issues. If the product here is

r326144: Mark the func pointer as __dead2. It looks up loader_main, which

r326182: Modify all FreeBSD bootloaders on PowerPC AIM (Book-S) systems

r326384: Use const pointers to avoid casting away constness.

r326421: loader.efi: efipart should exclude iPXE stub block protocol

r326440: Remove stale dependency on ufsread.c

r326441: Minor flags cleanup

r326442: Cleanup CFALGS usage here

r326443: We don't need both _STAND and _STANDALONE, use the latter.

r326444: Move geli to common DO32 stuff

r326445: Fix random() and srandom() prototypes to match the standard.

r326446: Undefine _STANDALONE since this is test code.

r326447: Tweaks to the beri boot loader so that it builds w/o warnings.

r326448: Fix all warnings related to geli and ZFS support on x86.

r326484: Const poison the propname.

r326485: Delcare md_load in libofw.h. Make all prototypes match for ofw

r326486: Include machine/md_var to pick up __syncicache prototype.

r326487: Cast mdp (a vm_offset_t) to void * to match prototype.

r326488: e_entry can be smaller than a pointer. Cast it to an intptr_t

r326490: Declare our strange brand of main().

r326491: Disconnet ps3 from the build. There's too many warnings to fix.

r326492: Cast void * pointer to char * so the arg matches the %s format.

r326493: Provide a md_load64 prototype.

r326494: Mark two things as unused (since they are only sometimes used)

r326495: Now it's safe to bump WARNS to 1.

r326504: Switch to proper MK_LOADER_GELI tests.

r326507: increase maximum size of zfsboot

r326509: loader.efi: add note about iPXE into the efipart.c

r326584: When building standalone, include stand.h rather than the kernel

r326585: Include ficl.h before anything else

r326586: No need to include the userland md5.h, the kernel one is just fine.

r326587: Use the kernel relative paths, rather than the userland relative
paths

r326588: Need to include skein in the include path

r326589: Make sure we include the right path for skein.h

r326590: Prefer stdint.h to inttypes.h

r326591: This isn't NetBSD specific code. Include these for any kernel /

r326592: Don't inherit CFLAGS. This a specialized test program.

r326593: Stop building with the standard system headers.

r326594: Now that we offer a semi-sane standards-ish set of #include files,
stop hacking includes with sed.

r326600: Since this is contrib code, create an upstreamable version of my

r326616: dhcp_try_rfc1048() is not used any more

r326671: Avoid setting -Wno-tentative-definition-incomplete-type with gcc.

r326707: Add partial support signal.h functioanlity. Pull in
machine/signal.h

r326708: Remove _KERNEL hack now that errno.h does the right thing when
built standalone.

r326709: Provide implementations for iscntrl, ispunct and isgraph.

r326710: Put the files we're copying over into a few variables and clean
hings up.

r326711: Const poison a couple of interfaces.

r326712: Create interp class.

r326714: boot1.c needs EFI_ZFS_BOOT too, so add it globally.

r326720: This path belongs in ficl/Makefile, not the common defines for
users

r326768: Fix a comment to be more accurate

r326772: Fix regression with lua import

r326784: Revert part of 362772. It was causing problems for includes

r326792: Attempt to unbreak buildworld

r326812: Revert r326792, r326784, r326772, r326712

r326854: libefi: make efichar.h more usable in stand code

r326855: Cargo cut a fix for the regressions r326585 caused.

r326856: Fix comments after bump in size.

r326858: Revert r326855: Cargo cut a fix for the regressions r326585 caused.

r326886: Panic in sbrk if setheap hasn't been called yet. This is preferable
o a mysterious crash

r326887: Remove the 'mini libstand in libstand' that util.[ch] provided.

r326914: Move loader-only defines to loader.mk from defs.mk

r326926: Move loader help file definitions to being 100% inside of
loader.mk.

r326927: libficl is only ever used in a loader (never a boot) program. Move
it.

r326960: Simplify things a little. The RETURN macro isn't required.

r326961: Interact is always called with NULL. Simplify code a little

r326962: Hoist btx include stuff to i386/Makefile.inc

r326963: No need to use relative paths like this here.

r327351: Fix ubldr. uboot/lib uses defines for the loader.

r327453: Add a validbcd() routine that uses the bcd2bin_data[] array

r327390: Garbage-collect loader.ps3. It is currently disconnected from the
build and kboot replaces.

r327523: Don't clobber system LDFLAGS for beri boot loaders.

r327524: Use 'extern uint8_t' instead of 'extern void' for external symbols.

r326489: Allow this file to be used in libsa without warning...

r327880: Move getsecs() prototype to stand.h from net.h so it can be used

r328437: Split panic routine

r328438: Implement abort() as a call to panic.

r328439: Provide abs form stdlib.h.

r328441: abort() should be marked __dead2 since it won't return.

r328446: Now that exit is __dead2, we need to tag ub_exit() as __dead2.

r328448: Make exit() never return until host_exit can be written.

r328449: Tag unreachable places as such. I left the while (1); in place

r328612: Move strtold wrapper from strtol.c to its own strtold.c.

r328613: Kill copies of strtol and strtoul.

r328615: Update stand.h for changes for strto*l

PR: 223969


/freebsd-11-stable/contrib/compiler-rt/lib/builtins/int_lib.h
/freebsd-11-stable/lib/libc/stdlib/Makefile.inc
/freebsd-11-stable/lib/libc/stdlib/strtol.c
/freebsd-11-stable/lib/libc/stdlib/strtold.c
/freebsd-11-stable/stand/Makefile.amd64
/freebsd-11-stable/stand/Makefile.i386
/freebsd-11-stable/stand/Makefile.inc
/freebsd-11-stable/stand/arm/uboot/Makefile
/freebsd-11-stable/stand/common/bootstrap.h
/freebsd-11-stable/stand/common/dev_net.c
/freebsd-11-stable/stand/common/interp.c
/freebsd-11-stable/stand/common/interp_backslash.c
/freebsd-11-stable/stand/common/interp_forth.c
/freebsd-11-stable/stand/common/interp_parse.c
/freebsd-11-stable/stand/common/load_elf.c
/freebsd-11-stable/stand/common/load_elf_obj.c
/freebsd-11-stable/stand/common/reloc_elf.c
/freebsd-11-stable/stand/defs.mk
/freebsd-11-stable/stand/efi/boot1/Makefile
/freebsd-11-stable/stand/efi/boot1/boot1.c
/freebsd-11-stable/stand/efi/include/efichar.h
/freebsd-11-stable/stand/efi/libefi/Makefile
/freebsd-11-stable/stand/efi/libefi/efichar.c
/freebsd-11-stable/stand/efi/libefi/efipart.c
/freebsd-11-stable/stand/efi/loader/Makefile
/freebsd-11-stable/stand/efi/loader/main.c
/freebsd-11-stable/stand/ficl.mk
/freebsd-11-stable/stand/ficl/Makefile
/freebsd-11-stable/stand/ficl/float.c
/freebsd-11-stable/stand/geli/Makefile
/freebsd-11-stable/stand/geli/geliboot.c
/freebsd-11-stable/stand/geli/geliboot_internal.h
Makefile.inc
boot2/Makefile
common/cons.c
common/drv.c
gptboot/Makefile
gptboot/gptboot.c
gptboot/gptldr.S
gptzfsboot/Makefile
libfirewire/Makefile
libi386/Makefile
libi386/biosdisk.c
libi386/multiboot.c
loader/Makefile
loader/main.c
zfsboot/Makefile
zfsboot/zfsboot.c
/freebsd-11-stable/stand/libsa/Makefile
/freebsd-11-stable/stand/libsa/abort.c
/freebsd-11-stable/stand/libsa/bootp.c
/freebsd-11-stable/stand/libsa/bootp.h
/freebsd-11-stable/stand/libsa/cd9660.c
/freebsd-11-stable/stand/libsa/gpt.c
/freebsd-11-stable/stand/libsa/net.h
/freebsd-11-stable/stand/libsa/panic.c
/freebsd-11-stable/stand/libsa/sbrk.c
/freebsd-11-stable/stand/libsa/stand.h
/freebsd-11-stable/stand/libsa/strtol.c
/freebsd-11-stable/stand/libsa/strtoul.c
/freebsd-11-stable/stand/libsa/util.c
/freebsd-11-stable/stand/libsa/util.h
/freebsd-11-stable/stand/libsa/xlocale_private.h
/freebsd-11-stable/stand/loader.mk
/freebsd-11-stable/stand/mips/beri/boot2/Makefile
/freebsd-11-stable/stand/mips/beri/boot2/boot2.c
/freebsd-11-stable/stand/mips/beri/common/altera_jtag_uart.c
/freebsd-11-stable/stand/mips/beri/common/cfi.c
/freebsd-11-stable/stand/mips/beri/common/sdcard.c
/freebsd-11-stable/stand/mips/beri/loader/Makefile
/freebsd-11-stable/stand/mips/beri/loader/devicename.c
/freebsd-11-stable/stand/mips/beri/loader/exec.c
/freebsd-11-stable/stand/mips/beri/loader/loader.h
/freebsd-11-stable/stand/mips/beri/loader/main.c
/freebsd-11-stable/stand/mips/uboot/Makefile
/freebsd-11-stable/stand/mips/uboot/conf.c
/freebsd-11-stable/stand/ofw/common/main.c
/freebsd-11-stable/stand/ofw/libofw/elf_freebsd.c
/freebsd-11-stable/stand/ofw/libofw/libofw.h
/freebsd-11-stable/stand/ofw/libofw/openfirm.c
/freebsd-11-stable/stand/ofw/libofw/openfirm.h
/freebsd-11-stable/stand/ofw/libofw/ppc64_elf_freebsd.c
/freebsd-11-stable/stand/powerpc/Makefile
/freebsd-11-stable/stand/powerpc/boot1.chrp/Makefile
/freebsd-11-stable/stand/powerpc/boot1.chrp/boot1.c
/freebsd-11-stable/stand/powerpc/kboot/Makefile
/freebsd-11-stable/stand/powerpc/kboot/host_syscall.h
/freebsd-11-stable/stand/powerpc/kboot/hostdisk.c
/freebsd-11-stable/stand/powerpc/kboot/kbootfdt.c
/freebsd-11-stable/stand/powerpc/kboot/main.c
/freebsd-11-stable/stand/powerpc/kboot/ppc64_elf_freebsd.c
/freebsd-11-stable/stand/powerpc/ofw/Makefile
/freebsd-11-stable/stand/powerpc/ofw/start.c
/freebsd-11-stable/stand/powerpc/ps3
/freebsd-11-stable/stand/powerpc/uboot/Makefile
/freebsd-11-stable/stand/sparc64/boot1/Makefile
/freebsd-11-stable/stand/sparc64/loader/Makefile
/freebsd-11-stable/stand/sparc64/loader/main.c
/freebsd-11-stable/stand/sparc64/loader/metadata.c
/freebsd-11-stable/stand/uboot/common/main.c
/freebsd-11-stable/stand/uboot/lib/glue.c
/freebsd-11-stable/stand/uboot/lib/glue.h
/freebsd-11-stable/stand/userboot/test/Makefile
/freebsd-11-stable/stand/userboot/test/test.c
/freebsd-11-stable/stand/userboot/userboot/Makefile
/freebsd-11-stable/stand/userboot/userboot/main.c
/freebsd-11-stable/stand/zfs/zfsimpl.c
/freebsd-11-stable/sys/cddl/boot/zfs/zfssubr.c
/freebsd-11-stable/sys/contrib/libfdt/libfdt_env.h
/freebsd-11-stable/sys/geom/eli/g_eli_hmac.c
/freebsd-11-stable/sys/geom/eli/pkcs5v2.c
/freebsd-11-stable/sys/opencrypto/xform_userland.h
/freebsd-11-stable/sys/sys/errno.h
/freebsd-11-stable/sys/sys/libkern.h
/freebsd-11-stable/sys/sys/syslimits.h
329146 12-Feb-2018 kevans

MFC r326038,r326069,r326072: More stand simplification and fixes

r326038: Move some more common stuff up to Makefile.inc.

r326069: Fix gptzfsboot for cases with GELI.

r326072: Unbreak riscv build in universe.

329145 12-Feb-2018 kevans

MFC r325834,r325997,326502: Move sys/boot to stand/

This is effectively a direct commit to stable/11, due to differences between
stable/11 and head. Changes to DTS in sys/boot/fdt/dts were often
accompanied by kernel changes. Many of these were also risc-v updates that
likely had many more dependencies to MFC.

Because of this, sys/boot/fdt/dts remains as-is while everything else in
sys/boot relocates to stand/.

r325834: Move sys/boot to stand. Fix all references to new location

r325997: Remove empty directories.

r326502: Document the sys/boot -> stand move in hier.7 and the top-level README.


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/Makefile.inc1
/freebsd-11-stable/README
/freebsd-11-stable/lib/libefivar/Makefile
/freebsd-11-stable/release/powerpc/generate-hfs.sh
/freebsd-11-stable/release/tools/vmimage.subr
/freebsd-11-stable/share/examples/bootforth/README
/freebsd-11-stable/share/examples/etc/make.conf
/freebsd-11-stable/share/man/man5/make.conf.5
/freebsd-11-stable/share/man/man7/hier.7
/freebsd-11-stable/share/man/man8/diskless.8
/freebsd-11-stable/stand
/freebsd-11-stable/stand/Makefile
/freebsd-11-stable/stand/Makefile.amd64
/freebsd-11-stable/stand/Makefile.arm
/freebsd-11-stable/stand/Makefile.arm64
/freebsd-11-stable/stand/Makefile.i386
/freebsd-11-stable/stand/Makefile.inc
/freebsd-11-stable/stand/Makefile.mips
/freebsd-11-stable/stand/Makefile.pc98
/freebsd-11-stable/stand/Makefile.powerpc
/freebsd-11-stable/stand/Makefile.sparc64
/freebsd-11-stable/stand/arm
/freebsd-11-stable/stand/arm64
/freebsd-11-stable/stand/common
/freebsd-11-stable/stand/defs.mk
/freebsd-11-stable/stand/efi
/freebsd-11-stable/stand/fdt
/freebsd-11-stable/stand/fdt.mk
/freebsd-11-stable/stand/fdt/Makefile
/freebsd-11-stable/stand/fdt/Makefile.depend
/freebsd-11-stable/stand/fdt/fdt_loader_cmd.c
/freebsd-11-stable/stand/fdt/fdt_platform.h
/freebsd-11-stable/stand/fdt/help.fdt
/freebsd-11-stable/stand/ficl
/freebsd-11-stable/stand/ficl.mk
/freebsd-11-stable/stand/ficl32
/freebsd-11-stable/stand/forth
/freebsd-11-stable/stand/forth/pnp.4th
/freebsd-11-stable/stand/forth/support.4th
/freebsd-11-stable/stand/geli
/freebsd-11-stable/stand/i386
Makefile.inc
/freebsd-11-stable/stand/kshim
/freebsd-11-stable/stand/libsa
/freebsd-11-stable/stand/libsa32
/freebsd-11-stable/stand/loader.mk
/freebsd-11-stable/stand/man
/freebsd-11-stable/stand/mips
/freebsd-11-stable/stand/ofw
/freebsd-11-stable/stand/pc98
/freebsd-11-stable/stand/pc98/Makefile.inc
/freebsd-11-stable/stand/powerpc
/freebsd-11-stable/stand/sparc64
/freebsd-11-stable/stand/uboot
/freebsd-11-stable/stand/uboot.mk
/freebsd-11-stable/stand/usb
/freebsd-11-stable/stand/userboot
/freebsd-11-stable/stand/userboot/ficl
/freebsd-11-stable/stand/userboot/libstand
/freebsd-11-stable/stand/userboot/zfs
/freebsd-11-stable/stand/zfs
/freebsd-11-stable/stand/zfs32
/freebsd-11-stable/sys/Makefile
/freebsd-11-stable/sys/boot/Makefile
/freebsd-11-stable/sys/boot/Makefile.amd64
/freebsd-11-stable/sys/boot/Makefile.arm
/freebsd-11-stable/sys/boot/Makefile.arm64
/freebsd-11-stable/sys/boot/Makefile.i386
/freebsd-11-stable/sys/boot/Makefile.inc
/freebsd-11-stable/sys/boot/Makefile.mips
/freebsd-11-stable/sys/boot/Makefile.pc98
/freebsd-11-stable/sys/boot/Makefile.powerpc
/freebsd-11-stable/sys/boot/Makefile.sparc64
/freebsd-11-stable/sys/boot/arm
/freebsd-11-stable/sys/boot/arm64
/freebsd-11-stable/sys/boot/common
/freebsd-11-stable/sys/boot/defs.mk
/freebsd-11-stable/sys/boot/efi
/freebsd-11-stable/sys/boot/fdt.mk
/freebsd-11-stable/sys/boot/fdt/Makefile
/freebsd-11-stable/sys/boot/fdt/Makefile.depend
/freebsd-11-stable/sys/boot/fdt/fdt_loader_cmd.c
/freebsd-11-stable/sys/boot/fdt/fdt_platform.h
/freebsd-11-stable/sys/boot/fdt/help.fdt
/freebsd-11-stable/sys/boot/ficl
/freebsd-11-stable/sys/boot/ficl.mk
/freebsd-11-stable/sys/boot/ficl32
/freebsd-11-stable/sys/boot/forth
/freebsd-11-stable/sys/boot/geli
/freebsd-11-stable/sys/boot/i386
/freebsd-11-stable/sys/boot/kshim
/freebsd-11-stable/sys/boot/libsa
/freebsd-11-stable/sys/boot/libsa32
/freebsd-11-stable/sys/boot/loader.mk
/freebsd-11-stable/sys/boot/man
/freebsd-11-stable/sys/boot/mips
/freebsd-11-stable/sys/boot/ofw
/freebsd-11-stable/sys/boot/pc98
/freebsd-11-stable/sys/boot/powerpc
/freebsd-11-stable/sys/boot/sparc64
/freebsd-11-stable/sys/boot/uboot
/freebsd-11-stable/sys/boot/uboot.mk
/freebsd-11-stable/sys/boot/usb
/freebsd-11-stable/sys/boot/userboot
/freebsd-11-stable/sys/boot/zfs
/freebsd-11-stable/sys/boot/zfs32
/freebsd-11-stable/sys/contrib/dev/acpica/acpica_prep.sh
/freebsd-11-stable/tools/boot/universe.sh
/freebsd-11-stable/tools/tools/bootparttest/Makefile
/freebsd-11-stable/tools/tools/zfsboottest/Makefile
/freebsd-11-stable/usr.sbin/bhyveload/Makefile
329140 11-Feb-2018 kevans

MFC Loader Fixes 2017q4p6: r324649,r324650,r324651,r324652,r324653,r324654,
r324700,r324702,r324709,r324717,r324719,r324841,r324842,r324843,r324845,
r324850,r324876,r324877,r324878,r324879,r324880,r324881,r324883,r324980,
r324981,r324982,r324995,r325014,r325093,r325094,r325114,r325170,r325171,
r325172,r325173,r325174,r325175,r325176,r325248,r325286,r325310,r325332,
r325338,r325339,r325376,r325377,r325379,r325380,r325382,r325478,r325479,
r325480,r325482,r325483,r325484,r325485,r325556,r325641,r325681,r325685,
r325686,r325687,r325688,r325689,r325690,r325691,r325692,r325693,r325694,
r325743,r325744,r325748,r325775,r325779,r325780

r324649: Move common/Makefile.inc to sys/boot/loader.mk.

r324650: tweak style

r324651: create defs.mk for common definitions

r324652: Move all the ficl common code into ficl.mk

r324653: LOADER_foo_SUPPORTED

r324654: Explicitly inlcude SYSDIR in the include path

r324700: loader: initialize dv_cleanup in md.c to eliminate clang warning

r324702: We need to include disk.o in libuboot.a when we're building with
support for disk access.

r324709: Revert "Unify boot1 with loader" change r324646

r324717: libsa/ip.c: misplaced comment, ip_v is half char, not ip_p

r324719: libsa/ip: stop read loop on bad fragments

r324841: Use BOOTDIR more consistently in defs.mk rather than repeat
sys/boot.

r324842: Introduce BOOTOBJ: The top level object directory for the boot tree

r324843: Stopgap fix to the mistmatch between LOADER_GELI_SUPPORT and
LOADER_NO_GELI_SUPPORT.

r324845: Use BOOTOBJ and BOOTDIR to find geli includes and libraries.

r324850: Define LIBSA32 to LIBSA on i386 to fix build.

r324876: Move fdt and uboot defines into common uboot.mk.

r324877: End source directories with SRC rather than a hodgepodge of names

r324878: Make at91 boot loader compile again.

r324879: Prefer SRCTOP paths for bits we're grabbing from libc.

r324880: Use BOOTSRC here.

r324881: Use SYSDIR instead of ${.CURDIR}/../..<etc>/sys.

r324883: Use preferred defined paths, rather than relative paths in fdt.

r324980: Use BOOTDIR consistently.

r324981: Move BINDIR definition to defs.mk, and override where it isn't
/boot

r324982: Remove sys/boot/arm/at91 and ixp425

r324995: loader.efi: Make framebuffer commands available for arm64

r325014: Add a 'place holder' arm struct efi_fb until a real one comes

r325093: Define new EFI variables

r325094: Cleanup non-arch Makefiles

r325114: Use defs.mk defins in most MD code

r325170: Use defs.mk values for userboot

r325171: Use defs.mk name and prefer bsd.init.mk

r325172: Remove the -nostdlib stuff I added. Instead, fix LDFLAGS to be
honored correctly with the new Makefile.inc include order.

r325173: We don't need to build a special ficl for userboot.

r325174: Minor cleanup

r325175: For amd64, compile both zfs and zfs32 libraries.

r325176: Actually add zfs32/Makefile

r325248: loader ptblread() is broken with >512B sectors

r325286: efipart_strategy is using wrong offset with >512B sectors

r325310: zfs.c:vdev_read() needs to be careful about large sectors

r325332: loader: re-enable gzip support for x86

r325338: loader: fix BOOTSRC -> BOOTOBJ in a library path

r325339: This used to have bzip2 support too.

r325376: WIP: centralize machine links

r325377: mostly libsa

r325379: Revert "mostly libsa"

r325380: Revert "WIP: centralize machine links"

r325382: Cleanup stray libstand names to be libsa names.

r325478: Powerpc is a 32-bit boot loader.

r325479: Define LIBFICL32 to be libficl.a on i386 and libficl32.a on amd64.

r325480: Use DO32 for all the places that we need to flag we're building a
32-bit version of a library.

r325482: Move machine and other link creation to defs.mk

r325483: MACHINE can never be powerpc64, so cleanup code that thinks it can.

r325484: Prefer bsd.init.mk to src.opts.mk

r325485: Centralize all 32-bit builds on 64-bit platform stuff.

r325556: loader: set options before including bsd.init.mk

r325641: loader.efi: efi_devpath_is_prefix should return bool

r325681: boot1: avoid using NULL device path

r325685: libsa32 isn't needed for i386. It's already a 32-bit platform.

r325686: Simplify this if to a direct assignment.

r325687: Remove all the empty help files from the powerpc build.

r325688: FDT support doesn't make sense for ps3, remove it.

r325689: Remove LOADER_FDT_SUPPORT as a Makefile variable.

r325690: Remove LOADER_ZFS_SUPPORT as a Makefile variable

r325691: Remove useless PNP define here.

r325692: Replace LOADER_FIREWIRE_SUPPORT variable

r325693: Move LOADER_{NO,}_GELI_SUPPORT to MK_LOADER_GELI

r325694: Install the 4th files in sys/boot/forth instead of each loader

r325743: Make sure the proper loader.rc gets installed.

r325744: boot1: also check for NULL device

r325748: Use proper include file.

r325775: Add loader.conf to the list of files that are MD.

r325779: Add /boot/dts to the list of default modules.

r325780: Don't add /boot/dt*s* but /boot/dt*b*. Stupid think-o.


/freebsd-11-stable/UPDATING
/freebsd-11-stable/share/mk/src.opts.mk
/freebsd-11-stable/sys/arm/include/metadata.h
/freebsd-11-stable/sys/arm64/include/metadata.h
/freebsd-11-stable/sys/boot/Makefile
/freebsd-11-stable/sys/boot/Makefile.amd64
/freebsd-11-stable/sys/boot/Makefile.arm
/freebsd-11-stable/sys/boot/Makefile.arm64
/freebsd-11-stable/sys/boot/Makefile.i386
/freebsd-11-stable/sys/boot/Makefile.inc
/freebsd-11-stable/sys/boot/Makefile.powerpc
/freebsd-11-stable/sys/boot/Makefile.sparc64
/freebsd-11-stable/sys/boot/arm/at91/Makefile
/freebsd-11-stable/sys/boot/arm/at91/Makefile.inc
/freebsd-11-stable/sys/boot/arm/at91/boot0/Makefile
/freebsd-11-stable/sys/boot/arm/at91/boot0/README
/freebsd-11-stable/sys/boot/arm/at91/boot0/linker.cfg
/freebsd-11-stable/sys/boot/arm/at91/boot0/main.c
/freebsd-11-stable/sys/boot/arm/at91/boot0iic/Makefile
/freebsd-11-stable/sys/boot/arm/at91/boot0iic/main.c
/freebsd-11-stable/sys/boot/arm/at91/boot0spi/Makefile
/freebsd-11-stable/sys/boot/arm/at91/boot0spi/main.c
/freebsd-11-stable/sys/boot/arm/at91/boot2/Makefile
/freebsd-11-stable/sys/boot/arm/at91/boot2/board.h
/freebsd-11-stable/sys/boot/arm/at91/boot2/boot2.c
/freebsd-11-stable/sys/boot/arm/at91/boot2/bwct_board.c
/freebsd-11-stable/sys/boot/arm/at91/boot2/centipad_board.c
/freebsd-11-stable/sys/boot/arm/at91/boot2/kb920x_board.c
/freebsd-11-stable/sys/boot/arm/at91/bootiic/Makefile
/freebsd-11-stable/sys/boot/arm/at91/bootiic/README
/freebsd-11-stable/sys/boot/arm/at91/bootiic/env_vars.c
/freebsd-11-stable/sys/boot/arm/at91/bootiic/env_vars.h
/freebsd-11-stable/sys/boot/arm/at91/bootiic/loader_prompt.c
/freebsd-11-stable/sys/boot/arm/at91/bootiic/loader_prompt.h
/freebsd-11-stable/sys/boot/arm/at91/bootiic/main.c
/freebsd-11-stable/sys/boot/arm/at91/bootspi/Makefile
/freebsd-11-stable/sys/boot/arm/at91/bootspi/README
/freebsd-11-stable/sys/boot/arm/at91/bootspi/ee.c
/freebsd-11-stable/sys/boot/arm/at91/bootspi/ee.h
/freebsd-11-stable/sys/boot/arm/at91/bootspi/env_vars.c
/freebsd-11-stable/sys/boot/arm/at91/bootspi/env_vars.h
/freebsd-11-stable/sys/boot/arm/at91/bootspi/loader_prompt.c
/freebsd-11-stable/sys/boot/arm/at91/bootspi/loader_prompt.h
/freebsd-11-stable/sys/boot/arm/at91/bootspi/main.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/Makefile
/freebsd-11-stable/sys/boot/arm/at91/libat91/arm_init.S
/freebsd-11-stable/sys/boot/arm/at91/libat91/at91rm9200.h
/freebsd-11-stable/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h
/freebsd-11-stable/sys/boot/arm/at91/libat91/delay.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/eeprom.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/emac.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/emac.h
/freebsd-11-stable/sys/boot/arm/at91/libat91/emac_init.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/getc.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/lib.h
/freebsd-11-stable/sys/boot/arm/at91/libat91/lib_AT91RM9200.h
/freebsd-11-stable/sys/boot/arm/at91/libat91/mci_device.h
/freebsd-11-stable/sys/boot/arm/at91/libat91/memcmp.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/memcpy.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/memset.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/p_string.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/printf.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/putchar.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/reset.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/sd-card.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/sd-card.h
/freebsd-11-stable/sys/boot/arm/at91/libat91/spi_flash.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/spi_flash.h
/freebsd-11-stable/sys/boot/arm/at91/libat91/strcmp.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/strcpy.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/strcvt.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/strlen.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/tag_list.c
/freebsd-11-stable/sys/boot/arm/at91/libat91/tag_list.h
/freebsd-11-stable/sys/boot/arm/at91/libat91/xmodem.c
/freebsd-11-stable/sys/boot/arm/at91/linker.cfg
/freebsd-11-stable/sys/boot/arm/ixp425/Makefile.inc
/freebsd-11-stable/sys/boot/arm/ixp425/boot2/Makefile
/freebsd-11-stable/sys/boot/arm/ixp425/boot2/arm_init.S
/freebsd-11-stable/sys/boot/arm/ixp425/boot2/boot2.c
/freebsd-11-stable/sys/boot/arm/ixp425/boot2/cf_ata.h
/freebsd-11-stable/sys/boot/arm/ixp425/boot2/ixp425_board.c
/freebsd-11-stable/sys/boot/arm/ixp425/boot2/lib.h
/freebsd-11-stable/sys/boot/arm/loader
/freebsd-11-stable/sys/boot/arm/loader/loader.conf
/freebsd-11-stable/sys/boot/arm/uboot/Makefile
/freebsd-11-stable/sys/boot/arm/uboot/loader.conf
/freebsd-11-stable/sys/boot/common/Makefile.inc
/freebsd-11-stable/sys/boot/common/disk.c
/freebsd-11-stable/sys/boot/common/md.c
/freebsd-11-stable/sys/boot/defs.mk
/freebsd-11-stable/sys/boot/efi/Makefile
/freebsd-11-stable/sys/boot/efi/Makefile.inc
/freebsd-11-stable/sys/boot/efi/boot1/Makefile
/freebsd-11-stable/sys/boot/efi/boot1/boot1.c
/freebsd-11-stable/sys/boot/efi/boot1/boot_module.h
/freebsd-11-stable/sys/boot/efi/boot1/ufs_module.c
/freebsd-11-stable/sys/boot/efi/boot1/zfs_module.c
/freebsd-11-stable/sys/boot/efi/fdt/Makefile
/freebsd-11-stable/sys/boot/efi/include/efilib.h
/freebsd-11-stable/sys/boot/efi/libefi/Makefile
/freebsd-11-stable/sys/boot/efi/libefi/devpath.c
/freebsd-11-stable/sys/boot/efi/libefi/efi_main.c
/freebsd-11-stable/sys/boot/efi/libefi/efipart.c
/freebsd-11-stable/sys/boot/efi/loader/Makefile
/freebsd-11-stable/sys/boot/efi/loader/arch/amd64/Makefile.inc
/freebsd-11-stable/sys/boot/efi/loader/arch/amd64/framebuffer.c
/freebsd-11-stable/sys/boot/efi/loader/arch/amd64/framebuffer.h
/freebsd-11-stable/sys/boot/efi/loader/arch/arm/Makefile.inc
/freebsd-11-stable/sys/boot/efi/loader/arch/arm64/Makefile.inc
/freebsd-11-stable/sys/boot/efi/loader/arch/i386/Makefile.inc
/freebsd-11-stable/sys/boot/efi/loader/bootinfo.c
/freebsd-11-stable/sys/boot/efi/loader/efi_main.c
/freebsd-11-stable/sys/boot/efi/loader/framebuffer.c
/freebsd-11-stable/sys/boot/efi/loader/framebuffer.h
/freebsd-11-stable/sys/boot/fdt.mk
/freebsd-11-stable/sys/boot/fdt/Makefile
/freebsd-11-stable/sys/boot/ficl.mk
/freebsd-11-stable/sys/boot/ficl/Makefile
/freebsd-11-stable/sys/boot/ficl32/Makefile
/freebsd-11-stable/sys/boot/forth/Makefile
/freebsd-11-stable/sys/boot/forth/Makefile.inc
/freebsd-11-stable/sys/boot/forth/loader.conf
/freebsd-11-stable/sys/boot/geli/Makefile
/freebsd-11-stable/sys/boot/i386/Makefile
/freebsd-11-stable/sys/boot/i386/Makefile.inc
/freebsd-11-stable/sys/boot/i386/boot0/Makefile
/freebsd-11-stable/sys/boot/i386/boot2/Makefile
/freebsd-11-stable/sys/boot/i386/btx/btx/Makefile
/freebsd-11-stable/sys/boot/i386/btx/btxldr/Makefile
/freebsd-11-stable/sys/boot/i386/btx/lib/Makefile
/freebsd-11-stable/sys/boot/i386/cdboot/Makefile
/freebsd-11-stable/sys/boot/i386/gptboot/Makefile
/freebsd-11-stable/sys/boot/i386/gptzfsboot/Makefile
/freebsd-11-stable/sys/boot/i386/kgzldr/Makefile
/freebsd-11-stable/sys/boot/i386/libfirewire/Makefile
/freebsd-11-stable/sys/boot/i386/libi386/Makefile
/freebsd-11-stable/sys/boot/i386/loader/Makefile
/freebsd-11-stable/sys/boot/i386/mbr/Makefile
/freebsd-11-stable/sys/boot/i386/pmbr/Makefile
/freebsd-11-stable/sys/boot/i386/pxeldr/Makefile
/freebsd-11-stable/sys/boot/i386/zfsboot/Makefile
/freebsd-11-stable/sys/boot/i386/zfsloader/Makefile
/freebsd-11-stable/sys/boot/libsa/Makefile
/freebsd-11-stable/sys/boot/libsa/ip.c
/freebsd-11-stable/sys/boot/libsa32/Makefile
/freebsd-11-stable/sys/boot/loader.mk
/freebsd-11-stable/sys/boot/man/Makefile
/freebsd-11-stable/sys/boot/mips/beri/Makefile.inc
/freebsd-11-stable/sys/boot/mips/beri/boot2/Makefile
/freebsd-11-stable/sys/boot/mips/beri/loader/Makefile
/freebsd-11-stable/sys/boot/mips/uboot/Makefile
/freebsd-11-stable/sys/boot/ofw/Makefile.inc
/freebsd-11-stable/sys/boot/ofw/libofw/Makefile
/freebsd-11-stable/sys/boot/powerpc/Makefile
/freebsd-11-stable/sys/boot/powerpc/Makefile.inc
/freebsd-11-stable/sys/boot/powerpc/boot1.chrp/Makefile
/freebsd-11-stable/sys/boot/powerpc/kboot/Makefile
/freebsd-11-stable/sys/boot/powerpc/kboot/help.kboot
/freebsd-11-stable/sys/boot/powerpc/ofw/Makefile
/freebsd-11-stable/sys/boot/powerpc/ofw/help.ofw
/freebsd-11-stable/sys/boot/powerpc/ps3/Makefile
/freebsd-11-stable/sys/boot/powerpc/ps3/help.ps3
/freebsd-11-stable/sys/boot/powerpc/uboot/Makefile
/freebsd-11-stable/sys/boot/powerpc/uboot/help.uboot
/freebsd-11-stable/sys/boot/sparc64/Makefile
/freebsd-11-stable/sys/boot/sparc64/Makefile.inc
/freebsd-11-stable/sys/boot/sparc64/boot1/Makefile
/freebsd-11-stable/sys/boot/sparc64/loader/Makefile
/freebsd-11-stable/sys/boot/sparc64/zfsloader/Makefile
/freebsd-11-stable/sys/boot/uboot.mk
/freebsd-11-stable/sys/boot/uboot/Makefile
/freebsd-11-stable/sys/boot/uboot/Makefile.inc
/freebsd-11-stable/sys/boot/uboot/common/Makefile.inc
/freebsd-11-stable/sys/boot/uboot/fdt/Makefile
/freebsd-11-stable/sys/boot/uboot/lib/Makefile
/freebsd-11-stable/sys/boot/userboot/Makefile
/freebsd-11-stable/sys/boot/userboot/ficl/Makefile
/freebsd-11-stable/sys/boot/userboot/ficl/Makefile.depend
/freebsd-11-stable/sys/boot/userboot/test/Makefile
/freebsd-11-stable/sys/boot/userboot/test/test.c
/freebsd-11-stable/sys/boot/userboot/userboot/Makefile
/freebsd-11-stable/sys/boot/userboot/zfs/Makefile
/freebsd-11-stable/sys/boot/userboot/zfs/Makefile.depend
/freebsd-11-stable/sys/boot/zfs/Makefile
/freebsd-11-stable/sys/boot/zfs/zfs.c
/freebsd-11-stable/sys/boot/zfs32
/freebsd-11-stable/sys/boot/zfs32/Makefile
/freebsd-11-stable/tools/boot/universe.sh
/freebsd-11-stable/tools/build/options/WITHOUT_LOADER_GEIL
/freebsd-11-stable/tools/build/options/WITH_LOADER_FIREWIRE
329134 11-Feb-2018 kevans

MFC Loader Fixes 2017q4p4: r324552,r324553,r324554,r324555,r324556

r324552: Kill the userboot copy of libstand.

r324553: Rename libstand.a to libsa.a and libstand32.a to libsa32.a

r324554: Move crc32.c, util.c and gpt.c over to libsa.

r324555: Honor CFLAGS modifications in Makefile.inc by using += here.

r324556: Move ufsread.c

329131 11-Feb-2018 kevans

MFC Loader Fixes 2017q4p3: r324460,r324471

r324460: Rather than laying whack-a-mole with including the path to stand.h,
always include it.

r324471: Fix typos: `stand alon{e,g}` should be spelled like `standalone`

329129 11-Feb-2018 kevans

MFC Loader Fixes 2017q4p1: r324321,r324359,r324360,r324388,r324449,r324450,
r324451,r324452

r324321: This README file was quite relevant for FreeBSD 3 or 4. No more.

r324359: Add efi_devpath_is_prefix

r324360: Encapsulate ZFS preferences into efi_zfs_is_preferred

r324388: Unbreak building efiboot with MK_ZFS == no

r324449: Prefer ${LIBSTAND} to -lstand

r324450: Define SASRC and use it

r324451: Add missing -I${SASRC} in a couple of places so that stand.h
doesn't accidentally come in via host pollution.

r324452: Define LIBSA* and use them instead of overloaded LIBSTAND


/freebsd-11-stable/sys/boot/Makefile.ficl
/freebsd-11-stable/sys/boot/Makefile.inc
/freebsd-11-stable/sys/boot/README
/freebsd-11-stable/sys/boot/arm/uboot/Makefile
/freebsd-11-stable/sys/boot/common/Makefile.inc
/freebsd-11-stable/sys/boot/efi/boot1/Makefile
/freebsd-11-stable/sys/boot/efi/fdt/Makefile
/freebsd-11-stable/sys/boot/efi/include/efilib.h
/freebsd-11-stable/sys/boot/efi/include/efizfs.h
/freebsd-11-stable/sys/boot/efi/libefi/Makefile
/freebsd-11-stable/sys/boot/efi/libefi/devpath.c
/freebsd-11-stable/sys/boot/efi/libefi/efizfs.c
/freebsd-11-stable/sys/boot/efi/loader/Makefile
/freebsd-11-stable/sys/boot/efi/loader/main.c
/freebsd-11-stable/sys/boot/fdt/Makefile
/freebsd-11-stable/sys/boot/i386/gptboot/Makefile
/freebsd-11-stable/sys/boot/i386/gptzfsboot/Makefile
/freebsd-11-stable/sys/boot/i386/libfirewire/Makefile
/freebsd-11-stable/sys/boot/i386/libi386/Makefile
/freebsd-11-stable/sys/boot/i386/loader/Makefile
/freebsd-11-stable/sys/boot/i386/zfsboot/Makefile
/freebsd-11-stable/sys/boot/libstand32/Makefile
/freebsd-11-stable/sys/boot/mips/beri/boot2/Makefile
/freebsd-11-stable/sys/boot/mips/beri/loader/Makefile
/freebsd-11-stable/sys/boot/mips/uboot/Makefile
/freebsd-11-stable/sys/boot/ofw/libofw/Makefile
/freebsd-11-stable/sys/boot/powerpc/kboot/Makefile
/freebsd-11-stable/sys/boot/powerpc/ofw/Makefile
/freebsd-11-stable/sys/boot/powerpc/ps3/Makefile
/freebsd-11-stable/sys/boot/powerpc/uboot/Makefile
/freebsd-11-stable/sys/boot/sparc64/loader/Makefile
/freebsd-11-stable/sys/boot/uboot/fdt/Makefile
/freebsd-11-stable/sys/boot/uboot/lib/Makefile
/freebsd-11-stable/sys/boot/userboot/Makefile.inc
/freebsd-11-stable/sys/boot/userboot/libstand/Makefile
/freebsd-11-stable/sys/boot/userboot/userboot/Makefile
/freebsd-11-stable/sys/boot/userboot/zfs/Makefile
/freebsd-11-stable/sys/boot/zfs/Makefile
329114 11-Feb-2018 kevans

MFC Loader Fixes 2017q3: r320547,r320553,r321621,r321844,r321969,r321991,
r322037,r322038,r322039,r322040,r322056,r322074,r322542,r322592,r322593,
r322896,r322923,r323671,r322930,r322931,r322932,r322933,r322934,r322935,
r322936,r322937,r322938,r322939,r322941,r323062,r323063,r323064,r323065,
r323100,r323131,r323174,r323258,r323261,r323272,r323367,r323379,r323389,
r323407,r323428,r323436,r323494,r323496,r323497,r323541,r323554,r323589,
r323707,r323867,r323885,r323886,r323895,r323896,r323897,r323905,r323906,
r323907,r323908,r323909,r323952,r323991,r324099,r324558,r326445,r326609,
r326610

This batch includes a special kludge to fix powerpc loader build; <stdlib.h>
was included after <stand.h> there, causing problems with DEBUG_MALLOC bits.
Include <stdlib.h> a little bit earlier to fix the build with the intention
of removing this when eventually libsa silently replaces stdlib.h with
stand.h.

r320547: Link EFI/uboot loaders with -znotext

r320553: Integer underflow in efipart_realstrategy when I/O starts after end
of disk

r321621: Always set the receive mask in loader.efi.

r321844: Clean up style in print_state(..) and pager_printf(..)

r321969: Fix the return types for printf and putchar to match their libc

r321991: Revert r321969

r322037: Add stpcpy and stpncpy to libstand

r322038: Add definitions and utilities for EFI drivers

r322039: Move EFI ZFS functions to libefi

r322040: Add EFI utility functions to libefi

r322056: Move EFI fmtdev functionality to libefi

r322074: libefi/time.c cstyle cleanup

r322542: loader.efi: repace XXX with real comments in trap.c

r322592: Remove unused defines.

r322593: Define proposed GUID for FreeBSD boot loader variables.

r322896: Make spinconsole platform independent and hook it up into EFI
loader

r322923: Hide length of geli passphrase during boot.

r323671: Fix language used in the r322923.

r322930: Move efi_main into efi/loader

r322931: Cleanup efi_main return type

r322932: Use the loader.efi conventions for the various EFI tables.

r322933: No need for MK_ZFS around these: they are by their nature only
active when MK_ZFS is true.

r322934: _STAND is sometimes defined on the command line. Make the define
here match.

r322935: Fix warnings due to type mismatch.

r322936: Remove useless 'static' for an enum definition.

r322937: Forward declare struct dsk to avoid warnings when building libi386.

r322938: Link in libefi for boot1

r322939: Use efi_devpath_str for debug path info.

r322941: Eliminate redunant device path matching.

r323062: Make efichar.c routines available to libefi.

r323063: boot1.efi: print more info about where boot1.efi is loaded from

r323064: Exit rather than panic for most errors.

r323065: Save where we're booted from

r323100: libstand: nfs_readlink() should return proper return code

r323131: Revert r322941: Eliminate redundant device matching functions

r323174: Fix loader bug causing too many pages allocation when bootloader
is U-Boot

r323258: ucs2len

r323261: Fix armv6 build

r323272: Be consistent and do return (1);

r323367: Mark init_chroot and init_script variables as deprecated.

r323379: It's been pointed out that init_script at least is useful w/o

r323389: loader.efi: chain loader should provide proper device handle

r323407: boot1 generate-fat: generate all templates at once

r323428: r323389 breaks the kernel build when WITHOUT_ZFS is defined in
src.conf

r323436: boot1: remove BOOT1_MAXSIZE default value

r323494: loader should support large_dnode

r323496: libstand: tftp_open() can leak pkt on error

r323497: libefi: efipart_open should check the status from disk_open

r323541: libefi: efipart_realstrategy rsize pointer may be NULL

r323554: Increase EFI boot file size frok 128k to 384k

r323589: loader: biosmem.c cstyle cleanup

r323707: loader: biosmem allocate heap just below 4GB

r323867: libefi: devicename.c cleanups

r323885: libefi: efi_devpath_match() should return bool

r323886: libefi: efipart.c should use calloc()

r323895: libefi: efi_devpath_match local len should be unsigned

r323896: r323885 did miss efilib.h update

r323897: efilib.h: typo in structure member description

r323905: libefi: pdinfo_t pd_unit and pd_open should be unsigned

r323906: libefi: efipart_strategy() should return ENXIO when there is no
media

r323907: libefi: efipart.c cstyle fix for efipart_print_common()

r323908: libefi: efipart_hdinfo_add_filepath should check strtol result

r323909: libefi: define EISA PNP constants

r323952: After the r317886 support for TFTP and NFS can be enable
simultaneously.

r323991: libefi: efipart_floppy() will should not pass acpi pointer if the
HID test fails

r324099: Compile loader as Little-Endian on PPC64/POWER8

r324558: Define prototype for exit and ensure references

r326445: Fix random() and srandom() prototypes to match the standard.

r326609: Make putenv and getenv match the userland definition

r326610: Fix random() prototype to match the system.

PR: 219000 221001 222215
Relnotes: yes ("The length of the geli passphrase is hidden during boot")


/freebsd-11-stable/UPDATING
/freebsd-11-stable/lib/libstand/Makefile
/freebsd-11-stable/lib/libstand/environment.c
/freebsd-11-stable/lib/libstand/libstand.3
/freebsd-11-stable/lib/libstand/nfs.c
/freebsd-11-stable/lib/libstand/random.c
/freebsd-11-stable/lib/libstand/stand.h
/freebsd-11-stable/lib/libstand/tftp.c
/freebsd-11-stable/sbin/geom/class/eli/geli.8
/freebsd-11-stable/sbin/geom/class/eli/geom_eli.c
/freebsd-11-stable/share/mk/src.opts.mk
/freebsd-11-stable/sys/boot/Makefile.inc
/freebsd-11-stable/sys/boot/arm/uboot/Makefile
/freebsd-11-stable/sys/boot/arm/uboot/conf.c
/freebsd-11-stable/sys/boot/common/loader.8
/freebsd-11-stable/sys/boot/efi/boot1/Makefile
/freebsd-11-stable/sys/boot/efi/boot1/Makefile.fat
/freebsd-11-stable/sys/boot/efi/boot1/boot1.c
/freebsd-11-stable/sys/boot/efi/boot1/boot_module.h
/freebsd-11-stable/sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu
/freebsd-11-stable/sys/boot/efi/boot1/fat-amd64.tmpl.xz
/freebsd-11-stable/sys/boot/efi/boot1/fat-arm.tmpl.bz2.uu
/freebsd-11-stable/sys/boot/efi/boot1/fat-arm.tmpl.xz
/freebsd-11-stable/sys/boot/efi/boot1/fat-arm64.tmpl.bz2.uu
/freebsd-11-stable/sys/boot/efi/boot1/fat-arm64.tmpl.xz
/freebsd-11-stable/sys/boot/efi/boot1/fat-i386.tmpl.bz2.uu
/freebsd-11-stable/sys/boot/efi/boot1/fat-i386.tmpl.xz
/freebsd-11-stable/sys/boot/efi/boot1/generate-fat.sh
/freebsd-11-stable/sys/boot/efi/boot1/ufs_module.c
/freebsd-11-stable/sys/boot/efi/boot1/zfs_module.c
/freebsd-11-stable/sys/boot/efi/include/efi.h
/freebsd-11-stable/sys/boot/efi/include/efi_driver_utils.h
/freebsd-11-stable/sys/boot/efi/include/efi_drivers.h
/freebsd-11-stable/sys/boot/efi/include/efiapi.h
/freebsd-11-stable/sys/boot/efi/include/efichar.h
/freebsd-11-stable/sys/boot/efi/include/efidevp.h
/freebsd-11-stable/sys/boot/efi/include/efilib.h
/freebsd-11-stable/sys/boot/efi/include/efiprot.h
/freebsd-11-stable/sys/boot/efi/include/efizfs.h
/freebsd-11-stable/sys/boot/efi/libefi/Makefile
/freebsd-11-stable/sys/boot/efi/libefi/devicename.c
/freebsd-11-stable/sys/boot/efi/libefi/devpath.c
/freebsd-11-stable/sys/boot/efi/libefi/efi_driver_utils.c
/freebsd-11-stable/sys/boot/efi/libefi/efichar.c
/freebsd-11-stable/sys/boot/efi/libefi/efinet.c
/freebsd-11-stable/sys/boot/efi/libefi/efipart.c
/freebsd-11-stable/sys/boot/efi/libefi/efizfs.c
/freebsd-11-stable/sys/boot/efi/libefi/errno.c
/freebsd-11-stable/sys/boot/efi/libefi/libefi.c
/freebsd-11-stable/sys/boot/efi/libefi/time.c
/freebsd-11-stable/sys/boot/efi/loader/Makefile
/freebsd-11-stable/sys/boot/efi/loader/arch/amd64/Makefile.inc
/freebsd-11-stable/sys/boot/efi/loader/arch/amd64/trap.c
/freebsd-11-stable/sys/boot/efi/loader/arch/i386/Makefile.inc
/freebsd-11-stable/sys/boot/efi/loader/bootinfo.c
/freebsd-11-stable/sys/boot/efi/loader/conf.c
/freebsd-11-stable/sys/boot/efi/loader/devicename.c
/freebsd-11-stable/sys/boot/efi/loader/efi_main.c
/freebsd-11-stable/sys/boot/efi/loader/loader_efi.h
/freebsd-11-stable/sys/boot/efi/loader/main.c
/freebsd-11-stable/sys/boot/geli/geliboot.c
/freebsd-11-stable/sys/boot/geli/geliboot.h
/freebsd-11-stable/sys/boot/geli/geliboot_crypto.c
/freebsd-11-stable/sys/boot/geli/geliboot_internal.h
/freebsd-11-stable/sys/boot/geli/pwgets.c
/freebsd-11-stable/sys/boot/i386/libi386/Makefile
/freebsd-11-stable/sys/boot/i386/libi386/biosdisk.c
/freebsd-11-stable/sys/boot/i386/libi386/biosmem.c
/freebsd-11-stable/sys/boot/i386/libi386/spinconsole.c
/freebsd-11-stable/sys/boot/mips/uboot/conf.c
/freebsd-11-stable/sys/boot/powerpc/ofw/conf.c
/freebsd-11-stable/sys/boot/powerpc/ofw/ofwfdt.c
/freebsd-11-stable/sys/boot/powerpc/uboot/conf.c
/freebsd-11-stable/sys/boot/userboot/test/test.c
/freebsd-11-stable/sys/boot/userboot/userboot.h
/freebsd-11-stable/sys/boot/userboot/userboot/main.c
/freebsd-11-stable/sys/boot/zfs/zfsimpl.c
/freebsd-11-stable/sys/cddl/boot/zfs/zfsimpl.h
/freebsd-11-stable/sys/geom/eli/g_eli.c
/freebsd-11-stable/sys/geom/eli/g_eli.h
/freebsd-11-stable/sys/geom/eli/g_eli_ctl.c
/freebsd-11-stable/usr.sbin/bhyveload/bhyveload.c
329100 10-Feb-2018 kevans

MFC Loader Fixes 2017q2: r316437,r316577,r316578,r316585,r316590,r316612,
r316625,r316628,r316654,r316682,r316704,r316771,r317092,r317097,r317099,
r317652,r317785,r317886,r317887,r318142,r318320,r318356,r318678,r318754,
r318982,r318986,r318987,r318988,r318989,r318990,r318991,r318992,r318993,
r318994,r318999,r319083,r319084,r319085,r320011,r320234,r320288,r320304,
r320467,r320482

r316437: Small cleanup to make i386/loader match efi/loader boot environment
code

r316577: loader: part.c cstyle cleanup

r316578: loader: want mechanism to avoid RA with bcache

r316585: loader: zfs reader should check all labels

r316590: libstand/dosfs: cache FAT32 in 128 Kb blocks to save loader memory

r316612: In r298230 the value of HEAP_MIN was changed from 3MB to 64MB.
Correct a comment.

r316625: Do not use -msoft-float with intention of disabling FP on aarch64

r316628: Silence GCC warning by initializing the local variable.

r316654: loader: r316585 did miss userboot update

r316682: loader: r316585 did miss sparc/ofw

r316704: loader.efi: only fetch zfs pool guid for the actual boot device

r316771: loader: Avoid possible overflow via environment variable

r317092: loader: zfs reader vdev_probe should check for minimum device size

r317097: loader: F_READ/F_WRITE should be checked against masked flag

r317099: loader: uboot disk ioctl should call disk_ioctl

r317652: loader.efi: ResetSystem does not use data with EFI_SUCCESS

r317785: zfsboot: drvsize() may be unusable on some systems

r317886: distinguish NFS versus TFTP boot by rootpath

r317887: loader: network read rework

r318142: libstand: NULL pointer dereference in rarp

r318320: loader: add ip layer code into libstand

r318356: libstand: increase nfs max read size to 16k

r318678: Replacing iterating over rootpath by strsep(3).

r318754: Pass -N directly to ld via -Wl rather than passing it to the
compiler driver.

r318982: Pass a "FREEBSD" user-class in PXE dhcp request

r318986: add a comment on vendor index 19 and 20 to avoid confusion

r318987: Support URI scheme for root-path in netbooting

r318988: Always build tftpfs support along with nfs for pxeboot

r318989: Always issue the pxe request

r318990: Partially revert r314948

r318991: Document recent changes on pxeboot

r318992: Capitalize DHCP

r318993: Use the usual FreeBSD spelling for the DHCP user class

r318994: Catch with the change in the user class

r318999: Update the comments concerning net_parse_rootpath to reflect what
it is now

r319083: Followup on the user-class changes

r319084: Small cleanup in dev_net.c

r319085: use the same option list for dhcp discovery and request

r320011: Add chain loader support for loader

r320234: Make structure padding explicit in EFI_MEMORY_DESCRIPTOR

r320288: Allow Clang's integrated assembler to assemble boot0

r320304: loader.efi: Disable smbios for arm

r320467: loader: chain load relocate data declaration is bad

r320482: As with arm64 mark the EFI PE header as allocated on arm.

PR: 218473


/freebsd-11-stable/lib/libstand/Makefile
/freebsd-11-stable/lib/libstand/arp.c
/freebsd-11-stable/lib/libstand/bootp.c
/freebsd-11-stable/lib/libstand/bootp.h
/freebsd-11-stable/lib/libstand/bootparam.c
/freebsd-11-stable/lib/libstand/dosfs.c
/freebsd-11-stable/lib/libstand/dosfs.h
/freebsd-11-stable/lib/libstand/ether.c
/freebsd-11-stable/lib/libstand/globals.c
/freebsd-11-stable/lib/libstand/ip.c
/freebsd-11-stable/lib/libstand/net.c
/freebsd-11-stable/lib/libstand/net.h
/freebsd-11-stable/lib/libstand/netif.c
/freebsd-11-stable/lib/libstand/netif.h
/freebsd-11-stable/lib/libstand/nfs.c
/freebsd-11-stable/lib/libstand/rarp.c
/freebsd-11-stable/lib/libstand/rpc.c
/freebsd-11-stable/lib/libstand/rpc.h
/freebsd-11-stable/lib/libstand/stand.h
/freebsd-11-stable/lib/libstand/tftp.c
/freebsd-11-stable/lib/libstand/udp.c
/freebsd-11-stable/share/mk/bsd.stand.mk
/freebsd-11-stable/sys/boot/common/bcache.c
/freebsd-11-stable/sys/boot/common/commands.c
/freebsd-11-stable/sys/boot/common/dev_net.c
/freebsd-11-stable/sys/boot/common/disk.c
/freebsd-11-stable/sys/boot/common/md.c
/freebsd-11-stable/sys/boot/common/part.c
/freebsd-11-stable/sys/boot/efi/Makefile.inc
/freebsd-11-stable/sys/boot/efi/boot1/Makefile
/freebsd-11-stable/sys/boot/efi/boot1/boot1.c
/freebsd-11-stable/sys/boot/efi/boot1/zfs_module.c
/freebsd-11-stable/sys/boot/efi/fdt/Makefile
/freebsd-11-stable/sys/boot/efi/include/efidef.h
/freebsd-11-stable/sys/boot/efi/libefi/Makefile
/freebsd-11-stable/sys/boot/efi/libefi/efinet.c
/freebsd-11-stable/sys/boot/efi/libefi/efipart.c
/freebsd-11-stable/sys/boot/efi/libefi/time.c
/freebsd-11-stable/sys/boot/efi/loader/Makefile
/freebsd-11-stable/sys/boot/efi/loader/arch/arm/start.S
/freebsd-11-stable/sys/boot/efi/loader/arch/arm64/Makefile.inc
/freebsd-11-stable/sys/boot/efi/loader/main.c
/freebsd-11-stable/sys/boot/forth/menu.rc
/freebsd-11-stable/sys/boot/i386/boot0/Makefile
/freebsd-11-stable/sys/boot/i386/common/drv.h
/freebsd-11-stable/sys/boot/i386/libi386/Makefile
/freebsd-11-stable/sys/boot/i386/libi386/bioscd.c
/freebsd-11-stable/sys/boot/i386/libi386/biosdisk.c
/freebsd-11-stable/sys/boot/i386/libi386/biosmem.c
/freebsd-11-stable/sys/boot/i386/libi386/libi386.h
/freebsd-11-stable/sys/boot/i386/libi386/pxe.c
/freebsd-11-stable/sys/boot/i386/libi386/pxe.h
/freebsd-11-stable/sys/boot/i386/libi386/relocater_tramp.S
/freebsd-11-stable/sys/boot/i386/loader/Makefile
/freebsd-11-stable/sys/boot/i386/loader/chain.c
/freebsd-11-stable/sys/boot/i386/loader/help.i386
/freebsd-11-stable/sys/boot/i386/loader/main.c
/freebsd-11-stable/sys/boot/i386/pxeldr/pxeboot.8
/freebsd-11-stable/sys/boot/i386/zfsboot/zfsboot.c
/freebsd-11-stable/sys/boot/mips/beri/boot2/Makefile
/freebsd-11-stable/sys/boot/mips/beri/loader/beri_disk_cfi.c
/freebsd-11-stable/sys/boot/mips/beri/loader/beri_disk_sdcard.c
/freebsd-11-stable/sys/boot/ofw/libofw/ofw_disk.c
/freebsd-11-stable/sys/boot/ofw/libofw/ofw_net.c
/freebsd-11-stable/sys/boot/ofw/libofw/openfirm.c
/freebsd-11-stable/sys/boot/ofw/libofw/openfirm.h
/freebsd-11-stable/sys/boot/powerpc/ps3/ps3cdrom.c
/freebsd-11-stable/sys/boot/powerpc/ps3/ps3disk.c
/freebsd-11-stable/sys/boot/sparc64/loader/main.c
/freebsd-11-stable/sys/boot/uboot/lib/disk.c
/freebsd-11-stable/sys/boot/uboot/lib/net.c
/freebsd-11-stable/sys/boot/usb/storage/umass_loader.c
/freebsd-11-stable/sys/boot/userboot/userboot/main.c
/freebsd-11-stable/sys/boot/userboot/userboot/userboot_disk.c
/freebsd-11-stable/sys/boot/zfs/libzfs.h
/freebsd-11-stable/sys/boot/zfs/zfsimpl.c
329099 10-Feb-2018 kevans

MFC Loader Fixes 2017q1: r311458,r312237,r312314,r312374,r312947,r313042,
r313047,r313166,r313328,r313332,r313333,r313337,r313348,r313349,r313389,
r313442,r313451,r313575,r313645,r313710,r314114,r314213,r314275,r314945,
r314948,r315008,r315408,r315427,r315645,r315646,r315648,r315653,r315850,
r316064,r316078,r316079,r316100,r316104,r316111,r316112,r316171,r316279,
r316280,r316287,r316311,r316343,r316424,r316436

r311458: Use compiler driver to link BERI boot loaders

r312237: loader.efi: find_currdev() can leak memory

r312314: loader: move device path definitions to include/efidevp.h

r312374: loader: efi devpath api usage should be more aware of NULL pointers

r312947: Remove "-Xassembler -G0" from CFLAGS.

r313042: loader.efi environment related cleanups

r313047: loader: disk/part api needs to use uint64_t offsets

r313166: loader: libefi/env.c warnings in arm build

r313328: loader: Implement disk_ioctl() to support DIOCGSECTORSIZE and
DIOCGMEDIASIZE.

r313332: loader: bcache read ahead block count should take account the large
sectors

r313333: loader: Replace EFI part devices.

r313337: loader: 313329 missed ZFS guard in loader/main.c

r313348: loader: biosdisk fix for 2+TB disks

r313349: loader: disk io should not use alloca()

r313389: efipart is also using the '%S' printf format, add -Wno-format for
it.

r313442: loader: possible NULL pointer dereference in efipart.c

r313451: loader: possible NULL pointer dereference in bcache.c

r313575: makefs: make the buffer functions look exactly like the kernel ones

r313645: loader: implement MEDIA_FILEPATH_DP support in efipart

r313710: loader: cstyle fixes and DIOCGMEDIASIZE should use uint64_t

r314114: Use LDFLAGS with CC instead of _LDFLAGS.

r314213: Remove control+r handling from geliboot's pwgets()

r314275: Remove unused macro from common/drv.c.

r314945: Some style(9) fixes. No functional changes.

r314948: Try to extract the RFC1048 data from PXE.

r315008: r314948 seems to be missing a variable or two that will break

r315408: loader: remove open_disk cache

r315427: loader: biosdisk should report IO error from INT13

r315645: loader: disk_cleanup was left in userboot_disk.c

r315646: loader: pxe.h constants have wrong values

r315648: libstand: verify value provided by nfs.read_size

r315653: loader: verify the value from dhcp.interface-mtu and use snprintf
o set mtu

r315850: The original author abused Nd (one-line description, used by
makewhatis)

r316064: Fix build with path names with 'align' or 'nop' in them.

r316078: gpt*boot: Save a bit more memory when LOADER_NO_GELI_SUPPORT is
specified

r316079: Simply retire the sedification of the boot2.s file.

r316100: Remove -fno-guess-branch-probability and -fno-unit-at-a-time.

r316104: Use `NO_WCAST_ALIGN` instead of spelling it out as -Wno-cast-align
in CFLAGS

r316111: loader: move bios getsecs into time.c

r316112: loader: ls command should display file types properly

r316171: xfsread inlined uses more space, so remove the inline tag.

r316279: loader: efipart should check disk size from partition table

r316280: loader: simplify efi_zfs_probe and avoid double probing for zfs.

r316287: Remove OLD_NFSV2 from loader and libstand

r316311: Add explicit_bzero() to libstand, and switch GELIBoot to using it

r316343: Implement boot-time encryption key passing (keybuf)

r316424: Fix sparc64 build broken by r316343 and r316076

r316436: Restore EFI boot environment functionality broken in r313333

PR: 216940 217298 217935


/freebsd-11-stable/lib/libstand/Makefile
/freebsd-11-stable/lib/libstand/bootp.c
/freebsd-11-stable/lib/libstand/bootp.h
/freebsd-11-stable/lib/libstand/nfs.c
/freebsd-11-stable/lib/libstand/nfsv2.h
/freebsd-11-stable/lib/libstand/stand.h
/freebsd-11-stable/sys/boot/common/bcache.c
/freebsd-11-stable/sys/boot/common/bootstrap.h
/freebsd-11-stable/sys/boot/common/dev_net.c
/freebsd-11-stable/sys/boot/common/disk.c
/freebsd-11-stable/sys/boot/common/disk.h
/freebsd-11-stable/sys/boot/common/ls.c
/freebsd-11-stable/sys/boot/common/part.c
/freebsd-11-stable/sys/boot/common/part.h
/freebsd-11-stable/sys/boot/efi/include/efidevp.h
/freebsd-11-stable/sys/boot/efi/include/efilib.h
/freebsd-11-stable/sys/boot/efi/libefi/Makefile
/freebsd-11-stable/sys/boot/efi/libefi/devpath.c
/freebsd-11-stable/sys/boot/efi/libefi/efinet.c
/freebsd-11-stable/sys/boot/efi/libefi/efipart.c
/freebsd-11-stable/sys/boot/efi/libefi/env.c
/freebsd-11-stable/sys/boot/efi/libefi/wchar.c
/freebsd-11-stable/sys/boot/efi/loader/conf.c
/freebsd-11-stable/sys/boot/efi/loader/devicename.c
/freebsd-11-stable/sys/boot/efi/loader/main.c
/freebsd-11-stable/sys/boot/forth/beastie.4th.8
/freebsd-11-stable/sys/boot/forth/loader.4th
/freebsd-11-stable/sys/boot/geli/Makefile
/freebsd-11-stable/sys/boot/geli/geliboot.c
/freebsd-11-stable/sys/boot/geli/geliboot.h
/freebsd-11-stable/sys/boot/geli/geliboot_crypto.c
/freebsd-11-stable/sys/boot/geli/geliboot_internal.h
/freebsd-11-stable/sys/boot/geli/pwgets.c
/freebsd-11-stable/sys/boot/i386/boot2/Makefile
/freebsd-11-stable/sys/boot/i386/boot2/boot2.c
/freebsd-11-stable/sys/boot/i386/btx/lib/btxv86.h
/freebsd-11-stable/sys/boot/i386/common/bootargs.h
/freebsd-11-stable/sys/boot/i386/common/drv.c
/freebsd-11-stable/sys/boot/i386/gptboot/Makefile
/freebsd-11-stable/sys/boot/i386/gptboot/gptboot.c
/freebsd-11-stable/sys/boot/i386/gptzfsboot/Makefile
/freebsd-11-stable/sys/boot/i386/libi386/bioscd.c
/freebsd-11-stable/sys/boot/i386/libi386/biosdisk.c
/freebsd-11-stable/sys/boot/i386/libi386/bootinfo32.c
/freebsd-11-stable/sys/boot/i386/libi386/bootinfo64.c
/freebsd-11-stable/sys/boot/i386/libi386/pxe.c
/freebsd-11-stable/sys/boot/i386/libi386/pxe.h
/freebsd-11-stable/sys/boot/i386/libi386/time.c
/freebsd-11-stable/sys/boot/i386/loader/Makefile
/freebsd-11-stable/sys/boot/i386/loader/main.c
/freebsd-11-stable/sys/boot/i386/zfsboot/zfsboot.c
/freebsd-11-stable/sys/boot/mips/beri/boot2/Makefile
/freebsd-11-stable/sys/boot/mips/beri/common/common.ldscript
/freebsd-11-stable/sys/boot/mips/beri/loader/beri_disk_cfi.c
/freebsd-11-stable/sys/boot/mips/beri/loader/beri_disk_sdcard.c
/freebsd-11-stable/sys/boot/mips/beri/loader/loader.ldscript
/freebsd-11-stable/sys/boot/sparc64/loader/Makefile
/freebsd-11-stable/sys/boot/uboot/lib/disk.c
/freebsd-11-stable/sys/boot/usb/storage/umass_loader.c
/freebsd-11-stable/sys/boot/userboot/userboot/userboot_disk.c
/freebsd-11-stable/sys/boot/zfs/libzfs.h
/freebsd-11-stable/sys/boot/zfs/zfs.c
/freebsd-11-stable/sys/crypto/intake.h
/freebsd-11-stable/sys/geom/eli/g_eli.c
/freebsd-11-stable/sys/geom/eli/g_eli.h
/freebsd-11-stable/sys/opencrypto/crypto.c
/freebsd-11-stable/sys/sys/linker.h
/freebsd-11-stable/usr.sbin/makefs/ffs.c
/freebsd-11-stable/usr.sbin/makefs/ffs/buf.c
/freebsd-11-stable/usr.sbin/makefs/ffs/buf.h
/freebsd-11-stable/usr.sbin/makefs/ffs/ffs_alloc.c
/freebsd-11-stable/usr.sbin/makefs/ffs/ffs_balloc.c
329070 09-Feb-2018 kevans

MFC r327606: Handle misconfigured/nonexistent pcidev for comconsole instead
of BTX panic.

[This is effectively a direct commit to stable/11 due to path restructuring
in head. Diffs have simply been applied to previous location]

PR: 203319

329011 08-Feb-2018 kevans

MFC r307322,r307323,r307324,r307326,r307327,r307338,r307879,r307908,r307911,
r307942,r307950,r307951,r307954,r307955,r308125,r308195,r308476,r308534,
r308535,r308776,r308843,r310236,r310726: Loader fixes, 2016q4

r307322: Remove /boot/boot.conf, deprecated for 16 years

r307323: Remove fetching of pInterp.

r307324: Create a new linker set, Xficl_compile_set which contains a list of
functions to call to register new forth words.

r307326: In UEFI mode expose the SMBIOS anchor base address via kenv

r307327: Update i386 build of loader.efi (but leave it disabled) so that we
at least build it now.

r307338: Create a pcibios-version environment FORTH word.

r307879: Preliminary support for EFI in boot loader.

r307908: Fix the build on both arm64 and when WITHOUT_FORTH is defined.

r307911: Add better comment...

r307942: Really make WITHOUT_FORTH (MK_FORTH==no) work.

r307950: Add it (Makefile.ficl) to the right place

r307951: Fix two backwards tests.

r307954: Back out the move to the loader script from -N.

r307955: LIBSTAND goes last, so put it last here too.

r308125: In loader.efi, instead of exiting directly, try to fallback.

r308195: efinet_dev_print should honor verbose option.

r308476: boot/forth spelling issue in forth word

r308534: The file_loadraw function grew an argument, update install function

r308535: Add support for LOADER_RC setting in the pkgfs manifes

r308776: loader: zfs toplevel vdev must have spa set.

r308843: loader: smbios version check is not correct

r310236: Renumber license clauses to avoid skipping #3

r310726: cdboot: add explict suffix to ambiguous or instruction

PR: 214375


/freebsd-11-stable/sys/boot/Makefile.ficl
/freebsd-11-stable/sys/boot/common/Makefile.inc
/freebsd-11-stable/sys/boot/common/bootstrap.h
/freebsd-11-stable/sys/boot/common/install.c
/freebsd-11-stable/sys/boot/common/interp.c
/freebsd-11-stable/sys/boot/common/interp_forth.c
/freebsd-11-stable/sys/boot/common/loader.8
/freebsd-11-stable/sys/boot/common/newvers.sh
/freebsd-11-stable/sys/boot/common/pnp.c
/freebsd-11-stable/sys/boot/efi/libefi/Makefile
/freebsd-11-stable/sys/boot/efi/libefi/efinet.c
/freebsd-11-stable/sys/boot/efi/libefi/env.c
/freebsd-11-stable/sys/boot/efi/loader/Makefile
/freebsd-11-stable/sys/boot/efi/loader/arch/amd64/ldscript.amd64
/freebsd-11-stable/sys/boot/efi/loader/arch/arm/ldscript.arm
/freebsd-11-stable/sys/boot/efi/loader/arch/arm64/ldscript.arm64
/freebsd-11-stable/sys/boot/efi/loader/arch/i386/efimd.c
/freebsd-11-stable/sys/boot/efi/loader/arch/i386/elf32_freebsd.c
/freebsd-11-stable/sys/boot/efi/loader/arch/i386/exec.c
/freebsd-11-stable/sys/boot/efi/loader/arch/i386/ldscript.i386
/freebsd-11-stable/sys/boot/efi/loader/main.c
/freebsd-11-stable/sys/boot/ficl/Makefile
/freebsd-11-stable/sys/boot/ficl/efi.c
/freebsd-11-stable/sys/boot/ficl/ficl.h
/freebsd-11-stable/sys/boot/ficl/i386/sysdep.c
/freebsd-11-stable/sys/boot/ficl/loader.c
/freebsd-11-stable/sys/boot/ficl32/Makefile
/freebsd-11-stable/sys/boot/forth/Makefile.inc
/freebsd-11-stable/sys/boot/forth/efi.4th
/freebsd-11-stable/sys/boot/forth/loader.4th
/freebsd-11-stable/sys/boot/forth/support.4th
/freebsd-11-stable/sys/boot/i386/Makefile.inc
/freebsd-11-stable/sys/boot/i386/cdboot/cdboot.S
/freebsd-11-stable/sys/boot/i386/gptboot/Makefile
/freebsd-11-stable/sys/boot/i386/gptzfsboot/Makefile
/freebsd-11-stable/sys/boot/i386/libi386/Makefile
/freebsd-11-stable/sys/boot/i386/libi386/biospci.c
/freebsd-11-stable/sys/boot/i386/libi386/libi386.h
/freebsd-11-stable/sys/boot/i386/libi386/smbios.c
/freebsd-11-stable/sys/boot/i386/loader/Makefile
/freebsd-11-stable/sys/boot/mips/beri/loader/loader.ldscript
/freebsd-11-stable/sys/boot/pc98/libpc98/Makefile
/freebsd-11-stable/sys/boot/zfs/zfsimpl.c
/freebsd-11-stable/targets/pseudo/userland/misc/Makefile.depend
329010 08-Feb-2018 kevans

MFC r303555,r303556,r303936,r303962,r304317,r304532,r305026,r305107,r305132,
r305178,r305353,r305814,r306159,r306380,r306504: Loader fixes, 2016q3

r303555: bcache should support reads shorter than sector size

r303556: Improve boot loader quote parsing

r303936: Add kernel environment variables under smbios.system

r303962: Add the missing space between .asciz directive and opening quote
for some lines with #ifdef BTXLDR_VERBOSE/#endif

r304317: boot1.efi Free() should check for NULL to provide consistent
behavior

r304532: Replace sprintf -> snprintf for command_errbuf provisioned from
dynamic content.

r305026: Emulate efi_cons_poll when WaitForKey is not available

r305107: Create a hook 'post-initialize' for people that want to define
something to read in .conf files after all other .conf files for the purpose
of overriding.

r305132: Remove accidentally committed stray comment.

r305178: bd_int13probe() should check extended info if sector info is bad

r305353: Don't use -N to set the OMAGIC with data and text writeable and
data not page aligned.

r305814: ufsread: Do not cast struct direct from void *

r306159: Consistently declare getsecs(void) with proper return type and void
when no arguments are present.

r306380: loader command interpreter should reset command_errmsg

r306504: Fix a cluster of bugs in list EFI environment variables

PR: 204602, 211958, 211958
Relnotes: yes ("Improve boot loader quote parsing")


/freebsd-11-stable/sys/boot/common/bcache.c
/freebsd-11-stable/sys/boot/common/boot.c
/freebsd-11-stable/sys/boot/common/bootstrap.h
/freebsd-11-stable/sys/boot/common/commands.c
/freebsd-11-stable/sys/boot/common/interp.c
/freebsd-11-stable/sys/boot/common/interp_forth.c
/freebsd-11-stable/sys/boot/common/interp_parse.c
/freebsd-11-stable/sys/boot/common/ls.c
/freebsd-11-stable/sys/boot/common/module.c
/freebsd-11-stable/sys/boot/common/ufsread.c
/freebsd-11-stable/sys/boot/efi/boot1/boot1.c
/freebsd-11-stable/sys/boot/efi/libefi/efi_console.c
/freebsd-11-stable/sys/boot/efi/libefi/time.c
/freebsd-11-stable/sys/boot/efi/libefi/time_event.c
/freebsd-11-stable/sys/boot/efi/loader/arch/amd64/framebuffer.c
/freebsd-11-stable/sys/boot/efi/loader/main.c
/freebsd-11-stable/sys/boot/fdt/fdt_loader_cmd.c
/freebsd-11-stable/sys/boot/forth/loader.4th
/freebsd-11-stable/sys/boot/i386/Makefile.inc
/freebsd-11-stable/sys/boot/i386/boot.ldscript
/freebsd-11-stable/sys/boot/i386/boot0/Makefile
/freebsd-11-stable/sys/boot/i386/boot2/Makefile
/freebsd-11-stable/sys/boot/i386/btx/btx/Makefile
/freebsd-11-stable/sys/boot/i386/btx/btxldr/Makefile
/freebsd-11-stable/sys/boot/i386/btx/btxldr/btxldr.S
/freebsd-11-stable/sys/boot/i386/cdboot/Makefile
/freebsd-11-stable/sys/boot/i386/gptboot/Makefile
/freebsd-11-stable/sys/boot/i386/gptzfsboot/Makefile
/freebsd-11-stable/sys/boot/i386/libi386/biosdisk.c
/freebsd-11-stable/sys/boot/i386/libi386/pxe.c
/freebsd-11-stable/sys/boot/i386/libi386/smbios.c
/freebsd-11-stable/sys/boot/i386/mbr/Makefile
/freebsd-11-stable/sys/boot/i386/pmbr/Makefile
/freebsd-11-stable/sys/boot/i386/pxeldr/Makefile
/freebsd-11-stable/sys/boot/i386/zfsboot/Makefile
/freebsd-11-stable/sys/boot/ofw/libofw/ofw_time.c
/freebsd-11-stable/sys/boot/pc98/Makefile.inc
/freebsd-11-stable/sys/boot/pc98/boot0/Makefile
/freebsd-11-stable/sys/boot/pc98/boot2/Makefile
/freebsd-11-stable/sys/boot/pc98/btx/btx/Makefile
/freebsd-11-stable/sys/boot/pc98/btx/btxldr/Makefile
/freebsd-11-stable/sys/boot/pc98/cdboot/Makefile
/freebsd-11-stable/sys/boot/powerpc/kboot/main.c
/freebsd-11-stable/sys/boot/powerpc/ps3/main.c
/freebsd-11-stable/sys/boot/uboot/lib/time.c
328889 05-Feb-2018 kevans

MFC r308434, 308827

MFC r308434: Loader paged/pageable data is not always paged.
MFC r308827: lsdev device name section headers should be printed by dv_print
callback.

328866 05-Feb-2018 kevans

MFC r304321,304753,304754,306751,316077,316110:
SHA512, skein, large block support for loader zfs

MFC r304321: Add SHA512, skein, large blocks support for loader zfs.
MFC r304753: loader: zio_checksum_verify() must test spa for NULL pointer
MFC r304754: r304321 broken bhyve zvol VM bhyveload hang 100% WCPU
MFC r306751: Disable loop unrolling in skein for sys/boot
MFC r316077: Unbreak compilation with gcc 4.2.1
MFC r316110: Use `-Wno-missing-declarations` with CWARNFLAGS for skein.c

323256 07-Sep-2017 rlibby

MFC r322329:

i386/boot2: -fno-asynchronous-unwind-tables for gcc

319024 28-May-2017 ngie

MFC r309412,r316109,r316132:

r309412 (by imp):

dd is currently a bootstrap tool. It really doesn't have any business
being a bootstrap tool. However, for reproducible build output,
FreeBSD added dd status=none because it was otherwise difficult to
suppress the status information, but retain any errors that might
happen. There's no real reason that dd has to be a build tool, other
than we use status=none unconditional. Remove dd from a bootstrap tool
entirely by only using status=none when available. This may also help
efforts to build the system on non-FreeBSD hosts as well.

r316109:

Don't hardcode input files for stage 1/2 bootloaders; use .ALLSRC instead

This is a better pattern to follow when creating the bootloaders and doing
the relevant space checks to make sure that the sizes aren't exceeded (and
thus, copy-pasting is a bit less error prone).

r316132:

Parameterize out 7680 (15 * 512) as BOOT2SIZE, similar to sys/boot/i386/zfsboot/...

This is being done to make it easier to change in the future--this action might be
needed sooner rather than later because of gcc 6.3.0 bailing, stating that there
is negative free space left (deficit) in the boot2 bootloader.

318019 09-May-2017 royger

MFC r316754: loader/multiboot: fix multiboot loading

Sponsored by: Citrix Systems R&D

313355 06-Feb-2017 tsoome

MFC r309369,310850,310853:

libstand: dosfs cstyle cleanup for return keyword.
dosfs support in libstand is broken since r298230

PR: 214423
Submitted by: Mikhail Kupchik
Reported by: Mikhail Kupchik
Approved by: imp (mentor)

313353 06-Feb-2017 tsoome

MFC r310845: boot2 will deadlock if extended keys are used on text input

Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D8608

312556 20-Jan-2017 emaste

MFC r310267: Deduplicate loader vers.c Makefile rules

The Makefile rule to create vers.c for loader version info was
previously duplicated in each of the various loader Makefiles.
Instead, share a common rule in Makefile.inc.

Sponsored by: The FreeBSD Foundation

312318 17-Jan-2017 emaste

MFC r310225: Reduce boot loader version string duplication

Instead of repeating "%s, Revision %s" "(%s %s)" in each loader, just
create the full version string in vers.c

311908 11-Jan-2017 emaste

MFC r310702: btxldr: process all PT_LOAD segments, not just the first two

With default settings GNU ld generates two PT_LOADs for loader.sym while
LLD generates three, because it creates a rodata segment. Previously
btxldr terminated phdr processing after two PT_LOADs. Remove the early
termination to process all PT_LOADs.

Sponsored by: The FreeBSD Foundation

311220 04-Jan-2017 emaste

MFC r310661: loader: use strip -o instead of cp and strip in place

It is simpler and cleaner to have strip produce the stripped output
directly than copying the input to the output first.

308914 21-Nov-2016 avg

MFC r308089: zfsbootcfg: a simple tool to set next boot (one time)
options for zfsboot

308722 16-Nov-2016 bapt

MFC r308477:

make pxeboot consistent with common/dev_net.c

Always define boot.netif.server in kenv in pxeboot
Add "boot.tftproot.server" to kenv when pxeboot uses tftpfs
Change the code order when setting env for TFTP or NFS to be the same as
common/dev_net.c

Reported by: tsoome

307632 19-Oct-2016 bapt

MFC: 304677, 304680, 305125, 305770, 305769

r304677:
Add tftpfs support for the EFI loader

Allow netbooting on efi without having to setup any NFS server by rebuilding the
loader with LOADER_TFTP_SUPPORT like for the i386 pxeloader

r305125:
Netboot: allow both tftpfs and nfs in both pxeboot and loader.efi

Add a new 'netproto' variable which can be set for now to
NET_TFTP or NET_NFS (default to NET_NONE)

From the dhcp options if one sets the root-path option to:
"ip:path", the loader will consider it is booting over NFS
(meaning same behaviour as the default current behaviour)

if the dhcp option "tftp server address" is set (option 150)
the loader will consider it is booting over tftpfs, it will then
consider the root-path options with 2 possible case
1. "path" then the IP of the tftp server will be the one passed by
the option 150, and the files will be retrieved under "path" on the tftp
server
2. "ip:path" then the IP of the tftp server will be the one passed in
the option "overwritting the IP from the option 150.

We could not "abuse" the rootpath option in the form or tftp://ip:path because
this is already used for other purpose by iPXE preventing any chainload from
iPXE to the FreeBSD loader.

Given at each open(), the loader loops over all available filesystems and keep
the "best" error, we needed to prevent tftpfs to fallback on nfs and vice versa.
the tftpfs and nfs implementation in libstand now return EINVAL early if
'netproto' for that purpose.

Relnotes: yes
Sponsored by: Gandi.net

307505 17-Oct-2016 sephe

MFC 305588

pxeboot: Add nfs.read_size tunable.

Increase this tunable improves kernel loading speed.

Submitted by: Jun Su <junsu microsoft com>
Reviewed by: rpokala, wblock (previous version)
Obtained from: DragonFlyBSD
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7756

305614 08-Sep-2016 pfg

MFC r303891, r303892:
sys: replace comma with semicolon when pertinent.

Uses of commas instead of a semicolons can easily go undetected. The comma
can serve as a statement separator but this shouldn't be abused when
statements are meant to be standalone.

305457 06-Sep-2016 avg

MFC r303738: report sector size and number of sectors in lsdev output
for bios disks

305232 01-Sep-2016 gjb

MFC r304966 (peter):
The read-ahead code from r298230 made it likely the boot code would read
beyond the end of disk. r298900 added code to prevent this. Some BIOSes
cause significant delays if asked to read past end-of-disk.

We never trusted the BIOS to accurately report the sectorsize of disks
before and this set of changes. Unfortuately they interact badly with
the infamous >2TB wraparound bugs. We have a number of relatively-recent
machines in the FreeBSD.org cluster where the BIOS reports 3TB disks as 1TB.

With pre-r298900 they work just fine. After r298900 they stop working if
the boot environment attempts to access anything outside the first 1TB on
the disk. 'ZFS: I/O error, all block copies unavailable' etc. It affects
both UFS and ZFS if they try to boot from large volumes.

This change replaces the blind trust of the BIOS end-of-disk reporting
with a read-ahead clip to prevent reads crossing the of end-of-disk
boundary. Since 2^32 (2TB) size reporting truncation is not uncommon,
the clipping is done on 2TB aliases of the reported end-of-disk.
ie: a 3TB disk reported as 1TB has readahead clipped at 1TB, 3TB, 5TB, ...
as one of them is likely to be the real end-of-disk.

This should make the loader on these broken machines behave the same as
traditional pre-r298900 loader behavior, without disabling read-ahead.

PR: 212139
Sponsored by: The FreeBSD Foundation

302408 08-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
300257 20-May-2016 allanjude

Fixup the geliboot sector rounding code

Replace all rounding with the round{up,down}2 macros
a missing set of braces caused the previous code to be incorrect

replace alloca() with malloc() because alloca() can return an allocation
that is actually invalid, causing boot to fail

Reviewed by: emaste, ed
Thanks To: peter
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D6213


300117 18-May-2016 imp

Fix several instances where the boot loader ignored pager_output
return value when it could return 1 (indicating we should stop).
Fix a few instances of pager_open() / pager_close() not being called.
Actually use these routines for the environment variable printing code
I just committed.


299997 17-May-2016 peter

Attempt to fix r299660:
slba is used only for the GPT case.
elba is used if either GPT or LOADER_GELI_SUPPORT is enabled.


299660 13-May-2016 ngie

Put slba and elba under LOADER_GELI_SUPPORT ifdef to mute warning about them being
unused in the non-GELI case

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division


299659 13-May-2016 ngie

Remove unused const variable

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division


299655 13-May-2016 ngie

Add missing prototype for getchar(..)

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division


298949 03-May-2016 peter

Change a rounding operation that had missing braces into a roundup2()
macro. Adjust the buffer clipping code to work as expected.

This prevented a number of machines in the FreeBSD.org cluster from
booting due to "ZFS: i/o error - all block copies unavailable"
after an unclean shutdown.


298900 01-May-2016 allanjude

bcache read ahead may attempt to read past end of disk

The new bcache code does not know the size of the disk, and therefore may attempt to read past the end of the disk while trying to fill its read-ahead cache.

This is usually not an issue, it fails gracefully on all of my machines, but some BIOSes seem to retry the reads for up to 30 seconds each, resulting in a long stall during boot

Submitted by: Toomas Soome <tsoome@me.com>
Reviewed by: jhb, np
Differential Revision: https://reviews.freebsd.org/D6109


298826 30-Apr-2016 pfg

sys/boot: spelling fixes in comments.

No functional change.


298230 18-Apr-2016 allanjude

A new implementation of the loader block cache

The block cache implementation in loader has proven to be almost useless, and in worst case even slowing down the disk reads due to insufficient cache size and extra memory copy.
Also the current cache implementation does not cache reads from CDs, or work with zfs built on top of multiple disks.
Instead of an LRU, this code uses a simple hash (O(1) read from cache), and instead of a single global cache, a separate cache per block device.
The cache also implements limited read-ahead to increase performance.
To simplify read ahead management, the read ahead will not wrap over bcache end, so in worst case, single block physical read will be performed to fill the last block in bcache.

Booting from a virtual CD over IPMI:
0ms latency, before: 27 second, after: 7 seconds
60ms latency, before: over 12 minutes, after: under 5 minutes.

Submitted by: Toomas Soome <tsoome@me.com>
Reviewed by: delphij (previous version), emaste (previous version)
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D4713


297954 14-Apr-2016 imp

Deprecate using hints.acpi.0.rsdp to communicate the RSDP to the
system. This uses the hints mechnanism. This mostly works today
because when there's no static hints (the default), this value can be
fetched from the hint. When there is a static hints file, the hint
passed from the boot loader to the kernel is ignored, but for the BIOS
case we're able to find it anyway. However, with UEFI, the fallback
doesn't work, so we get a panic instead.

Switch to acpi.rsdp and use TUNABLE_ULONG_FETCH instead. Continue to
generate the old values to allow for transitions. In addition, fall
back to the old method if the new method isn't present.

Add comments about all this.

Differential Revision: https://reviews.freebsd.org/D5866


297629 06-Apr-2016 allanjude

Fix GELIBoot support for GELI sector size is > 512

Add support for 4k sector GELI encrypted partitions to the bootloader
This is the default created by the installer

Because the IV is different for each sector, and the XTS tweak carries forward you can not decrypt a partial sector if the starting offset is not 0

Make boot2 and the loader read in 4k aligned chunks

Reviewed by: ed, oshogbo
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D5820


297283 26-Mar-2016 bdrewery

Implement (ACFLAGS|CFLAGS|CXXFLAGS).SRC globally.

Sponsored by: EMC / Isilon Storage Division


297154 21-Mar-2016 bdrewery

DIRDEPS_BUILD: Update dependencies.

Sponsored by: EMC / Isilon Storage Division


297151 21-Mar-2016 ian

If the dhcp server provided an interface-mtu option, transcribe the value
to the boot.netif.mtu env var, which will be picked up by pre-existing code
in nfs_mountroot() and used to configure the interface accordingly.

This should bring the same functionality when the bootp/dhcp work is done
by loader(8) as r297150 does for the in-kernel BOOTP case.


296963 16-Mar-2016 allanjude

Implement GELI (AES-XTS and AES-CBC only) in gptboot and gptzfsboot

Allows booting from a GELI encrypted root file system, via UFS or ZFS

Reviewed by: gnn, smh (previous version), delphij (previous version)
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D4593


296706 11-Mar-2016 bdrewery

Add more .NOMETA missed in r291320

Sponsored by: EMC / Isilon Storage Division


296705 11-Mar-2016 bdrewery

Revert r269030. CLEANFILES is already added to .NOPATH since r241298.

Sponsored by: EMC / Isilon Storage Division


295989 24-Feb-2016 bdrewery

DIRDEPS_BUILD: Regenerate without local dependencies.

These are no longer needed after the recent 'beforebuild: depend' changes
and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports
skipping 'make depend'.

Sponsored by: EMC / Isilon Storage Division


295757 18-Feb-2016 emaste

Remove dd xfer stats emitted during buildworld

They result in gratuitous differences when comparing build log output.


295398 08-Feb-2016 emaste

Restore kgzldr on i386 only

I previously disconnected kgzdr based on a misunderstanding.

I'd still like to transition to supporting only the loader(8)-based
boot path for handling compressed kernels, but that can follow the
standard deprecation procedure.

This reverts r291113.

Requested by: dteske


294925 27-Jan-2016 imp

Fix mistake when transitioning to the new defines with ZFS loader. I
hate adding yet another define, but it is the lessor of the evil
choices available. Kill another evil by removing PATH_BOOT3 and
replacing it with PATH_LOADER or PATH_LOADER_ZFS as appropriate.

PR: 206659


294766 26-Jan-2016 imp

RBX_ defines are in rbx.h, move it there.

Differential Revision: https://reviews.freebsd.org/D5038


294765 26-Jan-2016 imp

Move all the separate copies of the same strings into paths.h. There's
nothing machine specific about these.

Differential Revision: https://reviews.freebsd.org/D5038


294072 15-Jan-2016 allanjude

Move init_zfs_bootenv to sys/boot/zfs/zfs.c instead of having a copy in each loader

While here, add a filter to ignore special datasets

MFC after: 3 days
Sponsored by: ScaleEngine Inc.


293724 12-Jan-2016 smh

Enable warnings in EFI boot code

Set WARNS if not set for EFI boot code and fix the issues highlighted by
setting it.

Most components are set to WARNS level 6 with few being left at lower
levels due to the amount of changes needed to fix at higher levels.

Error types fixed:
* Missing / invalid casts
* Missing inner structs
* Unused vars
* Missing static for internal only funcs
* Missing prototypes
* Alignment changes
* Use of uninitialised vars
* Unknown pragma (intrinsic)
* Missing types etc due to missing includes
* printf formatting types

Reviewed by: emaste (in part)
MFC after: 2 weeks
X-MFC-With: r293268
Sponsored by: Multiplay
Differential Revision: https://reviews.freebsd.org/D4839


293612 09-Jan-2016 allanjude

Return call to init_zfs_bootenv to its previous location

When called to early, new_currdev->d_type was not yet set
zfs_fmtdev() would then return null

While here, guard call to init_zfs_bootenv with if d_type == DEVT_ZFS

Reported by: tsoome at me.com
MFC after: 3 days
Sponsored by: ScaleEngine Inc.


293454 09-Jan-2016 allanjude

Only call init_zfs_bootenv() when the system was booted with ZFS

Add a few other safeguards to ensure things do not break when the
boot device cannot be determined

Reported by: flo
MFC after: 3 days
Sponsored by: ScaleEngine Inc.


293414 08-Jan-2016 allanjude

Add support for ZFS Boot Environments to userboot (for bhyve and others)

While here, also fix a possible null pointer

Reported by: lattera
MFC after: 3 days
Sponsored by: ScaleEngine Inc.


293001 31-Dec-2015 allanjude

Introduce the ZFS Boot Environments menu to the loader menu

If the system was booted with ZFS, a new menu item (#7) appears
It contains an autogenerated list of ZFS Boot Environments

This allows the user to switch to an alternate root file system
Use Cases:
- Revert a failed upgrade
- Concurrently run different versions of FreeBSD with common home directory
- Easier integration with the sysadmin/beadm utility

Requested by: many
Reviewed by: dteske
MFC after: 10 days
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D3167


292682 24-Dec-2015 jhb

Fix remaining direct tests of the carry flag in the v86 %eflags via a
magic number to use V86_CY() instead. These should have been fixed as
part of the cleanup in r226746 but were missed.

The md5 sums of the object files were unchanged, so there should be no
functional change.

PR: 205424
Submitted by: Alexander Kuleshov <kuleshovmail@gmail.com>
MFC after: 1 week


292486 20-Dec-2015 ngie

Add missing smbios.h #include to mute a -Wimplicit-function-declaration warning
after r279222

Reported by: Jenkins
Sponsored by: EMC / Isilon Storage Division


292345 16-Dec-2015 bapt

Use human readable representation of ip for the pxeboot.ip kenv
While here use colon as a separator for pxeboot.hwaddr kenv

Sponsored by: Gandi.net


292344 16-Dec-2015 bapt

pxeboot: make the tftp loader use the option root-path directive

pxeboot in tftp loader mode (when built with LOADER_TFTP_SUPPORT) now
prefix all the path to open with the path obtained via the option 'root-path'
directive.

This allows to be able to use the traditional content /boot out of box. Meaning
it now works pretty much like all other loaders. It simplifies hosting hosting
multiple version of FreeBSD on a tftp server.

As a consequence, pxeboot does not look anymore for a pxeboot.4th (which was
never provided)

Note: that pxeboot in tftp loader mode is not built by default.

Reviewed by: rpokala
Relnotes: yes
Sponsored by: Gandi.net
Differential Revision: https://reviews.freebsd.org/D4590


291563 01-Dec-2015 bdrewery

META MODE: Update dependencies with 'the-lot' and add missing directories.

This is not properly respecting WITHOUT or ARCH dependencies in target/.
Doing so requires a massive effort to rework targets/ to do so. A
better approach will be to either include the SUBDIR Makefiles directly
and map to DIRDEPS or just dynamically lookup the SUBDIR. These lose
the benefit of having a userland/lib, userland/libexec, etc, though and
results in a massive package. The current implementation of targets/ is
very unmaintainable.

Currently rescue/rescue and sys/modules are still not connected.

Sponsored by: EMC / Isilon Storage Division


291320 25-Nov-2015 bdrewery

META MODE: Don't create .meta files when symlinking sources into the obj directory.

Tracking these leads to situations where meta mode will consider the
file to be out of date if /bin/sh or /bin/ln are newer than the source
file. There's no reason for meta mode to do this as make is already
handling the rebuild dependency fine.

Sponsored by: EMC / Isilon Storage Division


291113 20-Nov-2015 emaste

Disconnect unused kgzldr from sys/boot/i386

Sponsored by: The FreeBSD Foundation


291106 20-Nov-2015 bdrewery

Remove disconnected boot0ext.

This was [re-]added in r127458 (apparently with disconnected history as well)
and never connected to the build.

It is no longer relevant for modern systems from the past 20 years.

Discussed with: jhb
Sponsored by: EMC / Isilon Storage Division


289031 08-Oct-2015 cperciva

Change gptldr from relocating 0xfff1 bytes of boot2 to relocating 0x20000
bytes of boot2. Since we're in 16-bit mode, we can't copy all 128kB at
once; instead we loop four times and copy 32 kB each time.

This change was made necessary by an upcoming increase in the size of the
boot2 binary; should it increase further, the COPY_BLKS value can be
adjusted without anyone needing to remember 8086 assembly language again.

Requested by: allanjude
Tested by: allanjude
MFC after: 1 week


288228 25-Sep-2015 bdrewery

META_MODE: Remove DEP_MACHINE from Makefile.depend files.

This has not been needed since r246865 in projects/bmake.

Sponsored by: EMC / Isilon Storage Division


288226 25-Sep-2015 bdrewery

META_MODE: Remove DEP_RELDIR from Makefile.depend files.

This has not been needed since r284171 in projects/bmake.

Sponsored by: EMC / Isilon Storage Division


287227 27-Aug-2015 imp

Use CFLAGS_NO_SIMD in preference to varying lists of -mno-xxxx flags.
Go ahead and defined -D_STANDALONE for all targets (only strictly
needed for some architecture, but harmless on those it isn't required
for). Also add -msoft-float to all architectures uniformly rather
that higgley piggley like it is today.

Differential Revision: https://reviews.freebsd.org/D3496


286368 06-Aug-2015 allanjude

Remove guards around overwriting loader.rc and menu.rc

There have been .local version of each for user modifications for some time
This allows users to receive future updates to these files

PR: 183765
Submitted by: Bertram Scharpf, Nikolai Lifanov (patch)
Reviewed by: dteske, loos, eadler
Approved by: bapt (mentor)
MFC after: 1 month
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D3176


284878 26-Jun-2015 delphij

Reduce warnings:

- Add prototype for boot2 main()
- Don't make assignment within if statement, split it into two.

No functional or binary change -- verified with sha256(1).

MFC after: 2 weeks


284590 19-Jun-2015 bapt

Install loader(8) and zfsloader(8) only once

Differential Revision: https://reviews.freebsd.org/D2841
Reviewed by: imp


284345 13-Jun-2015 sjg

Add META_MODE support.

Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision: D2796
Reviewed by: brooks imp


283006 16-May-2015 thomas

Minor comments fixes


281887 23-Apr-2015 jhb

Reassign copyright statements on several files from Advanced
Computing Technologies LLC to Hudson River Trading LLC.

Approved by: Hudson River Trading LLC (who owns ACT LLC)
MFC after: 1 week


281138 06-Apr-2015 rpaulo

SMBIOS support for EFI.

MFC after: 1 week


281009 03-Apr-2015 jkim

Revert .PATH changes to fix mips build.

Reported by: bz
Pointy hat to: jkim


281002 02-Apr-2015 jkim

Install newly added brand-*.4th and logo-*.4th files and reduce duplication.

Reviewed by: dteske
Pointy hat to: dteske


281000 02-Apr-2015 emaste

Move i386/efi files to new home in efi/loader/arch/i386

This was not (and still is not) connected to the build, but the EFI
loader is in the process of being built for other than amd64 so these
files ought to live in their eventual MD location.


280980 02-Apr-2015 dim

Ensure the cross assembler, linker and objcopy are used for the build32
stage, just like for the regular world stage.

Reviewed by: rodrigc, imp, bapt, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D2187


280954 01-Apr-2015 royger

multiboot: fix error codes

Return EINVAL instead of EFTYPE if we have a multiboot kernel loaded but
failed to load the modules. This makes it clear that the kernel/module
should be handled by the multiboot handler but something went wrong.

Sponsored by: Citrix Systems R&D


280953 01-Apr-2015 royger

multiboot: zero mod list array

Zero the list of modules array before using it, or else we might pass
uninitialized data in unused fields of the struct that will make Xen choke.
Also add a check to make sure malloc succeeds.

Sponsored by: Citrix Systems R&D


280031 15-Mar-2015 dim

Upgrade our copy of clang, llvm and lldb to 3.6.0 release.

Please note that from 3.5.0 onwards, clang/llvm/lldb require C++11
support to build; see UPDATING for more information.

Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.6.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.6.0/tools/clang/docs/ReleaseNotes.html>

Thanks to Ed Maste for the lldb part of this upgrade.

Exp-run: antoine


279598 04-Mar-2015 dim

When compiling boot2 with gcc on i386 and pc98, only use the custom flag
-mno-align-long-strings when compiling with base gcc. This is checked
by comparing the version number against 4.2.1, which is not exactly
right, but good enough. (There is no other way to check whether we are
using the non-standard gcc in base, as far as I know.)

Reported by: rodrigc
MFC after: 3 days


279222 23-Feb-2015 grembo

Improve memory detection in biosmem.c

- Add a quirk to allow ignoring e820 extended memory detection.
- Improve memory detection through e801.
- Add bootloader command "biosmem".

See differential revision for more details.

Reviewed by: jhb, adrian
Approved by: adrian
Differential Revision: https://reviews.freebsd.org/D1741


277957 31-Jan-2015 grembo

Fix order of functions in smbios.c (corrects r277949), since this corrects
a build error I committed this directly, sorry.


277949 30-Jan-2015 grembo

New function smbios_match to detect BIOS versions during boot

Motivation is to introduce BIOS specific quirks early in the boot
process. smbios_match can be called before malloc is avaible, that's
why parts of smbios_detect have been moved into a separate function
smbios_probe that will be called by smbios_detect as well as
smbios_match.

Reviewed by: jhb
Approved by: jhb
Differential Revision: https://reviews.freebsd.org/D1679


277622 24-Jan-2015 will

Fix panic in firewire and creation of invalid config ROM.
(This change was supposed to be included in r277508.)

sys/boot/i386/libfirewire/firewire.c:
Fix configuration ROM generation count wrapping logic
so that the generation count is never outside of
allowed limits (0x2 -> 0xF).

Submitted by: gibbs
MFC after: 1 week
MFC with: 277508
Sponsored by: Spectra Logic
MFSpectraBSD: 1110685 on 2015/01/05


277418 20-Jan-2015 royger

loader: fix the size of MODINFOMD_MODULEP

The data in MODINFOMD_MODULEP is packed by the loader as a 4 byte type, but
the amd64 kernel expects a vm_paddr_t, which is of size 8 bytes. Fix this by
saving it as 8 bytes in the loader and retrieving it using the proper type
in the kernel.

Sponsored by: Citrix Systems R&D


277215 15-Jan-2015 royger

loader: implement multiboot support for Xen Dom0

Implement a subset of the multiboot specification in order to boot Xen
and a FreeBSD Dom0 from the FreeBSD bootloader. This multiboot
implementation is tailored to boot Xen and FreeBSD Dom0, and it will
most surely fail to boot any other multiboot compilant kernel.

In order to detect and boot the Xen microkernel, two new file formats
are added to the bootloader, multiboot and multiboot_obj. Multiboot
support must be tested before regular ELF support, since Xen is a
multiboot kernel that also uses ELF. After a multiboot kernel is
detected, all the other loaded kernels/modules are parsed by the
multiboot_obj format.

The layout of the loaded objects in memory is the following; first the
Xen kernel is loaded as a 32bit ELF into memory (Xen will switch to
long mode by itself), after that the FreeBSD kernel is loaded as a RAW
file (Xen will parse and load it using it's internal ELF loader), and
finally the metadata and the modules are loaded using the native
FreeBSD way. After everything is loaded we jump into Xen's entry point
using a small trampoline. The order of the multiboot modules passed to
Xen is the following, the first module is the RAW FreeBSD kernel, and
the second module is the metadata and the FreeBSD modules.

Since Xen will relocate the memory position of the second
multiboot module (the one that contains the metadata and native
FreeBSD modules), we need to stash the original modulep address inside
of the metadata itself in order to recalculate its position once
booted. This also means the metadata must come before the loaded
modules, so after loading the FreeBSD kernel a portion of memory is
reserved in order to place the metadata before booting.

In order to tell the loader to boot Xen and then the FreeBSD kernel the
following has to be added to the /boot/loader.conf file:

xen_cmdline="dom0_mem=1024M dom0_max_vcpus=2 dom0pvh=1 console=com1,vga"
xen_kernel="/boot/xen"

The first argument contains the command line that will be passed to the Xen
kernel, while the second argument is the path to the Xen kernel itself. This
can also be done manually from the loader command line, by for example
typing the following set of commands:

OK unload
OK load /boot/xen dom0_mem=1024M dom0_max_vcpus=2 dom0pvh=1 console=com1,vga
OK load kernel
OK load zfs
OK load if_tap
OK load ...
OK boot

Sponsored by: Citrix Systems R&D
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D517

For the Forth bits:
Submitted by: Julien Grall <julien.grall AT citrix.com>


276479 31-Dec-2014 dim

Upgrade our copy of clang, llvm and lldb to 3.5.0 release.

Please note that this version now requires C++11 support to build; see
UPDATING for more information.

Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.5.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.5.0/tools/clang/docs/ReleaseNotes.html>

Thanks to Ed Maste, Roman Divacky, Andrew Turner, Justin Hibbits and
Antoine Brodin for their invaluable help with this import.

Approved by: portmgr (antoine)
MFC after: 1 month


276074 22-Dec-2014 imp

Make this compile when TERM_EMU is not defined.


275305 30-Nov-2014 rdivacky

Unbreak the code for non-digits below '0' by casting the expression
to unsigned int.

Pointed out by: bde


275237 29-Nov-2014 rdivacky

Shrink boot2 a bit more by factoring out common pattern
of printf();return(-1);

This shrinks it by 8bytes using clang35 and by 12bytes using clang34.


275191 27-Nov-2014 rdivacky

Revert part of r275059. Comparing unsigned 8 bit value
against -'0' is always false so the conditional block is
optimized away.


275062 25-Nov-2014 rdivacky

Fix style(9).

Suggested by: jkim


275061 25-Nov-2014 rdivacky

Fix style(9).

Suggested by: jkim


275059 25-Nov-2014 rdivacky

Shrink boot2 by a couple more bytes.

Reviewed by: jhb
Tested by: me, dim


274925 23-Nov-2014 joel

Misc mdoc fixes:

- Remove superfluous paragraph macros.
- Remove/fix empty or incorrect macros.
- Sort sections into conventional order.
- Terminate quoted strings properly.
- Remove EOL whitespace.


274398 11-Nov-2014 jhb

Move NFS and TFTP filesystems before the synthetic filesystems (bzip,
gzip, and split). "Real" filesystems should always be listed first so
that the "bare" filename is tried before alternate filenames. For PXE
booting in particular this can remove a lot of spurious pathname lookups.

While here, move splitfs to the bottom after the bzip and gzip filesystems
as it is the least often used.

Tested by: Prokash Sinha <psinha@panasas.com>
MFC after: 1 week


273142 15-Oct-2014 schweikh

Correct grammos.

MFC after: 3 weeks


272785 09-Oct-2014 marcel

Properly NUL-terminate the on-stack buffer for reading /boot.config
or /boot/config. In qemu, on a warm boot, the stack is not all zeroes
and we parse beyond the file's contents.

Obtained from: Juniper Networks, Inc.


272249 28-Sep-2014 nyan

Remove extra '\'.


272214 27-Sep-2014 kan

Remove obsolete compatibility glue and improve firewire code readability.

Commit my version of style(9) pass over the firewire code. Now that
other people have started changing the code carrying this is as a
local patch is not longer a viable option.

MFC after: 1 month


271609 15-Sep-2014 avg

add gptzfsboot.8, zfsboot.8 and zfsloader.8 manual pages

Many thanks to Warren Block for his reviews, corrections and additions.

Reviewed by: Warren Block <wblock@FreeBSD.org>
MFC after: 1 week


271475 12-Sep-2014 ambrisko

Add support for serial and null console to UEFI boot loader.


271406 10-Sep-2014 imp

Add support for calling pcibios routines from the
bootloader. Implement the following routines:
pcibios-device-count count the number of instances of a devid
pcibios-read-config read pci config space
pcibios-write-config write pci config space
pcibios-find-devclass find the nth device with a given devclass
pcibios-find-device find the nth device with a given devid
pcibios-locator convert bus device function ti pcibios locator
These commands are thin wrappers over their PCI BIOS 2.1 counterparts. More
informaiton, such as it is, can be found in the standard.

Export a nunmber of pcibios.X variables into the environment to report
what the PCI IDENTIFY command returned.

Also implmenet a new command line primitive (pci-device-count), but don't
include it by default just yet, since it depends on the recently added
words and any errors here can render a system unbootable.

This is intended to allow the boot loader to do special things based
on the hardware it finds. This could be have special settings that are
optimized for the specific cards, or even loading special drivers. It
goes without saying that writing to pci config space should not be
done without a just cause and a sound mind.

Sponsored by: Netflix


270168 19-Aug-2014 bdrewery

Revert r267233 for now. PIE support needs to be reworked.

1. 50+% of NO_PIE use is fixed by adding -fPIC to INTERNALLIB and other
build-only utility libraries.
2. Another 40% is fixed by generating _pic.a variants of various libraries.
3. Some of the NO_PIE use is a bit absurd as it is disabling PIE (and ASLR)
where it never would work anyhow, such as csu or loader. This suggests
there may be better ways of adding support to the tree. Many of these
cases can be fixed such that -fPIE will work but there is really no
reason to have it in those cases.
4. Some of the uses are working around hacks done to some Makefiles that are
really building libraries but have been using bsd.prog.mk because the code
is cleaner. Had they been using bsd.lib.mk then NO_PIE would not have
been needed.

We likely do want to enable PIE by default (opt-out) for non-tree consumers
(such as ports). For in-tree though we probably want to only enable PIE
(opt-in) for common attack targets such as remote service daemons and setuid
utilities. This is also a great performance compromise since ASLR is expected
to reduce performance. As such it does not make sense to enable it in all
utilities such as ls(1) that have little benefit to having it enabled.

Reported by: kib


269154 27-Jul-2014 marcel

1. Suppress output for the TFTP-based PXE loader, but leave it in
place for the NFS-based PXE loader. Information like rootpath
or rootip aren't that useful for TFTP and the gateway IP is
typically already printed by the firmware.
2. Only set boot.nfsroot.* environment variables for NFS. This
makes it possible for the OS to work either way by checking
for the presence or absence of environment variables.
3. Set boot.netif.server when using TFTP so that the OS can fetch
files as well. A typical use case for this is network-based
installations with the installation process implemented on
top of FreeBSD.
4. The pxelinux loader has a set of alternative names it tries
for configuration files. Make it easier to do something
similar in Forth by providing the IP address as a 32-bit hex
number in the pxeboot.ip variable and the MAC address with
dashes in the pxeboot.hwaddr environment variable.

Obtained from: Juniper Networks, Inc.


269153 27-Jul-2014 marcel

Give loaders more control over the Forth initialization process. In
particular, allow loaders to define the name of the RC script the
interpreter needs to use. Use this new-found control to have the
PXE loader (when compiled with TFTP support and not NFS support)
read from ${bootfile}.4th, where ${bootfile} is the name of the
file fetched by the PXE firmware.

The normal startup process involves reading the following files:
1. /boot/boot.4th
2. /boot/loader.rc or alternatively /boot/boot.conf

When these come from a FreeBSD-defined file system, this is all
good. But when we boot over the network, subdirectories and fixed
file names are often painful to administrators and there's really
no way for them to change the behaviour of the loader.

Obtained from: Juniper Networks, Inc.


269030 23-Jul-2014 sbruno

Add .NOPATH to the machine target so that builds in sys/boot work and don't
error out building zfs loader.

Submitted by: sjg@freebsd.org


269017 23-Jul-2014 royger

don't set CR4 PSE bit on amd64

Setting PSE together with PAE or in long mode just makes the PSE bit
completely ignored, so don't set it.

Sponsored by: Citrix Systems R&D
Reviewed by: kib


268974 22-Jul-2014 sbruno

Supress clang warning for FreeBSD printf %b and %D formats

MFC after: 2 weeks


268475 10-Jul-2014 imp

Make SERIAL support optional again. Enable it for i386 because a huge
percentage of machines has a 16550. Disable it for pc98 since only a
tiny fraction of them have one. These changes save 293 bytes when
building with clang, but preserves the ability to build with serial if
you really want. We now have 92 bytes free (412 with the in-tree gcc).


267293 09-Jun-2014 joel

mdoc: fix AUTHORS section.


267233 08-Jun-2014 bdrewery

In preparation for ASLR [1] support add WITH_PIE to support building with -fPIE.

This is currently an opt-in build flag. Once ASLR support is ready and stable
it should changed to opt-out and be enabled by default along with ASLR.

Each application Makefile uses opt-out to ensure that ASLR will be enabled by
default in new directories when the system is compiled with PIE/ASLR. [2]

Mark known build failures as NO_PIE for now.

The only known runtime failure was rtld.

[1] http://www.bsdcan.org/2014/schedule/events/452.en.html
Submitted by: Shawn Webb <lattera@gmail.com>
Discussed between: des@ and Shawn Webb [2]


265420 06-May-2014 imp

Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.


265400 05-May-2014 imp

Introduce CWARNFLAGS.${COMPILER_TYPE} and use that to simplify the
thicket of .if ${COMPILER_TYPE} == "clang" that controls
warnings. Also, use CFLAGS.clang in a couple places in preference to
having a similar construct that's related to the CWARNFLAGS changes.


264482 14-Apr-2014 brueffer

Re-indent break statement.

MFC after: 1 week


264400 13-Apr-2014 imp

NO_MAN= has been deprecated in favor of MAN= for some time, go ahead
and finish the job. ncurses is now the only Makefile in the tree that
uses it since it wasn't a simple mechanical change, and will be
addressed in a future commit.


264095 04-Apr-2014 emaste

Support UEFI booting on amd64 via loader.efi

This is largely the work from the projects/uefi branch, with some
additional refinements. This is derived from (and replaces) the
original i386 efi implementation; i386 support will be restored later.

Specific revisions of note from projects/uefi:

r247380:

Adjust our load device when we boot from CD under UEFI.

The process for booting from a CD under UEFI involves adding a FAT
filesystem containing your loader code as an El Torito boot image.
When UEFI detects this, it provides a block IO instance that points at
the FAT filesystem as a child of the device that represents the CD
itself. The problem being that the CD device is flagged as a "raw
device" while the boot image is flagged as a "logical partition". The
existing EFI partition code only looks for logical partitions and so
the CD filesystem was rendered invisible.

To fix this, check the type of each block IO device. If it's found to
be a CD, and thus an El Torito boot image, look up its parent device
and add that instead so that the loader will then load the kernel from
the CD filesystem. This is done by using the handle for the boot
filesystem as an alias.

Something similar to this will be required for booting from other
media as well as the loader will live in the EFI system partition, not
on the partition containing the kernel.

r246231:

Add necessary code to hand off from loader to an amd64 kernel.

r246335:

Grab the EFI memory map and store it as module metadata on the kernel.

This is the same approach used to provide the BIOS SMAP to the kernel.

r246336:

Pass the ACPI table metadata via hints so the kernel ACPI code can
find them.

r246608:

Rework copy routines to ensure we always use memory allocated via EFI.

The previous code assumed it could copy wherever it liked. This is not
the case. The approach taken by this code is pretty ham-fisted in that
it simply allocates a large (32MB) buffer area and stages into that,
then copies the whole area into place when it's time to execute. A more
elegant solution could be used but this works for now.

r247214:

Fix a number of problems preventing proper handover to the kernel.

There were two issues at play here. Firstly, there was nothing
preventing UEFI from placing the loader code above 1GB in RAM. This
meant that when we switched in the page tables the kernel expects to
be running on, we are suddenly unmapped and things no longer work. We
solve this by making our trampoline code not dependent on being at any
given position and simply copying it to a "safe" location before
calling it.

Secondly, UEFI could allocate our stack wherever it wants. As it
happened on my PC, that was right where I was copying the kernel to.
This did not cause happiness. The solution to this was to also switch
to a temporary stack in a safe location before performing the final
copy of the loaded kernel.

r246231:

Add necessary code to hand off from loader to an amd64 kernel.

r246335:

Grab the EFI memory map and store it as module metadata on the kernel.

This is the same approach used to provide the BIOS SMAP to the kernel.

r246336:

Pass the ACPI table metadata via hints so the kernel ACPI code can
find them.

r246608:

Rework copy routines to ensure we always use memory allocated via EFI.

The previous code assumed it could copy wherever it liked. This is not
the case. The approach taken by this code is pretty ham-fisted in that
it simply allocates a large (32MB) buffer area and stages into that,
then copies the whole area into place when it's time to execute. A more
elegant solution could be used but this works for now.

r247214:

Fix a number of problems preventing proper handover to the kernel.

There were two issues at play here. Firstly, there was nothing
preventing UEFI from placing the loader code above 1GB in RAM. This
meant that when we switched in the page tables the kernel expects to
be running on, we are suddenly unmapped and things no longer work. We
solve this by making our trampoline code not dependent on being at any
given position and simply copying it to a "safe" location before
calling it.

Secondly, UEFI could allocate our stack wherever it wants. As it
happened on my PC, that was right where I was copying the kernel to.
This did not cause happiness. The solution to this was to also switch
to a temporary stack in a safe location before performing the final
copy of the loaded kernel.

r247216:

Use the UEFI Graphics Output Protocol to get the parameters of the
framebuffer.

Sponsored by: The FreeBSD Foundation


264087 03-Apr-2014 emaste

Build boot/ficl as 64-bit library on amd64

The 32-bit bootloaders on amd64 now use the 32-bit version in ficl32,
as is done with libstand32. The native 64-bit ficl will be used by the
upcoming UEFI loader.

Sponsored by: The FreeBSD Foundation


264078 03-Apr-2014 emaste

Put each source file on a separate line

This will simplify rebasing the amd64 UEFI patch set.

Sponsored by: The FreeBSD Foundation


263968 31-Mar-2014 emaste

Merge r246607 by benno from projects/uefi

Use EFI types for EFI values (silences warnings).

EFI UINTN is actually a 64-bit type on 64-bit processors.

Sponsored by: The FreeBSD Foundation


263005 11-Mar-2014 royger

howto_names: unify declaration

Approved by: gibbs
Sponsored by: Citrix Systems R&D

boot/i386/efi/bootinfo.c:
boot/i386/libi386/bootinfo.c:
boot/ia64/common/bootinfo.c:
boot/powerpc/ofw/metadata.c:
boot/powerpc/ps3/metadata.c:
boot/sparc64/loader/metadata.c:
boot/uboot/common/metadata.c:
boot/userboot/userboot/bootinfo.c:
i386/xen/xen_machdep.c:
- Include sys/boot.h
- Remove custom definition of howto_names.

sys/boot.h:
- Define howto_names.

x86/xen/pv.c:
- Include sys/boot.h


261567 06-Feb-2014 emaste

Build a 32-bit libstand under sys/boot/

A 32-bit libstand is needed on 64-bit platforms for use by various
bootloaders. Previously only the 32-bit version was built, installed as
/usr/lib/libstand.a.

A new 64-bit libstand consumer will arrive in the near future, so move
the bootloader-specific 32-bit version to sys/boot/libstand32/.

Explicitly link against this version in the 32-bit loaders.

Sponsored by: The FreeBSD Foundation


261522 05-Feb-2014 wblock

Describe the use of a freebsd-boot GPT partition, brought up by Scot
Hetzel <swhetzel@gmail.com> on the -doc mailing list.

Also modify the Author section to be clear that I wrote the man page,
not gptboot.

MFC after: 3 days


261520 05-Feb-2014 jhb

Drop the 3rd clause from all 3 clause BSD licenses where I am the sole
holder to convert them to 2 clause BSD licenses.

MFC after: 1 week


261517 05-Feb-2014 jhb

Similar to r130943 for cdboot.S, update the license on this file to a
stock 2-clause BSD license.

MFC after: 1 week


260949 20-Jan-2014 mav

Make comconsole options set before its activation to be remembered.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.


260334 05-Jan-2014 dim

Split the last gcc-specific flags off into CFLAGS.gcc. This also
removes the need to use -Qunused-arguments for clang throughout the
tree.

MFC after: 3 days


260095 30-Dec-2013 dim

For sys/boot/i386 and sys/boot/pc98, separate flags to be passed
directly to the linker (LD_FLAGS) from flags passed indirectly, via the
compiler driver (LDFLAGS).

This is because several Makefiles under sys/boot/i386 and sys/boot/pc98
use ${LD} directly to link, and the normal LDFLAGS value should not be
used in these cases.

MFC after: 3 days


259913 26-Dec-2013 dim

For libstand and sys/boot, split off gcc-only flags into CFLAGS.gcc.

MFC after: 3 days
X-MFC-With: r259730


258780 30-Nov-2013 eadler

Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
shifts into the sign bit. Instead use (1U << 31) which gets the
expected result.

This fix is not ideal as it assumes a 32 bit int, but does fix the issue
for most cases.

A similar change was made in OpenBSD.

Discussed with: -arch, rdivacky
Reviewed by: cperciva


258719 28-Nov-2013 emaste

Purely cosmetic change: order DT_REL* and DT_RELA* consistently.

From projects/uefi, r246107

Sponsored by: The FreeBSD Foundation


258270 17-Nov-2013 dteske

Add a try-include word (which acts the same as "include") and use it to
conditionally include (but ignore failures) /boot/loader.rc.local and
/boot/menu.rc.local -- to make customizing the menu easier.

Reviewed by: alfred
Discussed on: -hackers


257650 04-Nov-2013 dteske

Defer loading of kernel and modules if the beastie menu is enabled. Add a
kernel selection menu to the beastie menu. List of kernels is taken from
`kernels' in loader.conf(5) as a space (or comma) separated list of names
to display (up to 9). If not set, default value is "kernel kernel.old".
Does not validate that kernels exist because the next enhancement will be
to allow selection of the root device.

Discussed on: -current
MFC after: 3 days


256940 22-Oct-2013 jkim

Allow users to set UUID in network byte order regardless of SMBIOS version.
Define BOOT_NETWORK_ENDIAN_UUID in make.conf(5) to enable this feature.


256293 10-Oct-2013 jhb

Sanitize the %eflags returned by BIOS routines. Some BIOS routines enter
protected mode and may leave protected-mode-specific flags like PSL_NT set
when they return to real mode. This can cause a fault when BTX re-enters
protected mode after the BIOS mode returns.

PR: amd64/182740
Reported by: Julian Pidancet <julian.pidancet@gmail.com>
Approved by: re (gjb)
MFC after: 1 week


255944 29-Sep-2013 bdrewery

Use MK_SSP=no after including bsd.own.mk to disable SSP instead of user-knob
WITH[OUT]_SSP to avoid hitting an error if user has WITH_SSP in their
make.conf. Ports now use this knob.

make[7]: "/usr/src/share/mk/bsd.own.mk" line 466: WITH_SSP and
WITHOUT_SSP can't both be set.

This is similar to previous cleanup done in r188895

Approved by: bapt
Reviewed by: jlh (earlier version)
Approved by: re (marius)
MFC after: 1 week


254733 23-Aug-2013 jkim

Set the hint for physical address of RSDP in hexadecimal as before r223262.


252586 03-Jul-2013 wblock

Add descriptions to the FILES list, fix some mdoc complaints, move the
"neither" entry out of the table in BOOTING.

Submitted by: joeld
Reviewed by: joeld
MFC after: 1 week


252492 01-Jul-2013 wblock

Add a new gptboot(8) man page. Factor out the redundant information
in gpart(8) and boot(8), adding references to gptboot(8) in both.

Reviewed by: jhb, ae, pjd, Paul Schenkeveld <bsdcan@psconsult.nl>, david_a_bright@dell.com (portions), gjb
MFC after: 1 week


249846 24-Apr-2013 dim

When rebooting (exiting) from the BTX loader, make sure to restore the
GDT from the correct segment, otherwise a triple fault would be caused.
In some virtual environments (VMware, VirtualBox, etc) this could lead
to a unhandled error or hang in the guest emulation software.

Thanks to avg and jhb for a few hints in the right direction.

Noticed by: Jeremy Chadwick <jdc@koitsu.org> (and many others)
MFC after: 1 week


245848 23-Jan-2013 jhb

Always update the hw.uart.console hint anytime a change is made to the
comconsole setup. Previously the hint would be set when if you set a
custom port, but it would not be updated if you later set a custom speed.

Also, leave the hw.uart.console hint mutable so it can be overridden or
unset by the user if needed.

Reviewed by: kib (earlier version)
MFC after: 1 week


245765 22-Jan-2013 benno

Fix linking of loader.efi.

gcc handles -symbolic by passing -Bsymbolic through to ld. clang ignores
-symbolic and thus invokes ld without -Bsymbolic which leads to some symbols
not being properly linked in loader.efi. Fix this by using -Wl,-Bsymbolic which
passes -Bsymbolic to ld in both the gcc and clang cases.

Approved by: rpaulo


245424 14-Jan-2013 sbruno

Quiesce some clang warnings while we're here doing stuff.

Submitted by: Hiren Panchasara <hiren.panchasara@gmail.com>
Obtained from: Yahoo! Inc


244332 17-Dec-2012 rpaulo

amd64 only has rela sections.


243977 07-Dec-2012 rpaulo

Make this work for 64 bit binaries.


243875 05-Dec-2012 rpaulo

Remove dead code that clang refuses to compile.


243025 14-Nov-2012 avg

boot: use packed attribute for edd_params* structures and their substructures

The sole purpose of this change is to make sure that sizeof produces
"canonical" sizes for these structures. This is to avoid triggering
bugs in the BIOSes that properly handle only the canonical values of
input length provided to INT 13h AH=48h.
The canonical sizes are: 30 for v2, 66 for v3, etc.
Buggy BIOS code probably looks like:
if (input_length > 30) { /* > v2 */
assume that input length is 66 /* assume v3 or later */
}

This should fix boot problems at least on Supermicro X8DT6 and possibly
on P410i Smart Array Controller (as found in e.g. HP DL360 G7).

Reported by: gnn, np, rstone
Debugged by: rstone
Discussed with: ae, np, rstone
MFC after: 4 days


242804 08-Nov-2012 dim

Shrink boot2 by 8 bytes, by eliminating some unneeded instructions in
sio.S. This is not particularly needed for head right now, but it is
intended to merge to stable/9, to fix boot2 build with clang there.

Reviewed by: avg
MFC after: 3 days


242688 07-Nov-2012 dteske

Hook in new files menusets.4th and manual.

Approved by: adrian (co-mentor) (implicit)


241809 21-Oct-2012 ae

Add the flags parameter to the disk_open() function and DISK_F_NOCACHE
flag, that disables the caching of partition tables metadata.
Use this flag for floppies in the libi386/biosdisk driver.


241785 20-Oct-2012 avg

boot: use -march=i386 for both i386 and amd64 builds

.. so that consistent compilation algorithms are used for both
architectures as in practice the binaries are expected to be
interchangeable (for time being).
Previously i386 used default setting which were equivalent to
-march=i486 -mtune=generic.
The only difference is using smaller but slower "leave" instructions.

Discussed with: jhb, dim
MFC after: 29 days


241301 06-Oct-2012 avg

add detection of serial console presence to btx and boot2-like blocks

Note that this commit slightly increases size of boot blocks.

Reviewed by: jhb
Tested by: Olivier Cochard-Labbe <olivier@cochard.me>
MFC after: 26 days


241300 06-Oct-2012 avg

i386 comconsole: don't loop forever if hardware doesn't respond

- clear capability flags when hw timeouts
- retire comc_started status variable and directly use c_flags to see
if comconsole is selected for use

Reviewed by: jhb
Tested by: Uffe Jakobsen <uffe@uffe.org>,
Olivier Cochard-Labbe <olivier@cochard.me>
MFC after: 26 days


241294 06-Oct-2012 avg

zfsboot: simplify probe_drive() a little bit

The first discovered pool, whether it covers the whole boot disk or not,
is going to be first in zfs_pools list. So there is no need at all
for spapp parameter.

This commit also fixes a bug where NULL would be assigned to NULL
pointer when probe_drive was called with the spapp parameter of NULL.

MFC after: 21 days


241293 06-Oct-2012 avg

zfs boot: export boot/primary pool and vdev guid all the way to kenv

This is work in progress to for znextboot and it also provides
some convenient infrastructure.

MFC after: 20 days


241288 06-Oct-2012 avg

zfsboot: use the same zfs dataset naming format as loader

Also, pool name alone now names a root dataset of the pool regardless
of bootfs property value.

MFC after: 15 days


241284 06-Oct-2012 avg

zfs boot: add lszfs command to i386 loader

... to list child datasets of a specified dataset.
Dataset name should be provided in poolname/dsname format.

MFC after: 17 days


241068 30-Sep-2012 ae

Reduce the number of attempts to detect proper kld format for the amd64
loader.


241053 29-Sep-2012 ae

Almost each time when loader opens a file, this leads to calling
disk_open(). Very often this is called several times for one file.
This leads to reading partition table metadata for each call. To
reduce the number of disk I/O we have a simple block cache, but it
is very dumb and more than half of I/O operations related to reading
metadata, misses this cache.

Introduce new cache layer to resolve this problem. It is independent
and doesn't need initialization like bcache, and will work by default
for all loaders which use the new DISK API. A successful disk_open()
call to each new disk or partition produces new entry in the cache.
Even more, when disk was already open, now opening of any nested
partitions does not require reading top level partition table.
So, if without this cache, partition table metadata was read around
20-50 times during boot, now it reads only once. This affects the booting
from GPT and MBR from the UFS.


241047 29-Sep-2012 ae

Disable splitfs support, since we aren't support floppies for a long
time. This slightly reduces an overhead, when loader tries to open
file that doesn't exist.


240637 18-Sep-2012 avg

loader/i386: replace ugly inb/outb re-implementations with cpufunc.h

Use of __builtin_constant_p in a function that is only called via
a pointer is a good example of how out-of-date it was.

Suggested by: bde
MFC after: 1 week


240421 12-Sep-2012 mav

Make pxe device in lsdev really include device name, looking like this:
pxe0: 192.168.3.1:/storage/nfsroot/amd64
, instead of confusing and less useful:
192.168.3.1:pxeboot


240341 11-Sep-2012 avg

a bit of trailing whitespace cleanup

MFC after: 1 week


240335 11-Sep-2012 ae

Slightly reduce an overhead for the open() call in the zfsloader.
libstand(3) tries to detect file system in the predefined order,
but zfsloader usually is used for the booting from ZFS, and there is
no need to try detect several file system types for each open() call.


239243 13-Aug-2012 dim

After r239066, reinitialize v86.ctl and v86.addr for int 13 EDD probing
in sys/boot/i386/libi386/biosdisk.c. Otherwise, when DISK_DEBUG is
enabled, the DEBUG() macros will clobber those fields, and cause the
probing to always fail mysteriously when debugging is enabled.


239211 12-Aug-2012 ae

Add another debug message.


239068 05-Aug-2012 ae

Teach the ZFS use new partitions API when probing.
Note: now ZFS does probe only for partitions with type "freebsd-zfs"
and "freebsd".


239067 05-Aug-2012 ae

Remove unneeded flag.


239066 05-Aug-2012 ae

Add offset field to the i386_devdesc structure to be compatible with
disk_devdesc structure. Update biosdisk driver to the new disk API.


239060 05-Aug-2012 ae

When GPT signature is invalid in the primary GPT header, then try to
read backup GPT header.

Submitted by: hrs (previous version)


236405 01-Jun-2012 jhb

Remove unnecessary initializations. The BSS of boot2 is in fact
zero'd when boot2 begins execution by the _start() routine in btxcsu.S.

MFC after: 1 week


236213 29-May-2012 kevlo

Make sure that each va_start has one and only one matching va_end,
especially in error cases.


235988 25-May-2012 gleb

Use 32-bit ufs_ino_t instead of ino_t to keep boot2 small and prevent
unnecessary 64-bit math on 32-bit machines.

Sponsored by: Google Summer of Code 2011


235537 17-May-2012 gber

Import work done under project/nand (@235533) into head.

The NAND Flash environment consists of several distinct components:
- NAND framework (drivers harness for NAND controllers and NAND chips)
- NAND simulator (NANDsim)
- NAND file system (NAND FS)
- Companion tools and utilities
- Documentation (manual pages)

This work is still experimental. Please use with caution.

Obtained from: Semihalf
Supported by: FreeBSD Foundation, Juniper Networks


235329 12-May-2012 avg

zfsboot/zfsloader: support accessing filesystems within a pool

In zfs loader zfs device name format now is "zfs:pool/fs",
fully qualified file path is "zfs:pool/fs:/path/to/file"
loader allows accessing files from various pools and filesystems as well
as changing currdev to a different pool/filesystem.

zfsboot accepts kernel/loader name in a format pool:fs:path/to/file or,
as before, pool:path/to/file; in the latter case a default filesystem
is used (pool root or bootfs). zfsboot passes guids of the selected
pool and dataset to zfsloader to be used as its defaults.

zfs support should be architecture independent and is provided
in a separate library, but architectures wishing to use this zfs support
still have to provide some glue code and their devdesc should be
compatible with zfs_devdesc.
arch_zfs_probe method is used to discover all disk devices that may
be part of ZFS pool(s).

libi386 unconditionally includes zfs support, but some zfs-specific
functions are stubbed out as weak symbols. The strong definitions
are provided in libzfsboot.
This change mean that the size of i386_devspec becomes larger
to match zfs_devspec.

Backward-compatibility shims are provided for recently added sparc64
zfs boot support. Currently that architecture still works the old
way and does not support the new features.

TODO:
- clear up pool root filesystem vs pool bootfs filesystem distinction
- update sparc64 support
- set vfs.root.mountfrom based on currdev (for zfs)

Mid-future TODO:
- loader sub-menu for selecting alternative boot environment

Distant future TODO:
- support accessing snapshots, using a snapshot as readonly root

Reviewed by: marius (sparc64),
Gavin Mu <gavin.mu@gmail.com> (sparc64)
Tested by: Florian Wagner <florian@wagner-flo.net> (x86),
marius (sparc64)
No objections: fs@, hackers@
MFC after: 1 month


235281 11-May-2012 dim

Fix sys/boot/i386/cdboot/cdboot.S compilation with clang after r235219.
This file uses .code16 directives, which are not yet supported by
clang's integrated assembler.

MFC after: 1 month


235219 10-May-2012 avg

cdboot, pxeldr: make use of bootargs.h instead of redefining flag constants

Reviewed by: jhb
MFC after: 1 month


235158 09-May-2012 avg

r235154 followup: add stddef.h for offsetof

MFC after: 1 month


235156 09-May-2012 avg

i386 zfsloader: rename LIBZFS to LIBZFSBOOT

... to avoid name clash with the other libzfs

MFC after: 1 month


235155 09-May-2012 avg

i386 boot: consolidate MAXBDDEV definition

MFC after: 1 month


235154 09-May-2012 avg

btxldr: future-proof argument passing from boot1/2-ish to loader

Place the arguments at a fixed offset of 0x800 withing the argument area
(of size 0x1000). Allow variable size extended arguments first of which
should be a size of the extended arguments (including the size
parameter).

Consolidate all related definitions in a new i386/common/bootargs.h header.

Many thanks to jhb and bde for their guidance and reviews.

Reviewed by: jhb, bde
Approved by: jhb
MFC after: 1 month


235153 09-May-2012 avg

sys/boot: add common CTASSERT definition


234493 20-Apr-2012 marcel

Build a 32-bit EFI loader on amd64. This to match the rest of the
code that is used to construct a loader (e.g. libstand, ficl, etc).

There is such a thing as a 64-bit EFI application, but it's not
as standard as 32-bit is. Let's make the 32-bit functional (as in
we can load and actualy boot a kernel) before solving the 64-bit
loader problem.


234339 16-Apr-2012 avg

zfsboot: honor -q if it's present in boot.config

Before r228267 the option was honored but the original content of
boot.config was not preserved. I tried to fix that but missed the idea.
Now the proper way of doing things is taken from i386/boo2.
Also, a comment is added to explain this a little bit unobvious
behavior.

Inspired by: jhb
MFC after: 5 days


232754 09-Mar-2012 jkim

Make boot2 build with Clang again.

Submitted by: dim (bsd.sys.mk)
Reviewed by: dim, jhb


232623 06-Mar-2012 jhb

Add a note to clarify why we create a relocated copy of boot1 in lower
memory.


232570 05-Mar-2012 jhb

Fix boot2 to handle boot config files that only contain a custom path to
a loader or kernel. Specifically, kname cannot be pointed at cmd[] since
it's value is change to be an empty string after the initial call to
parse, and cmd[]'s value can be changed (thus losing a prior setting for
kname) due to user input at the boot prompt. While here, ensure that that
initial boot config file text is nul-terminated, that ops is initialized
to zero, and that kname is always initialized to a valid string.

Tested by: Domagoj Smolcic rank1seeker of gmail
MFC after: 1 week


232309 29-Feb-2012 jkim

Fix a long standing bug. The caller expects a non-zero value for success.
Luckily keyboard probing was turned off by default from the first revision.

Submitted by: Alexander Sack (asack at niksun dot com)
MFC after: 3 days


232263 28-Feb-2012 dim

Define several extra macros in bsd.sys.mk and sys/conf/kern.pre.mk, to
get rid of testing explicitly for clang (using ${CC:T:Mclang}) in
individual Makefiles.

Instead, use the following extra macros, for use with clang:
- NO_WERROR.clang (disables -Werror)
- NO_WCAST_ALIGN.clang (disables -Wcast-align)
- NO_WFORMAT.clang (disables -Wformat and friends)
- CLANG_NO_IAS (disables integrated assembler)
- CLANG_OPT_SMALL (adds flags for extra small size optimizations)

As a side effect, this enables setting CC/CXX/CPP in src.conf instead of
make.conf! For clang, use the following:

CC=clang
CXX=clang++
CPP=clang-cpp

MFC after: 2 weeks


230325 19-Jan-2012 sbruno

Wrap changes from svn r212126 inside LOADER_NFS_SUPPORT such that
using LOADER_TFTP_SUPPORT excludes this code. Fixes compilation of pxeldr
with -DLOADER_TFTP_SUPPORT

Applicable to stable/9 and stable/8 now.

This appears to not be needed on stable/7 as r212126 has not been MFC'd.

Obtained from: Yahoo! Inc.
MFC after: 2 weeks


229435 03-Jan-2012 kib

Add special loader environment variables 'comconsole_port' and
'comconsole_pcidev'. The former allows to set the base address of the
serial console i/o port. The later takes the string of the format
'bus:device:function:[bar]' as a value and uses the serial port attached
as PCI device at the specified location for console.

Both variants pass 'hw.uart.console' variable to the uart driver to
properly hand-over the kernel console.

Change allows to use ISA serial ports other than COM1 for the
loader/kernel console without loader recompilation. Also, you can use
PCI-attached port as the console, e.g. Intel AMT serial pseudo-port on
some motherboards based on Q67 chipset.

Reviewed by: jhb
MFC after: 2 weeks


228782 21-Dec-2011 ed

Make the RTC checking for QEMU even more aggressive.

At work, where we use use KVM+QEMU, we notice that pxeboot is pratically
impossible because of network timeouts. This is due to the fact that the
RTC code makes aggressive jumps.

Two RTC reads does not seem to be sufficient. Change the code to check
for 8 identical RTC values.

Sponsored by: Kumina bv


228738 20-Dec-2011 jhb

Allow boot0cfg to force a PXE boot via boot0 on the next boot.
- Fix boot0 to check for PXE when using the pre-set setting for the
preferred slice.
- Update boot0cfg to use slice 6 to select PXE. Accept a 'pxe' argument
instead of a number for the 's' option as a way to select PXE as well.

Submitted by: Andrew Boyer aboyer averesystems
MFC after: 2 weeks


228267 04-Dec-2011 avg

zfsboot: print boot.config contents before parsing it

as parsing can be a destructive operation

MFC after: 2 weeks


227726 19-Nov-2011 miwi

- Whitespaces fixed only

Approved by: rwatson (mentor)


227389 09-Nov-2011 jhb

Revert some debugging printfs that crept into 223695.


226748 25-Oct-2011 jhb

- Add a new header for the x86 boot code that defines various structures
and constants related to the BIOS Enhanced Disk Drive Specification.
- Use this header instead of magic numbers and various duplicate structure
definitions for doing I/O.
- Use an actual structure for the request to fetch drive parameters in
drvsize() rather than a gross hack of a char array with some magic
size. While here, change drvsize() to only pass the 1.1 version of
the structure and not request device path information. If we want
device path information you have to set the length of the device
path information as an input (along with probably checking the actual
EDD version to see which size one should use as the device path
information is variable-length). This fixes data smashing problems
from passing an EDD 3 structure to BIOSes supporting EDD 4.

Reviewed by: avg
Tested by: Dennis Koegel dk neveragain.de
MFC after: 1 week


226746 25-Oct-2011 jhb

Consolidate duplicate definitions of V86_CY() and V86_ZR() which check for
the carry and zero flags being set, respectively, in <btxv86.h> and use
them throughout the x86 boot code.


226506 18-Oct-2011 des

Look for /boot/config in addition to /boot.config, with the former taking
precedence over the latter if it exists.

MFC after: 3 weeks


225530 13-Sep-2011 avg

gpt/zfs boot blocks: reduce optimizing CFLAGS to -O1

gpt and zfs boot blocks are not nearly as size-constrained as boot2
from which they inherited their current optimization and anti-optimization
options. As such the current options do not provide any benefit, but
make debugging of the code much harder.
Also, it has been demonstrated that combination of -mrtd and
-fno-unit-at-a-time may result in mis-compilation of the boot code
with the current base gcc.

Additionally, intermediate assembly file filtering is removed for
zfsboot.

The new boot blocks are all compile- and boot- tested using qemu.
gptzfsboot is tested with real hardware.

Reported by: Peter Jeremy <peterjeremy@acm.org> [miscompilation]
Discussed with: bde, jhb
Tested by: Sebastian Chmielewski <chmielsster@gmail.com> [gptzfsboot]
Approved by: re (kib)
MFC after: 3 weeks


224131 17-Jul-2011 dim

When building some of the boot loaders with clang, and DEBUG_FLAGS or
CFLAGS having '-g' in it, clang outputs several assembly directives that
are too new for our version of binutils.

Therefore, assemble the resulting .s files with clang instead. A more
general solution can be implemented when a GNU as-compatible driver for
clang's integrated assembler appears.

Reported by: dougb


223758 04-Jul-2011 attilio

With retirement of cpumask_t and usage of cpuset_t for representing a
mask of CPUs, pc_other_cpus and pc_cpumask become highly inefficient.

Remove them and replace their usage with custom pc_cpuid magic (as,
atm, pc_cpumask can be easilly represented by (1 << pc_cpuid) and
pc_other_cpus by (all_cpus & ~(1 << pc_cpuid))).

This change is not targeted for MFC because of struct pcpu members
removal and dependency by cpumask_t retirement.

MD review by: marcel, marius, alc
Tested by: pluknet
MD testing by: marcel, marius, gonzo, andreast


223695 30-Jun-2011 dfr

Add a version of the FreeBSD bootloader which can run in userland, packaged
as a shared library. This is intended to be used by BHyVe to load FreeBSD
kernels into new virtual machines.


223611 27-Jun-2011 jhb

Revert the entry point label to 'start' to unbreak the build.

Pointy hat to: jhb


223597 27-Jun-2011 jhb

- Remove the fake BPB from zfsldr. zfsldr doesn't support booting from
floppies, so it will not be used as the start of an emulated floppy
image on a bootable CD which is what the fake BPB was used for.
- Only check that EDD packet mode is available once at the start of
zfsldr rather than for each disk sector now that we read data in one
sector at a time. As a result, collapse the remaining bits of read
up into nread and rename nread to read.
- Restore a return at the end of putstr that I removed in the previous
revision.

Tested by: Henri Hennebert (earlier version)
MFC after: 1 week


223477 23-Jun-2011 jhb

The recent change to increase the zfsboot size to 64k made a few BIOSes
unhappy (probably they don't handle crossing the 64k boundary, etc.).
Fix this by changing zfsldr to use a loop reading from the disk one
sector at a time. To avoid trashing the saved copy of the MBR which is
used for disk I/O, read zfsboot2 at address 0x9000. This has the
advantage that BTX no longer needs to be relocated as it is read into
the correct location. However, the loop to relocate zfsboot2.bin can
now cross a 64k boundary, so change it to use relative segments instead.
(This will need further work if zfsboot2.bin ever exceeds 64k.)

While here, stop storing a relocated copy of zfsldr at 0x700. This was
only used by the xread hack which has recently been removed (and even
that use was dubious). Also, include the BIOS error code as hex when
reporting read errors to aid in debugging.

Much thanks to Henri Hennebert for patiently testing various iterations
of the patch as well as fixing the zfsboot2.bin relocation to use
relative segments.

MFC after: 1 week


223262 18-Jun-2011 benl

Fix clang warnings.

Approved by: philip (mentor)


223017 12-Jun-2011 dim

Upgrade our copy of llvm/clang to r132879, from upstream's trunk.


222813 07-Jun-2011 attilio

etire the cpumask_t type and replace it with cpuset_t usage.

This is intended to fix the bug where cpu mask objects are
capped to 32. MAXCPU, then, can now arbitrarely bumped to whatever
value. Anyway, as long as several structures in the kernel are
statically allocated and sized as MAXCPU, it is suggested to keep it
as low as possible for the time being.

Technical notes on this commit itself:
- More functions to handle with cpuset_t objects are introduced.
The most notable are cpusetobj_ffs() (which calculates a ffs(3)
for a cpuset_t object), cpusetobj_strprint() (which prepares a string
representing a cpuset_t object) and cpusetobj_strscan() (which
creates a valid cpuset_t starting from a string representation).
- pc_cpumask and pc_other_cpus are target to be removed soon.
With the moving from cpumask_t to cpuset_t they are now inefficient
and not really useful. Anyway, for the time being, please note that
access to pcpu datas is protected by sched_pin() in order to avoid
migrating the CPU while reading more than one (possible) word
- Please note that size of cpuset_t objects may differ between kernel
and userland. While this is not directly related to the patch itself,
it is good to understand that concept and possibly use the patch
as a reference on how to deal with cpuset_t objects in userland, when
accessing kernland members.
- KTR_CPUMASK is changed and now is represented through a string, to be
set as the example reported in NOTES.

Please additively note that no MAXCPU is bumped in this patch, but
private testing has been done until to MAXCPU=128 on a real 8x8x2(htt)
machine (amd64).

Please note that the FreeBSD version is not yet bumped because of
the upcoming pcpu changes. However, note that this patch is not
targeted for MFC.

People to thank for the time spent on this patch:
- sbruno, pluknet and Nicholas Esborn (nick AT desert DOT net) tested
several revision of the patches and really helped in improving
stability of this work.
- marius fixed several bugs in the sparc64 implementation and reviewed
patches related to ktr.
- jeff and jhb discussed the basic approach followed.
- kib and marcel made targeted review on some specific part of the
patch.
- marius, art, nwhitehorn and andreast reviewed MD specific part of
the patch.
- marius, andreast, gonzo, nwhitehorn and jceel tested MD specific
implementations of the patch.
- Other people have made contributions on other patches that have been
already committed and have been listed separately.

Companies that should be mentioned for having participated at several
degrees:
- Yahoo! for having offered the machines used for testing on big
count of CPUs.
- The FreeBSD Foundation for having sponsored my devsummit attendance,
which has been instrumental.
- Sandvine for having offered offices and infrastructure during
development.

(I really hope I didn't forget anyone, if it happened I apologize in
advance).


222417 28-May-2011 julian

New boot loader menus from Devin Teske.
Discussed on hackers and recommended for inclusion into 9.0 at the devsummit.
All support email to devin dteske at vicor dot ignoreme dot com .

Submitted by: dteske at vicor dot ignoreme dot com
Reviewed by: me and many others


221506 05-May-2011 dim

Fine-tune llvm optimization for sys/boot/i386/boot2, which shaves off
some more bytes from the final boot2 image.

Submitted by: rdivacky


221348 02-May-2011 dim

Clang r130700 can now compile sys/boot/i386/boot2 with room to spare.


221177 28-Apr-2011 jhb

Due to space constraints, the UFS boot2 and boot1 use an evil hack where
boot2 calls back into boot1 to perform disk reads. The ZFS MBR boot blocks
do not have the same space constraints, so remove this hack for ZFS.
While here, remove commented out code to support C/H/S addressing from
zfsldr. The ZFS and GPT bootstraps always just use EDD LBA addressing.

MFC after: 2 weeks


220924 21-Apr-2011 ae

Remove all object files during 'make clean'.

MFC after: 1 week


220392 06-Apr-2011 rdivacky

Move getc() body before xgetc() so gcc does not emit a warning about function
having no body.

Approved by: jhb


220389 06-Apr-2011 rdivacky

Mark getc() as inline, this has no effect on gcc but helps clang.

Approved by: jhb


220337 04-Apr-2011 rdivacky

Build boot2 with -mregparm=3, ie. pass upto 3 arguments via registers.
This modifies CFLAGS and tweaks sio.S to use the new calling convention.
The sio_init() and sio_putc() prototypes are modified so that other
users of this code know the correct calling convention.

This makes the code smaller when compiled with clang.

Reviewed by: jhb
Tested by: me and Freddie Cash <fjwcash gmail com>


219703 16-Mar-2011 ae

The size of zfsboot2 grown up to 64 Kbytes in r219089.
Increase NSECT up to 128 sectors too.

Reviewed by: jhb, pjd


219702 16-Mar-2011 ae

Set control flags in putc(). This should fix zfsboot hangs in drvread().

PR: kern/153552
Reviewed by: jhb
MFC after: 1 week


219483 11-Mar-2011 jhb

Remove all object files during 'make clean'.

PR: kern/154888
Submitted by: arundel
MFC after: 1 week


219452 10-Mar-2011 rdivacky

Some more shrinking.

o bunch of variables are turned into uint8_t

o initial setting of namep[] in lookup() is removed
as it's only overwritten a few lines down

o kname is explicitly initialized in main() as BSS
in boot2 is not zeroed

o the setting and reading of "fmt" in load() is removed

o buf in printf() is made static to save space

Reviewed by: jhb
Tested by: me and Fabian Keil <freebsd-listen fabiankeil de>


219186 02-Mar-2011 rdivacky

This patch shrinks boot2 a little.

o It switches kname to be just a pointer instead of an array
thus avoiding a couple of memcpy()s.

o It changes ioctl to unsigned from uint8_t.

o It changes the second keyhit limit to 3 seconds from 5
so that constant propagation can take place.

o It changes the ticks overflow computation as suggested by bde@.

o It removes bi_basemem/bi_extmem/bi_memsizes_valid setting from
bootinfo as it is unused.

Reviewed by: jhb


219126 01-Mar-2011 brucec

Remove duplicate "in".

Suggested by: Rob Farmer <rfarmer at predatorlabs.net>
MFC after: 3 days


219096 28-Feb-2011 brucec

Revert some of r177626. "in in" is valid in certain sentences.

PR: 121490
MFC after: 3 days


219089 27-Feb-2011 pjd

Finally... Import the latest open-source ZFS version - (SPA) 28.

Few new things available from now on:

- Data deduplication.
- Triple parity RAIDZ (RAIDZ3).
- zfs diff.
- zpool split.
- Snapshot holds.
- zpool import -F. Allows to rewind corrupted pool to earlier
transaction group.
- Possibility to import pool in read-only mode.

MFC after: 1 month


219079 27-Feb-2011 dim

Clang's integrated assembler can now handle sys/boot/i386/boot2/sio.S.
It used to choke on the notation "inb (%dx),%al" for "inb %dx,%al"; GNU
as accepts both forms. Which notation is more 'correct' is an open
question. :)


218926 21-Feb-2011 dim

In sys/boot/i386/boot2/boot2.c, change the type of the 'opts' variable
from uint16_t back to uint32_t. The actual option bitmasks (RB_* and
RBX_*) assume at least a 32 bit variable.

Submitted by: rdivacky


218893 20-Feb-2011 dim

Upgrade our copy of llvm/clang to r126079, from upstream's trunk.

This contains many improvements, primarily better C++ support, an
integrated assembler for x86 and support for -pg.


218822 18-Feb-2011 dim

Merge binutils 2.17.50 to head. This brings a number of improvements to
x86 CPU support, better support for powerpc64, some new directives, and
many other things. Bump __FreeBSD_version, and add a note to UPDATING.

Thanks to the many people that have helped to test this.

Obtained from: projects/binutils-2.17


218745 16-Feb-2011 imp

Remove reading of symbols from a.out loaded files. Since we are tight
on space for clang and a.out support is only needed for /boot/loader,
they are excess bytes that serve no useful purpose other than to
support really old kernels (FreeBSD < 3.2 or so). Prefer clang
support over support for these old kernels and remove this code. We
gain about 100 bytes of space this way.

Reviewed by: rdivacky@


218713 15-Feb-2011 dim

Apply a few small optimizations to boot2's code, to make it shrink a
little further. This gets us further on the way to be able to build it
successfully with clang. Using in-tree gcc, this shrinks boot2.bin with
60 bytes, the in-tree clang shaves off 72 bytes, and ToT clang 84 bytes.

Submitted by: rdivacky
Reviewed by: imp


217033 05-Jan-2011 dim

On i386 and amd64, consistently use the following options whenever we
want to avoid using any "advanced" CPU features:

-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float


217028 05-Jan-2011 dim

Remove superfluous -mno-(mmx|3dnow|sse|sse2|sse3) flags in Makefiles
under sys/boot/{i386,pc98}, since these are already added via
sys/boot/{i386,pc98}/Makefile.inc.

Submitted by: arundel


215285 14-Nov-2010 brucec

Fix the jump location.


215284 14-Nov-2010 brucec

When rebooting the machine jump to 0xf000:fff0 instead of 0xffff:0x0.
This is the same change that was made in rev 1.33 of boot/i386/btx/btx/btx.S

PR: i386/91871
Submitted by: Bjorn Konig <bkoenig at cs.tu-berlin.de>
MFC after: 1 week


215245 13-Nov-2010 nyan

Remove unused includes.


215016 08-Nov-2010 jhb

Remove support for autoloading ACPI from the loader. Leave in the code to
detect ACPI and export info such as the location of the RSDP via hints as
that is still useful.


214210 22-Oct-2010 rdivacky

Avoid using memcpy() for copying 32bit chunks. This shrinks
the resulting code a little.

Approved by: rpaulo (mentor)
Reviewed by: jhb


213568 08-Oct-2010 pho

Ensure that a make from sys/boot does not pick up include files from
/usr/include.

Discussed with: kib


213136 24-Sep-2010 pjd

- Split code shared by almost any boot loader into separate files and
clean up most layering violations:

sys/boot/i386/common/rbx.h:

RBX_* defines
OPT_SET()
OPT_CHECK()

sys/boot/common/util.[ch]:

memcpy()
memset()
memcmp()
bcpy()
bzero()
bcmp()
strcmp()
strncmp() [new]
strcpy()
strcat()
strchr()
strlen()
printf()

sys/boot/i386/common/cons.[ch]:

ioctrl
putc()
xputc()
putchar()
getc()
xgetc()
keyhit() [now takes number of seconds as an argument]
getstr()

sys/boot/i386/common/drv.[ch]:

struct dsk
drvread()
drvwrite() [new]
drvsize() [new]

sys/boot/common/crc32.[ch] [new]

sys/boot/common/gpt.[ch] [new]

- Teach gptboot and gptzfsboot about new files. I haven't touched the
rest, but there is still a lot of code duplication to be removed.

- Implement full GPT support. Currently we just read primary header and
partition table and don't care about checksums, etc. After this change we
verify checksums of primary header and primary partition table and if
there is a problem we fall back to backup header and backup partition
table.

- Clean up most messages to use prefix of boot program, so in case of an
error we know where the error comes from, eg.:

gptboot: unable to read primary GPT header

- If we can't boot, print boot prompt only once and not every five
seconds.

- Honour newly added GPT attributes:

bootme - this is bootable partition
bootonce - try to boot from this partition only once
bootfailed - we failed to boot from this partition

- Change boot order of gptboot to the following:

1. Try to boot from all the partitions that have both 'bootme'
and 'bootonce' attributes one by one.
2. Try to boot from all the partitions that have only 'bootme'
attribute one by one.
3. If there are no partitions with 'bootme' attribute, boot from
the first UFS partition.

- The 'bootonce' functionality is implemented in the following way:

1. Walk through all the partitions and when 'bootonce'
attribute is found without 'bootme' attribute, remove
'bootonce' attribute and set 'bootfailed' attribute.
'bootonce' attribute alone means that we tried to boot from
this partition, but boot failed after leaving gptboot and
machine was restarted.
2. Find partition with both 'bootme' and 'bootonce' attributes.
3. Remove 'bootme' attribute.
4. Try to execute /boot/loader or /boot/kernel/kernel from that
partition. If succeeded we stop here.
5. If execution failed, remove 'bootonce' and set 'bootfailed'.
6. Go to 2.

If whole boot succeeded there is new /etc/rc.d/gptboot script coming
that will log all partitions that we failed to boot from (the ones with
'bootfailed' attribute) and will remove this attribute. It will also
find partition with 'bootonce' attribute - this is the partition we
booted from successfully. The script will log success and remove the
attribute.

All the GPT updates we do here goes to both primary and backup GPT if
they are valid. We don't touch headers or partition tables when
checksum doesn't match.

Reviewed by: arch (Message-ID: <20100917234542.GE1902@garage.freebsd.pl>)
Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com
MFC after: 2 weeks


212979 21-Sep-2010 dim

When building world with clang, for gnu/lib/libobjc, sys/boot/i386/boot2
and sys/boot/pc98/boot2, do not simply assign 'gcc' to CC, since compile
flags are sometimes passed via this variable, for example during the
build32 stage on amd64. This caused the 32-bit libobjc build on amd64
to fail.

Instead, only replace the first instance of clang (if any, including
optional path) with gcc, and leave the arguments alone.

Approved-by: rpaulo (mentor)


212805 17-Sep-2010 pjd

Before VirtualBox is fixed, mark with #ifdef what has to be done to make
it possible to boot from ZFS RAIDZ for example from within VirtualBox.
The problem with VirtualBox is that its BIOS reports only one disk present.
If we choose to ignore this report, we can find all the disks available.
We can't have this work-around to be turned on by default, because some broken
BIOSes report true when it comes to number of disks, but present the same disk
multiple times.


212126 02-Sep-2010 rmacklem

Modify pxe.c to use the version of nfs_getrootfh() that returns
the file handle's size and was recently committed to
lib/libstand/nfs.c. This allows pxeboot to use NFSv3 and work
correcty for non-FreeBSD as well as FreeBSD NFS servers.
If built with OLD_NFSV2 defined, the old
code that predated this patch will be used.

Tested by: danny at cs.huji.ac.il


212066 31-Aug-2010 delphij

For consistency, change all 'i386' and MACHINE_ARCH to x86.

Reviewed by: jhb
MFC after: 1 week


212060 31-Aug-2010 dim

Use a more robust way to substitute gcc for clang, when compiling
gnu/lib/libobjc and sys/boot/i386/boot2, so it also works when using
absolute paths and/or options, as in CC="/absolute/path/clang -foo".

Approved by: rpaulo (mentor)


211677 23-Aug-2010 imp

MF tbemd: Minor tweaks, prefer MACHINE_CPUARCH generally to MACHINE_ARCH


211571 21-Aug-2010 rpaulo

Make sure the boot2 stage is compiled with gcc, as clang has no
problems compiling it, but it just gets too big at the moment, even
with -Os. This is not applicable to gptboot, though.

Submitted by: Dimitry Andric <dimitry at andric.com>


210387 22-Jul-2010 rpaulo

Correctly setup LDADD with regards to libstand. The submitter points
out that "on amd64, libstand.a is compiled for i386, but is still installed
under ${WORLDTMP}/usr/lib instead of ${WORLDTMP}/usr/lib32. Even if it
would be installed there, ld on amd64 is set up incorrectly with a
${TOOLS_PREFIX}/usr/lib/i386 default path, so it wouldn't link. The reason
it does link under gcc is that gcc passes -L${WORLDTMP}/usr/lib twice,
even for -m32 builds, which is also incorrect, but accidentally works in
this case."

Submitted by: Dimitry Andric <dimitry at andric.com>


209162 14-Jun-2010 rdivacky

Pass the -N flag to linked via -Wl.

Approved by: ed (mentor)


208789 03-Jun-2010 ed

Use -Wl,-N instead of the undocumented -N option for GCC.

GCC forwards the -N flag directly to ld. This flag is not documented and
not supported by (for example) Clang. Just use -Wl,-N.

Submitted by: Pawel Worach


208388 21-May-2010 jhb

- Set 'dmadat' earlier so that we properly setup the heap if we fail to
locate a high memory area for the heap using the SMAP.
- Read the number of hard drive devices from the BIOS instead of hardcoding
a limit of 128. Some BIOSes duplicate disk devices once you get beyond
the maximum drive number.

MFC after: 1 month


206378 07-Apr-2010 rpaulo

Add a copyright.


206376 07-Apr-2010 rpaulo

EFI boot loader for FreeBSD/i386.

Doesn't boot a kernel yet, but it can read an ELF file from the EFI FAT
partition.


205662 26-Mar-2010 delphij

Our boot loader is capable of booting both i386 and amd64 kernels so
call it "x86" instead of "i386".

Suggested by: jhb in response to Alexander Best's loader proposal
MFC after: 1 month


200872 22-Dec-2009 jhb

Don't build zfsboot, gptzfsboot, and zfsloader if WITHOUT_ZFS is enabled.

MFC after: 1 week


200631 17-Dec-2009 nyan

Fix debug messages of bd_io().

MFC after: 1 week


200357 10-Dec-2009 jhb

Don't warn about an RSDP with a corrupt checksum. The kernel does a better
job about warning about these things later and this message can be
confusing.

Submitted by: infofarmer
MFC after: 1 week


200310 09-Dec-2009 jhb

Fix a confusing typo in the EDD packet structure used in gptboot and
gptzfsboot. I got the segment and offset fields reversed in the structure,
but I also succeeded in crossing the assignments so the actual EDD packet
ended up correct.

MFC after: 1 week


200309 09-Dec-2009 jhb

- Port bios_getmem() from libi386 to {gpt,}zfsboot() and use it to
safely allocate a heap region above 1MB. This enables {gpt,}zfsboot()
to allocate much larger buffers than before.
- Use a larger buffer (1MB instead of 128K) for temporary ZFS buffers. This
allows more reliable reading of compressed files in a raidz/raidz2 pool.

Submitted by: Matt Reimer mattjreimer of gmail
MFC after: 1 week


200219 07-Dec-2009 jhb

Improve the algorithm the loader uses to choose a memory range for its
heap when using a range above 1MB.

Previously the loader would always use the last 3MB in the first memory
range above 1MB for the heap. However, this memory range is also where the
kernel and any modules are loaded. If this memory range is "small", then
using the high 3MB for the heap may not leave enough room for the kernel
and modules.

Now the loader will use any range below 4GB for the heap, and the logic to
choose the "high" heap region has moved into biosmem.c. It sets two
variables that the loader can use for a high heap if it desires. When a
high heap is enabled (BZIP2, FireWire, GPT, or ZFS), then the following
memory ranges are preferred for the heap in order from best to worst:
- The largest memory region in the SMAP with a start address greater than
1MB. The memory region must be at least 3MB in length. This leaves the
region starting at 1MB purely for use by the kernel and modules.
- The last 3MB of the memory region starting at 1MB if it is at least 3MB
in size. This matches the current behavior except that the current loader
would break horribly if the first region was not at least 3MB in size.
- The memory range from the end of the loader up to the 640k window. This
is the range the loader uses when none of the high-heap-requesting options
are enabled.

Tested by: hrs
MFC after: 1 week


200216 07-Dec-2009 jhb

Various small whitespace and style fixes.


199857 27-Nov-2009 sobomax

Whitespace-only: another instance of identation with spaces.


199856 27-Nov-2009 sobomax

Whitespace on: use tabs for identation consistently.


199855 27-Nov-2009 sobomax

Add new loader console type: "spinconsole". This console selects the
video console which doesn't take any input from keyboard and hides
all output replacing it with ``spinning'' character (useful for
embedded products and custom installations).

Sponsored by: Sippy Software, Inc.


199806 25-Nov-2009 trasz

Be nice, don't use the f-word.


199714 23-Nov-2009 rnoland

Create a seperate ZFS enabled loader.

This adds zfsloader which will be called by zfsboot/gptzfsboot code rather
than the tradional loader. This eliminates the need to set the
LOADER_ZFS_SUPPORT variable in order to get a ZFS enabled loader.

Note however, that you must reinstall your bootcode (zfsboot/gptzfsboot)
in order for the boot process to use the new loader.

New installations will no longer be required to build a ZFS enabled
loader for a working ZFS boot system. Installing zfsboot/gptzfsboot is
sufficient for acknowledging the use of CDDL code and therefore the ZFS
enabled loader.

Based on a previous patch from jhb@

Reviewed by: jhb@
MFC after: 2 weeks


199579 20-Nov-2009 jhb

Always use 64-bit LBAs for disk addresses in zfsboot and gptzfsboot to
fully support booting from large volumes.

Tested by: Emil Smolenski ambsd of raisa.eu.org
Submitted by: Matt Reimer mattjreimer of gmail (most of the C bits)
MFC after: 1 week


198420 23-Oct-2009 rnoland

Correct some issues with zfs boot.

- Teach it to read gang blocks. (essentially untested)
If you see "ZFS: gang block detected!", please let
me know, so we can either remove the printf if it
works, or fix it if it doesn't.

- If multiple partitions exist on a disk, probe them all.
We also need to reset dsk->start to 0 to read the right
sector here.

- With GPT, we can have 128 partitions.

- If the bootfs property has ever been set on a pool
it seems that it never goes away. zpool won't allow
you to add to the pool with the bootfs property set.
However, if you clear the property back to default
we end up getting 0 for the object number and read
a bogus block pointer and fail to boot.

- Fix some error printfs. The printf in the loader is
only capable of c,s and u formats.

- Teach printf how to display %llu

Reviewed by: dfr, jhb
MFC after: 2 weeks


198079 14-Oct-2009 jhb

Use zfs_read() instead of xfsread() to read /boot.config. xfsread() fails
short read requests, so the result was that a /boot.config smaller than 512
bytes was ignored. boot2 uses fsread() instead of xfsread() to read
/boot.config already, so this makes zfsboot more like boot2.

Submitted by: Johny Mattsson johny-freebsd of earthmagic org
Reviewed by: dfr
MFC after: 3 days


197082 10-Sep-2009 emaste

If the pxe client is told to use / as the root path, honour that rather
of trying to mount /pxeroot instead.

PR: i386/106493
Submitted by: Andrey Russev
MFC after: 1 month


196326 17-Aug-2009 jhay

Fix parse() so that the partition to boot (load /boot/loader) from can
be set. The syntax as printed in main() is used: 0:ad(0p3)/boot/loader

Reviewed by: jhb
Approved by: re (kib)


195045 26-Jun-2009 rpaulo

On special systems where the MBR and the GPT are in sync (up to the 4th
slicei, Apple EFI hardware), the bootloader will fail to recognize the GPT
if it finds anything else but the EFI partition. Change the check to continue
detecting the GPT by looking at the EFI partition on the MBR but
stopping successfuly after finding it.

PR: kern/134590
Submitted by: Christoph Langguth <christoph at rosenkeller.org>
Reviewed by: jhb
MFC after: 2 weeks
Approved by: re (kib)


193720 08-Jun-2009 jhb

Instead of packing the individual fields in the PnP structures, pack the
entire structures. This trims some warnings.

Verified by: md5(1)
MFC after: 1 week


193719 08-Jun-2009 jhb

Don't attempt to free the GPT partition list for a disk with an empty GPT.

Submitted by: Yuri Pankov yuri.pankov of gmail
MFC after: 3 days


193530 05-Jun-2009 jkim

Import ACPICA 20090521.


193229 01-Jun-2009 jhb

Add a missing parameter when displaying GPT partitions with an unknown
UUID.

Submitted by: Pawel Worach pawel.worach | gmail
MFC after: 1 week


192194 16-May-2009 dfr

Add support for booting from raidz1 and raidz2 pools.


191111 15-Apr-2009 jkim

A simple rewrite of biossmap.c:

- Do not iterate int 15h, function e820h twice. Instead, we use STAILQ to
store each return buffer and copy all at once.
- Export optional extended attributes defined in ACPI 3.0 as separate
metadata. Currently, there are only two bits defined in the specification.
For example, if the descriptor has extended attributes and it is not
enabled, it has to be ignored by OS. We may implement it in the kernel
later if it is necessary and proven correct in reality.
- Check return buffer size strictly as suggested in ACPI 3.0.

Reviewed by: jhb


191061 14-Apr-2009 jhb

Use a disk address instead of an int to hold the starting offset of an
open partition. This fixes access to partitions whose starting offset
is >= 2 TB.

Submitted by: "James R. Van Artsdalen" james jrv.org
MFC after: 3 days


190814 07-Apr-2009 jkim

Rewrite SMBIOS for loader:

- First three fields of system UUID may be little-endian as described in
SMBIOS Specification v2.6. For now, we keep the network byte order for
backward compatibility (and consistency with popular dmidecode tool)
if SMBIOS table revision is less than 2.6. However, little-endian format
can be forced by defining BOOT_LITTLE_ENDIAN_UUID from make.conf(5) if it
is necessary.
- Replace overly ambitious optimizations with more readable code.
- Update comments to SMBIOS Specification v2.6 and clean up style(9) bugs.


190813 07-Apr-2009 jkim

Increase sprintf(3) buffer size, which I forgot from the previous commit.


190599 31-Mar-2009 jkim

Probe size of installed memory modules from loader and display it
as 'real memory' instead of Maxmem if the value is available.
Note amd64 displayed physmem as 'usable memory' since machdep.c r1.640
to unconfuse users. Now it is consistent across amd64 and i386 again.
While I am here, clean up smbios.c a bit and update copyright date.

Reviewed by: jhb


189749 12-Mar-2009 jhb

The recent change to use memory > 1MB for the heap by default broke CD
booting because the CD driver did not use bounce buffers to ensure
request buffers sent to the BIOS were always in the first 1MB. Copy over
the bounce buffer logic from the BIOS disk driver (minus the 64k boundary
code for floppies) to fix this.

Reported by: kensmith


189588 09-Mar-2009 jhb

- Make it possible to disable GPT support by setting LOADER_NO_GPT_SUPPORT
in make.conf or src.conf.
- When GPT is enabled (which it is by default), use memory above 1 MB and
leave the memory from the end of the bss to the end of the 640k window
purely for the stack. The loader has grown and now it is much more
common for the heap and stack to grow into each other when both are
located in the 640k window.

PR: kern/129526
MFC after: 1 week


189500 07-Mar-2009 marcel

Revert the part of change 107879 that employs the unused bytes after
the disklabel in the 2nd sector for boot code. Even with both UFS1
and UFS2 supported, there's enough bytes left that we don't have to
nibble from the disklabel.
Thus, the entire 2nd sector is now reserved for the disklabel, which
makes the bootcode compatible again with disklabels that have more
than 8 partitions -- such as those created and supported by gpart.

i386: 135 bytes available
amd64: 151 bytes available

Ok'd by: jhb


189017 24-Feb-2009 jhb

Fix some more issues with the real mode BTX.

The old BTX passed the general purpose registers from the 32-bit client to
the routines called via virtual 86 mode. The new BTX did the same thing.
However, it turns out that some instructions behave differently in virtual 86
mode and real mode (even though this is under-documented). For example, the
LEAVE instruction will cause an exception in real mode if any of the upper
16-bits of %ebp are non-zero after it executes. In virtual 8086 mode the
upper 16-bits are simply ignored. This could cause faults in hardware
interrupt handlers that inherited an %ebp larger than 0xffff from the 32-bit
client (loader, boot2, etc.) while running in real mode.

To fix, when executing hardware interrupt handlers provide an explicit clean
state where all the general purpose and segment registers are zero upon
entry to the interrupt handler. While here, I attempted to simplify the
control flow in the 'intusr' code that sets up the various stack frames
and exits protected mode to invoke the requested routine via real mode.

A huge thanks to Tor Egge (tegge@) for debugging this issue.

Submitted by: tegge
Reviewed by: tegge
Tested by: bz
MFC after: 1 week


188895 21-Feb-2009 ru

Fix build when WITH_SSP is set explicitly.

Submitted by: Jeremie Le Hen


187917 30-Jan-2009 gabor

- Remove superfluous comment

PR: docs/129400
Submitted by: Gavin Atkinson <gavin@freebsd.org>


187101 12-Jan-2009 jkim

Allow VIA Nano processors to boot FreeBSD/amd64.

PR: amd64/130303
MFC after: 1 week


186598 30-Dec-2008 luigi

A number of small changes to make the 'save choice to disk' safer,
and re-enable it as default.

In particular:

+ re-enable the 'update' flag in the Makefile (of course!);

+ commit Warner's patch "orb $NOUPDATE,_FLAGS(%bp)"
to avoid writing to disk in case of a timeout/default choice;

+ fix an off-by-one count in the partition scan code that would
print the wrong name for unknown partitions;

+ unconditionally change the boot prompt to 'Boot:' instead of 'Default:'
to make room for the extra code/checks/messages. Some of the changes
listed below are also made to save space;

+ rearrange and fix comments for known partition types. Right now we
explicitly recognise *BSD, Linux, FAT16 (type 6, used on many USB keys),
NTFS (type 7), FAT32 (type 11).
Depending on other options we also recognise Extended (type 5),
FAT12 (type 1) and FAT16 < 32MB (type 4).

+ Add an entry "F6 PXE" when the code is built with -DPXE (which is
a default now). Technically, F6 boots through INT18, so the prompt 'PXE'
is a bit misleading. Unfortunately the name INT18
is too long and does not fit in - we could use ROM perhaps.
The reason I picked 'PXE' is that on many (I believe) new systems
INT18 calls PXE.

Apart from the choice of the name for PXE/ROM/INT18, this should close
pending issues on the 1-sector boot0 code and we should be able to
move the code to RELENG_7 when it reopens.

No boot0cfg changes are necessary.

MFC after: 3 weeks


186243 17-Dec-2008 dfr

Use full 64bit arithmetic when converting file offsets to block numbers - fixes
booting on filesystems with inode numbers with values above 4194304.

Submitted by: ps


185781 09-Dec-2008 sobomax

Remove now unused label.

Submitted by: Christoph Mallon
MFC after: 4 weeks
(along with r185779 and r185780)


185780 09-Dec-2008 sobomax

Optimiza assembly in the previous r185779, to save whooping 16 bytes.

Submitted by: Christoph Mallon
MFC after: 4 weeks
(including r185779)


185779 08-Dec-2008 sobomax

Respect RBX_MUTE flag from boot[012].

MFC after: 4 weeks


185776 08-Dec-2008 sobomax

Fix typo in the comment %is -> %si.


185579 03-Dec-2008 luigi

Another, hopefully final set of changes to boot0 and boot0cfg.

boot0.S changes:

+ import a patch from Christoph Mallon to rearrange the various
print functions and save another couple of bytes;

+ implement the suggestion in PR 70531 to enable booting from
any valid partition because even the extended partitions that
were previously in our kill list may contain a valid boot loader.
This simplifies the code and saves some bytes;

+ followwing up PR 127764, implement conditional code to preserve
the 'Volume ID' which might be used by other OS (NT, XP, Vista)
and is located at offset 0x1b8. This requires a relocation of the
parameter block within the boot sector -- there is no other
possible workaround.
To address this, boot0cfg has been updated to handle both
versions of the boot code;

+ slightly rearrange the strings printed in the menus to make
the code buildable with all options. Given the tight memory
budget, this means that with certain options we need to
shrink or remove certain labels.

and especially:

make -DVOLUME_LABEL -DPXE the default options.

This means that the newly built boot0 block will preserve the
Volume ID, and has the (hidden) option F6 to boot from INT18/PXE.
I think the extra functionality is well worth the change.

The most visible difference here is that the 'Default: ' string
now becomes 'Boot: ' (it can be reverted to the old value
but then we need to nuke 1/2 partition name or entries to
make up for the extra room).

boot0cfg changes:

+ modify the code to recognise the new boot0 structure (with the
relocated options block to make room for the Volume id).

+ add two options, '-i xxxx-xxxx' to set the volume ID, -e c
to modify the character printed in case of bad input

PR: 127764 70531
Submitted by: Christoph Mallon (portions)
MFC after: 4 weeks


185562 02-Dec-2008 luigi

This commits brings in a lot of documentation and some enhancement
of the boot0.S code, with a number of compile-time selectable options,
the most interesting one being the ability to select PXE booting.

The code is completely compatible with the previous one, and with
the boot0cfg program. Even the actual code is largely unmodified,
with only minor rearrangements or fixes to make room for the new
features.

The behaviour of the standard build differs from the previous
version in the following, minor things:

+ 'noupdate' is the default, which means the code does not
write back the selection to disk. You can enable the feature
at runtime with boot0cfg, or changing the flags in the Makefile.

+ a drive number of 0x00 (floppy, or USB in floppy emulation) is
now accepted as valid. Previously, it was overridden with 0x80,
meaning that the partition table coming from the media was
used to access sectors on a possibly different media.
You can revert to the previous mode building with -DCHECK_DRIVE,
and you can always use the 'setdrv' option in boot0cfg

+ certain FAT or NTFS partitions are listed as WIN instead of DOS.

+ the 'bel' character on a bad selection is replaced by a '#' to
make it clear that the system is not hang even if the machine
does not have a speaker. This can be reverted back at compile
time, or at runtime with an upcoming boot0cfg option.

Additional features are available as compile time options,
and may be become the default if deemed useful. In particular:

+ INT18/PXE boot (make -DPXE)
This option enables booting through INT 18h (which on certain
BIOSes can be hooked to PXE) by pressing F6. There is unfortunately
no room to print the additional menu option.
Also, to make room for the code, the 'Default: ' string is
changed to 'Boot: '

+ print current drive number (make -DTEST)
Prints a line indicating the current drive number.
This is useful to figure out what is going on for machines/bioses
which remap drives in sometimes surprising ways.

+ disable numeric keys in console mode (make -DONLY_F_KEYS)
Not really a significant option, but it is needed to make
room for the -DTEST mode.

+ disable floppy support (make -DCHECK_DRIVE)
Revert to the old behaviour of only accepting 0x80 and above
as valid drive numbers.

MFC after: 6 weeks


185346 26-Nov-2008 luigi

Fix a typo in previous commit: must call "putn" to print a crlf,
instead of "puts" which prints whatever is at %si, followed by a CRLF.

It was not noticed during tests because at that point %si points
to a partition entry whose first byte is 0x80, which is both a
terminator for the string and a non printable character.

Submitted by: Christoph Mallon


185339 26-Nov-2008 luigi

Pass the pointer to the selected partition in %si to the next stage
boot code. The bug was introduced in rev.1.13, and went unnoticed
because FreeBSD's boot1 does not use it, but other systems might.

(I have been struggling for almost a full day trying to figure out
why a syslinux'ed partition would not boot when started with the
FreeBSD /boot/boot0, only to realize that the bug was ours!)

The space for the two extra bytes (push %si and pop %si) is reclaimed
by removing an extra CRLF that is printed before booting.

The bug is not a major one but if there is time it might be a good
thing to merge it into the upcoming releases.


185175 22-Nov-2008 dfr

Fix amd64 build and re-enable gptzfsboot.


185151 21-Nov-2008 des

Disconnect gptzfsboot from the build until dfr@ gets his act together.


185096 19-Nov-2008 dfr

Add a GPT-aware variant of zfsboot which should be used in a similar manner
to gptboot, i.e. installed in a freebsd-boot partition using /sbin/gpart or
/sbin/gpt.

Tweak the /boot/loader ZFS support so that it can find ZFS pools that are
contained in GPT partitions.


185095 19-Nov-2008 dfr

If we free the GPT partition list in bd_open_gpt() because of an error, don't
try to free it again in bd_closedisk(). While I'm here, fix a DEBUG print.


185045 18-Nov-2008 ache

Fix building without ZFS (can't find library)


185029 17-Nov-2008 pjd

Update ZFS from version 6 to 13 and bring some FreeBSD-specific changes.

This bring huge amount of changes, I'll enumerate only user-visible changes:

- Delegated Administration

Allows regular users to perform ZFS operations, like file system
creation, snapshot creation, etc.

- L2ARC

Level 2 cache for ZFS - allows to use additional disks for cache.
Huge performance improvements mostly for random read of mostly
static content.

- slog

Allow to use additional disks for ZFS Intent Log to speed up
operations like fsync(2).

- vfs.zfs.super_owner

Allows regular users to perform privileged operations on files stored
on ZFS file systems owned by him. Very careful with this one.

- chflags(2)

Not all the flags are supported. This still needs work.

- ZFSBoot

Support to boot off of ZFS pool. Not finished, AFAIK.

Submitted by: dfr

- Snapshot properties

- New failure modes

Before if write requested failed, system paniced. Now one
can select from one of three failure modes:
- panic - panic on write error
- wait - wait for disk to reappear
- continue - serve read requests if possible, block write requests

- Refquota, refreservation properties

Just quota and reservation properties, but don't count space consumed
by children file systems, clones and snapshots.

- Sparse volumes

ZVOLs that don't reserve space in the pool.

- External attributes

Compatible with extattr(2).

- NFSv4-ACLs

Not sure about the status, might not be complete yet.

Submitted by: trasz

- Creation-time properties

- Regression tests for zpool(8) command.

Obtained from: OpenSolaris


183667 07-Oct-2008 jhb

Use CPUID to see if the current CPU supports long mode when attemping to
boot an amd64 kernel. If not, then fail the boot request with an error
message. Otherwise, the boot attempt will fail with a BTX fault when
trying to read the EFER MSR.

MFC after: 3 days


181436 08-Aug-2008 jhb

- Initialize the vm86 structure to a known-good state. Specifically, always
set the %eflags used during a BIOS call via BTX to 0x202. Previously
the flags field was uninitialized garbage, and thus it was "random" if
interrupts were enabled or not during BIOS calls.
- Use constants from <machine/psl.h> for fields in %eflags.

MFC after: 3 days


181433 08-Aug-2008 jhb

Fix the hangs reported with the real mode BTX:
- I had errantly assumed that all user requests should run with interrupts
enabled. User requests for software interrupts, however, need to disable
interrupts (and tracing) just like hardware interrupts.
- Disable alignment checking when emulating a hardware interrupt as well
(based on the description of the real mode operation of the 'INT'
instruction in the IA-32 manuals).
- Use constants for fields in %eflags.

Tested by: bz
MFC after: 3 days


181282 04-Aug-2008 cperciva

Dereferencing uninitialized pointers considered harmful. Prior to this
commit, calling i386_parsedev(..., X, ...) where X is "ad", "bge", or
any other disk or network device name without a unit number, would
result in dereferencing whatever happened to be on the stack where the
variable "cp" is stored.

Found by: LLVM/Clang Static Checker


180208 03-Jul-2008 peter

Set magic fbsd:nokeywords property that allows files to bypass
keyword expansion. (file-specific replacement for CVSROOT/exclude)


180145 01-Jul-2008 nyan

Fix off-by-one error.

MFC after: 1 week


180012 25-Jun-2008 ru

Enable GCC stack protection (aka Propolice) for userland:
- It is opt-out for now so as to give it maximum testing, but it may be
turned opt-in for stable branches depending on the consensus. You
can turn it off with WITHOUT_SSP.
- WITHOUT_SSP was previously used to disable the build of GNU libssp.
It is harmless to steal the knob as SSP symbols have been provided
by libc for a long time, GNU libssp should not have been much used.
- SSP is disabled in a few corners such as system bootstrap programs
(sys/boot), process bootstrap code (rtld, csu) and SSP symbols themselves.
- It should be safe to use -fstack-protector-all to build world, however
libc will be automatically downgraded to -fstack-protector because it
breaks rtld otherwise.
- This option is unavailable on ia64.

Enable GCC stack protection (aka Propolice) for kernel:
- It is opt-out for now so as to give it maximum testing.
- Do not compile your kernel with -fstack-protector-all, it won't work.

Submitted by: Jeremie Le Hen <jeremie@le-hen.org>


179825 16-Jun-2008 olli

Implement a workaround for a long-standing problem in
libi386's time(), caused by a qemu bug. The bug might
be present in other BIOSes, too.

qemu either does not simulate the AT RTC correctly or
has a broken BIOS 1A/02 implementation, and will return
an incorrect value if the RTC is read while it is being
updated.

The effect is worsened by the fact that qemu's INT 15/86
function ("wait" a.k.a. usleep) is non-implmeneted or
broken and returns immediately, causing beastie.4th to
spin in a tight loop calling the "read RTC" function
millions of times, triggering the problem quickly.

Therefore, we keep reading the BIOS value until we get
the same result twice. This change fixes beastie.4th's
countdown under qemu.

Approved by: des (mentor)


179631 07-Jun-2008 jhb

Workaround a bug in the BIOS of Dell R900 machines. Specifically, each
entry in the SMAP is a 20 byte structure and they are queried from the
BIOS via sucessive BIOS calls. Due to an apparent bug in the R900's
BIOS, for some SMAP requests the BIOS overflows the 20 byte buffer
trashing a few bytes of memory immediately after the SMAP structure. As
a workaround, add 8 bytes of padding after the SMAP structure used in
the loader for SMAP queries.

PR: i386/122668
Submitted by: Mike Hibler mike flux.utah.edu, silby
MFC after: 3 days


178037 09-Apr-2008 jhb

Revert the previous change and let PROBE_KEYBOARD function identical to -P
in boot2/gptboot.


177626 26-Mar-2008 brueffer

Fix some "in in" typos in comments.

PR: 121490
Submitted by: Anatoly Borodin <anatoly.borodin@gmail.com>
Approved by: rwatson (mentor), jkoshy
MFC after: 3 days


177039 10-Mar-2008 jhb

Change the BTX kernel to drop all the way out to real mode to invoke BIOS
routines (V86 requests from the client and hardware interrupt handlers):
- Install trampoline real mode interrupt handlers at IDT vectors 0x20-0x2f
to handle hardware interrupts by invoking the appropriate vector (0x8-0xf
or 0x70-0x78). This allows the 8259As to use vectors 0x20-0x2f in real
mode as well as protected mode will ensuring that the master 8259A
doesn't share IDT space with CPU exceptions in protected mode.
- Since we don't need to reserve space for page tables and a page directory
anymore since dropping paging support, move the TSS and protected mode
IDT up by 16k. Grow the ring 1 link stack by 16k as a result.
- Repurpose the ring 1 link stack to be used as a real mode stack when
invoking real mode routines either via a V86 request or a hardware
interrupts. This simplifies a few things as we avoid disturbing the
original user stack.
- Add some more block comments to explain how the code interacts with the
V86 structure as this wasn't immediately obvious from the prior comments
(e.g. that we explicitly copy the seg regs for real mode out of the V86
struct onto the stack to be popped off when going into real mode, etc.).
Also, document some of the stack frames we create going to real mode and
back.
- Remove all of the virtual 86 related code including having to simulate
various instructions and BIOS calls on a trap from virtual 86 mode.
- Explicitly panic if a user client attempts to perform a V86 CALL
request that isn't a far call.
- Bump version to 1.2.

Assuming this works ok this should fix some of the long standing issues
with USB booting as well as etherboot.

MFC after: 2 weeks
Submitted by: kib (some parts from his original real mode patch)


176882 06-Mar-2008 jhb

In the PROBE_KEYBOARD case, always enable multiple consoles and set the
serial console as the primary console if the keyboard probe fails.

MFC after: 1 week


176646 28-Feb-2008 jhb

Tweak the verbose disk printing a bit:
- Consolidate the code to humanize the size of a disk partition into a
single function based on the code for GPT partitions and use it for
GPT partitions, BSD slices, and BSD partitions.
- Teach the humanize code to use KB for small partitions (e.g. GPT boot
partitions now show up as 64KB rather than 0MB).
- Pad a few partition type names out so that things line up in the
common case.

MFC after: 1 week


176644 28-Feb-2008 jhb

Rev 1.72 fixed a bug where if /boot.config changed the console its contents
weren't displayed on the new console. However, the config string has been
altered as part of being parsed so we only display the first option. Fix
this by saving a copy of /boot.config before parsing it and displaying the
saved copy after parsing.

MFC after: 1 week
PR: i386/103972
Submitted by: Alexandre Belloni alexandre.belloni of netasq.com


176631 27-Feb-2008 jhb

Retire the support for using paging in BTX. It hasn't been used since
before 4.0.

Submitted by: kib


173957 26-Nov-2007 jhb

Add a note to indicate that these files do borrow in part from mbr.s and
boot1.S

Requested by: rnordier


173697 17-Nov-2007 jhb

Add a trailing \0 to the read error string so that read errors don't print
out two error messages.

MFC after: 3 days


173575 12-Nov-2007 bz

Though we are currently not interested in the EDD3 flag,
Enhanced Disk Drive Specification Ver 3.0 defines that the version
of extension in AH would be 30h.
Correct the check for that to be >=30h instead of >3h.
MFC after: 2 months


173118 28-Oct-2007 jhb

- Add constants for the different memory types in the SMAP table.
- Use the SMAP types and constants from <machine/pc/bios.h> in the boot
code rather than duplicating it.


173040 26-Oct-2007 jhb

Use the smaller cgbase() macro in ufsread.c if UFS_SMALL_CGBASE is
defined. This lets each boot program choose which version of cgbase() it
wants to use rather than forcing ufsread.c to have that knowledge.

MFC after: 1 week
Discussed with: imp


173026 26-Oct-2007 jhb

Add . to the include path so that we follow the 'machine' symlink we create
during depend on amd64.

Reported by: rwatson


172974 25-Oct-2007 jhb

Break out of the I/O retry loop as soon as an I/O operation succeeds rather
than always retrying operations three times.

Submitted by: nyan


172940 24-Oct-2007 jhb

First cut at support for booting a GPT labeled disk via the BIOS bootstrap
on i386 and amd64 machines. The overall process is that /boot/pmbr lives
in the PMBR (similar to /boot/mbr for MBR disks) and is responsible for
locating and loading /boot/gptboot. /boot/gptboot is similar to /boot/boot
except that it groks GPT rather than MBR + bsdlabel. Unlike /boot/boot,
/boot/gptboot lives in its own dedicated GPT partition with a new
"FreeBSD boot" type. This partition does not have a fixed size in that
/boot/pmbr will load the entire partition into the lower 640k. However,
it is limited in that it can only be 545k. That's still a lot better than
the current 7.5k limit for boot2 on MBR. gptboot mostly acts just like
boot2 in that it reads /boot.config and loads up /boot/loader. Some more
details:
- Include uuid_equal() and uuid_is_nil() in libstand.
- Add a new 'boot' command to gpt(8) which makes a GPT disk bootable using
/boot/pmbr and /boot/gptboot. Note that the disk must have some free
space for the boot partition.
- This required exposing the backend of the 'add' function as a
gpt_add_part() function to the rest of gpt(8). 'boot' uses this to
create a boot partition if needed.
- Don't cripple cgbase() in the UFS boot code for /boot/gptboot so that
it can handle a filesystem > 1.5 TB.
- /boot/gptboot has a simple loader (gptldr) that doesn't do any I/O
unlike boot1 since /boot/pmbr loads all of gptboot up front. The
C portion of gptboot (gptboot.c) has been repocopied from boot2.c.
The primary changes are to parse the GPT to find a root filesystem
and to use 64-bit disk addresses. Currently gptboot assumes that the
first UFS partition on the disk is the / filesystem, but this algorithm
will likely be improved in the future.
- Teach the biosdisk driver in /boot/loader to understand GPT tables.
GPT partitions are identified as 'disk0pX:' (e.g. disk0p2:) which is
similar to the /dev names the kernel uses (e.g. /dev/ad0p2).
- Add a new "freebsd-boot" alias to g_part() for the new boot UUID.

MFC after: 1 month
Discussed with: marcel (some things might still change, but am committing
what I have so far)


172927 24-Oct-2007 jhb

Rework the read/write support in the bios disk driver some to cut down
on duplicated code and support 64-bit LBAs for GPT.
- The code to manage an EDD or C/H/S I/O request are now in their own
routines. The EDD routine now handles a full 64-bit LBA instead of
truncating LBAs to the lower 32-bits. (MBRs and BSD labels only
have 32-bit LBAs anyway, so the only LBAs ever passed down were 32-bit).
- All of the bounce buffer and retry logic duplicated in bd_read() and
bd_write() are merged into a single bd_io() routine that takes an
extra direction argument. bd_read() and bd_write() are now simple
wrappers around bd_io().
- If a disk supports EDD then always use it rather than only using it if
the cylinder is > 1023. Other parts of the boot code already do
something similar to this. Also, GPT just uses LBAs, so for a GPT disk
it's probably best to ignore C/H/S completely. Always using EDD when
it is supported by a disk is an easy way to accomplish this.

MFC after: 1 week


172922 24-Oct-2007 jhb

Reindent the read/write code of bd_realstrategy() so it is more readable.

MFC after: 1 week


172921 24-Oct-2007 jhb

Slightly cleanup the 'bootdev' concept on x86 by changing the various
macros to treat the 'slice' field as a real part of the bootdev instead
of as hack that spans two other fields (adaptor (sic) and controller)
that are not used in any modern FreeBSD boot code.

MFC after: 1 week


172591 12-Oct-2007 ps

Do not attempt to make an NFS rpc call if using tftp

PR: kern/91720
Submitted by: Ruben Kerkhof


170101 29-May-2007 simokawa

MFp4: add FireWire/dcons support in loader for i386/amd64.

It is disabled by default. You need to put
LOADER_FIREWIRE_SUPPORT=yes in /etc/make.conf
and rebuild loader to enable it.
(cd /sys/boot/i386 && make clean && make && make install)

You can find a short introduction of dcons at
http://wiki.freebsd.org/DebugWithDcons


169842 21-May-2007 jkim

Use lower cases for UUID string to conform RFC4122 and ISO/IEC-9834-8:2005.


169732 19-May-2007 kan

Tweak inlining parameters a little. Add warning to tell us if function
we declared as inline can not be inlined.


167914 26-Mar-2007 thomas

Fix setting of serial port speed. A junk value was passed in AX when
bioscom is called to set up serial port parameters because COMSPEED
was treated as an address instead of an immediate value, causing
serial port parameters to never be set.

PR: i386/110828
Reviewed by: jhb
MFC after: 2 weeks


167814 22-Mar-2007 jkim

Catch up with ACPI-CA 20070320 import.


166926 23-Feb-2007 remko

Fix the cdboot twiddle display.
I created and tested this with a custom FreeSBIE cd-image.

PR: i386/96452
Submitted by: Yuichiro Goto <y7goto at gmail dot com>
MFC after: 3 days
Approved by: imp (mentor)


164948 06-Dec-2006 jhb

Ignore any breakpoint instructions (int 3) we encounter in vm86 mode
rather than treating them as a fatal exception and halting. At least one
storage BIOS (some newer mpt(4) parts) have a breakpoint instruction in
their disk read routine.

MFC after: 3 days


164335 16-Nov-2006 ru

Remove an unused variable.


163914 02-Nov-2006 ru

Revert the last change. Masking only 2 MSBs of the virtual address
to get the physical address doesn't work for all values of KVA_PAGES,
while masking 8 MSBs works for all values of KVA_PAGES that are
multiple of 4 for non-PAE and 8 for PAE. (This leaves us limited
with 12MB for non-PAE kernels and 14MB for PAE kernels.)

To get things right, we'd need to subtract the KERNBASE from the
virtual address (but KERNBASE is not easy to figure out from here),
or have physical addresses set properly in the ELF headers.

Discussed with: jhb


163897 02-Nov-2006 marcel

Extend struct devdesc with a unit field, called d_unit. Promote the
device (kind) specific unit field to the common field. This change
allows a future version of libefi to work without requiring anything
more than what is defined in struct devdesc and as such makes it
possible to compile said version of libefi for different platforms
without requiring that those platforms have identical derivatives
of struct devdesc.


163893 02-Nov-2006 marcel

Don't unconditionally compile-in the bcache code. It's only used on
i386/amd64 and pc98. Remove useless calls to bcache_init() from the
ia64 and sparc64 loaders, as well as from the OFW common code.


163765 29-Oct-2006 ru

Because the BTX mini-kernel now uses flat memory mode and clients
are no longer limited to a virtual address space of 16 megabytes,
only mask high two bits of a virtual address. This allows to load
larger kernels (up to 1 gigabyte). Not masking addresses at all
was a bad idea on machines with less than >3G of memory -- kernels
are linked at 0xc0xxxxxx, and that would attempt to load a kernel
at above 3G. By masking only two highest bits we stay within the
safe limits while still allowing to boot larger kernels.

(This is a safer reimplmentation of sys/boot/i386/boot2/boot.2.c
rev. 1.71.)

Prodded by: jhb
Tested by: nyan (pc98)


163708 26-Oct-2006 ru

Adopt comments borrowed from aout_freebsd.c.


163707 26-Oct-2006 ru

Restore support for -c and -d that were treacherously murdered in
rev. 1.58. (This only costs us four bytes.)

Prodded by: bde
MFC after: 3 days


163706 26-Oct-2006 ru

Back out rev. 1.71 as it breaks directly loading (i386) kernels.

OK'ed by: jhb
PR: i386/96430, i386/104709
MFC after: 3 days


163070 07-Oct-2006 pav

- Update URL of Intel documentation

Submitted by: Rob <spamrefuse@yahoo.com> on freebsd-doc
MFC after: 3 days


163032 05-Oct-2006 jhb

- Fix a couple of improper uses of leal in the previous space saving
commits. For some reason I thought the scale factor was a shift count
rather than the multiplicand (that is, I thought leal (%eax,%edx,4) was
going to generate %eax + %edx << 4 rather than %eax + %edx * 4). What
I need is to multiply by 16 to convert a real-mode (seg, offset) tuple
into a flat address. However, the max multiplicand for scaled/index
addressing on i386 is 8, so go back to using a shl and an add.
- Convert two more inter-register mov instructions where we don't need to
preserve the source register to xchg instructions to keep our space
savings.

Tested by: Ian FREISLICH if at hetzner.co.za
MFC after: 1 week


162814 29-Sep-2006 ru

Fix most of the WARNS=2 warnings.


162813 29-Sep-2006 jhb

Oops, add return values for the smap command function. We must have the
warnings set weird or something because gcc didn't warn about this at all.

Submitted by: ru


162745 28-Sep-2006 jhb

Tweak the code to handle intercepting BIOS calls to int 0x15 to shave
another 16 bytes off of BTX (and thus boot2):
- Compare against the value of %eax that is saved on the stack instead of
loading it into %eax (which requires saving the current %eax on the
stack).
- Use %ch to examine the keyboard flag state in the BIOS to see if
Ctrl-Alt-Del is pressed instead of %al so we don't have to save %eax on
the stack anymore.

MFC after: 1 week


162744 28-Sep-2006 jhb

Optimize the int 15/87 handler for space to shave another 16 bytes off of
BTX (and thus boot2):
- Don't bother saving %eax, %ebx, or %ecx as it is not necessary.
- Use a more compact sequence to load the base value out of a GDT entry
by loading the contiguous low 24 bits into the upper 24 bits of %eax,
loading the high 8 bits into %al, and using a ror to rotate the bits
(2 mov's and a ror) rather than loading the pieces in smaller chunks
(3 mov's and a shl).
- Use movzwl + leal instead of movl + movw + shll + addl.
- Use 'xchgl %eax,%foo' rather than 'movl %eax,%foo' for cases where
it's ok to trash %eax. xchgl %eax, foo is a 1-byte opcode whereas the
mov is a 2-byte opcode.
- Use movzwl rather than xorl + movw.

MFC after: 1 week


162743 28-Sep-2006 jhb

Add an 'smap' command that dumps out the BIOS SMAP.

MFC after: 1 week


162737 28-Sep-2006 jhb

A couple of simple tweaks that trim BTX by 6 bytes. Since BTX is
16-byte aligned within boot2 however, this actually trims boot2 by 16
bytes.


162717 28-Sep-2006 ru

Add -march=i386 to fix amd64 build by generating the same code
as i386 would do.


162710 27-Sep-2006 jhb

Emulate moving cr0, cr2, cr3, or cr4 into any i386 general register
rather than just emulating mov cr0, eax. This fixes some Compaq/HP BIOS
with DMA (as the BIOS tried to read cr3 so it could translate addresses
if paging was enabled).

MFC after: 1 week


162046 05-Sep-2006 ru

- Include <sys/reboot.h> to get the RB_* defines.

- Make the PROBE_KEYBOARD option better resemble the -P option in
boot2, i.e., if keyboard isn't present then boot with both
RB_SERIAL and RB_MULTIPLE set.

Reviewed by: jhb


160964 04-Aug-2006 yar

Commit the results of the typo hunt by Darren Pilgrim.
This change affects documentation and comments only,
no real code involved.

PR: misc/101245
Submitted by: Darren Pilgrim <darren pilgrim bitfreak org>
Tested by: md5(1)
MFC after: 1 week


159096 31-May-2006 iedowse

Increment the disk block offset after writing, not before. This
fixes filesystem corruption when nextboot.conf is located after
cylinder 1023. The bug appears to have been introduced at the time
bd_read was copied to create bd_write.

PR: bin/98005
Reported by: yar
MFC after: 1 week


158265 03-May-2006 jhb

Restore the pre-5.x behavior of only beeping if the user makes a bad
selection and not always beeping on startup. The two bytes for the extra
'jmp' instruction were obtained by removing recognition of BSD/OS
partitions.

Requested by: many
Tested by: subset of many
Head nod: imp, keramida
MFC after: 2 weeks


158023 25-Apr-2006 jhb

Use PTOV() to convert physical addresses to appropriate virtual addresses
in the loader when searching for the ACPI RSDP. (The loader runs in a flat
mode with va 0 == pa 0xa000.)


157669 11-Apr-2006 sobomax

Merge in timeout into A20-enable routine from cdboot/boot1.

MFC after: 1 day


157668 11-Apr-2006 jhb

Drop the gateA20() function in the loader as it is unused. All the other
boot loaders that load the loader already handle A20. In fact, they are
required to do so in order to setup the environment that btxldr expects.


157667 11-Apr-2006 jhb

Minor whitespace tweak.


157664 11-Apr-2006 jhb

Tweak comment.


157663 11-Apr-2006 jhb

Use the proper condition to determine that we matched an filename.
Otherwise, we could match on a filename that had the wrong last character
(such as /boot/loaded instead of /boot/loader).

PR: kern/95625
Submitted by: Oliver Fromme <olli@secnetix.de>
MFC after: 1 month


157652 11-Apr-2006 sobomax

When enabling A20 put upper limit on amount of time we wait for the keyboard
controller to get ready (65K x ISA access time, visually around 1 second).
If we have wait more than that amount it's likely that the hardware is a
legacy-free one and simply doesn't have keyboard controller and doesn't
require enabling A20 at all.

This makes cdboot working for MacBook Pro with Boot Camp.

MFC after: 1 day


156813 17-Mar-2006 ru

Reimplementation of world/kernel build options. For details, see:

http://lists.freebsd.org/pipermail/freebsd-current/2006-March/061725.html

The src.conf(5) manpage is to follow in a few days.

Brought to you by: imp, jhb, kris, phk, ru (all bugs are mine)


156712 14-Mar-2006 jkim

Export SMBIOS serial numbers by default. To turn it off, use
'BOOT_HIDE_SERIAL_NUMBERS' knob.

Suggested by: ceri


156558 10-Mar-2006 jkim

Micro-optimize invalid UUID check.


156519 09-Mar-2006 jkim

- Implement serial numbers, UUID, and asset tag (turned off by default).
Use 'BOOT_SENSITIVE_INFO=YES' variable to turn them on.
- Use 'uint*_t' instead of 'u_int*_t', correct compilation warnings, and
update copyright while I am here.


153589 21-Dec-2005 sobomax

For the cases when loading bzip2-compressed kernels enabled use last
3MB of physical memory for heap instead of range between 1MB and 4MB.
This makes this feature working with PAE and amd64 kernels, which are
loaded at 2MB. Teach i386_copyin() to avoid using range allocated by
heap in such case, so that it won't trash heap in the low memory
conditions.

This should make loading bzip2-compressed kernels/modules/mfs images
generally useable, so that re@ team is welcome to evaluate merits
of using this feature in the installation CDs.

Valuable suggestions by: jhb


153536 19-Dec-2005 sobomax

If LOADER_BZIP2_SUPPORT is defined allocate heap in the 1MB-4MB range to
provide enough room for decompression (up to 2.5MB is necessary). This
should be safe to do since we load i386 kernels after 8MB mark now, so
that 16MB is the minimum amount of RAM necessary to even boot FreeBSD.

This makes bzip2-support practically useable.


153535 19-Dec-2005 sobomax

Long-long time ago, when the trees were large and memory expensive amount of
memory directly available to loader(8) and friends was limited to 640K on i386.
Those times have passed long time ago and now loader(8) can directly access
up to 4GB of RAM at least theoretically. At the same time, there are several
places where it's assumed that malloc() will only allocate memory within
first megabyte.

Remove that assumption by allocating appropriate bounce buffers for BIOS
calls on stack where necessary.

This allows using memory above first megabyte for heap if necessary.


151999 03-Nov-2005 ru

Consistently use OPT_* macros to test/set boot options.


151874 30-Oct-2005 scottl

Add back some bits.


151452 18-Oct-2005 jkim

Export processor socket information. New environment variables are:

smbios.socket.enabled: number of enabled sockets
smbios.socket.populated: number of populated sockets


151382 16-Oct-2005 sobomax

Re-implement rev.1.76 with respect to the code size.


151381 16-Oct-2005 sobomax

Backout previous commit - for some reason it overflows space constrains on
amd64. Better version will follow.


151367 16-Oct-2005 sobomax

Add new option `q', which makes second stage loader quiet unless autoboot
is disabled or fails.

MFC after: 1 week


150470 22-Sep-2005 ru

Cause all flags passed by boot2 to set the respective loader(8)
boot_* variable. The end effect is that all flags from boot2
are now passed to the kernel.


150469 22-Sep-2005 ru

Add loader(8) variables for RB_DFLTROOT, RB_MUTE, and RB_PAUSE:
"boot_dfltroot", "boot_mute", and "boot_pause" respectively.


150464 22-Sep-2005 ru

- RBX_MASK wasn't updated when RB_PAUSE was changed from 0x40000
to 0x100000 in rev. 1.67.

- NOPT wasn't updated (decremented) in previous revision.


149213 18-Aug-2005 iedowse

Add a "comconsole_speed" loader variable that can be used to change
the serial console speed (i386 and amd64 only). If the previous
stage boot loader requested a serial console (RB_SERIAL or RB_MULTIPLE)
then the default speed is determined from the current serial port
speed. Otherwise it is set to 9600 or the value of BOOT_COMCONSOLE_SPEED
at compile time.

This makes it possible to set the serial port speed once in
/boot.config and the setting will propagate to boot2, loader and
the kernel serial console.


149212 18-Aug-2005 iedowse

Add the ability to specify the boot2 serial console speed in
/boot.config or on the "boot:" prompt line via a "-S<speed>" flag,
e.g. "-h -S19200". This adds about 50 bytes to the size of boot2
and required a few other small changes to limit the size impact.
This changes only affects boot2; there are further loader changes
to follow.


148767 06-Aug-2005 ssouhlal

The kernel is usually at /boot/kernel/kernel nowadays.

PR: i386/81756
Submitted by: trasz <trasz@buziaczek.pl>


148450 27-Jul-2005 jkim

Simplify SMBIOS loader variables and drop `hint.smbios.0.enabled'.

They are not real hints.

Reported by: des
Pointed out by: peter
Approved by: anholt (mentor)


148046 15-Jul-2005 ache

Add -mno-sse3 for prescott/nocona


148006 14-Jul-2005 jkim

Scan static SMBIOS structures and export the following environment
variables to loader:

hint.smbios.0.enabled "YES" when SMBIOS is detected

hint.smbios.0.bios.vendor BIOS vendor
hint.smbios.0.bios.version BIOS version
hint.smbios.0.bios.reldate BIOS release date

hint.smbios.0.system.maker System manufacturer
hint.smbios.0.system.product System product name
hint.smbios.0.system.version System version number

hint.smbios.0.planar.maker Base board manufacturer
hint.smbios.0.planar.product Base board product name
hint.smbios.0.planar.version Base board version number

hint.smbios.0.chassis.maker Enclosure manufacturer
hint.smbios.0.chassis.version Enclosure version

These strings can be used to detect hardware quirks and to set appropriate
flags. For example, Compaq R3000 series and some HP laptops require

hint.atkbd.0.flags="0x9"

to boot. See amd64/67745 for more detail.

Note: Please do not abuse this feature to resolve general problem when it
can be fixed programmatically. This must be used as a last resort.

PR: kern/81449
Approved by: anholt (mentor)


146874 01-Jun-2005 obrien

Temperarly disable building in the bzip2 support by default so we can fit
on the i386 floppies. Sigh, I hate floppies.


146840 31-May-2005 obrien

Put bzip2 support on equal footing with gzip support.
Enable bzip2 support by default, set LOADER_NO_BZIP2_SUPPORT to disable it.

Pointy hat to: sobomax


146698 27-May-2005 jhb

- Add support to the loader for multiple consoles.
- Teach the i386 and pc98 loaders to honor multiple console requests from
their respective boot2 binaries so that the same console(s) are used in
both boot2 and the loader.
- Since the kernel doesn't support multiple consoles, whichever console is
listed first is treated as the "primary" console and is passed to the
kernel in the boot_howto flags.

PR: kern/66425
Submitted by: Gavin Atkinson gavin at ury dot york dot ac dot uk
MFC after: 1 week


146697 27-May-2005 jhb

Fix a warning by adding a missing 'const'.

MFC after: 1 week


146696 27-May-2005 jhb

Print out the commands from /boot.config after parsing them so that they
output is sent to the correct console(s).

PR: kern/66425
Submitted by: Gavin Atkinson gavin at ury dot york dot ac dot uk
MFC after: 1 week


146448 20-May-2005 charnier

Remove unused variables. Remove prototype for function that does not exist.


145515 25-Apr-2005 ru

Allow BOOT_BOOT0_COMCONSOLE_SPEED to be derived from BOOT_COMCONSOLE_SPEED
at compile time.


145209 17-Apr-2005 wollman

Pass the hostname we got from DHCP to the kernel so that machines can
share a read-only NFS root.


145158 16-Apr-2005 njl

Extend a local buffer to prevent an overflow of the XSDT address.

Submitted by: Joerg Sonnenberger
Obtained from: DragonflyBSD
MFC after: 1 day


144837 09-Apr-2005 stefanf

Fix 'implicit int' instance.


143661 15-Mar-2005 obrien

Ensure GCC does not use FP registers in integer code.
I think all we really need is -fno-sse2.
I really don't like cluttering up the compiler invocation,
but this bigger hammer will fix reported problems for now.


143476 12-Mar-2005 kan

Allow kernels loaded by pxeboot, which was compiled with LOADER_TFTP_SUPPORT,
to stll be able to mount NFS root as prescribed by DCHP configuration. Since
pxeboot is using TFTP to get to the files, pxeboot can not rely on NFS to
provide it a root directory hande as a side effect. pxeboot has to make RPC
mount call itself.


141540 08-Feb-2005 des

Remove type 0x4 (FAT12 <32MB) to make room for type 0x7 (NTFS).


139948 09-Jan-2005 peadar

Only update the boot sector when there is a valid drive number provided.
(After squeezing a few more bytes out of boot0)

Discussed With: jhb, julian
PR: 66248
Submitted By: Hans Petter Selasky
MFC After: 1 week


139123 21-Dec-2004 ru

NOFORTH -> NO_FORTH


139112 21-Dec-2004 ru

NOSHARED -> NO_SHARED


139103 21-Dec-2004 ru

Start the dreaded NOFOO -> NO_FOO conversion.

OK'ed by: core


138249 01-Dec-2004 scottl

Remove the last vestiges of the userconfig option. None of this actually
did anything, so this commit should be considered a NO-OP.


138186 29-Nov-2004 ru

Pick up loader.rc from its old home.


138183 29-Nov-2004 scottl

Disable the beastie menu. It offends some and annoys everyone else, and I'm
frankly tired of the controversy. When people ask me why FreeBSD isn't user-
friendly, I'll tell them that I tried. RIP.


138048 24-Nov-2004 jhb

- If the COMSPEED is set to 0, then don't try to initialize the serial port
and assume that the BIOS has set it up for us. This allows folks with a
serial-aware BIOS to set the BIOS to speeds above 9600 and allow boot0 to
just use the existing settings.
- Purge some gratuitous cpp comments as per style(9).

Submitted by: Danny Braniss danny at cs dot huji dot ac dot il (1)
MFC after: 1 month


138046 24-Nov-2004 jhb

Fix comments for serial I/O function prototypes that were broken in the
assembler to cpp(1) comment conversions. This allows btx to compile again
when BTX_SERIAL is defined.

Reported by: Danny Braniss danny at cs dot huji dot ac dot il
MFC after: 1 month


137419 08-Nov-2004 peter

Remove a pre-tier-1 kernel compatability helper. This means a 6.x loader
won't boot a pre-5.1 development amd64 kernel. That's no big loss though.


137298 06-Nov-2004 keramida

Clean up the comments, rewording, adding missing punctuation
and other minor nits.

Approved by: jhb


136910 24-Oct-2004 ru

For variables that are only checked with defined(), don't provide
any fake value.


136780 22-Oct-2004 simokawa

Respect RB_MULTIPLE flag.


136779 22-Oct-2004 simokawa

- Add FireWire subclass and OHCI interface.
- Add some PCI BIOS function calls.
(find_devclass, read_config, write_config)


135967 30-Sep-2004 ru

Document boot_cdrom, boot_multicons, and boot_serial.
Reduce diffs between help.common and loader(8).
Mention that boot_userconfig is currently a no-op.


135538 21-Sep-2004 wes

Trap invalid sector size 0 in disk probe, refusing to add such a
device to the list. This prevents crashes on /0 errors in 'lsdev'
et al.

Reviewed-by: jhb@
MT5 after: RE approval


135410 18-Sep-2004 jhb

A long, long time ago in a CVS branch far away (specifically, HEAD prior
to 4.0 and RELENG_3), the BTX mini-kernel used paging rather than flat
mode and clients were limited to a virtual address space of 16 megabytes.
Because of this limitation, boot2 silently masked all physical addresses
in any binaries it loaded so that they were always loaded into the first
16 Meg. Since BTX no longer has this limitation (and hasn't for a long
time), remove the masking from boot2. This allows boot2 to load kernels
larger than about 12 to 14 meg (12 for non-PAE, 14 for PAE).

Submitted by: Sergey Lyubka devnull at uptsoft dot com
MFC after: 1 month


134459 29-Aug-2004 iedowse

Add the loader side of support for preloading ELF relocatable object
format modules, which are currently only used on the amd64 platform.
This initial implementation just parses enough of the module to
allow it to extract dependencies and load all the bits into the
right place in memory, so the kernel must still do the full relocation
and linking. The details of the loaded sections are passed to the
kernel by supplying a copy of the ELF section header table as module
metadata with the MODINFOMD_SHDR tag.


134431 28-Aug-2004 yar

Don't be too smart, just try packet mode of INT13 first.
This way of operation is more robust than the "AI" used
before.

Add flags to mbr accessible from make.conf as BOOT_MBR_FLAGS.
Only one flag is defined now, "allow using packet mode", which
is 0x80 in accord with the rest of i386 boot code. The "packet"
flag is on by default.

PR: i386/70241
Submitted by: Valentin Nechayev <netch <@> netch.kiev.ua> (inital version)
Discussed with: jhb (by Valentin Nechayev)
Tested on: bochs (with EDD turned on or off by patching the BIOS), PCs


134430 28-Aug-2004 yar

Try packet mode of INT13 on a hard disk first if not prohibited by
the flag, fall back to the old INT13/AH=02 function if that fails.
This way of operation is less likely to fail with modern BIOSes and
large disks of strange geometries.

PR: i386/70241
Submitted by: Valentin Nechayev <netch <@> netch.kiev.ua> (inital version)
Discussed with: jhb (by Valentin Nechayev)
Tested on: bochs (with EDD turned on or off by patching the BIOS), PCs


134382 27-Aug-2004 yar

B1FLAGS -> BOOT_BOOT1_FLAGS, which is consistent with
naming of other boot-related make vars.


134357 27-Aug-2004 obrien

In conjunction with having boot0cfg(8) default boot0 to packet mode.

Submitted by: Tor.Egge@cvsup.no.freebsd.org


133154 05-Aug-2004 kan

Move boot2 BSS zeroing into btx startup code out of boot1. boot1 does not
have clear idea on boot2 BSS size and leaves portion of it not zeroed out.
btxcsu.s is in much better position for this job.

Obtained from: DragonflyBSD (with minor adjustments)


132870 30-Jul-2004 kan

Compile boot2 with -fno-unit-at-a-time. GCCs aggressive optimization
breaks boot in spectacular ways otherwise.


132864 30-Jul-2004 kan

Clean up local memcpy implementation to take void * parameters.


132764 28-Jul-2004 kan

Define our own memcpy here instead of relying on GCC to provide one.


130943 22-Jun-2004 jhb

Update the copyright to use a 3 clause BSD license rather than one that
is less clear about allowing redistribution of modified copies.

Requested by: Tom Cosgrove tom dot cosgrove at arches-consulting dot com


130942 22-Jun-2004 jhb

Remove a bogus increment of %di when scanning the list of loader paths.
%di will already point to the character after the nul char when the
'repnz scasb' terminates.

Submitted by: Tom Cosgrove tom dot cosgrove at arches-consulting dot com


130632 17-Jun-2004 phk

Save a couple of bytes for the SIO case.


130603 16-Jun-2004 phk

Unspam sys/boot, the dev_t commit should not have touched these.

Spotted by: peter


130585 16-Jun-2004 phk

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


130579 16-Jun-2004 phk

Premptively fix GCC3.4 issue: add break; after empty default: clauses.

PR: 65493
Submitted by: Pawel Worach <sajd@telia.com>


130343 11-Jun-2004 phk

Merge boot0 and boot0sio so they behave the same.


129993 02-Jun-2004 phk

Some embedded platforms have no keyboard controller. Give up waiting
for it to react after a timeout.


129702 25-May-2004 njl

Use the correct location of the EBDA for searching for the RSDP.
The EBDA is the 1 KB area addressed by the 16 bit pointer at 0x40E.

Pointed out by: robert.moore AT intel.com


129240 14-May-2004 ru

Back out last revision that unnecessarily changed valid assembler
line comments and damaged the CVS history.

Prompted by: bde, jhb


129239 14-May-2004 ru

Partly back out last revision that unnecessarily changed valid
assembler line comments and damaged the CVS history.

Prompted by: bde, jhb


129195 14-May-2004 jdp

Fix a potential stack buffer overflow on systems whose ACPI OEMID
fills its field (6 characters). In that case the OEMID is not
null-terminated, and the sprintf that was used would copy up to the
next null byte, which could be pretty far away.


128741 29-Apr-2004 ru

Convert block comments into C-style that is understood by cpp(1).
Keep line comments in assembler style. A few lines that match
the '^[[:space:]]+#' regexp still need to be fixed, somehow.

OK'ed by: bde, jhb


128725 28-Apr-2004 ru

Thanks to David's patches, we can now simplify these makefiles
further, and just use PROG directly (without FILES).

Suggested by: bde


128724 28-Apr-2004 ru

Properly merge boot0sio.s and boot0.s into boot0.S.


128723 28-Apr-2004 ru

Switch to using C99 comments in assembler preprocessed with cpp(1).


128722 28-Apr-2004 ru

- Properly merge boot0sio.s and boot0.s into boot0.S.
boot0sio.s was repo-copied to boot0.S.

- Rename boot0ext.s to boot0ext.S, to stay consistent
with other preprocessed asm files around here, and
for better portability.

Repocopied by: joe


128718 28-Apr-2004 ru

Temporary precaution measure until repocopy requests are
processed: don't forget to clean generated .s sources.


128716 28-Apr-2004 ru

After talking to Bruce Evans and reading more standards specs,
switch to using C99-style comments everywhere in preprocessed
assembler. The reason is that lines starting with the regexp
'^[[:space:]]#' are treated as preprocessing directives, and
while it seems to work now with GCC, it's not necessarily has
to work. Use C99 comments `//' for the trailing comments to
save whitespace.


128709 28-Apr-2004 ru

Use C (and CPP) style comments for assembler-with-cpp sources,
for lines that start with a comment.


128708 28-Apr-2004 ru

Use C (and CPP) style comments for assembler-with-cpp sources,
for lines that start with a comment.


128707 28-Apr-2004 ru

- Use C (and CPP) style comments for assembler-with-cpp sources,
for lines that start with a comment.
- Preserve as(1) style comments for the rest.


128694 27-Apr-2004 ru

Removed now redundant CLEANFILES assignments.

Not read enough of my patch by: obrien ;)


128691 27-Apr-2004 phk

Change from '#' to "//" comment character to allow CPP preprocessing.

Merge boot0.s and boot0sio.s into boot0_512.s controlled by "#ifdef SIO".

Add Makefile magic to generate boot0.s and boot0sio.s from boot0_512.s.

The compile boot0 and boot0sio have unchanged MD5 checksums.


128651 25-Apr-2004 obrien

Use a more compact syntax for passing the "binary" options to 'ld'.


128649 25-Apr-2004 obrien

Simplify the building of our i386 'binary' boot components by directly
producing them using 'ld' options rather than post-processing with 'objcopy'.

Idea by: Ryan Sommers <ryans@gamersimpact.com>


128471 20-Apr-2004 obrien

Fix a last second typo in 'vi' that caused a problem.


128451 20-Apr-2004 obrien

White space style cleanup.


128441 19-Apr-2004 obrien

MFp4: merge version #5 of the 2-sector boot0 from the "jhb boot" branch.


127458 26-Mar-2004 obrien

Bring back jhb's two sector (1024 bytes) 'boot0' [rev 1.22] as 'boot0ext'.


126958 14-Mar-2004 bde

Fixed misspellings of 0 as NULL.


126891 12-Mar-2004 trhodes

These are changes to allow to use the Intel C/C++ compiler (lang/icc)
to build the kernel. It doesn't affect the operation if gcc.

Most of the changes are just adding __INTEL_COMPILER to #ifdef's, as
icc v8 may define __GNUC__ some parts may look strange but are
necessary.

Additional changes:
- in_cksum.[ch]:
* use a generic C version instead of the assembly version in the !gcc
case (ASM code breaks with the optimizations icc does)
-> no bad checksums with an icc compiled kernel
Help from: andre, grehan, das
Stolen from: alpha version via ppc version
The entire checksum code should IMHO be replaced with the DragonFly
version (because it isn't guaranteed future revisions of gcc will
include similar optimizations) as in:
---snip---
Revision Changes Path
1.12 +1 -0 src/sys/conf/files.i386
1.4 +142 -558 src/sys/i386/i386/in_cksum.c
1.5 +33 -69 src/sys/i386/include/in_cksum.h
1.5 +2 -0 src/sys/netinet/igmp.c
1.6 +0 -1 src/sys/netinet/in.h
1.6 +2 -0 src/sys/netinet/ip_icmp.c

1.4 +3 -4 src/contrib/ipfilter/ip_compat.h
1.3 +1 -2 src/sbin/natd/icmp.c
1.4 +0 -1 src/sbin/natd/natd.c
1.48 +1 -0 src/sys/conf/files
1.2 +0 -1 src/sys/conf/files.amd64
1.13 +0 -1 src/sys/conf/files.i386
1.5 +0 -1 src/sys/conf/files.pc98
1.7 +1 -1 src/sys/contrib/ipfilter/netinet/fil.c
1.10 +2 -3 src/sys/contrib/ipfilter/netinet/ip_compat.h
1.10 +1 -1 src/sys/contrib/ipfilter/netinet/ip_fil.c
1.7 +1 -1 src/sys/dev/netif/txp/if_txp.c
1.7 +1 -1 src/sys/net/ip_mroute/ip_mroute.c
1.7 +1 -2 src/sys/net/ipfw/ip_fw2.c
1.6 +1 -2 src/sys/netinet/igmp.c
1.4 +158 -116 src/sys/netinet/in_cksum.c
1.6 +1 -1 src/sys/netinet/ip_gre.c
1.7 +1 -2 src/sys/netinet/ip_icmp.c
1.10 +1 -1 src/sys/netinet/ip_input.c
1.10 +1 -2 src/sys/netinet/ip_output.c
1.13 +1 -2 src/sys/netinet/tcp_input.c
1.9 +1 -2 src/sys/netinet/tcp_output.c
1.10 +1 -1 src/sys/netinet/tcp_subr.c
1.10 +1 -1 src/sys/netinet/tcp_syncache.c
1.9 +1 -2 src/sys/netinet/udp_usrreq.c

1.5 +1 -2 src/sys/netinet6/ipsec.c
1.5 +1 -2 src/sys/netproto/ipsec/ipsec.c
1.5 +1 -1 src/sys/netproto/ipsec/ipsec_input.c
1.4 +1 -2 src/sys/netproto/ipsec/ipsec_output.c

and finally remove
sys/i386/i386 in_cksum.c
sys/i386/include in_cksum.h
---snip---
- endian.h:
* DTRT in C++ mode
- quad.h:
* we don't use gcc v1 anymore, remove support for it
Suggested by: bde (long ago)
- assym.h:
* avoid zero-length arrays (remove dependency on a gcc specific
feature)
This change changes the contents of the object file, but as it's
only used to generate some values for a header, and the generator
knows how to handle this, there's no impact in the gcc case.
Explained by: bde
Submitted by: Marius Strobl <marius@alchemy.franken.de>
- aicasm.c:
* minor change to teach it about the way icc spells "-nostdinc"
Not approved by: gibbs (no reply to my mail)
- bump __FreeBSD_version (lang/icc needs to know about the changes)

Incarnations of this patch survive gcc compiles since a loooong time,
I use it on my desktop. An icc compiled kernel works since Nov. 2003
(exceptions: snd_* if used as modules), it survives a build of the
entire ports collection with icc.

Parts of this commit contains suggestions or submissions from
Marius Strobl <marius@alchemy.franken.de>.

Reviewed by: -arch
Submitted by: netchild


126312 27-Feb-2004 ru

For some reason crt0.o needs to be linked first for pxeboot(8) to
work. This is odd because loader(8) doesn't suffer from this problem.
Perhaps pxeboot bootstrap can be fixed to handle this better.
Anyway, PXE booting should work again.


125932 17-Feb-2004 ru

Re-add sio.S, and properly deal with assembler files.

Repocopied by: joe


125901 16-Feb-2004 obrien

Fix the AMD64 build: this file shouldn't exist.


125753 12-Feb-2004 ru

Fixed the fatal bug introduced in previous commit: don't strip
kgzldr.o -- kgzipping with such a loader produces bad images.


125751 12-Feb-2004 ru

Clean CLEANFILES.


125722 11-Feb-2004 ru

kzip(8) is long dead.


125693 11-Feb-2004 ru

Get rid of unnecessary use of m4(1) by using cpp(1) instead.
(John tells me there were problems when trying this before,
but it appears to be safe these day.)

OK'ed by: jhb
Repocopied by: joe


125621 09-Feb-2004 ru

- Factor out -nostdlib to an upper level Makefile.inc.

- Now that bsd.prog.mk deals with programs linked with -nostdlib
better, and has a notion of an "internal" program, use PROG
where possible. This has a good impact on the contents of
.depend files and causes programs to be linked with cc(1).

XXX: boot2 couldn't be converted as it's actually two programs.

Tested on: i386, amd64


125581 07-Feb-2004 ru

Argh, unbreak "make depend" for AMD64.

Reported by: kris


125566 07-Feb-2004 ru

- Removed -elf which is not a valid gcc(1) option anymore.
- Removed -ffreestanding; it's enforced by ../Makefile.inc.


125564 07-Feb-2004 ru

Generate .depend file.


125556 07-Feb-2004 ru

Untangle building of AMD64 boot code.

Tested on: amd64 (sledge)


125537 06-Feb-2004 ru

First round of cleanups to sys/boot/ makefiles:

- do not use PROG for what's not a real C program,
- use sys.mk transformation rules where possible,
- only create the "machine" symlink on AMD64,
- removed MAINTAINER lines in individual makefiles,
- added the LIBSTAND defitinion to <bsd.libnames.mk>,
- somewhat better contents in .depend files.

Tested on: i386, amd64
Prodded by: bde


125517 06-Feb-2004 ru

Inherit BINDIR from a parent Makefile.inc.


125516 06-Feb-2004 ru

Only include ../Makefile.inc once in loader/Makefile.


124818 21-Jan-2004 jhb

If a transfer to or from a floppy disk crosses a 64k boundary, we have to
use a bounce buffer for the actual transfer to avoid crossing a 64k
boundary. To do this, we malloc a buffer twice as big as we need and then
find an aligned block within that buffer to do the transfer. The check
to see which part of the block we use used the wrong variable for part of
the condition meaning that in certain edge cases we would ask the BIOS to
cross a 64k boundary. The BIOS request would then fail resulting in file
transfers that just magically fail in the middle without any apparent
reason. Specifically, my tests for the splitfs boot floppies managed to
trigger this edge case.

MFC after: 1 week
X-MFC-info: along with fixes to libstand filesystems


124445 12-Jan-2004 jhb

- Use constant for shift when converting file length in bytes to a sector
count.
- Fix the twiddle output so that it actually spins.
- Save %cx around BIOS calls to read in sectors from the disc as at least
one BIOS trashes %cx when called to read off of a USB CD-ROM drive.

Submitted by: Martin Nilsson <martin@gneto.com>
MFC after: 1 week


124179 06-Jan-2004 obrien

Allow one to specify the com port settings for boot0sio.


123476 11-Dec-2003 jhb

- Change the lookup() function to report success or failure using the carry
flag rather than explicitly halting if a lookup failed.
- Add a loop around the call to lookup() to traverse an array of
nul-terminated strings for possible paths to the boot loader. A double
nul character denotes the end of the list.
- Add a new message to say that the boot failed if all of the path lookups
for a boot loader file failed.
- Add '/boot/loader' as a second boot path. If you build an ISO using
risky options to mkisofs such as -U then the loader will be called
'/boot/loader' rather than '/BOOT/LOADER;0'. This allows cdboot to work
with such risky ISO images.
- Bump version to 1.2 to denote added functionality.

The basic idea as well as some of the code were provided by the submitter,
but I added some extra code to use a loop rather than hard-code just 2
possible paths.

PR: misc/43543
Submitted by: kientzle
MFC after: 1 week


123470 11-Dec-2003 jhb

Properly fix a typo that the previous revision made even worse.


123336 09-Dec-2003 obrien

Sync these two files.


123302 08-Dec-2003 obrien

Hook boot0sio to the build. Use 'boot0cfg -b /boot/boot0sio' to use.


123301 08-Dec-2003 bms

Add a serial console capable version of the FreeBSD boot manager. This has
been lying around my tree(s) for the past year or so. It could do with TLC.

Requested by: obrien
Sponsored by: Weyland-Yutani Corporation


122942 21-Nov-2003 dcs

With the beastie menu a problem was introduced in which selecting a
different kernel to boot with kernel="NAME" would load the kernel and
loader.conf-selected modules from /boot/NAME, but it would not change
module_path. So, for instance, the automatically loaded acpi.ko would come
from /boot/kernel/acpi.ko, *always*.

Mind you, this happened for unassisted boot. If you interrupted, typed
"unload" and then "boot NAME", it would Do The Right Thing.

The source of the problem is the double initialization with beastie's
loader.rc. One would happen inside "start", and would load the kernel. The
next one would happen later in the loader.rc script, resetting module_path.

Because module_path is set to the Right Value by the functions in support.4th
that actually load the kernel, when beastie.4th proceeded to boot
module_path would remain wrong, as the kernel was already loaded.

This can be corrected by removing either initialization, and also by changing
the command used by beastie.4th from "boot" to "boot-conf", which makes sure
you use the right kernel and modules.

I chose to remove the second initialization, since this let you interrupt
(or confirm) boot before beastie even comes up. I avoid also doing the
boot-conf change because that would simply cause the kernel and modules to
be loaded twice (in fact, that was my original patch, until, in writing this
very commit message, I saw the error of my ways).

This commit changes the semantics of module loading when using the beastie
menu. Now it does what one would expect it to, but not what it was actually
doing, so something may break for unusual setups depending on broken
behavior. As our japanese friends so nicely put it, shikata ga nakatta. :-)

Approved by: re (scottl)


122923 20-Nov-2003 jhb

Update the size of the OS string table that wasn't updated in the previous
commit that removed the UNIX entry.

Submitted by: Rudolf Cejka <cejkar@fit.vutbr.cz>
Approved by: re (rwatson)


122806 16-Nov-2003 phk

When rebooting the machine jump to 0xf000:0xfff0 instead of 0xffff:0x0.

While we end up the same place, we end up with two different CS register
values after the jump and 0xf000 is compatible with the hardware reset
value.

This makes a difference if the BIOS does a near jump before a far jump.

Detective work and patch by: Adrian Steinmann <ast@marabu.ch>


122749 15-Nov-2003 bde

Changed the RB_PAUSE flag from 0x40000 to 0x100000 and marked the old
value as reserved for internal use in boot blocks, because RB_PAUSE
broke binary compatibility by usurping the RB_DUAL flag. Probably no
one except me has boot blocks for which this matters, since most boot
blocks based on biosboot including pc98's boot2 can't boot elf kernels,
and /boot/loader doesn't properly pass flags set by the previous stage.

reboot.h:
Also mark the historical RB_PROBEKBD flag (0x80000) as reserved for
internal use in boot blocks.

boot2.c:
Added comments to inhibit usurping of other flags.

Approved by: guido, imp
MFC after: 1 week


122463 11-Nov-2003 bde

Include <sys/reboot.h> the definition of RB_BOOTINFO. The previous
commit broke the world because it depended on namespace pollution that
was only in my version of <machine/bootinfo.h>. The include was removed
in rev.1.63 after the last reference to it went away in rev.1.61.


122433 10-Nov-2003 bde

Fixed loss of setting of the RB_BOOTINFO flag in rev.1.43. Fixed wrong
comment about this flag in rev.1.61. It is not historical like the
comment said; it is the flag that says that most of what is laboriously
put in the bootinfo struct is actually there. Newer kernels were
bootable by even the broken boot2 without losing anything except the
symbol table, but older kernels need at least the memory sizes.

Restoring the "|" with RB_BOOTINFO that was lost in rev.1.43 costs 5
bytes. The fix can be done in only 4 bytes by fixing some code that
was removed in rev.1.61 (put RB_BOOTINFO back in in the initial value
of "opts" and fix RBX_MASK to not clobber it.)


122177 06-Nov-2003 jhb

Fix an incorrect quote character in an M4 test conditon. Basically, one
of the verbose print statements that BTXLDR_VERBOSE enables wasn't properly
enabled.


120118 16-Sep-2003 bde

Don't repeat selected defines from ns16550.h or sioreg.h. Just
include ns16550.h. The missing installation of ns16550.h was fixed
long ago and the misplaced defines in sioreg.h were fixed recently.


119714 03-Sep-2003 phk

Add BOOT_PXELDR_ALWAYS_SERIAL option which forces serial console.


119482 25-Aug-2003 obrien

Use __FBSDID().
Also some minor copyright style cleanups.


119253 22-Aug-2003 imp

Many newer CF do not handle having the entire track read from them at
boot time. Instead, read it a sector at a time. While this sounds
like a significant slowdown, I've not been able to measure any
signficant difference.

Submitted by: luigi
Reviewed by: jhb, sam (both a while ago)
MFC After: 3 days


118607 07-Aug-2003 jhb

Consistently use the BSD u_int and u_short instead of the SYSV uint and
ushort. In most of these files, there was a mixture of both styles and
this change just makes them self-consistent.

Requested by: bde (kern_ktrace.c)


118604 07-Aug-2003 njl

Null terminate the OEM hint. This rids my laptop of the smiley face that
would follow the 6 valid chars of the table entry.


117529 13-Jul-2003 njl

Add include file so this builds with new acpica

Reported by: Kevin Oberman <oberman@es.net>


117160 02-Jul-2003 ru

Revert non-style part of the recent two deltas that dealt with
using as(1) to compile plain assembler source files; bsd.lib.mk
has been fixed (in revision 1.147).


117075 30-Jun-2003 ru

Switch to using bsd.prog.mk; this gives us back the standard
.s.o transformation rule.


117052 30-Jun-2003 ru

Revision 1.13, besides its useful part, replaced bsd.prog.mk by
bsd.lib.mk and thus broke the build since AFLAGS were not taken
into considered anymore, as bsd.lib.mk currently has wrong .s.o
rule that uses cc(1) instead of as(1).

Revision 1.14 reverted to using as(1), and revision 1.15 brought
AFLAGS back to the business, but revision 1.14 also broke "make
clean".

To fix this, but not break anything that was fixed in revisions
1.13-1.15, we revert mostly to revision 1.13 except for switching
back to using bsd.prog.mk. This gives us back the default .s.o
rule from sys.mk that uses as(1), and fixes "make clean" by
restoring the full contents of OBJS.

Also fixed LDFLAGS.


116864 26-Jun-2003 peter

Build on amd64. Yes, I know this isn't particularly nice.


116451 16-Jun-2003 iedowse

When looking for the ':' separator in the root path, don't go past
the terminating '\0'. Since the initialisation of rootpath in
libstand/bootp.c may copy junk into the rest of the buffer, it was
possible for the code to find a ':' after the '\0' and do the wrong
thing.

Reviewed by: ps
MFC after: 1 week


115964 07-Jun-2003 obrien

Add ${AFLAGS} to 'as' invocation.


115941 07-Jun-2003 obrien

Don't use a C compiler to assemble a pure asm file.


115899 06-Jun-2003 kuriyama

Tweak make values and targets not to build kgzldr.o at
installation stage.

Reviewed by: bde


115670 02-Jun-2003 obrien

Don't use a C compiler to assemble a pure asm file.


115638 01-Jun-2003 obrien

Accpet '1'..'5' in place of F1..F5 for serial console users.

Reviewed by: Bruce M Simpson <bms@spc.org>


115423 31-May-2003 scottl

Enable the new bootloader for i386 only. The new loader.rc is will only
be installed if an old one does not exist, i.e. only during install, not
during upgrades.

Approved by: re


115410 30-May-2003 scottl

Add a new bootloader menu. Pull in screen.4th and frames.4th from the
examples directory to support it. This is installed only on i386 for
now. It will be enabled in a later commit.

Approved by: re


115091 17-May-2003 peter

Fix a bug in the AMD64 trampoline. I misunderstood the implicit
32->64 bit zero extend. This changes a movl to an orq.

Approved by: re (amd64 bits)


114933 12-May-2003 peter

Revert leftover AMD64 disable-acpi-module stuff.


114920 11-May-2003 peter

For amd64 kernels, repeat the 1GB mapping over the entire address space
instead of just at 0GB and 1GB marks. This gives more flexibility for
the choice of KERNBASE.

Approved by: re (amd64 stuff)


114385 01-May-2003 peter

Argh. This was broken by the last-minute elf32/elf64/"elf kernel" changes.


114380 01-May-2003 peter

Nuke; repocopied to elf32_freebsd.c where it lives on.


114379 01-May-2003 peter

Enable the i386 loader to load and run an amd64 kernel. If this puts
things over floppy size limits, I can exclude it for release builds or
something like that. Most of the changes are to get the load_elf.c file
into a seperate elf32_ or elf64_ namespace so that you can have two
ELF loaders present at once. Note that for 64 bit kernels, it actually
starts up the kernel already in 64 bit mode with paging enabled. This
is really easy because we have a known minimum feature set.

Of note is that for amd64, we have to pass in the bios int 15 0xe821
memory map because once in long mode, you absolutely cannot make VM86
calls. amd64 does not use 'struct bootinfo' at all. It is a pure loader
metadata startup, just like sparc64 and powerpc. Much of the
infrastructure to support this was adapted from sparc64.


114339 30-Apr-2003 peter

ACPI will always be present on AMD64 - it will never be an autodetect
module.


114246 29-Apr-2003 njl

Support functions for the new ACPI import.
* AcpiOsDerivePciId(): finds a bus number, given the slot/func and the
acpi parse tree.
* AcpiOsPredefinedOverride(): use the sysctl hw.acpi.os_name to
override the value for _OS.

Ideas from: takawata, jhb
Reviewed by: takawata, marcel
Tested on: i386, ia64


113083 04-Apr-2003 phk

Libdisk does not need to include <sys/diskslice.h> any more.

Move the remaining bits of <sys/diskslice.h> to <i386/include/bootinfo.h>

Move i386/pc98 specific bits from <sys/reboot.h> to
<i386/include/bootinfo.h> as well.

Adjust includes in sys/boot accordingly.


111490 25-Feb-2003 ru

Fixed CLEANFILES.

Submitted by: cron


109886 26-Jan-2003 phk

Build a file "boot" which consists of boot1 and boot2 concatenated.

There is little if any reason to treat the two components separately
and it will simplify disklabel(8) and libdisk if we didn't.


109559 20-Jan-2003 phk

Use NEXTDOSPART instead of MAX_SLICES.


109498 18-Jan-2003 obrien

Simplify the Makefile by just using our standard PROG variable.


109235 14-Jan-2003 imp

Save 4 more bytes by not initializing opts to 0. This moves it from
the data section to the bss section givig us initialization for free.

Noticed by: bde


109197 13-Jan-2003 imp

Fix interactive booting:
o Revision 1.38 introduced the -n flag. It conflicted with the
RB_BOOTINFO flag, so was in effect always on. Change the -n flag to
be bit 0x1c instead of 0x1f. This also had the consequence that a mal-formed
/boot.config would render the system unbootable because the user was
unable to enter anything at all on the command line.
o Remove the initialization of opt to be RB_BOOTINFO since we filter that bit
out and do not otherwise use it.

Reviewed by: jhb
MFC after: 3 days


108476 31-Dec-2002 obrien

RIP liloldr.
It is not complete (the LILO root= specification isn't passed to our
loader for instance), it has not been touched in over 2 years. Linux has
moved on to GRUB, so this is OBE now. If someone creeps up to work on it,
it could become a port.


108149 21-Dec-2002 obrien

-mno-align-long-strings can make things smaller, so lets use it in hopes
that it does here.


108119 20-Dec-2002 imp

Put back the casts to unsigned. While no strictly necessary for its
current uses, the name strcmp has strong connotations that shouldn't
lightly be discarded. This doesn't cost us anything.

Submitted by: bde


108100 19-Dec-2002 jake

Renamed the loader's zipfs to gzipfs. zipfs.c was repo-copied to gzipfs.c.


108016 18-Dec-2002 imp

I didn't intend to delete this rm from the Makefile. It snuck in at
the last second before the commit.

# likely we can remove this hack now that gcc generates better aligned code
# in the align to word case.

Noticed by: bde


108005 17-Dec-2002 imp

Reduce diffs with Peter's expanded diffs:
1) Put back the keyboard printing printf, at the cost of 58 bytes.
2) Minor tweak to getstr at no apparent cost.


108000 17-Dec-2002 imp

Make both UFS1 and UFS2 fit on the same boot blocks. These are a
subset of Peter's patchs that are believed to be safe.

Makefile tweaks:
o -fomit-frame-pointer
o Change default to building both UFS1 and UFS2 bootblocks.

Lots of boot2 tweaks:
o lookup is only ever called with kname, so use it directly.
o inline memsize
o getstr are only ever called with cmd, so hardware that.
o tweaks to the parsing code to test after the conversion rather than
before since we tested after anyways.
o eliminate support for %x in printf.
o eliminate a few bytes in printfs.
o Tweak the boot banner.
o eliminate support for wd and " " devices (I might add wd back to
keep bde happy).
o eliminate support for a few arguments.

This takes us from -162 bytes free to 67 bytes free.

I've tested this only on a few systems, so be careful when updating to
this change.

Submitted by: peter, imp, ian


107889 15-Dec-2002 obrien

Remove unneeded casts. Add others to make WARNS=5 happy.


107879 14-Dec-2002 phk

Employ the unused bytes after the disklabel in the second sector. This makes
it possible to make UFS1_ONLY and UFS2_ONLY versions which fit inside the
traditional 16 sectors.

Remove assorted now unneeded hackery.

UFS1_AND_UFS2 still needs another 150 bytes to work, and that is probably
not within our reach, ever.


107878 14-Dec-2002 phk

Remove unnecessary call to fsread().


107875 14-Dec-2002 phk

Always use the smaller GCC builtin memcpy


107874 14-Dec-2002 phk

Remove unused variable.


107869 14-Dec-2002 phk

Don't fill in the table with the BIOS idea about disk-geometry, we don't
use it. This saves a surprising number of bytes.


107788 12-Dec-2002 ru

Uniformly refer to a file system as "file system".

Approved by: re


106385 03-Nov-2002 phk

Correctly recognize both bogus and genuine BSD disklabels.

Don't expect me to participate in a discussion which is which.

Sponsored by: DARPA & NAI Labs.


104683 08-Oct-2002 jhb

Revert MEM_USR back to 0xa000 for BTX clients. Instead, adjust boot2
to run at 0xc000 by changing its virtual start address from 0x1000 to
0x2000.

Tested by: phk


104680 08-Oct-2002 phk

Now that ufsread.c doesn't do 64bit divide remainder operations,
don't bother with libkern.

Sponsored by: DARPA & NAI Labs.


104679 08-Oct-2002 phk

Save a couple of bytes by not returning ints nobody care about.

Sponsored by: DARPA & NAI labs


104673 08-Oct-2002 green

Reinstate rev 1.36 with an important line that got missed. Note this
also improves the "random undocumented offsets into various memory
spaces" a little bit.


104671 08-Oct-2002 phk

Remove unused TYPE_WD and TYPE_WFD.


104670 08-Oct-2002 phk

Correctly calculate dmadat: We need to take the address of _end, it's
contents is irrelevant and likely to be zero;

This doesn't change the resultant value, but it does save a couple of bytes
because &_end is constant.


104668 08-Oct-2002 phk

Unbreak boot2 by backing out rev 1.36 to Makefile, which does not
work as advertised:

bang# pwd
/bang/src/sys/boot/i386/boot2
bang# make clean >& /dev/null
bang# cvs -q update -r 1.35 Makefile >& /dev/null
bang# make >& /dev/null
bang# cat /usr/obj/`pwd`/boot2.h
#define XREADORG 0x725
bang# cvs -q update -r 1.36 Makefile > & /dev/null
bang# make clean > & /dev/null
bang# make > & /dev/null
bang# cat /usr/obj/`pwd`/boot2.h
#define XREADORG 0x25
bang#


104666 08-Oct-2002 phk

Save four bytes by shortening a string two chars.

Sponsored by: DARPA & NAI Labs.


104636 07-Oct-2002 green

Correct a bug in adding 0x700 to a number.


104635 07-Oct-2002 phk

Conditionalize the number of sectors loaded by boot1.s on UFS1/UFS12.

Conditionalize the "XX bytes left" checks reference on UFS1/UFS12.

Conditionally build the necessary 64bit math for boot2 if UFS12.

Sponsored by: DARPA & NAI Labs.


104632 07-Oct-2002 phk

Change the comment character from # to // in boot1.s and run
it through CPP so we can conditionalized things.

Sponsored by: DARPA & NAI Labs


104629 07-Oct-2002 phk

Correctly adjust for moved start address.

It seems that the existence of a "depend" target in src/sys/boot is not
to be taken as an indication that it actually does what one would expect,
at least it clearly threw my testing off.

Apologies to: jhb


104620 07-Oct-2002 phk

Correctly compensate for both offset and unoffset on-disk BSD disklabels.

Sponsored by: DARPA & NAI Labs.


104618 07-Oct-2002 phk

Move MEM_USR a page upwards to make space for larger UFS1 boot2.

Load 4 sectors more than we used to. This is harmless overhead for
the UFS1_ONLY case, but sufficient for boot2(UFS1+2).

Sponsored by: DARPA & NAI Labs


104612 07-Oct-2002 phk

Move the definition of UFS1_ONLY into the Makefiles where it belongs.

Sponsored by: DARPA & NAI Labs.


104315 01-Oct-2002 iwasaki

Don't call INT 12H anymore in boot program.
Many recent machine have a broken INT 12H (Get base memory size)
implementation and boot program stops if INT 12H is called.

This commit should solve the problem at very first step of FreeBSD
installation occurred on newer some machines.

Reviewed by: bde, jhb
MFC after: 1 week


104272 01-Oct-2002 phk

Split MBR and PC98 on-disk sliceformats out from disklabel.h, step 1:

Peter had repocopied sys/disklabel.h to sys/diskpc98.h and sys/diskmbr.h.

These two new copies are still intact copies of disklabel.h and
therefore protected by #ifndef _SYS_DISKLABEL_H_ so #including them
in programs which already include <sys.disklabel.h> is currently a
no-op.

This commit adds a number of such #includes.

Once I have verified that I have fixed all the places which need fixing,
I will commit the updated versions of the three #include files.

Sponsored by: DARPA & NAI Labs.


104234 30-Sep-2002 peter

Use as's --defsym switch to compensate for the loss of the M4 substitution
of SIOPRT which broke kgzldr and therefore make release.

Pointed out by: murray


103870 23-Sep-2002 alfred

use __packed.


103436 17-Sep-2002 peter

Initiate deorbit burn for the i386-only a.out related support. Moves are
under way to move the remnants of the a.out toolchain to ports. As the
comment in src/Makefile said, this stuff is deprecated and one should not
expect this to remain beyond 4.0-REL. It has already lasted WAY beyond
that.

Notable exceptions:
gcc - I have not touched the a.out generation stuff there.
ldd/ldconfig - still have some code to interface with a.out rtld.
old as/ld/etc - I have not removed these yet, pending their move to ports.
some includes - necessary for ldd/ldconfig for now.

Tested on: i386 (extensively), alpha


102960 05-Sep-2002 iwasaki

Parse hint.acpi.0.disabled correctly.
Now that hint.acpi.0.disabled="0" won't disable acpi as expected.

Pointed-out by: bde


102807 01-Sep-2002 kan

Restore Rev. 1.40 (remove "Keyboard yes/no" printf).
GCC 3.2 overflows boot2 by 12 bytes, this patch brings it back
within the boundaries, with 12 bytes available for future bloat.

Approved by: obrien


102623 30-Aug-2002 jhb

Revert previous untested revision. The i386 loader consists of three parts:
At the front is btxldr, in the middle is BTX itself (our mini-kernel), and
then the 'client' (loader.bin) which is the actual loader itself. boot2
just executes a raw ELF or a.out binary with the only setup provided being
that a bootinfo structure is passed on the stack. Now, since loader.bin
is a BTX client, the loader needs to be able to locate a BTX kernel for
the client to execute in the context. Thus, just like pxelder, btxldr
uses the a.out header on the loader binary to find the BTX kernel stored
in the loader and set it up. It does _not_ just reuse the BTX kernel
that boot2 invoked it with. This is because it can't assume that it will
_have_ a "spare" BTX kernel lying around. For example, when cdboot
loads the loader there isn't an existing BTX kernel. In fact, cdboot
will only work with an a.out loader as well since it also "borrows" the
BTX kernel in the loader binary (which it finds by parsing the a.out
header) just as pxeldr does. The only difference between cdboot and
pxeldr is where they get /boot/loader from.

If we wanted to make /boot/loader be an actual ELF binary we would need
to change the following utilites to handle that (and they all have to be
able to handle locating the BTX kernel inside of an ELF binary somehow):
- btxldr
- pxeldr
- cdboot

If we didn't want to require a flag day but make the transition smooth
then we need to be able to support both a.out and ELF versions of
/boot/loader which isn't exactly trivial since all three of these utilities
are written in assembly.

Pointy-hat to: peter


102612 30-Aug-2002 iwasaki

s/hint.acpi.0.disable/hint.acpi.0.disabled/

Fix device hints entry for disabling acpi(4).
This also should fix the arbitration with apm(4) when both drivers
are enabled.

Note that your /boot/device.hints needs to be updated if you want to
stop auto-loading acpi.ko or disable acpi(4).


102591 29-Aug-2002 peter

Try #2 at having /boot/loader default to ELF. Have pxeldr build its
own a.out version of loader.bin rather than depend on ../loader/loader
being a.out.


102588 29-Aug-2002 peter

Actually remove the stale a.out kld support. This is the stuff that was
never updated for the metadata infrastructure.


102556 29-Aug-2002 peter

Initiate deorbit burn of i386 a.out kld "support" in loader. Note that
this was quite broken, it never was updated for metadata support.
The a.out kld file support was never really used, as it wasn't necessary.
You could always load elf kld's, even in an a.out kernel.


101602 09-Aug-2002 iwasaki

Add help about hint.acpi.0.disable.


101558 09-Aug-2002 obrien

Restore autoloading of ACPI module.

Document the approved ways of disabling it.
Submitted by: Daniel O'Connor <doconnor@gsoft.com.au>


101556 09-Aug-2002 obrien

Don't auto load ACPI -- it causes trouble with my laptop and is TOTALLY
undocumented how to control its loading and queries to freebsd-current
go unanswered.


100872 29-Jul-2002 ru

Drop support for COPY, -c has been the default mode of install(1)
for a long time now.

Approved by: bde


99976 14-Jul-2002 charnier

The .Nm bootloader


99682 09-Jul-2002 iwasaki

Resolve conflicts arising from the ACPI CA 20020611 import.


99170 30-Jun-2002 iwasaki

Fix a build problem for the ACPI CA 20020404 import.
Add definition of COMPILER_DEPENDENT_INT64 and also
fix definition of COMPILER_DEPENDENT_UINT64.

Pointed-out by: Michael Nottebrock <michaelnottebrock@gmx.net>


98556 21-Jun-2002 phk

Revert the part of Kirks UFS2 commit which added divdi3.c and moddi3.c
to libi386, this issue was resolved already in a cleaner way.


98542 21-Jun-2002 mckusick

This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit
block pointers. It also adds a file-creation time field, an ability
to use jumbo blocks per inode to allow extent like pointer density,
and space for extended attributes (up to twice the filesystem block
size worth of attributes, e.g., on a 16K filesystem, there is space
for 32K of attributes). UFS2 fully supports and runs existing UFS1
filesystems. New filesystems built using newfs can be built in either
UFS1 or UFS2 format using the -O option. In this commit UFS1 is
the default format, so if you want to build UFS2 format filesystems,
you must specify -O 2. This default will be changed to UFS2 when
UFS2 proves itself to be stable. In this commit the boot code for
reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c)
as there is insufficient space in the boot block. Once the size of the
boot block is increased, this code can be defined.

Things to note: the definition of SBSIZE has changed to SBLOCKSIZE.
The header file <ufs/ufs/dinode.h> must be included before
<ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and
ufs_lbn_t.

Still TODO:
Verify that the first level bootstraps work for all the architectures.
Convert the utility ffsinfo to understand UFS2 and test growfs.
Add support for the extended attribute storage. Update soft updates
to ensure integrity of extended attribute storage. Switch the
current extended attribute interfaces to use the extended attribute
storage. Add the extent like functionality (framework is there,
but is currently never used).

Sponsored by: DARPA & NAI Labs.
Reviewed by: Poul-Henning Kamp <phk@freebsd.org>


98472 20-Jun-2002 peter

Add boot_serial and boot_multicons variables to set RB_SERIAL and
RB_MULTIPLE since this seems to be the easiest way to add these flags
for non-forth loaders etc.


97867 05-Jun-2002 phk

Add explicit dependency on ufsread.c


97860 05-Jun-2002 phk

Preparation for UFS2 commit:

Factor the ufs reading code out of the i386/boot2 loader so it can
be reused by for instance sparc64.

Sponsored by: DARPA and NAI Labs.


96843 18-May-2002 phk

Fix one of the va_arg() with less than int sized type probelms.


96654 15-May-2002 jhay

DEV_BSIZE lives in sys/param.h and not in machine/param.h anymore.


96533 13-May-2002 ru

Align CLEANFILES with revision 1.25 changes.


96532 13-May-2002 ru

Fixed CLEANFILES after bsd.lib.mk sweep.


96513 13-May-2002 ru

Removed now unused INTERNALSTATICLIB.
INTERNALLIB now implies NOPIC and NOPROFILE.
Removed gratuitous NOMAN.


96512 13-May-2002 ru

Major cleanup of bsd.lib.mk.

Get rid of the INTERNALSTATICLIB knob and just use plain INTERNALLIB.
INTERNALLIB now means to build static library only and don't install
anything. Added a NOINSTALLLIB knob for libpam/modules. To not
build any library at all, just do not set LIB.


96460 12-May-2002 bde

Saved 176 bytes by compiling with -fno-guess-branch-probability. The
default of -fguess-branch-probablility causes time optimizations (?)
like rewriting `if (foo) x++;' as
`if (!foo) goto forth; back: ; ...; forth: x++; goto back;". This is
pessimizes space especially well on i386's because one short branch
gets converted to 2 long ones.

Removed -fno-align-foo since it is implied by -Os. Previous commit
messages seem to have overstated the new alignment bugs in gcc. The
only case that affects boot2 is that -fno-align-functions (or
equivalently -falign-functions=1) actually gives -falign-functions=2.
This is caused by FUNCTION_BOUNDARY being 2 (bytes) instead of 1.
The default case where the optimization level is 1 and no alignment
options are given is more broken. All alignments are minimal, modulo
the bug in FUNCTION_BOUNDARY. This is caused by toplev.c setting
defaults too early.

Some hacks in previous commits ar not needed now, but may as well be
kept until gcc is fixed. The previous on in the Makefile saved 96
bytes of text due to the wrong FUNCTION_BOUNDARY and 32 bytes of data
due to unrelated bloat in the alignment of large objects. There aren't
even any options to control alignment of data.


96455 12-May-2002 obrien

Back out last commit. I expect our bsd.*.mk gods to remove the need for
defining so many extra things in addition to INTERNALLIB. We don't like
repetitive C code and we shouldn't for make code either.


96426 11-May-2002 peter

Save about 60 bytes by #define memcpy __builtin_memcpy and removing
the function we provided. Restore the Keyboard: yes/no printf for the
probe diagnostics. We end up with 40 bytes free.


96425 11-May-2002 peter

Reconnect boot2. I'm sure I'll regret this though. :-)


96424 11-May-2002 peter

Use a crowbar and duct-tape to make boot2 fit again. This gets it down
to 4 bytes free. I removed a printf (the Keyboard yes/no) since it is of
marginal value and sed'ed the generated asm output to remove the unwanted
aligns. There's probably a better way to gain a few extra bytes than
losing the printf. Shortening strings is probably a better option but this
should get us over the hurdle.


96415 11-May-2002 obrien

NOPIC, NOPROFILE, NOMAN, and INTERNALSTATICLIB are redundant when using
INTERNALLIB now.


96327 10-May-2002 jhb

- Axe -mpreferred-stack-boundary=2 as -Os turns this on by default.
- Axe -fdata-sections as turning it on or off makes no difference. If
it did make a difference it would serve to bloat boot2 even further with
extra padding.
- Axe -fforce-addr. This gets us 32 bytes so we are down to only being
64-bytes over.

We still can't compile this with gcc 3.1. The problem seems to be that
the -fno-align-foo options don't actually work. Comparing the new and
old output it turns out that gcc is 4-byte padding all the functions and
labels and what not despite the passed in arguments thus adding the
unfortunate bloat to boot2.


96309 10-May-2002 obrien

Don't be redundant.


96306 10-May-2002 obrien

-ffreestanding is the word for /sys.


96305 10-May-2002 obrien

Turn off boot2 -- it gained over 96 bytes dieting on the in-tree Gcc 3.1.


94956 17-Apr-2002 ru

Install files via FILES, there's no reason to compare them before installing.


94952 17-Apr-2002 ru

Really unbreak it this time (clean and install were still broken).


94510 12-Apr-2002 ru

Unbreak this as well.
At the extra bonus of fixing the contents of the .depend file.

Not really my day.


94411 11-Apr-2002 pb

Code cleanup, no functional change.
Patch adapted from PR.

PR: i386/36015
Submitted by: thomas@cuivre.fr.eu.org
MFC after: 1 week


93352 28-Mar-2002 obrien

Needs a.out support built into the loader.


93044 23-Mar-2002 pb

Add option -n to i386 boot2 to disallow boot interruption by keypress.

PR: i386/36016
Submitted by: Thomas Quinot <thomas@cuivre.fr.eu.org>
Reviewed by: rnordier
MFC after: 1 week


92494 17-Mar-2002 sobomax

Add splitfs vfs layer into libstand, which allows loading big kernels and
modules split across several physical medias. Following is how it works:

The splitfs code, when asked to open "foo" looks for a file "foo.split"
which is a text file containing a list of filenames and media names, e.g.

foo.aa "Kernel floppy 1"
foo.ab "Kernel floppy 2"
foo.ac "Kernel and modules floppy"

For each file segment, the process is:

- try to open the file
- prompt "Insert the disk labelled <whatever> and press any key..."
- try to open the file
- return error if file could not be located

RE team is free to use this feature in the upcoming 5.0-DP1.

Reviewed by: msmith, dcs


92225 13-Mar-2002 ru

Implement -m and -p loader(8) "boot" command options in boot2.
(This is more useful for 4.x where boot blocks can still load
kernels, modulo the PR kern/17422.)


89481 17-Jan-2002 iedowse

Oops, the previous revision (1.35) broke booting from floppies
because the buffers we use could end up spanning a 64k boundary.
Unfortunately it causes too much bloat (228 -> 72 bytes free) to
just reinstate the old malloc() function.

Instead, define a structure that contains all 4 buffers which must
not cross 64k boundaries. We allocate a 64k-aligned instance in
main() using the magic that was in the old boot2 malloc() function.
This brings the free space down to 168 bytes, but that is still
better than it was before revision 1.35 (136 bytes).

Reported by: Mike Brancato <funnyguy@digitalsmackdown.net>
Pointy-hat to: iedowse


89368 14-Jan-2002 iedowse

Make the i386 boot2 fully blocksize-agnostic, as has already been
done with boot1 on the alpha. We use 4k buffers regardless of the
actual filesystem block size.

Remove the simple malloc() implementation, as it is no longer used.


89240 10-Jan-2002 jhb

Unrevert revision 1.12. Revision 1.14 backed this out saying it was
backing out the 1024 sector boot0, but revision 1.12 had nothing to do with
that. Instead, it documented various compile time options for boot0 and
allowed them to be overridden via make.conf or options on the make
command line.


89154 09-Jan-2002 iedowse

Increase BSIZEMAX from 8k to 16k, so that we can reliably boot from
filesystems with 16k blocks.


88874 04-Jan-2002 jhb

Don't turn on RB_CDROM if the rootdev is a BIOS cd device for now as this
breaks when cdboot is used with an MFS root.


87636 11-Dec-2001 jhb

- Add 'fwrite' and 'fseek' words for writing to and seeking on files.
- Change the 'fopen' keyword to accept a mode parameter. Note that this
will break existing 4th scripts that use fopen. Thus, the loader
version has been bumped and loader.4th has been changed to check for a
sufficient version on i386 and alpha. Be sure that you either do a full
world build or install or full build and install of sys/boot after this
since loader.old won't work with the new 4th files and vice versa.

PR: kern/32389
Submitted by: Jonathan Mini <mini@haikugeek.com>
Sponsored by: ClickArray, Inc.


87633 11-Dec-2001 jhb

Add support for writing to BIOS disks.

PR: kern/32389
Submitted by: Jonathan Mini <mini@haikugeek.com>
Sponsored by: ClickArray, Inc.


87620 10-Dec-2001 guido

Add new boot flag to i386 boot: -p.
This flag adds a pausing utility. When ran with -p, during the kernel
probing phase, the kernel will pause after each line of output.
This pausing can be ended with the '.' key, and is automatically
suspended when entering ddb.

This flag comes in handy at systems without a serial port that either hang
during booting or reser.
Reviewed by: (partly by jlemon)
MFC after: 1 week


87599 10-Dec-2001 obrien

Update to C99, s/__FUNCTION__/__func__/,
also don't use ANSI string concatenation.


86164 07-Nov-2001 jhb

Remove a few more debugging bits and turn on twiddle output while reading
from the CD. This turns off the dual console output to COM1.


86094 05-Nov-2001 jhb

- If we are booted via cdboot, use bc_add() to instantiate the cd0 device
from the loader.
- Cleanup extract_currdev() some and add support for setting the currdev
to cd0 when booted via cdboot.


86093 05-Nov-2001 jhb

Hook up the bioscd driver and the cd9660 filesystem.


86091 05-Nov-2001 jhb

Add a device driver for the BIOS device for CD-ROM's booted via El Torito
no emulation mode. Unlike other BIOS devices, this device uses 2048 byte
sectors. Also, the bioscd driver does not have to worry about slices
or partitions.


86001 04-Nov-2001 jhb

Trim all the extra debugging output including hexdumps, debug messages,
etc. The only bit of debugging left is performing dual output to both
the screen and COM1. Also, the twiddle is still disabled since it seems
to do weird things to the serial dump. cdboot now has 880 bytes to spare.


86000 04-Nov-2001 jhb

Axe the old cdldr.


85999 04-Nov-2001 jhb

Use the new cdboot instead of cdldr.


85998 04-Nov-2001 jhb

This is a new CD bootstrap utility designed to replace cdldr. According
to the El Torito standard for CD booting, a CD may boot in "No emulation"
mode without using a floppy image. In this mode, the BIOS loads a program
off of the CD into memory and creates a BIOS device using 2048 byte sectors
for the CD. According to the standard, this program can be up to 0xFFFF
virtual (512-byte) sectors long. The old cdldr depended on this by having
the BIOS load the entire loader and the small cdldr stub as one binary
similar to pxeboot so that cdldr didn't have to read the CD to find the
loader. However, the NT no emulation loader just uses 1 disk sector
(4 virtual sectors), so it seems that at least some BIOS writers just did
enough to get NT to boot by only loading 1 sector and ignoring the sector
count. Thus, while cdldr should have worked in theory, it doesn't in
practice. This replacment fits entirely in 1 sector and includes simple
ISO 9660 support. It looks for /boot/loader on the CD and loads it up
using the BIOS. This allows us to not have to depend on the limited size
of floppy images but use a full GENERIC kernel for CD-ROM installs in the
future, among other things.

This version of cdboot is a bit bloated as it includes some useful
debugging routines that people can pull to use in other x86 assembly
modules. Even with all the debugging cruft, we still have 272 bytes to
spare.


85995 03-Nov-2001 jhb

Whoops, missed these bits in the previous commit.


85994 03-Nov-2001 jhb

Add support for sending messages to the serial console which is helpful
when debugging boot problems. It is not on by default but is enabled via
the BTX_SERIAL variable. The port and speed can be set via the same
variables used by boot2 and the loader.


85993 03-Nov-2001 jhb

Add support for outputting multiple lines when dumping memory during the
register dump. Change the default to bump 2 lines of output (32 bytes)
instead of 1 line (16 byte).


85990 03-Nov-2001 jhb

Add support for trace traps by returning from them just as for breakpoint
traps rather than halting. Ideally, we should avoid printing the
'BTX halted' message for debug register dumps.


85989 03-Nov-2001 jhb

Output a newline at the end of a dump so that there are blank lines between
dumps when using breakpoints or tracing.


85805 01-Nov-2001 peter

Fix the ILLEGAL fdisk table that is there for supporting "dangerously
dedicated" mode. This was specifying that there are 256 (illegal!)
heads on the disk. If bioses store that in a byte, and it gets truncated
to 0, then that almost certainly causes the infamous divide-by-zero
nightmare.

This is also most likely the reason why the Thinkpad T20/A20 series
were locking up when FreeBSD was installed. This is also the most likely
reason why a boot1 being present causes an IA64 box to lock up at boot.
(removing the "part4" stuff from boot1.s fixes the IA64 boxes and would
most likely have fixed the T20/A20 and some TP600E series thinkpads)


85376 23-Oct-2001 jlemon

Set RB_MULTIPLE (multiple console support) if the kernel is booted
with the -D flag.


85374 23-Oct-2001 jlemon

Allow the RBX_DUAL flag to appear in bootinfo.


84461 04-Oct-2001 jhb

Whitespace fixes.


84371 02-Oct-2001 yokota

Fix the ANSI color escape sequence \E[m.

- Corretly map the ansi color number to a PC BIOS color.
- Handle multiple arguments to the escape sequence.


84354 02-Oct-2001 yokota

Fix the local macro: isvisible().

- The space char (0x20) IS a visible char :-)


84277 01-Oct-2001 yokota

Fix the function CD(): "Clear to the end of the screen".

- When the video BIOS is called to clear the region (x, y)-(79, 24)
(by scrolling), the slashed region in Fig.1 is cleared. CD() is
supposed to clear the region shown in Fig.2.
x x
+-------+ +-------+
| | | |
y| ////| y| ////|
| ////| |///////|
| ////| |///////|
+-------+ +-------+
Fig.1 Fig.2

- Don't move the cursor during this operation.


84276 01-Oct-2001 yokota

This is white-space only change. No functional difference.

- Be consistent about placing spaces around keywords and
operators; don't mix statements like "if(A==B)" and "if (X == Y)",
"return(0)" and "return (-1)", "P=10" and "Q = 0", etc.

- Consitently indent lines. It's not good to indent by 8 columns
in one part of the file, and by 4 columns in the other part.


83616 18-Sep-2001 sobomax

Add support for loading bzip2-compressed kernels and modules. This support
is turned off by default and could be enabled by defining LOADER_BZIP2_SUPPORT
make variable. Also make gzip support optional (turned on by default) -
it could be turned off via LOADER_NO_GZIP_SUPPORT make variable.

Please note, that due to limit on the amount of memory available to the
loader(8), it is possible to load modules/kernels compressed with the smallest
block size supported by the bzip2 - 100k (`-1' bzip2(1) option), however
even in this mode bzip2(1) usually provides better compression ratio than
gzip(1) in its best compression mode.

MFC after: 1 month


83368 12-Sep-2001 ru

Create backup copies using install(1).


83321 11-Sep-2001 peter

Implement the long-awaited module->file cache database. A userland
tool (kldxref(8)) keeps a cache of what modules and versions are inside
what .ko files. I have tested this on both Alpha and i386.

Submitted by: bp


82542 30-Aug-2001 msmith

Mention that the ACPI module load can be disabled by unsetting $acpi_load


82531 30-Aug-2001 msmith

Teach the loader how to find the system ACPI information, and autoload
the ACPI module if the system apperars to be ACPI compliant.

This is an initial cut; the load should really be done by Forth support
code, and we should check both the BIOS build date and a blacklist.


82133 22-Aug-2001 peter

OK, now I am scared of pxeldr. It had /boot/loader appended onto
the end of it and decoded the headers.

Submitted by: jhb


82128 22-Aug-2001 peter

Generate an ELF /boot/loader instead of fake a.out. The fake a.out wrapper
did not work with old a.out-only bootblocks anyway. :-(


81367 09-Aug-2001 mp

Allow for text section alignment to properly align the "end" symbol at the
actual end of the section. The new gas (binutils) puts in additional padding
which was misaligning the concatenated btx loader.

Reported by: Oliver Hartmann <ohartman@klima.physik.uni-mainz.de>,
Harti Brandt <brandt@fokus.gmd.de>
Tested by: Oliver Hartmann <ohartman@klima.physik.uni-mainz.de>,
David Wolfskill <dhw@whistle.com>, ps
Reviewed by: jhb
MFC after: 1 day


81363 09-Aug-2001 jhb

Trim trailing whitespace.


80751 31-Jul-2001 jhb

Add in a hack to support IBM "El Torito" CD-ROM booting BIOS's which expect
the first sector of the emulated floppy to contain a valid MS-DOS BPB that
it can modify. Since boot1 is the first sector of boot.flp, this resulted
in the BIOS overwriting part of boot1: specifically the function used to
read in sectors from the disk.

Submitted by: Mark Peek <mark@whistle.com>
Submitted by: Doug Ambrisko <ambrisko@ambrisko.com>
PR: i386/26382
Obtained from: NetBSD, OpenBSD (the example BPB)
MFC after: 1 month


80203 23-Jul-2001 kris

s/adress/address/

Inspired by: OpenBSD
MFC After: 1 week


80084 21-Jul-2001 rnordier

Unset MAINTAINER.


78522 21-Jun-2001 peter

Remove -DNEW_LINKERSET, it is not used here anymore. This is now native.


77273 27-May-2001 rnordier

Fix reboot buglet when BOOT_BTX_NOHANG is defined.

Submitted by: Umesh Krishnaswamy <umesh@juniper.net>


76224 02-May-2001 obrien

* include/elf.h has been repo copied to include/elf-hints.h, and it no
longer includes machine/elf.h.
* consumers of elf.h now use the minimalist elf header possible.

This change is motivated by Binutils 2.11.0 and too much clashing over
our base elf headers and the Binutils elf headers.


74850 27-Mar-2001 ru

MAN[1-9] -> MAN.


74592 21-Mar-2001 jhb

Always disable paging when exiting back to real mode after receiving a
fatal trap. Also, reload the GDT register to point to BTX's GDT before
playing around with the segment registers to return to real mode. This is
helpful if the kernel causes a fatal exception before it has setup its own
IDT and fault handlers. For example, if one happens to break mtx_init().
Without these changes BTX would recursively page fault (if paging was not
disabled) or triple fault and reset the CPU (without the GDT reload)
instead of providing a potentially useful register dump.

Reviewed by: rnordier


74265 14-Mar-2001 ps

Don't set the gateway address if the netmask is zero or we're on
the same network. PXE does not do netmask calculations, so if the
gateway is set it will use it.

Submitted by: peter & FreeBSD cluster ACLs


72640 18-Feb-2001 asmodai

Preceed/preceeding are not english words. Use precede or preceding.


72091 06-Feb-2001 asmodai

Fix typo: seperate -> separate.

Seperate does not exist in the english language.


70177 19-Dec-2000 rnordier

Fix column alignment (whitespace-only change).


69985 13-Dec-2000 rnordier

Strip the .comment and .note sections when stripping. There's no
point in retaining this info, particularly under BTX.


69921 12-Dec-2000 rnordier

Add a magic number, for easier identification of boot0. At present,
this is used only by libdisk.


69395 30-Nov-2000 jhb

Set the proper bit in the howto flags for a serial console rather than
setting the index of the bit. (0xc vs. 0x1000)


69391 30-Nov-2000 ps

Add support for probing the keyboard from pxeboot which will behave
exactly the same as passing -P to boot2.

Submitted by: jhb


69027 22-Nov-2000 ru

mdoc(7) police: do not split author names in the AUTHORS section.


68854 17-Nov-2000 ru

mdoc(7) police: use certified section headers wherever possible.


68362 05-Nov-2000 ps

Honor the ip address given in the root-path dhcp option.

PR: 21743
Submitted by: Brian Candler <B.Candler@pobox.com>


68314 04-Nov-2000 rnordier

Support a.out: avoid (%dx) in in/out instructions, and use an m4
macro to supply underscores for externals.


68310 04-Nov-2000 ps

MF4: Add LOADER_TFTP_SUPPORT make.conf flag.


68264 02-Nov-2000 jhb

The Number of Fixed Disks at memory location 0x475 is only 1 byte, not a
2 byte word. This fixes machines that probe 30-odd hard drives during boot
in the loader.

Submitted by: Helpful folks at Tyan via ps


68136 01-Nov-2000 mph

"it's" --> "its" (possessive).

Correct a malformed sentence.


66556 02-Oct-2000 rnordier

Go back to occupying just a single sector, reverting r1.17 - r1.20.
Taking over the sector following the MBR causes problems on some
machines, and the actual gains are fairly small in terms of how
the space is presently used.

Since we need a number of further features (eg. handling extended
partitions) that can't be readily accommodated in the basic boot0
design anyway, rather choose to implement the additional stuff
separately and concentrate on compatibility rather than features
here.


66555 02-Oct-2000 rnordier

Set MAINTAINER.


66133 20-Sep-2000 archie

Add support for the "nullconsole" console type, for systems with
neither a video console nor a serial port. Use it if the RB_MUTE
flag is set.

Submitted by: Doug Ambrisko <ambrisko@whistle.com>
Reviewed by: jhb


65685 10-Sep-2000 dcs

Bump up version as a result of the recent changes to kernel path,
and boot-conf&boot semantic changes.

Also, make it 1.0.

Reminded by: peter (even though he doesn't know it)


65640 09-Sep-2000 rnordier

Correct BSD/OS slice type.

PR: 21099
Submitted by: Alan Clegg <abc@bsdi.com>


65598 08-Sep-2000 imp

Look for libstand in the built tree rather than in /usr/lib. This
likely could be done better, but the tree is broken and I wanted to
get a fix into the tree.

Reviewed by: msmith


65499 05-Sep-2000 msmith

Fix a bug which prevents parsing this Makefile without having a
previously-built loader binary elsewhere.


65498 05-Sep-2000 msmith

Export the salient configuration items in a non-pxe-specific namespace
to allow commonality between varying platforms. This is a step
towards parsing the diskless configuration information with MI code
inside the kernel.

Export the interface hardware address to the kernel, so that it is possible
to determine the boot interface with certainty.

Export the NFS filehandle for the root mount to the kernel, so that the
kernel does not need to perform a mount RPC call.


65063 24-Aug-2000 jhb

Add a new compile-time tweak to BTX. If you set the make(1) variable
BOOT_BTX_NOHANG, then BTX will be compiled with the appropriate flags so
that it reboots after a fault instead of hanging forever.

Requested by: ps
Approved by: rnordier


64550 11-Aug-2000 peter

Add -mpreferred-stack-boundary=2 to CFLAGS for i386. This and libstand
reduces /boot/loader from 163840 bytes to 155648 and pxeboot from 165888
bytes to 157696 bytes.


64527 11-Aug-2000 ps

Add support to send the string 'PXEClient' as the Vendor class
identifier to the DHCP server. Now you can check for this string
in your dhcp configuration to decide whether you will hand out a
lease to the client or not.


64522 11-Aug-2000 ps

Pass along the interesting variables we were given from DHCP so we
can utilize them in the kernel and with kenv.


64385 08-Aug-2000 rnordier

Typo/spelling fixes.


64260 04-Aug-2000 jhb

Argh! Fix a brainfart of mine. In the old boot0, we relocated ourself
to 0x600 via a 'rep movsw'. Once that was done, %cx was zero, so we could
simply use 'movb' to update the lower byte of %cx in preparation for
zeroing out the fake partition entry used to boot to other drives via F5.
Well, in the new boot0, we don't actually relocate ourselves, instead it
is easier to create the fake partition entry first and then just use it to
get the BIOS to load all of boot0 into memory at 0x600. However, since we
aren't doing the relocate code anymore, we don't know that %cx == 0 when
we hit the 'movb' to setup %cx for clearning the fake partition entry.
Thus, if %ch != 0 when the BIOS started boot0, then it would end up zeroing
a lot more memory than just 8 words. The solution is to do a word move of
$8 into %cx.

Debugging help from: David Wolfskill <dhw@whistle.com>


64187 03-Aug-2000 jhb

Cleanup warnings. Most of these are signed/unsigned warnings, as well as
some added const's.


64186 03-Aug-2000 jhb

Fix several BDECFLAGS warnings. Also, actually use the 'verbose' parameter
for lsdev when printing out slice information. Now, you only get the
sizes and LBA's of slices if you use 'lsdev -v'.


63328 17-Jul-2000 jhb

Oops. Remove some debugging code used to display a hexdump of the sector
we just loaded from the disk. The code to call it was commented out, and
it easily fit into the extra sector, but remove it anyway as it is
unneeded.


63321 17-Jul-2000 jlemon

Unbreak the build -- no manual page for this yet.


63315 17-Jul-2000 jlemon

Hook up liloldr


63314 17-Jul-2000 jlemon

This is `liloboot', which creates a file which can be treated like a
Linux kernel image, and is designed to be dropped into a Linux system
and booted via LILO. Once booted, the user is greeted by the FreeBSD
loader. This still isn't quite complete, as the the root= specification
from LILO isn't currently passed to the loader yet.


63032 12-Jul-2000 jhb

The new and improved boot0, v1.1. This version adds the following:
- Autodetection and support of the BIOS EDD extensions to work around the
1024 cylinder limit on all but really ancient BIOS's.
- To work around some BIOS's which break when EDD is used with older drives,
we only attempt to use EDD if the cylinder is > 1023.
- Since this new code required more space than we had left, expand boot0 to
2 sectors (1024 bytes) in length.
- Add support for boot0 being multiple sectors using predefined constants.
If boot0 needs to be extended in the future, all that is required is
bumping the NUM_SECTORS constant.
- Now that we have more room to work with, add a few more fs type
descriptions while making others more verbose.


62787 07-Jul-2000 jhb

Remove commented out NOMAN variable.


62665 06-Jul-2000 jhb

- Inline all the functions that are only called once. This results in a
savings of 68 bytes in boot2.
- Also add a comment warning that you can't remove the empty exit()
function.


62660 06-Jul-2000 jhb

Doh. The disklabel is not 0x200 bytes of zeros, but it is 0x200 bytes long.


62658 06-Jul-2000 jhb

Clarify the comments in here a bit. The first sector of boot2 is not just
zeros, it is actually the disklabel itself. boot2.ldr is simply a
placeholder in the boot2 binary.


62657 06-Jul-2000 jhb

Emulate the WBINVD instruction when it is called by the BIOS.


62242 29-Jun-2000 jhb

Change the fault message to say 'BTX halted' isntead of 'System halted' to
avoid confusion.

Submitted by: George Scott <George.Scott@its.monash.edu.au>


62229 29-Jun-2000 jhb

Rework the detecting of the rdmsr and wrmsr instructions in the v86
monitor so that the codepath is cleaner and easier to maintain in the
future.


62176 27-Jun-2000 jhb

- Don't blindly assume that there are 8 hard drives installed. Instead,
use the BIOS Equipment List to determine how many hard drives are
installed and if the drive number we received in %dl is valid.
- Don't bother to disable interrupts when setting up the stack. The 8086
and beyond implicitly disable interrupts after an instruction that sets
%ss (for example, a pop or a mov) so that you can safely set %ss and %sp
in two consecutive instructions. An exception to this is the lss
instruction, which can set both registers simultaneously and thus doesn't
need this hack.
- Add support for EDD BIOS extensions to support booting off of hard drives
of nearly arbitrary length.


62146 26-Jun-2000 jhb

Comment this.


62138 26-Jun-2000 jhb

Add in support for EDD to support large disks via LBA. This uses a
method similar to that of the loader to avoid potentially breaking older
drives in that we only use EDD if the desired cylinder is > 1023.


61836 19-Jun-2000 jhb

Comment this bad boy. Hopefully the next person that comes along won't
have to spend a few hours reading the code to figure all this out.


61823 19-Jun-2000 jhb

- Add some more details to the 'lsdev' output for FAT file systems.
- Add in support for the EDD (Enhanced Disk Drive) BIOS extensions to
use LBA mode for accessing drives past cylinder 1024. This should allow
us to load a kernel from anywhere on a newer drive up to 2 TB. Part
of this came from the PR below.

PR: i386/13847
Submitted by: Tor Egge <Tor.Egge@fast.no>


61743 17-Jun-2000 jhb

Add support for emulating the RDMSR and WRMSR instructions into BTX. In
theory, this should allow the K7V Athlon motherboard to boot ok with boot
virus protection enabled. However, I have no hardware to test this. It
shouldn't break anything though. :)

Prodded by: Kelly Yancey <kbyanc@posi.net>


61659 14-Jun-2000 ps

Delay calling the device cleanup routines until the absolute last
moment. We were cleaning up after PXE too early and the module
dependancy code would not be able to load any files if it needed
too.


61627 13-Jun-2000 ru

Treat \t and \n inside /boot.config as whitespaces.

PR: 19215


61377 07-Jun-2000 dcs

Bump loader version due to copyin, copyout, setenv&cia.


60846 24-May-2000 jhb

Convert the short stub of real-mode code into 16-bit assembly.


60823 23-May-2000 jhb

Grrr, fix a silly 'movl' -> 'movw' typo in both pxeldr and cdldr. Also,
remove unnecessary cruft from the Makefiles for both.


60822 23-May-2000 jhb

Clean up some more 16-bit code and get rid of more m4 macros.


60821 23-May-2000 jhb

Clean up all of the 16-bit assembly code in the x86 bootstrap to work
with the new binutils. Now that we have a decent assembler, all the old
m4 macros are no longer needed. Instead, straight assembly can be used
since as(1) now understands 16-bit addressing, branches, etc. Also,
several bugs have been fixed in as(1), allowing boot0.s to be further
cleaned up.


60703 19-May-2000 dcs

This file got repo-copied to common/.


60702 19-May-2000 dcs

Move man page directives to common/Makefile.inc.


60684 18-May-2000 dcs

Make corrections to allow for Alpha.


60277 09-May-2000 dwhite

Remove metion of the 'magic options.' Apparently PXE doesn't require the
special options on 0.99c (it mumbles something about 'PXE server not found'
but works anyway), and it won't work at all with PXE 2.0.


60046 05-May-2000 jhb

Switch to using the .code16 as(1) directive and using 16-bit assembly
code instead of using 32-bit code and having to just "know" that it's
really 16-bit instructions when things run. This also allows the code
to use fewer macros and more actual assembly statements, which eases
maintenance. Unfortunately, due to as(1) brokenness, we still use m4
macros for all 16-bit addresses, and all short jumps (i.e., 8-bit
relative addresses in the jump instruction) must be wrapped in .code32
directives to avoid useless bloat by as(1). This also fixes a few
problems that were preventing boot0 from compiling with the latest
and greatest version of as(1).


60023 05-May-2000 ps

Remove the static heap. It is unknown why it was needed in the
beginning, but it no longer is required. This has been tested with
many different revisions of the PXE rom from Intel.


60006 04-May-2000 dcs

Make documentation on recently added heap? command reflect reality.


60005 04-May-2000 dcs

Add "heap?" to loader's man page.


60003 04-May-2000 dcs

Further improve ordering.


60002 04-May-2000 dcs

Sort entries in FreeBSD-specific FICL commands.


59887 02-May-2000 dwhite

Add man page for pxeboot.

Reviewed By: asmodai


59855 01-May-2000 ps

Wrap the failure warnings around PXE_DEBUG in the cleanup routine.
It does not matter if they fail, so dont print anything about it
unless we are debugging.


59854 01-May-2000 bp

Update loader logic to distinguish modules vs. files.
Add support for module metadata. The old way of dependancy
handling will be supported for a while.

Reviewed by: peter


59768 29-Apr-2000 ps

Fall back to /pxeroot as the location of the NFS exported directory
if we are not given one by dhcp.
Remove extra includes while I am here.

Reminded by: jlemon


59767 29-Apr-2000 jlemon

Teach the loader about the ext2fs filesystem, extended partitions, and
the new readdir function.


59686 27-Apr-2000 ps

Make PXE do a dhcp request to find out where its files are. The
DHCP server is no longer required to also act as the NFS/TFTP
server.


59673 27-Apr-2000 ps

Don't report errors when we UDP_WRITE fails with a status of 1.


59659 26-Apr-2000 jhb

Now that we are compiling PXE into libi386, we don't need ../libi386 in
.PATH anymore.


59644 26-Apr-2000 ps

Bring support in for Intel Wired for Management 1.1 (PXE 0.99 and
below). This did not work previously because interrupts were
disabled when PXE calls were being made, and they must be enabled.
This should also allow us to be compliant with all newer PXE rom's
from Intel.

For PXE 0.99, this has been tested using the Intel N440BX motherboard
and I am confident it will work on the Intel L440GX motherboard.

Lots of help/information from: jhb, peter

I would like to thank Michael Johnston <michael.johnston@intel.com>,
Mike Henry <mike.henry@intel.com>, and all the other PXE developers
at Intel for their help, and information in helping solve this
problem.


59634 26-Apr-2000 jhb

Don't disable interrupts when calling a vm86 mode interrupt or routine
from user mode. Don't disable interrupts when returning from vm86 mode
to user mode either. Now, we only disable interrupts before calling a
hardware interrupt handler, which is the only time we _should_ be
disabling interrupts.

Because of this, err, feature, any routine that one called in vm86 mode
had to re-enable interrupts by setting the interrupt flag or interrupts
would remain disabled even after the routine returned. For example, I
have a simple debugging routine that uses a vm86 mode function to dump
any arbitrary memory word that I use to read the BIOS timer or any other
memory location. This function does 1 load instruction from memory and
then returns. Since it didn't re-enable interrupts, the first time I
called it to read the BIOS timer, it disabled interrupts. This also
affected the PXE bootstrap as it needs interrupts enabled while it is
processing. This patch fixes both of those situations so that those
functions do not worry about having to enable interrupts. Hardware
interrupt handlers worked fine with the old code because they always
enable interrupts as part of their routine.

If you have any problems with the loader after this commit, please
let me know. I'd like to MFC it in a week or two since PXE support
needs it.

Noticed by: ps, Michael Johnston <michael.johnston@intel.com>


59473 21-Apr-2000 ps

Move the building of the PXE module into libi386.


59456 21-Apr-2000 ps

Make the loader a little smarter about when it is and is not allowed
to call PXE.


59455 21-Apr-2000 ps

Don't call the PXE cleanup routine if PXE is not enabled. This
should fix the "Invalid partition table" error people were seeing.


59408 20-Apr-2000 ps

Add a cleanup function. This is needed for PXE where you should
shutdown the UNDI and unload the stack.


59390 19-Apr-2000 ps

Use !PXE api over PXENV+ api.
Magic trampoline by: peter (at 4am and after a good whipping at airhockey)
Do a better job of returning and detecting errors.


59150 11-Apr-2000 jhb

Add a missing dependency: boot2 depends on the BTX kernel.


59100 08-Apr-2000 jkh

Nuke duplicate struct declaration from somebody's paste-o


59087 08-Apr-2000 ps

Make PXE use the UDP API. This allows for both TFTP and NFS support.
You may specify TFTP or NFS via compile time options in the loader,
but not both at this time.

Also, remove a warning about not knowing how to boot from network
devices. We can obviously do that now.


58999 04-Apr-2000 ps

Add a missing PXE API call and structure.


58993 04-Apr-2000 ps

Add all the PXE related structures from the 2.1 PXE spec from Intel.
Fix exsisting code to match the spec.


58713 28-Mar-2000 jhb

Mega i386 loader commit.
- Don't hard code 0x10000 as the entry point for the loader. Instead add
src/sys/boot/i386/Makefile.inc which defines a make variable with the
entry point for the loader. Move the loader's entry point up to
0x20000, which makes PXE happy.
- Don't try to use cpp to parse btxldr for the optional BTXLDR_VERBOSE,
instead use m4 to achieve this. Also, add a BTXLDR_VERBOSE knob in the
btxldr Makefile to turn this option on.
- Redo parts of cdldr's Makefile so that it now builds and installs cdboot
instead of having i386/loader/Makefile do that. Also, add in some more
variables to make the pxeldr Makefile almost identical and thus to ease
maintainability.
- Teach cdldr about the a.out format. Cdldr now parsers the a.out header
of the loader binary and relocates it based on that. The entry point of
the loader no longer has to be hardcoded into cdldr. Also, the boot
info table from mkisofs is no longer required to get a useful cdboot.
- Update the lsdev function for BIOS disks to parse other file systems
(such as DOS FAT) that we currently support. This is still buggy as
it assumes that a floppy with a DOS boot sector actually has a MBR and
parses it as such. I'll be fixing this in the future.
- The biggie: Add in support for booting off of PXE-enabled network
adapters. Currently, we use the TFTP API provided by the PXE BIOS.
Eventually we will switch to using the low-level NIC driver thus
allowing both TFTP and NFS to be used, but for now it's just TFTP.

Submitted by: ps, alfred
Testing by: Benno Rice <benno@netizen.com.au>


58098 15-Mar-2000 jhb

Remove some extra spammage that made it into this commit. This will be
revisited later with a better fix, or at least one that compiles. :)

Approved by: dcs


58081 15-Mar-2000 dcs

Pass an unit number to bcache_strategy, so it can flush the cache when
necessary. Pass an absolute block number too, instead of receiving a
relative one in realstrategy(), as bcache_strategy() requires this.

The fix is sligthly different from the one in the PR.

PR: 17098
Submitted by: John Hood <jhood@sitaranetworks.com>


57254 16-Feb-2000 jhb

This patch to BTX fixes several small things:

1) Fix a bug in the int15 function 87 emulation where we only copied half
of what the BIOS asked for. This caused the Mylex RAID adapter to go
haywire and start trashing memory when you tried to boot from it.
2) Don't use interrupt 19 to reboot. Instead, set the reboot flag to a warm
boot and jump to the BIOS's reboot handler. int 19 doesn't clear memory
or restore the interrupt vector table, and thus really isn't safe. For
example, when booting off of PXE, the PXE BIOS eats up a chunk of memory
for its internal data and structures. Since we rebooted via int 19,
using the 'reboot' command in the loader resulted in that memory not
being reclaimed by the BIOS. Thus, after a few PXE boots, the system
was out of lower memory.
3) Catch any int 19 calls made by a BTX client or a user pressing
Ctrl-Alt-Delete and shutdown BTX and reboot the machine cleanly. This
fixes Ctrl-Alt-Delete in the loader and in boot2 instead of presenting
the user with a BTX fault.

Approved by: jkh
Found by: 1) by msmith


57090 09-Feb-2000 ru

Support the new ata(4) syntax, while providing backward compatibility for wd(4).

Reviewed by: jkh, msmith, sos
Approved by: jkh


56992 04-Feb-2000 luigi

Add a NOFORTH variable so we can build a smaller loader without
Forth support, for use with PicoBSD

Approved-By: jordan


56903 30-Jan-2000 jhb

Fix bogon in previous commit. Re-enable Forth in the loader.

Noticed by: dcs
Approved by: jkh


56752 28-Jan-2000 jhb

Allow for cdldr to be built in ${.OBJDIR}/../cdldr/cdldr instead of
only looking for it in ${.CURDIR}/../cdldr/cdldr. This fixes world.


56693 27-Jan-2000 jhb

Add the new cdldr CD bootstrap loader. This patch includes the following:

- Fix btxldr to preserve a NULL bootinfo pointer when it copies the kernel
arguments.
- Add the cdldr bootstrap program. This program is tacked onto the
beginning of the standard 3rd stage boot loader (/boot/loader) to form
the CD boot loader (/boot/cdboot). When a CD is booted, the cdboot file
is copied into memory instead and executed. The cdldr stub emulates the
environment normally provided by boot2 and then starts the loader. This
booting method does not emulate a floppy drive, but boots directly off of
the CD. This should fix the problems some BIOS's have with emulating a
2.88 MB floppy image.
- Add support to the loader to recognize that it has been booted by cdldr
instead of boot2 and use a simpler method of extracting the BIOS boot
device.


56691 27-Jan-2000 jhb

Fix brokenness introduced with the PAGING conditional variable. The value
of %cr0 wasn't reloaded into %eax before being modified to turn protected
mode off if PAGING was not defined. The result was that the processor did
not exit protected mode, so when it tried to jump to segment 0x0 in the
next instruction to clear the prefetch cache like one should when leaving
protected mode, it actually tried to jump to a null selector, causing a
GPF.


55211 29-Dec-1999 msmith

Substantially revamp the way that we determine the amount of memory available
for our use. Use the same search order for BIOS memory size functions
as the kernel will later use.

Allow the loader to use all of the detected physical memory (this will
greatly help people trying to load enormous memory disk images).

More correctly handle running out of memory when loading an object.

Use the end of base memory for the top of the heap, rather than
blindly hoping that there is 384k left.

Add copyrights to a couple of files I forgot.


54294 08-Dec-1999 phk

Remove BAD144 support, it has already been disabled for some time.


53637 23-Nov-1999 dcs

Add machine-specific include path to ficl's sysdep.h. Wishes I had
gone to bed earlier.

Pointed by: peter


53174 15-Nov-1999 obrien

Add -fdata-sections, which is a new GCC 2.95 optimization. Remove
-fschedule-insns as it wasn't such a big win with 2.95 after all.

Add the *BIG* win "-mpreferred-stack-boundary=2" optimiztion submitted by
Dima. GCC 2.95 ensures the stack frame is always properly [opitimally]
aligned by surrounding every function call by code simular to
"addl $-12, %esp" / "addl $12, %esp". Here we need the reduction in space,
with speed not an issue.


53159 14-Nov-1999 obrien

Return this file to its pre-spammed version. Thanks to some new compiler
optimizations, we can go from 3 bytes free with the spammed version, to
279 bytes free with the full version.


53135 14-Nov-1999 obrien

Enter complier upgrade mode again. We need to cut 169 bytes from this:
Remove some printf() calls, reduce size of buffers, and abbreviate
some strings.

Hopefully the boot people will fix this spamage after the cut over to
Gcc 2.95.2 as the system compiler.


53134 13-Nov-1999 obrien

Turn on the -fforce-addr and -fschedule-insns optimizations. Adding
either one gives us an additional 32 bytes of additional space available
when using EGCS 1.1.2. With GCC 2.95.2 -fforce-addr gives us 12 more bytes,
and adding -fschedule-insns gives us an additional 4 bytes.


52545 27-Oct-1999 jhb

If PAGING is defined then actually turn it on when entering protected
mode.


52395 19-Oct-1999 dcs

Make the "machine" target a prequisite to all source files.

Hinted-at by: bde


52173 12-Oct-1999 jhb

aThis patch updates the BTX to emulate the BIOS function "Copy Extended
Memory" called as function 0x87 of interrupt 0x15. Since the Mylex RAID
adapter's BIOS used this function to access memory (actually PCI bus
space) beyond 16 MB, this patch also allows BTX to address all 4 Gig of
possible address space on i386+. Since the loader does not have room for
4 MB of page tables, this was done by turning off paging.

Paging was turned off via a compile time setting which defaults to off.
To enable paging, simply define the make variable PAGING.

rnordier might want to clean this up later.

Submitted by: W. Gerald Hicks <wghicks@bellsouth.net>,
Bosko Milekic <bmilekic@ares.dsuper.net>
Reviewed by: msmith
Required by: Mylex RAID adapter's BIOS


52148 12-Oct-1999 brian

Blank out the twiddly thing when outputting the ``BTX loader'' message.


50822 03-Sep-1999 julian

Remove accidental cut&paste garbage in a comment.


50820 03-Sep-1999 julian

Comment the boot manager. So I don't have to work it all out again :-)

Reviewed by: rnordier@freebsd.org


50477 28-Aug-1999 peter

$Id$ -> $FreeBSD$


49191 28-Jul-1999 nik

Fix some typos.

PR: docs/11955
Submitted by: Christian Weisgerber <naddy@mips.rhein-neckar.de>


49060 24-Jul-1999 rnordier

Recognise NetBSD slices.

Submitted by : Lars Koeller <lkoeller@cc.fh-lippe.de>
PR : 12772


48952 21-Jul-1999 msmith

Walk around the end of all the silly guessing of device types and unit
numbers that we have been doing in the past, and read /etc/fstab off the
proposed root filesystem to determine the actual device name and vfs
type for the root filesystem. These are then exported to the kernel
via the environment variable vfs.root.mountfrom.


48919 20-Jul-1999 rnordier

Reintroduce LBA (cyl > 1023) support in the bootblocks, enabled by
means of a build option.


48913 19-Jul-1999 rnordier

Activate kgzldr.


48912 19-Jul-1999 rnordier

Use M4FLAGS for m4.


48908 19-Jul-1999 rnordier

This commit was generated by cvs2svn to compensate for changes in r48907,
which included commits to RCS files with non-trunk default branches.


48351 29-Jun-1999 peter

Reconcile all the loader newvers.sh's into one common one.


48135 23-Jun-1999 ru

-mdoc fix.


48083 21-Jun-1999 rnordier

Fill in bi_bios_geom[] in the bootinfo structure passed to the kernel.
This should resolve the problem raised in PR 12315, and incidentally
makes it easier to determine what geometry the BIOS is actually using
(by way of boot -v and dmesg).


48037 19-Jun-1999 rnordier

Provide for enabling/disabling each slice individually.


48034 19-Jun-1999 rnordier

Fix use of e_phoff in place of e_phnum.


48033 19-Jun-1999 rnordier

Correct and clarify some comments.


48010 18-Jun-1999 rnordier

Change active flag handling; sanity check passed drive number; pass
partition pointer to bootstrap; optimise away 10 bytes; cosmetics.


47727 04-Jun-1999 ghelmer

Modify the boot loader to recognize the -C flag and pass the RB_CDROM
flag to the kernel to mount a CDROM as the root filesystem. Alternatively,
the boot_cdrom env var can be set.

As Mike Smith noted, "-C is the "wrong" way to do this", but this is
an acceptable stopgap in lieu of a better way.

PR: bin/11884
Reviewed by: msmith@freebsd.org


47473 24-May-1999 rnordier

Activate mbr.


47472 24-May-1999 rnordier

This commit was generated by cvs2svn to compensate for changes in r47471,
which included commits to RCS files with non-trunk default branches.


47395 22-May-1999 rnordier

Fix a reference to the mysterious Mike Smisth.


47312 18-May-1999 rnordier

Drop some non-existent commented-out targets.


47011 11-May-1999 jb

Found the needle in the haystack!

Use colons instead of semi-colons in the default init_path to behave like
UNIX instead of DOS.

Suggested by: bde
Reminded by: des (with no hint as to *which* man page).


46354 03-May-1999 jkoshy

Correct typos.

PR: docs/11445
Submitted by: Kazuo Horikawa <horikawa@jp.freebsd.org>


46074 25-Apr-1999 dcs

Make man page reflect reality on parsing rules. Now I know Jordan
never read this man page... :-)


46009 24-Apr-1999 dcs

Move loader.conf.5, while it is still in it's first revision.


46005 24-Apr-1999 dcs

Add loader.4th man page (worst man page I ever wrote -- reviews
are welcomed). Correct a nasty bug in loader.4th before anyone
notices, add a couple of features.


45881 20-Apr-1999 des

Make the location of init(8) tunable at boot time.


45759 18-Apr-1999 dcs

Installs a default loader.rc if none exists. Document loader.conf.


45335 05-Apr-1999 rnordier

Fix damage introduced in previous commit.


45334 05-Apr-1999 rnordier

Optimize better for space.
Thanks to: jdp


45309 04-Apr-1999 obrien

Remove the string ">>> FreeBSD/i386 BOOT". I need to reduce the size of
boot2 by 16 bytes. I expect this to be temperary until the boot2 authors
can do the proper fix.


45175 31-Mar-1999 joerg

Make <DEL> an alternative rubout character for command input; many
serial terminals use this as their default rubout key.


44861 18-Mar-1999 dcs

Avoid copying m_args if none exists. (Perhaps this is a better solution,
Doug?)


44840 17-Mar-1999 dcs

Version bump: kvm & dictionary size.


44780 15-Mar-1999 dcs

The man page, version 0.1.


44622 10-Mar-1999 dcs

Install new loader.rc stuff.


44572 08-Mar-1999 dcs

Add MODINFO_ARGS, parameters passed to a module at load time.

VS: ----------------------------------------------------------------------


44357 01-Mar-1999 rnordier

Save option, rather than slice, selected. This permits unattended
booting from other than drive 0, as the F5 keypress is saved and
"replayed."

Requested (some time ago) by: archie


44296 26-Feb-1999 rnordier

Implement "setdrv" option


44274 25-Feb-1999 rnordier

Emulate a V86 "movl %cr0,%eax" instruction.

Feedback and testing: Kurt Hopfensperger <kjhmdjd@ix.netcom.com>


44243 24-Feb-1999 msmith

Don't try protecting page 0; it seems that BIOS writers now feel it's
appropriate to check for Windows95 by polling for state in low
memory, with fatal results.

Submitted by: rnordier@freebsd.org


43759 08-Feb-1999 dcs

Bumb up loader's version.

Reviewed by: Michael Smith <msmith@freebsd.org>


43374 29-Jan-1999 rnordier

Check size of partition before using it.


43205 25-Jan-1999 rnordier

Fix a couple of further bugs: missing argument to sprintf() and
"==" used for "=".


43137 24-Jan-1999 msmith

Bleh. Missing 'unit =' doesn't help legacy num_ide_disks code.

PR: bin/9651
Submitted by: "Daniel C. Sobral" <dcs@newsguy.com>


43115 24-Jan-1999 msmith

Document root_disk_unit


43114 24-Jan-1999 msmith

biosdisk.c
Implement a new variable 'root_disk_unit' which supersedes
'num_ide_disks' and makes it possible to explicitly set the
root device unit number regardless of type considerations.

bootinfo.c
If we can't calculate a dev_t for the root disk, complain and
don't proceed to boot with an invalid boot device.


43113 24-Jan-1999 msmith

Fill in the bi_bios_dev field in the bootinfo struct; the loader doesn't
guess this value well in anything other than the simplest of situations.


43068 22-Jan-1999 rnordier

Fix read error not being detected.


43059 22-Jan-1999 rnordier

Push version numbers up to 1.00. This is just intended to reflect
that the BTX code can be regarded as stable: there are no associated
code changes.

Suggested by: obrien


42807 18-Jan-1999 msmith

Transition from using Perl to using awk for our text-manipulation
needs. This removes the dependancy on Perl for the generation of the
loader, allowing the world to be built on a perl-free system.

Submitted by: Joe Abley <jabley@clear.co.nz>


42638 13-Jan-1999 rnordier

In the event of a disk error, boot2 is expecting an error
code to be returned: give it one


42519 11-Jan-1999 rnordier

Drop boot.help support.


42510 11-Jan-1999 msmith

Preserve the previous loader as loader.old.

Note no matching commit for the Alpha, as the alpha boot0 stage does
not have the ability to prompt for user input.

PR: kern/9406
Submitted by: "Daniel C. Sobral" <dcs@newsguy.com>


42493 10-Jan-1999 msmith

Disable kzipping the loader; it seems to be breaking the aout-to-elf build


42488 10-Jan-1999 steve

Remove redundant line of code.

PR: 9364
Submitted by: Daniel C. Sobral <dcs@newsguy.com>


42480 10-Jan-1999 rnordier

Use etc/make.conf settings for serial port and speed.

Submitted by: rvb
Reviewed by: bde


42478 10-Jan-1999 peter

Damn, I thought I had committed this already, but it seems not.

Move the relocated boot1 and arg transfer space from 0x600/0x800 to
0x700/0x900. In theory this should make no difference, apart from the fact
that Buslogic controllers happen to use a few bytes at 0x600 for some sort
of scratch space for it's int 0x13 hook (!!!), causing the machine to crash
badly when the boot2 code makes it's callbacks into boot1 for disk IO.

Submitted by: Robert Nordier <rnordier@freebsd.org>


42446 09-Jan-1999 msmith

Explicitly look for kzip in /usr/bin, again this is a stopgap, to avoid
making kzip a build tool.


42420 09-Jan-1999 msmith

kzip the loader, this shrinks it to about 60% of its original size.
Note that this is a stopgap with dependancies on the a.out tools.


42419 09-Jan-1999 msmith

Extend bd_print() so that it displays slices and partitions on disks.


42291 04-Jan-1999 peter

Fix a potential sign extension bug on 8-bit chars.
Outputting a backspace isn't supposed to be destructive.. It isn't on
most terminals, nor on the standard bios output (vs. TERM_EMU mode)


42274 04-Jan-1999 msmith

Restore dependancy to build loader.help here


42268 03-Jan-1999 msmith

Reenable generation of the loader.help file


42207 31-Dec-1998 abial

Add back ability to make beeps when using new TERM_EMU.

Submitted by: W Gerald Hicks <wghicks@bellsouth.net>


42002 22-Dec-1998 abial

Add simple terminal emulator, compatible with cons25. Currently supported
capabilities are: AF, AB, cm, ho, me, cd. The code is hidden behind
-DTERM_EMU - should it cause any problems, you can remove this define
to get back the old behaviour.

You'll find some examples how to use it in src/share/examples/bootforth.

Reviewed by: jkh


41838 16-Dec-1998 msmith

Disable build/install of boot.help until we sort out how to construct it
in the makeworld environment.


41822 15-Dec-1998 msmith

Reformat help to improve subtopic display appearance, other minor
cleaning. The 'help' command in the loader should now be usable and
hopefully informative.


41821 15-Dec-1998 msmith

Build the composite help file from the generic and architecture-specific
help files, sorting topics and subtopics to allow maximum flexibility.


41587 07-Dec-1998 ache

unlocalize date
Submitted by: Cejka Rudolf <cejkar@dcse.fee.vutbr.cz>


41540 05-Dec-1998 rnordier

Revise some comments and labels.


41412 29-Nov-1998 rnordier

Drop EDD support detection, though retain configurable use of disk
packet interface. Add booteasy-style F5 support. Add no-update
option. Implement various space optimizations and consistency fixes.


41285 22-Nov-1998 rnordier

Drop use of BIOS int 0x14 services in favor of direct port I/O.

Feedback and testing: Adrian Filipi-Martin <adrian@ubergeeks.com>


41139 13-Nov-1998 msmith

Add a new variable $num_ide_disks which is used to offset the unit number
for SCSI disks when converting from BIOS unit numbers to da unit numbers.

Prompted by Kevin Street <street@iname.com>


41107 12-Nov-1998 jkh

bootforth seems to be working well enough for me and others to turn
on by default. If it causes trouble, it's very easy to switch off again.


41085 11-Nov-1998 rnordier

Revise error messages.


41013 08-Nov-1998 rnordier

Prevent boot.config being parsed more than once.


41010 08-Nov-1998 rnordier

Drop the familiar 'text=xxxx data=xxxx bss=xxxx ...' display while
loading. This eliminates noise when loading boot/loader; and when
loading a kernel, they generally flash by too fast to be
intelligible anyway.


41008 08-Nov-1998 rnordier

boot1: Eliminate EDD detection and optional use of disk packet
interface. Do some general consistency fixes and space optimizations.
Use of some freed-up space to defend against possible BIOS misfeatures.

boot2: Revise disk read interface to provide for boot1 changes. Free
up space for this.


40940 05-Nov-1998 rnordier

Make use of BIOS int 0x13 extensions configurable, and disabled
by default.


40884 04-Nov-1998 msmith

Turn off -g accidentally left in from testing.


40879 04-Nov-1998 jkh

Respect ${.OBJDIR} properly when looking for libficl.a


40877 04-Nov-1998 msmith

Add required parts for BootForth building (currently disabled and
untested). Only suitable for i386 at the moment, as we are missing
setjmp/longjmp on the Alpha.


40834 02-Nov-1998 msmith

Implement a simple LRU block cache. By default this is initialised to 16k,
and will bypass transfers for more than 8k. Blocks are invalidated after
2 seconds, so removable media should not confuse the cache.

The 8k threshold is a compromise; all UFS transfers performed by
libstand are 8k or less, so large file reads thrash the cache.
However many filesystem metadata operations are also performed using
8k blocks, so using a lower threshold gives poor performance.

Those of you with an eye for cache algorithms are welcome to tell me
how badly this one sucks; you can start with the 'bcachestats' command
which will print the contents of the cache and access statistics.


40833 02-Nov-1998 rnordier

Revise a few comments.


40807 01-Nov-1998 rnordier

Ignore, rather than emulate, an i386 'hlt' instruction (though for
most practical purposes, this should be indistinguishable from a
more strictly correct approach).

Feedback and testing: msmith


40775 31-Oct-1998 msmith

- Add a new command 'lsdev' to list devices which might be likely to host
filesystems.
- New 'help' command and data in the help.* files (not yet installed),
provides topic and subtopic help, indexes, etc.
- Don't crash if the user tries to set an invalid console. Be helpful
instead.
- Expand tabs (badly) on the i386 video console.
- Some minor cosmetic changes.


40753 30-Oct-1998 luoqi

Fix an uninitialized variable in the `dangerously dedicated disk' case.


40745 30-Oct-1998 msmith

Make the BTX loader much more quiet about what it's doing. This removes
most of the "what the (*^&%(*^ was that?" stuff that normally flies by.


40705 28-Oct-1998 msmith

Simplify the "is a character ready" test, so that we don't return a false
negative for keypresses with zero ascii values. This is in line with the
comconsole test, rather than being more ambitious.

Submitted by: rnordier


40675 27-Oct-1998 rnordier

Avoid interruptions while talking to keyboard controller.


40674 27-Oct-1998 rnordier

biosboot compatibility fix: change behavior of backspace in getstr().
Noticed by: abial

Optimize away a few bytes to make space for the above.


40620 23-Oct-1998 msmith

Clean the ${BASE}.sym file as well.


40619 23-Oct-1998 msmith

Remove a debugging copy of offsetof() that snuck in.


40618 23-Oct-1998 msmith

Enable the PCI BIOS PnP enumerator.


40617 23-Oct-1998 msmith

PnP enumerator using the PCI BIOS. This is needlessly complex due to the
lack of a simple "enumerate all PCI devices" function.


40601 22-Oct-1998 msmith

PnP BIOS enumerator; mostly useful for hunting PnP devices that are supported
by the system BIOS rather than supporting ISA PnP.


40600 22-Oct-1998 msmith

Add a dependancy on the BTX crt0 object
Add the biospnp handler to the pnp handler array
Drop some old debugging code


40599 22-Oct-1998 msmith

Add biospnp.c


40598 22-Oct-1998 msmith

Pop the return address off the stack before making a V86_CALLF call;
this allows us to implement what look like C function calls from user
space "directly" to v86 mode code. (Used for calling the PnP BIOS)


40556 21-Oct-1998 msmith

Bye-bye setdefs.


40555 21-Oct-1998 msmith

- Enable PnP and ISA PnP code.
- Use the ISA PnP enumerator.
- Use the new linker set code, throw out the gensetdefs stuff.
- Produce an intermediate loader image that has symbols stripped, to aid
- in debugging.
- Supply ISA port access functions required for ISA PnP


40554 21-Oct-1998 msmith

Don't depend on being part of the kernel tree. If we are, use the kernel's
<machine> includes rather than the system's.


40541 20-Oct-1998 rnordier

Make serial port, data format, and bps configurable.


40524 19-Oct-1998 rnordier

Make configurable (a) whether to use int 0x13 extensions; (b) timeout
value. Ignore failure to update mbr sector. Disable interrupts while
using extended registers. Default to F1 not F2.


40493 17-Oct-1998 rnordier

Set BINMODE to 444.


40477 17-Oct-1998 rnordier

Fix some glitches in the input routine:
Don't display a \b if not acting on it.
Don't process binary zero chars (which result from pressing function
keys, etc. on the PC).


40476 17-Oct-1998 rnordier

Having probed the keyboard, turn off the -P flag.


40474 17-Oct-1998 rnordier

Treat all options as toggles (ie. -c -c is the same no -c). Since
the boot.config settings are persistent, this seems to provide a
useful override capability, and should break only on broken
boot.config's.

Output a cosmetic newline if booting with no input.


40472 17-Oct-1998 rnordier

biosboot compatibility fix:
If we have a boot.config command, display it.


40471 17-Oct-1998 rnordier

biosboot compatibility fix:
Read boot.help before parsing boot.config. We were parsing
boot.config first, which could result in boot.help being read
from a different location (or not found), which would probably
just cause surprise, without being useful.


40416 15-Oct-1998 rnordier

Fix path to sio.s


40404 15-Oct-1998 rnordier

Add serial, dual, and probe-keyboard support.


40393 15-Oct-1998 peter

Get the last used address via a more conservative method, don't depend
on the module chain being in increasing address order.


40358 14-Oct-1998 rnordier

Activate boot2.


40338 14-Oct-1998 peter

Try and get the sys/* and machine/* includes via relative paths. This
saves having to do a 'make includes' after touching any header file for
the boot code.


40336 14-Oct-1998 peter

Align to sizeof(long) rather than sizeof(int32_t). It needs to be
long because this code is shared with the alpha. I hope the alpha can
read 32 bit ints at 32 bit alignment (vs. 64 bit alignment).


40330 14-Oct-1998 rnordier

Fix btx include path.


40326 14-Oct-1998 rnordier

Include <bsd.prog.mk>. Add install target (to /boot for now).


40325 13-Oct-1998 rnordier

Fix flow of control after directory listing; enable EDD support;
cosmetics.


40323 13-Oct-1998 rnordier

Make v86.ctl default more explicit; simplify read error-handling;
twiddle.


40320 13-Oct-1998 rnordier

Adjust NDEV value.
Optimize reading of system time.


40314 13-Oct-1998 rnordier

Change to a 15-sector boot2.
Refine slice-handling.


40308 13-Oct-1998 rnordier

Don't use an absolute path to objcopy.
Noticed by: Scott Mace <smace@intt.org>


40307 13-Oct-1998 rnordier

Improve drive recognition and handling.


40270 12-Oct-1998 rnordier

This commit was generated by cvs2svn to compensate for changes in r40269,
which included commits to RCS files with non-trunk default branches.


40269 12-Oct-1998 rnordier

New boot blocks: support for /boot/loader; a.out & ELF; cyl > 1023;
multiple 0xa5 slices; etc.


40245 12-Oct-1998 rnordier

Drop .MAKEFLAGS: hack.


40244 12-Oct-1998 rnordier

Do without head and tail: they're pretty unnecessary here anyway.


40243 12-Oct-1998 rnordier

Use rather than for linking. This allows the new rather
than stale version of libstand.a to be found.

After this change, the new boot code is apparently building correctly
in a make world.


40218 11-Oct-1998 rnordier

Override for ELF.


40217 11-Oct-1998 rnordier

Override for ELF. Override .s.o suffix rule.


40216 11-Oct-1998 peter

Fix a warning that's been bugging me for ages.


40212 11-Oct-1998 peter

Only call vidc_init() once (unless forced).
Cosmetic change to the init-time character eater (like, make it increment
the index counter - if there's a problem, it would sit there in an infinite
loop instead of only running 10 times).


40211 11-Oct-1998 peter

Fix comconsole mode. The int 0x14 read and status commands were reversed.
Also, make sure we set %dx each time around otherwise the commands
suddenly start trying to work on things like com92 instead of com1.
Make sure comc_init() is only run once.
Cosmetic change to init-time character eater.


40210 11-Oct-1998 peter

Warn that one of the DEBUG statements has a v86 recursion bug.


40209 11-Oct-1998 peter

Fix comment to match code


40182 10-Oct-1998 rnordier

Fix a typo.
Output another newline before invoking bootstrap.


40149 09-Oct-1998 rnordier

Turn off the new /sys/boot stuff (except boot0) unless OBJFORMAT
is elf. (The BTX client must be ELF, though it is packaged as a.out
for compatibility.)


40146 09-Oct-1998 peter

Attempt to at least align MODINFO_* blocks. IMHO, decoding this stuff
should be MD code since one day we'll have to recover pages from deleted
preload data. MI code can't be expected to know how to deal with pmap
internals, assuming it gets done via pmap that is. :-)


40145 09-Oct-1998 peter

Turn symbol table info passing back on, although it's probably not
particularly useful in this form. KLD can deal with it much better.
setenv kernelname moved earlier.


40144 09-Oct-1998 peter

Remove kernelname setenv, the common code does it.
Use the metadata for symtab pointers, mainly to keep it common with
elf_freebsd.c.


40124 09-Oct-1998 rnordier

Get this building as a.out or ELF.

With thanks to: jdp


40107 09-Oct-1998 msmith

Remove some debugging code.
Do a much better job of DWIM with partial device specifications.
Fix the module metadata build process, which was completely broken.
Use a larger read buffer when copying large objects in; this
improves performance marginally and will avoid flushning any small caches
we might choose to implement.


40034 07-Oct-1998 peter

Fix that pesky boot aguments parsing bug. (I think :-)


40032 07-Oct-1998 msmith

Request the flags back when checking for keyboard status.
Submitted by: rnordier


40017 07-Oct-1998 msmith

Enable the DOS filesystem. NOTE: you will have to rebuild libstand in
order to be able to build again.


40016 07-Oct-1998 msmith

- Drain the keyboard buffer when initialising.
- Be pedantic about the return from int 16 fn 01.


39989 06-Oct-1998 msmith

bootinfo.c
Strip any device name information from the kernel name
before passing it in.

biosdisk.c
Be more strict about matching device names to slice entries.
Only allow unsliced syntax on unsliced disks.


39988 06-Oct-1998 rnordier

Fix for "get base memory" bug found and mostly fixed by Mike.


39987 06-Oct-1998 msmith

The BIOS memory size is only a word. Some BIOSsen have garbage in the other
16 bits we were reading here, causing loss of arguments.


39986 06-Oct-1998 msmith

Build boot0 as well.


39980 05-Oct-1998 rnordier

Install in /boot.


39974 05-Oct-1998 rnordier

This commit was generated by cvs2svn to compensate for changes in r39973,
which included commits to RCS files with non-trunk default branches.


39962 04-Oct-1998 rnordier

Adjust setting of argument pointer for BTX 0.87.


39961 04-Oct-1998 rnordier

Allocate space for storing of arguments at the end of conventional
memory.


39960 04-Oct-1998 msmith

Don't include ELF symbol information yet - it causes the ELF DDB to
explode.


39944 04-Oct-1998 msmith

Improve the handling of the initial bootdev value from the previous loader.
Remove some unused code.


39943 04-Oct-1998 msmith

biosdisk.c
Allocate space for, and copy, NDOSPART slice entries from the
MBR, not just one. Add some extra debugging while we're at it.

elf_freebsd.c
Initialise the symbol table start/end pointers in case we don't
have them.


39931 03-Oct-1998 rnordier

Missing newline in heap command display.
Noticed by: jkh


39930 03-Oct-1998 rnordier

For system calls, reboot without prompting; for exceptions, display
message and await reset.


39921 03-Oct-1998 rnordier

Map all BTX system pages readable at ring 3.
This resolves the firmware problem first raised in connection
with PR 8105, although unrelated.


39919 03-Oct-1998 rnordier

bootinfo bi_vesa no longer exists.


39902 02-Oct-1998 msmith

Consolidate the bootinfo-loading code, greatly simplifying the _exec
functions.


39901 02-Oct-1998 msmith

Fix an egregious precedence bug.


39897 02-Oct-1998 msmith

Set $currdev according to our best guess at the BIOS device that the previous
bootstrap loaded us from.


39896 02-Oct-1998 msmith

aout_freebsd.c
Use bd_getdev() to work out a dev_t for the root device.
Allow $rootdev to override $currdev as the root device.

biosdisk.c
Save the slice table and disklabel when opening a disk.
Add bd_getdev(), which attempts to return a dev_t corresponding
to a given device. Cases which it still doesn't get right:
- The inevitable da-when-wd-also-exists
- Disks with no slice table (the slice number is not set correctly)
The first is difficult to get right, the second will be
fixed in an upcoming commit.

comconsole.c
vidconsole.c
getchar() should return an 8-bit value; some BIOSsen pack extra
information in %eax.

libi386.h
Remove some stale prototypes, add new ones.


39895 02-Oct-1998 msmith

Mark exit() as __attribute__((__noreturn__))


39887 02-Oct-1998 peter

First shot at loading elf symbols. Things are a bit strange because
of the ..umm.. "wierd" way binutils lays out the file. The section
headers are nearly at the end of the file and this is a problem when
loading from a .gz file which can't seek backwards (or has a limited
reverse seek, ~2K from memory).

This is intended to be compatable with the ddb/db_elf.c code and the
alpha/libalpha/elf_freebsd.c layout. I've studied these (which are NetBSD
derived) but did it a bit differently. Naturally the process is similar
since it's supposed to end up with the same result.


39857 01-Oct-1998 jkh

Override STRIP so installation doesn't try to strip the loader.


39851 30-Sep-1998 peter

Make 'make install' do something that might be useful.


39850 30-Sep-1998 peter

Stop libi386.a from being installed..


39834 30-Sep-1998 peter

Turn on i386-elf


39833 30-Sep-1998 peter

i386 ELF loader startup backend. On an ELF kernel booted with the 3-stage
bootblocks, the kernel shows up as the primary module:

[3:24am]~-100# kldstat
Id Refs Address Size Name
1 1 0xf0100000 ff00000 /kernel
^^^^ oops.. :-)

Based heavily on aout_freebsd.c. Hmm.. There's so much in common that
these could probably be combined and just check the metadata to see which
format it is.


39832 30-Sep-1998 peter

Save booted kernel name. Cosmetic cleanups.


39831 30-Sep-1998 peter

Fix typos.. The vector for "int 0x12" (get base mem) is not written in
hex as "0x1a". :-)
Fix a comment about the extended memory checks, that's int 0x15.


39756 29-Sep-1998 peter

The bootinfo struct was getting clobbered or not passed through correctly.
Presumably VTOP doesn't work for static objects.
The easiest way to get it working was to reserve some space after the
environment strings and copy the bootinfo struct there.
Also, set RB_BOOTINFO, it's needed.

I got the code to load and run an unmolested kernel OK for the first time
with this system a few minutes ago - at last!. I did have to stop it
looking at the floppy though as BTX was trapping a mode 14 fault when
it look for /boot/boot.conf when no disk was in the drive. (I'm booting
from a scsi disk (bios disk 0x80)).

Now to teach it about ELF and modules :-)


39733 28-Sep-1998 peter

Only bcopy the correct amount of data from the buffer in case it is ever
in an overrun situation.


39731 28-Sep-1998 peter

Reactivate the a.out kernel loader code.


39730 28-Sep-1998 peter

Missing return value that was kinda important.


39729 28-Sep-1998 peter

Argh, I don't believe how much time I wasted looking for this...
Bytes of extended memory = (extkb * 1024), not (extkb + 1024)


39725 28-Sep-1998 peter

The comconsole mode is accessed as 'comconsole' not 'com'.


39724 28-Sep-1998 peter

MBR magic is 0x55aa not 0xffaa.


39723 28-Sep-1998 peter

Precedence bug (?) causing probe problems.


39673 26-Sep-1998 dfr

* Add old UFS compatibility code to alpha/boot1.
* Fix a raft of warnings, printf and otherwise.
* Allocate the correct amount in mod_searchmodule to prevent an overflow.
* Fix the makefiles so they work outside my home directory (oops).


39664 26-Sep-1998 msmith

Recover the arguments passed in from the previous load stage, use them to set
the default console.
Print malloc stats from the new libstand allocator.


39662 26-Sep-1998 msmith

The BIOS can't perform a floppy operation where the destination crosses
a physical 64k boundary. Allocate a bounce buffer for such a transaction.


39646 25-Sep-1998 peter

Make these compile when there is an obj dir.


39474 19-Sep-1998 msmith

Make libstand movable.

This completes the basic work required to make the loader work with BTX. We
now have a third-stage bootstrap shared by the i386 and Alpha.


39473 19-Sep-1998 msmith

- Improve debugging code.
- Make the "what do we do with a drunken disklabel" if-then-else-regardless
tangle easier to read.
- Don't count on the v86 structure being preserved between loop iterations,
as it may be trampled eg. by the DEBUG call.


39450 18-Sep-1998 msmith

Enable the biosdisk driver, duplicate -lstand as it both calls and is called
by the i386 platform library.


39449 18-Sep-1998 msmith

Synch with development version. Compiles and opens but doesn't work yet.


39447 18-Sep-1998 msmith

We lost all the files in crt/, so define the BIOS sector size here instead.


39441 17-Sep-1998 msmith

Initial integration of the i386 bootloader and BTX.

- Discard large amounts of BIOS-related code in favour of the more compact
BTX vm86 interface.
- Build the loader module as ELF, although the resulting object is a.out,
make gensetdefs 32/64-bit sensitive and use a single copy of it.
- Throw away installboot, as it's no longer required.
- Use direct bcopy operations in the i386_copy module, as BTX
maps the first 16M of memory. Check operations against the
detected size of actual memory.


39274 15-Sep-1998 rnordier

Add exec syscall.


39178 14-Sep-1998 msmith

Resynch with working sources before BTX integration.

- Use format-independant module allocator.
- Conditionalise ISA PnP support.
- Simplify PnP enumerator interface.
- Improve module/object searching.
- Add missing depend/install targets in BTX makefiles.
- Pass the kernel environment and module data in extended bootinfo fields.
- Add a pointer to the end of the kernel + modules in bootinfo.
- Fix parsing of old-style kernel arguments.


39165 14-Sep-1998 rnordier

Add BTX startup/interface code.


39125 13-Sep-1998 rnordier

Enable client entry point support.


39091 12-Sep-1998 rnordier

Add btxldr, a BTX loader for ELF clients.


39089 12-Sep-1998 rnordier

This commit was generated by cvs2svn to compensate for changes in r39088,
which included commits to RCS files with non-trunk default branches.


39088 12-Sep-1998 rnordier

BTX (aka the boot extender) is an i386 kernel that hosts 32-bit
bootstrap programs, and provides page-level protection, hardware
interrupt reflection, a virtual-8086 mode interface to BIOS, etc.


38764 03-Sep-1998 msmith

Bootstrap updates.

- Move some startup code from MD to MI sections
- Add a 'copyout' and some copyout-related functions. These will be
obsoleted when BTX is available for the 386 and the kernel load
area becomes directly addressable.
- Add the ability load an arbitrary file as a module, associating
and arbitrary type string with it. This can be used eg. for loading
splash-screen images etc.
- Add KLD module dependancy infrastructure. We know how to look for
dependancies inside KLD modules, how to resolve these dependancies
and what to do if things go wrong. Only works for a.out at the
moment, due to lack of an MI ELF loader. Attach KLD module information
to loaded modules as metadata, but don't pass it to the kernel (it
can find it itself).
- Load a.out KLD modules on a page boundary. Only pad the a.out BSS
for the kernel, as it may want to throw symbols away. (We might want
to do this for KLD modules too.)
- Allow commands to be hidden from the '?' display, to avoid cluttering
it with things like 'echo'. Add 'echo'.
- Bring the 'prompt' command into line with the parser syntax.
- Fix the verbose 'ls'; it was using an uninitialised stack variable.
- Add a '-v' flag to 'lsmod' to have it display module metadata as well
(not terribly useful for the average user)
- Support a 'module searchpath' for required modules.
- The bootstrap file on i386 is now called 'loader' to permit the
/boot directory to use that name.
- Discard the old i386 pread() function, as it's replaced by
arch_readin()


38712 31-Aug-1998 msmith

Bootloader update.

- Implement a new copyin/readin interface for loading modules.
This allows the module loaders to become MI, reducing code duplication.
- Simplify the search for an image activator for the loaded kernel.
- Use the common module management code for all module metadata.
- Add an 'unload' command that throws everything away.
- Move the a.out module loader to MI code, add support for a.out
kld modules.

Submitted by: Alpha changes fixed by Doug Rabson <dfr@freebsd.org>


38466 21-Aug-1998 msmith

This commit was generated by cvs2svn to compensate for changes in r38465,
which included commits to RCS files with non-trunk default branches.


38465 21-Aug-1998 msmith

This is the new unified bootstrap, sometimes known previously as the
'three-stage' bootstrap.
There are a number of caveats with the code in its current state:
- The i386 bootstrap only supports booting from a floppy.
- The kernel and kld do not yet know how to deal with the extended
information and module summary passed in.
- PnP-based autodetection and demand loading of modules is not implemented.
- i386 ELF kernel loading is not ready yet.
- The i386 bootstrap is loaded via an ugly blockmap.

On the alpha, both net- and disk-booting (SRM console machines only) is
supported. No blockmaps are used by this code.

Obtained from: Parts from the NetBSD/i386 standalone bootstrap.