xref: /netbsd-src/sys/dev/md.h (revision e2cb3fd64fefcd2e1a380868e84919ac0e7bf6c8)
1 /*	$NetBSD: md.h,v 1.11 2009/12/14 03:11:22 uebayasi 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 #ifndef _SYS_DEV_MD_H_
29 #define _SYS_DEV_MD_H_
30 
31 /*
32  * Memory-disk ioctl functions:
33  */
34 
35 #include <sys/ioccom.h>
36 
37 struct md_conf {
38 	void *md_addr;
39 	size_t  md_size;
40 	int     md_type;
41 };
42 
43 #define MD_GETCONF	_IOR('r', 0, struct md_conf)	/* get unit config */
44 #define MD_SETCONF	_IOW('r', 1, struct md_conf)	/* set unit config */
45 
46 /*
47  * There are three configurations supported for each unit,
48  * reflected in the value of the md_type field:
49  */
50 #define MD_UNCONFIGURED 0
51 /*
52  *     Not yet configured.  Open returns ENXIO.
53  */
54 #define MD_KMEM_FIXED	1
55 /*
56  *     Disk image resident in kernel (patched in or loaded).
57  *     Requires that the function: md_set_kmem() is called to
58  *     attach the (initialized) kernel memory to be used by the
59  *     device.  It can be initialized by an "open hook" if this
60  *     driver is compiled with the MD_OPEN_HOOK option.
61  *     No attempt will ever be made to free this memory.
62  */
63 #define MD_KMEM_ALLOCATED 2
64 /*
65  *     Small, wired-down chunk of kernel memory obtained from
66  *     kmem_alloc().  The allocation is performed by an ioctl
67  *     call on the raw partition.
68  */
69 #define MD_UMEM_SERVER 3
70 /*
71  *     Indirect access to user-space of a user-level server.
72  *     (Like the MFS hack, but better! 8^)  Device operates
73  *     only while the server has the raw partition open and
74  *     continues to service I/O requests.  The process that
75  *     does this setconf will become the I/O server.  This
76  *     configuration type can be disabled using:
77  *         options  MEMORY_DISK_SERVER=0
78  */
79 
80 #ifdef	_KERNEL
81 /*
82  * If the option MEMORY_DISK_HOOKS is on, then these functions are
83  * called by the ramdisk driver to allow machine-dependent to
84  * match/configure and/or load each ramdisk unit.
85  */
86 extern void md_attach_hook(int, struct md_conf *);
87 extern void md_open_hook(int, struct md_conf *);
88 extern void md_root_setconf(char *, size_t);
89 
90 extern int md_is_root;
91 #endif /* _KERNEL */
92 
93 #endif /* _SYS_DEV_MD_H_ */
94