Home | History | Annotate | only in /src/usr.sbin/installboot
History log of /src/usr.sbin/installboot
RevisionDateAuthorComments
 1.61 05-Oct-2025  thorpej Add riscv.
 1.60 22-May-2024  tsutsui Remove no-op emips stuff.

It seems blindly copied and modified from pmax, but emips bootloader
can be specified by "Ml40x_2ace.plx" config file on the Giano simulator.
(not sure what on the real Xilinx ML401 board, but maybe hardcoded)
 1.59 19-May-2024  tsutsui Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.
 1.58 03-Jun-2023  lukem adapt to ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}

Simplify CWARNFLAGS to use ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
which works for both clang and gcc, and remove compiler-specific
equivalents.
 1.57 03-Jun-2023  lukem bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER

Provide a single variable
CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
CLANG_NO_ADDR_OF_PACKED_MEMBER
CC_NO_ADDR_OF_PACKED_MEMBER
GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.56 06-Sep-2020  mrg branches: 1.56.6;
add support for new GCC 9 warnings that may be too much to fix
right now. new address-of-packed-member and format-overflow
warnings have new GCC_NO_ADDR_OF_PACKED_MEMBER amd
GCC_NO_FORMAT_OVERFLOW variables to remove these warnings.

apply to a bunch of the tree. mostly, these are real bugs that
should be fixed, but in many cases, only by removing the 'packed'
attribute from some structure that doesn't really need it. (i
looked at many different ones, and while perhaps 60-80% were
already properly aligned, it wasn't clear to me that the uses
were always coming from sane data vs network alignment, so it
doesn't seem safe to remove packed without careful research for
each affect struct.) clang already warned (and was not erroring)
for many of these cases, but gcc picked up dozens more.
 1.55 21-Jun-2020  thorpej Add evbmips support for u-boot handling.
 1.54 15-Aug-2019  martin Never trust a compiler that predefines i386 as 1 - do the symbol name
concatenation at the make level instead.
 1.53 15-Aug-2019  martin Replace black voodo linker magic (sometimes failing) with some
makefile + macro magic to trim the list of available machines on size
restricted install media.
 1.52 07-May-2019  thorpej branches: 1.52.2;
Add installboot(8) support for evbarm (and, in the future, other evb*)
boards that use u-boot. A known board database lists boards and their
respective u-boot packages. u-boot packages are discovered at run-time
(in /usr/pkg/share/u-boot, by default). These packages contain board
database overlays that describe u-boot installation procedure that's
specific for that board.

Support this as a native tool and as a host tool. The native tool
will attempt to determine the running board type using OpenFirmware
calls. Host tool and native tool alike may also specify a board type
directly using the "-o board=xxx option" or have installboot(8) determine
the board type from a device tree blob using "-o dtb=/path/to/board.dtb".
A "-o media=xxx" option is provided for boards that have different u-boot
binaries and/or installation procedures for different media types (e.g.
SDMMC, eMMC, or USB).

This is trivial to extend to other evb* platforms that use u-boot, even if
they don't use FDT for autoconfiguration.
 1.51 11-Jan-2017  joerg branches: 1.51.6; 1.51.14;
Disable a couple of warnings until further investigation.
 1.50 06-Jun-2015  joerg branches: 1.50.2;
Linking against libutil is not appropiate for tools.
 1.49 05-Jun-2015  mlelstv Support wedge names.
 1.48 24-Feb-2014  skrll branches: 1.48.4;
Rename NetBSD/hp700 to NetBSD/hppa.

Unfortunately our VCS isn't very helpful here.
 1.47 10-Aug-2012  joerg branches: 1.47.2;
Remove many HAVE_GCC || HAVE_PCC conditionals as the options also apply
to Clang. Add a few cases of HAVE_LLVM for -fno-strict-aliasing.
 1.46 14-Aug-2011  christos branches: 1.46.2;
fix various gcc-4.5 warnings
 1.45 22-Jun-2011  mrg apply some -Wno-error and/or -fno-strict-aliasing.


all of this should be looked at closer, but some of them are not
very trivial.
 1.44 20-Jun-2011  mrg remove most of the remaining HAVE_GCC tests that are always true in
the modern world.
 1.43 26-Jan-2011  pooka branches: 1.43.2;
Add support for the Extensible MIPS ("eMIPS") platform. The
NetBSD/emips port runs on Xilinx and Beecube FPGA systems and the
Giano system simulator.

eMIPS is a platform developed at Microsoft Research for researching
reconfigurable computing. eMIPS allows dynamic loading and scheduling
of application-specific circuits for the purpose of accelerating
computations based on the current workload.

NetBSD eMIPS support for NetBSD 4.x was written at Microsoft Research
by Alessandro Forin and Neil Pittman. Microsoft Corporation has
donated full copyright to The NetBSD Foundation.

Platform support for eMIPS is the first part of Microsoft's
contribution. The second part includes the hardware accelerator
framework and will be proposed on tech-kern soon.
 1.42 22-Apr-2009  lukem branches: 1.42.2;
Enable WARNS=4 by default, except for:
cpuctl dumplfs hprop ipf iprop-log kadmin kcm kdc kdigest
kimpersonate kstash ktutil makefs ndbootd ntp pppd quot
racoon racoonctl rtadvd sntp sup tcpdchk tcpdmatch tcpdump
traceroute traceroute6 user veriexecgen wsmoused zic
(Mostly third-party applications)
 1.41 05-Apr-2009  lukem WARNS=4
 1.40 29-Aug-2008  gmcgarry branches: 1.40.6;
Wrap compiler-specific flags with HAVE_GCC and HAVE_PCC as necessary. Add a few flags for PCC.
 1.39 09-Feb-2008  mrg branches: 1.39.6;
make all sun2 use -O0 and move most of the hacks out into just 3 files.
 1.38 02-Feb-2008  tsutsui Add a findstage2 function (which returns block numbers where
the secondary boot is stored to embed them into the primary bootxx)
for ext2fs.

Currently disabled because there is no primary boot block
which supports ext2fs, but it might help someone in some day.
 1.37 01-Sep-2006  uwe branches: 1.37.8;
NetBSD/landisk support.
 1.36 12-May-2006  mrg don't do the -Wno-pointer-sign dance for host programs.
 1.35 11-May-2006  mrg sprinkle some -fno-strict-aliasing and -Wno-pointer-sign with GCC4.
 1.34 18-Feb-2006  dsl Changes to allow support for a reduced set of architectures.
In particular if SMALLPROG is set (eg for installation crunched ramdiskbin)
only build for the current MACHINE.
 1.33 29-Dec-2005  tsutsui Add ews4800mips support.
 1.32 12-Jun-2005  dyoung Build hp300 support into installboot(8).
 1.31 14-May-2005  chs add hp700 support.
 1.30 14-Nov-2003  lukem Disable hp300 support (again).
This code is not to be reenabled again until it is fixed to my satisfaction
(as a member of core and the person who ends up dealing with most of
the host tool build bugs)
 1.29 13-Nov-2003  dsl roundup() write of hp300 boot code to a multiplr of the disk sector size.
and re-instate the hp300 code - seems to work.
 1.28 10-Nov-2003  fvdl Disable the hp300 for now.
 1.27 08-Nov-2003  dsl First cut of hp300 installboot, seems to DTRT on i386.
Maybe this code ought to know how to add a file to the LIF filesystem.
 1.26 28-Oct-2003  mrg XXX: build mdsetimage.c / installboot/ffs.c with -O0 on sun2 as GCC3
barfs on these for now.
 1.25 27-Oct-2003  cl add next68k support to installboot
 1.24 18-May-2003  lukem Now that <bsd.prog.mk> DTRT if HOSTPROG is defined (i.e, it is a no-op),
there's no need to special-case .include-ing it.
 1.23 09-Apr-2003  dsl Add support for i386 boot code - for new bootxx stuff
 1.22 15-Jan-2003  mhitch Add support for amiga.
 1.21 02-Jun-2002  isaki Add x68k stuff.
 1.20 20-May-2002  lukem - use uint8_t instead of char for boot block blobs
- bbinfo_params:
- replace "int littleendian" with "bbinfo_endian endian"
- add comments
- shared_bbinfo_clearboot():
- add callback method to shared_bbinfo_clearboot()
- don't clear from 0..headeroffset; use a callback to do that
- add news68k and newsmips support.
From Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, with a rework by me to
take advantage of the new shared_bbinfo_clearboot() callback.
(XXX: untested yet)
 1.19 15-May-2002  lukem bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
and sun68k_bbinfo (296 byte, with 64 block entries)
into shared_bbinfo (512 bytes, with 118 block entries),
which will be also shared by future bbinfo-using platforms
(including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
perform the majority of the work for bbinfo-using back-ends
(rather than replicating that across multiple back-ends).
 1.18 06-May-2002  pk Add sparc module.
 1.17 26-Apr-2002  lukem s/_SRC_TOP_/NETBSDSRCDIR/
 1.16 24-Apr-2002  lukem convert from "sun68k_bbinfo.h" to <dev/sun/sun_boot.h>
 1.15 23-Apr-2002  lukem after consideration, don't bother with compat symlinks, as it might
cause end-user confusion if the syntax changed between
/usr/mdec/installboot and /usr/sbin/installboot
 1.14 22-Apr-2002  bjh21 include <bsd.own.mk> for _SRC_TOP_
 1.13 22-Apr-2002  fredette Install the compatability symlink for sun2.
In the sun68k handler, add some sync()s to make sure we
get a coherent picture of the filesystem. Maybe should
be in the MI filesystem code?
 1.12 22-Apr-2002  lukem Add sun2 backend from Matthew Fredette.
(Implemented with "sun68k.c" as it should eventually support "sun3" as well.)
 1.11 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.10 11-Apr-2002  lukem - add no_parseopt(), no_setboot() and no_clearboot() methods for back-ends
to use when they don't support a particular method
- don't automatically generate machines.c anymore
- add entries for i386 (temporarily unsupported) and shark
(permanently unsupported)
 1.9 06-Apr-2002  bjh21 Install the compat symlink into ${DESTDIR}.
 1.8 06-Apr-2002  bjh21 Don't install the compat symlink if this is a HOSTPROG.
 1.7 04-Apr-2002  lukem Add framework for adding compat symlink from /usr/mdec/installboot ->
/usr/sbin/installboot.
Enable pmax.
 1.6 04-Apr-2002  lukem Add sparc64 back-end, contributed by Matthew Green.
 1.5 03-Apr-2002  lukem Add support for alpha, based on {vax,pmax}.c and
sys/arch/alpha/stand/installboot.
XXX: not fully tested yet.
 1.4 03-Apr-2002  lukem Migrate MD files to arch/ subdir. Suggested by Hubert Feyrer.
 1.3 03-Apr-2002  lukem Add pmax installboot back-end; from vax.c and arch/pmax/stand/installboot/*.
XXX: not tested yet.
 1.2 03-Apr-2002  lukem replace machines.c rebuild with "regenmachines", which needs to be run
manually
 1.1 03-Apr-2002  lukem Machine independent "unified" installboot(8).
Currently only supports vax, with more MD back-ends to be added RSN.
 1.37.8.1 23-Mar-2008  matt sync with HEAD
 1.39.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.40.6.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.42.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.43.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.46.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.46.2.1 30-Oct-2012  yamt sync with head
 1.47.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.4.1 16-Jul-2015  snj Pull up following revision(s) (requested by mlelstv in ticket #844):
usr.sbin/installboot/Makefile: revisions 1.49, 1.50
usr.sbin/installboot/installboot.c: revisions 1.37, 1.38
usr.sbin/installboot/arch/amiga.c: revision 1.9
Support wedge names.
--
Can't use getfsspecname (and thus wedge names) while building tools.
--
Linking against libutil is not appropiate for tools.
--
Compute bootloader checksum correctly also on little endian systems.
 1.50.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.51.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.51.14.1 10-Jun-2019  christos Sync with HEAD
 1.51.6.1 07-May-2021  martin Pull up following revision(s) (requested by mrg in ticket #1678):

bin/pax/options.c: revision 1.119
usr.bin/config/scan.l: revision 1.32
usr.bin/make/main.c: revision 1.274
bin/pax/extern.h: revision 1.60
usr.bin/config/defs.h: revision 1.106
usr.bin/make/make.h: revision 1.105
sbin/newfs_udf/udf_create.c: revision 1.27 (patch)
sbin/newfs_udf/newfs_udf.h: revision 1.7 (patch)
usr.bin/config/main.c: revision 1.100
usr.sbin/installboot/Makefile: revisions 1.53,1.54 (patch)
usr.sbin/installboot/installboot.h: revision 1.41 (patch)
usr.sbin/installboot/machines.c: revisisons 1.41,1.42 (patch)

Avoid depending on common symbols.
 1.52.2.1 21-Aug-2019  msaitoh Pull up following revision(s) (requested by martin in ticket #80):
usr.sbin/installboot/Makefile: revision 1.53
usr.sbin/installboot/Makefile: revision 1.54
usr.sbin/installboot/machines.c: revision 1.41
usr.sbin/installboot/machines.c: revision 1.42
Replace black voodo linker magic (sometimes failing) with some
makefile + macro magic to trim the list of available machines on size
restricted install media.
Never trust a compiler that predefines i386 as 1 - do the symbol name
concatenation at the make level instead.
 1.56.6.1 22-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #722):

sys/fs/cd9660/cd9660_util.c: revision 1.16
sys/arch/hp300/stand/common/clock.c: revision 1.14
sys/arch/hp300/stand/common/scsireg.h: revision 1.5
sys/arch/hp300/stand/common/scsireg.h: revision 1.6
sys/arch/hp300/stand/Makefile.buildboot: revision 1.38
sys/arch/hp300/include/bus.h: revision 1.23
sys/arch/hp300/stand/Makefile.buildboot: revision 1.39
sys/arch/hp300/stand/common/sd.c: revision 1.12
sys/arch/hp300/stand/common/prf.c: revision 1.6
sys/arch/hp300/stand/common/sd.c: revision 1.13
usr.sbin/installboot/installboot.8: revision 1.106
usr.sbin/installboot/Makefile: revision 1.59
sys/arch/hp300/stand/common/devopen.c: revision 1.14
usr.sbin/installboot/installboot.8: revision 1.107
sys/arch/hp300/stand/common/ite_dumb.c: revision 1.2
sys/arch/hp300/stand/common/devopen.c: revision 1.15
usr.sbin/installboot/installboot.8: revision 1.108
sys/fs/cd9660/cd9660_extern.h: revision 1.29
usr.sbin/installboot/installboot.8: revision 1.109
tools/Makefile.nbincludes: revision 1.11 (patch)
sys/arch/hp300/dev/rboxreg.h: revision 1.3
sys/arch/hp300/stand/common/scsivar.h: revision 1.5
sys/arch/hp300/dev/dnkbd.c: revision 1.14
sys/arch/hp300/hp300/trap.c: revision 1.156
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.12
sys/arch/hp300/dev/frodoreg.h: revision 1.6
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.13
sys/arch/hp300/stand/common/ite_sti.c: revision 1.2
sys/arch/hp300/stand/common/hil.c: revision 1.15
usr.sbin/installboot/arch/hp300.c: revision 1.18
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.14
sys/arch/hp300/dev/rbox.c: revision 1.4
usr.sbin/installboot/arch/hp300.c: revision 1.19
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.15
sys/sys/bootblock.h: revision 1.59
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.16
usr.sbin/installboot/installboot.h: revision 1.44
sys/arch/hp300/stand/mkboot/volhdr.h: file removal
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.17
sys/arch/hp300/dev/hpib.c: revision 1.45
usr.sbin/installboot/installboot.h: revision 1.45
usr.sbin/installboot/cd9660.c: revision 1.1
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.18
sys/arch/hp300/dev/topcatreg.h: revision 1.3
usr.sbin/installboot/cd9660.c: revision 1.2
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.19
sys/arch/hp300/stand/inst/inst.c: revision 1.25
sys/arch/hp300/stand/uboot/Makefile: revision 1.12
sys/arch/hp300/dev/dvbox.c: revision 1.4
sys/arch/hp300/dev/dma.c: revision 1.45
sys/arch/hp300/stand/uboot/Makefile: revision 1.13
sys/arch/hp300/stand/common/rd.c: revision 1.16
sys/arch/hp300/stand/inst/Makefile: revision 1.12
distrib/hp300/cdroms/installcd/Makefile: revision 1.4
sys/arch/hp300/stand/mkboot/volhdr.h: revision 1.6
sys/arch/hp300/stand/common/machdep.c: revision 1.16
usr.sbin/installboot/fstypes.c: revision 1.14
sys/arch/hp300/hp300/machdep.c: revision 1.238
sys/arch/hp300/include/cpu.h: revision 1.73
sys/arch/hp300/dev/diofbreg.h: revision 1.4
sys/arch/hp300/stand/common/scsi.c: revision 1.12
sys/arch/hp300/stand/common/netio.c: revision 1.19
sys/arch/hp300/stand/common/scsi.c: revision 1.13
sys/arch/hp300/dev/sti_sgc.c: revision 1.8
sys/arch/hp300/dev/rtc.c: revision 1.22
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.20
sys/arch/hp300/stand/common/conf.h: revision 1.4
sys/arch/hp300/hp300/autoconf.c: revision 1.111
sys/arch/hp300/stand/common/conf.c: revision 1.15
sys/arch/hp300/stand/mkboot/Makefile: revision 1.12
sys/arch/hp300/stand/mkboot/Makefile: revision 1.13
sys/arch/hp300/hp300/autoconf.c: revision 1.114
sys/arch/hp300/dev/dcmreg.h: revision 1.11
sys/arch/hp300/dev/diofbvar.h: revision 1.4
sys/arch/hp300/dev/dcm.c: revision 1.91
sys/fs/cd9660/cd9660_util.c: revision 1.15
sys/arch/hp300/dev/mcclock_frodo.c: revision 1.2

TAB/space cleanup.

installboot(8): formatting improvements

Use Ar foo instead of <foo>; this is mdoc.

Other formatting tweaks.
installboot(8): fix up markup

Don't overuse .Sy - when everything is highlighted, nothing is. Use
.Ic for options &c to get correct PostScript output (both are bold in
plain text).

Use Aq Ar inside .Pa, as both Pa and Ar are rendered as underscored
text in plain text output, and the distinction is lost.

Don't set examples in bold, but give them .Pp space around - they are
much easier to read this way.

Use consistent -width in FILES.
document how to use installboot on netbsd/vax.

PR/57909: Jan-Benedict Glaw: Don't include (build) timestamp when doing a
reproducible build
fix usage string, improve error handling.
add missing chunk for repro-build. fix gcc warnings.
avoid stringop truncation, fix copyright string to prevent assembler warnings.

Fix build as a tool (Jan-Benedict Glaw)

Fix integer overflow of strtol(3) for "loadpoint" address on ILP32 hosts.

This strtol(3) was introduced in rev 1.12 for PR/57909 after netbsd-10,
but it returns LONG_MAX (0x7FFFFFFF) for 0xFFF00000 on ILP32 hosts and
the wrong loadpoint causes "NOT ENOUGH MEMORY" error by the BOOTROMs
on loading uboot.lif on (at least) my 9000/360 and 9000/425t.

Misc cosmetic changes for mostly readability.
- KNF and add some newlines per blocks
- define and use proper bintobcd() macro
- make local functions and variables static

The same uboot.lif binaries are generated.

Rename ${PROGAOUT} -> ${PROGELF} to reflect reality.
Use proper signedness for the LIF file system data structures.

Ancient 4.3BSD used short and int for location, file size, file type,
and addresses etc. but all of them should be unsigned.

Also rename several variables and add comments for readability.
The LIF file system info can be found in "The HPDir Project" page:
https://www.hp9845.net/9845/projects/hpdir/
The same uboot.lif binaries are generated.

Add a preliminary CD boot support to uboot for preparation of PR/54455.
Briefly tested on mame, but not enalbed yet.

Recognize SCSI CD-ROM devices as a booted device properly.

Necessary for PR port-hp300/54455, to boot an md root root RAMDISK

kernel from CD-ROM without "WARNING: can't find match for bootdev:"
prompt.

Sync with src/sys/arch/hp300/stand/mkboot/volhdr.h rev 1.6.
https://mail-index.netbsd.org/source-changes/2024/05/07/msg151195.html

Use proper signedness for the LIF file system data structures.
mkboot should use this MI <sys/bootblock.h> and volhdr.h should
be removed soon.

Use MI <sys/bootblock.h> to refer LIF filesystem structures.
This should have been done when LIF definitions were initially added
to <sys/bootblock.h> for MI installboot(8).

Enable SUPPORT_CD on uboot.

Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.

Install cd9660 related system headers for tools installboot(8) builds.

Reorder function prototypes per source files.

Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.

Put a RAMDISK kernel and SYS_UBOOT into hp300 installcd to make it bootable.

This should finally close PR/54455.

Fix tools build errors on Cygwin.

Appease warnings on building tools/installboot on Cygwin.
 1.14 05-Apr-2009  lukem fix sign-compare issues
 1.13 09-May-2008  tsutsui branches: 1.13.6;
If writing the primary boot fails with EROFS, use DIOCWLABEL ioctl
then try again because some ports have to overwrite LABELSECTOR
which might be protected by bounds_check_with_label(9) on putting
primaty bootxx.
 1.12 28-Apr-2008  martin branches: 1.12.2;
Remove clause 3 and 4 from TNF licenses
 1.11 07-Jun-2005  he branches: 1.11.18;
Initialize a local variable (bbinfop) to appease -Wuninitialized.
Marked with XXXGCC for sparc64 (found while compiling for it).

Reviewed by lukem.
 1.10 05-Jun-2005  chs appease gcc -Wuninitialized on hp700.
 1.9 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.8 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.7 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.6 21-May-2002  tsutsui Define and use both HOSTTOTARGET32() and TARGET32TOHOST() properly.
(just for consistency)
 1.5 20-May-2002  lukem - use uint8_t instead of char for boot block blobs
- bbinfo_params:
- replace "int littleendian" with "bbinfo_endian endian"
- add comments
- shared_bbinfo_clearboot():
- add callback method to shared_bbinfo_clearboot()
- don't clear from 0..headeroffset; use a callback to do that
- add news68k and newsmips support.
From Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, with a rework by me to
take advantage of the new shared_bbinfo_clearboot() callback.
(XXX: untested yet)
 1.4 20-May-2002  lukem more cosmetic tweaks
 1.3 20-May-2002  lukem cosmetic tweaks
 1.2 15-May-2002  lukem don't print a warning if the callback failed; rely upon the callback
to do that for us.
 1.1 15-May-2002  lukem bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
and sun68k_bbinfo (296 byte, with 64 block entries)
into shared_bbinfo (512 bytes, with 118 block entries),
which will be also shared by future bbinfo-using platforms
(including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
perform the majority of the work for bbinfo-using back-ends
(rather than replicating that across multiple back-ends).
 1.11.18.1 18-May-2008  yamt sync with head.
 1.12.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.13.6.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.2 24-May-2024  tsutsui branches: 1.2.2;
Fix tools build errors on Cygwin.
 1.1 19-May-2024  tsutsui Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.
 1.2.2.2 22-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #722):

sys/fs/cd9660/cd9660_util.c: revision 1.16
sys/arch/hp300/stand/common/clock.c: revision 1.14
sys/arch/hp300/stand/common/scsireg.h: revision 1.5
sys/arch/hp300/stand/common/scsireg.h: revision 1.6
sys/arch/hp300/stand/Makefile.buildboot: revision 1.38
sys/arch/hp300/include/bus.h: revision 1.23
sys/arch/hp300/stand/Makefile.buildboot: revision 1.39
sys/arch/hp300/stand/common/sd.c: revision 1.12
sys/arch/hp300/stand/common/prf.c: revision 1.6
sys/arch/hp300/stand/common/sd.c: revision 1.13
usr.sbin/installboot/installboot.8: revision 1.106
usr.sbin/installboot/Makefile: revision 1.59
sys/arch/hp300/stand/common/devopen.c: revision 1.14
usr.sbin/installboot/installboot.8: revision 1.107
sys/arch/hp300/stand/common/ite_dumb.c: revision 1.2
sys/arch/hp300/stand/common/devopen.c: revision 1.15
usr.sbin/installboot/installboot.8: revision 1.108
sys/fs/cd9660/cd9660_extern.h: revision 1.29
usr.sbin/installboot/installboot.8: revision 1.109
tools/Makefile.nbincludes: revision 1.11 (patch)
sys/arch/hp300/dev/rboxreg.h: revision 1.3
sys/arch/hp300/stand/common/scsivar.h: revision 1.5
sys/arch/hp300/dev/dnkbd.c: revision 1.14
sys/arch/hp300/hp300/trap.c: revision 1.156
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.12
sys/arch/hp300/dev/frodoreg.h: revision 1.6
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.13
sys/arch/hp300/stand/common/ite_sti.c: revision 1.2
sys/arch/hp300/stand/common/hil.c: revision 1.15
usr.sbin/installboot/arch/hp300.c: revision 1.18
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.14
sys/arch/hp300/dev/rbox.c: revision 1.4
usr.sbin/installboot/arch/hp300.c: revision 1.19
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.15
sys/sys/bootblock.h: revision 1.59
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.16
usr.sbin/installboot/installboot.h: revision 1.44
sys/arch/hp300/stand/mkboot/volhdr.h: file removal
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.17
sys/arch/hp300/dev/hpib.c: revision 1.45
usr.sbin/installboot/installboot.h: revision 1.45
usr.sbin/installboot/cd9660.c: revision 1.1
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.18
sys/arch/hp300/dev/topcatreg.h: revision 1.3
usr.sbin/installboot/cd9660.c: revision 1.2
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.19
sys/arch/hp300/stand/inst/inst.c: revision 1.25
sys/arch/hp300/stand/uboot/Makefile: revision 1.12
sys/arch/hp300/dev/dvbox.c: revision 1.4
sys/arch/hp300/dev/dma.c: revision 1.45
sys/arch/hp300/stand/uboot/Makefile: revision 1.13
sys/arch/hp300/stand/common/rd.c: revision 1.16
sys/arch/hp300/stand/inst/Makefile: revision 1.12
distrib/hp300/cdroms/installcd/Makefile: revision 1.4
sys/arch/hp300/stand/mkboot/volhdr.h: revision 1.6
sys/arch/hp300/stand/common/machdep.c: revision 1.16
usr.sbin/installboot/fstypes.c: revision 1.14
sys/arch/hp300/hp300/machdep.c: revision 1.238
sys/arch/hp300/include/cpu.h: revision 1.73
sys/arch/hp300/dev/diofbreg.h: revision 1.4
sys/arch/hp300/stand/common/scsi.c: revision 1.12
sys/arch/hp300/stand/common/netio.c: revision 1.19
sys/arch/hp300/stand/common/scsi.c: revision 1.13
sys/arch/hp300/dev/sti_sgc.c: revision 1.8
sys/arch/hp300/dev/rtc.c: revision 1.22
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.20
sys/arch/hp300/stand/common/conf.h: revision 1.4
sys/arch/hp300/hp300/autoconf.c: revision 1.111
sys/arch/hp300/stand/common/conf.c: revision 1.15
sys/arch/hp300/stand/mkboot/Makefile: revision 1.12
sys/arch/hp300/stand/mkboot/Makefile: revision 1.13
sys/arch/hp300/hp300/autoconf.c: revision 1.114
sys/arch/hp300/dev/dcmreg.h: revision 1.11
sys/arch/hp300/dev/diofbvar.h: revision 1.4
sys/arch/hp300/dev/dcm.c: revision 1.91
sys/fs/cd9660/cd9660_util.c: revision 1.15
sys/arch/hp300/dev/mcclock_frodo.c: revision 1.2

TAB/space cleanup.

installboot(8): formatting improvements

Use Ar foo instead of <foo>; this is mdoc.

Other formatting tweaks.
installboot(8): fix up markup

Don't overuse .Sy - when everything is highlighted, nothing is. Use
.Ic for options &c to get correct PostScript output (both are bold in
plain text).

Use Aq Ar inside .Pa, as both Pa and Ar are rendered as underscored
text in plain text output, and the distinction is lost.

Don't set examples in bold, but give them .Pp space around - they are
much easier to read this way.

Use consistent -width in FILES.
document how to use installboot on netbsd/vax.

PR/57909: Jan-Benedict Glaw: Don't include (build) timestamp when doing a
reproducible build
fix usage string, improve error handling.
add missing chunk for repro-build. fix gcc warnings.
avoid stringop truncation, fix copyright string to prevent assembler warnings.

Fix build as a tool (Jan-Benedict Glaw)

Fix integer overflow of strtol(3) for "loadpoint" address on ILP32 hosts.

This strtol(3) was introduced in rev 1.12 for PR/57909 after netbsd-10,
but it returns LONG_MAX (0x7FFFFFFF) for 0xFFF00000 on ILP32 hosts and
the wrong loadpoint causes "NOT ENOUGH MEMORY" error by the BOOTROMs
on loading uboot.lif on (at least) my 9000/360 and 9000/425t.

Misc cosmetic changes for mostly readability.
- KNF and add some newlines per blocks
- define and use proper bintobcd() macro
- make local functions and variables static

The same uboot.lif binaries are generated.

Rename ${PROGAOUT} -> ${PROGELF} to reflect reality.
Use proper signedness for the LIF file system data structures.

Ancient 4.3BSD used short and int for location, file size, file type,
and addresses etc. but all of them should be unsigned.

Also rename several variables and add comments for readability.
The LIF file system info can be found in "The HPDir Project" page:
https://www.hp9845.net/9845/projects/hpdir/
The same uboot.lif binaries are generated.

Add a preliminary CD boot support to uboot for preparation of PR/54455.
Briefly tested on mame, but not enalbed yet.

Recognize SCSI CD-ROM devices as a booted device properly.

Necessary for PR port-hp300/54455, to boot an md root root RAMDISK

kernel from CD-ROM without "WARNING: can't find match for bootdev:"
prompt.

Sync with src/sys/arch/hp300/stand/mkboot/volhdr.h rev 1.6.
https://mail-index.netbsd.org/source-changes/2024/05/07/msg151195.html

Use proper signedness for the LIF file system data structures.
mkboot should use this MI <sys/bootblock.h> and volhdr.h should
be removed soon.

Use MI <sys/bootblock.h> to refer LIF filesystem structures.
This should have been done when LIF definitions were initially added
to <sys/bootblock.h> for MI installboot(8).

Enable SUPPORT_CD on uboot.

Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.

Install cd9660 related system headers for tools installboot(8) builds.

Reorder function prototypes per source files.

Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.

Put a RAMDISK kernel and SYS_UBOOT into hp300 installcd to make it bootable.

This should finally close PR/54455.

Fix tools build errors on Cygwin.

Appease warnings on building tools/installboot on Cygwin.
 1.2.2.1 24-May-2024  martin file cd9660.c was added on branch netbsd-10 on 2024-06-22 10:57:10 +0000
 1.8 01-Nov-2022  andvar s/instalboot/installboot/
 1.7 10-Jul-2022  brook usr.sbin/installboot: Add a command line option (-u) to set U-Boot search paths

Installboot can install U-Boot boot blocks directly into a system
image. Normally, the U-Boot files are searched for in
/usr/pkg/share/u-boot, under the expectation that most people will
build them with pkgsrc. However, it is also possible to set an
environment variable (INSTALLBOOT_UBOOT_PATHS) to a colon-separated
search path to accommodate other situations. This commit adds a
command line option (-u) to set the search path; if present, it
overrides the environment and default.
 1.6 06-Aug-2021  andvar fix various typos in comments.
 1.5 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.4 14-May-2020  msaitoh Remove extra semicolon.
 1.3 19-Sep-2019  thorpej Add support for additional install step directives to enable using
installboot(8) to write u-boot images to SPI NOR and other types of
raw flash devices: input-block-size, input-pad-size, output-size, and
output-block-size.

Add the ability to create aliases for install objects, useful for when
e.g. sdmmc and emmc share the same steps.

Tested on an A20-OLinuXino-LIME2-e16Gs16M by bouyer@.

XXX pullup netbsd-9
 1.2 12-May-2019  maya branches: 1.2.2; 1.2.4;
Use attribute printf.

Helps clang builds. From a.rin.
 1.1 07-May-2019  thorpej Add installboot(8) support for evbarm (and, in the future, other evb*)
boards that use u-boot. A known board database lists boards and their
respective u-boot packages. u-boot packages are discovered at run-time
(in /usr/pkg/share/u-boot, by default). These packages contain board
database overlays that describe u-boot installation procedure that's
specific for that board.

Support this as a native tool and as a host tool. The native tool
will attempt to determine the running board type using OpenFirmware
calls. Host tool and native tool alike may also specify a board type
directly using the "-o board=xxx option" or have installboot(8) determine
the board type from a device tree blob using "-o dtb=/path/to/board.dtb".
A "-o media=xxx" option is provided for boards that have different u-boot
binaries and/or installation procedures for different media types (e.g.
SDMMC, eMMC, or USB).

This is trivial to extend to other evb* platforms that use u-boot, even if
they don't use FDT for autoconfiguration.
 1.2.4.1 22-Sep-2019  martin Pull up following revision(s) (requested by thorpej in ticket #210):

usr.sbin/installboot/evboards.h: revision 1.2
usr.sbin/installboot/evboards.c: revision 1.3

Add support for additional install step directives to enable using
installboot(8) to write u-boot images to SPI NOR and other types of
raw flash devices: input-block-size, input-pad-size, output-size, and
output-block-size.

Add the ability to create aliases for install objects, useful for when
e.g. sdmmc and emmc share the same steps.

Tested on an A20-OLinuXino-LIME2-e16Gs16M by bouyer@.
XXX pullup netbsd-9
 1.2.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.2.2 10-Jun-2019  christos Sync with HEAD
 1.2.2.1 12-May-2019  christos file evboards.c was added on branch phil-wifi on 2019-06-10 22:10:30 +0000
 1.2 19-Sep-2019  thorpej Add support for additional install step directives to enable using
installboot(8) to write u-boot images to SPI NOR and other types of
raw flash devices: input-block-size, input-pad-size, output-size, and
output-block-size.

Add the ability to create aliases for install objects, useful for when
e.g. sdmmc and emmc share the same steps.

Tested on an A20-OLinuXino-LIME2-e16Gs16M by bouyer@.

XXX pullup netbsd-9
 1.1 07-May-2019  thorpej branches: 1.1.2; 1.1.4;
Add installboot(8) support for evbarm (and, in the future, other evb*)
boards that use u-boot. A known board database lists boards and their
respective u-boot packages. u-boot packages are discovered at run-time
(in /usr/pkg/share/u-boot, by default). These packages contain board
database overlays that describe u-boot installation procedure that's
specific for that board.

Support this as a native tool and as a host tool. The native tool
will attempt to determine the running board type using OpenFirmware
calls. Host tool and native tool alike may also specify a board type
directly using the "-o board=xxx option" or have installboot(8) determine
the board type from a device tree blob using "-o dtb=/path/to/board.dtb".
A "-o media=xxx" option is provided for boards that have different u-boot
binaries and/or installation procedures for different media types (e.g.
SDMMC, eMMC, or USB).

This is trivial to extend to other evb* platforms that use u-boot, even if
they don't use FDT for autoconfiguration.
 1.1.4.1 22-Sep-2019  martin Pull up following revision(s) (requested by thorpej in ticket #210):

usr.sbin/installboot/evboards.h: revision 1.2
usr.sbin/installboot/evboards.c: revision 1.3

Add support for additional install step directives to enable using
installboot(8) to write u-boot images to SPI NOR and other types of
raw flash devices: input-block-size, input-pad-size, output-size, and
output-block-size.

Add the ability to create aliases for install objects, useful for when
e.g. sdmmc and emmc share the same steps.

Tested on an A20-OLinuXino-LIME2-e16Gs16M by bouyer@.
XXX pullup netbsd-9
 1.1.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.2.2 10-Jun-2019  christos Sync with HEAD
 1.1.2.1 07-May-2019  christos file evboards.h was added on branch phil-wifi on 2019-06-10 22:10:30 +0000
 1.9 23-Jun-2013  dholland fsbtodb() -> FFS_FSBTODB(), EXT2_FSBTODB(), or MFS_FSBTODB()
dbtofsb() -> FFS_DBTOFSB() or EXT2_DBTOFSB()

(Christos already did the lfs ones a few days back)
 1.8 19-Jun-2013  dholland Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.
 1.7 22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.6 14-Jan-2010  tsutsui branches: 1.6.6; 1.6.12;
Remove if defined(__RCSID) around __RCSID() macro.
#include "nbtool_config.h" is enough for tools.
 1.5 07-Jan-2010  tsutsui Add a sectorsize parameter member in struct ib_params and use it
where sector size (disk block size) is required, instead of
DEV_BSIZE constant which means device I/O block size.

"Looks reasonable" from dholland@, and fixes tools installboot(8)
on Cygwin where DEV_BSIZE != 512 as mentioned in PR toolchain/42555.
 1.4 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.3 12-Oct-2008  apb Try to improve warning messages when stage2 bootstrap is not found
in the root of the file systrem in which the installation is being
performed.

Inspired by PR 39728 by der Mouse
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 02-Feb-2008  tsutsui branches: 1.1.4; 1.1.6;
Add a findstage2 function (which returns block numbers where
the secondary boot is stored to embed them into the primary bootxx)
for ext2fs.

Currently disabled because there is no primary boot block
which supports ext2fs, but it might help someone in some day.
 1.1.6.1 18-May-2008  yamt sync with head.
 1.1.4.2 23-Mar-2008  matt sync with HEAD
 1.1.4.1 02-Feb-2008  matt file ext2fs.c was added on branch matt-armv6 on 2008-03-23 00:50:06 +0000
 1.6.12.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.12.2 23-Jun-2013  tls resync from head
 1.6.12.1 25-Feb-2013  tls resync with head
 1.6.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.6.1 23-Jan-2013  yamt sync with head
 1.33 17-Nov-2022  chs Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new fsck_ffs operations "-c ea" and "-c no-ea" to convert file systems
from UFS2 to UFS2ea and vice-versa (both of which delete all existing extended
attributes in the process).
 1.32 23-Jun-2013  dholland fsbtodb() -> FFS_FSBTODB(), EXT2_FSBTODB(), or MFS_FSBTODB()
dbtofsb() -> FFS_DBTOFSB() or EXT2_DBTOFSB()

(Christos already did the lfs ones a few days back)
 1.31 19-Jun-2013  dholland Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.
 1.30 22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.29 14-Jan-2010  tsutsui branches: 1.29.6; 1.29.12;
Remove if defined(__RCSID) around __RCSID() macro.
#include "nbtool_config.h" is enough for tools.
 1.28 07-Jan-2010  tsutsui Add a sectorsize parameter member in struct ib_params and use it
where sector size (disk block size) is required, instead of
DEV_BSIZE constant which means device I/O block size.

"Looks reasonable" from dholland@, and fixes tools installboot(8)
on Cygwin where DEV_BSIZE != 512 as mentioned in PR toolchain/42555.
 1.27 05-Apr-2009  lukem fix sign-compare issues
 1.26 12-Oct-2008  apb branches: 1.26.4;
Try to improve warning messages when stage2 bootstrap is not found
in the root of the file systrem in which the installation is being
performed.

Inspired by PR 39728 by der Mouse
 1.25 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.24 30-Oct-2006  he branches: 1.24.16;
In order to avoid warnings (which is converted to error with -Werror)
about empty bodies in an if-statement, we need to make add some proprocessor
conditionals around these if statements. FFS byte-swapping is sometimes
compiled out of install-media versions of this program.
 1.23 23-Oct-2006  christos buf can never be NULL (jani at xeebioneurope dot de)
 1.22 22-Oct-2006  christos remove dead code.
 1.21 20-Sep-2006  bad Apply changes to ffs_find_disk_blocks_ufs1() from revision 1.19
to ffs_find_disk_blocks_ufs2() too. Except for data types the
code in the two functions is the same.

From the original commit message:
Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition.

Briefly tested under 3.x/i386.
 1.20 20-Jun-2006  jdc Don't include <dev/raidframe/raidframevar.h> but define RF_PROTECTED_SECTORS
directly.

Including raidframevar.h needs several definitions adding to the compat
framework for the tools builds, which aren't needed here.

XXX It's probably sensible to split off the few defines from raidframevar.h
into a separate header file.
 1.19 20-Jun-2006  jdc Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition. Tested on sparc.

Reviewed by gdt.
 1.18 18-Feb-2006  dsl Remove support for byteswapped file systems if NO_FFS_SWAP is defined.
For SAMLLPROG builds.
 1.17 23-Oct-2005  thorpej Use the real field name (d_fileno instead of d_ino).
 1.16 19-Aug-2005  christos 64 bit inode changes
 1.15 20-Jun-2004  jmc branches: 1.15.2;
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.14 21-Mar-2004  dsl branches: 1.14.2;
When searching for the superblock, don't pick an ffsv1 superblock from the
location where we expect to find an ffsv2 superblock.
It could be the first alternate for a ffsv1 filesystem with 64k blocks.
Fixes part of PR kern/24809
 1.13 06-Oct-2003  lukem spelo in comment
 1.12 30-May-2003  dsl Another mistake in the ufs2 code - a missing else.
 1.11 05-Apr-2003  he Fix two mistakes done in the UFS2 merge:
o Correct the order of arguments to ffs_read_disk_block; the second one
is blocknumber to read, not the size to be read. This would affect the
UFS2 code, and is thus not much excercised at the moment.
o The offsets in SBLOCKSEARCH are in bytes, but ffs_read_disk_block wants
its location in terms of DEV_BSIZE blocks. Fix this bug in ffs_match().
The latter together with the recent magic number fix to <ufs/ffs/fs.h>
fixes a cross build problem seen when doing a i386->sparc build.
 1.10 02-Apr-2003  he Add cats for printf %llu arguments, for the benefit of LP64 platforms.
 1.9 02-Apr-2003  he With the new UFS2 code, alternative places are searched for a super-block.
This includes block #0. Therefore, allow read of block #0 in
ffs_read_disk_block(); change assert (blkno > 0) to (blkno >= 0).
 1.8 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.7 24-Jan-2003  fvdl Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.6 15-May-2002  lukem bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
and sun68k_bbinfo (296 byte, with 64 block entries)
into shared_bbinfo (512 bytes, with 118 block entries),
which will be also shared by future bbinfo-using platforms
(including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
perform the majority of the work for bbinfo-using back-ends
(rather than replicating that across multiple back-ends).
 1.5 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.4 07-May-2002  pk Stop directory entry search if d_reclen == 0.
 1.3 02-May-2002  lukem tweak asserts
 1.2 30-Apr-2002  lukem add some more assert()s
 1.1 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.14.2.1 22-Jun-2004  tron Pull up revision 1.15 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.15.2.3 09-Nov-2006  tron Pull up following revision(s) (requested by bad in ticket #1524):
usr.sbin/installboot/ffs.c: revision 1.21
Apply changes to ffs_find_disk_blocks_ufs1() from revision 1.19
to ffs_find_disk_blocks_ufs2() too. Except for data types the
code in the two functions is the same.
From the original commit message:
Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition.
Briefly tested under 3.x/i386.
 1.15.2.2 09-Nov-2006  tron Pull up following revision(s) (requested by bad in ticket #1524):
usr.sbin/installboot/ffs.c: revision 1.20
Don't include <dev/raidframe/raidframevar.h> but define RF_PROTECTED_SECTORS
directly.
Including raidframevar.h needs several definitions adding to the compat
framework for the tools builds, which aren't needed here.
XXX It's probably sensible to split off the few defines from raidframevar.h
into a separate header file.
 1.15.2.1 09-Nov-2006  tron Pull up following revision(s) (requested by bad in ticket #1524):
usr.sbin/installboot/installboot.8: revision 1.54 via patch
usr.sbin/installboot/installboot.h: revision 1.31
usr.sbin/installboot/fstypes.c: revision 1.9
usr.sbin/installboot/ffs.c: revision 1.19
Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition. Tested on sparc.
Reviewed by gdt.
 1.24.16.1 18-May-2008  yamt sync with head.
 1.26.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.29.12.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.12.2 23-Jun-2013  tls resync from head
 1.29.12.1 25-Feb-2013  tls resync with head
 1.29.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.29.6.1 23-Jan-2013  yamt sync with head
 1.14 19-May-2024  tsutsui Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.
 1.13 14-Jan-2010  tsutsui branches: 1.13.56;
Remove if defined(__RCSID) around __RCSID() macro.
#include "nbtool_config.h" is enough for tools.
 1.12 07-Jan-2010  tsutsui Add a sectorsize parameter member in struct ib_params and use it
where sector size (disk block size) is required, instead of
DEV_BSIZE constant which means device I/O block size.

"Looks reasonable" from dholland@, and fixes tools installboot(8)
on Cygwin where DEV_BSIZE != 512 as mentioned in PR toolchain/42555.
 1.11 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.10 22-Oct-2006  christos branches: 1.10.16;
fix initializers
 1.9 20-Jun-2006  jdc Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition. Tested on sparc.

Reviewed by gdt.
 1.8 18-Feb-2006  dsl The fstypes table is only needed for adding 'stage2' bootstraps on some
platforms. Compile out the code if NO_STAGE2 is defined.
 1.7 20-Jun-2004  jmc branches: 1.7.2;
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.6 27-Jul-2003  lukem branches: 1.6.2;
rcsid
 1.5 15-May-2002  lukem bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
and sun68k_bbinfo (296 byte, with 64 block entries)
into shared_bbinfo (512 bytes, with 118 block entries),
which will be also shared by future bbinfo-using platforms
(including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
perform the majority of the work for bbinfo-using back-ends
(rather than replicating that across multiple back-ends).
 1.4 15-May-2002  lukem - add fsstat (fstat(2) on fsfd) and s1stat (fstat(2) on s1fd) in ib_params,
and use instead of replicating the effort in various locations
- if filesystem is not a regular file, use sync(2) instead of fsync(2)
after the bootstrap has been written
 1.3 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.2 30-Apr-2002  lukem implement "raw" file system type. this can be used when the primary
bootstrap is being installed at a particular block offset and the underlying
filesystem doesn't matter (e.g, alpha ustarboot in ustar floppies)
 1.1 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.6.2.1 22-Jun-2004  tron Pull up revision 1.7 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.7.2.1 09-Nov-2006  tron Pull up following revision(s) (requested by bad in ticket #1524):
usr.sbin/installboot/installboot.8: revision 1.54 via patch
usr.sbin/installboot/installboot.h: revision 1.31
usr.sbin/installboot/fstypes.c: revision 1.9
usr.sbin/installboot/ffs.c: revision 1.19
Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition. Tested on sparc.
Reviewed by gdt.
 1.10.16.1 18-May-2008  yamt sync with head.
 1.13.56.1 22-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #722):

sys/fs/cd9660/cd9660_util.c: revision 1.16
sys/arch/hp300/stand/common/clock.c: revision 1.14
sys/arch/hp300/stand/common/scsireg.h: revision 1.5
sys/arch/hp300/stand/common/scsireg.h: revision 1.6
sys/arch/hp300/stand/Makefile.buildboot: revision 1.38
sys/arch/hp300/include/bus.h: revision 1.23
sys/arch/hp300/stand/Makefile.buildboot: revision 1.39
sys/arch/hp300/stand/common/sd.c: revision 1.12
sys/arch/hp300/stand/common/prf.c: revision 1.6
sys/arch/hp300/stand/common/sd.c: revision 1.13
usr.sbin/installboot/installboot.8: revision 1.106
usr.sbin/installboot/Makefile: revision 1.59
sys/arch/hp300/stand/common/devopen.c: revision 1.14
usr.sbin/installboot/installboot.8: revision 1.107
sys/arch/hp300/stand/common/ite_dumb.c: revision 1.2
sys/arch/hp300/stand/common/devopen.c: revision 1.15
usr.sbin/installboot/installboot.8: revision 1.108
sys/fs/cd9660/cd9660_extern.h: revision 1.29
usr.sbin/installboot/installboot.8: revision 1.109
tools/Makefile.nbincludes: revision 1.11 (patch)
sys/arch/hp300/dev/rboxreg.h: revision 1.3
sys/arch/hp300/stand/common/scsivar.h: revision 1.5
sys/arch/hp300/dev/dnkbd.c: revision 1.14
sys/arch/hp300/hp300/trap.c: revision 1.156
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.12
sys/arch/hp300/dev/frodoreg.h: revision 1.6
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.13
sys/arch/hp300/stand/common/ite_sti.c: revision 1.2
sys/arch/hp300/stand/common/hil.c: revision 1.15
usr.sbin/installboot/arch/hp300.c: revision 1.18
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.14
sys/arch/hp300/dev/rbox.c: revision 1.4
usr.sbin/installboot/arch/hp300.c: revision 1.19
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.15
sys/sys/bootblock.h: revision 1.59
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.16
usr.sbin/installboot/installboot.h: revision 1.44
sys/arch/hp300/stand/mkboot/volhdr.h: file removal
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.17
sys/arch/hp300/dev/hpib.c: revision 1.45
usr.sbin/installboot/installboot.h: revision 1.45
usr.sbin/installboot/cd9660.c: revision 1.1
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.18
sys/arch/hp300/dev/topcatreg.h: revision 1.3
usr.sbin/installboot/cd9660.c: revision 1.2
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.19
sys/arch/hp300/stand/inst/inst.c: revision 1.25
sys/arch/hp300/stand/uboot/Makefile: revision 1.12
sys/arch/hp300/dev/dvbox.c: revision 1.4
sys/arch/hp300/dev/dma.c: revision 1.45
sys/arch/hp300/stand/uboot/Makefile: revision 1.13
sys/arch/hp300/stand/common/rd.c: revision 1.16
sys/arch/hp300/stand/inst/Makefile: revision 1.12
distrib/hp300/cdroms/installcd/Makefile: revision 1.4
sys/arch/hp300/stand/mkboot/volhdr.h: revision 1.6
sys/arch/hp300/stand/common/machdep.c: revision 1.16
usr.sbin/installboot/fstypes.c: revision 1.14
sys/arch/hp300/hp300/machdep.c: revision 1.238
sys/arch/hp300/include/cpu.h: revision 1.73
sys/arch/hp300/dev/diofbreg.h: revision 1.4
sys/arch/hp300/stand/common/scsi.c: revision 1.12
sys/arch/hp300/stand/common/netio.c: revision 1.19
sys/arch/hp300/stand/common/scsi.c: revision 1.13
sys/arch/hp300/dev/sti_sgc.c: revision 1.8
sys/arch/hp300/dev/rtc.c: revision 1.22
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.20
sys/arch/hp300/stand/common/conf.h: revision 1.4
sys/arch/hp300/hp300/autoconf.c: revision 1.111
sys/arch/hp300/stand/common/conf.c: revision 1.15
sys/arch/hp300/stand/mkboot/Makefile: revision 1.12
sys/arch/hp300/stand/mkboot/Makefile: revision 1.13
sys/arch/hp300/hp300/autoconf.c: revision 1.114
sys/arch/hp300/dev/dcmreg.h: revision 1.11
sys/arch/hp300/dev/diofbvar.h: revision 1.4
sys/arch/hp300/dev/dcm.c: revision 1.91
sys/fs/cd9660/cd9660_util.c: revision 1.15
sys/arch/hp300/dev/mcclock_frodo.c: revision 1.2

TAB/space cleanup.

installboot(8): formatting improvements

Use Ar foo instead of <foo>; this is mdoc.

Other formatting tweaks.
installboot(8): fix up markup

Don't overuse .Sy - when everything is highlighted, nothing is. Use
.Ic for options &c to get correct PostScript output (both are bold in
plain text).

Use Aq Ar inside .Pa, as both Pa and Ar are rendered as underscored
text in plain text output, and the distinction is lost.

Don't set examples in bold, but give them .Pp space around - they are
much easier to read this way.

Use consistent -width in FILES.
document how to use installboot on netbsd/vax.

PR/57909: Jan-Benedict Glaw: Don't include (build) timestamp when doing a
reproducible build
fix usage string, improve error handling.
add missing chunk for repro-build. fix gcc warnings.
avoid stringop truncation, fix copyright string to prevent assembler warnings.

Fix build as a tool (Jan-Benedict Glaw)

Fix integer overflow of strtol(3) for "loadpoint" address on ILP32 hosts.

This strtol(3) was introduced in rev 1.12 for PR/57909 after netbsd-10,
but it returns LONG_MAX (0x7FFFFFFF) for 0xFFF00000 on ILP32 hosts and
the wrong loadpoint causes "NOT ENOUGH MEMORY" error by the BOOTROMs
on loading uboot.lif on (at least) my 9000/360 and 9000/425t.

Misc cosmetic changes for mostly readability.
- KNF and add some newlines per blocks
- define and use proper bintobcd() macro
- make local functions and variables static

The same uboot.lif binaries are generated.

Rename ${PROGAOUT} -> ${PROGELF} to reflect reality.
Use proper signedness for the LIF file system data structures.

Ancient 4.3BSD used short and int for location, file size, file type,
and addresses etc. but all of them should be unsigned.

Also rename several variables and add comments for readability.
The LIF file system info can be found in "The HPDir Project" page:
https://www.hp9845.net/9845/projects/hpdir/
The same uboot.lif binaries are generated.

Add a preliminary CD boot support to uboot for preparation of PR/54455.
Briefly tested on mame, but not enalbed yet.

Recognize SCSI CD-ROM devices as a booted device properly.

Necessary for PR port-hp300/54455, to boot an md root root RAMDISK

kernel from CD-ROM without "WARNING: can't find match for bootdev:"
prompt.

Sync with src/sys/arch/hp300/stand/mkboot/volhdr.h rev 1.6.
https://mail-index.netbsd.org/source-changes/2024/05/07/msg151195.html

Use proper signedness for the LIF file system data structures.
mkboot should use this MI <sys/bootblock.h> and volhdr.h should
be removed soon.

Use MI <sys/bootblock.h> to refer LIF filesystem structures.
This should have been done when LIF definitions were initially added
to <sys/bootblock.h> for MI installboot(8).

Enable SUPPORT_CD on uboot.

Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.

Install cd9660 related system headers for tools installboot(8) builds.

Reorder function prototypes per source files.

Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.

Put a RAMDISK kernel and SYS_UBOOT into hp300 installcd to make it bootable.

This should finally close PR/54455.

Fix tools build errors on Cygwin.

Appease warnings on building tools/installboot on Cygwin.
 1.2 13-Nov-2003  dsl roundup() write of hp300 boot code to a multiplr of the disk sector size.
and re-instate the hp300 code - seems to work.
 1.1 08-Nov-2003  dsl First cut of hp300 installboot, seems to DTRT on i386.
Maybe this code ought to know how to add a file to the LIF filesystem.
 1.114 05-Oct-2025  thorpej Add riscv.
 1.113 29-Dec-2024  christos update date for previous
 1.112 29-Dec-2024  jakllsch spelling fix

From Alexander Kuleshov in PR bin/58945.
 1.111 29-Aug-2024  dholland installboot(8): excise stray word
 1.110 01-Jun-2024  gutteridge branches: 1.110.2;
installboot.8: reflect current evbmips support
 1.109 19-May-2024  tsutsui Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.
 1.108 26-Dec-2023  mrg document how to use installboot on netbsd/vax.
 1.107 17-May-2023  uwe installboot(8): fix up markup

Don't overuse .Sy - when everything is highlighted, nothing is. Use
.Ic for options &c to get correct PostScript output (both are bold in
plain text).

Use Aq Ar inside .Pa, as both Pa and Ar are rendered as underscored
text in plain text output, and the distinction is lost.

Don't set examples in bold, but give them .Pp space around - they are
much easier to read this way.

Use consistent -width in FILES.
 1.106 16-May-2023  lukem installboot(8): formatting improvements

Use Ar foo instead of <foo>; this is mdoc.
Other formatting tweaks.
 1.105 19-Aug-2022  riastradh branches: 1.105.2;
installboot(8): Note relation to UEFI boot and hybrid images.
 1.104 19-Aug-2022  riastradh installboot(8): Fix capitalization of U-Boot.
 1.103 10-Jul-2022  brook usr.sbin/installboot: Add a command line option (-u) to set U-Boot search paths

Installboot can install U-Boot boot blocks directly into a system
image. Normally, the U-Boot files are searched for in
/usr/pkg/share/u-boot, under the expectation that most people will
build them with pkgsrc. However, it is also possible to set an
environment variable (INSTALLBOOT_UBOOT_PATHS) to a colon-separated
search path to accommodate other situations. This commit adds a
command line option (-u) to set the search path; if present, it
overrides the environment and default.
 1.102 05-Dec-2021  msaitoh s/filesytem/filesystem/
 1.101 25-Feb-2021  rin Adjust manpage for amiga/boot ver 3.1.

Bump date.
 1.100 06-Feb-2021  rin Mention fdisk(8) and x86/mbr(8) in example for x86, for careless
people like me ;).

Bump date.
 1.99 06-Jun-2020  wiz Reduce macro arguments.
 1.98 06-Jun-2020  tsutsui Fix ews4800mips example. Its raw partition is rsd0p, not rsd0c.
 1.97 07-May-2019  wiz branches: 1.97.2;
Fix typos. Fix link. Use Pa for path.
 1.96 07-May-2019  thorpej Add installboot(8) support for evbarm (and, in the future, other evb*)
boards that use u-boot. A known board database lists boards and their
respective u-boot packages. u-boot packages are discovered at run-time
(in /usr/pkg/share/u-boot, by default). These packages contain board
database overlays that describe u-boot installation procedure that's
specific for that board.

Support this as a native tool and as a host tool. The native tool
will attempt to determine the running board type using OpenFirmware
calls. Host tool and native tool alike may also specify a board type
directly using the "-o board=xxx option" or have installboot(8) determine
the board type from a device tree blob using "-o dtb=/path/to/board.dtb".
A "-o media=xxx" option is provided for boards that have different u-boot
binaries and/or installation procedures for different media types (e.g.
SDMMC, eMMC, or USB).

This is trivial to extend to other evb* platforms that use u-boot, even if
they don't use FDT for autoconfiguration.
 1.95 15-Aug-2017  wiz branches: 1.95.4;
Remove superfluous Tn macros.
 1.94 15-Aug-2017  mrg merge the rest of sbmips into evbmips. install the stand files in
/usr/mdec/sbmips/ and document them in installboot(8) even though
it isn't really ported yet. also build the SBMIPS kernels.

unfortunately, sbmips has been broken since mips64 merge, but the
fix can happen in the evbmips version, which we might merge into
the older trees anyway.

XXX: releng can turn off sbmips* builds now for -current.
 1.93 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.92 15-Mar-2017  wiz branches: 1.92.4;
Bump date for previous.
 1.91 14-Mar-2017  bad Document option console=auto. Works since at least NetBSD 6. [i386,amd64]
 1.90 21-Jun-2016  alnsn branches: 1.90.2; 1.90.4;
Fix a typo: s/can be use/can be used/
 1.89 22-Mar-2015  wiz Use An in AUTHORS section.
 1.88 22-Mar-2015  ast Appease various mandoc -Tlint warnings and update copyright while we're here
 1.87 24-Feb-2014  skrll Rename NetBSD/hp700 to NetBSD/hppa.

Unfortunately our VCS isn't very helpful here.
 1.86 10-Mar-2012  wiz branches: 1.86.2;
Add missing word.
 1.85 10-Mar-2012  dsl Some FAT16 filesystems don't have 'hidden sectors' correctly set to
the offset of the filesystem on the disk.
Let '-b s1blk' be used to fix the value.
 1.84 11-Feb-2012  ast Use "NetBSD 6.0" and not "NetBSD 6" and sound less like a broken record.
Add note where the actual example is because that's where it's expected.
Part of earlier commit ok-ed by releng@
 1.83 10-Feb-2012  wiz Remove trailing whitespace. Put macro arguments on same line.
 1.82 09-Feb-2012  ast Update the amd64 and i386 examples to use /usr/mdec/bootxx_ffsv2,
i.e. DEFAULT_UFS2 as src/distrib/utils/sysinst/bsddisklabel.c does
since post-NetBSD5. This avoids rendering an i386 or amd64 system
unbootable if the given example is thoughtlessly cut-and-pasted on
a NetBSD6.x system (been there, done that ;-) Qualify the descriptions
of /usr/mdec/bootxx_ffsv{1,2} along those lines.

Fixed a small typo in comment of distrib/utils/sysinst/arch/amd64/md.h.

Ok by releng@
 1.81 09-Jan-2012  skrll Update for hp700. Bump date.
 1.80 09-Jan-2012  skrll s/ISO9660/ISO 9660/ for consistency with rest of man page.
 1.79 03-Nov-2011  martin Minor nits in the sparc64 example
 1.78 29-Aug-2011  alnsn branches: 1.78.2;
Typo.
 1.77 03-Aug-2011  gdt Explain how to use -e -v without -o to see the current options.
Caution that installing a new primary bootstrap will reset options to
default values.
 1.76 25-Apr-2011  martin Use rsd0c instead of the (far less common) rwd0c as boot disk in the
sparc64 example.
 1.75 21-Nov-2010  jym Sort options.
 1.74 14-Jan-2010  drochner On i386/amd64, define two flag bits in the boot parameters which control
whether modules are loaded and whether boot.cfg is evaluated, and
set both to "off" per default in the PXE bootloader.
Extend "installboot" to toggle the bits.
This way, pxeboot works with existing dhcp server setups (and as
described in the manpage) out of the box. Also, boot.cfg reading
involves a stat() call which is horribly inefficient with the
TFTP pseudo file system.
 1.73 07-May-2009  lukem Add reminder to confirm the ffs format using dumpfs(8).
 1.72 12-Oct-2008  apb branches: 1.72.4;
Try to improve documentation of the fact that the primary bootstrap is
specified using a file name on the running system, while the secondary
bootstrap is specified using a file name relative to the root of the
file systrem in which the installation is being performed.

Inspired by PR 39728 by der Mouse
 1.71 02-Oct-2008  wiz Drop trailing whitespace; bump date for previous.
 1.70 02-Oct-2008  sborrill Add example using installboot -e
 1.69 24-Sep-2008  reed Add missing comma in SEE ALSO list.
 1.68 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.67 05-Jul-2007  dsl branches: 1.67.10;
Note here that -e can be used on the pxeboot_ia32.bin file.
(It is already mentioned on the pxeboot(8) page.)
 1.66 01-Jun-2007  dyoung Bring the example concerning a bootable ISO9660 for i386 up-to-date,
demonstrating the -e option.
 1.65 17-Feb-2007  wiz Sort SEE ALSO.
 1.64 15-Feb-2007  dsl Add a -f (force) parameter to installboot(8).
If specified then checks on the disks BPB are not done, and any existing BPB
is deleted.
This is needed soince newfs(8) doesn't overwrite the BPB - which is basically
the FAT superblock.
Update documentation and add an example of using bootxx_fat16.
 1.63 08-Jan-2007  wiz Drop trailing space.
 1.62 06-Jan-2007  dsl Document bootxx_fat16 with a short description of why it differs from
bootxx_msdos.
 1.61 23-Dec-2006  wiz Reword OF3 restrictions, ok tsutsui@.
Bump date.
 1.60 23-Dec-2006  wiz New sentence, new line. Improve English.
 1.59 25-Nov-2006  tsutsui branches: 1.59.2; 1.59.4;
Add some macppc specific description. Closes PR port-macppc/34496 by myself.
 1.58 24-Sep-2006  wiz Mark up a path with .Pa.
 1.57 24-Sep-2006  martin Add a note to explain 'c' (or 'd') partition usage in the common example.
 1.56 03-Sep-2006  wiz Bump date for previous.
 1.55 02-Sep-2006  uwe Mention landisk as supported.
 1.54 20-Jun-2006  jdc Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition. Tested on sparc.

Reviewed by gdt.
 1.53 13-Jan-2006  wiz Replace NetBSD with Nx.
 1.52 13-Jan-2006  tsutsui Note about ews4800mips.
 1.51 12-Nov-2005  wiz It is not 2006 yet. Fix typo. Uppercase BIOS.
 1.50 12-Nov-2005  dsl Don't try to determine the type of the target filesystem unless a second
stage bootstrap is specified. It is only needed when we need to copy the
sector numbers of the second stage into the first stage.
Document that a configured baud rate of zero will cause the baud rate set by
the bios to be used.
 1.49 11-Nov-2005  wiz Keeps in SYNOPSIS are not necessary any longer, groff is smart enough nowadays.
Sort options and option descriptions.
 1.48 11-Nov-2005  dsl Add a -e (edit) option to allow the bootstrap options of an installed
bootstrap or a file containing such a bootstrap to be changed/displayed.
In particular this will (soon) let you modify the parameters for pxeboot.
 1.47 10-Oct-2005  dyoung Add single quotes to escape a semicolon in the makefs(8) argument
list. Pointed out by Hubert Feyrer.
 1.46 06-Oct-2005  wiz Punctuation nits; bump date for previous.
 1.45 06-Oct-2005  dyoung Add an example of using installboot(8) and makefs(8) with bootxx_cd9660
to create a bootable CD-ROM for an i386 host with a serial console.
 1.44 03-Jun-2005  wiz Add hp700 to supported list. Bump date.
 1.43 15-Aug-2004  dsl branches: 1.43.2;
Add an option to set bp_consaddr (serial console IO port address)
Only complain about small patch area if we would write something non-zero there.
 1.42 25-Jun-2004  wiz Document amd64; from Nicolas Joly in PR 26026.
 1.41 13-Mar-2004  wiz Add example to keymap description. Use more macros. Bump date.
 1.40 13-Mar-2004  dsl Add a -o keymap=zyz option that will set the boot keymap.
If a character in the map is typed, it gets replaced by the one following.
 1.39 26-Nov-2003  wiz Use Xr instead of Ic when suitable; NetBSD -> .Nx; add comma;
use Dq for a string.
 1.38 26-Nov-2003  lukem Provide an example for making a bootable FAT file system, and improve
some of the other examples.
 1.37 13-Nov-2003  dsl roundup() write of hp300 boot code to a multiplr of the disk sector size.
and re-instate the hp300 code - seems to work.
 1.36 10-Nov-2003  fvdl Comment out hp300 references.
 1.35 08-Nov-2003  dsl First cut of hp300 installboot, seems to DTRT on i386.
Maybe this code ought to know how to add a file to the LIF filesystem.
 1.34 02-Nov-2003  perry Clean up the i386 examples somewhat, adding an example of upgrading
the boot blocks on the existing mounted root file system, and
eliminating references to bootxx_ufs.

I referenced the a partition even though most other ports seem to
reference the c partition. I don't know if that's the most correct
way to do it, but it seems to work for me and no one can tell me what
the canonical method is. I'd let someone else fix the man page but no
one seemed to want to and it really needed the example.
 1.33 28-Oct-2003  wiz Grammar fixes in previous; use Nx in one place;
sort examples; replace < and > with \*[Lt] and \*[Gt] respectively.
Bump date for previous.
 1.32 27-Oct-2003  cl add next68k support to installboot
 1.31 08-Oct-2003  lukem Overhaul MBR handling (part 1):

<sys/bootblock.h>:
* Added definitions for the Master Boot Record (MBR) used by
a variety of systems (primarily i386), including the format
of the BIOS Parameter Block (BPB).
This information was cribbed from a variety of sources
including <sys/disklabel_mbr.h> which this is a superset of.

As part of this, some data structure elements and #defines
were renamed to be more "namespace friendly" and consistent
with other bootblocks and MBR documentation.
Update all uses of the old names to the new names.

<sys/disklabel_mbr.h>:
* Deprecated in favor of <sys/bootblock.h> (the latter is more
"host tool" friendly).

amd64 & i386:
* Renamed /usr/mdec/bootxx_dosfs to /usr/mdec/bootxx_msdos, to
be consistent with the naming convention of the msdosfs tools.

* Removed /usr/mdec/bootxx_ufs, as it's equivalent to bootxx_ffsv1
and it's confusing to have two functionally equivalent bootblocks,
especially given that "ufs" has multiple meanings (it could be
a synonym for "ffs", or the group of ffs/lfs/ext2fs file systems).

* Rework pbr.S (the first sector of bootxx_*):
+ Ensure that BPB (bytes 11..89) and the partition table
(bytes 446..509) do not contain code.
+ Add support for booting from FAT partitions if BOOT_FROM_FAT
is defined. (Only set for bootxx_msdos).
+ Remove "dummy" partition 3; if people want to installboot(8)
these to the start of the disk they can use fdisk(8) to
create a real MBR partition table...
+ Compile with TERSE_ERROR so it fits because of the above.
Whilst this is less user friendly, I feel it's important
to have a valid partition table and BPB in the MBR/PBR.

* Renamed /usr/mdec/biosboot to /usr/mdec/boot, to be consistent
with other platforms.

* Enable SUPPORT_DOSFS in /usr/mdec/boot (stage2), so that
we can boot off FAT partitions.

* Crank version of /usr/mdec/boot to 3.1, and fix some of the other
entries in the version file.

installboot(8) (i386):
* Read the existing MBR of the filesystem and retain the BIOS
Parameter Block (BPB) in bytes 11..89 and the MBR partition
table in bytes 446..509. (Previously installboot(8) would
trash those two sections of the MBR.)

mbrlabel(8):
* Use sys/lib/libkern/xlat_mbr_fstype.c instead of homegrown code
to map the MBR partition type to the NetBSD disklabel type.


Test built "make release" for i386, and new bootblocks verified to work
(even off FAT!).
 1.30 03-Oct-2003  lukem Document the various bootxx_ variants seen on i386, since it's a FAQ.

Document /usr/mdec/biosboot. (Arguably that should be renamed to
"/usr/mdec/boot" or "/usr/mdec/boot.i386" for consistency with other platforms)
 1.29 16-Aug-2003  martin Add an example for creating a bootable i386 floppy.
 1.28 20-Apr-2003  lukem Add explicit descriptions of the `filesystem', `primary', and `secondary'
arguments, including a clarification that `secondary' is relative to the root
of the filesystem, not a path name to that file if `filesystem' is mounted.
Resolves PR 20977 from Jim Bernard.
 1.27 16-Apr-2003  wiz Bump date for last; sort authors; add comma after e.g.
 1.26 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.25 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.24 15-Jan-2003  mhitch Add support for amiga.
 1.23 03-Oct-2002  lukem alpha also supports append & sunsum
 1.22 30-Jun-2002  wiz Mdoc nit.
 1.21 30-Jun-2002  lukem - be consistent with formatting, and use FSTYPE instead of <fs>
- remove sparc and sun[23] BUGS that aren't relevant in this version
 1.20 30-Jun-2002  grant update to reflect current state of reality for alpha, pmax, sparc,
sparc64, sun2, sun3 and vax.
clean up examples.
include bugs/caveats from the (now removed) arch installboot man pages.
 1.19 02-Jun-2002  isaki Add x68k stuff.
 1.18 20-May-2002  wiz branches: 1.18.2;
No .Pp before section headers, and use .Nx instead of NetBSD in one place.
 1.17 20-May-2002  lukem - use uint8_t instead of char for boot block blobs
- bbinfo_params:
- replace "int littleendian" with "bbinfo_endian endian"
- add comments
- shared_bbinfo_clearboot():
- add callback method to shared_bbinfo_clearboot()
- don't clear from 0..headeroffset; use a callback to do that
- add news68k and newsmips support.
From Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, with a rework by me to
take advantage of the new shared_bbinfo_clearboot() callback.
(XXX: untested yet)
 1.16 17-May-2002  lukem Enable sun3, using same sun68k backend as sun2.

XXX: sun3 port still needs to be cut over to using sun68k bootxx...
 1.15 15-May-2002  lukem advertise macppc support. other tart-ups
 1.14 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.13 06-May-2002  lukem sparc now has a back-end
 1.12 06-May-2002  lukem document what uses the optional secondary arg. add sun2 example
 1.11 30-Apr-2002  lukem implement "raw" file system type. this can be used when the primary
bootstrap is being installed at a particular block offset and the underlying
filesystem doesn't matter (e.g, alpha ustarboot in ustar floppies)
 1.10 22-Apr-2002  lukem Add sun2 backend from Matthew Fredette.
(Implemented with "sun68k.c" as it should eventually support "sun3" as well.)
 1.9 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.8 12-Apr-2002  lukem - support optional secondary bootstrap arg for install (unused by
existing backends, but future ones need it)
- use "bootstrap" instead of "boot block" in various messages where appropriate
- rename some members of ib_params
 1.7 04-Apr-2002  lukem Add sparc64 back-end, contributed by Matthew Green.
 1.6 04-Apr-2002  wiz Mostly typo fixes, some formatting nits.
 1.5 04-Apr-2002  lukem -n and -v are optional ...
 1.4 04-Apr-2002  lukem update description, history, authors, examples, bugs,
including pmax specific stuff
 1.3 03-Apr-2002  lukem Add support for alpha, based on {vax,pmax}.c and
sys/arch/alpha/stand/installboot.
XXX: not fully tested yet.
 1.2 03-Apr-2002  lukem Add pmax installboot back-end; from vax.c and arch/pmax/stand/installboot/*.
XXX: not tested yet.
 1.1 03-Apr-2002  lukem Machine independent "unified" installboot(8).
Currently only supports vax, with more MD back-ends to be added RSN.
 1.18.2.1 30-Jun-2002  lukem pull up revisions 1.20-1.22 (requested by lukem in ticket #410):
revision 1.22
Mdoc nit.
revision 1.21
- be consistent with formatting, and use FSTYPE instead of <fs>
- remove sparc and sun[23] BUGS that aren't relevant in this version
revision 1.20
update to reflect current state of reality for alpha, pmax, sparc,
sparc64, sun2, sun3 and vax.
clean up examples.
include bugs/caveats from the (now removed) arch installboot man pages.
 1.43.2.1 09-Nov-2006  tron Pull up following revision(s) (requested by bad in ticket #1524):
usr.sbin/installboot/installboot.8: revision 1.54 via patch
usr.sbin/installboot/installboot.h: revision 1.31
usr.sbin/installboot/fstypes.c: revision 1.9
usr.sbin/installboot/ffs.c: revision 1.19
Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition. Tested on sparc.
Reviewed by gdt.
 1.59.4.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.59.2.1 04-Jun-2007  bouyer Pull up following revision(s) (requested by dyoung in ticket #692):
usr.sbin/installboot/installboot.8: revision 1.66
Bring the example concerning a bootable ISO9660 for i386 up-to-date,
demonstrating the -e option.
 1.67.10.1 18-May-2008  yamt sync with head.
 1.72.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.78.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.78.2.2 17-Apr-2012  yamt sync with head
 1.78.2.1 10-Nov-2011  yamt sync with head
 1.86.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.90.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.90.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.92.4.1 30-Aug-2017  martin Pull up following revision(s) (requested by mrg in ticket #231):
distrib/sets/lists/base/md.evbmips 1.3
doc/CHANGES 1.2303-1.2304
etc/etc.evbmips/MAKEDEV.conf 1.8
etc/etc.evbmips/Makefile.inc 1.22
etc/mtree/Makefile 1.37
etc/mtree/NetBSD.dist.evbmips 1.1
sys/arch/evbmips/Makefile 1.9
sys/arch/evbmips/conf/SBMIPS upto 1.2
sys/arch/evbmips/conf/SBMIPS.MP upto 1.2
sys/arch/evbmips/conf/SBMIPS64 upto 1.2
sys/arch/evbmips/conf/SBMIPS64.MP upto 1.2
sys/arch/evbmips/conf/files.sbmips upto 1.2
sys/arch/evbmips/conf/std.sbmips upto 1.2
sys/arch/evbmips/include/disklabel.h 1.6
sys/arch/evbmips/include/loadfile_machdep.h
sys/arch/evbmips/include/param.h 1.10
sys/arch/evbmips/include/pci_machdep.h 1.3
sys/arch/evbmips/sbmips/TODO
sys/arch/evbmips/sbmips/autoconf.c
sys/arch/evbmips/sbmips/autoconf.h
sys/arch/evbmips/sbmips/console.c
sys/arch/evbmips/sbmips/cpu.c upto 1.3
sys/arch/evbmips/sbmips/cpuvar.h
sys/arch/evbmips/sbmips/disksubr.c
sys/arch/evbmips/sbmips/leds.h
sys/arch/evbmips/sbmips/locore_machdep.S
sys/arch/evbmips/sbmips/machdep.c upto 1.2
sys/arch/evbmips/sbmips/rtc.c upto 1.2
sys/arch/evbmips/sbmips/sb1250_icu.c upto 1.2
sys/arch/evbmips/sbmips/swarm.h
sys/arch/evbmips/sbmips/systemsw.c upto 1.2
sys/arch/evbmips/sbmips/systemsw.h
sys/arch/evbmips/sbmips/zbbus.c upto 1.2
sys/arch/evbmips/stand/Makefile 1.1
sys/arch/evbmips/stand/sbmips/Makefile
sys/arch/evbmips/stand/sbmips/Makefile.bootprogs upto 1.2
sys/arch/evbmips/stand/sbmips/Makefile.bootprogs 1.3
sys/arch/evbmips/stand/sbmips/Makefile.bootxx
sys/arch/evbmips/stand/sbmips/Makefile.inc upto 1.3
sys/arch/evbmips/stand/sbmips/boot/Makefile
sys/arch/evbmips/stand/sbmips/boot/filesystem.c
sys/arch/evbmips/stand/sbmips/boot/version
sys/arch/evbmips/stand/sbmips/bootxx_cd9660/Makefile
sys/arch/evbmips/stand/sbmips/bootxx_ffs/Makefile
sys/arch/evbmips/stand/sbmips/bootxx_lfs/Makefile
sys/arch/evbmips/stand/sbmips/common/bbinfo.h
sys/arch/evbmips/stand/sbmips/common/blkdev.c upto 1.2
sys/arch/evbmips/stand/sbmips/common/blkdev.h
sys/arch/evbmips/stand/sbmips/common/boot.c upto 1.2
sys/arch/evbmips/stand/sbmips/common/boot.ldscript
sys/arch/evbmips/stand/sbmips/common/booted_dev.c upto 1.2
sys/arch/evbmips/stand/sbmips/common/bootxx.c
sys/arch/evbmips/stand/sbmips/common/cfe.c
sys/arch/evbmips/stand/sbmips/common/cfe_api.c
sys/arch/evbmips/stand/sbmips/common/cfe_api.h
sys/arch/evbmips/stand/sbmips/common/cfe_api_int.h
sys/arch/evbmips/stand/sbmips/common/cfe_error.h
sys/arch/evbmips/stand/sbmips/common/cfe_ioctl.h
sys/arch/evbmips/stand/sbmips/common/checksize.sh
sys/arch/evbmips/stand/sbmips/common/common.h
sys/arch/evbmips/stand/sbmips/common/panic_putstr.c
sys/arch/evbmips/stand/sbmips/common/putstr.c
sys/arch/evbmips/stand/sbmips/common/start.S
sys/arch/evbmips/stand/sbmips/netboot/Makefile
sys/arch/evbmips/stand/sbmips/netboot/conf.c
sys/arch/evbmips/stand/sbmips/netboot/dev_net.c
sys/arch/evbmips/stand/sbmips/netboot/devopen.c
sys/arch/evbmips/stand/sbmips/netboot/getsecs.c upto 1.2
sys/arch/evbmips/stand/sbmips/netboot/if_cfe.c upto 1.2
sys/arch/evbmips/stand/sbmips/netboot/version
sys/arch/mips/conf/files.sibyte 1.8
sys/arch/mips/include/pmap.h 1.70
sys/arch/mips/sibyte/dev/sbbuswatch.c 1.4
sys/arch/mips/sibyte/dev/sbmac.c 1.49
sys/arch/mips/sibyte/dev/sbscn.c 1.43
sys/arch/mips/sibyte/dev/sbsmbus.c 1.17
sys/arch/mips/sibyte/dev/sbtimer.c 1.21
sys/arch/mips/sibyte/dev/sbwdog.c 1.15
sys/arch/mips/sibyte/pci/sbbrz_pci.c 1.8
usr.sbin/installboot/installboot.8 1.94

Move sys/arch/sbmips/* into sys/arch/evbmips/*/sbmips.
 1.95.4.1 10-Jun-2019  christos Sync with HEAD
 1.97.2.1 20-Jun-2020  martin Pull up following revision(s) (requested by tsutsui in ticket #953):

usr.sbin/installboot/installboot.8: revision 1.99
usr.sbin/installboot/installboot.8: revision 1.98

Fix ews4800mips example. Its raw partition is rsd0p, not rsd0c.
Reduce macro arguments.
 1.105.2.1 22-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #722):

sys/fs/cd9660/cd9660_util.c: revision 1.16
sys/arch/hp300/stand/common/clock.c: revision 1.14
sys/arch/hp300/stand/common/scsireg.h: revision 1.5
sys/arch/hp300/stand/common/scsireg.h: revision 1.6
sys/arch/hp300/stand/Makefile.buildboot: revision 1.38
sys/arch/hp300/include/bus.h: revision 1.23
sys/arch/hp300/stand/Makefile.buildboot: revision 1.39
sys/arch/hp300/stand/common/sd.c: revision 1.12
sys/arch/hp300/stand/common/prf.c: revision 1.6
sys/arch/hp300/stand/common/sd.c: revision 1.13
usr.sbin/installboot/installboot.8: revision 1.106
usr.sbin/installboot/Makefile: revision 1.59
sys/arch/hp300/stand/common/devopen.c: revision 1.14
usr.sbin/installboot/installboot.8: revision 1.107
sys/arch/hp300/stand/common/ite_dumb.c: revision 1.2
sys/arch/hp300/stand/common/devopen.c: revision 1.15
usr.sbin/installboot/installboot.8: revision 1.108
sys/fs/cd9660/cd9660_extern.h: revision 1.29
usr.sbin/installboot/installboot.8: revision 1.109
tools/Makefile.nbincludes: revision 1.11 (patch)
sys/arch/hp300/dev/rboxreg.h: revision 1.3
sys/arch/hp300/stand/common/scsivar.h: revision 1.5
sys/arch/hp300/dev/dnkbd.c: revision 1.14
sys/arch/hp300/hp300/trap.c: revision 1.156
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.12
sys/arch/hp300/dev/frodoreg.h: revision 1.6
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.13
sys/arch/hp300/stand/common/ite_sti.c: revision 1.2
sys/arch/hp300/stand/common/hil.c: revision 1.15
usr.sbin/installboot/arch/hp300.c: revision 1.18
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.14
sys/arch/hp300/dev/rbox.c: revision 1.4
usr.sbin/installboot/arch/hp300.c: revision 1.19
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.15
sys/sys/bootblock.h: revision 1.59
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.16
usr.sbin/installboot/installboot.h: revision 1.44
sys/arch/hp300/stand/mkboot/volhdr.h: file removal
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.17
sys/arch/hp300/dev/hpib.c: revision 1.45
usr.sbin/installboot/installboot.h: revision 1.45
usr.sbin/installboot/cd9660.c: revision 1.1
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.18
sys/arch/hp300/dev/topcatreg.h: revision 1.3
usr.sbin/installboot/cd9660.c: revision 1.2
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.19
sys/arch/hp300/stand/inst/inst.c: revision 1.25
sys/arch/hp300/stand/uboot/Makefile: revision 1.12
sys/arch/hp300/dev/dvbox.c: revision 1.4
sys/arch/hp300/dev/dma.c: revision 1.45
sys/arch/hp300/stand/uboot/Makefile: revision 1.13
sys/arch/hp300/stand/common/rd.c: revision 1.16
sys/arch/hp300/stand/inst/Makefile: revision 1.12
distrib/hp300/cdroms/installcd/Makefile: revision 1.4
sys/arch/hp300/stand/mkboot/volhdr.h: revision 1.6
sys/arch/hp300/stand/common/machdep.c: revision 1.16
usr.sbin/installboot/fstypes.c: revision 1.14
sys/arch/hp300/hp300/machdep.c: revision 1.238
sys/arch/hp300/include/cpu.h: revision 1.73
sys/arch/hp300/dev/diofbreg.h: revision 1.4
sys/arch/hp300/stand/common/scsi.c: revision 1.12
sys/arch/hp300/stand/common/netio.c: revision 1.19
sys/arch/hp300/stand/common/scsi.c: revision 1.13
sys/arch/hp300/dev/sti_sgc.c: revision 1.8
sys/arch/hp300/dev/rtc.c: revision 1.22
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.20
sys/arch/hp300/stand/common/conf.h: revision 1.4
sys/arch/hp300/hp300/autoconf.c: revision 1.111
sys/arch/hp300/stand/common/conf.c: revision 1.15
sys/arch/hp300/stand/mkboot/Makefile: revision 1.12
sys/arch/hp300/stand/mkboot/Makefile: revision 1.13
sys/arch/hp300/hp300/autoconf.c: revision 1.114
sys/arch/hp300/dev/dcmreg.h: revision 1.11
sys/arch/hp300/dev/diofbvar.h: revision 1.4
sys/arch/hp300/dev/dcm.c: revision 1.91
sys/fs/cd9660/cd9660_util.c: revision 1.15
sys/arch/hp300/dev/mcclock_frodo.c: revision 1.2

TAB/space cleanup.

installboot(8): formatting improvements

Use Ar foo instead of <foo>; this is mdoc.

Other formatting tweaks.
installboot(8): fix up markup

Don't overuse .Sy - when everything is highlighted, nothing is. Use
.Ic for options &c to get correct PostScript output (both are bold in
plain text).

Use Aq Ar inside .Pa, as both Pa and Ar are rendered as underscored
text in plain text output, and the distinction is lost.

Don't set examples in bold, but give them .Pp space around - they are
much easier to read this way.

Use consistent -width in FILES.
document how to use installboot on netbsd/vax.

PR/57909: Jan-Benedict Glaw: Don't include (build) timestamp when doing a
reproducible build
fix usage string, improve error handling.
add missing chunk for repro-build. fix gcc warnings.
avoid stringop truncation, fix copyright string to prevent assembler warnings.

Fix build as a tool (Jan-Benedict Glaw)

Fix integer overflow of strtol(3) for "loadpoint" address on ILP32 hosts.

This strtol(3) was introduced in rev 1.12 for PR/57909 after netbsd-10,
but it returns LONG_MAX (0x7FFFFFFF) for 0xFFF00000 on ILP32 hosts and
the wrong loadpoint causes "NOT ENOUGH MEMORY" error by the BOOTROMs
on loading uboot.lif on (at least) my 9000/360 and 9000/425t.

Misc cosmetic changes for mostly readability.
- KNF and add some newlines per blocks
- define and use proper bintobcd() macro
- make local functions and variables static

The same uboot.lif binaries are generated.

Rename ${PROGAOUT} -> ${PROGELF} to reflect reality.
Use proper signedness for the LIF file system data structures.

Ancient 4.3BSD used short and int for location, file size, file type,
and addresses etc. but all of them should be unsigned.

Also rename several variables and add comments for readability.
The LIF file system info can be found in "The HPDir Project" page:
https://www.hp9845.net/9845/projects/hpdir/
The same uboot.lif binaries are generated.

Add a preliminary CD boot support to uboot for preparation of PR/54455.
Briefly tested on mame, but not enalbed yet.

Recognize SCSI CD-ROM devices as a booted device properly.

Necessary for PR port-hp300/54455, to boot an md root root RAMDISK

kernel from CD-ROM without "WARNING: can't find match for bootdev:"
prompt.

Sync with src/sys/arch/hp300/stand/mkboot/volhdr.h rev 1.6.
https://mail-index.netbsd.org/source-changes/2024/05/07/msg151195.html

Use proper signedness for the LIF file system data structures.
mkboot should use this MI <sys/bootblock.h> and volhdr.h should
be removed soon.

Use MI <sys/bootblock.h> to refer LIF filesystem structures.
This should have been done when LIF definitions were initially added
to <sys/bootblock.h> for MI installboot(8).

Enable SUPPORT_CD on uboot.

Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.

Install cd9660 related system headers for tools installboot(8) builds.

Reorder function prototypes per source files.

Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.

Put a RAMDISK kernel and SYS_UBOOT into hp300 installcd to make it bootable.

This should finally close PR/54455.

Fix tools build errors on Cygwin.

Appease warnings on building tools/installboot on Cygwin.
 1.110.2.1 02-Aug-2025  perseant Sync with HEAD
 1.41 10-Jul-2022  brook usr.sbin/installboot: Add a command line option (-u) to set U-Boot search paths

Installboot can install U-Boot boot blocks directly into a system
image. Normally, the U-Boot files are searched for in
/usr/pkg/share/u-boot, under the expectation that most people will
build them with pkgsrc. However, it is also possible to set an
environment variable (INSTALLBOOT_UBOOT_PATHS) to a colon-separated
search path to accommodate other situations. This commit adds a
command line option (-u) to set the search path; if present, it
overrides the environment and default.
 1.40 07-May-2019  thorpej Add installboot(8) support for evbarm (and, in the future, other evb*)
boards that use u-boot. A known board database lists boards and their
respective u-boot packages. u-boot packages are discovered at run-time
(in /usr/pkg/share/u-boot, by default). These packages contain board
database overlays that describe u-boot installation procedure that's
specific for that board.

Support this as a native tool and as a host tool. The native tool
will attempt to determine the running board type using OpenFirmware
calls. Host tool and native tool alike may also specify a board type
directly using the "-o board=xxx option" or have installboot(8) determine
the board type from a device tree blob using "-o dtb=/path/to/board.dtb".
A "-o media=xxx" option is provided for boards that have different u-boot
binaries and/or installation procedures for different media types (e.g.
SDMMC, eMMC, or USB).

This is trivial to extend to other evb* platforms that use u-boot, even if
they don't use FDT for autoconfiguration.
 1.39 25-Jul-2015  mlelstv branches: 1.39.16;
Handle getfsspecname errors.
 1.38 05-Jun-2015  mlelstv Can't use getfsspecname (and thus wedge names) while building tools.
 1.37 05-Jun-2015  mlelstv Support wedge names.
 1.36 03-Nov-2011  martin branches: 1.36.18;
Minor usage tweaks for SMALLPROG
 1.35 31-Aug-2011  joerg branches: 1.35.2;
Use __dead
 1.34 14-Jan-2010  drochner On i386/amd64, define two flag bits in the boot parameters which control
whether modules are loaded and whether boot.cfg is evaluated, and
set both to "off" per default in the PXE bootloader.
Extend "installboot" to toggle the bits.
This way, pxeboot works with existing dhcp server setups (and as
described in the manpage) out of the box. Also, boot.cfg reading
involves a stat() call which is horribly inefficient with the
TFTP pseudo file system.
 1.33 14-Jan-2010  tsutsui Remove if defined(__RCSID) around __RCSID() macro.
#include "nbtool_config.h" is enough for tools.
 1.32 07-Jan-2010  tsutsui Add a sectorsize parameter member in struct ib_params and use it
where sector size (disk block size) is required, instead of
DEV_BSIZE constant which means device I/O block size.

"Looks reasonable" from dholland@, and fixes tools installboot(8)
on Cygwin where DEV_BSIZE != 512 as mentioned in PR toolchain/42555.
 1.31 05-Apr-2009  lukem fix sign-compare issues
 1.30 28-Apr-2008  martin branches: 1.30.8;
Remove clause 3 and 4 from TNF licenses
 1.29 06-Mar-2008  dsl branches: 1.29.2;
Don't treat -f and an invalid flag.
Report the hex value of unknown unsupported (for the specified arch) flags.
 1.28 15-Feb-2007  dsl branches: 1.28.4; 1.28.8;
Add a -f (force) parameter to installboot(8).
If specified then checks on the disks BPB are not done, and any existing BPB
is deleted.
This is needed soince newfs(8) doesn't overwrite the BPB - which is basically
the FAT superblock.
Update documentation and add an example of using bootxx_fat16.
 1.27 22-Oct-2006  christos fix initializers
 1.26 22-Apr-2006  christos Coverity CID 55: Do things in a different order to appease coverity.
 1.25 22-Feb-2006  dogcow Since installboot is part of tools, and TIOCGWINSZ is not present on all
systems (PR/32878), make the window sizing stuff conditional.

Also, fix formatting of 'supported file system types are' line.
 1.24 18-Feb-2006  dsl Ignore entre is in the 'machines' table that have no name.
Use terminal with to break line of machine names.
 1.23 18-Feb-2006  dsl Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.22 26-Dec-2005  jmmv Installing the primary bootstrap requires two arguments, so ensure they are
present. Otherwise, an assertion is triggered (and core is dumped) in the
MD setboot code (just try 'installboot /dev/fd0a' on, e.g., i386).
 1.21 12-Nov-2005  dsl Don't try to determine the type of the target filesystem unless a second
stage bootstrap is specified. It is only needed when we need to copy the
sector numbers of the second stage into the first stage.
Document that a configured baud rate of zero will cause the baud rate set by
the bios to be used.
 1.20 11-Nov-2005  wiz Sync usage with man page (sort options).
 1.19 11-Nov-2005  dsl Add a -e (edit) option to allow the bootstrap options of an installed
bootstrap or a file containing such a bootstrap to be changed/displayed.
In particular this will (soon) let you modify the parameters for pxeboot.
 1.18 10-Jul-2005  isaki Use errx() rather than err() where appropriate.
 1.17 15-Aug-2004  dsl Add an option to set bp_consaddr (serial console IO port address)
Only complain about small patch area if we would write something non-zero there.
 1.16 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.15 13-Mar-2004  dsl branches: 1.15.2;
Add a -o keymap=zyz option that will set the boot keymap.
If a character in the map is typed, it gets replaced by the one following.
 1.14 05-Jan-2004  jmmv Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
 1.13 08-May-2003  petrov Format fixes.
 1.12 29-Apr-2003  dsl Change 'ulong' to 'unsigned long' so it compiles as a host tool on freebsd.
 1.11 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.10 20-May-2002  lukem - clean up display of supported machines & fstypes to ensure that last
column gets a trailing "," if there's more entries to come.
- if getmachines() or getfstypes() is called with 3 NULL params, just
print the list of supported items.
- in usage(), call getmachines() and getfstypes() with 3 NULL params.
(i got sick of typing "installboot -m asdf" to get a list of
supported machines during testing :)
 1.9 15-May-2002  lukem - add fsstat (fstat(2) on fsfd) and s1stat (fstat(2) on s1fd) in ib_params,
and use instead of replicating the effort in various locations
- if filesystem is not a regular file, use sync(2) instead of fsync(2)
after the bootstrap has been written
- move <sys/stat.h> and <stdint.h> into "installboot.h"
 1.8 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.7 30-Apr-2002  lukem add some more assert()s
 1.6 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.5 12-Apr-2002  lukem - support optional secondary bootstrap arg for install (unused by
existing backends, but future ones need it)
- use "bootstrap" instead of "boot block" in various messages where appropriate
- rename some members of ib_params
 1.4 12-Apr-2002  lukem run fsync on the fsfd before closing
 1.3 11-Apr-2002  lukem - add no_parseopt(), no_setboot() and no_clearboot() methods for back-ends
to use when they don't support a particular method
- don't automatically generate machines.c anymore
- add entries for i386 (temporarily unsupported) and shark
(permanently unsupported)
 1.2 04-Apr-2002  simonb Include <limits.h> to explicitly get LONG_MAX.
 1.1 03-Apr-2002  lukem Machine independent "unified" installboot(8).
Currently only supports vax, with more MD back-ends to be added RSN.
 1.15.2.1 22-Jun-2004  tron Pull up revision 1.16 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.28.8.1 24-Mar-2008  keiichi sync with head.
 1.28.4.1 23-Mar-2008  matt sync with HEAD
 1.29.2.1 18-May-2008  yamt sync with head.
 1.30.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.35.2.1 10-Nov-2011  yamt sync with head
 1.36.18.2 30-Jul-2015  snj Pull up following revision(s) (requested by mlelstv in ticket #900):
sbin/newfs/newfs.c: revision 1.113
usr.sbin/installboot/installboot.c: revision 1.39
Handle getfsspecname errors.
 1.36.18.1 16-Jul-2015  snj Pull up following revision(s) (requested by mlelstv in ticket #844):
usr.sbin/installboot/Makefile: revisions 1.49, 1.50
usr.sbin/installboot/installboot.c: revisions 1.37, 1.38
usr.sbin/installboot/arch/amiga.c: revision 1.9
Support wedge names.
--
Can't use getfsspecname (and thus wedge names) while building tools.
--
Linking against libutil is not appropiate for tools.
--
Compute bootloader checksum correctly also on little endian systems.
 1.39.16.1 10-Jun-2019  christos Sync with HEAD
 1.47 05-Oct-2025  thorpej Add riscv.
 1.46 22-May-2024  tsutsui Remove no-op emips stuff.

It seems blindly copied and modified from pmax, but emips bootloader
can be specified by "Ml40x_2ace.plx" config file on the Giano simulator.
(not sure what on the real Xilinx ML401 board, but maybe hardcoded)
 1.45 19-May-2024  tsutsui Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.
 1.44 19-May-2024  tsutsui Reorder function prototypes per source files.
 1.43 10-Jul-2022  brook branches: 1.43.2;
usr.sbin/installboot: Add a command line option (-u) to set U-Boot search paths

Installboot can install U-Boot boot blocks directly into a system
image. Normally, the U-Boot files are searched for in
/usr/pkg/share/u-boot, under the expectation that most people will
build them with pkgsrc. However, it is also possible to set an
environment variable (INSTALLBOOT_UBOOT_PATHS) to a colon-separated
search path to accommodate other situations. This commit adds a
command line option (-u) to set the search path; if present, it
overrides the environment and default.
 1.42 21-Jun-2020  thorpej Add evbmips support for u-boot handling.
 1.41 15-Aug-2019  kamil Add missing extern declaration of ib_mach_emips in installboot

Change added for the consistency with the existing code.
 1.40 07-May-2019  thorpej branches: 1.40.2;
Add installboot(8) support for evbarm (and, in the future, other evb*)
boards that use u-boot. A known board database lists boards and their
respective u-boot packages. u-boot packages are discovered at run-time
(in /usr/pkg/share/u-boot, by default). These packages contain board
database overlays that describe u-boot installation procedure that's
specific for that board.

Support this as a native tool and as a host tool. The native tool
will attempt to determine the running board type using OpenFirmware
calls. Host tool and native tool alike may also specify a board type
directly using the "-o board=xxx option" or have installboot(8) determine
the board type from a device tree blob using "-o dtb=/path/to/board.dtb".
A "-o media=xxx" option is provided for boards that have different u-boot
binaries and/or installation procedures for different media types (e.g.
SDMMC, eMMC, or USB).

This is trivial to extend to other evb* platforms that use u-boot, even if
they don't use FDT for autoconfiguration.
 1.39 24-Feb-2014  skrll branches: 1.39.18; 1.39.26;
Rename NetBSD/hp700 to NetBSD/hppa.

Unfortunately our VCS isn't very helpful here.
 1.38 14-Jun-2011  matt branches: 1.38.2; 1.38.8;
A small bit of constification
 1.37 14-Jan-2010  drochner branches: 1.37.4;
On i386/amd64, define two flag bits in the boot parameters which control
whether modules are loaded and whether boot.cfg is evaluated, and
set both to "off" per default in the PXE bootloader.
Extend "installboot" to toggle the bits.
This way, pxeboot works with existing dhcp server setups (and as
described in the manpage) out of the box. Also, boot.cfg reading
involves a stat() call which is horribly inefficient with the
TFTP pseudo file system.
 1.36 07-Jan-2010  tsutsui Add a sectorsize parameter member in struct ib_params and use it
where sector size (disk block size) is required, instead of
DEV_BSIZE constant which means device I/O block size.

"Looks reasonable" from dholland@, and fixes tools installboot(8)
on Cygwin where DEV_BSIZE != 512 as mentioned in PR toolchain/42555.
 1.35 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.34 02-Feb-2008  tsutsui branches: 1.34.4;
Add a findstage2 function (which returns block numbers where
the secondary boot is stored to embed them into the primary bootxx)
for ext2fs.

Currently disabled because there is no primary boot block
which supports ext2fs, but it might help someone in some day.
 1.33 15-Feb-2007  dsl branches: 1.33.4;
Add a -f (force) parameter to installboot(8).
If specified then checks on the disks BPB are not done, and any existing BPB
is deleted.
This is needed soince newfs(8) doesn't overwrite the BPB - which is basically
the FAT superblock.
Update documentation and add an example of using bootxx_fat16.
 1.32 01-Sep-2006  uwe NetBSD/landisk support.
 1.31 20-Jun-2006  jdc Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition. Tested on sparc.

Reviewed by gdt.
 1.30 18-Feb-2006  dsl Best to declare these structures 'extern' ...
 1.29 18-Feb-2006  dsl Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.28 29-Dec-2005  tsutsui Add ews4800mips support.
 1.27 11-Nov-2005  dsl Add a -e (edit) option to allow the bootstrap options of an installed
bootstrap or a file containing such a bootstrap to be changed/displayed.
In particular this will (soon) let you modify the parameters for pxeboot.
 1.26 14-May-2005  chs add hp700 support.
 1.25 15-Aug-2004  dsl branches: 1.25.2;
Add an option to set bp_consaddr (serial console IO port address)
Only complain about small patch area if we would write something non-zero there.
 1.24 13-Mar-2004  dsl Add a -o keymap=zyz option that will set the boot keymap.
If a character in the map is typed, it gets replaced by the one following.
 1.23 08-Nov-2003  dsl First cut of hp300 installboot, seems to DTRT on i386.
Maybe this code ought to know how to add a file to the LIF filesystem.
 1.22 27-Oct-2003  cl add next68k support to installboot
 1.21 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.20 27-Jul-2003  lukem Explicitly pull in <sys/endian.h> #if !defined(HAVE_CONFIG_H).
(I prefer to be explicit about this, since installboot uses the endian
macros a lot)
 1.19 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.18 09-Apr-2003  dsl Add support for i386 boot code - for new bootxx stuff
 1.17 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.16 15-Jan-2003  mhitch Add support for amiga.
 1.15 03-Oct-2002  lukem correct comment
 1.14 02-Jun-2002  isaki Add x68k stuff.
 1.13 20-May-2002  lukem - use uint8_t instead of char for boot block blobs
- bbinfo_params:
- replace "int littleendian" with "bbinfo_endian endian"
- add comments
- shared_bbinfo_clearboot():
- add callback method to shared_bbinfo_clearboot()
- don't clear from 0..headeroffset; use a callback to do that
- add news68k and newsmips support.
From Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, with a rework by me to
take advantage of the new shared_bbinfo_clearboot() callback.
(XXX: untested yet)
 1.12 15-May-2002  lukem bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
and sun68k_bbinfo (296 byte, with 64 block entries)
into shared_bbinfo (512 bytes, with 118 block entries),
which will be also shared by future bbinfo-using platforms
(including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
perform the majority of the work for bbinfo-using back-ends
(rather than replicating that across multiple back-ends).
 1.11 15-May-2002  lukem - add fsstat (fstat(2) on fsfd) and s1stat (fstat(2) on s1fd) in ib_params,
and use instead of replicating the effort in various locations
- if filesystem is not a regular file, use sync(2) instead of fsync(2)
after the bootstrap has been written
- move <sys/stat.h> and <stdint.h> into "installboot.h"
 1.10 14-May-2002  lukem pull in <sys/bootblock.h> in "installboot.h" instead of in arch/*.c
(and remove <dev/dec/dec_boot.h>, since <sys/bootblock.h> has that stuff now)
 1.9 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.8 06-May-2002  pk Add sparc module.
 1.7 30-Apr-2002  lukem implement "raw" file system type. this can be used when the primary
bootstrap is being installed at a particular block offset and the underlying
filesystem doesn't matter (e.g, alpha ustarboot in ustar floppies)
 1.6 22-Apr-2002  lukem Add sun2 backend from Matthew Fredette.
(Implemented with "sun68k.c" as it should eventually support "sun3" as well.)
 1.5 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.4 12-Apr-2002  lukem - support optional secondary bootstrap arg for install (unused by
existing backends, but future ones need it)
- use "bootstrap" instead of "boot block" in various messages where appropriate
- rename some members of ib_params
 1.3 11-Apr-2002  lukem - add no_parseopt(), no_setboot() and no_clearboot() methods for back-ends
to use when they don't support a particular method
- don't automatically generate machines.c anymore
- add entries for i386 (temporarily unsupported) and shark
(permanently unsupported)
 1.2 04-Apr-2002  bjh21 Pull in config.h as necessary to get byte-order macros etc.
 1.1 03-Apr-2002  lukem Machine independent "unified" installboot(8).
Currently only supports vax, with more MD back-ends to be added RSN.
 1.25.2.1 09-Nov-2006  tron Pull up following revision(s) (requested by bad in ticket #1524):
usr.sbin/installboot/installboot.8: revision 1.54 via patch
usr.sbin/installboot/installboot.h: revision 1.31
usr.sbin/installboot/fstypes.c: revision 1.9
usr.sbin/installboot/ffs.c: revision 1.19
Add support for finding files on RAID partitions. This allows us to
add the block list of the 2nd stage boot loader to the 1st stage boot
loader when the partition is a RAID partition. Tested on sparc.
Reviewed by gdt.
 1.33.4.1 23-Mar-2008  matt sync with HEAD
 1.34.4.1 18-May-2008  yamt sync with head.
 1.37.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.38.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.39.26.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.39.26.1 10-Jun-2019  christos Sync with HEAD
 1.39.18.1 07-May-2021  martin Pull up following revision(s) (requested by mrg in ticket #1678):

bin/pax/options.c: revision 1.119
usr.bin/config/scan.l: revision 1.32
usr.bin/make/main.c: revision 1.274
bin/pax/extern.h: revision 1.60
usr.bin/config/defs.h: revision 1.106
usr.bin/make/make.h: revision 1.105
sbin/newfs_udf/udf_create.c: revision 1.27 (patch)
sbin/newfs_udf/newfs_udf.h: revision 1.7 (patch)
usr.bin/config/main.c: revision 1.100
usr.sbin/installboot/Makefile: revisions 1.53,1.54 (patch)
usr.sbin/installboot/installboot.h: revision 1.41 (patch)
usr.sbin/installboot/machines.c: revisisons 1.41,1.42 (patch)

Avoid depending on common symbols.
 1.40.2.1 16-Aug-2019  martin Pull up following revision(s) (requested by kamil in ticket #67):

usr.sbin/installboot/installboot.h: revision 1.41

Add missing extern declaration of ib_mach_emips in installboot

Change added for the consistency with the existing code.
 1.43.2.1 22-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #722):

sys/fs/cd9660/cd9660_util.c: revision 1.16
sys/arch/hp300/stand/common/clock.c: revision 1.14
sys/arch/hp300/stand/common/scsireg.h: revision 1.5
sys/arch/hp300/stand/common/scsireg.h: revision 1.6
sys/arch/hp300/stand/Makefile.buildboot: revision 1.38
sys/arch/hp300/include/bus.h: revision 1.23
sys/arch/hp300/stand/Makefile.buildboot: revision 1.39
sys/arch/hp300/stand/common/sd.c: revision 1.12
sys/arch/hp300/stand/common/prf.c: revision 1.6
sys/arch/hp300/stand/common/sd.c: revision 1.13
usr.sbin/installboot/installboot.8: revision 1.106
usr.sbin/installboot/Makefile: revision 1.59
sys/arch/hp300/stand/common/devopen.c: revision 1.14
usr.sbin/installboot/installboot.8: revision 1.107
sys/arch/hp300/stand/common/ite_dumb.c: revision 1.2
sys/arch/hp300/stand/common/devopen.c: revision 1.15
usr.sbin/installboot/installboot.8: revision 1.108
sys/fs/cd9660/cd9660_extern.h: revision 1.29
usr.sbin/installboot/installboot.8: revision 1.109
tools/Makefile.nbincludes: revision 1.11 (patch)
sys/arch/hp300/dev/rboxreg.h: revision 1.3
sys/arch/hp300/stand/common/scsivar.h: revision 1.5
sys/arch/hp300/dev/dnkbd.c: revision 1.14
sys/arch/hp300/hp300/trap.c: revision 1.156
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.12
sys/arch/hp300/dev/frodoreg.h: revision 1.6
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.13
sys/arch/hp300/stand/common/ite_sti.c: revision 1.2
sys/arch/hp300/stand/common/hil.c: revision 1.15
usr.sbin/installboot/arch/hp300.c: revision 1.18
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.14
sys/arch/hp300/dev/rbox.c: revision 1.4
usr.sbin/installboot/arch/hp300.c: revision 1.19
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.15
sys/sys/bootblock.h: revision 1.59
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.16
usr.sbin/installboot/installboot.h: revision 1.44
sys/arch/hp300/stand/mkboot/volhdr.h: file removal
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.17
sys/arch/hp300/dev/hpib.c: revision 1.45
usr.sbin/installboot/installboot.h: revision 1.45
usr.sbin/installboot/cd9660.c: revision 1.1
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.18
sys/arch/hp300/dev/topcatreg.h: revision 1.3
usr.sbin/installboot/cd9660.c: revision 1.2
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.19
sys/arch/hp300/stand/inst/inst.c: revision 1.25
sys/arch/hp300/stand/uboot/Makefile: revision 1.12
sys/arch/hp300/dev/dvbox.c: revision 1.4
sys/arch/hp300/dev/dma.c: revision 1.45
sys/arch/hp300/stand/uboot/Makefile: revision 1.13
sys/arch/hp300/stand/common/rd.c: revision 1.16
sys/arch/hp300/stand/inst/Makefile: revision 1.12
distrib/hp300/cdroms/installcd/Makefile: revision 1.4
sys/arch/hp300/stand/mkboot/volhdr.h: revision 1.6
sys/arch/hp300/stand/common/machdep.c: revision 1.16
usr.sbin/installboot/fstypes.c: revision 1.14
sys/arch/hp300/hp300/machdep.c: revision 1.238
sys/arch/hp300/include/cpu.h: revision 1.73
sys/arch/hp300/dev/diofbreg.h: revision 1.4
sys/arch/hp300/stand/common/scsi.c: revision 1.12
sys/arch/hp300/stand/common/netio.c: revision 1.19
sys/arch/hp300/stand/common/scsi.c: revision 1.13
sys/arch/hp300/dev/sti_sgc.c: revision 1.8
sys/arch/hp300/dev/rtc.c: revision 1.22
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.20
sys/arch/hp300/stand/common/conf.h: revision 1.4
sys/arch/hp300/hp300/autoconf.c: revision 1.111
sys/arch/hp300/stand/common/conf.c: revision 1.15
sys/arch/hp300/stand/mkboot/Makefile: revision 1.12
sys/arch/hp300/stand/mkboot/Makefile: revision 1.13
sys/arch/hp300/hp300/autoconf.c: revision 1.114
sys/arch/hp300/dev/dcmreg.h: revision 1.11
sys/arch/hp300/dev/diofbvar.h: revision 1.4
sys/arch/hp300/dev/dcm.c: revision 1.91
sys/fs/cd9660/cd9660_util.c: revision 1.15
sys/arch/hp300/dev/mcclock_frodo.c: revision 1.2

TAB/space cleanup.

installboot(8): formatting improvements

Use Ar foo instead of <foo>; this is mdoc.

Other formatting tweaks.
installboot(8): fix up markup

Don't overuse .Sy - when everything is highlighted, nothing is. Use
.Ic for options &c to get correct PostScript output (both are bold in
plain text).

Use Aq Ar inside .Pa, as both Pa and Ar are rendered as underscored
text in plain text output, and the distinction is lost.

Don't set examples in bold, but give them .Pp space around - they are
much easier to read this way.

Use consistent -width in FILES.
document how to use installboot on netbsd/vax.

PR/57909: Jan-Benedict Glaw: Don't include (build) timestamp when doing a
reproducible build
fix usage string, improve error handling.
add missing chunk for repro-build. fix gcc warnings.
avoid stringop truncation, fix copyright string to prevent assembler warnings.

Fix build as a tool (Jan-Benedict Glaw)

Fix integer overflow of strtol(3) for "loadpoint" address on ILP32 hosts.

This strtol(3) was introduced in rev 1.12 for PR/57909 after netbsd-10,
but it returns LONG_MAX (0x7FFFFFFF) for 0xFFF00000 on ILP32 hosts and
the wrong loadpoint causes "NOT ENOUGH MEMORY" error by the BOOTROMs
on loading uboot.lif on (at least) my 9000/360 and 9000/425t.

Misc cosmetic changes for mostly readability.
- KNF and add some newlines per blocks
- define and use proper bintobcd() macro
- make local functions and variables static

The same uboot.lif binaries are generated.

Rename ${PROGAOUT} -> ${PROGELF} to reflect reality.
Use proper signedness for the LIF file system data structures.

Ancient 4.3BSD used short and int for location, file size, file type,
and addresses etc. but all of them should be unsigned.

Also rename several variables and add comments for readability.
The LIF file system info can be found in "The HPDir Project" page:
https://www.hp9845.net/9845/projects/hpdir/
The same uboot.lif binaries are generated.

Add a preliminary CD boot support to uboot for preparation of PR/54455.
Briefly tested on mame, but not enalbed yet.

Recognize SCSI CD-ROM devices as a booted device properly.

Necessary for PR port-hp300/54455, to boot an md root root RAMDISK

kernel from CD-ROM without "WARNING: can't find match for bootdev:"
prompt.

Sync with src/sys/arch/hp300/stand/mkboot/volhdr.h rev 1.6.
https://mail-index.netbsd.org/source-changes/2024/05/07/msg151195.html

Use proper signedness for the LIF file system data structures.
mkboot should use this MI <sys/bootblock.h> and volhdr.h should
be removed soon.

Use MI <sys/bootblock.h> to refer LIF filesystem structures.
This should have been done when LIF definitions were initially added
to <sys/bootblock.h> for MI installboot(8).

Enable SUPPORT_CD on uboot.

Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.

Install cd9660 related system headers for tools installboot(8) builds.

Reorder function prototypes per source files.

Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.

Put a RAMDISK kernel and SYS_UBOOT into hp300 installcd to make it bootable.

This should finally close PR/54455.

Fix tools build errors on Cygwin.

Appease warnings on building tools/installboot on Cygwin.
 1.45 05-Oct-2025  thorpej Add riscv.
 1.44 22-May-2024  tsutsui Remove no-op emips stuff.

It seems blindly copied and modified from pmax, but emips bootloader
can be specified by "Ml40x_2ace.plx" config file on the Giano simulator.
(not sure what on the real Xilinx ML401 board, but maybe hardcoded)
 1.43 21-Jun-2020  thorpej Add evbmips support for u-boot handling.
 1.42 15-Aug-2019  martin Never trust a compiler that predefines i386 as 1 - do the symbol name
concatenation at the make level instead.
 1.41 15-Aug-2019  martin Replace black voodo linker magic (sometimes failing) with some
makefile + macro magic to trim the list of available machines on size
restricted install media.
 1.40 07-May-2019  thorpej branches: 1.40.2;
Add installboot(8) support for evbarm (and, in the future, other evb*)
boards that use u-boot. A known board database lists boards and their
respective u-boot packages. u-boot packages are discovered at run-time
(in /usr/pkg/share/u-boot, by default). These packages contain board
database overlays that describe u-boot installation procedure that's
specific for that board.

Support this as a native tool and as a host tool. The native tool
will attempt to determine the running board type using OpenFirmware
calls. Host tool and native tool alike may also specify a board type
directly using the "-o board=xxx option" or have installboot(8) determine
the board type from a device tree blob using "-o dtb=/path/to/board.dtb".
A "-o media=xxx" option is provided for boards that have different u-boot
binaries and/or installation procedures for different media types (e.g.
SDMMC, eMMC, or USB).

This is trivial to extend to other evb* platforms that use u-boot, even if
they don't use FDT for autoconfiguration.
 1.39 24-Feb-2014  skrll branches: 1.39.18; 1.39.26;
Rename NetBSD/hp700 to NetBSD/hppa.

Unfortunately our VCS isn't very helpful here.
 1.38 14-Jun-2011  matt branches: 1.38.2; 1.38.8;
A small bit of constification
 1.37 26-Jan-2011  pooka branches: 1.37.2;
Add support for the Extensible MIPS ("eMIPS") platform. The
NetBSD/emips port runs on Xilinx and Beecube FPGA systems and the
Giano system simulator.

eMIPS is a platform developed at Microsoft Research for researching
reconfigurable computing. eMIPS allows dynamic loading and scheduling
of application-specific circuits for the purpose of accelerating
computations based on the current workload.

NetBSD eMIPS support for NetBSD 4.x was written at Microsoft Research
by Alessandro Forin and Neil Pittman. Microsoft Corporation has
donated full copyright to The NetBSD Foundation.

Platform support for eMIPS is the first part of Microsoft's
contribution. The second part includes the hardware accelerator
framework and will be proposed on tech-kern soon.
 1.36 14-Jan-2010  tsutsui branches: 1.36.2;
Remove if defined(__RCSID) around __RCSID() macro.
#include "nbtool_config.h" is enough for tools.
 1.35 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.34 01-Sep-2006  uwe branches: 1.34.16;
NetBSD/landisk support.
 1.33 18-Feb-2006  dsl Define the ib_mach_xxx entries here in a way that will allocate them into
the bss if the MD file isn't linked into the installboot image.
 1.32 18-Feb-2006  dsl Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.31 29-Dec-2005  tsutsui Add ews4800mips support.
 1.30 14-Nov-2005  lukem Update copyright years.
Whitespace tweaks.
 1.29 11-Nov-2005  dsl Add a -e (edit) option to allow the bootstrap options of an installed
bootstrap or a file containing such a bootstrap to be changed/displayed.
In particular this will (soon) let you modify the parameters for pxeboot.
 1.28 16-Jul-2005  hannken Add option `ioaddr=<ioaddr>' to amd64. Already noted in man page.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.27 12-Jun-2005  dyoung Build hp300 support into installboot(8).
 1.26 14-May-2005  chs add hp700 support.
 1.25 15-Aug-2004  dsl Add an option to set bp_consaddr (serial console IO port address)
Only complain about small patch area if we would write something non-zero there.
 1.24 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.23 13-Mar-2004  dsl branches: 1.23.2;
Add a -o keymap=zyz option that will set the boot keymap.
If a character in the map is typed, it gets replaced by the one following.
 1.22 14-Nov-2003  lukem Disable hp300 support (again).
This code is not to be reenabled again until it is fixed to my satisfaction
(as a member of core and the person who ends up dealing with most of
the host tool build bugs)
 1.21 13-Nov-2003  dsl roundup() write of hp300 boot code to a multiplr of the disk sector size.
and re-instate the hp300 code - seems to work.
 1.20 10-Nov-2003  fvdl Comment out hp300 references.
 1.19 08-Nov-2003  dsl First cut of hp300 installboot, seems to DTRT on i386.
Maybe this code ought to know how to add a file to the LIF filesystem.
 1.18 27-Oct-2003  cl add next68k support to installboot
 1.17 30-Aug-2003  fvdl Add amd64 to list of supported machines (does the same as i386).
 1.16 27-Jul-2003  lukem rcsid
 1.15 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.14 09-Apr-2003  dsl Add support for i386 boot code - for new bootxx stuff
 1.13 15-Jan-2003  mhitch Add support for amiga.
 1.12 02-Jun-2002  isaki Add x68k stuff.
 1.11 20-May-2002  lukem - use uint8_t instead of char for boot block blobs
- bbinfo_params:
- replace "int littleendian" with "bbinfo_endian endian"
- add comments
- shared_bbinfo_clearboot():
- add callback method to shared_bbinfo_clearboot()
- don't clear from 0..headeroffset; use a callback to do that
- add news68k and newsmips support.
From Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, with a rework by me to
take advantage of the new shared_bbinfo_clearboot() callback.
(XXX: untested yet)
 1.10 17-May-2002  lukem Enable sun3, using same sun68k backend as sun2.

XXX: sun3 port still needs to be cut over to using sun68k bootxx...
 1.9 15-May-2002  lukem bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
and sun68k_bbinfo (296 byte, with 64 block entries)
into shared_bbinfo (512 bytes, with 118 block entries),
which will be also shared by future bbinfo-using platforms
(including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
perform the majority of the work for bbinfo-using back-ends
(rather than replicating that across multiple back-ends).
 1.8 06-May-2002  pk Add sparc module.
 1.7 22-Apr-2002  lukem Add sun2 backend from Matthew Fredette.
(Implemented with "sun68k.c" as it should eventually support "sun3" as well.)
 1.6 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.5 11-Apr-2002  lukem - add no_parseopt(), no_setboot() and no_clearboot() methods for back-ends
to use when they don't support a particular method
- don't automatically generate machines.c anymore
- add entries for i386 (temporarily unsupported) and shark
(permanently unsupported)
 1.4 04-Apr-2002  lukem Add sparc64 back-end, contributed by Matthew Green.
 1.3 03-Apr-2002  lukem Add support for alpha, based on {vax,pmax}.c and
sys/arch/alpha/stand/installboot.
XXX: not fully tested yet.
 1.2 03-Apr-2002  lukem Add pmax installboot back-end; from vax.c and arch/pmax/stand/installboot/*.
XXX: not tested yet.
 1.1 03-Apr-2002  lukem replace machines.c rebuild with "regenmachines", which needs to be run
manually
 1.23.2.1 22-Jun-2004  tron Pull up revision 1.24 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.34.16.1 18-May-2008  yamt sync with head.
 1.36.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.37.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.38.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.39.26.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.39.26.1 10-Jun-2019  christos Sync with HEAD
 1.39.18.1 07-May-2021  martin Pull up following revision(s) (requested by mrg in ticket #1678):

bin/pax/options.c: revision 1.119
usr.bin/config/scan.l: revision 1.32
usr.bin/make/main.c: revision 1.274
bin/pax/extern.h: revision 1.60
usr.bin/config/defs.h: revision 1.106
usr.bin/make/make.h: revision 1.105
sbin/newfs_udf/udf_create.c: revision 1.27 (patch)
sbin/newfs_udf/newfs_udf.h: revision 1.7 (patch)
usr.bin/config/main.c: revision 1.100
usr.sbin/installboot/Makefile: revisions 1.53,1.54 (patch)
usr.sbin/installboot/installboot.h: revision 1.41 (patch)
usr.sbin/installboot/machines.c: revisisons 1.41,1.42 (patch)

Avoid depending on common symbols.
 1.40.2.1 21-Aug-2019  msaitoh Pull up following revision(s) (requested by martin in ticket #80):
usr.sbin/installboot/Makefile: revision 1.53
usr.sbin/installboot/Makefile: revision 1.54
usr.sbin/installboot/machines.c: revision 1.41
usr.sbin/installboot/machines.c: revision 1.42
Replace black voodo linker magic (sometimes failing) with some
makefile + macro magic to trim the list of available machines on size
restricted install media.
Never trust a compiler that predefines i386 as 1 - do the symbol name
concatenation at the make level instead.
 1.2 11-Apr-2002  lukem - add no_parseopt(), no_setboot() and no_clearboot() methods for back-ends
to use when they don't support a particular method
- don't automatically generate machines.c anymore
- add entries for i386 (temporarily unsupported) and shark
(permanently unsupported)
 1.1 03-Apr-2002  lukem Machine independent "unified" installboot(8).
Currently only supports vax, with more MD back-ends to be added RSN.
 1.2 03-Apr-2002  lukem Migrate MD files to arch/ subdir. Suggested by Hubert Feyrer.
 1.1 03-Apr-2002  lukem Add pmax installboot back-end; from vax.c and arch/pmax/stand/installboot/*.
XXX: not tested yet.
 1.5 14-Jan-2010  tsutsui Remove if defined(__RCSID) around __RCSID() macro.
#include "nbtool_config.h" is enough for tools.
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 20-Jun-2004  jmc branches: 1.3.24;
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.2 19-Apr-2002  lukem branches: 1.2.4;
- Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.1 03-Apr-2002  lukem Machine independent "unified" installboot(8).
Currently only supports vax, with more MD back-ends to be added RSN.
 1.2.4.1 22-Jun-2004  tron Pull up revision 1.3 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.3.24.1 18-May-2008  yamt sync with head.
 1.3 03-Apr-2002  lukem Migrate MD files to arch/ subdir. Suggested by Hubert Feyrer.
 1.2 03-Apr-2002  lukem whitespace foo
 1.1 03-Apr-2002  lukem Machine independent "unified" installboot(8).
Currently only supports vax, with more MD back-ends to be added RSN.
 1.22 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.21 14-Aug-2011  christos branches: 1.21.42;
fix various gcc-4.5 warnings
 1.20 26-Oct-2009  tsutsui A checksum value in alpha boot block is stored in little endian,
so use le64toh() to print it on the host tool.
While here, use consistent (unsignd long long) casts on printing it.
 1.19 05-Apr-2009  lukem fix sign-compare issues
 1.18 28-Apr-2008  martin branches: 1.18.8;
Remove clause 3 and 4 from TNF licenses
 1.17 18-Mar-2006  dsl branches: 1.17.18;
Coverty 7449: Change 'return (0)' to 'goto done' so we free(bootstrapbuf)
before exiting with error.
 1.16 18-Feb-2006  dsl Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.15 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.14 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.13 20-Jul-2002  grant sweep of errx/warnx, remove unnecessary trailing \n
 1.12 31-May-2002  matt Use to htobe16, not htons
 1.11 15-May-2002  lukem branches: 1.11.2;
- add fsstat (fstat(2) on fsfd) and s1stat (fstat(2) on s1fd) in ib_params,
and use instead of replicating the effort in various locations
- if filesystem is not a regular file, use sync(2) instead of fsync(2)
after the bootstrap has been written
- move <sys/stat.h> and <stdint.h> into "installboot.h"
 1.10 14-May-2002  lukem pull in <sys/bootblock.h> in "installboot.h" instead of in arch/*.c
(and remove <dev/dec/dec_boot.h>, since <sys/bootblock.h> has that stuff now)
 1.9 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.8 30-Apr-2002  lukem display sector start & count in decimal rather than hex
 1.7 25-Apr-2002  tv HAVE_CONFIG_Hize. Also get *_boot.h from "../../sys/" when HAVE_CONFIG_H,
rather than creating more stubs.
 1.6 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.5 12-Apr-2002  lukem - support optional secondary bootstrap arg for install (unused by
existing backends, but future ones need it)
- use "bootstrap" instead of "boot block" in various messages where appropriate
- rename some members of ib_params
 1.4 11-Apr-2002  lukem check size of reading bootblock against the correct size...
 1.3 04-Apr-2002  mrg LP64isms. also, be sure to use <string.h> if we use memset or memcpy.
 1.2 04-Apr-2002  lukem don't pull in <dev/sun/disklabel.h> just for SUN_DKMAGIC; instead,
provide local copy of that #define.
 1.1 03-Apr-2002  lukem Add support for alpha, based on {vax,pmax}.c and
sys/arch/alpha/stand/installboot.
XXX: not fully tested yet.
 1.11.2.1 31-May-2002  tv Pull up revision 1.12 (requested by matt in ticket #105):
Use to htobe16, not htons
 1.17.18.1 18-May-2008  yamt sync with head.
 1.18.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.21.42.1 10-Jun-2019  christos Sync with HEAD
 1.10 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.9 05-Jun-2015  mlelstv branches: 1.9.16;
Compute bootloader checksum correctly also on little endian systems.
 1.8 14-Jun-2013  msaitoh branches: 1.8.6;
Remove trailng whitespaces.
 1.7 14-Jan-2010  tsutsui branches: 1.7.6; 1.7.12;
Remove if defined(__RCSID) around __RCSID() macro.
#include "nbtool_config.h" is enough for tools.
 1.6 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5 18-Feb-2006  dsl branches: 1.5.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.4 02-Jun-2005  lukem Don't try to use an uninitialized variable.
Detected with gcc -Wuninitialized.
 1.3 20-Jun-2004  jmc branches: 1.3.2;
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.2 15-Apr-2003  dsl branches: 1.2.2;
Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.1 15-Jan-2003  mhitch Add support for amiga.
 1.2.2.1 22-Jun-2004  tron Pull up revision 1.3 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.3.2.1 15-Jun-2005  snj Pull up revision 1.4 (requested by lukem in ticket #411):
Don't try to use an uninitialized variable.
Detected with gcc -Wuninitialized.
 1.5.18.1 18-May-2008  yamt sync with head.
 1.7.12.1 23-Jun-2013  tls resync from head
 1.7.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.6.1 16-Jul-2015  snj Pull up following revision(s) (requested by mlelstv in ticket #844):
usr.sbin/installboot/Makefile: revisions 1.49, 1.50
usr.sbin/installboot/installboot.c: revisions 1.37, 1.38
usr.sbin/installboot/arch/amiga.c: revision 1.9
Support wedge names.
--
Can't use getfsspecname (and thus wedge names) while building tools.
--
Linking against libutil is not appropiate for tools.
--
Compute bootloader checksum correctly also on little endian systems.
 1.9.16.1 10-Jun-2019  christos Sync with HEAD
 1.3 22-May-2024  tsutsui Remove no-op emips stuff.

It seems blindly copied and modified from pmax, but emips bootloader
can be specified by "Ml40x_2ace.plx" config file on the Giano simulator.
(not sure what on the real Xilinx ML401 board, but maybe hardcoded)
 1.2 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.1 26-Jan-2011  pooka branches: 1.1.2; 1.1.46;
Add support for the Extensible MIPS ("eMIPS") platform. The
NetBSD/emips port runs on Xilinx and Beecube FPGA systems and the
Giano system simulator.

eMIPS is a platform developed at Microsoft Research for researching
reconfigurable computing. eMIPS allows dynamic loading and scheduling
of application-specific circuits for the purpose of accelerating
computations based on the current workload.

NetBSD eMIPS support for NetBSD 4.x was written at Microsoft Research
by Alessandro Forin and Neil Pittman. Microsoft Corporation has
donated full copyright to The NetBSD Foundation.

Platform support for eMIPS is the first part of Microsoft's
contribution. The second part includes the hardware accelerator
framework and will be proposed on tech-kern soon.
 1.1.46.1 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 08-Feb-2011  bouyer Sync with HEAD
 1.1.2.1 26-Jan-2011  bouyer file emips.c was added on branch bouyer-quota2 on 2011-02-08 16:20:15 +0000
 1.1 07-May-2019  thorpej branches: 1.1.2;
Add installboot(8) support for evbarm (and, in the future, other evb*)
boards that use u-boot. A known board database lists boards and their
respective u-boot packages. u-boot packages are discovered at run-time
(in /usr/pkg/share/u-boot, by default). These packages contain board
database overlays that describe u-boot installation procedure that's
specific for that board.

Support this as a native tool and as a host tool. The native tool
will attempt to determine the running board type using OpenFirmware
calls. Host tool and native tool alike may also specify a board type
directly using the "-o board=xxx option" or have installboot(8) determine
the board type from a device tree blob using "-o dtb=/path/to/board.dtb".
A "-o media=xxx" option is provided for boards that have different u-boot
binaries and/or installation procedures for different media types (e.g.
SDMMC, eMMC, or USB).

This is trivial to extend to other evb* platforms that use u-boot, even if
they don't use FDT for autoconfiguration.
 1.1.2.2 10-Jun-2019  christos Sync with HEAD
 1.1.2.1 07-May-2019  christos file evbarm.c was added on branch phil-wifi on 2019-06-10 22:10:30 +0000
 1.1 21-Jun-2020  thorpej Add evbmips support for u-boot handling.
 1.3 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.2 18-Feb-2006  dsl branches: 1.2.84;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.1 29-Dec-2005  tsutsui Add ews4800mips support.
 1.2.84.1 10-Jun-2019  christos Sync with HEAD
 1.22 05-Apr-2025  tsutsui Replace unnecessary pointer arith with array for readability.
 1.21 05-Apr-2025  tsutsui Cleanup hp300 LIF bootblock definitions.

- move LIF value definitions from MD mkboot to MI <sys/bootblock.h>
to share them between mkboot and MI installboot(8)
- rename variables and use proper macros for readability
- misc KNF
 1.20 30-Mar-2025  tsutsui Always read LIF volume/directory from stage1 even on cd9660 stage2 case.

mmap(2) against the bootstrap file in the target cd9660 could fail
because the sector size of ISO9660 is 2048 so each file could be
allocated at an offset not pagesize (4096 or 8192) aligned.

This could fail if stage1 (specified via "primary" arg on command line)
and stage2 (on the target filesystem) files are different, but
in "build.sh iso-image" case they are always identical.

The problem (build failures in auotomated builds for hp300 on Linux)
was reported by Jan-Benedict Glaw.

Should also be pulled up to netbsd-10.
 1.19 19-May-2024  tsutsui branches: 1.19.2;
Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.
 1.18 11-May-2024  tsutsui Sync with src/sys/arch/hp300/stand/mkboot/volhdr.h rev 1.6.

https://mail-index.netbsd.org/source-changes/2024/05/07/msg151195.html
> Use proper signedness for the LIF file system data structures.

mkboot should use this MI <sys/bootblock.h> and volhdr.h should
be removed soon.
 1.17 05-Dec-2021  msaitoh branches: 1.17.2;
s/maping/mapping/
 1.16 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.15 14-Jun-2013  msaitoh branches: 1.15.28;
Remove trailng whitespaces.
 1.14 03-May-2013  matt Make this build with the disk label change.
 1.13 10-Feb-2011  tsutsui branches: 1.13.4; 1.13.10;
Fix botch in previous revision. Sorry for a stupid change.
 1.12 07-Jan-2010  tsutsui branches: 1.12.2;
Add a sectorsize parameter member in struct ib_params and use it
where sector size (disk block size) is required, instead of
DEV_BSIZE constant which means device I/O block size.

"Looks reasonable" from dholland@, and fixes tools installboot(8)
on Cygwin where DEV_BSIZE != 512 as mentioned in PR toolchain/42555.
 1.11 05-Apr-2009  lukem fix sign-compare issues
 1.10 28-Apr-2008  martin branches: 1.10.8;
Remove clause 3 and 4 from TNF licenses
 1.9 02-Feb-2008  itohy branches: 1.9.4;
Change be32toh to htobe32 where applicable.
 1.8 02-Feb-2008  itohy d_npartitions field of struct disklabel is 16bit, not 32bit.
 1.7 18-Feb-2006  dsl branches: 1.7.10;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.6 12-Jun-2005  dyoung Oops, straggler: #include <nbinclude/sys/disklabel.h> if we're
building a host-tool.

XXX In hp300_setboot, quiet -Wunitialized: initialize secsize to
XXX HP300_SECTSIZE. Is this correct?
 1.5 12-Jun-2005  dyoung For portability, use 'unsigned int' instead of 'uint'.
 1.4 13-Nov-2003  dsl roundup() write of hp300 boot code to a multiplr of the disk sector size.
and re-instate the hp300 code - seems to work.
 1.3 10-Nov-2003  dsl Ensure we use the target disklabel.h, not the host one.
Read the disklabel directly from sector 2 instead of using DIOCGDINFO.
Expect the label to be big-endian.
Support -o append for real files.
 1.2 08-Nov-2003  uwe Don't use PRId64 in a host tool. Not all systems have the PRI*
macros (e.g. FreeBSD 4.x). Cast to long long int instead.
 1.1 08-Nov-2003  dsl First cut of hp300 installboot, seems to DTRT on i386.
Maybe this code ought to know how to add a file to the LIF filesystem.
 1.7.10.1 23-Mar-2008  matt sync with HEAD
 1.9.4.1 18-May-2008  yamt sync with head.
 1.10.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.12.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.13.10.1 23-Jun-2013  tls resync from head
 1.13.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.28.1 10-Jun-2019  christos Sync with HEAD
 1.17.2.2 12-Apr-2025  martin Pull up following revision(s) (requested by tsutsui in ticket #1088):

usr.sbin/installboot/arch/hp300.c: revision 1.20

Always read LIF volume/directory from stage1 even on cd9660 stage2 case.
mmap(2) against the bootstrap file in the target cd9660 could fail
because the sector size of ISO9660 is 2048 so each file could be
allocated at an offset not pagesize (4096 or 8192) aligned.

This could fail if stage1 (specified via "primary" arg on command line)
and stage2 (on the target filesystem) files are different, but
in "build.sh iso-image" case they are always identical.

The problem (build failures in auotomated builds for hp300 on Linux)
was reported by Jan-Benedict Glaw.
 1.17.2.1 22-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #722):

sys/fs/cd9660/cd9660_util.c: revision 1.16
sys/arch/hp300/stand/common/clock.c: revision 1.14
sys/arch/hp300/stand/common/scsireg.h: revision 1.5
sys/arch/hp300/stand/common/scsireg.h: revision 1.6
sys/arch/hp300/stand/Makefile.buildboot: revision 1.38
sys/arch/hp300/include/bus.h: revision 1.23
sys/arch/hp300/stand/Makefile.buildboot: revision 1.39
sys/arch/hp300/stand/common/sd.c: revision 1.12
sys/arch/hp300/stand/common/prf.c: revision 1.6
sys/arch/hp300/stand/common/sd.c: revision 1.13
usr.sbin/installboot/installboot.8: revision 1.106
usr.sbin/installboot/Makefile: revision 1.59
sys/arch/hp300/stand/common/devopen.c: revision 1.14
usr.sbin/installboot/installboot.8: revision 1.107
sys/arch/hp300/stand/common/ite_dumb.c: revision 1.2
sys/arch/hp300/stand/common/devopen.c: revision 1.15
usr.sbin/installboot/installboot.8: revision 1.108
sys/fs/cd9660/cd9660_extern.h: revision 1.29
usr.sbin/installboot/installboot.8: revision 1.109
tools/Makefile.nbincludes: revision 1.11 (patch)
sys/arch/hp300/dev/rboxreg.h: revision 1.3
sys/arch/hp300/stand/common/scsivar.h: revision 1.5
sys/arch/hp300/dev/dnkbd.c: revision 1.14
sys/arch/hp300/hp300/trap.c: revision 1.156
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.12
sys/arch/hp300/dev/frodoreg.h: revision 1.6
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.13
sys/arch/hp300/stand/common/ite_sti.c: revision 1.2
sys/arch/hp300/stand/common/hil.c: revision 1.15
usr.sbin/installboot/arch/hp300.c: revision 1.18
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.14
sys/arch/hp300/dev/rbox.c: revision 1.4
usr.sbin/installboot/arch/hp300.c: revision 1.19
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.15
sys/sys/bootblock.h: revision 1.59
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.16
usr.sbin/installboot/installboot.h: revision 1.44
sys/arch/hp300/stand/mkboot/volhdr.h: file removal
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.17
sys/arch/hp300/dev/hpib.c: revision 1.45
usr.sbin/installboot/installboot.h: revision 1.45
usr.sbin/installboot/cd9660.c: revision 1.1
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.18
sys/arch/hp300/dev/topcatreg.h: revision 1.3
usr.sbin/installboot/cd9660.c: revision 1.2
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.19
sys/arch/hp300/stand/inst/inst.c: revision 1.25
sys/arch/hp300/stand/uboot/Makefile: revision 1.12
sys/arch/hp300/dev/dvbox.c: revision 1.4
sys/arch/hp300/dev/dma.c: revision 1.45
sys/arch/hp300/stand/uboot/Makefile: revision 1.13
sys/arch/hp300/stand/common/rd.c: revision 1.16
sys/arch/hp300/stand/inst/Makefile: revision 1.12
distrib/hp300/cdroms/installcd/Makefile: revision 1.4
sys/arch/hp300/stand/mkboot/volhdr.h: revision 1.6
sys/arch/hp300/stand/common/machdep.c: revision 1.16
usr.sbin/installboot/fstypes.c: revision 1.14
sys/arch/hp300/hp300/machdep.c: revision 1.238
sys/arch/hp300/include/cpu.h: revision 1.73
sys/arch/hp300/dev/diofbreg.h: revision 1.4
sys/arch/hp300/stand/common/scsi.c: revision 1.12
sys/arch/hp300/stand/common/netio.c: revision 1.19
sys/arch/hp300/stand/common/scsi.c: revision 1.13
sys/arch/hp300/dev/sti_sgc.c: revision 1.8
sys/arch/hp300/dev/rtc.c: revision 1.22
sys/arch/hp300/stand/mkboot/mkboot.c: revision 1.20
sys/arch/hp300/stand/common/conf.h: revision 1.4
sys/arch/hp300/hp300/autoconf.c: revision 1.111
sys/arch/hp300/stand/common/conf.c: revision 1.15
sys/arch/hp300/stand/mkboot/Makefile: revision 1.12
sys/arch/hp300/stand/mkboot/Makefile: revision 1.13
sys/arch/hp300/hp300/autoconf.c: revision 1.114
sys/arch/hp300/dev/dcmreg.h: revision 1.11
sys/arch/hp300/dev/diofbvar.h: revision 1.4
sys/arch/hp300/dev/dcm.c: revision 1.91
sys/fs/cd9660/cd9660_util.c: revision 1.15
sys/arch/hp300/dev/mcclock_frodo.c: revision 1.2

TAB/space cleanup.

installboot(8): formatting improvements

Use Ar foo instead of <foo>; this is mdoc.

Other formatting tweaks.
installboot(8): fix up markup

Don't overuse .Sy - when everything is highlighted, nothing is. Use
.Ic for options &c to get correct PostScript output (both are bold in
plain text).

Use Aq Ar inside .Pa, as both Pa and Ar are rendered as underscored
text in plain text output, and the distinction is lost.

Don't set examples in bold, but give them .Pp space around - they are
much easier to read this way.

Use consistent -width in FILES.
document how to use installboot on netbsd/vax.

PR/57909: Jan-Benedict Glaw: Don't include (build) timestamp when doing a
reproducible build
fix usage string, improve error handling.
add missing chunk for repro-build. fix gcc warnings.
avoid stringop truncation, fix copyright string to prevent assembler warnings.

Fix build as a tool (Jan-Benedict Glaw)

Fix integer overflow of strtol(3) for "loadpoint" address on ILP32 hosts.

This strtol(3) was introduced in rev 1.12 for PR/57909 after netbsd-10,
but it returns LONG_MAX (0x7FFFFFFF) for 0xFFF00000 on ILP32 hosts and
the wrong loadpoint causes "NOT ENOUGH MEMORY" error by the BOOTROMs
on loading uboot.lif on (at least) my 9000/360 and 9000/425t.

Misc cosmetic changes for mostly readability.
- KNF and add some newlines per blocks
- define and use proper bintobcd() macro
- make local functions and variables static

The same uboot.lif binaries are generated.

Rename ${PROGAOUT} -> ${PROGELF} to reflect reality.
Use proper signedness for the LIF file system data structures.

Ancient 4.3BSD used short and int for location, file size, file type,
and addresses etc. but all of them should be unsigned.

Also rename several variables and add comments for readability.
The LIF file system info can be found in "The HPDir Project" page:
https://www.hp9845.net/9845/projects/hpdir/
The same uboot.lif binaries are generated.

Add a preliminary CD boot support to uboot for preparation of PR/54455.
Briefly tested on mame, but not enalbed yet.

Recognize SCSI CD-ROM devices as a booted device properly.

Necessary for PR port-hp300/54455, to boot an md root root RAMDISK

kernel from CD-ROM without "WARNING: can't find match for bootdev:"
prompt.

Sync with src/sys/arch/hp300/stand/mkboot/volhdr.h rev 1.6.
https://mail-index.netbsd.org/source-changes/2024/05/07/msg151195.html

Use proper signedness for the LIF file system data structures.
mkboot should use this MI <sys/bootblock.h> and volhdr.h should
be removed soon.

Use MI <sys/bootblock.h> to refer LIF filesystem structures.
This should have been done when LIF definitions were initially added
to <sys/bootblock.h> for MI installboot(8).

Enable SUPPORT_CD on uboot.

Make cd9660_util.c usable in userland tools like installboot(8).

This was partially done for src/distrib/cdrom/macppc_installboot,
but more strict prototypes are necessary for native binary builds.

Install cd9660 related system headers for tools installboot(8) builds.

Reorder function prototypes per source files.

Add cd9660 support to search a bootloader file in the target file system.

Also add CD boot support for hp300, using a bootloader file in cd9660 fs.
This is a tool's part to close PR/54455.

HP 9000/300 machines read LIF directory entry allocated after
the LIF volume header at the top of the boot disk during bootstrap,
and a bootstrap file must be contiguously allocated on the disk
due to limitation of the LIF specification.

Current NetBSD/hp300's bootloader is larger than ~80KB so we have
to prepare a special 'boot' partition for FFS (that has only 8KB (ffsv1)
or 32KB (ffsv2) spaces) disks to put such a large bootloader.

On the other hand, on ISO9660 fs all files are allocated contiguously
so we can specify a bootloader file in the target ISO9660 directly
in the LIF directory entry.

Note we can simply use the existing "append" option to create bootable
CD ISO for hp300, but it looks some emulators (at leaset MAME) reject
such non-standard ISO files, i.e. with an appended bootloader file at
the end of the image.

Put a RAMDISK kernel and SYS_UBOOT into hp300 installcd to make it bootable.

This should finally close PR/54455.

Fix tools build errors on Cygwin.

Appease warnings on building tools/installboot on Cygwin.
 1.19.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 24-Feb-2014  skrll Rename NetBSD/hp700 to NetBSD/hppa.

Unfortunately our VCS isn't very helpful here.
 1.6 14-Jun-2013  msaitoh Remove trailng whitespaces.
 1.5 09-Jan-2012  skrll branches: 1.5.6;
Make it an error for the partition to exceed the PDC limit.

Inspired by PR/45742
 1.4 28-Apr-2008  martin branches: 1.4.4;
Remove clause 3 and 4 from TNF licenses
 1.3 02-Feb-2008  itohy branches: 1.3.4;
Try to warn possibly unbootable conditions:
- no disklabel
- no partition "a"
- partition "a" exceeds 2GB boundary
 1.2 18-Feb-2006  dsl branches: 1.2.10;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.1 14-May-2005  chs add hp700 support.
 1.2.10.1 23-Mar-2008  matt sync with HEAD
 1.3.4.1 18-May-2008  yamt sync with head.
 1.4.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.4.1 17-Apr-2012  yamt sync with head
 1.5.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.6.1 23-Jun-2013  tls resync from head
 1.2 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.1 24-Feb-2014  skrll branches: 1.1.4; 1.1.8; 1.1.30;
Rename NetBSD/hp700 to NetBSD/hppa.

Unfortunately our VCS isn't very helpful here.
 1.1.30.1 10-Jun-2019  christos Sync with HEAD
 1.1.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.1 24-Feb-2014  tls file hppa.c was added on branch tls-maxphys on 2014-08-20 00:05:08 +0000
 1.1.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.4.1 24-Feb-2014  yamt file hppa.c was added on branch yamt-pagecache on 2014-05-22 11:43:04 +0000
 1.44 11-Jul-2025  andvar Fix various typos, mainly in comments and log/error messages.
 1.43 05-Dec-2021  msaitoh branches: 1.43.4;
s/filesytem/filesystem/ in comment.
 1.42 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.41 23-Jun-2018  kamil branches: 1.41.2;
Fix integer overflow in installboot(8)

Add a sanity check of the disk_buf first three bytes. The original code on
a disk with nul bytes was causing integer overflow and thus calling the
memcmp(3) functin in is_zero() with enormous length.

Verity that the 0th byte is JMP, 1th a signed byte >=9 to prevent overflow
and 2th byte NOP.

Add a comment explaining the check.

Detected with MKSANITIZER and ASan.
 1.40 14-Jun-2013  msaitoh branches: 1.40.20; 1.40.26;
Remove trailng whitespaces.
 1.39 06-Apr-2012  gson branches: 1.39.2;
When printing the list of valid console names, don't treat the consoles[]
array as NULL terminated, because it's not.
 1.38 10-Mar-2012  dsl Some FAT16 filesystems don't have 'hidden sectors' correctly set to
the offset of the filesystem on the disk.
Let '-b s1blk' be used to fix the value.
 1.37 14-Aug-2011  christos branches: 1.37.2;
fix various gcc-4.5 warnings
 1.36 17-Jan-2010  drochner Invert the flag bits to control module loading: rename
LOADMODULES->NOMODULES and READBOOTCONF->NOBOOTCONF.
This way, the default value (0) wired into old bootxx_* and installed
to file systems remains valid and we avoid problems on partial updates.
 1.35 14-Jan-2010  drochner On i386/amd64, define two flag bits in the boot parameters which control
whether modules are loaded and whether boot.cfg is evaluated, and
set both to "off" per default in the PXE bootloader.
Extend "installboot" to toggle the bits.
This way, pxeboot works with existing dhcp server setups (and as
described in the manpage) out of the box. Also, boot.cfg reading
involves a stat() call which is horribly inefficient with the
TFTP pseudo file system.
 1.34 23-Dec-2009  mbalmer Fix typo in comments, no code change.
 1.33 07-May-2009  lukem refer to FFSv1 instead of UFSv1
 1.32 05-Apr-2009  lukem fix sign-compare issues
 1.31 18-Feb-2009  christos CID 4393: plug memory leak.
 1.30 28-Apr-2008  martin branches: 1.30.8;
Remove clause 3 and 4 from TNF licenses
 1.29 06-Mar-2008  dsl branches: 1.29.2;
Add a large warning about the possible side effect of using '-f'.
 1.28 23-Jun-2007  christos branches: 1.28.4; 1.28.8;
Don't use __arraycount because this is a 700L, and toolz have messed up
includes.
 1.27 23-Jun-2007  dogcow unb0rk tools/ builds on systems that don't have __arraycount() defined.
 1.26 23-Jun-2007  christos PR/36527: Greg A. Woods: installboot(8) doesn't allow for the valid
consdev=auto setting
 1.25 15-Feb-2007  dsl Add a -f (force) parameter to installboot(8).
If specified then checks on the disks BPB are not done, and any existing BPB
is deleted.
This is needed soince newfs(8) doesn't overwrite the BPB - which is basically
the FAT superblock.
Update documentation and add an example of using bootxx_fat16.
 1.24 07-Jan-2007  dogcow %d -> %ld, so that building on alpha doesn't fail. (also print more useful
errors - x bytes written, should be y.)
 1.23 06-Jan-2007  dsl Support for non-512 byte media.
Automatically enable writes to the 'labelsector' if necessary.
Detect and recover from problems with the write-protected 'labelsector'
stopping writes to nearby sectors when the non-raw disk device is used.
Support the installation of 512-byte pbr boot code (eg fatboot).
Verify that there is enough reserved space in the bpb (if not all zeros) to
avoid overwriting the start of FAT filesystems.
 1.22 18-Feb-2006  dsl Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.21 30-Jan-2006  dsl Fix the detection of the bootstrap magic number when run on big-endian systems.
Correct another typo.
 1.20 24-Jan-2006  dsl Fix spelling mistake in message
 1.19 11-Nov-2005  dsl Add a -e (edit) option to allow the bootstrap options of an installed
bootstrap or a file containing such a bootstrap to be changed/displayed.
In particular this will (soon) let you modify the parameters for pxeboot.
 1.18 16-Aug-2004  yamt revert a part of the previous. (uint -> u_int)
to make tools/installboot compile again.
 1.17 15-Aug-2004  dsl Add an option to set bp_consaddr (serial console IO port address)
Only complain about small patch area if we would write something non-zero there.
 1.16 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.15 14-Mar-2004  lukem branches: 1.15.2;
fix a typo in a comment, and expand the description of x86_boot_params.
 1.14 13-Mar-2004  dsl Add a -o keymap=zyz option that will set the boot keymap.
If a character in the map is typed, it gets replaced by the one following.
 1.13 27-Oct-2003  lukem fix typo in comment
 1.12 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.11 14-Oct-2003  lukem Instead of requiring that the BPB is always the FAT32 one, check the
first three bytes to determine how much of the BPB to preserve.
Supported values:
eb 3c 90 FAT16 BPB
eb 58 90 FAT32 BPB
(anything else) don't preserve any BPB

This is because the BPB is generally only the FAT16 one except in the
bootxx_msdos case, where it's the larger FAT32 one.
 1.10 10-Oct-2003  lukem Fix compile error on powerpc. Noted by Juergen Hannken-Illjes in private mail.
 1.9 08-Oct-2003  lukem Overhaul MBR handling (part 1):

<sys/bootblock.h>:
* Added definitions for the Master Boot Record (MBR) used by
a variety of systems (primarily i386), including the format
of the BIOS Parameter Block (BPB).
This information was cribbed from a variety of sources
including <sys/disklabel_mbr.h> which this is a superset of.

As part of this, some data structure elements and #defines
were renamed to be more "namespace friendly" and consistent
with other bootblocks and MBR documentation.
Update all uses of the old names to the new names.

<sys/disklabel_mbr.h>:
* Deprecated in favor of <sys/bootblock.h> (the latter is more
"host tool" friendly).

amd64 & i386:
* Renamed /usr/mdec/bootxx_dosfs to /usr/mdec/bootxx_msdos, to
be consistent with the naming convention of the msdosfs tools.

* Removed /usr/mdec/bootxx_ufs, as it's equivalent to bootxx_ffsv1
and it's confusing to have two functionally equivalent bootblocks,
especially given that "ufs" has multiple meanings (it could be
a synonym for "ffs", or the group of ffs/lfs/ext2fs file systems).

* Rework pbr.S (the first sector of bootxx_*):
+ Ensure that BPB (bytes 11..89) and the partition table
(bytes 446..509) do not contain code.
+ Add support for booting from FAT partitions if BOOT_FROM_FAT
is defined. (Only set for bootxx_msdos).
+ Remove "dummy" partition 3; if people want to installboot(8)
these to the start of the disk they can use fdisk(8) to
create a real MBR partition table...
+ Compile with TERSE_ERROR so it fits because of the above.
Whilst this is less user friendly, I feel it's important
to have a valid partition table and BPB in the MBR/PBR.

* Renamed /usr/mdec/biosboot to /usr/mdec/boot, to be consistent
with other platforms.

* Enable SUPPORT_DOSFS in /usr/mdec/boot (stage2), so that
we can boot off FAT partitions.

* Crank version of /usr/mdec/boot to 3.1, and fix some of the other
entries in the version file.

installboot(8) (i386):
* Read the existing MBR of the filesystem and retain the BIOS
Parameter Block (BPB) in bytes 11..89 and the MBR partition
table in bytes 446..509. (Previously installboot(8) would
trash those two sections of the MBR.)

mbrlabel(8):
* Use sys/lib/libkern/xlat_mbr_fstype.c instead of homegrown code
to map the MBR partition type to the NetBSD disklabel type.


Test built "make release" for i386, and new bootblocks verified to work
(even off FAT!).
 1.8 06-Oct-2003  lukem Replace BP_* with I386_BP_FLAGS_*, for consistency with other stuff in
<sys/bootblock.h>
(CONSDEV_ should be converted as well, but that's more intrusive...)
 1.7 04-Jul-2003  dsl Add some htole32() for host endianness independance
 1.6 08-May-2003  petrov Format fixes.
 1.5 18-Apr-2003  bjh21 Use <md5.h> rather than <sys/md5.h>. This is what the man page tells us to
do, and is required for cross-compiling since libnbcompat doesn't provide
<sys/md5.h>.
 1.4 16-Apr-2003  briggs Protect use of __RCSID() with a check to ensure that it's defined.
Suggested by Ian Lance Taylor on tech-userlevel@ to help cross-compilation
on Red Hat 7.3.
 1.3 15-Apr-2003  dsl Use htole32 so host endianness independant
 1.2 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.1 09-Apr-2003  dsl Add support for 'new' format i386 bootxx code
 1.15.2.1 22-Jun-2004  tron Pull up revision 1.16 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.28.8.1 24-Mar-2008  keiichi sync with head.
 1.28.4.1 23-Mar-2008  matt sync with HEAD
 1.29.2.1 18-May-2008  yamt sync with head.
 1.30.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.37.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.2.1 17-Apr-2012  yamt sync with head
 1.39.2.1 23-Jun-2013  tls resync from head
 1.40.26.1 25-Jun-2018  pgoyette Sync with HEAD
 1.40.20.1 24-Jun-2018  martin Pull up following revision(s) (requested by kamil in ticket #898):

usr.sbin/installboot/arch/i386.c: revision 1.41

Fix integer overflow in installboot(8)
Add a sanity check of the disk_buf first three bytes. The original code on
a disk with nul bytes was causing integer overflow and thus calling the
memcmp(3) functin in is_zero() with enormous length.
Verity that the 0th byte is JMP, 1th a signed byte >= 9 to prevent overflow
and 2th byte NOP.

Add a comment explaining the check.

Detected with MKSANITIZER and ASan.
 1.41.2.1 10-Jun-2019  christos Sync with HEAD
 1.43.4.1 02-Aug-2025  perseant Sync with HEAD
 1.9 11-May-2024  andvar s/boostrap/bootstrap/ in comment, warning message and documentation.
 1.8 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.7 17-Jul-2017  christos branches: 1.7.2; 1.7.6;
don't complain if the mbr was all 0's.
 1.6 19-Oct-2013  christos move all the unused code inside #if 0
 1.5 07-May-2009  lukem branches: 1.5.6; 1.5.12;
refer to FFSv1 instead of UFSv1
 1.4 05-Apr-2009  lukem fix sign-compare issues
 1.3 28-Apr-2008  martin branches: 1.3.8;
Remove clause 3 and 4 from TNF licenses
 1.2 27-Sep-2006  christos branches: 1.2.16;
Coverity CID 4160: Remove dead code.
 1.1 01-Sep-2006  uwe NetBSD/landisk support.
 1.2.16.1 18-May-2008  yamt sync with head.
 1.3.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.5.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.6.1 10-Jun-2019  christos Sync with HEAD
 1.7.2.2 17-Jul-2017  christos 3356330
 1.7.2.1 17-Jul-2017  christos file landisk.c was added on branch perseant-stdc-iso10646 on 2017-07-17 18:43:46 +0000
 1.12 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.11 24-May-2008  tsutsui branches: 1.11.60;
Try DIOCWLABEL ioctl only if write op fails with EROFS
because the ioctl is required and valid only for raw devices.
 1.10 09-May-2008  tsutsui Use DIOCWLABEL ioctl before writing block 0 which might be
protected by (now MI) bounds_check_with_label(9).
Fixes a problem on sysinst mentioned in PR port-macppc/38016.
 1.9 28-Apr-2008  martin branches: 1.9.2;
Remove clause 3 and 4 from TNF licenses
 1.8 18-Feb-2006  dsl branches: 1.8.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.7 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.6 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.5 20-May-2002  lukem - use uint8_t instead of char for boot block blobs
- bbinfo_params:
- replace "int littleendian" with "bbinfo_endian endian"
- add comments
- shared_bbinfo_clearboot():
- add callback method to shared_bbinfo_clearboot()
- don't clear from 0..headeroffset; use a callback to do that
- add news68k and newsmips support.
From Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, with a rework by me to
take advantage of the new shared_bbinfo_clearboot() callback.
(XXX: untested yet)
 1.4 16-May-2002  lukem Set pmBootSize of the block 2 applepartmapentry ("NetBSD Partition")
to roundup(size-of-bootxx, 512) instead of hardcoding it to 1024.

(Gets the new boot floppy working slightly further - still broken tho)
 1.3 15-May-2002  lukem ensure that members of apple_drvr_map and apple_part_map_entry are big endian
 1.2 15-May-2002  lukem add setboot callback to write the Apple partition map
 1.1 15-May-2002  lukem bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
and sun68k_bbinfo (296 byte, with 64 block entries)
into shared_bbinfo (512 bytes, with 118 block entries),
which will be also shared by future bbinfo-using platforms
(including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
perform the majority of the work for bbinfo-using back-ends
(rather than replicating that across multiple back-ends).
 1.8.18.2 04-Jun-2008  yamt sync with head
 1.8.18.1 18-May-2008  yamt sync with head.
 1.9.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.60.1 10-Jun-2019  christos Sync with HEAD
 1.8 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.7 28-Apr-2008  martin branches: 1.7.62;
Remove clause 3 and 4 from TNF licenses
 1.6 18-Feb-2006  dsl branches: 1.6.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.5 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.4 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.3 21-May-2002  tsutsui NEWS_BOOT_BLOCK_OFFSET is now changed to 0, so use NEWS_BOOT_BLOCK_BLOCKSIZE
to allocate buffer to read LABELSECTOR.
 1.2 21-May-2002  lukem I made a mistake when converting Izumi Tsutsui's back-end to the shared
bbinfo.c module; news* boot blocks occupy all of the first 16 sectors,
with a jump instruction to skip the label at bytes 64..511.
Replace news_clearboot() and news_setboot() callbacks with common
news_copydisklable() callback, and set bbinfo_params->offset to
NEWS_BOOT_BLOCK_OFFSET (which is now 0), and ->headeroffset to 0.

(Thanks to Izumi for picking this up; the perils of working on code at 2am)
 1.1 20-May-2002  lukem - use uint8_t instead of char for boot block blobs
- bbinfo_params:
- replace "int littleendian" with "bbinfo_endian endian"
- add comments
- shared_bbinfo_clearboot():
- add callback method to shared_bbinfo_clearboot()
- don't clear from 0..headeroffset; use a callback to do that
- add news68k and newsmips support.
From Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, with a rework by me to
take advantage of the new shared_bbinfo_clearboot() callback.
(XXX: untested yet)
 1.6.18.1 18-May-2008  yamt sync with head.
 1.7.62.1 10-Jun-2019  christos Sync with HEAD
 1.10 14-Feb-2023  andvar s/programm/program/ and s/suuport/support/ in comments and message.
 1.9 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.8 14-Jun-2013  msaitoh branches: 1.8.28;
Remove trailng whitespaces.
 1.7 07-Jan-2010  tsutsui branches: 1.7.6; 1.7.12;
Add a sectorsize parameter member in struct ib_params and use it
where sector size (disk block size) is required, instead of
DEV_BSIZE constant which means device I/O block size.

"Looks reasonable" from dholland@, and fixes tools installboot(8)
on Cygwin where DEV_BSIZE != 512 as mentioned in PR toolchain/42555.
 1.6 05-Apr-2009  lukem fix sign-compare issues
 1.5 28-Apr-2008  martin branches: 1.5.8;
Remove clause 3 and 4 from TNF licenses
 1.4 18-Feb-2006  dsl branches: 1.4.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.3 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.2 27-Oct-2003  lukem branches: 1.2.2;
minor consistency tweaks
 1.1 27-Oct-2003  cl add next68k support to installboot
 1.2.2.1 22-Jun-2004  tron Pull up revision 1.3 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.4.18.1 18-May-2008  yamt sync with head.
 1.5.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.7.12.1 23-Jun-2013  tls resync from head
 1.7.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.28.1 10-Jun-2019  christos Sync with HEAD
 1.16 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.15 21-Oct-2013  christos branches: 1.15.26;
XXX: gcc initialize a variable
 1.14 05-Apr-2009  lukem branches: 1.14.6; 1.14.12;
fix sign-compare issues
 1.13 28-Apr-2008  martin branches: 1.13.8;
Remove clause 3 and 4 from TNF licenses
 1.12 18-Feb-2006  dsl branches: 1.12.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.11 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.10 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.9 15-May-2002  lukem - add fsstat (fstat(2) on fsfd) and s1stat (fstat(2) on s1fd) in ib_params,
and use instead of replicating the effort in various locations
- if filesystem is not a regular file, use sync(2) instead of fsync(2)
after the bootstrap has been written
- move <sys/stat.h> and <stdint.h> into "installboot.h"
 1.8 14-May-2002  lukem pull in <sys/bootblock.h> in "installboot.h" instead of in arch/*.c
(and remove <dev/dec/dec_boot.h>, since <sys/bootblock.h> has that stuff now)
 1.7 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.6 30-Apr-2002  lukem display sector start & count in decimal rather than hex
 1.5 25-Apr-2002  tv HAVE_CONFIG_Hize. Also get *_boot.h from "../../sys/" when HAVE_CONFIG_H,
rather than creating more stubs.
 1.4 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.3 12-Apr-2002  lukem - support optional secondary bootstrap arg for install (unused by
existing backends, but future ones need it)
- use "bootstrap" instead of "boot block" in various messages where appropriate
- rename some members of ib_params
 1.2 09-Apr-2002  thorpej Need <string.h> for memcmp().
 1.1 03-Apr-2002  lukem Migrate MD files to arch/ subdir. Suggested by Hubert Feyrer.
 1.12.18.1 18-May-2008  yamt sync with head.
 1.13.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.14.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.26.1 10-Jun-2019  christos Sync with HEAD
 1.1 05-Oct-2025  thorpej Add riscv.
 1.12 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.11 28-Apr-2008  martin branches: 1.11.62;
Remove clause 3 and 4 from TNF licenses
 1.10 18-Feb-2006  dsl branches: 1.10.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.9 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.8 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.7 20-May-2002  lukem - use uint8_t instead of char for boot block blobs
- bbinfo_params:
- replace "int littleendian" with "bbinfo_endian endian"
- add comments
- shared_bbinfo_clearboot():
- add callback method to shared_bbinfo_clearboot()
- don't clear from 0..headeroffset; use a callback to do that
- add news68k and newsmips support.
From Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, with a rework by me to
take advantage of the new shared_bbinfo_clearboot() callback.
(XXX: untested yet)
 1.6 15-May-2002  lukem add missing prototype for static function
 1.5 15-May-2002  lukem bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
and sun68k_bbinfo (296 byte, with 64 block entries)
into shared_bbinfo (512 bytes, with 118 block entries),
which will be also shared by future bbinfo-using platforms
(including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
perform the majority of the work for bbinfo-using back-ends
(rather than replicating that across multiple back-ends).
 1.4 15-May-2002  lukem - add fsstat (fstat(2) on fsfd) and s1stat (fstat(2) on s1fd) in ib_params,
and use instead of replicating the effort in various locations
- if filesystem is not a regular file, use sync(2) instead of fsync(2)
after the bootstrap has been written
- move <sys/stat.h> and <stdint.h> into "installboot.h"
 1.3 14-May-2002  lukem pull in <sys/bootblock.h> in "installboot.h" instead of in arch/*.c
(and remove <dev/dec/dec_boot.h>, since <sys/bootblock.h> has that stuff now)
 1.2 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.1 06-May-2002  pk Add sparc module.
 1.10.18.1 18-May-2008  yamt sync with head.
 1.11.62.1 10-Jun-2019  christos Sync with HEAD
 1.19 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.18 14-Jan-2010  tsutsui branches: 1.18.46;
Remove if defined(__RCSID) around __RCSID() macro.
#include "nbtool_config.h" is enough for tools.
 1.17 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.16 28-Apr-2008  martin branches: 1.16.2;
Remove clause 3 and 4 from TNF licenses
 1.15 18-Feb-2006  dsl branches: 1.15.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.14 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.13 15-May-2002  lukem branches: 1.13.4;
- add fsstat (fstat(2) on fsfd) and s1stat (fstat(2) on s1fd) in ib_params,
and use instead of replicating the effort in various locations
- if filesystem is not a regular file, use sync(2) instead of fsync(2)
after the bootstrap has been written
- move <sys/stat.h> and <stdint.h> into "installboot.h"
 1.12 14-May-2002  lukem pull in <sys/bootblock.h> in "installboot.h" instead of in arch/*.c
(and remove <dev/dec/dec_boot.h>, since <sys/bootblock.h> has that stuff now)
 1.11 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.10 30-Apr-2002  lukem display sector start & count in decimal rather than hex
 1.9 22-Apr-2002  lukem formatting consistency frobs
 1.8 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.7 17-Apr-2002  fredette Small fix to a warning message that was displaying the wrong filename.
 1.6 12-Apr-2002  lukem - support optional secondary bootstrap arg for install (unused by
existing backends, but future ones need it)
- use "bootstrap" instead of "boot block" in various messages where appropriate
- rename some members of ib_params
 1.5 11-Apr-2002  lukem - add no_parseopt(), no_setboot() and no_clearboot() methods for back-ends
to use when they don't support a particular method
- don't automatically generate machines.c anymore
- add entries for i386 (temporarily unsupported) and shark
(permanently unsupported)
 1.4 04-Apr-2002  mrg be sure to pad the bootblock.
 1.3 04-Apr-2002  mrg clean up a bit, use fewer magic numbers.
 1.2 04-Apr-2002  mrg LP64isms. also, be sure to use <string.h> if we use memset or memcpy.
 1.1 04-Apr-2002  lukem Add sparc64 back-end, contributed by Matthew Green.
 1.13.4.1 22-Jun-2004  tron Pull up revision 1.14 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.15.18.2 04-Jun-2008  yamt sync with head
 1.15.18.1 18-May-2008  yamt sync with head.
 1.16.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.18.46.1 10-Jun-2019  christos Sync with HEAD
 1.22 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.21 28-Apr-2008  martin branches: 1.21.62;
Remove clause 3 and 4 from TNF licenses
 1.20 18-Feb-2006  dsl branches: 1.20.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.19 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.18 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.17 20-May-2002  lukem - use uint8_t instead of char for boot block blobs
- bbinfo_params:
- replace "int littleendian" with "bbinfo_endian endian"
- add comments
- shared_bbinfo_clearboot():
- add callback method to shared_bbinfo_clearboot()
- don't clear from 0..headeroffset; use a callback to do that
- add news68k and newsmips support.
From Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>, with a rework by me to
take advantage of the new shared_bbinfo_clearboot() callback.
(XXX: untested yet)
 1.16 15-May-2002  lukem bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
and sun68k_bbinfo (296 byte, with 64 block entries)
into shared_bbinfo (512 bytes, with 118 block entries),
which will be also shared by future bbinfo-using platforms
(including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
perform the majority of the work for bbinfo-using back-ends
(rather than replicating that across multiple back-ends).
 1.15 15-May-2002  lukem - add fsstat (fstat(2) on fsfd) and s1stat (fstat(2) on s1fd) in ib_params,
and use instead of replicating the effort in various locations
- if filesystem is not a regular file, use sync(2) instead of fsync(2)
after the bootstrap has been written
- move <sys/stat.h> and <stdint.h> into "installboot.h"
 1.14 14-May-2002  lukem `-b bno' isn't supported. (sync with similar fix in arch/sparc.c)
 1.13 14-May-2002  lukem pull in <sys/bootblock.h> in "installboot.h" instead of in arch/*.c
(and remove <dev/dec/dec_boot.h>, since <sys/bootblock.h> has that stuff now)
 1.12 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.11 06-May-2002  lukem s/bootinfo.h/bootblock.h/
 1.10 06-May-2002  lukem add missing "sys/". noted by Martti Kuparinen <martti.kuparinen@iki.fi>
 1.9 06-May-2002  lukem replace <dev/sun/sun_boot.h> with <sys/bootinfo.h>
 1.8 06-May-2002  lukem - sanity check bbi_block_count determined from bbinfo
- use warnx() instead of warn() in a couple of places
 1.7 30-Apr-2002  lukem display sector start & count in decimal rather than hex
 1.6 29-Apr-2002  lukem consistently use sizeof(bb) instead of SUN68K_BOOT_BLOCK_MAX_SIZE
 1.5 25-Apr-2002  tv HAVE_CONFIG_Hize. Also get *_boot.h from "../../sys/" when HAVE_CONFIG_H,
rather than creating more stubs.
 1.4 24-Apr-2002  lukem convert from "sun68k_bbinfo.h" to <dev/sun/sun_boot.h>
 1.3 22-Apr-2002  bjh21 When printf'ing a size_t, cast it to unsigned long and use a %lu format.
This gets rid of a warning when compiling for ARM.
 1.2 22-Apr-2002  fredette Install the compatability symlink for sun2.
In the sun68k handler, add some sync()s to make sure we
get a coherent picture of the filesystem. Maybe should
be in the MI filesystem code?
 1.1 22-Apr-2002  lukem Add sun2 backend from Matthew Fredette.
(Implemented with "sun68k.c" as it should eventually support "sun3" as well.)
 1.20.18.1 18-May-2008  yamt sync with head.
 1.21.62.1 10-Jun-2019  christos Sync with HEAD
 1.20 24-Jan-2022  andvar s/begining/beginning/ in comments and messages.
 1.19 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.18 13-Nov-2014  christos branches: 1.18.16;
Use VAX_LABELOFFSET here; It needs to be the machine-specific one. Thanks
to gcc-4.8 for discovering the bug and to Atari for having a LABELOFFSET of
516 > 512 :-)
XXX: Perhaps we should put all those constants in <sys/bootblock.h> instead
of spreading them around.
 1.17 16-Jun-2013  martin branches: 1.17.6;
In the tool build <nbinclude/vax/disklabel.h> is enough.
 1.16 03-May-2013  matt Make this build with the disk label change.
 1.15 04-Apr-2013  martin Provide an empty __CTASSERT() for toolbuilds
 1.14 04-Apr-2013  martin Fix installboot for VAX, as discussed on port-vax. Problem pointed out
by Jonny Billquist, thanks to Marl Pizzolato for patiently explaining
the various ways of booting a vax to me.
Now VAX 780 can boot directly from VMB.EXE again.
 1.13 05-Apr-2009  lukem branches: 1.13.6; 1.13.8; 1.13.12;
fix sign-compare issues
 1.12 28-Apr-2008  martin branches: 1.12.6; 1.12.8;
Remove clause 3 and 4 from TNF licenses
 1.11 18-Feb-2006  dsl branches: 1.11.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.10 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.9 15-Apr-2003  dsl Change the way -o options are parsed, now done in MI code with a check after
all the options have been processed that they are supported my the
specific system.
Add i386 MD options (console, password, speed and timeout)
(Approved by christos and lukem)
 1.8 15-May-2002  lukem - add fsstat (fstat(2) on fsfd) and s1stat (fstat(2) on s1fd) in ib_params,
and use instead of replicating the effort in various locations
- if filesystem is not a regular file, use sync(2) instead of fsync(2)
after the bootstrap has been written
- move <sys/stat.h> and <stdint.h> into "installboot.h"
 1.7 14-May-2002  lukem pull in <sys/bootblock.h> in "installboot.h" instead of in arch/*.c
(and remove <dev/dec/dec_boot.h>, since <sys/bootblock.h> has that stuff now)
 1.6 14-May-2002  lukem user visible stuff:
- add `-B s2bno', to provide the starting block for the secondary bootstrap.
intended for use on platforms where the blocks of the stage2 bootstrap
are hardcoded into the stage1 bootstrap (currently: sparc, sun2)
- don't support `-b s1bno' for sparc or sun2, since the primary is always
at a fixed location on the disk.
- if `filesystem' is a regular file, use fsync(2) instead of sync(2)

code changes:
- add hardcode_stage2(), which uses -B s2bno and the size of the
provided secondary bootstrap (as an actual file, not as part of the
`filesystem' argument) to provide a sequential list of blocks from s2bno,
each block being the appropriate file system size (from
params->fstype->blocksize)
- add blocksize and needswap run-time parameters to ib_fs
- in *_match(), set params->fstype->blocksize to the underlying block size
(8KB for raw), and params->fstype->needswap as appropriate
- rename IB_STARTBLOCK to IB_STAGE1START, and add IB_STAGE2START
- use hardcode_stage2() to implement raw_findstage2() and IB_STAGE2BLOCK
support for ffs_findstage2()
- improve some comments, add some prototypes, ...
 1.5 30-Apr-2002  lukem display sector start & count in decimal rather than hex
 1.4 25-Apr-2002  tv HAVE_CONFIG_Hize. Also get *_boot.h from "../../sys/" when HAVE_CONFIG_H,
rather than creating more stubs.
 1.3 19-Apr-2002  lukem - Add code from Matt Fredette <fredette@theory.lcs.mit.edu> to implement
fstype checking, and back-end "ffs" support.
- Consistently use at least uint32_t for blocknumbers (vs. int / long / ...)
- Consistently use uintXX_t instead of u_intXX_t.
- Move various duplicated prototypes into "installboot.h"
 1.2 12-Apr-2002  lukem - support optional secondary bootstrap arg for install (unused by
existing backends, but future ones need it)
- use "bootstrap" instead of "boot block" in various messages where appropriate
- rename some members of ib_params
 1.1 03-Apr-2002  lukem Migrate MD files to arch/ subdir. Suggested by Hubert Feyrer.
 1.11.18.1 18-May-2008  yamt sync with head.
 1.12.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.12.6.3 17-Jun-2013  msaitoh Fix compile error (requested by martin in ticket #1856):
usr.sbin/installboot/arch/vax.c rev. 1.17

In the tool build <nbinclude/vax/disklabel.h> is enough.
 1.12.6.2 14-Jun-2013  msaitoh Pull up following revision(s) (requested by martin in ticket #1856):
sys/sys/bootblock.h rev. 1.55
usr.sbin/installboot/arch/vax.c rev. 1.16
Adapt to new vax primary bootstrap layout.
Don't include host's disklabel.h.
 1.12.6.1 12-Jun-2013  msaitoh Pull up following revision(s) (requested by martin in ticket #1856):
sys/arch/vax/boot/xxboot/start.S: revision 1.5
sys/sys/bootblock.h: revision 1.55
sys/sys/disklabel.h: revision 1.113
usr.sbin/installboot/arch/vax.c: revision 1.14-1.15
Rearrange primary bootstrap slightly to free up all space between the disk
label and the uVAX rom boot parameter block.
Calculate the disklabel size (for asm code) dynamically based on MAXPARTITIONS.
Adapt to new vax primary bootstrap layout.
Fix installboot for VAX, as discussed on port-vax. Problem pointed out
by Jonny Billquist, thanks to Marl Pizzolato for patiently explaining
the various ways of booting a vax to me.
Now VAX 780 can boot directly from VMB.EXE again.
Provide an empty __CTASSERT() for toolbuilds
 1.13.12.1 23-Jun-2013  tls resync from head
 1.13.8.2 17-Jun-2013  msaitoh Fix compile error (requested by martin in ticket #865):
usr.sbin/installboot/arch/vax.c rev. 1.16-1.17

Don't include host's disklabel.h.
 1.13.8.1 20-Apr-2013  bouyer Pull up following revision(s) (requested by martin in ticket #865):
sys/arch/vax/include/disklabel.h: revision 1.7
sys/arch/vax/boot/xxboot/start.S: revision 1.5
sys/sys/bootblock.h: revision 1.55
sys/sys/disklabel.h: revision 1.113
usr.sbin/installboot/arch/vax.c: revision 1.14
usr.sbin/installboot/arch/vax.c: revision 1.15
sys/kern/sys_generic.c: revision 1.129
Revert VAX MAXPARTITION bump to 16, adjusting it to 12 instead. Fix bootblocks
and installboot for VAX 780 and other machines booting via VMB.EXE.
 1.13.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.6.1 14-Dec-2014  martin Pull up following revision(s) (requested by tsutsui in ticket #323):
usr.sbin/installboot/arch/vax.c: revision 1.18
Use VAX_LABELOFFSET here; It needs to be the machine-specific one. Thanks
to gcc-4.8 for discovering the bug and to Atari for having a LABELOFFSET of
516 > 512 :-)
XXX: Perhaps we should put all those constants in <sys/bootblock.h> instead
of spreading them around.
 1.18.16.1 10-Jun-2019  christos Sync with HEAD
 1.5 07-May-2019  thorpej Use designated initializers for struct ib_mach.
 1.4 28-Apr-2008  martin branches: 1.4.62;
Remove clause 3 and 4 from TNF licenses
 1.3 18-Feb-2006  dsl branches: 1.3.18;
Move the MD definitions into the MD files, leaving machines.c with just
a list of the supported machines.
 1.2 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.1 02-Jun-2002  isaki Add x68k stuff.
 1.3.18.1 18-May-2008  yamt sync with head.
 1.4.62.1 10-Jun-2019  christos Sync with HEAD

RSS XML Feed