From fe83804dea5e58244c4eaf5a82c81bf983a0b3b1 Mon Sep 17 00:00:00 2001 From: jonathan Date: Tue, 17 Nov 1998 22:41:05 +0000 Subject: [PATCH] Add md (memory disk) hooks for pmax. ecoff kernel with 2MB ramdisk tftp-boots on new PROMs. (3MB is too large). --- sys/arch/pmax/conf/files.pmax | 6 ++- sys/arch/pmax/pmax/autoconf.c | 8 ++-- sys/arch/pmax/pmax/conf.c | 9 +++- sys/arch/pmax/pmax/md_root.c | 87 +++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 sys/arch/pmax/pmax/md_root.c diff --git a/sys/arch/pmax/conf/files.pmax b/sys/arch/pmax/conf/files.pmax index 2c215e2cda45..da0fbcd4d512 100644 --- a/sys/arch/pmax/conf/files.pmax +++ b/sys/arch/pmax/conf/files.pmax @@ -1,4 +1,4 @@ -# $NetBSD: files.pmax,v 1.56 1998/09/26 21:02:56 drochner Exp $ +# $NetBSD: files.pmax,v 1.57 1998/11/17 22:41:05 jonathan Exp $ # DECstation-specific configuration info # maxpartitions must be first item in files.${ARCH}. @@ -117,6 +117,10 @@ include "dev/scsipi/files.scsipi" major { tz = 10 } major { rz = 21 } +# Memory Disk +file arch/pmax/pmax/md_root.c memory_disk_hooks +major { md = 17 } + # # Old 4.4bsd pmax-specific scsi driver (deprecated). # diff --git a/sys/arch/pmax/pmax/autoconf.c b/sys/arch/pmax/pmax/autoconf.c index d3b4f5fac6ff..2f0eec2e0a98 100644 --- a/sys/arch/pmax/pmax/autoconf.c +++ b/sys/arch/pmax/pmax/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.31 1998/03/26 03:12:05 thorpej Exp $ */ +/* $NetBSD: autoconf.c,v 1.32 1998/11/17 22:41:06 jonathan Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -43,7 +43,7 @@ */ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.31 1998/03/26 03:12:05 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.32 1998/11/17 22:41:06 jonathan Exp $"); /* * Setup the system to run on the current machine. @@ -92,9 +92,7 @@ void findroot __P((struct device **, int *)); struct devnametobdevmaj pmax_nam2blk[] = { { "rz", 21 }, -#ifdef notyet - { "md", XXX }, -#endif + { "md", 17 }, { NULL, 0 }, }; diff --git a/sys/arch/pmax/pmax/conf.c b/sys/arch/pmax/pmax/conf.c index 37c15a571ee6..a15af8988452 100644 --- a/sys/arch/pmax/pmax/conf.c +++ b/sys/arch/pmax/pmax/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.30 1998/11/13 04:47:08 oster Exp $ */ +/* $NetBSD: conf.c,v 1.31 1998/11/17 22:41:05 jonathan Exp $ */ /* * Copyright (c) 1992, 1993 @@ -64,6 +64,8 @@ bdev_decl(ccd); bdev_decl(raid); #include "vnd.h" bdev_decl(vnd); +#include "md.h" +bdev_decl(md); struct bdevsw bdevsw[] = { @@ -84,7 +86,7 @@ struct bdevsw bdevsw[] = bdev_notdef(), /* 14: rl */ bdev_notdef(), /* 15: tmscp */ bdev_notdef(), /* 16: cs */ - bdev_notdef(), /* 17: md */ + bdev_disk_init(NMD,md), /* 17: memory disk driver */ bdev_tape_init(NST,st), /* 18: st */ bdev_disk_init(NSD,sd), /* 19: sd */ bdev_tape_init(NTZ, tz), /* 20: tz */ @@ -136,6 +138,7 @@ cdev_decl(log); cdev_decl(fd); cdev_decl(sd); cdev_decl(st); +cdev_decl(md); #include "ss.h" cdev_decl(ss); #include "uk.h" @@ -295,6 +298,7 @@ struct cdevsw cdevsw[] = cdev_lkm_init(NLKM,lkm), /* 94: loadable module driver */ cdev_scsibus_init(NSCSIBUS,scsibus), /* 95: SCSI bus */ cdev_disk_init(NRAID,raid), /* 96: RAIDframe disk driver */ + cdev_disk_init(NMD,md), /* 97: memory disk driver */ }; int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]); @@ -430,6 +434,7 @@ static int chrtoblktbl[] = { /* 94 */ NODEV, /* 95 */ NODEV, /* 96 */ 32, + /* 97 */ 17, }; /* diff --git a/sys/arch/pmax/pmax/md_root.c b/sys/arch/pmax/pmax/md_root.c new file mode 100644 index 000000000000..68c31adf5e25 --- /dev/null +++ b/sys/arch/pmax/pmax/md_root.c @@ -0,0 +1,87 @@ +/* $NetBSD: md_root.c,v 1.1 1998/11/17 22:41:06 jonathan Exp $ */ + +/* + * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. + * 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. + * + * 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 /* RCS ID & Copyright macro defns */ + +__KERNEL_RCSID(0, "$NetBSD: md_root.c,v 1.1 1998/11/17 22:41:06 jonathan Exp $"); + +#include +#include +#include + +#include + +extern int boothowto; + +#ifndef MINIROOTSIZE +#define MINIROOTSIZE 512 +#endif + +#define ROOTBYTES (MINIROOTSIZE << DEV_BSHIFT) + +/* + * This array will be patched to contain a file-system image. + */ +u_int32_t md_root_size = ROOTBYTES; +char md_root_image[ROOTBYTES] = "|This is the root ramdisk!\n"; + +/* + * This is called during autoconfig. + */ +void +md_attach_hook(unit, md) + int unit; + struct md_conf *md; +{ + + if (unit == 0) { + /* Setup root ramdisk */ + md->md_addr = (caddr_t)md_root_image; + md->md_size = (size_t)md_root_size; + md->md_type = MD_KMEM_FIXED; + printf("md%d: internal %dK image area\n", unit, + ROOTBYTES / 1024); + } +} + +/* + * This is called during open (i.e. mountroot) + */ +void +md_open_hook(unit, md) + int unit; + struct md_conf *md; +{ + + if (unit == 0) { + /* The root ramdisk only works single-user. */ + boothowto |= RB_SINGLE; + } +}