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