sf_buf.h revision 178172
1178172Simp/*-
2178172Simp * Copyright (c) 2003, 2005 Alan L. Cox <alc@cs.rice.edu>
3178172Simp * All rights reserved.
4178172Simp *
5178172Simp * Redistribution and use in source and binary forms, with or without
6178172Simp * modification, are permitted provided that the following conditions
7178172Simp * are met:
8178172Simp * 1. Redistributions of source code must retain the above copyright
9178172Simp *    notice, this list of conditions and the following disclaimer.
10178172Simp * 2. Redistributions in binary form must reproduce the above copyright
11178172Simp *    notice, this list of conditions and the following disclaimer in the
12178172Simp *    documentation and/or other materials provided with the distribution.
13178172Simp *
14178172Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15178172Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16178172Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17178172Simp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18178172Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19178172Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20178172Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21178172Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22178172Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23178172Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24178172Simp * SUCH DAMAGE.
25178172Simp *
26178172Simp *	from: src/sys/i386/include/sf_buf.h,v 1.4 2005/02/13 06:23:13 alc
27178172Simp * $FreeBSD: head/sys/mips/include/sf_buf.h 178172 2008-04-13 07:27:37Z imp $
28178172Simp */
29178172Simp
30178172Simp#ifndef _MACHINE_SF_BUF_H_
31178172Simp#define	_MACHINE_SF_BUF_H_
32178172Simp
33178172Simp#include <sys/queue.h>
34178172Simp#include <vm/vm.h>
35178172Simp#include <vm/vm_param.h>
36178172Simp#include <vm/vm_page.h>
37178172Simp
38178172Simpstruct vm_page;
39178172Simp
40178172Simpstruct sf_buf {
41178172Simp	LIST_ENTRY(sf_buf) list_entry;	/* list of buffers */
42178172Simp	TAILQ_ENTRY(sf_buf) free_entry; /* list of buffers */
43178172Simp	struct		vm_page *m;	/* currently mapped page */
44178172Simp	vm_offset_t	kva;		/* va of mapping */
45178172Simp	int		ref_count;	/* usage of this mapping */
46178172Simp#ifdef SMP
47178172Simp	cpumask_t	cpumask;	/* cpus on which mapping is valid */
48178172Simp#endif
49178172Simp};
50178172Simp
51178172Simpstatic __inline vm_offset_t
52178172Simpsf_buf_kva(struct sf_buf *sf)
53178172Simp{
54178172Simp
55178172Simp	return (sf->kva);
56178172Simp}
57178172Simp
58178172Simpstatic __inline struct vm_page *
59178172Simpsf_buf_page(struct sf_buf *sf)
60178172Simp{
61178172Simp
62178172Simp	return (sf->m);
63178172Simp}
64178172Simp
65178172Simp#endif /* !_MACHINE_SF_BUF_H_ */
66