[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pbsd-mg2] md root (Re: Serial console)



takesi@is.titech.ac.jp wrote:

 > In message "[pbsd-mg2] RE: Serial console ",
 > "たけむら" write:
 > >arch/hpcmips/hpcmips/conf.c の bdevsw[]にエントリをつくって、
 > >autoconf.c の findroot() あたりがそれを使うようにする必要があります。
 > >そのへんはすでにやっていますか?
 > 
 > あ、やってません。そういう仕組みが必要なんですね。

pmaxから持ってきました。こちらのCVS的な準備が整ってないので
commitする前にとりあえず patch付けときます。

# md_root.c って atariとsparc64以外全部同じなのね... MIに置いた方が良さげ。


で MEMDISKで作ったkernelに、
ramdisk fs imageを mdsetimageでくっつけるわけですが、
/usr/sbin/mdsetimageではcross環境で使用できません。
で、BFD使ったmdsetimageを作って現在テストしてます。

# さて、実機ではどうやってテストしようか...

sakamoto@cec.co.jp

--
diff -ruN ../../../osrc/sys/arch/hpcmips/conf/MEMDISK hpcmips/conf/MEMDISK
--- ../../../osrc/sys/arch/hpcmips/conf/MEMDISK	Thu Jan  1 09:00:00 1970
+++ hpcmips/conf/MEMDISK	Wed May 12 11:20:34 1999
@@ -0,0 +1,137 @@
+#
+# Distribution kernel (any  model) kernel config file
+
+#
+# 	$NetBSD:$
+#
+include		"arch/hpcmips/conf/std.hpcmips"
+
+maxusers	8
+
+options 	MIPS3			# R4000/R4400/R4600 CPUs
+
+# Support for specific models of H/PC MIPS
+options 	VR41X1			# NEC VR41x1 series
+options		MIPS3_L2CACHE_ABSENT
+
+# Enable the hooks used for initializing the root memory-disk.
+options		MEMORY_DISK_HOOKS
+options		MEMORY_DISK_IS_ROOT	# force root on memory disk
+options		MEMORY_DISK_SERVER=0	# no userspace memory disk support
+options		MINIROOTSIZE=4096	# size of memory disk, in blocks
+#options	MINIROOTSIZE=2880	# 1.44M, same as a floppy
+
+# Standard system options
+options 	DDB			# in-kernel debugger
+#options 	DDB_ONPANIC=0		# don't enter debugger on panic
+#options 	DIAGNOSTIC		# extra kernel debugging checks
+#options 	DEBUG			# extra kernel debugging support
+options 	"COMPAT_43"		# compatibility with 4.3BSD binaries
+options 	KTRACE			# system call tracing support
+options 	"NKMEMCLUSTERS=1024"	# 4K pages in kernel malloc pool
+
+#options 	SCSIVERBOSE		# Verbose SCSI errors
+
+options 	NTP			# network time protocol
+#options 	UCONSOLE		# users can redirect console (unsafe)
+
+#options		SYSCALL_DEBUG		# for debug
+#options		HPCMIPS_L1CAHCE_DISABLE	# disable L1 cache for debug
+options		HPCMIPS_PGSIZE_16K	# page size is 16KB
+
+# Filesystem options
+file-system 	FFS             # fast filesystem with user and group quotas
+#file-system 	MFS		# memory-based filesystem
+#file-system 	NFS		# Sun NFS-compatible filesystem (client)
+#file-system	LFS		# Log-based filesystem (still experimental)
+#file-system 	CD9660		# ISO 9660 + Rock Ridge file system
+#file-system 	FDESC		# /dev/fd
+file-system 	KERNFS		# /kern (kernel informational filesystem)
+#file-system 	NULLFS		# loopback file system
+#file-system 	PORTAL		# portal filesystem (still experimental)
+file-system 	PROCFS		# /proc
+#file-system 	UMAPFS		# NULLFS + uid and gid remapping
+file-system 	UNION
+
+options 	FIFO		# POSIX fifo support (in all filesystems)
+#options 	NFSSERVER	# Sun NFS-compatible filesystem (server)
+options 	QUOTA		# UFS quotas
+
+# Networking options
+options 	INET		# Internet protocols
+options 	"TCP_COMPAT_42"	# compatibility with 4.2BSD TCP/IP
+#options 	GATEWAY		# IP packet forwarding
+options 	MULTICAST	# Multicast support
+#options 	MROUTING	# Multicast routing support
+#options 	ISO		# OSI networking
+#options 	TPIP		# TPIP
+#options 	EON		# OSI tunneling over IP
+#options 	CCITT,LLC,HDLC	# X.25
+
+# NetBSD backwards compatibility
+#options 	COMPAT_10	# NetBSD 1.0, (needed for X on 386?)
+#options 	COMPAT_11	# NetBSD 1.1,
+options 	COMPAT_12	# Netbsd 1.2 reboot()
+
+config		netbsd		root on ? type ?
+config		nfsnetbsd	root on ? type nfs
+
+
+########################################################################
+###                   I/O bus and device options                     ###
+########################################################################
+
+# No device supported.
+
+########################################################################
+# SCSI configuration                                                   #
+########################################################################
+
+########################################################################
+#
+# Device configuration
+#
+########################################################################
+
+vrip*	at mainbus0
+#rtc*	at vrip?
+vrrtc*	at vrip?
+vrbcu*	at vrip?
+#pcic*	at vrip? addr 0x150003e0 addr2 0x10070000 size2 0x4000 intr 4
+pcic*	at vrip? addr 0x150003e0 addr2 0x10070000 size2 0x4000 intr 8
+com*	at vrip? addr 0x0C000000 intr 9
+options __NO_SOFT_SERIAL_INTERRUPT
+
+# PCMCIA bus support
+pcmcia*	at pcic? controller ? socket ?
+
+# PCMCIA IDE disk
+wdc*	at pcmcia? function ?
+wd*	at wdc? channel ? drive ? flags 0x0000
+
+# ATAPI bus support
+atapibus* at wdc? channel ?
+
+########################################################################
+#
+#  Pseudo devices
+#
+########################################################################
+
+pseudo-device	loop		1	# network loopback
+#pseudo-device	sl		 4	# serial-line IP ports
+#pseudo-device   ppp              2      # serial-line IP ports
+pseudo-device	pty		64	# pseudo ptys
+#pseudo-device	bpfilter	16	# packet filter ports
+#pseudo-device	ipfilter		# IP filter, NAT
+
+#pseudo-device	vnd		4	# virtual disk ick
+#pseudo-device   ccd             4       # concatenated disks
+pseudo-device	md		1	# memory disk device (ramdisk)
+
+#pseudo-device	rasterconsole	1 	# NB: raster console requires "fb"
+#pseudo-device	fb		1	# up to 3 framebuffers
+# rnd is EXPERIMENTAL
+#pseudo-device	rnd			# /dev/random and in-kernel generator
+
+pseudo-device	biconsdev	1	# build-in console device
diff -ruN ../../../osrc/sys/arch/hpcmips/conf/files.hpcmips hpcmips/conf/files.hpcmips
--- ../../../osrc/sys/arch/hpcmips/conf/files.hpcmips	Thu Apr 15 07:20:51 1999
+++ hpcmips/conf/files.hpcmips	Wed May 12 11:32:30 1999
@@ -55,6 +55,10 @@
 pseudo-device	biconsdev
 file	arch/hpcmips/dev/biconsdev.c	biconsdev	needs-count
 
+# Memory Disk
+file	arch/hpcmips/dev/md_root.c	memory_disk_hooks
+major { md = 17 }
+
 #
 #  Vr41x1 integrated peripherals
 #
diff -ruN ../../../osrc/sys/arch/hpcmips/dev/md_root.c hpcmips/dev/md_root.c
--- ../../../osrc/sys/arch/hpcmips/dev/md_root.c	Thu Jan  1 09:00:00 1970
+++ hpcmips/dev/md_root.c	Wed May 12 10:29:31 1999
@@ -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 <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
+
+__KERNEL_RCSID(0, "$NetBSD: md_root.c,v 1.1 1998/11/17 22:41:06 jonathan Exp $");
+
+#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;
+	}
+}
diff -ruN ../../../osrc/sys/arch/hpcmips/hpcmips/conf.c hpcmips/hpcmips/conf.c
--- ../../../osrc/sys/arch/hpcmips/hpcmips/conf.c	Sun Apr 18 21:39:07 1999
+++ hpcmips/hpcmips/conf.c	Wed May 12 11:34:20 1999
@@ -50,6 +50,8 @@
 bdev_decl(wd);
 #include "com.h"
 cdev_decl(com);
+#include "md.h"
+bdev_decl(md);
 
 struct bdevsw	bdevsw[] =
 {
@@ -70,7 +72,7 @@
 	bdev_notdef(),			/* 14: rl */
 	bdev_notdef(),			/* 15: tmscp */
 	bdev_notdef(),			/* 16: cs */
-bdev_notdef(),/*bdev_disk_init(NMD,md),*/		/* 17: memory disk driver */
+	bdev_disk_init(NMD,md),		/* 17: memory disk driver */
 bdev_notdef(),/*bdev_tape_init(NST,st),*/		/* 18: st */
 bdev_notdef(),/*bdev_disk_init(NSD,sd),*/		/* 19: sd */
 bdev_notdef(),/*bdev_tape_init(NTZ, tz),*/	/* 20: tz */
@@ -106,6 +108,7 @@
 cdev_decl(cn);
 #include "biconsdev.h"
 cdev_decl(biconsdev);
+cdev_decl(md);
 
 #if (NDC_DS > 0) || (NDC_IOASIC > 0)
 # define NDC 1
@@ -224,7 +227,7 @@
 cdev_notdef(),	/*cdev_lkm_init(NLKM,lkm),*/	/* 94: loadable module driver */
 cdev_notdef(),	/*cdev_scsibus_init(NSCSIBUS,scsibus),*/ /* 95: SCSI bus */
 cdev_notdef(),	/*cdev_disk_init(NRAID,raid),*/	/* 96: RAIDframe disk driver */
-cdev_notdef(),	/*cdev_disk_init(NMD,md),*/	/* 97: memory disk  driver */
+	cdev_disk_init(NMD,md),	/* 97: memory disk  driver */
 
 	cdev_tty_init(NBICONSDEV,biconsdev),	/* 98: bicons pseudo-dev */
 };