From 3fc28b5769d7ff0569c7d815db1ad40e911dfb83 Mon Sep 17 00:00:00 2001 From: rahnds Date: Thu, 6 Feb 1997 04:36:38 +0000 Subject: [PATCH] PowerPC pieces for ramdisk (rd) changes this is adds majors, rd_root pieces, config file to generate MINIROOT with rdroot and MAKEDEV changes as well as adding the rd device to known device types. --- etc/etc.powerpc/MAKEDEV | 8 +-- sys/arch/powerpc/conf/DDB | 2 + sys/arch/powerpc/conf/MINI | 10 +++- sys/arch/powerpc/conf/files.powerpc | 5 ++ sys/arch/powerpc/powerpc/conf.c | 40 +++++++++++---- sys/arch/powerpc/powerpc/rd_root.c | 79 +++++++++++++++++++++++++++++ 6 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 sys/arch/powerpc/powerpc/rd_root.c diff --git a/etc/etc.powerpc/MAKEDEV b/etc/etc.powerpc/MAKEDEV index bbca1b93c95..e42a31060ed 100644 --- a/etc/etc.powerpc/MAKEDEV +++ b/etc/etc.powerpc/MAKEDEV @@ -40,6 +40,7 @@ # cd* SCSI compact discs # ch* SCSI changers # vnd* vnode pseudo-disks +# rd* "ramdisk" pseudo-disks # ccd* concatenated disk driver # # Terminal ports: @@ -81,7 +82,7 @@ all) raminst) sh MAKEDEV std sh MAKEDEV sd0 sd1 sd2 sd3 st0 st1 cd0 cd1 - sh MAKEDEV grf0 grf1 ttye0 + sh MAKEDEV rd0 sh MAKEDEV tty00 tty01 pty0 ;; @@ -117,8 +118,9 @@ sd*|vnd*|ccd*) umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'` case $i in sd*) name=sd; blk=4; chr=13;; - vnd*) name=vnd; blk=8; chr=19;; - ccd*) name=ccd; blk=9; chr=20;; + vnd*) name=vnd; blk=14; chr=19;; + ccd*) name=ccd; blk=16; chr=20;; + rd*) name=rd; blk=17; chr=17;; esac rm -f $name$unit? r$name$unit? case $unit in diff --git a/sys/arch/powerpc/conf/DDB b/sys/arch/powerpc/conf/DDB index 0ed083ae4ae..a8ce76d5158 100644 --- a/sys/arch/powerpc/conf/DDB +++ b/sys/arch/powerpc/conf/DDB @@ -68,3 +68,5 @@ ofrtc* at openfirm? pseudo-device loop pseudo-device pty 64 pseudo-device random 1 +pseudo-device rd +pseudo-device vnd 1 diff --git a/sys/arch/powerpc/conf/MINI b/sys/arch/powerpc/conf/MINI index 5b5bb1a6364..df0b6c1141a 100644 --- a/sys/arch/powerpc/conf/MINI +++ b/sys/arch/powerpc/conf/MINI @@ -20,7 +20,7 @@ options FIREPOWERBUGS #options DDB #options KTRACE -options SYSCALL_DEBUG +#options SYSCALL_DEBUG options TCP_COMPAT_42 options COMPAT_43 options COMPAT_09 @@ -50,7 +50,12 @@ options NMBCLUSTERS=1024 options MAXUSERS=20 #options TARGET_ELF -config bsd swap generic +# needed for rd miniroot support +options MINIROOTSIZE=4096 +options RAMDISK_HOOKS + + +config bsd swap on ofdisk0 and ofdisk1 and ofdisk2 root rd0a ofroot* at root @@ -68,3 +73,4 @@ ofrtc* at openfirm? pseudo-device loop pseudo-device pty 64 pseudo-device random 1 +pseudo-device rd diff --git a/sys/arch/powerpc/conf/files.powerpc b/sys/arch/powerpc/conf/files.powerpc index 55e0e95de36..3de19114146 100644 --- a/sys/arch/powerpc/conf/files.powerpc +++ b/sys/arch/powerpc/conf/files.powerpc @@ -45,6 +45,11 @@ file arch/powerpc/powerpc/db_disasm.c ddb file arch/powerpc/powerpc/db_interface.c ddb file arch/powerpc/powerpc/db_trace.c ddb +pseudo-device rd +file dev/ramdisk.c rd needs-flag +file arch/powerpc/powerpc/rd_root.c ramdisk_hooks +major {rd = 17} + # FirePower specific code #device firepower: openfirm #attach firepower at root diff --git a/sys/arch/powerpc/powerpc/conf.c b/sys/arch/powerpc/powerpc/conf.c index eefeaff4d0a..da0983d3c5a 100644 --- a/sys/arch/powerpc/powerpc/conf.c +++ b/sys/arch/powerpc/powerpc/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.2 1996/12/28 06:21:41 rahnds Exp $ */ +/* $OpenBSD: conf.c,v 1.3 1997/02/06 04:36:41 rahnds Exp $ */ /* $NetBSD: conf.c,v 1.2 1996/10/16 17:26:19 ws Exp $ */ /* @@ -43,12 +43,34 @@ bdev_decl(ofd); bdev_decl(sw); +#include "rd.h" +bdev_decl(rd); + +#include "vnd.h" +bdev_decl(vnd); +#include "ccd.h" +bdev_decl(ccd); + struct bdevsw bdevsw[] = { bdev_notdef(), /* 0 */ bdev_swap_init(1,sw), /* 1: swap pseudo device */ bdev_notdef(), /* 2 SCSI tape */ bdev_notdef(), /* 3 SCSI CD-ROM */ bdev_disk_init(NOFDISK,ofd), /* 4: Openfirmware disk */ + bdev_notdef(), /* 5 unknown*/ + bdev_notdef(), /* 6 unknown*/ + bdev_notdef(), /* 7 unknown*/ + bdev_lkm_dummy(), /* 8 */ + bdev_lkm_dummy(), /* 9 */ + bdev_lkm_dummy(), /* 10 */ + bdev_lkm_dummy(), /* 11 */ + bdev_lkm_dummy(), /* 12 */ + bdev_lkm_dummy(), /* 13 */ + bdev_disk_init(NVND,vnd), /* 14 vnode disk driver*/ + bdev_notdef(), /* 15 unknown*/ + bdev_disk_init(NCCD,ccd), /* 16 concatenated disk driver*/ + bdev_disk_init(NRD,rd), /* 17 ram disk driver*/ + bdev_notdef(), /* 18 unknown*/ }; int nblkdev = sizeof bdevsw / sizeof bdevsw[0]; @@ -75,12 +97,12 @@ cdev_decl(ofrtc); #include #include #include -#include cdev_decl(st); cdev_decl(sd); cdev_decl(cd); cdev_decl(vnd); cdev_decl(ccd); +cdev_decl(rd); dev_decl(filedesc,open); @@ -131,8 +153,8 @@ struct cdevsw cdevsw[] = { cdev_notdef(), /* 14 */ cdev_notdef(), /* 15 */ cdev_notdef(), /* 16 */ - cdev_rtc_init(NOFRTC,ofrtc), /* 17: Openfirmware RTC */ - cdev_notdef(), /* 18 */ + cdev_disk_init(NRD,rd), /* 17 ram disk driver*/ + cdev_rtc_init(NOFRTC,ofrtc), /* 18: Openfirmware RTC */ cdev_disk_init(NVND,vnd), /* 19: vnode disk */ cdev_tape_init(NST,st), /* 20: SCSI tape */ cdev_fd_init(1,filedesc), /* 21: file descriptor pseudo-dev */ @@ -205,11 +227,11 @@ static int chrtoblktbl[] = { /* 14 */ NODEV, /* 15 */ NODEV, /* 16 */ NODEV, - /* 10 */ NODEV, - /* 10 */ NODEV, - /* 10 */ NODEV, - /* 10 */ NODEV, - /* 10 */ NODEV, + /* 17 */ 17, + /* 18 */ NODEV, + /* 19 */ NODEV, + /* 20 */ NODEV, + /* 21 */ NODEV, }; /* diff --git a/sys/arch/powerpc/powerpc/rd_root.c b/sys/arch/powerpc/powerpc/rd_root.c new file mode 100644 index 00000000000..4120f4641a6 --- /dev/null +++ b/sys/arch/powerpc/powerpc/rd_root.c @@ -0,0 +1,79 @@ +/* $NetBSD: rd_root.c,v 1.2 1996/03/27 16:38:33 perry 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. + * + * 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 +#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. + * See the program: src/distrib/sun3/common/rdsetroot.c + */ +int rd_root_size = ROOTBYTES; +char rd_root_image[ROOTBYTES] = "|This is the root ramdisk!\n"; + +/* + * This is called during autoconfig. + */ +void +rd_attach_hook(unit, rd) + int unit; + struct rd_conf *rd; +{ + if (unit == 0) { + /* Setup root ramdisk */ + rd->rd_addr = (caddr_t) rd_root_image; + rd->rd_size = (size_t) rd_root_size; + rd->rd_type = RD_KMEM_FIXED; + printf(" fixed, %d blocks", MINIROOTSIZE); + } +} + +/* + * This is called during open (i.e. mountroot) + */ +void +rd_open_hook(unit, rd) + int unit; + struct rd_conf *rd; +{ + if (unit == 0) { + /* The root ramdisk only works single-user. */ + boothowto |= RB_SINGLE; + } +} -- 2.20.1