add ifdefs for dev_bsize (almost working)
[unix-history] / usr / src / sys / ufs / ffs / ffs_tables.c
CommitLineData
da7c5cc6 1/*
0880b18e 2 * Copyright (c) 1982, 1986 Regents of the University of California.
da7c5cc6
KM
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
0880b18e 6 * @(#)ffs_tables.c 7.1 (Berkeley) %G%
da7c5cc6 7 */
5576d804 8
94368568 9#include "param.h"
5576d804 10
5576d804 11/*
88a7a62a 12 * Bit patterns for identifying fragments in the block map
5576d804
KM
13 * used as ((map & around) == inside)
14 */
15int around[9] = {
16 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
17};
18int inside[9] = {
19 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
20};
21
22/*
88a7a62a 23 * Given a block map bit pattern, the frag tables tell whether a
5576d804 24 * particular size fragment is available.
b6407c9d 25 *
5576d804 26 * used as:
b6407c9d 27 * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
5576d804
KM
28 * at least one fragment of the indicated size is available
29 * }
b6407c9d
KM
30 *
31 * These tables are used by the scanc instruction on the VAX to
5576d804
KM
32 * quickly find an appropriate fragment.
33 */
88a7a62a 34u_char fragtbl124[256] = {
156b8f82
KM
35 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
36 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
37 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
38 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
39 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
40 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
41 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
42 0x3e, 0x3e, 0x3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e,
64 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
65 0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce,
66 0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
5576d804 67};
5576d804 68
88a7a62a 69u_char fragtbl8[256] = {
5576d804
KM
70 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
71 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
72 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
73 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
74 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
75 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
76 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
77 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
78 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
79 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
80 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
81 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
82 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
83 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
84 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
85 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
86 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
87 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
88 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
89 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
90 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
91 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
92 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
93 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
94 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
95 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
96 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
97 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
98 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
99 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
100 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
101 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
102};
b6407c9d
KM
103
104/*
88a7a62a 105 * The actual fragtbl array.
b6407c9d 106 */
88a7a62a 107u_char *fragtbl[MAXFRAG + 1] = {
156b8f82 108 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
b6407c9d 109};