Move via repository copy to sys/arch/pmax/stand/scsiboot

This commit is contained in:
simonb 1999-01-20 12:03:56 +00:00
parent c8851d63a0
commit 47c28b03d8
8 changed files with 0 additions and 1079 deletions

View File

@ -1,170 +0,0 @@
/* $NetBSD: boot.c,v 1.6 1995/06/28 10:22:32 jonathan Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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 University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
*
* @(#)boot.c 8.1 (Berkeley) 6/10/93
*/
#include <sys/param.h>
#include <sys/exec.h>
#include <stand.h>
#include <pmax/stand/dec_prom.h>
#include "byteswap.h"
char line[1024];
/*
* This gets arguments from the PROM, calls other routines to open
* and load the program to boot, and then transfers execution to that
* new program.
* Argv[0] should be something like "rz(0,0,0)vmunix" on a DECstation 3100.
* Argv[0,1] should be something like "boot 5/rz0/vmunix" on a DECstation 5000.
* The argument "-a" means vmunix should do an automatic reboot.
*/
int
main(argc, argv)
int argc;
char **argv;
{
register char *cp;
int ask, entry;
#ifdef DIAGNOSTIC
extern int prom_id; /* hack, saved by standalone startup */
(*(callvec._printf))("hello, world\n");
printf ((callv == &callvec)? "No REX %x\n" : "have REX %x\n",
prom_id);
#endif
#ifdef JUSTASK
ask = 1;
#else
/* check for DS5000 boot */
if (strcmp(argv[0], "boot") == 0) {
argc--;
argv++;
}
cp = *argv;
ask = 0;
#endif /* JUSTASK */
printf("Boot: ");
if (ask) {
gets(line);
if (line[0] == '\0')
return 0;
cp = line;
argv[0] = cp;
argc = 1;
} else
printf("%s\n", cp);
entry = loadfile(cp);
if (entry == -1)
return 0;
printf("Starting at 0x%x\n\n", entry);
if (callv == &callvec)
((void (*)())entry)(argc, argv, 0, 0);
else
((void (*)())entry)(argc, argv, DEC_PROM_MAGIC, callv);
}
/*
* Open 'filename', read in program and return the entry point or -1 if error.
*/
loadfile(fname)
register char *fname;
{
register struct devices *dp;
register int fd, i, n;
struct exec aout;
if ((fd = open(fname, 0)) < 0) {
printf("open(%s) failed: %d\n", fname, errno);
goto err;
}
/* read the exec header */
i = read(fd, (char *)&aout, sizeof(aout));
if (i != sizeof(aout)) {
printf("no aout header\n");
goto cerr;
} else if ((N_GETMAGIC(aout) != OMAGIC)
&& (aout.a_midmag & 0xfff) != OMAGIC) {
printf("%s: bad magic %x\n", fname, aout.a_midmag);
goto cerr;
}
/* read the code and initialized data */
printf("Size: %d+%d", aout.a_text, aout.a_data);
#if 0
/* In an OMAGIC file, we're already there. */
if (lseek(fd, (off_t)N_TXTOFF(aout), 0) < 0) {
goto cerr;
}
#endif
i = aout.a_text + aout.a_data;
n = read(fd, (char *)aout.a_entry, i);
#ifndef SMALL
(void) close(fd);
#endif
if (n < 0) {
printf("read error %d\n", errno);
goto err;
} else if (n != i) {
printf("read() short %d bytes\n", i - n);
goto err;
}
/* kernel will zero out its own bss */
n = aout.a_bss;
printf("+%d\n", n);
return ((int)aout.a_entry);
cerr:
#ifndef SMALL
(void) close(fd);
#endif
err:
printf("Can't boot '%s'\n", fname);
return (-1);
}

View File

@ -1,10 +0,0 @@
/* $NetBSD: byteswap.h,v 1.2 1998/01/05 07:03:16 perry Exp $ */
/*
* inline macros for doing byteswapping on a little-endian machine.
* for boot.
*/
#define ntohs(x) \
( ( ((u_short)(x)&0xff) << 8) | ( ((u_short) (x)&0xff00) >> 8) )
#define ntohl(x) \
( ((ntohs((u_short)(x))) << 16) | (ntohs( (u_short) ((x)>>16) )) )

View File

@ -1,72 +0,0 @@
/* $NetBSD: conf.c,v 1.5 1995/01/18 06:53:39 mellon Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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 University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
*
* @(#)conf.c 8.1 (Berkeley) 6/10/93
*/
#include <stand.h>
#include <dec_prom.h>
const struct callback *callv = &callvec;
int errno;
extern void nullsys();
extern int nodev(), noioctl();
int rzstrategy(), rzopen();
#ifdef SMALL
#define rzclose 0
#else /*!SMALL*/
int rzclose();
#endif /*!SMALL*/
#define rzioctl noioctl
#ifndef BOOT
int tzstrategy(), tzopen(), tzclose();
#endif
#define tzioctl noioctl
struct devsw devsw[] = {
{ "rz", rzstrategy, rzopen, rzclose, rzioctl }, /*0*/
#ifndef BOOT
{ "tz", tzstrategy, tzopen, tzclose, tzioctl }, /*1*/
#endif
};
int ndevs = (sizeof(devsw)/sizeof(devsw[0]));

View File

@ -1,48 +0,0 @@
/*
* Copyright (c) 1993 Philip A. Nelson.
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Philip A. Nelson.
* 4. The name of Philip A. Nelson may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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.
*
* filesystem.c
*
* $NetBSD: filesystem.c,v 1.2 1997/10/13 14:22:45 lukem Exp $
*/
#include <stand.h>
#include <ufs.h>
struct fs_ops file_system[] = {
#ifdef SMALL
{ ufs_open, 0, ufs_read, 0, ufs_seek, ufs_stat }
#else
{ ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }
#endif
};
int nfsys = sizeof(file_system)/sizeof(struct fs_ops);

View File

@ -1,214 +0,0 @@
/* $NetBSD: mkboot.c,v 1.5 1995/01/18 06:53:42 mellon Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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 University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
*
* @(#)mkboot.c 8.1 (Berkeley) 6/10/93
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif not lint
#ifndef lint
#ifdef notdef
static char sccsid[] = "@(#)mkboot.c 8.1 (Berkeley) 6/10/93";
#endif
static char rcsid[] = "$NetBSD: mkboot.c,v 1.5 1995/01/18 06:53:42 mellon Exp $";
#endif not lint
#include <sys/param.h>
#include <sys/exec.h>
#include <sys/disklabel.h>
#include <stdio.h>
#include <pmax/stand/dec_boot.h>
struct Dec_DiskBoot decBootInfo;
char block[DEV_BSIZE];
char *bootfname, *xxboot, *bootxx;
/*
* This program takes a boot program and splits it into xxboot and bootxx
* files for the disklabel program. The disklabel program should be used to
* label and install the boot program onto a new disk.
*
* mkboot bootprog xxboot bootxx
*/
main(argc, argv)
int argc;
char *argv[];
{
register int i, n;
int ifd, ofd1, ofd2;
int nsectors;
long loadAddr;
long execAddr;
long length;
if (argc != 4)
usage();
bootfname = argv[1];
xxboot = argv[2];
bootxx = argv[3];
ifd = open(bootfname, 0, 0);
if (ifd < 0) {
perror(bootfname);
exit(1);
}
ofd1 = creat(xxboot, 0666);
if (ofd1 < 0) {
xxboot_err:
perror(xxboot);
exit(1);
}
ofd2 = creat(bootxx, 0666);
if (ofd2 < 0) {
bootxx_err:
perror(bootxx);
exit(1);
}
/*
* Check for exec header and skip to code segment.
*/
if (!GetHeader(ifd, &loadAddr, &execAddr, &length)) {
fprintf(stderr, "Need impure text format (OMAGIC) file\n");
exit(1);
}
/*
* Write the boot information block.
*/
decBootInfo.magic = DEC_BOOT_MAGIC;
decBootInfo.mode = 0;
decBootInfo.loadAddr = loadAddr;
decBootInfo.execAddr = execAddr;
decBootInfo.map[0].numBlocks = nsectors =
(length + DEV_BSIZE - 1) >> DEV_BSHIFT;
decBootInfo.map[0].startBlock = 1;
decBootInfo.map[1].numBlocks = 0;
if (write(ofd1, (char *)&decBootInfo, sizeof(decBootInfo)) !=
sizeof(decBootInfo) || close(ofd1) != 0)
goto xxboot_err;
printf("load %x, start %x, len %d, nsectors %d\n", loadAddr, execAddr,
length, nsectors);
/*
* Write the boot code to the bootxx file.
*/
for (i = 0; i < nsectors && length > 0; i++) {
if (length < DEV_BSIZE) {
n = length;
bzero(block, DEV_BSIZE);
} else
n = DEV_BSIZE;
if (read(ifd, block, n) != n) {
perror(bootfname);
break;
}
length -= n;
if (write(ofd2, block, DEV_BSIZE) != DEV_BSIZE) {
perror(bootxx);
break;
}
}
if (length > 0)
printf("Warning: didn't reach end of boot program!\n");
exit(0);
}
usage()
{
printf("Usage: mkboot bootprog xxboot bootxx\n");
printf("where:\n");
printf("\t\"bootprog\" is a -N format file\n");
printf("\t\"xxboot\" is the file name for the first boot block\n");
printf("\t\"bootxx\" is the file name for the remaining boot blocks.\n");
exit(1);
}
/*
*----------------------------------------------------------------------
*
* GetHeader -
*
* Check if the header is an a.out file.
*
* Results:
* Return true if all went ok.
*
* Side effects:
* bootFID is left ready to read the text & data sections.
* length is set to the size of the text + data sections.
*
*----------------------------------------------------------------------
*/
GetHeader(bootFID, loadAddr, execAddr, length)
int bootFID; /* Handle on the boot program */
long *loadAddr; /* Address to start loading boot program. */
long *execAddr; /* Address to start executing boot program. */
long *length; /* Length of the boot program. */
{
struct exec aout;
int bytesRead;
if (lseek(bootFID, 0, 0) < 0) {
perror(bootfname);
return 0;
}
bytesRead = read(bootFID, (char *)&aout, sizeof(aout));
if (bytesRead != sizeof(aout)
|| (N_GETMAGIC(aout) != OMAGIC &&
(aout.a_midmag & 0xffff) != OMAGIC))
return 0;
*loadAddr = aout.a_entry;
*execAddr = aout.a_entry;
*length = aout.a_text + aout.a_data;
#if 0 /* N_TXTOFF(aout) on an OMAGIC file is where we are now. */
if (lseek(bootFID, N_TXTOFF(aout), 0) < 0) {
perror(bootfname);
return 0;
}
#endif
if (N_GETMAGIC (aout) == OMAGIC)
printf("Input file is in NetBSD a.out format.\n");
else
printf ("Input file is in 4.4BSD mips a.out format.\n");
return 1;
}

View File

@ -1,244 +0,0 @@
/* $NetBSD: mkboottape.c,v 1.7 1997/11/01 06:49:53 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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 University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
*
* @(#)mkboottape.c 8.1 (Berkeley) 6/10/93
*/
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/exec.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <err.h>
#include <pmax/stand/dec_boot.h>
#include <pmax/stand/dec_exec.h>
void usage __P((void));
struct Dec_DiskBoot decBootInfo;
struct coff_exec dec_exec;
extern char *__progname; /* Program name, from crt0. */
/*
* This program takes a kernel and the name of the special device file that
* has the mini-root file system stored on it and creates a boot tape.
* The -b option makes a bootfile that can load the kernel and mini-root
* over the network using the 'boot 6/tftp/filename -m' PROM command.
*
* usage: mkboottape [-b] tapedev netbsd minirootdev size
*/
int
main(argc, argv)
int argc;
char *argv[];
{
register int i, n;
ProcSectionHeader shdr;
struct exec aout;
long loadAddr;
long execAddr;
off_t textoff;
long length;
long rootsize;
int ifd, ofd, rfd;
int makebootfile;
int nsectors;
char block[DEV_BSIZE];
makebootfile = 0;
while ((i = getopt(argc, argv, "b")) != -1)
switch(i) {
case 'b':
makebootfile = 1;
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (argc != 4)
usage();
if (makebootfile)
ofd = open(argv[0], O_CREAT|O_TRUNC|O_WRONLY, DEFFILEMODE);
else
ofd = open(argv[0], O_RDWR, 0);
if (ofd < 0)
deverr: err(1, "%s", argv[0]);
if ((ifd = open(argv[1], O_RDONLY, 0)) < 0)
bootferr: err(1, "%s", argv[1]);
if ((rfd = open(argv[2], O_RDONLY, 0)) < 0)
rooterr: err(1, "%s", argv[2]);
rootsize = atoi(argv[3]);
/*
* Check for exec header and skip to code segment.
*/
if (read(ifd, &aout, sizeof(aout)) != sizeof(aout)
|| ((N_GETMAGIC (aout) != OMAGIC)
&& (aout.a_midmag & 0xffff) != OMAGIC)) {
fprintf(stderr, "%s: %s: need old text format (OMAGIC) file\n",
__progname, argv[1]);
exit(1);
}
loadAddr = aout.a_entry;
execAddr = aout.a_entry;
length = aout.a_text + aout.a_data;
#if 0
textoff = N_TXTOFF(aout);
#endif
(void)printf("Input file is a.out format\n");
(void)printf("load %x, start %x, len %d\n", loadAddr, execAddr, length);
/*
* Compute size of boot program rounded to page size + mini-root size.
*/
nsectors = (((length + aout.a_bss + NBPG - 1) & ~(NBPG - 1)) >>
DEV_BSHIFT) + rootsize;
if (makebootfile) {
/*
* Write the ECOFF header.
*/
dec_exec.magic = COFF_MAGIC;
dec_exec.numSections = 1;
dec_exec.optHeader = 56;
dec_exec.flags = 7;
dec_exec.aout_magic = OMAGIC;
dec_exec.verStamp = 512;
dec_exec.codeSize = nsectors << DEV_BSHIFT;
dec_exec.entry = execAddr;
dec_exec.codeStart = loadAddr;
dec_exec.heapStart = dec_exec.bssStart =
dec_exec.codeStart + aout.a_text;
if (write(ofd, (char *)&dec_exec, sizeof(dec_exec)) !=
sizeof(dec_exec))
goto deverr;
strncpy(shdr.name, ".text", sizeof(shdr.name));
shdr.physAddr = shdr.virtAddr = loadAddr;
shdr.size = dec_exec.codeSize;
shdr.sectionPtr = n =
(sizeof(dec_exec) + sizeof(shdr) + 15) & ~15;
shdr.relocPtr = 0;
shdr.lnnoPtr = 0;
shdr.numReloc = 0;
shdr.numLnno = 0;
shdr.flags = 0x20;
if (write(ofd, (char *)&shdr, sizeof(shdr)) != sizeof(shdr))
goto deverr;
n -= sizeof(dec_exec) + sizeof(shdr);
if (write(ofd, block, n) != n)
goto deverr;
} else {
/*
* Write the boot information block.
*/
decBootInfo.magic = DEC_BOOT_MAGIC;
decBootInfo.mode = 0;
decBootInfo.loadAddr = loadAddr;
decBootInfo.execAddr = execAddr;
decBootInfo.map[0].numBlocks = nsectors;
decBootInfo.map[0].startBlock = 1;
decBootInfo.map[1].numBlocks = 0;
if (write(ofd, (char *)&decBootInfo, sizeof(decBootInfo)) !=
sizeof(decBootInfo))
goto deverr;
}
#if 0
/* seek to start of text */
if (lseek(ifd, textoff, SEEK_SET) < 0)
goto bootferr;
#endif
/*
* Write the remaining code to the correct place on the tape.
*/
for (i = length; i > 0; i -= n) {
n = DEV_BSIZE;
if (n > i)
n = i;
if (read(ifd, block, n) != n)
goto bootferr;
if (write(ofd, block, DEV_BSIZE) != DEV_BSIZE)
goto deverr;
}
/*
* Pad the boot file with zeros to the start of the mini-root.
*/
bzero(block, DEV_BSIZE);
i = ((nsectors - rootsize) << DEV_BSHIFT) -
((length + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1));
n = DEV_BSIZE;
for (; i > 0; i -= n) {
if (write(ofd, block, n) != n)
goto deverr;
}
/*
* Write the mini-root to tape.
*/
for (i = rootsize; i > 0; i--) {
if (read(rfd, block, DEV_BSIZE) != DEV_BSIZE)
goto rooterr;
if (write(ofd, block, DEV_BSIZE) != DEV_BSIZE)
goto deverr;
}
(void)printf("%s: wrote %d sectors\n", __progname, nsectors);
exit(0);
}
void
usage()
{
(void)fprintf(stderr,
"usage: %s [-b] tapedev netbsd minirootdev size\n", __progname);
exit(1);
}

View File

@ -1,185 +0,0 @@
/* $NetBSD: rz.c,v 1.6 1995/06/28 10:22:35 jonathan Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Van Jacobson of Lawrence Berkeley Laboratory and Ralph Campbell.
*
* 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 University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
*
* @(#)rz.c 8.1 (Berkeley) 6/10/93
*/
#include <stdarg.h>
#include <stand.h>
#include <sys/param.h>
#include <sys/disklabel.h>
#include "dec_prom.h"
struct rz_softc {
int sc_fd; /* PROM file id */
int sc_ctlr; /* controller number */
int sc_unit; /* disk unit number */
int sc_part; /* disk partition number */
struct disklabel sc_label; /* disk label for this disk */
};
int
rzstrategy(devdata, rw, bn, reqcnt, addr, cnt)
void *devdata;
int rw;
daddr_t bn;
u_int reqcnt;
char *addr;
u_int *cnt; /* out: number of bytes transfered */
{
register struct rz_softc *sc = (struct rz_softc *)devdata;
register int part = sc->sc_part;
register struct partition *pp = &sc->sc_label.d_partitions[part];
register int s;
long offset;
offset = bn * DEV_BSIZE;
#ifdef DEBUG
/*XXX*/printf("rz:%x %d\n", offset, reqcnt);
#endif
/*
* Partial-block transfers not handled.
*/
if (reqcnt & (DEV_BSIZE - 1)) {
*cnt = 0;
return (EINVAL);
}
offset += pp->p_offset * DEV_BSIZE;
if (callv == &callvec) {
/* No REX on this machine */
if (prom_lseek(sc->sc_fd, offset, 0) < 0)
return (EIO);
s = prom_read(sc->sc_fd, addr, reqcnt);
} else
s = bootread (offset / 512, addr, reqcnt);
if (s < 0)
return (EIO);
*cnt = s;
return (0);
}
int
rzopen(struct open_file *f, ...)
{
register int ctlr, unit, part;
register struct rz_softc *sc;
register struct disklabel *lp;
register int i;
char *msg;
char buf[DEV_BSIZE];
int cnt;
static char device[] = "rz(0,0,0)";
va_list ap;
va_start(ap, f);
ctlr = va_arg(ap, int);
unit = va_arg(ap, int);
part = va_arg(ap, int);
if (unit >= 8 || part >= 8)
return (ENXIO);
device[5] = '0' + unit;
/* NOTE: only support reads for now */
/* Another NOTE: bootinit on the TurboChannel doesn't look at
the device string - it's provided for compatibility with
the DS3100 PROMs. As a consequence, it may be possible to
boot from some other drive with these bootblocks on the 3100,
but will not be possible on any TurboChannel machine. */
if (callv == &callvec)
i = prom_open(device, 0);
else
i = bootinit (device);
if (i < 0) {
printf("boot init failed\n");
return (ENXIO);
}
sc = alloc(sizeof(struct rz_softc));
bzero(sc, sizeof(struct rz_softc));
f->f_devdata = (void *)sc;
sc->sc_fd = i;
sc->sc_ctlr = ctlr;
sc->sc_unit = unit;
sc->sc_part = part;
/* try to read disk label and partition table information */
lp = &sc->sc_label;
lp->d_secsize = DEV_BSIZE;
lp->d_secpercyl = 1;
lp->d_npartitions = MAXPARTITIONS;
lp->d_partitions[part].p_offset = 0;
lp->d_partitions[part].p_size = 0x7fffffff;
i = rzstrategy(sc, F_READ, (daddr_t)LABELSECTOR, DEV_BSIZE, buf, &cnt);
if (i || cnt != DEV_BSIZE) {
printf("rz%d: error reading disk label\n", unit);
goto bad;
} else {
msg = getdisklabel(buf, lp);
if (msg) {
printf("rz%d: %s\n", unit, msg);
goto bad;
}
}
if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0) {
bad:
#ifndef SMALL
free(sc, sizeof(struct rz_softc));
#endif
return (ENXIO);
}
return (0);
}
#ifndef SMALL
rzclose(f)
struct open_file *f;
{
free(f->f_devdata, sizeof(struct rz_softc));
f->f_devdata = (void *)0;
return (0);
}
#endif

View File

@ -1,136 +0,0 @@
/* $NetBSD: start.S,v 1.2 1997/06/16 01:24:00 jonathan Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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 University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
*
* @(#)start.s 8.2 (Berkeley) 1/21/94
*/
/*
* start.s -
*
* Contains code that is the first executed at boot time.
*
* Copyright (C) 1989 Digital Equipment Corporation.
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appears in all copies.
* Digital Equipment Corporation makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* from: Header: /sprite/src/boot/decprom/ds3100.md/RCS/start.s,
* v 1.1 90/02/16 16:19:39 shirriff Exp SPRITE (DECWRL)
*/
#include <mips/regdef.h>
#include <mips/asm.h>
#include <mips/cpuregs.h>
#include <pmax/stand/dec_prom.h>
/*
* Amount to take off of the stack for the benefit of the debugger.
*/
#define START_FRAME ((4 * 4) + 4 + 4)
.globl start
start:
.set noreorder
#ifdef __GP_SUPPORT__
la gp, _C_LABEL (_gp)
#endif
la sp, start - START_FRAME
sw zero, START_FRAME - 4(sp) # Zero out old ra for debugger
sw zero, START_FRAME - 8(sp) # Zero out old fp for debugger
move s0, a0 # save argc
move s1, a1 # save argv
move s3, a3 # save call vector
beq a2, 0x30464354, 1f # jump if boot from DS5000
nop
la s3, _C_LABEL(callvec) # init call vector
1:
la a0, _C_LABEL (edata) # clear BSS
la a1, _C_LABEL (end)
jal _C_LABEL(bzero) # bzero(edata, end - edata)
subu a1, a1, a0
sw s3, _C_LABEL(callv) # save call vector
move a0, s0 # restore argc
jal _C_LABEL(main) # main(argc, argv)
move a1, s1 # restore argv
j _C_LABEL(prom_restart) # restart...
nop
/* dummy routine for gcc2 */
.globl _C_LABEL(__main)
_C_LABEL(__main):
j ra
nop
LEAF(prom_restart)
lw v0, _C_LABEL (callv)
lw v0, 0x9C(v0) /* halt */
move a0, zero /* Don't print anything. */
j v0
move a1, zero
END(prom_restart)
#if 0
LEAF(prom_open)
li v0, DEC_PROM_OPEN
j v0
nop
END(prom_open)
LEAF(prom_lseek)
li v0, DEC_PROM_LSEEK
j v0
nop
END(prom_lseek)
LEAF(prom_read)
li v0, DEC_PROM_READ
j v0
nop
END(prom_read)
#endif
LEAF(printf)
lw v0, _C_LABEL(callv) # get pointer to call back vectors
sw a1, 4(sp) # store args on stack for printf
lw v0, 48(v0) # offset for callv->printf
sw a2, 8(sp)
j v0 # call PROM printf
sw a3, 12(sp)
END(printf)