]>
git.saurik.com Git - apple/xnu.git/blob - bsd/vm/vnode_pager.h
0d90c6c3bb9263db99f147d1d33ab1e601aaa21d
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Mach Operating System
32 * Copyright (c) 1987 Carnegie-Mellon University
33 * All rights reserved. The CMU software License Agreement specifies
34 * the terms and conditions for use and redistribution.
38 #define _VNODE_PAGER_ 1
40 #include <mach/kern_return.h>
41 #include <sys/types.h>
42 #include <kern/queue.h>
45 #include <mach/boolean.h>
46 #include <mach/memory_object_types.h>
47 #include <mach/vm_types.h>
48 #include <vm/vm_pager.h>
50 vm_pager_t
vnode_pager_setup(struct vnode
*, memory_object_t
);
53 * Vstructs are the internal (to us) description of a unit of backing store.
54 * The are the link between memory objects and the backing store they represent.
55 * For the vnode pager, backing store comes in two flavors: normal files and
58 * For objects that page to and from normal files (e.g. objects that represent
59 * program text segments), we maintain some simple parameters that allow us to
60 * access the file's contents directly through the vnode interface.
62 * Data for objects without associated vnodes is maintained in the swap files.
63 * Each object that uses one of these as backing store has a vstruct indicating
64 * the swap file of preference (vs_pf) and a mapping between contiguous object
65 * offsets and swap file offsets (vs_pmap). Each entry in this mapping specifies
66 * the pager file to use, and the offset of the page in that pager file. These
67 * mapping entries are of type pfMapEntry.
71 * Pager file structure. One per swap file.
73 typedef struct pager_file
{
74 queue_chain_t pf_chain
; /* link to other paging files */
75 struct vnode
*pf_vp
; /* vnode of paging file */
76 u_int pf_count
; /* Number of vstruct using this file */
77 u_char
*pf_bmap
; /* Map of used blocks */
78 long pf_npgs
; /* Size of file in pages */
79 long pf_pfree
; /* Number of unused pages */
80 long pf_lowat
; /* Low water page */
81 long pf_hipage
; /* Highest page allocated */
82 long pf_hint
; /* Lowest page unallocated */
83 char *pf_name
; /* Filename of this file */
85 int pf_index
; /* index into the pager_file array */
86 void * pf_lock
; /* Lock for alloc and dealloc */
89 #define PAGER_FILE_NULL (pager_file_t) 0
91 #define MAXPAGERFILES 16
93 #define MAX_BACKING_STORE 100
99 extern struct bs_map bs_port_table
[];
104 * Pager file data structures.
108 unsigned int index
:8; /* paging file this block is in */
109 unsigned int offset
:24; /* page number where block resides */
113 IS_INODE
, /* Local disk */
118 * Basic vnode pager structure. One per object, backing-store pair.
120 typedef struct vstruct
{
121 boolean_t is_device
; /* Must be first - see vm_pager.h */
122 pager_file_t vs_pf
; /* Pager file this uses */
123 pf_entry
**vs_pmap
; /* Map of pages into paging file */
125 /* boolean_t */ vs_swapfile
:1; /* vnode is a swapfile */
126 short vs_count
; /* use count */
127 int vs_size
; /* size of this chunk in pages*/
128 struct vnode
*vs_vp
; /* vnode to page to */
131 #define VNODE_PAGER_NULL ((vnode_pager_t) 0)
134 pager_return_t
vnode_pagein(struct vnode
*, upl_t
,
135 upl_offset_t
, vm_object_offset_t
,
136 upl_size_t
, int, int *);
137 pager_return_t
vnode_pageout(struct vnode
*, upl_t
,
138 upl_offset_t
, vm_object_offset_t
,
139 upl_size_t
, int, int *);
141 extern vm_object_offset_t
vnode_pager_get_filesize(
144 extern kern_return_t
vnode_pager_get_pathname(
147 vm_size_t
*length_p
);
149 extern kern_return_t
vnode_pager_get_filename(
155 #endif /* _VNODE_PAGER_ */