Fix whitespace for function prototypes.
[dragonfly.git] / sys / sys / msfbuf.h
1 /*
2  * Copyright (c) 2004 The DragonFly Project.  All rights reserved.
3  *
4  * This code is derived from software contributed to The DragonFly Project
5  * by Hiten Pandya <hmp@backplane.com> and Matthew Dillon
6  * <dillon@backplane.com>.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in
16  *    the documentation and/or other materials provided with the
17  *    distribution.
18  * 3. Neither the name of The DragonFly Project nor the names of its
19  *    contributors may be used to endorse or promote products derived
20  *    from this software without specific, prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
26  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  * The MSF_BUF API is an augmentation similar to the SFBUF APIs and uses XIO
36  * page array handling.  The SFBUF API originally came from:
37  *
38  *      Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu>.  All rights reserved.
39  *      Copyright (c) 1998 David Greenman.  All rights reserved.
40  *      src/sys/sys/sfbuf.h,v 1.4 2004/04/01 17:58:06 dillon
41  *
42  * $DragonFly: src/sys/sys/msfbuf.h,v 1.6 2005/03/01 04:24:28 hmp Exp $
43  */
44 #ifndef _SYS_MSFBUF_H_
45 #define _SYS_MSFBUF_H_
46
47 #ifndef _SYS_QUEUE_H_
48 #include <sys/queue.h>
49 #endif
50
51 #ifndef _SYS_XIO_H_
52 #include <sys/xio.h>
53 #endif
54
55 #if defined(MALLOC_DECLARE)
56 MALLOC_DECLARE(M_MSFBUF);
57 #endif
58
59 /*
60  * MSF_BUFs are used for caching ephermal mappings that span more than
61  * one page.
62  *
63  * The interface returns an msf_buf data structure which has information
64  * about managing the ephermal mapping, its KVA pointer and an embedded
65  * XIO structure which describes the mapping.
66  *
67  * The embedded XIO structure be passed around to the DEV system because
68  * it is ref-counted; thus making it perfectly usable by anything that
69  * can accept an XIO as a transfer unit, most notably the buffer-cache
70  * and the XIO API.
71  *
72  */
73
74 struct msf_buf {
75         LIST_ENTRY(msf_buf)  active_list; /* active list of buffers */
76         TAILQ_ENTRY(msf_buf) free_list;   /* free list of buffers */
77         vm_offset_t     m_kva;                /* KVA offset */
78         cpumask_t       m_cpumask;            /* CPU mask for synchronization */
79         struct xio      m_xio;                /* xio embedded */
80         int             m_refcnt;             /* map usage tracking */
81         int             m_flags;              /* control flags */
82 };
83
84 #if defined(_KERNEL)
85
86 /*
87  * Return a KVA offset to the client
88  */
89 static __inline
90 vm_offset_t
91 msf_buf_kva(struct msf_buf *msf)
92 {
93         return (msf->m_kva);
94 }
95
96 /*
97  * Return a reference to the underlying pages of an MSF_BUF
98  */
99 static __inline
100 vm_page_t *
101 msf_buf_pages(struct msf_buf *msf)
102 {
103         return (msf->m_xio.xio_pages);
104 }
105
106 /* API function prototypes */
107 struct msf_buf  *msf_buf_alloc(vm_page_t *, int, int);
108 void    msf_buf_free(struct msf_buf *);
109 void    msf_buf_ref(struct msf_buf *);
110
111 #endif /* _KERNEL */
112
113 #endif