Fix up mix of man(7)/mdoc(7).
[netbsd-mini2440.git] / sys / arch / acorn32 / dev / md_hooks.c
blob2bfd79738c7e8a73383da21ab87d1ab8bfd96ca4
1 /* $NetBSD: md_hooks.c,v 1.9 2009/03/14 14:45:51 dsl Exp $ */
3 /*
4 * Copyright (c) 1995 Gordon W. Ross
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: md_hooks.c,v 1.9 2009/03/14 14:45:51 dsl Exp $");
33 #include "opt_md.h"
35 #include <sys/param.h>
36 #include <sys/reboot.h>
37 #include <sys/device.h>
38 #include <sys/systm.h>
40 #include <uvm/uvm_extern.h>
42 #include <dev/md.h>
44 #ifdef MEMORY_DISK_ROOT_SIZE
45 #define ROOTBYTES (MEMORY_DISK_ROOT_SIZE << DEV_BSHIFT)
48 * This array will be patched to contain a file-system image.
49 * See the program: src/distrib/sun3/common/rdsetroot.c
51 size_t md_root_size = ROOTBYTES;
52 char md_root_image[ROOTBYTES] = "|This is the root ramdisk!\n";
54 #else /* MEMORY_DISK_ROOT_SIZE */
56 size_t md_root_size = 0; /* set by machdep.c */
57 static struct md_conf *bootmd = NULL;
59 extern int load_memory_disc_from_floppy(struct md_conf *md, dev_t dev);
61 #include "fdc.h"
62 #endif /* MEMORY_DISK_ROOT_SIZE */
64 void
65 md_attach_hook(int unit, struct md_conf *md)
67 if (unit == 0) {
68 #ifdef MEMORY_DISK_ROOT_SIZE
69 /* Setup root ramdisk */
70 md->md_addr = (void *) md_root_image;
71 md->md_size = (size_t) md_root_size;
72 md->md_type = MD_KMEM_FIXED;
73 #else /* MEMORY_DISK_ROOT_SIZE */
74 #ifdef OLD_MEMORY_DISK_SIZE
75 if (md_root_size == 0 && OLD_MEMORY_DISK_SIZE)
76 md_root_size = (OLD_MEMORY_DISK_SIZE << DEV_BSHIFT);
77 #endif /* OLD_MEMORY_DISK_SIZE */
78 if (md_root_size != 0) {
79 md->md_size = round_page(md_root_size);
80 md->md_addr = (void *)uvm_km_alloc(kernel_map,
81 md_root_size, 0, UVM_KMF_WIRED | UVM_KMF_ZERO);
82 md->md_type = MD_KMEM_FIXED;
83 bootmd = md;
85 #endif /* MEMORY_DISK_ROOT_SIZE */
86 printf("md%d: allocated %ldK (%ld blocks)\n", unit, (long)md->md_size / 1024, (long)md->md_size / DEV_BSIZE);
92 * This is called during open (i.e. mountroot)
95 void
96 md_open_hook(int unit, struct md_conf *md)
98 if (unit == 0) {
99 /* The root memory disk only works single-user. */
100 boothowto |= RB_SINGLE;
101 #if !defined(MEMORY_DISK_ROOT_SIZE) && NFDC > 0
102 load_memory_disc_from_floppy(bootmd, makedev(17, 1)); /* XXX 1.44MB FD */
103 #endif