Commit | Line | Data |
---|---|---|
619edcce KM |
1 | /* |
2 | * Copyright (c) 1990 University of Utah. | |
ad787160 C |
3 | * Copyright (c) 1991, 1993 |
4 | * The Regents of the University of California. All rights reserved. | |
619edcce KM |
5 | * |
6 | * This code is derived from software contributed to Berkeley by | |
7 | * the Systems Programming Group of the University of Utah Computer | |
8 | * Science Department. | |
9 | * | |
ad787160 C |
10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | |
18 | * 3. All advertising materials mentioning features or use of this software | |
19 | * must display the following acknowledgement: | |
20 | * This product includes software developed by the University of | |
21 | * California, Berkeley and its contributors. | |
22 | * 4. Neither the name of the University nor the names of its contributors | |
23 | * may be used to endorse or promote products derived from this software | |
24 | * without specific prior written permission. | |
619edcce | 25 | * |
ad787160 C |
26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
36 | * SUCH DAMAGE. | |
37 | * | |
38 | * @(#)swap_pager.h 8.1 (Berkeley) 6/11/93 | |
619edcce KM |
39 | */ |
40 | ||
41 | #ifndef _SWAP_PAGER_ | |
42 | #define _SWAP_PAGER_ 1 | |
43 | ||
44 | /* | |
45 | * In the swap pager, the backing store for an object is organized as an | |
46 | * array of some number of "swap blocks". A swap block consists of a bitmask | |
47 | * and some number of contiguous DEV_BSIZE disk blocks. The minimum size | |
48 | * of a swap block is: | |
49 | * | |
50 | * max(PAGE_SIZE, dmmin*DEV_BSIZE) [ 32k currently ] | |
51 | * | |
52 | * bytes (since the pager interface is page oriented), the maximum size is: | |
53 | * | |
54 | * min(#bits(swb_mask)*PAGE_SIZE, dmmax*DEV_BSIZE) [ 128k currently ] | |
55 | * | |
56 | * where dmmin and dmmax are left over from the old VM interface. The bitmask | |
57 | * (swb_mask) is used by swap_pager_haspage() to determine if a particular | |
58 | * page has actually been written; i.e. the pager copy of the page is valid. | |
59 | * All swap blocks in the backing store of an object will be the same size. | |
60 | * | |
61 | * The reason for variable sized swap blocks is to reduce fragmentation of | |
62 | * swap resources. Whenever possible we allocate smaller swap blocks to | |
63 | * smaller objects. The swap block size is determined from a table of | |
64 | * object-size vs. swap-block-size computed at boot time. | |
65 | */ | |
66 | typedef int sw_bm_t; /* pager bitmask */ | |
67 | ||
68 | struct swblock { | |
69 | sw_bm_t swb_mask; /* bitmask of valid pages in this block */ | |
70 | daddr_t swb_block; /* starting disk block for this block */ | |
71 | }; | |
72 | typedef struct swblock *sw_blk_t; | |
73 | ||
74 | /* | |
75 | * Swap pager private data. | |
76 | */ | |
77 | struct swpager { | |
78 | vm_size_t sw_osize; /* size of object we are backing (bytes) */ | |
79 | int sw_bsize; /* size of swap blocks (DEV_BSIZE units) */ | |
80 | int sw_nblocks;/* number of blocks in list (sw_blk_t units) */ | |
81 | sw_blk_t sw_blocks; /* pointer to list of swap blocks */ | |
82 | short sw_flags; /* flags */ | |
83 | short sw_poip; /* pageouts in progress */ | |
84 | }; | |
85 | typedef struct swpager *sw_pager_t; | |
86 | ||
87 | #define SW_WANTED 0x01 | |
88 | #define SW_NAMED 0x02 | |
89 | ||
619edcce | 90 | #endif /* _SWAP_PAGER_ */ |