Improve seperation between kernel code and userland code by requiring
[dragonfly.git] / sys / sys / disk.h
CommitLineData
984263bc 1/*
8c10bfcf
MD
2 * Copyright (c) 2003,2004 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
6 *
e4c9c0c8
MD
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
8c10bfcf 10 *
e4c9c0c8
MD
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
8c10bfcf
MD
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
e4c9c0c8 32 * SUCH DAMAGE.
8c10bfcf 33 *
984263bc
MD
34 * ----------------------------------------------------------------------------
35 * "THE BEER-WARE LICENSE" (Revision 42):
36 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
37 * can do whatever you want with this stuff. If we meet some day, and you think
38 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
39 * ----------------------------------------------------------------------------
40 *
41 * $FreeBSD: src/sys/sys/disk.h,v 1.16.2.3 2001/06/20 16:11:01 scottl Exp $
d9f3f6fa 42 * $DragonFly: src/sys/sys/disk.h,v 1.7 2004/12/30 07:01:52 cpressey Exp $
984263bc
MD
43 */
44
45#ifndef _SYS_DISK_H_
46#define _SYS_DISK_H_
47
d9f3f6fa
CP
48#if !defined(_KERNEL) && !defined(_KERNEL_STRUCTURES)
49#error "This file should not be included by userland programs."
50#endif
51
984263bc
MD
52#ifndef _SYS_DISKSLICE_H_
53#include <sys/diskslice.h>
335dda38 54#endif
984263bc
MD
55
56#ifndef _SYS_DISKLABEL
57#include <sys/disklabel.h>
335dda38
MD
58#endif
59
60#ifndef _SYS_DISKLABEL
61#include <sys/msgport.h>
62#endif
984263bc
MD
63
64struct disk {
335dda38 65 struct lwkt_port d_port; /* interception port */
e4c9c0c8
MD
66 struct cdevsw *d_devsw; /* our device switch */
67 struct cdevsw *d_rawsw; /* the raw device switch */
984263bc
MD
68 u_int d_flags;
69 u_int d_dsflags;
e4c9c0c8
MD
70 dev_t d_rawdev; /* backing raw device */
71 dev_t d_cdev; /* special whole-disk part */
984263bc
MD
72 struct diskslices *d_slice;
73 struct disklabel d_label;
74 LIST_ENTRY(disk) d_list;
75};
76
77#define DISKFLAG_LOCK 0x1
78#define DISKFLAG_WANTED 0x2
79
d9f3f6fa 80#ifdef _KERNEL
e4c9c0c8 81dev_t disk_create (int unit, struct disk *disk, int flags, struct cdevsw *sw);
b153f746
RG
82void disk_destroy (struct disk *disk);
83int disk_dumpcheck (dev_t dev, u_int *count, u_int *blkno, u_int *secsize);
84struct disk *disk_enumerate (struct disk *disk);
85void disk_invalidate (struct disk *disk);
d9f3f6fa 86#endif /* _KERNEL */
984263bc
MD
87
88#endif /* _SYS_DISK_H_ */