Add memory disk support.

This commit is contained in:
tsubai 1998-06-24 15:13:42 +00:00
parent 16c5e36010
commit 730bea0760
5 changed files with 102 additions and 9 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.3 1998/06/21 13:46:02 tsubai Exp $
# $NetBSD: GENERIC,v 1.4 1998/06/24 15:13:42 tsubai Exp $
#
# POWERMAC config file
#
@ -136,6 +136,7 @@ uk* at scsibus? target ? lun ? # SCSI unknown
pseudo-device vnd 4 # disk-like interface to files
pseudo-device ccd 4 # concatenated/striped disk devices
pseudo-device md 1 # memory disk device
pseudo-device loop # network loopback
pseudo-device bpfilter 8 # packet filter
pseudo-device ipfilter # IP filter (firewall) and NAT

View File

@ -16,6 +16,12 @@ file arch/macppc/macppc/machdep.c
file arch/macppc/dev/dbdma.c
file dev/cons.c
#
# Memory Disk for install floppy
#
file arch/macppc/macppc/md_root.c memory_disk_hooks
major {md = 9}
#
# Machine-independent SCSI drivers
#

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.2 1998/06/05 12:22:45 tsubai Exp $ */
/* $NetBSD: autoconf.c,v 1.3 1998/06/24 15:13:43 tsubai Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -57,9 +57,7 @@ int booted_partition; /* ...and partition on that device */
struct devnametobdevmaj powermac_nam2blk[] = {
{ "ofdisk", 0 },
{ "sd", 4 },
#ifdef notyet
{ "md", XXX },
#endif
{ "md", 9 },
{ NULL, 0 },
};
@ -121,6 +119,9 @@ findroot()
goto out;
/* XXX for now... */
if (strncmp(p, "scsi/sd", 7) != 0)
goto out;
booted_partition = p[len - 2] - '0';
targ = p[len - 4] - '0';

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.2 1998/06/05 12:24:44 tsubai Exp $ */
/* $NetBSD: conf.c,v 1.3 1998/06/24 15:13:43 tsubai Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -50,6 +50,8 @@ bdev_decl(sd);
bdev_decl(st);
#include "cd.h"
bdev_decl(cd);
#include "md.h"
bdev_decl(md);
struct bdevsw bdevsw[] = {
bdev_notdef(), /* 0: Openfirmware disk */
@ -61,7 +63,7 @@ struct bdevsw bdevsw[] = {
bdev_disk_init(NCD,cd), /* 6: SCSI CD-ROM */
bdev_lkm_dummy(), /* 7 */
bdev_lkm_dummy(), /* 8 */
bdev_lkm_dummy(), /* 9 */
bdev_disk_init(NMD,md), /* 9: memory disk driver */
bdev_lkm_dummy(), /* 10 */
bdev_lkm_dummy(), /* 11 */
};
@ -138,7 +140,7 @@ struct cdevsw cdevsw[] = {
cdev_rnd_init(NRND,rnd), /* 24: random source pseudo-device */
cdev_disk_init(NVND,vnd), /* 25: vnode disk driver */
cdev_disk_init(NCCD,ccd), /* 26: concatenated disk driver */
cdev_lkm_dummy(), /* 27: */
cdev_disk_init(NMD,md), /* 27: memory disk driver */
cdev_mouse_init(NADB,adb), /* 28: ADB event interface */
cdev_lkm_dummy(), /* 29: */
cdev_lkm_dummy(), /* 30: */
@ -205,7 +207,7 @@ static int chrtoblktbl[] = {
/* 24 */ NODEV,
/* 25 */ 2,
/* 26 */ 3,
/* 27 */ NODEV,
/* 27 */ 9,
/* 28 */ NODEV,
/* 29 */ NODEV,
/* 30 */ NODEV,

View File

@ -0,0 +1,83 @@
/* $NetBSD: md_root.c,v 1.1 1998/06/24 15:13:43 tsubai 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 <sys/param.h>
#include <sys/systm.h>
#include <sys/reboot.h>
#include <dev/md.h>
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;
}
}