]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. | |
7 | * | |
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 | |
13 | * file. | |
14 | * | |
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. | |
22 | * | |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
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. | |
30 | */ | |
31 | ||
32 | #ifndef _VNODE_PAGER_ | |
33 | #define _VNODE_PAGER_ 1 | |
34 | ||
35 | #include <mach/kern_return.h> | |
36 | #include <sys/types.h> | |
37 | #include <kern/queue.h> | |
38 | ||
39 | #ifdef KERNEL | |
40 | ||
41 | #include <mach/boolean.h> | |
42 | #include <vm/vm_pager.h> | |
43 | ||
44 | vm_pager_t vnode_pager_setup(); | |
45 | boolean_t vnode_has_page(); | |
46 | boolean_t vnode_pager_active(); | |
47 | ||
48 | /* | |
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 | |
52 | * swap files. | |
53 | * | |
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. | |
57 | * | |
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. | |
64 | */ | |
65 | ||
66 | /* | |
67 | * Pager file structure. One per swap file. | |
68 | */ | |
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 */ | |
80 | boolean_t pf_prefer; | |
81 | int pf_index; /* index into the pager_file array */ | |
82 | void * pf_lock; /* Lock for alloc and dealloc */ | |
83 | } *pager_file_t; | |
84 | ||
85 | #define PAGER_FILE_NULL (pager_file_t) 0 | |
86 | ||
87 | #define MAXPAGERFILES 16 | |
88 | ||
89 | #define MAX_BACKING_STORE 100 | |
90 | ||
91 | struct bs_map { | |
92 | struct vnode *vp; | |
93 | void *bs; | |
94 | }; | |
95 | ||
96 | ||
97 | ||
98 | /* | |
99 | * Pager file data structures. | |
100 | */ | |
101 | #define INDEX_NULL 0 | |
102 | typedef struct { | |
103 | unsigned int index:8; /* paging file this block is in */ | |
104 | unsigned int offset:24; /* page number where block resides */ | |
105 | } pf_entry; | |
106 | ||
107 | typedef enum { | |
108 | IS_INODE, /* Local disk */ | |
109 | IS_RNODE /* NFS */ | |
110 | } vpager_fstype; | |
111 | ||
112 | /* | |
113 | * Basic vnode pager structure. One per object, backing-store pair. | |
114 | */ | |
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 */ | |
119 | unsigned int | |
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 */ | |
124 | } *vnode_pager_t; | |
125 | ||
126 | #define VNODE_PAGER_NULL ((vnode_pager_t) 0) | |
127 | ||
128 | ||
129 | ||
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(); | |
134 | ||
135 | #endif /* KERNEL */ | |
136 | ||
137 | #endif /* _VNODE_PAGER_ */ |