1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)ffs_tables.c 7.4 (Berkeley) 06/28/90 8 */ 9 10 #ifdef KERNEL 11 #include "param.h" 12 #else 13 #include <sys/param.h> 14 #endif 15 16 /* 17 * Bit patterns for identifying fragments in the block map 18 * used as ((map & around) == inside) 19 */ 20 int around[9] = { 21 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff 22 }; 23 int inside[9] = { 24 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe 25 }; 26 27 /* 28 * Given a block map bit pattern, the frag tables tell whether a 29 * particular size fragment is available. 30 * 31 * used as: 32 * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] { 33 * at least one fragment of the indicated size is available 34 * } 35 * 36 * These tables are used by the scanc instruction on the VAX to 37 * quickly find an appropriate fragment. 38 */ 39 u_char fragtbl124[256] = { 40 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e, 41 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a, 42 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, 43 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, 44 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, 45 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, 46 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e, 47 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, 48 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, 49 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, 50 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 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ragtbl8[256] = { 75 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04, 76 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08, 77 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, 78 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10, 79 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, 80 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, 81 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, 82 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20, 83 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, 84 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, 85 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, 86 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, 87 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, 88 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, 89 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, 90 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40, 91 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, 92 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, 93 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, 94 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, 95 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, 96 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, 97 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 98 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21, 99 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, 100 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, 101 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 102 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12, 103 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, 104 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c, 105 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c, 106 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80, 107 }; 108 109 /* 110 * The actual fragtbl array. 111 */ 112 u_char *fragtbl[MAXFRAG + 1] = { 113 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8, 114 }; 115