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