From fd2c055c0187b50a5ac74f2e50249b704b4f39a3 Mon Sep 17 00:00:00 2001 From: uch Date: Mon, 2 Jul 2001 17:17:23 +0000 Subject: [PATCH] add MEMORY_DISK_DYNAMIC option. if enable MEMORY_DISK_DYNAMIC, file system image's address and size are setted by md_root_setconf(). --- sys/conf/files | 4 ++-- sys/dev/md.h | 9 ++++++--- sys/dev/md_root.c | 33 ++++++++++++++++++++++----------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index e5f10b719ad8..1d8b34165528 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.449 2001/07/01 02:56:20 gmcgarry Exp $ +# $NetBSD: files,v 1.450 2001/07/02 17:17:23 uch Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -140,7 +140,7 @@ defopt LOCKDEBUG defopt SYSCALL_DEBUG # memory (ram) disk options -defopt opt_md.h MEMORY_DISK_HOOKS MEMORY_DISK_SERVER MEMORY_DISK_IS_ROOT +defopt opt_md.h MEMORY_DISK_HOOKS MEMORY_DISK_SERVER MEMORY_DISK_IS_ROOT MEMORY_DISK_DYNAMIC defopt opt_mdsize.h MINIROOTSIZE diff --git a/sys/dev/md.h b/sys/dev/md.h index c2cb6050d6a3..2b85e3652af5 100644 --- a/sys/dev/md.h +++ b/sys/dev/md.h @@ -1,4 +1,4 @@ -/* $NetBSD: md.h,v 1.6 2000/01/21 12:14:53 tsutsui Exp $ */ +/* $NetBSD: md.h,v 1.7 2001/07/02 17:17:25 uch Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -85,6 +85,9 @@ struct md_conf { * called by the ramdisk driver to allow machine-dependent to * match/configure and/or load each ramdisk unit. */ -extern void md_attach_hook __P((int unit, struct md_conf *)); -extern void md_open_hook __P((int unit, struct md_conf *)); +extern void md_attach_hook(int, struct md_conf *); +extern void md_open_hook(int, struct md_conf *); +#ifdef MEMORY_DISK_DYNAMIC +extern void md_root_setconf(char *, size_t); #endif +#endif /* _KERNEL */ diff --git a/sys/dev/md_root.c b/sys/dev/md_root.c index d2cbe9510fd5..81efc52a79bf 100644 --- a/sys/dev/md_root.c +++ b/sys/dev/md_root.c @@ -1,4 +1,4 @@ -/* $NetBSD: md_root.c,v 1.1 2000/10/02 15:22:32 tsutsui Exp $ */ +/* $NetBSD: md_root.c,v 1.2 2001/07/02 17:17:25 uch Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -36,20 +36,25 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "opt_md.h" +#include "opt_mdsize.h" + #include #include #include #include -#include "opt_mdsize.h" - extern int boothowto; +#if MEMORY_DISK_DYNAMIC +size_t md_root_size; +char *md_root_image; +#else /* MEMORY_DISK_DYNAMIC */ + #ifndef MINIROOTSIZE #define MINIROOTSIZE 512 #endif - #define ROOTBYTES (MINIROOTSIZE << DEV_BSHIFT) /* @@ -58,14 +63,22 @@ extern int boothowto; */ u_int32_t md_root_size = ROOTBYTES; char md_root_image[ROOTBYTES] = "|This is the root ramdisk!\n"; +#endif /* MEMORY_DISK_DYNAMIC */ + +#if MEMORY_DISK_DYNAMIC +void +md_root_setconf(char *addr, size_t size) +{ + md_root_image = addr; + md_root_size = size; +} +#endif /* MEMORY_DISK_DYNAMIC */ /* * This is called during pseudo-device attachment. */ void -md_attach_hook(unit, md) - int unit; - struct md_conf *md; +md_attach_hook(int unit, struct md_conf *md) { char pbuf[9]; @@ -74,7 +87,7 @@ md_attach_hook(unit, md) md->md_addr = (caddr_t)md_root_image; md->md_size = (size_t)md_root_size; md->md_type = MD_KMEM_FIXED; - format_bytes(pbuf, sizeof(pbuf), ROOTBYTES); + format_bytes(pbuf, sizeof(pbuf), md->md_size); printf("md%d: internal %s image area\n", unit, pbuf); } } @@ -83,9 +96,7 @@ md_attach_hook(unit, md) * This is called during open (i.e. mountroot) */ void -md_open_hook(unit, md) - int unit; - struct md_conf *md; +md_open_hook(int unit, struct md_conf *md) { if (unit == 0) {