sf_buf.h revision 256281
150476Speter/*-
21987Swollman * Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu>
31987Swollman * All rights reserved.
41987Swollman *
5156813Sru * Redistribution and use in source and binary forms, with or without
6156813Sru * modification, are permitted provided that the following conditions
7100346Sru * are met:
8100346Sru * 1. Redistributions of source code must retain the above copyright
9100346Sru *    notice, this list of conditions and the following disclaimer.
10100346Sru * 2. Redistributions in binary form must reproduce the above copyright
11100346Sru *    notice, this list of conditions and the following disclaimer in the
12100346Sru *    documentation and/or other materials provided with the distribution.
13100346Sru *
14100346Sru * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15100346Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16100346Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17100346Sru * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18100346Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19100346Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20100346Sru * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21100346Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22100346Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23100346Sru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24100346Sru * SUCH DAMAGE.
25100346Sru *
26100346Sru * $FreeBSD: stable/10/sys/mips/include/sf_buf.h 255318 2013-09-06 17:44:13Z glebius $
27100346Sru */
28100346Sru
29100346Sru#ifndef _MACHINE_SF_BUF_H_
30100346Sru#define _MACHINE_SF_BUF_H_
31100346Sru
32100346Sru#ifdef __mips_n64
33100346Sru#include <vm/vm.h>
34100346Sru#include <vm/vm_param.h>
35100346Sru#include <vm/vm_page.h>
36132211Sscottl#else
374257Sphk#include <sys/queue.h>
38100346Sru#endif
39100346Sru
40100346Sru#ifdef __mips_n64
41100346Sru/* In 64 bit the whole memory is directly mapped */
42100346Srustruct	sf_buf;
43100346Sru
44100346Srustatic inline struct sf_buf *
45100346Srusf_buf_alloc(struct vm_page *m, int pri)
46100346Sru{
47100346Sru
48100346Sru	return ((struct sf_buf *)m);
49100346Sru}
50100346Sru
51100346Srustatic inline void
52100346Srusf_buf_free(struct sf_buf *sf)
53100346Sru{
54100346Sru}
55100346Sru
56100346Srustatic __inline vm_offset_t
57100346Srusf_buf_kva(struct sf_buf *sf)
58100346Sru{
59100346Sru	vm_page_t	m;
60100346Sru
61100346Sru	m = (vm_page_t)sf;
62100346Sru	return (MIPS_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m)));
63100346Sru}
64100346Sru
65100346Srustatic __inline struct vm_page *
66100346Srusf_buf_page(struct sf_buf *sf)
67100346Sru{
68100346Sru
69100346Sru	return ((vm_page_t)sf);
70100346Sru}
71100346Sru
72100346Sru#else /* ! __mips_n64 */
73100346Srustruct vm_page;
74100346Sru
75100346Srustruct sf_buf {
76100346Sru	SLIST_ENTRY(sf_buf) free_list;	/* list of free buffer slots */
77100346Sru	struct		vm_page *m;	/* currently mapped page */
78100346Sru	vm_offset_t	kva;		/* va of mapping */
79100346Sru};
80100346Sru
81100346Srustruct sf_buf * sf_buf_alloc(struct vm_page *m, int flags);
82100346Sruvoid sf_buf_free(struct sf_buf *sf);
83100346Sru
84100346Srustatic __inline vm_offset_t
85100346Srusf_buf_kva(struct sf_buf *sf)
86100346Sru{
87100346Sru
88100346Sru	return (sf->kva);
89100346Sru}
90100346Sru
91100346Srustatic __inline struct vm_page *
92100346Srusf_buf_page(struct sf_buf *sf)
93100346Sru{
94100346Sru
95100346Sru	return (sf->m);
96100346Sru}
97100346Sru#endif /* __mips_n64 */
98100346Sru
99100346Sru#endif /* !_MACHINE_SF_BUF_H_ */
100100346Sru