xref: /original-bsd/sys/ufs/ffs/ffs_tables.c (revision f0fd5f8a)
1 /*	ffs_tables.c	2.3	82/07/15	*/
2 
3 #include "../h/param.h"
4 
5 /*
6  * bit patterns for identifying fragments in the block map
7  * used as ((map & around) == inside)
8  */
9 int around[9] = {
10 	0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
11 };
12 int inside[9] = {
13 	0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
14 };
15 
16 /*
17  * given a block map bit pattern, the frag tables tell whether a
18  * particular size fragment is available.
19  *
20  * used as:
21  * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
22  *	at least one fragment of the indicated size is available
23  * }
24  *
25  * These tables are used by the scanc instruction on the VAX to
26  * quickly find an appropriate fragment.
27  */
28 
29 unsigned char fragtbl124[256] = {
30 	0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
31 	0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
32 	0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
33 	0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
34 	0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
35 	0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
36 	0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
37 	0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa,
38 	0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
39 	0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
40 	0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
41 	0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
42 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 0x01, 0x01, 0x02, 0x04,
66 	0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
67 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
68 	0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
69 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
70 	0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
71 	0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
72 	0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
73 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
74 	0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
75 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
76 	0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
77 	0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
78 	0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
79 	0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
80 	0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
81 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
82 	0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
83 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
84 	0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
85 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
86 	0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
87 	0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
88 	0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
89 	0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
90 	0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
91 	0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
92 	0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
93 	0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
94 	0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
95 	0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
96 	0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
97 };
98 
99 /*
100  * the actual fragtbl array
101  */
102 unsigned char *fragtbl[MAXFRAG + 1] = {
103 	0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
104 };
105