]>
git.saurik.com Git - apple/xnu.git/blob - bsd/vm/vnode_pager.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1987 Carnegie-Mellon University
28 * All rights reserved. The CMU software License Agreement specifies
29 * the terms and conditions for use and redistribution.
33 #define _VNODE_PAGER_ 1
35 #include <mach/kern_return.h>
36 #include <sys/types.h>
37 #include <kern/queue.h>
41 #include <mach/boolean.h>
42 #include <vm/vm_pager.h>
44 vm_pager_t
vnode_pager_setup();
45 boolean_t
vnode_has_page();
46 boolean_t
vnode_pager_active();
49 * Vstructs are the internal (to us) description of a unit of backing store.
50 * The are the link between memory objects and the backing store they represent.
51 * For the vnode pager, backing store comes in two flavors: normal files and
54 * For objects that page to and from normal files (e.g. objects that represent
55 * program text segments), we maintain some simple parameters that allow us to
56 * access the file's contents directly through the vnode interface.
58 * Data for objects without associated vnodes is maintained in the swap files.
59 * Each object that uses one of these as backing store has a vstruct indicating
60 * the swap file of preference (vs_pf) and a mapping between contiguous object
61 * offsets and swap file offsets (vs_pmap). Each entry in this mapping specifies
62 * the pager file to use, and the offset of the page in that pager file. These
63 * mapping entries are of type pfMapEntry.
67 * Pager file structure. One per swap file.
69 typedef struct pager_file
{
70 queue_chain_t pf_chain
; /* link to other paging files */
71 struct vnode
*pf_vp
; /* vnode of paging file */
72 u_int pf_count
; /* Number of vstruct using this file */
73 u_char
*pf_bmap
; /* Map of used blocks */
74 long pf_npgs
; /* Size of file in pages */
75 long pf_pfree
; /* Number of unused pages */
76 long pf_lowat
; /* Low water page */
77 long pf_hipage
; /* Highest page allocated */
78 long pf_hint
; /* Lowest page unallocated */
79 char *pf_name
; /* Filename of this file */
81 int pf_index
; /* index into the pager_file array */
82 void * pf_lock
; /* Lock for alloc and dealloc */
85 #define PAGER_FILE_NULL (pager_file_t) 0
87 #define MAXPAGERFILES 16
89 #define MAX_BACKING_STORE 100
99 * Pager file data structures.
103 unsigned int index
:8; /* paging file this block is in */
104 unsigned int offset
:24; /* page number where block resides */
108 IS_INODE
, /* Local disk */
113 * Basic vnode pager structure. One per object, backing-store pair.
115 typedef struct vstruct
{
116 boolean_t is_device
; /* Must be first - see vm_pager.h */
117 pager_file_t vs_pf
; /* Pager file this uses */
118 pf_entry
**vs_pmap
; /* Map of pages into paging file */
120 /* boolean_t */ vs_swapfile
:1; /* vnode is a swapfile */
121 short vs_count
; /* use count */
122 int vs_size
; /* size of this chunk in pages*/
123 struct vnode
*vs_vp
; /* vnode to page to */
126 #define VNODE_PAGER_NULL ((vnode_pager_t) 0)
130 pager_return_t
pager_vnode_pagein();
131 pager_return_t
pager_vnode_pageout();
132 pager_return_t
vnode_pagein();
133 pager_return_t
vnode_pageout();
137 #endif /* _VNODE_PAGER_ */