Module Name: src
Committed By: tsutsui
Date: Sun Sep 15 03:56:58 UTC 2024
Modified Files:
src/distrib/sets/lists/base: md.macppc
src/etc/etc.macppc: Makefile.inc
src/share/mk: bsd.own.mk
src/sys/arch/macppc/stand: Makefile
src/tools: Makefile
src/tools/macppc_installboot: Makefile
Added Files:
src/etc/etc.macppc: hfsmap.lst hide-hfs.lst hide-jol.lst
src/sys/arch/macppc/stand/boothfs: Makefile
src/sys/arch/macppc/stand/installboot: Makefile installboot.c
installboot.h
src/sys/arch/macppc/stand/mkboothfs: Makefile mkboothfs.c
src/tools/macppc_mkboothfs: Makefile
Removed Files:
src/distrib/cdrom/macppc_installboot: Makefile installboot.c
installboot.h
src/distrib/cdrom/macppc_mkboothfs: Makefile mkboothfs.c
Log Message:
Move macppc bootable installcd stuff to sys/arch/macppc/stand dirs.
- move installboot (for CD ISO) and mkboothfs (for mkhybrid(8)) tools to
sys/arch/macppc/stand
- also build mkboothfs as ${TOOL_MACPPCMKBOOTHFS} in src/tools
- explicitly generate boothfs file (for mkhybrid(8)) in
sys/arch/macppc/stand/boothfs and install it into /usr/mdec
- use installed /usr/mdec/boothfs to create macppc bootable iso
- move list files for mkhybrid(8) hfs options to etc/etc.macppc
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r0 src/distrib/cdrom/macppc_installboot/Makefile
cvs rdiff -u -r1.7 -r0 src/distrib/cdrom/macppc_installboot/installboot.c
cvs rdiff -u -r1.5 -r0 src/distrib/cdrom/macppc_installboot/installboot.h
cvs rdiff -u -r1.6 -r0 src/distrib/cdrom/macppc_mkboothfs/Makefile
cvs rdiff -u -r1.4 -r0 src/distrib/cdrom/macppc_mkboothfs/mkboothfs.c
cvs rdiff -u -r1.37 -r1.38 src/distrib/sets/lists/base/md.macppc
cvs rdiff -u -r1.13 -r1.14 src/etc/etc.macppc/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/etc/etc.macppc/hfsmap.lst \
src/etc/etc.macppc/hide-hfs.lst src/etc/etc.macppc/hide-jol.lst
cvs rdiff -u -r1.1400 -r1.1401 src/share/mk/bsd.own.mk
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/macppc/stand/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/stand/boothfs/Makefile
cvs rdiff -u -r0 -r1.5 src/sys/arch/macppc/stand/installboot/Makefile
cvs rdiff -u -r0 -r1.9 src/sys/arch/macppc/stand/installboot/installboot.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/stand/installboot/installboot.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/stand/mkboothfs/Makefile \
src/sys/arch/macppc/stand/mkboothfs/mkboothfs.c
cvs rdiff -u -r1.225 -r1.226 src/tools/Makefile
cvs rdiff -u -r1.1 -r1.2 src/tools/macppc_installboot/Makefile
cvs rdiff -u -r0 -r1.1 src/tools/macppc_mkboothfs/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/base/md.macppc
diff -u src/distrib/sets/lists/base/md.macppc:1.37 src/distrib/sets/lists/base/md.macppc:1.38
--- src/distrib/sets/lists/base/md.macppc:1.37 Thu Jul 11 20:41:06 2024
+++ src/distrib/sets/lists/base/md.macppc Sun Sep 15 03:56:57 2024
@@ -1,5 +1,6 @@
-# $NetBSD: md.macppc,v 1.37 2024/07/11 20:41:06 riastradh Exp $
+# $NetBSD: md.macppc,v 1.38 2024/09/15 03:56:57 tsutsui Exp $
#
+./usr/mdec/boothfs base-sysutil-bin
./usr/mdec/bootxx base-sysutil-bin
./usr/mdec/installboot base-obsolete obsolete
./usr/mdec/mbr base-obsolete obsolete
Index: src/etc/etc.macppc/Makefile.inc
diff -u src/etc/etc.macppc/Makefile.inc:1.13 src/etc/etc.macppc/Makefile.inc:1.14
--- src/etc/etc.macppc/Makefile.inc:1.13 Sat Jun 8 13:07:48 2024
+++ src/etc/etc.macppc/Makefile.inc Sun Sep 15 03:56:57 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.13 2024/06/08 13:07:48 tsutsui Exp $
+# $NetBSD: Makefile.inc,v 1.14 2024/09/15 03:56:57 tsutsui Exp $
#
# etc.macppc/Makefile.inc -- macppc-specific etc Makefile targets
#
@@ -17,19 +17,15 @@ INSTALLATION_DIRS+= installation/floppy
# For "make iso-image"
# mkisofs arguments to create a hybrid (HFS/Rockridge) CD-ROM image.
-# XXX: files in ${DISTRIB_CDROMDIR} should be moved under distrib/macppc/cdrom?
-DISTRIB_CDROMDIR= ${NETBSDSRCDIR}/distrib/cdrom
+ETCMACHINEDIR= ${.CURDIR}/etc.${MACHINE}
-BOOTHFS= boothfs
-UUDECODE_FILES= ${BOOTHFS}
-.SUFFIXES: .uue
-.PATH.uue: ${DISTRIB_CDROMDIR}
+BOOTHFS= ${DESTDIR}/usr/mdec/boothfs
MKISOFS_FLAGS+= -hide-rr-moved \
- -hfs -part -hide-hfs-list ${DISTRIB_CDROMDIR}/hide-hfs.lst \
- --macbin -map ${DISTRIB_CDROMDIR}/hfsmap.lst \
- -hide-joliet-list ${DISTRIB_CDROMDIR}/hide-jol.lst \
- -boot-hfs-file ${.OBJDIR}/${BOOTHFS}
+ -hfs -part -hide-hfs-list ${ETCMACHINEDIR}/hide-hfs.lst \
+ --macbin -map ${ETCMACHINEDIR}/hfsmap.lst \
+ -hide-joliet-list ${ETCMACHINEDIR}/hide-jol.lst \
+ -boot-hfs-file ${BOOTHFS}
# exclude large debug sets to avoid 700MB overflow
MKISOFS_FLAGS+= -m debug.tgz -m xdebug.tgz
Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.1400 src/share/mk/bsd.own.mk:1.1401
--- src/share/mk/bsd.own.mk:1.1400 Tue Aug 27 21:52:39 2024
+++ src/share/mk/bsd.own.mk Sun Sep 15 03:56:57 2024
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.own.mk,v 1.1400 2024/08/27 21:52:39 christos Exp $
+# $NetBSD: bsd.own.mk,v 1.1401 2024/09/15 03:56:57 tsutsui Exp $
# This needs to be before bsd.init.mk
.if defined(BSD_MK_COMPAT_FILE)
@@ -502,6 +502,7 @@ TOOL_LLVM_TBLGEN= ${TOOLDIR}/bin/${_TOOL
TOOL_M4= ${TOOLDIR}/bin/${_TOOL_PREFIX}m4
TOOL_MACPPCFIXCOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff
TOOL_MACPPCINSTALLBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}macppc_installboot
+TOOL_MACPPCMKBOOTHFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}macppc_mkboothfs
TOOL_MAKEFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makefs
TOOL_MAKEINFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo
TOOL_MAKEKEYS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makekeys
Index: src/sys/arch/macppc/stand/Makefile
diff -u src/sys/arch/macppc/stand/Makefile:1.7 src/sys/arch/macppc/stand/Makefile:1.8
--- src/sys/arch/macppc/stand/Makefile:1.7 Sun Dec 11 12:18:06 2005
+++ src/sys/arch/macppc/stand/Makefile Sun Sep 15 03:56:57 2024
@@ -1,10 +1,11 @@
-# $NetBSD: Makefile,v 1.7 2005/12/11 12:18:06 christos Exp $
+# $NetBSD: Makefile,v 1.8 2024/09/15 03:56:57 tsutsui Exp $
.include <bsd.own.mk>
.if (${USETOOLS} != "yes")
-SUBDIR= fixcoff .WAIT
+SUBDIR= fixcoff mkboothfs .WAIT
.endif
SUBDIR+= bootxx ofwboot
+SUBDIR+= boothfs
.include <bsd.subdir.mk>
Index: src/tools/Makefile
diff -u src/tools/Makefile:1.225 src/tools/Makefile:1.226
--- src/tools/Makefile:1.225 Sun Aug 18 14:11:21 2024
+++ src/tools/Makefile Sun Sep 15 03:56:58 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.225 2024/08/18 14:11:21 christos Exp $
+# $NetBSD: Makefile,v 1.226 2024/09/15 03:56:58 tsutsui Exp $
.include <bsd.own.mk>
.include <bsd.endian.mk>
@@ -173,6 +173,7 @@ SUBDIR+= ibmnws-ncdcs
.if ${MACHINE} == "macppc"
SUBDIR+= macppc-fixcoff
SUBDIR+= macppc_installboot
+SUBDIR+= macppc_mkboothfs
.endif
.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
Index: src/tools/macppc_installboot/Makefile
diff -u src/tools/macppc_installboot/Makefile:1.1 src/tools/macppc_installboot/Makefile:1.2
--- src/tools/macppc_installboot/Makefile:1.1 Sat Jun 8 13:03:41 2024
+++ src/tools/macppc_installboot/Makefile Sun Sep 15 03:56:58 2024
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.1 2024/06/08 13:03:41 tsutsui Exp $
+# $NetBSD: Makefile,v 1.2 2024/09/15 03:56:58 tsutsui Exp $
.include <bsd.hostinit.mk>
HOSTPROGNAME= ${_TOOL_PREFIX}macppc_installboot
-HOST_SRCDIR= distrib/cdrom/macppc_installboot
+HOST_SRCDIR= sys/arch/macppc/stand/installboot
.include "${.CURDIR}/../Makefile.nbincludes"
.include "${.CURDIR}/../Makefile.host"
Added files:
Index: src/etc/etc.macppc/hfsmap.lst
diff -u /dev/null src/etc/etc.macppc/hfsmap.lst:1.1
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/etc/etc.macppc/hfsmap.lst Sun Sep 15 03:56:57 2024
@@ -0,0 +1,8 @@
+.hqx - 'BnHq' 'TEXT'
+.txt - 'ttxt' 'TEXT'
+.ps - 'ASPS' 'TEXT'
+.gz - 'GNUz' 'TEXT'
+.tgz - 'GNUz' 'TEXT'
+.html - 'nbsd' 'TEXT'
+.chrp - 'chrp' 'tbxi'
+* - 'nbsd' 'TEXT'
Index: src/etc/etc.macppc/hide-hfs.lst
diff -u /dev/null src/etc/etc.macppc/hide-hfs.lst:1.1
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/etc/etc.macppc/hide-hfs.lst Sun Sep 15 03:56:57 2024
@@ -0,0 +1,8 @@
+MD5
+SHA512
+TRANS.TBL
+INSTALL.more
+./boot
+./boot.*
+./netbsd*
+./packages
Index: src/etc/etc.macppc/hide-jol.lst
diff -u /dev/null src/etc/etc.macppc/hide-jol.lst:1.1
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/etc/etc.macppc/hide-jol.lst Sun Sep 15 03:56:57 2024
@@ -0,0 +1,5 @@
+./boot
+./boot.*
+./netbsd*
+./ofwboot*
+./mac68k/installation/misc/*.bin
Index: src/sys/arch/macppc/stand/boothfs/Makefile
diff -u /dev/null src/sys/arch/macppc/stand/boothfs/Makefile:1.1
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/sys/arch/macppc/stand/boothfs/Makefile Sun Sep 15 03:56:57 2024
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2024/09/15 03:56:57 tsutsui Exp $
+
+PROG= boothfs
+NOMAN= # defined
+BINMODE= 444
+
+SRCS= # generated from ${TOOL_MACPPCMKBOOTHFS}
+
+${PROG}:
+ ${TOOL_MACPPCMKBOOTHFS} ${.TARGET}
+
+CLEANFILES+= ${BOOTHFS}
+
+.include <bsd.prog.mk>
Index: src/sys/arch/macppc/stand/installboot/Makefile
diff -u /dev/null src/sys/arch/macppc/stand/installboot/Makefile:1.5
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/sys/arch/macppc/stand/installboot/Makefile Sun Sep 15 03:56:57 2024
@@ -0,0 +1,30 @@
+# $NetBSD: Makefile,v 1.5 2024/09/15 03:56:57 tsutsui Exp $
+
+NOMAN= # defined
+PROG= macppc_installboot
+SRCS= installboot.c cd9660.c cd9660_util.c
+
+.PATH.c: ${.CURDIR}
+.PATH.c: ${NETBSDSRCDIR}/usr.sbin/installboot ${NETBSDSRCDIR}/sys/fs/cd9660
+
+CPPFLAGS+= -I. -I${.CURDIR}
+#CPPFLAGS+= -DDEBUG
+
+.if !defined(HOSTPROGNAME)
+.if !make(obj) && !make(clean) && !make(cleandir)
+.BEGIN:
+ -rm -rf fs
+ ${HOST_INSTALL_DIR} fs
+ ${HOST_INSTALL_DIR} fs/cd9660
+ ${HOST_LN} -s ${NETBSDSRCDIR}/sys/fs/unicode.h fs
+ ${HOST_LN} -s ${NETBSDSRCDIR}/sys/fs/cd9660/iso.h fs/cd9660
+ ${HOST_LN} -s ${NETBSDSRCDIR}/sys/fs/cd9660/cd9660_extern.h fs/cd9660
+.endif
+
+cleandir distclean: cleaninc
+
+cleaninc:
+ -rm -rf fs
+.endif # !defined(HOSTPROGNAME)
+
+.include <bsd.prog.mk>
Index: src/sys/arch/macppc/stand/installboot/installboot.c
diff -u /dev/null src/sys/arch/macppc/stand/installboot/installboot.c:1.9
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/sys/arch/macppc/stand/installboot/installboot.c Sun Sep 15 03:56:57 2024
@@ -0,0 +1,230 @@
+/* $NetBSD: installboot.c,v 1.9 2024/09/15 03:56:57 tsutsui Exp $ */
+
+/*-
+ * Copyright (c) 2005 Izumi Tsutsui. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "installboot.h"
+
+#define BSIZE 512
+#define MAX_SB_SIZE (64 * 1024) /* XXX */
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
+
+static void usage(void);
+
+static ib_params installboot_params;
+
+static struct ib_fs cd9660_fstype = {
+ .name = "cd9660",
+ .match = cd9660_match,
+ .findstage2 = cd9660_findstage2
+};
+
+int
+main(int argc, char **argv)
+{
+ ib_params *params;
+ uint8_t *bb;
+ struct apple_part_map_entry pme;
+ size_t bbi;
+ struct shared_bbinfo *bbinfop;
+ off_t partoff;
+ uint32_t nblk, maxblk, blk_i;
+ int rv;
+ ib_block *blocks;
+ uint64_t block;
+
+ setprogname(argv[0]);
+ params = &installboot_params;
+ memset(params, 0, sizeof(*params));
+ params->fsfd = -1;
+ params->s1fd = -1;
+
+ if (argc != 4)
+ usage();
+
+ params->filesystem = argv[1];
+ params->fstype = &cd9660_fstype;
+
+ if ((params->fsfd = open(params->filesystem, O_RDWR, 0600)) == -1)
+ err(1, "Opening file system `%s' read", params->filesystem);
+ if (fstat(params->fsfd, ¶ms->fsstat) == -1)
+ err(1, "Examining file system `%s'", params->filesystem);
+ if (!params->fstype->match(params))
+ errx(1, "File system `%s' is not of type %s",
+ params->filesystem, params->fstype->name);
+
+#ifdef DEBUG
+ printf("file system: %s, %ld bytes\n",
+ params->filesystem, (long)params->fsstat.st_size);
+#endif
+
+ /*
+ * Find space for primary boot from the second (NetBSD_BootBlock)
+ * partition.
+ */
+ if (pread(params->fsfd, &pme, sizeof pme, BSIZE * 2) != sizeof(pme))
+ err(1, "read pme from file system `%s'", params->filesystem);
+
+ if (strcmp((char *)pme.pmPartName, "NetBSD_BootBlock"))
+ err(1, "invalid partition map in file system `%s'",
+ params->filesystem);
+
+ /* pmPyPartStart is written by mkisofs */
+ partoff = BSIZE * be32toh(pme.pmPyPartStart);
+
+#ifdef DEBUG
+ printf("NetBSD partition offset = %ld\n", (long)partoff);
+#endif
+
+ params->stage1 = argv[2];
+
+ if ((params->s1fd = open(params->stage1, O_RDONLY, 0600)) == -1)
+ err(1, "Opening primary bootstrap `%s'", params->stage1);
+ if (fstat(params->s1fd, ¶ms->s1stat) == -1)
+ err(1, "Examining primary bootstrap `%s'", params->stage1);
+ if (!S_ISREG(params->s1stat.st_mode))
+ err(1, "`%s' must be a regular file", params->stage1);
+
+ if (params->s1stat.st_size > MACPPC_BOOT_BLOCK_MAX_SIZE)
+ err(1, "primary bootrap `%s' too large (%ld bytes)",
+ params->stage1, (long)params->s1stat.st_size);
+
+#ifdef DEBUG
+ printf("primary boot: %s, %ld bytes\n",
+ params->stage1, (long)params->s1stat.st_size);
+#endif
+
+ params->stage2 = argv[3];
+
+ bb = calloc(1, MACPPC_BOOT_BLOCK_MAX_SIZE);
+ if (bb == NULL)
+ err(1, "Allocating %ul bytes for bbinfo",
+ MACPPC_BOOT_BLOCK_MAX_SIZE);
+
+ rv = read(params->s1fd, bb, params->s1stat.st_size);
+
+ if (rv == -1)
+ err(1, "Reading `%s'", params->stage1);
+
+ if (memcmp(bb + 1, "ELF", strlen("ELF")) == 0) {
+ warnx("`%s' is an ELF executable; need raw binary",
+ params->stage1);
+ }
+
+ /* look for the bbinfo structure */
+ for (bbi = 0; bbi < MACPPC_BOOT_BLOCK_MAX_SIZE;
+ bbi += sizeof(uint32_t)) {
+ bbinfop = (void *)(bb + bbi);
+ if (memcmp(bbinfop->bbi_magic, MACPPC_BBINFO_MAGIC,
+ sizeof(bbinfop->bbi_magic)) == 0) {
+#ifdef DEBUG
+ printf("magic found: %s\n", bbinfop->bbi_magic);
+#endif
+ break;
+ }
+ }
+ if (bbi >= MACPPC_BOOT_BLOCK_MAX_SIZE)
+ err(1, "bbinfo structure not found in `%s'", params->stage1);
+
+ maxblk = be32toh(bbinfop->bbi_block_count);
+ if (maxblk == 0 ||
+ maxblk > (MACPPC_BOOT_BLOCK_MAX_SIZE / sizeof(uint32_t)))
+ err(1, "bbinfo structure in `%s' has preposterous size `%u'",
+ params->stage1, maxblk);
+
+ blocks = malloc(sizeof(*blocks) * maxblk);
+ if (blocks == NULL) {
+ err(1, "Allocating %lu bytes for blocks",
+ (unsigned long)sizeof(*blocks) * maxblk);
+ }
+
+ if (S_ISREG(params->fsstat.st_mode)) {
+ if (fsync(params->fsfd) == -1)
+ err(1, "Synchronising file system `%s'",
+ params->filesystem);
+ }
+
+ nblk = maxblk;
+ if (!params->fstype->findstage2(params, &nblk, blocks)) {
+ exit(1);
+ }
+
+ bbinfop->bbi_block_count = htobe32(nblk);
+ bbinfop->bbi_block_size = htobe32(blocks[0].blocksize);
+ for (blk_i = 0; blk_i < nblk; blk_i++) {
+ /* XXX bootxx assumes blocksize is 512 */
+ block = blocks[blk_i].block * (params->fstype->blocksize / 512);
+ bbinfop->bbi_block_table[blk_i] = htobe32(block);
+ if (blocks[blk_i].blocksize < blocks[0].blocksize &&
+ blk_i + 1 != nblk) {
+ warnx("Secondary bootstrap `%s' blocks do not have "
+ "a uniform size", params->stage2);
+ exit(1);
+ }
+ }
+
+ /* XXX no write option */
+
+ if (pwrite(params->fsfd, bb, MACPPC_BOOT_BLOCK_MAX_SIZE, partoff) !=
+ MACPPC_BOOT_BLOCK_MAX_SIZE)
+ err(1, "write bootblock");
+
+ if (S_ISREG(params->fsstat.st_mode)) {
+ if (fsync(params->fsfd) == -1)
+ err(1, "Synchronising file system `%s'",
+ params->filesystem);
+ }
+
+ free(bb);
+
+ if (close(params->fsfd) == -1)
+ err(1, "Closing file system `%s'", params->filesystem);
+ if (close(params->s1fd) == -1)
+ err(1, "Closing primary bootstrap `%s'", params->stage1);
+
+ return 0;
+}
+
+static void
+usage(void)
+{
+ const char *prog;
+
+ prog = getprogname();
+ fprintf(stderr, "usage: %s hybrid-cd-image primary secondary\n", prog);
+ exit(1);
+}
Index: src/sys/arch/macppc/stand/installboot/installboot.h
diff -u /dev/null src/sys/arch/macppc/stand/installboot/installboot.h:1.1
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/sys/arch/macppc/stand/installboot/installboot.h Sun Sep 15 03:56:57 2024
@@ -0,0 +1,134 @@
+/* $NetBSD: installboot.h,v 1.1 2024/09/15 03:56:57 tsutsui Exp $ */
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Luke Mewburn of Wasabi Systems.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _INSTALLBOOT_H
+#define _INSTALLBOOT_H
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#include "../../sys/sys/bootblock.h"
+#else
+#include <sys/bootblock.h>
+#include <sys/endian.h>
+#endif
+
+#include <sys/stat.h>
+#include <stdint.h>
+
+typedef enum {
+ /* flags from global options */
+ IB_VERBOSE = 1<<0, /* verbose operation */
+ IB_NOWRITE = 1<<1, /* don't write */
+ IB_CLEAR = 1<<2, /* clear boot block */
+
+ /* flags from -o options */
+ IB_ALPHASUM = 1<<8, /* set Alpha checksum */
+ IB_APPEND = 1<<9, /* append stage 1 to EO(regular)F */
+ IB_SUNSUM = 1<<10, /* set Sun checksum */
+ IB_STAGE1START= 1<<11, /* start block for stage 1 provided */
+ IB_STAGE2START= 1<<12, /* start block for stage 2 provided */
+ IB_COMMAND = 1<<13, /* Amiga commandline option */
+ IB_RESETVIDEO = 1<<14, /* i386 reset video */
+ IB_CONSOLE = 1<<15, /* i386 console */
+ IB_CONSPEED = 1<<16, /* i386 console baud rate */
+ IB_TIMEOUT = 1<<17, /* i386 boot timeout */
+ IB_PASSWORD = 1<<18, /* i386 boot password */
+ IB_KEYMAP = 1<<19, /* i386 console keymap */
+ IB_CONSADDR = 1<<20, /* i386 console io address */
+} ib_flags;
+
+typedef struct {
+ ib_flags flags; /* flags (see above) */
+ struct ib_mach *machine; /* machine details (see below) */
+ struct ib_fs *fstype; /* file system details (see below) */
+ const char *filesystem; /* name of target file system */
+ int fsfd; /* open fd to filesystem */
+ struct stat fsstat; /* fstat(2) of fsfd */
+ const char *stage1; /* name of stage1 bootstrap */
+ int s1fd; /* open fd to stage1 */
+ struct stat s1stat; /* fstat(2) of s1fd */
+ uint64_t s1start; /* start block of stage1 */
+ const char *stage2; /* name of stage2 bootstrap */
+ uint64_t s2start; /* start block of stage2 */
+ /* parsed -o option=value data */
+ const char *command; /* name of command string */
+ const char *console; /* name of console */
+ int conspeed; /* console baud rate */
+ int consaddr; /* console io address */
+ const char *password; /* boot password */
+ int timeout; /* interactive boot timeout */
+ const char *keymap; /* keyboard translations */
+} ib_params;
+
+typedef struct {
+ uint64_t block;
+ uint32_t blocksize;
+} ib_block;
+
+struct ib_mach {
+ const char *name;
+ int (*setboot) (ib_params *);
+ int (*clearboot) (ib_params *);
+ ib_flags valid_flags;
+};
+
+struct ib_fs {
+ /* compile time parameters */
+ const char *name;
+ int (*match) (ib_params *);
+ int (*findstage2) (ib_params *, uint32_t *, ib_block *);
+ /* run time fs specific parameters */
+ uint32_t blocksize;
+ uint32_t needswap;
+ off_t sblockloc; /* location of superblock */
+};
+
+typedef enum {
+ BBINFO_BIG_ENDIAN = 0,
+ BBINFO_LITTLE_ENDIAN = 1,
+} bbinfo_endian;
+
+struct bbinfo_params {
+ const char *magic; /* magic string to look for */
+ uint32_t offset; /* offset to write start of stage1 */
+ uint32_t blocksize; /* blocksize of stage1 */
+ uint32_t maxsize; /* max size of stage1 */
+ uint32_t headeroffset; /*
+ * header offset (relative to offset)
+ * to read stage1 into
+ */
+ bbinfo_endian endian;
+};
+
+int cd9660_match(ib_params *);
+int cd9660_findstage2(ib_params *, uint32_t *, ib_block *);
+
+#endif /* _INSTALLBOOT_H */
Index: src/sys/arch/macppc/stand/mkboothfs/Makefile
diff -u /dev/null src/sys/arch/macppc/stand/mkboothfs/Makefile:1.1
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/sys/arch/macppc/stand/mkboothfs/Makefile Sun Sep 15 03:56:58 2024
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2024/09/15 03:56:58 tsutsui Exp $
+
+WARNS?= 5
+NOMAN= # defined
+
+PROG= mkboothfs
+SRCS= mkboothfs.c
+
+.include <bsd.prog.mk>
Index: src/sys/arch/macppc/stand/mkboothfs/mkboothfs.c
diff -u /dev/null src/sys/arch/macppc/stand/mkboothfs/mkboothfs.c:1.1
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/sys/arch/macppc/stand/mkboothfs/mkboothfs.c Sun Sep 15 03:56:58 2024
@@ -0,0 +1,167 @@
+/* $NetBSD: mkboothfs.c,v 1.1 2024/09/15 03:56:58 tsutsui Exp $ */
+
+/*-
+ * Copyright (c) 2005, 2006 Izumi Tsutsui. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#include "../../sys/sys/bootblock.h"
+#else
+#include <sys/bootblock.h>
+#endif
+#if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#define BUFSIZE (64 * 1024)
+
+#define BSIZE 512
+#define BOOTPARTSIZE 32768 /* XXX: not sure how much required */
+#define BOOTDATASIZE (BOOTPARTSIZE - MACPPC_BOOT_BLOCK_MAX_SIZE)
+
+#define HFS_BLKSIZE 512
+#define HFS_MAGICOFFSET (BOOTDATASIZE - (HFS_BLKSIZE * 2))
+#define HFS_MAGIC 0x4c4b
+
+#define SIZETOBLK512(size) ((size) / 512)
+#define SIZETOBLK2048(size) ((size) / 2048)
+
+static void usage(void);
+
+/*
+ * Creates a file for use by mkisofs's -boot-hfs-file.
+ */
+
+int
+main(int argc, char **argv)
+{
+ char *boothfs;
+ int ofd;
+ struct apple_drvr_map dm;
+ struct apple_part_map_entry pme;
+ char *buf;
+
+ if (argc != 2)
+ usage();
+
+ boothfs = argv[1];
+
+ buf = malloc(BUFSIZE);
+ if (buf == NULL)
+ err(1, "malloc write buffer");
+
+ /* create output boot-hfs-file */
+ if ((ofd = open(boothfs, O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1)
+ err(1, "create output boot-hfs-file `%s'", boothfs);
+
+ /*
+ * Populate 18 byte driver map header in the first 512 byte block
+ */
+ memset(&dm, 0, sizeof dm);
+ dm.sbSig = htobe16(APPLE_DRVR_MAP_MAGIC);
+ dm.sbBlockSize = htobe16(2048);
+ dm.sbBlkCount = htobe32(0); /* XXX */
+ dm.sbDevType = htobe16(1);
+ dm.sbDevID = htobe16(1);
+ dm.sbData = 0;
+ dm.sbDrvrCount = 0;
+
+ memset(buf, 0, BSIZE);
+ memcpy(buf, &dm, sizeof(dm));
+ write(ofd, buf, BSIZE);
+
+ /*
+ * Write 2048-byte/sector map in the second 512 byte block
+ */
+ memset(&pme, 0, sizeof(pme));
+ pme.pmSig = htobe16(APPLE_PART_MAP_ENTRY_MAGIC);
+ pme.pmMapBlkCnt = htobe32(1);
+ pme.pmPyPartStart = htobe32(1);
+ pme.pmPartBlkCnt = htobe32(SIZETOBLK2048(BOOTPARTSIZE));
+ pme.pmDataCnt = htobe32(SIZETOBLK2048(BOOTDATASIZE));
+ strlcpy(pme.pmPartName, "NetBSD_BootBlock", sizeof(pme.pmPartName));
+ strlcpy(pme.pmPartType, "Apple_Driver", sizeof(pme.pmPartType));
+ pme.pmPartStatus = htobe32(0x3b);
+ pme.pmBootSize = htobe32(MACPPC_BOOT_BLOCK_MAX_SIZE);
+ pme.pmBootLoad = htobe32(0x4000);
+ pme.pmBootEntry = htobe32(0x4000);
+ strlcpy(pme.pmProcessor, "PowerPC", sizeof(pme.pmProcessor));
+
+ memset(buf, 0, BSIZE);
+ memcpy(buf, &pme, sizeof(pme));
+ write(ofd, buf, BSIZE);
+
+ /*
+ * Write 512-byte/sector map in the third 512 byte block
+ */
+ pme.pmPyPartStart = htobe32(4);
+ pme.pmPartBlkCnt = htobe32(SIZETOBLK512(BOOTPARTSIZE));
+ pme.pmDataCnt = htobe32(SIZETOBLK512(BOOTDATASIZE));
+ memset(buf, 0, BSIZE);
+ memcpy(buf, &pme, sizeof(pme));
+ write(ofd, buf, BSIZE);
+
+ /*
+ * Placeholder for 2048 byte padding
+ */
+ memset(buf, 0, BSIZE);
+ write(ofd, buf, BSIZE);
+
+ /*
+ * Placeholder for NetBSD bootblock
+ */
+ memset(buf, 0, MACPPC_BOOT_BLOCK_MAX_SIZE);
+ write(ofd, buf, MACPPC_BOOT_BLOCK_MAX_SIZE);
+
+ /*
+ * Prepare HFS "bootblock"; enough to pacify mkisofs.
+ */
+ memset(buf, 0, BOOTDATASIZE);
+ be16enc(&buf[HFS_MAGICOFFSET], HFS_MAGIC);
+ if (write(ofd, buf, BOOTDATASIZE) != BOOTDATASIZE)
+ err(1, "write boot-hfs-file `%s'", boothfs);
+
+ free(buf);
+ close(ofd);
+ return 0;
+}
+
+static void
+usage(void)
+{
+ const char *prog;
+
+ prog = getprogname();
+ fprintf(stderr, "usage: %s boot-hfs-file\n", prog);
+ exit(1);
+}
Index: src/tools/macppc_mkboothfs/Makefile
diff -u /dev/null src/tools/macppc_mkboothfs/Makefile:1.1
--- /dev/null Sun Sep 15 03:56:58 2024
+++ src/tools/macppc_mkboothfs/Makefile Sun Sep 15 03:56:58 2024
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2024/09/15 03:56:58 tsutsui Exp $
+
+.include <bsd.hostinit.mk>
+
+HOSTPROGNAME= ${_TOOL_PREFIX}macppc_mkboothfs
+HOST_SRCDIR= sys/arch/macppc/stand/mkboothfs
+
+.include "${.CURDIR}/../Makefile.nbincludes"
+.include "${.CURDIR}/../Makefile.host"