add MEMORY_DISK_DYNAMIC option. if enable MEMORY_DISK_DYNAMIC, file

system image's address and size are setted by md_root_setconf().
This commit is contained in:
uch 2001-07-02 17:17:23 +00:00
parent b53f2df0b2
commit fd2c055c01
3 changed files with 30 additions and 16 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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 <sys/param.h>
#include <sys/systm.h>
#include <sys/reboot.h>
#include <dev/md.h>
#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) {