1178172Simp/*- 2206714Sjmallett * Copyright (c) 2003 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 * $FreeBSD$ 27178172Simp */ 28178172Simp 29178172Simp#ifndef _MACHINE_SF_BUF_H_ 30206714Sjmallett#define _MACHINE_SF_BUF_H_ 31178172Simp 32217944Sjchandra#ifdef __mips_n64 33217944Sjchandra#include <vm/vm.h> 34217944Sjchandra#include <vm/vm_param.h> 35217944Sjchandra#include <vm/vm_page.h> 36217944Sjchandra#else 37178172Simp#include <sys/queue.h> 38217944Sjchandra#endif 39178172Simp 40217944Sjchandra#ifdef __mips_n64 41217944Sjchandra/* In 64 bit the whole memory is directly mapped */ 42217944Sjchandrastruct sf_buf; 43217944Sjchandra 44255289Sglebiusstatic inline struct sf_buf * 45255289Sglebiussf_buf_alloc(struct vm_page *m, int pri) 46255289Sglebius{ 47255289Sglebius 48255289Sglebius return ((struct sf_buf *)m); 49255289Sglebius} 50255289Sglebius 51255289Sglebiusstatic inline void 52255289Sglebiussf_buf_free(struct sf_buf *sf) 53255289Sglebius{ 54255289Sglebius} 55255289Sglebius 56217944Sjchandrastatic __inline vm_offset_t 57217944Sjchandrasf_buf_kva(struct sf_buf *sf) 58217944Sjchandra{ 59217944Sjchandra vm_page_t m; 60217944Sjchandra 61217944Sjchandra m = (vm_page_t)sf; 62217944Sjchandra return (MIPS_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m))); 63217944Sjchandra} 64217944Sjchandra 65217944Sjchandrastatic __inline struct vm_page * 66217944Sjchandrasf_buf_page(struct sf_buf *sf) 67217944Sjchandra{ 68217944Sjchandra 69217944Sjchandra return ((vm_page_t)sf); 70217944Sjchandra} 71217944Sjchandra 72217944Sjchandra#else /* ! __mips_n64 */ 73178172Simpstruct vm_page; 74178172Simp 75178172Simpstruct sf_buf { 76206714Sjmallett SLIST_ENTRY(sf_buf) free_list; /* list of free buffer slots */ 77178172Simp struct vm_page *m; /* currently mapped page */ 78178172Simp vm_offset_t kva; /* va of mapping */ 79178172Simp}; 80178172Simp 81255318Sglebiusstruct sf_buf * sf_buf_alloc(struct vm_page *m, int flags); 82255318Sglebiusvoid sf_buf_free(struct sf_buf *sf); 83255318Sglebius 84178172Simpstatic __inline vm_offset_t 85178172Simpsf_buf_kva(struct sf_buf *sf) 86178172Simp{ 87178172Simp 88178172Simp return (sf->kva); 89178172Simp} 90178172Simp 91178172Simpstatic __inline struct vm_page * 92178172Simpsf_buf_page(struct sf_buf *sf) 93178172Simp{ 94178172Simp 95178172Simp return (sf->m); 96178172Simp} 97217944Sjchandra#endif /* __mips_n64 */ 98178172Simp 99178172Simp#endif /* !_MACHINE_SF_BUF_H_ */ 100