compiles, but...
This commit is contained in:
parent
25590bff04
commit
03137e0abf
|
@ -0,0 +1,5 @@
|
|||
# $NetBSD: Makefile,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $
|
||||
|
||||
SUBDIR= libsa boot bootxx installboot
|
||||
|
||||
.include <bsd.subdir.mk>
|
|
@ -0,0 +1,27 @@
|
|||
# $NetBSD: Makefile.inc,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $
|
||||
|
||||
.if defined(SA_PROG)
|
||||
|
||||
# Must have S=/usr/src/sys (or equivalent)
|
||||
# But note: this is w.r.t. a subdirectory
|
||||
S= ../../../..
|
||||
|
||||
RELOC?= 240000
|
||||
DEFS?= -DSTANDALONE
|
||||
INCL?= -I. -I../libsa -I${S}/lib/libsa -I${S}
|
||||
COPTS?= -msoft-float ${DEFS} ${INCL}
|
||||
|
||||
LIBSA?= ../libsa
|
||||
SRTOBJ?= ${LIBSA}/SRT0.o ${LIBSA}/SRT1.o
|
||||
LIBS?= ${LIBSA}/libsa.a
|
||||
|
||||
SRCS?= ${SA_PROG}.c
|
||||
OBJS?= ${SRTOBJ} ${SRCS:S/.c/.o/g}
|
||||
|
||||
all: ${SA_PROG}
|
||||
|
||||
${SA_PROG} : ${OBJS} ${LIBS}
|
||||
${LD} -N -T ${RELOC} -e start -o $@ ${OBJS} ${LIBS}
|
||||
@size $@
|
||||
|
||||
.endif
|
|
@ -0,0 +1,21 @@
|
|||
/* $NetBSD: README,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $ */
|
||||
|
||||
The sun bootblocks are split into two parts: a small 1st-level program that
|
||||
gets written right after the superblock in a partition (and is hence limited
|
||||
in size to SBSIZE - DEV_BSIZE bytes), and a 2nd-level program that resides
|
||||
in the filesystem proper.
|
||||
|
||||
The 1st-level program is loaded into memory by the PROM. It loads the second
|
||||
stage program from a set of filesystem block numbers that are hard-coded
|
||||
into it by the `installboot' program. The prototype code for the 1st-level
|
||||
bootblocks are in `bootxx'.
|
||||
|
||||
The 2nd-level program (`boot') is normally installed in the root directory
|
||||
as `/boot'. It uses the device drivers in the PROM and the stand-alone
|
||||
filesystem code in `libsa.a' to locate and load the kernel.
|
||||
|
||||
Use the following command to install the 1st-level bootblocks in the
|
||||
root filesystem (on `sd0a') using the file `/boot' as the second level
|
||||
boot program:
|
||||
|
||||
installboot /boot bootxx /dev/rsd0a
|
|
@ -0,0 +1,6 @@
|
|||
# $NetBSD: Makefile,v 1.1.1.1 1995/02/14 22:56:37 gwr Exp $
|
||||
|
||||
SA_PROG= boot
|
||||
SRCS= boot.c filesystem.c version.c
|
||||
|
||||
.include <bsd.prog.mk>
|
|
@ -0,0 +1,163 @@
|
|||
/* $NetBSD: boot.c,v 1.1.1.1 1995/02/14 22:56:37 gwr Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1993
|
||||
* The Regents of the University of California. 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 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 <machine/mon.h>
|
||||
#include <a.out.h>
|
||||
|
||||
#include "stand.h"
|
||||
|
||||
int debug;
|
||||
int errno;
|
||||
int netif_debug;
|
||||
|
||||
/*
|
||||
* Boot device is derived from ROM provided information.
|
||||
*/
|
||||
#define LOADADDR 0x4000
|
||||
#define DEFAULT_KERNEL "netbsd"
|
||||
extern char *version;
|
||||
char kernel[100];
|
||||
unsigned long esym;
|
||||
char *strtab;
|
||||
int strtablen;
|
||||
|
||||
main()
|
||||
{
|
||||
MachMonBootParam *bp;
|
||||
char *cp;
|
||||
int io;
|
||||
|
||||
printf(">> NetBSD BOOT [%s]\n", version);
|
||||
|
||||
bp = *romp->bootParam;
|
||||
cp = bp->fileName;
|
||||
|
||||
if (cp == 0 || *cp == 0) {
|
||||
strcpy(kernel, DEFAULT_KERNEL);
|
||||
} else {
|
||||
char *kp = kernel;
|
||||
|
||||
while (*cp && *cp != '-')
|
||||
*kp++ = *cp++;
|
||||
/* clean off trailing spaces */
|
||||
while (kp > kernel && *--kp == ' ');
|
||||
*++kp = '\0';
|
||||
}
|
||||
while ((io = open(kernel, 0)) < 0) {
|
||||
printf("open: %s: %s\n", kernel, strerror(errno));
|
||||
printf("boot: ");
|
||||
gets(kernel);
|
||||
}
|
||||
reset_twiddle();
|
||||
|
||||
printf("Booting %s @ 0x%x\n", kernel, LOADADDR);
|
||||
copyunix(io, LOADADDR);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
copyunix(io, addr)
|
||||
register int io;
|
||||
register char *addr;
|
||||
{
|
||||
struct exec x;
|
||||
int i;
|
||||
void (*entry)() = (void (*)())addr;
|
||||
|
||||
i = read(io, (char *)&x, sizeof(x));
|
||||
if (i != sizeof(x) ||
|
||||
N_BADMAG(x)) {
|
||||
printf("%s: Bad format\n", kernel);
|
||||
return;
|
||||
}
|
||||
reset_twiddle();
|
||||
printf("%d", x.a_text);
|
||||
if (N_GETMAGIC(x) == ZMAGIC) {
|
||||
entry = (void (*)())(addr+sizeof(struct exec));
|
||||
addr += sizeof(struct exec);
|
||||
}
|
||||
if (read(io, (char *)addr, x.a_text) != x.a_text)
|
||||
goto shread;
|
||||
addr += x.a_text;
|
||||
if (N_GETMAGIC(x) == ZMAGIC || N_GETMAGIC(x) == NMAGIC)
|
||||
while ((int)addr & __LDPGSZ)
|
||||
*addr++ = 0;
|
||||
reset_twiddle();
|
||||
printf("+%d", x.a_data);
|
||||
if (read(io, addr, x.a_data) != x.a_data)
|
||||
goto shread;
|
||||
addr += x.a_data;
|
||||
reset_twiddle();
|
||||
printf("+%d", x.a_bss);
|
||||
for (i = 0; i < x.a_bss; i++)
|
||||
*addr++ = 0;
|
||||
if (x.a_syms != 0) {
|
||||
bcopy(&x.a_syms, addr, sizeof(x.a_syms));
|
||||
addr += sizeof(x.a_syms);
|
||||
printf("+[%d+", x.a_syms);
|
||||
if (read(io, addr, x.a_syms) != x.a_syms)
|
||||
goto shread;
|
||||
addr += x.a_syms;
|
||||
reset_twiddle();
|
||||
|
||||
if (read(io, &strtablen, sizeof(int)) != sizeof(int))
|
||||
goto shread;
|
||||
reset_twiddle();
|
||||
|
||||
bcopy(&strtablen, addr, sizeof(int));
|
||||
if (i = strtablen) {
|
||||
i -= sizeof(int);
|
||||
addr += sizeof(int);
|
||||
if (read(io, addr, i) != i)
|
||||
goto shread;
|
||||
reset_twiddle();
|
||||
addr += i;
|
||||
}
|
||||
printf("%d]", i);
|
||||
esym = KERNBASE +
|
||||
(((int)addr + sizeof(int) - 1) & ~(sizeof(int) - 1));
|
||||
}
|
||||
printf("=0x%x\n", addr);
|
||||
|
||||
#define DDB_MAGIC ( ('D'<<24) | ('D'<<16) | ('B'<<8) | ('0') )
|
||||
(*entry)(romp, esym, DDB_MAGIC);
|
||||
return;
|
||||
shread:
|
||||
printf("Short read\n");
|
||||
return;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/* $NetBSD: filesystem.c,v 1.1.1.1 1995/02/14 22:56:37 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stand.h>
|
||||
#include <ufs.h>
|
||||
|
||||
struct fs_ops file_system[] = {
|
||||
{ ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat },
|
||||
};
|
||||
|
||||
int nfsys = sizeof(file_system)/sizeof(struct fs_ops);
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
dd ibs=32 skip=1 | dd conv=sync
|
|
@ -0,0 +1,40 @@
|
|||
/* $NetBSD: version.c,v 1.1.1.1 1995/02/14 22:56:37 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
* 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 Paul Kranenburg.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.
|
||||
*
|
||||
* 1.1
|
||||
* 1.2 get it to work with V0 bootproms.
|
||||
*/
|
||||
|
||||
char *version = "$Revision: 1.1.1.1 $";
|
|
@ -0,0 +1,5 @@
|
|||
# $NetBSD: Makefile,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $
|
||||
|
||||
SA_PROG= bootxx
|
||||
|
||||
.include <bsd.prog.mk>
|
|
@ -0,0 +1,127 @@
|
|||
/* $NetBSD: bootxx.c,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Paul Kranenburg
|
||||
* 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 Paul Kranenburg.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <a.out.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
||||
#include <machine/mon.h>
|
||||
#include "stand.h"
|
||||
|
||||
int debug;
|
||||
int netif_debug;
|
||||
|
||||
/*
|
||||
* Boot device is derived from ROM provided information.
|
||||
*/
|
||||
#define LOADADDR 0x4000
|
||||
struct open_file io;
|
||||
char sblock[SBSIZE];
|
||||
struct fs *fs;
|
||||
|
||||
#if 0
|
||||
#define MAXBLOCKNUM MINBSIZE / sizeof(daddr_t)
|
||||
#else
|
||||
#define MAXBLOCKNUM 512
|
||||
#endif
|
||||
int maxblocknum = MAXBLOCKNUM;
|
||||
daddr_t blocknum[MAXBLOCKNUM] = { 0 };
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *dummy;
|
||||
int n;
|
||||
|
||||
io.f_flags = F_RAW;
|
||||
if (devopen(&io, 0, &dummy)) {
|
||||
printf("Can't open device\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
if ((io.f_dev->dv_strategy)(io.f_devdata, F_READ,
|
||||
btodb(SBOFF), SBSIZE,
|
||||
sblock, &n) || n != SBSIZE) {
|
||||
printf("Can't read superblock\n");
|
||||
exit();
|
||||
}
|
||||
fs = (struct fs *)sblock;
|
||||
|
||||
(void)copyboot(&io, LOADADDR);
|
||||
exit();
|
||||
}
|
||||
|
||||
int
|
||||
copyboot(f, addr)
|
||||
register struct open_file *f;
|
||||
register char *addr;
|
||||
{
|
||||
int n, i;
|
||||
daddr_t blk;
|
||||
void (*entry)() = (void (*)())addr;
|
||||
|
||||
addr -= sizeof(struct exec); /* XXX */
|
||||
|
||||
for (i = 0; i < MAXBLOCKNUM; i++) {
|
||||
if ((blk = blocknum[i]) == 0)
|
||||
break;
|
||||
#ifdef DEBUG
|
||||
printf("bootxx: block # %d = %d\n", i, blk);
|
||||
#endif
|
||||
if ((f->f_dev->dv_strategy)(f->f_devdata, F_READ,
|
||||
fsbtodb(fs, blk), fs->fs_bsize,
|
||||
addr, &n)) {
|
||||
printf("Read failure\n");
|
||||
return -1;
|
||||
}
|
||||
if (n != fs->fs_bsize) {
|
||||
printf("Short read\n");
|
||||
return -1;
|
||||
}
|
||||
addr += fs->fs_bsize;
|
||||
}
|
||||
if (blk != 0) {
|
||||
printf("File too long\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("bootxx: start 0x%x\n", (int)entry);
|
||||
#endif
|
||||
(*entry)();
|
||||
return 0;
|
||||
}
|
||||
|
||||
twiddle() {}
|
|
@ -0,0 +1,6 @@
|
|||
# $NetBSD: Makefile,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $
|
||||
|
||||
PROG= installboot
|
||||
MAN8=
|
||||
|
||||
.include <bsd.prog.mk>
|
|
@ -0,0 +1,304 @@
|
|||
/* $NetBSD: installboot.c,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Paul Kranenburg
|
||||
* 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 Paul Kranenburg.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <err.h>
|
||||
#include <a.out.h>
|
||||
#include <fcntl.h>
|
||||
#include <nlist.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int verbose, nowrite;
|
||||
char *boot, *proto, *dev;
|
||||
struct nlist nl[] = {
|
||||
#define X_BLOCKNUM 0
|
||||
{"_blocknum"},
|
||||
#define X_MAXBLOCKNUM 1
|
||||
{"_maxblocknum"},
|
||||
{NULL}
|
||||
};
|
||||
daddr_t *blocknums; /* block number array in prototype image */
|
||||
int maxblocknum; /* size of this array */
|
||||
|
||||
|
||||
char *loadprotoblocks __P((char *, long *));
|
||||
int loadblocknums __P((char *, int));
|
||||
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: installboot [-n] [-v] <boot> <proto> <device>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int c;
|
||||
int devfd;
|
||||
char *protostore;
|
||||
long protosize;
|
||||
|
||||
while ((c = getopt(argc, argv, "vn")) != EOF) {
|
||||
switch (c) {
|
||||
case 'n':
|
||||
nowrite = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (argc - optind < 3) {
|
||||
usage();
|
||||
}
|
||||
|
||||
boot = argv[optind];
|
||||
proto = argv[optind + 1];
|
||||
dev = argv[optind + 2];
|
||||
|
||||
if (verbose) {
|
||||
printf("boot: %s\n", boot);
|
||||
printf("proto: %s\n", proto);
|
||||
printf("device: %s\n", dev);
|
||||
}
|
||||
|
||||
/* Load proto blocks into core */
|
||||
if ((protostore = loadprotoblocks(proto, &protosize)) == NULL)
|
||||
exit(1);
|
||||
|
||||
/* Open and check raw disk device */
|
||||
if ((devfd = open(dev, O_RDONLY, 0)) < 0)
|
||||
err(1, "open: %s", dev);
|
||||
|
||||
/* Extract and load block numbers */
|
||||
if (loadblocknums(boot, devfd) != 0)
|
||||
exit(1);
|
||||
|
||||
(void)close(devfd);
|
||||
|
||||
if (nowrite)
|
||||
return 0;
|
||||
|
||||
/* Write patched proto bootblocks into the superblock */
|
||||
if (protosize > SBSIZE - DEV_BSIZE)
|
||||
errx(1, "proto bootblocks too big");
|
||||
|
||||
if ((devfd = open(dev, O_RDWR, 0)) < 0)
|
||||
err(1, "open: %s", dev);
|
||||
|
||||
if (lseek(devfd, DEV_BSIZE, SEEK_SET) != DEV_BSIZE)
|
||||
err(1, "lseek bootstrap");
|
||||
|
||||
if (write(devfd, protostore, protosize) != protosize)
|
||||
err(1, "write bootstrap");
|
||||
(void)close(devfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
loadprotoblocks(fname, size)
|
||||
char *fname;
|
||||
long *size;
|
||||
{
|
||||
int fd;
|
||||
char *bp;
|
||||
struct stat statbuf;
|
||||
struct exec *hp;
|
||||
long off;
|
||||
|
||||
/* Locate block number array in proto file */
|
||||
if (nlist(fname, nl) != 0) {
|
||||
warnx("nlist: %s: symbols not found", fname);
|
||||
return NULL;
|
||||
}
|
||||
if (nl[X_BLOCKNUM].n_type != N_DATA + N_EXT) {
|
||||
warnx("nlist: %s: wrong type", nl[X_BLOCKNUM].n_un.n_name);
|
||||
return NULL;
|
||||
}
|
||||
if (nl[X_MAXBLOCKNUM].n_type != N_DATA + N_EXT) {
|
||||
warnx("nlist: %s: wrong type", nl[X_MAXBLOCKNUM].n_un.n_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((fd = open(fname, O_RDONLY)) < 0) {
|
||||
warn("open: %s", fname);
|
||||
return NULL;
|
||||
}
|
||||
if (fstat(fd, &statbuf) != 0) {
|
||||
warn("fstat: %s", fname);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
if ((bp = calloc(roundup(statbuf.st_size, DEV_BSIZE), 1)) == NULL) {
|
||||
warnx("malloc: %s: no memory", fname);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
if (read(fd, bp, statbuf.st_size) != statbuf.st_size) {
|
||||
warn("read: %s", fname);
|
||||
free(bp);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
hp = (struct exec *)bp;
|
||||
*size = roundup(hp->a_text + hp->a_data, DEV_BSIZE);
|
||||
|
||||
/* Calculate the symbols' location within the proto file */
|
||||
off = N_DATOFF(*hp) - N_DATADDR(*hp) - (hp->a_entry - N_TXTADDR(*hp));
|
||||
blocknums = (daddr_t *) (bp + nl[X_BLOCKNUM].n_value + off);
|
||||
bcopy(bp + nl[X_MAXBLOCKNUM].n_value + off,
|
||||
&maxblocknum, sizeof(maxblocknum));
|
||||
|
||||
if (verbose) {
|
||||
printf("%s: entry point %#x\n", fname, hp->a_entry);
|
||||
printf("proto bootblock size %ld\n", *size);
|
||||
printf("room for %d filesystem blocks at %#x\n",
|
||||
maxblocknum, nl[X_BLOCKNUM].n_value);
|
||||
}
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
static void
|
||||
devread(fd, buf, blk, size, msg)
|
||||
int fd;
|
||||
char *buf;
|
||||
daddr_t blk;
|
||||
int size;
|
||||
char *msg;
|
||||
{
|
||||
if (lseek(fd, dbtob(blk), SEEK_SET) != dbtob(blk))
|
||||
err(1, "%s: devread: lseek", msg);
|
||||
|
||||
if (read(fd, buf, size) != size)
|
||||
err(1, "%s: devread: read", msg);
|
||||
}
|
||||
|
||||
static char sblock[SBSIZE];
|
||||
|
||||
int
|
||||
loadblocknums(boot, devfd)
|
||||
char *boot;
|
||||
int devfd;
|
||||
{
|
||||
int i, fd;
|
||||
struct stat statbuf;
|
||||
struct statfs statfsbuf;
|
||||
struct fs *fs;
|
||||
char *buf;
|
||||
daddr_t blk, *ap;
|
||||
struct dinode *ip;
|
||||
int ndb;
|
||||
|
||||
/*
|
||||
* Open 2nd-level boot program and record the block numbers
|
||||
* it occupies on the filesystem represented by `devfd'.
|
||||
*/
|
||||
if ((fd = open(boot, O_RDONLY)) < 0)
|
||||
err(1, "open: %s", boot);
|
||||
|
||||
if (fstatfs(fd, &statfsbuf) != 0)
|
||||
err(1, "statfs: %s", boot);
|
||||
|
||||
if (strcmp(statfsbuf.f_fstypename, "ufs"))
|
||||
errx(1, "%s: must be on a UFS filesystem", boot);
|
||||
|
||||
if (fsync(fd) != 0)
|
||||
err(1, "fsync: %s", boot);
|
||||
|
||||
if (fstat(fd, &statbuf) != 0)
|
||||
err(1, "fstat: %s", boot);
|
||||
|
||||
close(fd);
|
||||
|
||||
/* Read superblock */
|
||||
devread(devfd, sblock, btodb(SBOFF), SBSIZE, "superblock");
|
||||
fs = (struct fs *)sblock;
|
||||
|
||||
/* Read inode */
|
||||
if ((buf = malloc(fs->fs_bsize)) == NULL)
|
||||
errx(1, "No memory for filesystem block");
|
||||
|
||||
blk = fsbtodb(fs, ino_to_fsba(fs, statbuf.st_ino));
|
||||
devread(devfd, buf, blk, fs->fs_bsize, "inode");
|
||||
ip = (struct dinode *)(buf) + ino_to_fsbo(fs, statbuf.st_ino);
|
||||
|
||||
/*
|
||||
* Get the block numbers; we don't handle fragments
|
||||
*/
|
||||
ndb = howmany(ip->di_size, fs->fs_bsize);
|
||||
ap = ip->di_db;
|
||||
for (i = 0; i < NDADDR && *ap && ndb; i++, ap++, ndb--) {
|
||||
if (i >= maxblocknum)
|
||||
errx(1, "Too many blocks");
|
||||
*blocknums++ = *ap;
|
||||
}
|
||||
if (ndb == 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Just one level of indirections; there isn't much room
|
||||
* for more in the 1st-level bootblocks anyway.
|
||||
*/
|
||||
blk = ip->di_ib[0];
|
||||
devread(devfd, buf, blk, fs->fs_bsize, "indirect block");
|
||||
ap = (daddr_t *)buf;
|
||||
for (; i < NINDIR(fs) && *ap && ndb; i++, ap++, ndb--) {
|
||||
if (i >= maxblocknum)
|
||||
errx(1, "Too many blocks");
|
||||
*blocknums++ = *ap;
|
||||
}
|
||||
|
||||
if (ndb)
|
||||
errx(1, "Too many blocks");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# $NetBSD: Makefile,v 1.1.1.1 1995/02/14 22:56:37 gwr Exp $
|
||||
|
||||
LIB=sa
|
||||
|
||||
SRCS= alloc.c ashrdi3.c bcopy.c bzero.c gets.c \
|
||||
open.c panic.c printf.c promcons.c promdev.c \
|
||||
read.c strcmp.c strerror.c strlen.c strlen.c \
|
||||
twiddle.c ufs.c
|
||||
|
||||
NOPIC=nopic
|
||||
NOPROFILE=noprofile
|
||||
|
||||
# Logically src/sys
|
||||
S=../../../..
|
||||
|
||||
SRC_SA=$S/lib/libsa
|
||||
SRC_KERN=$S/lib/libkern
|
||||
|
||||
DEFS= -DCOMPAT_UFS
|
||||
INCL= -I. -I${S}/lib/libsa -I${S}
|
||||
CFLAGS= -O -msoft-float ${DEFS} ${INCL}
|
||||
|
||||
.PATH: ${SRC_SA} ${SRC_KERN}
|
||||
|
||||
all: libsa.a SRT0.o SRT1.o
|
||||
|
||||
.include <bsd.lib.mk>
|
|
@ -0,0 +1,87 @@
|
|||
| $NetBSD: SRT0.S,v 1.1.1.1 1995/02/14 22:56:37 gwr Exp $
|
||||
|
||||
| Copyright (c) 1995 Gordon W. Ross
|
||||
| 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. The name of the author may not be used to endorse or promote products
|
||||
| derived from this software without specific prior written permission.
|
||||
| 4. All advertising materials mentioning features or use of this software
|
||||
| must display the following acknowledgement:
|
||||
| This product includes software developed by Gordon Ross
|
||||
|
|
||||
| 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.
|
||||
|
||||
| SRT0.S - Stand-alone Run-Time startup code, part 0
|
||||
.file "SRT0.S"
|
||||
.text
|
||||
.globl start
|
||||
start:
|
||||
| Check to see if the code is located correctly.
|
||||
| This SHOULD do a PC-relative load into a0, but...
|
||||
| lea start, a0 | current location (0x4000)
|
||||
| XXX - GAS version 1.93 gets the above lea wrong!
|
||||
.word 0x41fa
|
||||
.word 0xfffe
|
||||
| Now force a long (not PC-relative) load to a1 and compare.
|
||||
lea start:l, a1 | desired location (LINKADDR)
|
||||
cmpl a0, a1
|
||||
beqs restart
|
||||
|
||||
| Relocate the code and data to where they belong.
|
||||
movl #_edata,d0 | Desired end of program
|
||||
subl a1,d0 | Calculate length, round up.
|
||||
lsrl #2,d0
|
||||
Lcp:
|
||||
movl a0@+, a1@+
|
||||
dbra d0, Lcp
|
||||
|
||||
| Force a long jump to the relocated code (not pc-relative)
|
||||
lea restart:l, a0
|
||||
jmp a0@
|
||||
|
||||
restart:
|
||||
| now in the relocated code
|
||||
|
||||
| Set up stack (just before relocated text)
|
||||
lea start:l, a0
|
||||
movl a0, sp
|
||||
|
||||
| Call the run-time startup C code, which will:
|
||||
| initialize, call main, call exit
|
||||
jsr __start:l
|
||||
|
||||
| If _start returns, fall into abort.
|
||||
.globl _abort
|
||||
_abort:
|
||||
trap #0
|
||||
|
||||
| If abort returns, fall into reset.
|
||||
.globl _reset
|
||||
_reset:
|
||||
reset
|
||||
jmp _reset
|
||||
|
||||
| function to get the vector base register
|
||||
.globl _getvbr
|
||||
_getvbr:
|
||||
movc vbr, d0
|
||||
rts
|
||||
|
||||
| The end.
|
|
@ -0,0 +1,74 @@
|
|||
/* $NetBSD: SRT1.c,v 1.1.1.1 1995/02/14 22:56:37 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Gordon W. Ross
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* 4. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Gordon Ross
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* SRT1.c - Stand-alone Run-time startup code, part 1 */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <machine/mon.h>
|
||||
|
||||
extern char edata[], end[];
|
||||
extern int * getvbr();
|
||||
extern volatile void abort();
|
||||
|
||||
volatile void
|
||||
exit()
|
||||
{
|
||||
mon_exit_to_mon();
|
||||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
* This is called by SRT0.S
|
||||
* to do final prep for main
|
||||
*/
|
||||
_start()
|
||||
{
|
||||
register int *p;
|
||||
|
||||
/* Clear BSS */
|
||||
p = (int *) edata;
|
||||
do *p++ = 0;
|
||||
while (((char*)p) < end);
|
||||
|
||||
/* Set the vector for trap 0 used by abort. */
|
||||
p = getvbr();
|
||||
p[32] = (int)romp->abortEntry;
|
||||
|
||||
main(0);
|
||||
exit();
|
||||
}
|
||||
|
||||
/*
|
||||
* Boot programs in C++ ? Not likely!
|
||||
*/
|
||||
__main() {}
|
|
@ -0,0 +1,116 @@
|
|||
/* $NetBSD: gets.c,v 1.1.1.1 1995/02/14 22:56:37 gwr Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
* The Regents of the University of California. 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 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.
|
||||
*
|
||||
* @(#)gets.c 8.1 (Berkeley) 6/11/93
|
||||
*/
|
||||
|
||||
#include "stand.h"
|
||||
|
||||
/*
|
||||
* This implementation assumes that getchar() does echo, because
|
||||
* on some machines, it is hard to keep echo from being done.
|
||||
* Those that need it can do echo in their getchar() function.
|
||||
*
|
||||
* Yes, the code below will echo CR, DEL, and other control chars,
|
||||
* but sending CR or DEL here is harmless. All the other editing
|
||||
* characters will be followed by a newline, so it doesn't matter.
|
||||
* (Most terminals will not show them anyway.)
|
||||
*/
|
||||
|
||||
void
|
||||
gets(buf)
|
||||
char *buf;
|
||||
{
|
||||
register int c;
|
||||
register char *lp;
|
||||
|
||||
top:
|
||||
lp = buf;
|
||||
|
||||
for (;;) {
|
||||
c = getchar() & 0177;
|
||||
|
||||
#ifdef GETS_MUST_ECHO /* Preserved in case someone wants it... */
|
||||
putchar(c);
|
||||
#endif
|
||||
|
||||
switch (c) {
|
||||
|
||||
default:
|
||||
*lp++ = c;
|
||||
continue;
|
||||
|
||||
case '\177':
|
||||
putchar('\b');
|
||||
/* fall through */
|
||||
case '\b':
|
||||
putchar(' ');
|
||||
putchar('\b');
|
||||
/* fall through */
|
||||
case '#':
|
||||
if (lp > buf)
|
||||
lp--;
|
||||
continue;
|
||||
|
||||
#ifdef GETS_REPRINT
|
||||
/*
|
||||
* This is not very useful in a boot program.
|
||||
* (It costs you 52 bytes on m68k, gcc -O3).
|
||||
*/
|
||||
case 'r'&037: {
|
||||
register char *p;
|
||||
putchar('\n');
|
||||
for (p = buf; p < lp; ++p)
|
||||
putchar(*p);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
case '@':
|
||||
case 'u'&037:
|
||||
case 'w'&037:
|
||||
putchar('\n');
|
||||
goto top;
|
||||
|
||||
case '\r':
|
||||
putchar('\n');
|
||||
/* fall through */
|
||||
case '\n':
|
||||
*lp = '\0';
|
||||
return;
|
||||
|
||||
} /* switch */
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include "stand.h"
|
||||
|
||||
extern volatile void abort();
|
||||
|
||||
volatile void
|
||||
panic(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
printf(fmt, ap);
|
||||
printf("\n");
|
||||
va_end(ap);
|
||||
abort();
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <machine/mon.h>
|
||||
|
||||
int
|
||||
getchar()
|
||||
{
|
||||
return ( (*romp->getChar)() );
|
||||
}
|
||||
|
||||
peekchar()
|
||||
{
|
||||
return ( (*romp->mayGet)() );
|
||||
}
|
||||
|
||||
void
|
||||
putchar(c)
|
||||
int c;
|
||||
{
|
||||
if (c == '\n')
|
||||
(*romp->putChar)('\r');
|
||||
(*romp->putChar)(c);
|
||||
}
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
/* $NetBSD: promdev.c,v 1.1.1.1 1995/02/14 22:56:37 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
* 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 Paul Kranenburg.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <machine/mon.h>
|
||||
#include <machine/saio.h>
|
||||
|
||||
#include "stand.h"
|
||||
|
||||
int promopen __P((struct open_file *, ...));
|
||||
int promclose __P((struct open_file *));
|
||||
int promioctl __P((struct open_file *, u_long, void *));
|
||||
int promstrategy __P((void *, int, daddr_t, u_int, char *, u_int *));
|
||||
|
||||
struct devsw devsw[] = {
|
||||
{ "prom", promstrategy, promopen, promclose, promioctl },
|
||||
};
|
||||
|
||||
int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
|
||||
|
||||
static char pathbuf[100];
|
||||
|
||||
int
|
||||
devopen(f, fname, file)
|
||||
struct open_file *f;
|
||||
char *fname;
|
||||
char **file;
|
||||
{
|
||||
struct bootparam *bp;
|
||||
struct boottab *ops;
|
||||
struct devinfo *dip;
|
||||
struct saioreq *si;
|
||||
char *cp, *path, *dev;
|
||||
int error;
|
||||
|
||||
bp = *romp->bootParam;
|
||||
ops = bp->bootDevice;
|
||||
dip = ops->b_devinfo;
|
||||
|
||||
si = (struct saioreq *) alloc(sizeof(*si));
|
||||
bzero((caddr_t)si, sizeof(*si));
|
||||
si->si_boottab = ops;
|
||||
si->si_ctlr = bp->ctlrNum;
|
||||
si->si_unit = bp->unitNum;
|
||||
si->si_boff = bp->partNum;
|
||||
|
||||
f->f_devdata = (void *) si;
|
||||
f->f_dev = devsw;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Boot device type: %s\n", ops->b_desc);
|
||||
#endif
|
||||
|
||||
path = pathbuf;
|
||||
cp = bp->argPtr[0];
|
||||
while (*cp) {
|
||||
*path++ = *cp;
|
||||
if (*cp++ == ')')
|
||||
break;
|
||||
}
|
||||
*path = '\0';
|
||||
dev = path = pathbuf;
|
||||
error = (*ops->b_open)(si);
|
||||
if (error != 0) {
|
||||
printf("Can't open device `%s'\n", dev);
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
*file = fname;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
promstrategy(devdata, flag, dblk, size, buf, rsize)
|
||||
void *devdata;
|
||||
int flag;
|
||||
daddr_t dblk;
|
||||
u_int size;
|
||||
char *buf;
|
||||
u_int *rsize;
|
||||
{
|
||||
struct saioreq *si;
|
||||
struct boottab *ops;
|
||||
int error = 0;
|
||||
int si_flag, xcnt;
|
||||
|
||||
si = (struct saioreq *) devdata;
|
||||
ops = si->si_boottab;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("promstrategy: size=%d dblk=%d\n", size, dblk);
|
||||
#endif
|
||||
twiddle();
|
||||
|
||||
si->si_bn = dblk;
|
||||
si->si_ma = buf;
|
||||
si->si_cc = xcnt = 512; /* XXX */
|
||||
|
||||
si_flag = (flag == F_READ) ? SAIO_F_READ : SAIO_F_WRITE;
|
||||
error = (*ops->b_strategy)(si, si_flag);
|
||||
if (error)
|
||||
return (EIO);
|
||||
|
||||
*rsize = xcnt;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("rsize = %x\n", *rsize);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
promopen(f)
|
||||
struct open_file *f;
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("promopen:\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
promclose(f)
|
||||
struct open_file *f;
|
||||
{
|
||||
return EIO;
|
||||
}
|
||||
|
||||
int
|
||||
promioctl(f, cmd, data)
|
||||
struct open_file *f;
|
||||
u_long cmd;
|
||||
void *data;
|
||||
{
|
||||
return EIO;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
static short tw_on;
|
||||
static short tw_pos;
|
||||
static char tw_chars[4] = "|/-\\";
|
||||
|
||||
twiddle()
|
||||
{
|
||||
if (tw_on)
|
||||
putchar('\b');
|
||||
else
|
||||
tw_on = 1;
|
||||
putchar(tw_chars[tw_pos++]);
|
||||
tw_pos &= 3;
|
||||
}
|
||||
|
||||
reset_twiddle()
|
||||
{
|
||||
if (tw_on)
|
||||
putchar('\b');
|
||||
tw_on = 0;
|
||||
tw_pos = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue