xref: /freebsd/sys/i386/include/sf_buf.h (revision 8a5ac5d56f6fa2d4569c90ce3efe3077588dd9f9)
1e45db9b8SAlan Cox /*-
25c0db7c7SAlan Cox  * Copyright (c) 2003, 2005 Alan L. Cox <alc@cs.rice.edu>
3e45db9b8SAlan Cox  * All rights reserved.
4e45db9b8SAlan Cox  *
5e45db9b8SAlan Cox  * Redistribution and use in source and binary forms, with or without
6e45db9b8SAlan Cox  * modification, are permitted provided that the following conditions
7e45db9b8SAlan Cox  * are met:
8e45db9b8SAlan Cox  * 1. Redistributions of source code must retain the above copyright
9e45db9b8SAlan Cox  *    notice, this list of conditions and the following disclaimer.
10e45db9b8SAlan Cox  * 2. Redistributions in binary form must reproduce the above copyright
11e45db9b8SAlan Cox  *    notice, this list of conditions and the following disclaimer in the
12e45db9b8SAlan Cox  *    documentation and/or other materials provided with the distribution.
13e45db9b8SAlan Cox  *
14e45db9b8SAlan Cox  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15e45db9b8SAlan Cox  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16e45db9b8SAlan Cox  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17e45db9b8SAlan Cox  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18e45db9b8SAlan Cox  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19e45db9b8SAlan Cox  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20e45db9b8SAlan Cox  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21e45db9b8SAlan Cox  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22e45db9b8SAlan Cox  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23e45db9b8SAlan Cox  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24e45db9b8SAlan Cox  * SUCH DAMAGE.
25e45db9b8SAlan Cox  *
26e45db9b8SAlan Cox  * $FreeBSD$
27e45db9b8SAlan Cox  */
28e45db9b8SAlan Cox 
29e45db9b8SAlan Cox #ifndef _MACHINE_SF_BUF_H_
30e45db9b8SAlan Cox #define _MACHINE_SF_BUF_H_
31e45db9b8SAlan Cox 
32e45db9b8SAlan Cox #include <sys/queue.h>
33e45db9b8SAlan Cox 
34e45db9b8SAlan Cox struct vm_page;
35e45db9b8SAlan Cox 
36e45db9b8SAlan Cox struct sf_buf {
370543fa53SAlan Cox 	LIST_ENTRY(sf_buf) list_entry;	/* list of buffers */
38a5819cb5SAlan Cox 	TAILQ_ENTRY(sf_buf) free_entry;	/* list of buffers */
39e45db9b8SAlan Cox 	struct		vm_page *m;	/* currently mapped page */
40e45db9b8SAlan Cox 	vm_offset_t	kva;		/* va of mapping */
410543fa53SAlan Cox 	int		ref_count;	/* usage of this mapping */
425c0db7c7SAlan Cox #ifdef SMP
435c0db7c7SAlan Cox 	cpumask_t	cpumask;	/* cpus on which mapping is valid */
445c0db7c7SAlan Cox #endif
45e45db9b8SAlan Cox };
46e45db9b8SAlan Cox 
47e45db9b8SAlan Cox static __inline vm_offset_t
48e45db9b8SAlan Cox sf_buf_kva(struct sf_buf *sf)
49e45db9b8SAlan Cox {
50e45db9b8SAlan Cox 
51e45db9b8SAlan Cox 	return (sf->kva);
52e45db9b8SAlan Cox }
53e45db9b8SAlan Cox 
54e45db9b8SAlan Cox static __inline struct vm_page *
55e45db9b8SAlan Cox sf_buf_page(struct sf_buf *sf)
56e45db9b8SAlan Cox {
57e45db9b8SAlan Cox 
58e45db9b8SAlan Cox 	return (sf->m);
59e45db9b8SAlan Cox }
60e45db9b8SAlan Cox 
618a5ac5d5SKonstantin Belousov boolean_t sf_buf_invalidate_cache(vm_page_t m);
628a5ac5d5SKonstantin Belousov 
63e45db9b8SAlan Cox #endif /* !_MACHINE_SF_BUF_H_ */
64