Add support for amiga.

This commit is contained in:
mhitch 2003-01-15 06:33:13 +00:00
parent 0d8f526f58
commit e7852b0563
5 changed files with 217 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.21 2002/06/02 10:44:57 isaki Exp $
# $NetBSD: Makefile,v 1.22 2003/01/15 06:33:58 mhitch Exp $
#
.include <bsd.own.mk>
@ -6,7 +6,7 @@
PROG= installboot
SRCS= installboot.c sum.c machines.c fstypes.c \
ffs.c ffs_bswap.c bbinfo.c \
alpha.c macppc.c news.c pmax.c sparc.c sparc64.c sun68k.c vax.c x68k.c
alpha.c amiga.c macppc.c news.c pmax.c sparc.c sparc64.c sun68k.c vax.c x68k.c
MAN= installboot.8
WARNS?= 3

View File

@ -0,0 +1,195 @@
/* $NetBSD: amiga.c,v 1.1 2003/01/15 06:33:13 mhitch Exp $ */
/*-
* Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Michael Hitch.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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.
*/
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
__RCSID("$NetBSD: amiga.c,v 1.1 2003/01/15 06:33:13 mhitch Exp $");
#endif /* !__lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <assert.h>
#include <err.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "installboot.h"
/* XXX Must be kept in sync with bbstart.s! */
#define CMDLN_LOC 0x10
#define CMDLN_LEN 0x20
char command[CMDLN_LEN];
#define CHKSUMOFFS 1
u_int32_t chksum(u_int32_t *, int);
int amiga_parseopt(ib_params *, const char *);
int amiga_setboot(ib_params *);
int amiga_clearboot(ib_params *);
int
amiga_parseopt(ib_params *params, const char *option)
{
if (strncmp("command=", option, strlen("command=")) == 0) {
strncpy(command, option + strlen("command="), CMDLN_LEN);
params->flags |= IB_COMMAND;
return (1);
}
warnx("Unknown -o option `%s'", option);
return (0);
}
int
amiga_clearboot(ib_params *params)
{
return 0;
}
int
amiga_setboot(ib_params *params)
{
int retval;
ssize_t rv;
char *dline;
int sumlen;
u_int32_t sum2, sum16;
struct stat bootstrapsb;
u_int32_t block[128*16];
if (fstat(params->s1fd, &bootstrapsb) == -1) {
warn("Examining `%s'", params->stage1);
goto done;
}
if (!S_ISREG(bootstrapsb.st_mode)) {
warnx("`%s' must be a regular file", params->stage1);
goto done;
}
rv = pread(params->s1fd, &block, sizeof(block), 0);
if (rv == -1) {
warn("Reading `%s'", params->stage1);
goto done;
} else if (rv != sizeof(block)) {
warnx("Reading `%s': short read", params->stage1);
goto done;
}
/* XXX the choices should not be hardcoded */
sum2 = chksum(block, 1024/4);
sum16 = chksum(block, 8192/4);
if (sum16 == 0xffffffff) {
sumlen = 8192/4;
} else if (sum2 == 0xffffffff) {
sumlen = 1024/4;
} else {
errx(1, "%s: wrong checksum", params->stage1);
/* NOTREACHED */
}
if (sum2 == sum16) {
warnx("eek - both sums are the same");
}
if (params->flags & IB_COMMAND) {
dline = (char *)&(block[CMDLN_LOC/4]);
/* XXX keep the default default line in sync with bbstart.s */
if (strcmp(dline, "netbsd -ASn2") != 0) {
errx(1, "Old bootblock version? Can't change command line.");
}
(void)strncpy(dline, command, CMDLN_LEN-1);
block[1] = 0;
block[1] = 0xffffffff - chksum(block, sumlen);
}
if (params->flags & IB_NOWRITE) {
retval = 1;
goto done;
}
if (params->flags & IB_VERBOSE)
printf("Writing boot block\n");
rv = pwrite(params->fsfd, &block, sizeof(block), 0);
if (rv == -1) {
warn("Writing `%s'", params->filesystem);
goto done;
} else if (rv != sizeof(block)) {
warnx("Writing `%s': short write", params->filesystem);
goto done;
} else {
retval = 1;
}
done:
return (retval);
}
u_int32_t
chksum(block, size)
u_int32_t *block;
int size;
{
u_int32_t sum, lastsum;
int i;
sum = 0;
for (i=0; i<size; i++) {
lastsum = sum;
sum += htobe32(block[i]);
if (sum < lastsum)
++sum;
}
return sum;
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: installboot.8,v 1.23 2002/10/03 07:27:50 lukem Exp $
.\" $NetBSD: installboot.8,v 1.24 2003/01/15 06:33:58 mhitch Exp $
.\"
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -150,6 +150,7 @@ into
The following platforms do not require this step if the primary bootstrap
already exists and the secondary bootstrap file is just being updated:
.Sy alpha ,
.Sy amiga ,
.Sy pmax ,
.Sy sparc64 ,
and
@ -206,6 +207,7 @@ The following machines are currently supported by
.Nm "" :
.Bd -ragged -offset indent
.Sy alpha ,
.Sy amiga ,
.Sy macppc ,
.Sy news68k ,
.Sy newsmips ,
@ -248,6 +250,10 @@ to the end of
.Ar filesystem ,
which must be a regular file in this case.
.
.It Sy command=<boot command>
.Sy [ amiga ]
Modify the default boot command line.
.
.It Sy sunsum
.Sy [ alpha ,
.Sy pmax ,
@ -421,6 +427,11 @@ with the secondary bootstrap
already present:
.Dl Ic installboot /dev/rsd0c /usr/mdec/bootxx /boot
.
.Ss NetBSD/amiga examples
Modify the command line to change the default from "netbsd -ASn2" to
"netbsd -S":
.Dl Ic installboot -m amiga -o command="netbsd -S" /dev/rsd0a /usr/mdec/bootxx_ffs
.
.Sh SEE ALSO
.Xr uname 3 ,
.Xr boot 8 ,
@ -446,8 +457,9 @@ Ross Harvey (alpha),
Paul Kranenburg (sparc),
Luke Mewburn (macppc),
Matt Thomas (vax),
Izumi Tsutsui (news68k, newsmips),
and
Izumi Tsutsui (news68k, newsmips).
Michael Hitch (amiga).
.
.Sh BUGS
There are not currently primary bootstraps to support all file systems

View File

@ -1,4 +1,4 @@
/* $NetBSD: installboot.h,v 1.15 2002/10/03 05:31:25 lukem Exp $ */
/* $NetBSD: installboot.h,v 1.16 2003/01/15 06:33:58 mhitch Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -61,6 +61,7 @@ typedef enum {
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_flags;
typedef struct {
@ -145,6 +146,8 @@ int raw_findstage2(ib_params *, uint32_t *, ib_block *);
int alpha_parseopt(ib_params *, const char *);
int alpha_setboot(ib_params *);
int alpha_clearboot(ib_params *);
int amiga_parseopt(ib_params *, const char *);
int amiga_setboot(ib_params *);
int macppc_setboot(ib_params *);
int macppc_clearboot(ib_params *);
int news68k_setboot(ib_params *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: machines.c,v 1.12 2002/06/02 10:44:57 isaki Exp $ */
/* $NetBSD: machines.c,v 1.13 2003/01/15 06:33:58 mhitch Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -41,6 +41,7 @@
struct ib_mach machines[] = {
{ "alpha", alpha_parseopt, alpha_setboot, alpha_clearboot },
{ "amiga", amiga_parseopt, amiga_setboot, no_clearboot },
{ "i386", no_parseopt, no_setboot, no_clearboot },
{ "macppc", no_parseopt, macppc_setboot, macppc_clearboot },
{ "news68k", no_parseopt, news68k_setboot, news68k_clearboot },