/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1990 University of Utah.4* Copyright (c) 1991 The Regents of the University of California.5* All rights reserved.6*7* This code is derived from software contributed to Berkeley by8* the Systems Programming Group of the University of Utah Computer9* Science Department.10*11* Redistribution and use in source and binary forms, with or without12* modification, are permitted provided that the following conditions13* are met:14* 1. Redistributions of source code must retain the above copyright15* notice, this list of conditions and the following disclaimer.16* 2. Redistributions in binary form must reproduce the above copyright17* notice, this list of conditions and the following disclaimer in the18* documentation and/or other materials provided with the distribution.19* 3. Neither the name of the University nor the names of its contributors20* may be used to endorse or promote products derived from this software21* without specific prior written permission.22*23* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND24* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE25* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE26* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE27* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL28* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS29* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)30* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT31* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF33* SUCH DAMAGE.34*/3536#ifndef _VM_SWAP_PAGER_H_37#define _VM_SWAP_PAGER_H_3839#include <sys/_types.h>4041struct buf;42struct swdevt;43struct thread;44typedef void sw_strategy_t(struct buf *, struct swdevt *);45typedef void sw_close_t(struct thread *, struct swdevt *);4647/*48* Swap device table49*/50struct swdevt {51int sw_flags;52int sw_nblks;53int sw_used;54dev_t sw_dev;55struct vnode *sw_vp;56void *sw_id;57__daddr_t sw_first;58__daddr_t sw_end;59struct blist *sw_blist;60TAILQ_ENTRY(swdevt) sw_list;61sw_strategy_t *sw_strategy;62sw_close_t *sw_close;63};6465#define SW_UNMAPPED 0x0166#define SW_CLOSING 0x046768#ifdef _KERNEL6970extern bool swap_pager_almost_full;71extern int swap_pager_avail;72extern int nsw_cluster_max;7374struct xswdev;75int swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len);76void swap_pager_copy(vm_object_t, vm_object_t, vm_pindex_t, int);77bool swap_pager_scan_all_shadowed(vm_object_t object);78vm_pindex_t swap_pager_seek_data(vm_object_t object, vm_pindex_t pindex);79vm_pindex_t swap_pager_seek_hole(vm_object_t object, vm_pindex_t pindex);80void swap_pager_freespace(vm_object_t object, vm_pindex_t start,81vm_size_t size, vm_size_t *freed);82void swap_pager_swap_init(void);83int swap_pager_nswapdev(void);84int swap_pager_reserve(vm_object_t, vm_pindex_t, vm_pindex_t);85void swap_pager_status(int *total, int *used);86u_long swap_pager_swapped_pages(vm_object_t object);87void swapoff_all(void);88bool swap_pager_init_object(vm_object_t object, void *handle,89struct ucred *cred, vm_ooffset_t size, vm_ooffset_t offset);90#endif /* _KERNEL */91#endif /* _VM_SWAP_PAGER_H_ */929394