Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /* |
2 | * Copyright (c) 1982, 1986 Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | * | |
1eb58e01 | 33 | * from: @(#)ufs_tables.c 7.4 (Berkeley) 6/28/90 |
fde1aeb2 | 34 | * $Id: ufs_tables.c,v 1.2 1993/10/16 18:18:00 rgrimes Exp $ |
15637ed4 RG |
35 | */ |
36 | ||
37 | #ifdef KERNEL | |
38 | #include "param.h" | |
fde1aeb2 | 39 | #include "systm.h" |
15637ed4 RG |
40 | #else |
41 | #include <sys/param.h> | |
42 | #endif | |
43 | ||
44 | /* | |
45 | * Bit patterns for identifying fragments in the block map | |
46 | * used as ((map & around) == inside) | |
47 | */ | |
48 | int around[9] = { | |
49 | 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff | |
50 | }; | |
51 | int inside[9] = { | |
52 | 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe | |
53 | }; | |
54 | ||
55 | /* | |
56 | * Given a block map bit pattern, the frag tables tell whether a | |
57 | * particular size fragment is available. | |
58 | * | |
59 | * used as: | |
60 | * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] { | |
61 | * at least one fragment of the indicated size is available | |
62 | * } | |
63 | * | |
64 | * These tables are used by the scanc instruction on the VAX to | |
65 | * quickly find an appropriate fragment. | |
66 | */ | |
67 | u_char fragtbl124[256] = { | |
68 | 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e, | |
69 | 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a, | |
70 | 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, | |
71 | 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, | |
72 | 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, | |
73 | 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, | |
74 | 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e, | |
75 | 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, | |
76 | 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, | |
77 | 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, | |
78 | 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, | |
79 | 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, | |
80 | 0x26, 0x36, 0x36, 0x2e, 0x36, 0x36, 0x26, 0x6e, | |
81 | 0x36, 0x36, 0x36, 0x3e, 0x2e, 0x3e, 0x6e, 0xae, | |
82 | 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e, | |
83 | 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce, | |
84 | 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, | |
85 | 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, | |
86 | 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, | |
87 | 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, | |
88 | 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, | |
89 | 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, | |
90 | 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, | |
91 | 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe, | |
92 | 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e, | |
93 | 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, | |
94 | 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, | |
95 | 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe, | |
96 | 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e, | |
97 | 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce, | |
98 | 0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce, | |
99 | 0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a, | |
100 | }; | |
101 | ||
102 | u_char fragtbl8[256] = { | |
103 | 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04, | |
104 | 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08, | |
105 | 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, | |
106 | 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10, | |
107 | 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, | |
108 | 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, | |
109 | 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, | |
110 | 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20, | |
111 | 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, | |
112 | 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, | |
113 | 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, | |
114 | 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, | |
115 | 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, | |
116 | 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, | |
117 | 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, | |
118 | 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40, | |
119 | 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, | |
120 | 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, | |
121 | 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, | |
122 | 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, | |
123 | 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, | |
124 | 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, | |
125 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, | |
126 | 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21, | |
127 | 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, | |
128 | 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, | |
129 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, | |
130 | 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12, | |
131 | 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, | |
132 | 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c, | |
133 | 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c, | |
134 | 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80, | |
135 | }; | |
136 | ||
137 | /* | |
138 | * The actual fragtbl array. | |
139 | */ | |
140 | u_char *fragtbl[MAXFRAG + 1] = { | |
141 | 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8, | |
142 | }; |