xref: /netbsd-src/sys/dev/md.h (revision abb0f93cd77b67f080613360c65701f85e5f5cfe)
1 /*	$NetBSD: md.h,v 1.10 2009/10/21 23:12:10 snj Exp $	*/
2 
3 /*
4  * Copyright (c) 1995 Gordon W. Ross
5  * All rights reserved.
6  *
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  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 /*
29  * Memory-disk ioctl functions:
30  */
31 
32 #include <sys/ioccom.h>
33 
34 struct md_conf {
35 	void *md_addr;
36 	size_t  md_size;
37 	int     md_type;
38 };
39 
40 #define MD_GETCONF	_IOR('r', 0, struct md_conf)	/* get unit config */
41 #define MD_SETCONF	_IOW('r', 1, struct md_conf)	/* set unit config */
42 
43 /*
44  * There are three configurations supported for each unit,
45  * reflected in the value of the md_type field:
46  */
47 #define MD_UNCONFIGURED 0
48 /*
49  *     Not yet configured.  Open returns ENXIO.
50  */
51 #define MD_KMEM_FIXED	1
52 /*
53  *     Disk image resident in kernel (patched in or loaded).
54  *     Requires that the function: md_set_kmem() is called to
55  *     attach the (initialized) kernel memory to be used by the
56  *     device.  It can be initialized by an "open hook" if this
57  *     driver is compiled with the MD_OPEN_HOOK option.
58  *     No attempt will ever be made to free this memory.
59  */
60 #define MD_KMEM_ALLOCATED 2
61 /*
62  *     Small, wired-down chunk of kernel memory obtained from
63  *     kmem_alloc().  The allocation is performed by an ioctl
64  *     call on the raw partition.
65  */
66 #define MD_UMEM_SERVER 3
67 /*
68  *     Indirect access to user-space of a user-level server.
69  *     (Like the MFS hack, but better! 8^)  Device operates
70  *     only while the server has the raw partition open and
71  *     continues to service I/O requests.  The process that
72  *     does this setconf will become the I/O server.  This
73  *     configuration type can be disabled using:
74  *         options  MEMORY_DISK_SERVER=0
75  */
76 
77 #ifdef	_KERNEL
78 /*
79  * If the option MEMORY_DISK_HOOKS is on, then these functions are
80  * called by the ramdisk driver to allow machine-dependent to
81  * match/configure and/or load each ramdisk unit.
82  */
83 extern void md_attach_hook(int, struct md_conf *);
84 extern void md_open_hook(int, struct md_conf *);
85 extern void md_root_setconf(char *, size_t);
86 
87 extern int md_is_root;
88 #endif /* _KERNEL */
89