Commit Graph

62 Commits

Author SHA1 Message Date
dsl d7d05c9ee2 roundup() write of hp300 boot code to a multiplr of the disk sector size.
and re-instate the hp300 code - seems to work.
2003-11-13 08:19:43 +00:00
dsl c948aa4152 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.
2003-11-10 10:48:30 +00:00
uwe 57f9d3f327 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.
2003-11-08 22:39:07 +00:00
dsl 6bf8729bd1 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.
2003-11-08 16:44:35 +00:00
lukem f4f2cda6de minor consistency tweaks 2003-10-27 22:38:39 +00:00
lukem c176c56887 fix typo in comment 2003-10-27 22:29:59 +00:00
cl e05d95b990 add next68k support to installboot 2003-10-27 16:51:05 +00:00
lukem 171d653219 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).
2003-10-27 00:12:41 +00:00
lukem 10e10fae7e 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.
2003-10-14 09:46:43 +00:00
lukem 58e13fba70 Fix compile error on powerpc. Noted by Juergen Hannken-Illjes in private mail. 2003-10-10 01:50:47 +00:00
lukem 1c33b4e6a4 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!).
2003-10-08 04:25:43 +00:00
lukem 420f3b76ba 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...)
2003-10-06 05:24:54 +00:00
dsl d2b9d2f94a Add some htole32() for host endianness independance 2003-07-04 07:45:06 +00:00
petrov 674b7e97b8 Format fixes. 2003-05-08 20:33:44 +00:00
bjh21 360968bcd9 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>.
2003-04-18 14:16:42 +00:00
briggs 755a56f62f 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.
2003-04-16 01:32:07 +00:00
dsl 8c4da2e486 Use htole32 so host endianness independant 2003-04-15 14:35:57 +00:00
dsl ed45ba76c7 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)
2003-04-15 14:22:13 +00:00
dsl f14ef8a1e3 Add support for 'new' format i386 bootxx code 2003-04-09 22:14:27 +00:00
mhitch e7852b0563 Add support for amiga. 2003-01-15 06:33:13 +00:00
grant eda9e509bb sweep of errx/warnx, remove unnecessary trailing \n 2002-07-20 08:40:16 +00:00
isaki 53175db820 Add x68k stuff. 2002-06-02 10:44:30 +00:00
matt 5d837662a3 Use to htobe16, not htons 2002-05-31 05:54:36 +00:00
tsutsui 6734af58f9 NEWS_BOOT_BLOCK_OFFSET is now changed to 0, so use NEWS_BOOT_BLOCK_BLOCKSIZE
to allocate buffer to read LABELSECTOR.
2002-05-21 14:59:38 +00:00
lukem 6a574a38b0 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)
2002-05-21 00:38:08 +00:00
lukem d22f5cff9c - 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)
2002-05-20 16:05:26 +00:00
lukem 86dee8f439 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)
2002-05-16 01:35:44 +00:00
lukem a6fac9a778 ensure that members of apple_drvr_map and apple_part_map_entry are big endian 2002-05-15 15:43:01 +00:00
lukem 2b7c014c1c add setboot callback to write the Apple partition map 2002-05-15 13:38:42 +00:00
lukem bc6c7991bf add missing prototype for static function 2002-05-15 09:58:19 +00:00
lukem 35749caf16 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).
2002-05-15 09:56:59 +00:00
lukem 966b42a3e6 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).
2002-05-15 09:44:54 +00:00
lukem 932b752477 - 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"
2002-05-15 02:18:22 +00:00
lukem 714021421e `-b bno' isn't supported. (sync with similar fix in arch/sparc.c) 2002-05-14 15:29:50 +00:00
lukem 1279ab0cf5 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)
2002-05-14 06:40:32 +00:00
lukem 1bdd92ee90 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, ...
2002-05-14 06:18:50 +00:00
pk efad6f6e12 Add sparc module. 2002-05-06 16:24:45 +00:00
lukem e427ebdd56 s/bootinfo.h/bootblock.h/ 2002-05-06 13:34:18 +00:00
lukem 3efe6f707b add missing "sys/". noted by Martti Kuparinen <martti.kuparinen@iki.fi> 2002-05-06 12:16:55 +00:00
lukem 5123a119e3 replace <dev/sun/sun_boot.h> with <sys/bootinfo.h> 2002-05-06 05:28:30 +00:00
lukem ce61e6de03 - sanity check bbi_block_count determined from bbinfo
- use warnx() instead of warn() in a couple of places
2002-05-06 01:49:48 +00:00
lukem d9e55fca47 display sector start & count in decimal rather than hex 2002-04-30 14:24:33 +00:00
lukem fa2a19276b consistently use sizeof(bb) instead of SUN68K_BOOT_BLOCK_MAX_SIZE 2002-04-29 13:07:41 +00:00
tv 4887cf3412 HAVE_CONFIG_Hize. Also get *_boot.h from "../../sys/" when HAVE_CONFIG_H,
rather than creating more stubs.
2002-04-25 18:11:53 +00:00
lukem 2fddf94b34 convert from "sun68k_bbinfo.h" to <dev/sun/sun_boot.h> 2002-04-24 01:35:25 +00:00
bjh21 1723b1333c 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.
2002-04-22 23:24:10 +00:00
fredette 7493ba97a6 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?
2002-04-22 21:11:45 +00:00
lukem 878d42b158 Add sun2 backend from Matthew Fredette.
(Implemented with "sun68k.c" as it should eventually support "sun3" as well.)
2002-04-22 17:17:35 +00:00
lukem ed5fff8877 formatting consistency frobs 2002-04-22 16:03:07 +00:00
lukem 8eb8919e12 - 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"
2002-04-19 07:08:51 +00:00