xref: /original-bsd/sys/ufs/ffs/ffs_tables.c (revision fbed46ce)
1 /*	ffs_tables.c	2.2	82/04/19	*/
2 
3 #include "../h/param.h"
4 
5 /*	partab.c	4.2	81/03/08	*/
6 
7 /*
8  * Table giving parity for characters and indicating
9  * character classes to tty driver.  In particular,
10  * if the low 6 bits are 0, then the character needs
11  * no special processing on output.
12  */
13 
14 unsigned char partab[] = {
15 	0001,0201,0201,0001,0201,0001,0001,0201,
16 	0202,0004,0003,0201,0005,0206,0201,0001,
17 	0201,0001,0001,0201,0001,0201,0201,0001,
18 	0001,0201,0201,0001,0201,0001,0001,0201,
19 	0200,0000,0000,0200,0000,0200,0200,0000,
20 	0000,0200,0200,0000,0200,0000,0000,0200,
21 	0000,0200,0200,0000,0200,0000,0000,0200,
22 	0200,0000,0000,0200,0000,0200,0200,0000,
23 	0200,0000,0000,0200,0000,0200,0200,0000,
24 	0000,0200,0200,0000,0200,0000,0000,0200,
25 	0000,0200,0200,0000,0200,0000,0000,0200,
26 	0200,0000,0000,0200,0000,0200,0200,0000,
27 	0000,0200,0200,0000,0200,0000,0000,0200,
28 	0200,0000,0000,0200,0000,0200,0200,0000,
29 	0200,0000,0000,0200,0000,0200,0200,0000,
30 	0000,0200,0200,0000,0200,0000,0000,0201,
31 
32 	/*
33 	 * 7 bit ascii ends with the last character above,
34 	 * but we contine through all 256 codes for the sake
35 	 * of the tty output routines which use special vax
36 	 * instructions which need a 256 character trt table.
37 	 */
38 
39 	0007,0007,0007,0007,0007,0007,0007,0007,
40 	0007,0007,0007,0007,0007,0007,0007,0007,
41 	0007,0007,0007,0007,0007,0007,0007,0007,
42 	0007,0007,0007,0007,0007,0007,0007,0007,
43 	0007,0007,0007,0007,0007,0007,0007,0007,
44 	0007,0007,0007,0007,0007,0007,0007,0007,
45 	0007,0007,0007,0007,0007,0007,0007,0007,
46 	0007,0007,0007,0007,0007,0007,0007,0007,
47 	0007,0007,0007,0007,0007,0007,0007,0007,
48 	0007,0007,0007,0007,0007,0007,0007,0007,
49 	0007,0007,0007,0007,0007,0007,0007,0007,
50 	0007,0007,0007,0007,0007,0007,0007,0007,
51 	0007,0007,0007,0007,0007,0007,0007,0007,
52 	0007,0007,0007,0007,0007,0007,0007,0007,
53 	0007,0007,0007,0007,0007,0007,0007,0007,
54 	0007,0007,0007,0007,0007,0007,0007,0007
55 };
56 
57 /*
58  * bit patterns for identifying fragments in the block map
59  * used as ((map & around) == inside)
60  */
61 int around[9] = {
62 	0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
63 };
64 int inside[9] = {
65 	0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
66 };
67 
68 /*
69  * given a block map bit pattern, the frag tables tell whether a
70  * particular size fragment is available.
71  *
72  * used as:
73  * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
74  *	at least one fragment of the indicated size is available
75  * }
76  *
77  * These tables are used by the scanc instruction on the VAX to
78  * quickly find an appropriate fragment.
79  */
80 
81 unsigned char fragtbl124[256] = {
82 	0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
83 	0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
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 	0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
89 	0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa,
90 	0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
91 	0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
92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x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
114 };
115 
116 unsigned char fragtbl8[256] = {
117 	0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
118 	0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
119 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
120 	0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
121 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
122 	0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
123 	0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
124 	0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
125 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
126 	0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
127 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
128 	0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
129 	0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
130 	0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
131 	0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
132 	0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
133 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
134 	0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
135 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
136 	0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
137 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
138 	0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
139 	0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
140 	0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
141 	0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
142 	0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
143 	0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
144 	0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
145 	0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
146 	0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
147 	0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
148 	0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
149 };
150 
151 /*
152  * the actual fragtbl array
153  */
154 unsigned char *fragtbl[MAXFRAG + 1] = {
155 	0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
156 };
157