Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: BL_Hsiao_30_7_Synd.cc | |
4 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
6 | // | |
7 | // The above named program is free software; you can redistribute it and/or | |
8 | // modify it under the terms of the GNU General Public | |
9 | // License version 2 as published by the Free Software Foundation. | |
10 | // | |
11 | // The above named program is distributed in the hope that it will be | |
12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | // General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public | |
17 | // License along with this work; if not, write to the Free Software | |
18 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | // | |
20 | // ========== Copyright Header End ============================================ | |
21 | /************************************************************************ | |
22 | ** | |
23 | ** Copyright (C) 2006, Sun Microsystems, Inc. | |
24 | ** | |
25 | ** Sun considers its source code as an unpublished, proprietary | |
26 | ** trade secret and it is available only under strict license provisions. | |
27 | ** This copyright notice is placed here only to protect Sun in the event | |
28 | ** the source is deemed a published work. Disassembly, decompilation, | |
29 | ** or other means of reducing the object code to human readable form | |
30 | ** is prohibited by the license agreement under which this code is | |
31 | ** provided to the user or company in possession of this copy. | |
32 | ** | |
33 | *************************************************************************/ | |
34 | ||
35 | #include <stdlib.h> | |
36 | #include "BL_Types.h" | |
37 | #include "BL_Hsiao_30_7_Synd.h" | |
38 | ||
39 | ||
40 | BL_EccBits BL_Hsiao_30_7_Synd::Patterns::syndromes[30]; | |
41 | ||
42 | BL_Hsiao_30_7_Synd::Patterns BL_Hsiao_30_7_Synd::hsiao_30_7_patterns; | |
43 | ||
44 | BL_Hsiao_30_7_Synd::Patterns::Patterns() | |
45 | { | |
46 | // These syndromes are defined in PRM 1.3 Section 16.14.2 | |
47 | // Note they are written in base 2 so we use strtoul() to convert them. | |
48 | syndromes[0] = strtoul("1110000", NULL, 2); | |
49 | syndromes[1] = strtoul("0001110", NULL, 2); | |
50 | syndromes[2] = strtoul("1100001", NULL, 2); | |
51 | syndromes[3] = strtoul("0011010", NULL, 2); | |
52 | syndromes[4] = strtoul("1000101", NULL, 2); | |
53 | syndromes[5] = strtoul("0110010", NULL, 2); | |
54 | syndromes[6] = strtoul("0001101", NULL, 2); | |
55 | syndromes[7] = strtoul("1101000", NULL, 2); | |
56 | syndromes[8] = strtoul("0000111", NULL, 2); | |
57 | syndromes[9] = strtoul("1010010", NULL, 2); | |
58 | syndromes[10] = strtoul("0101001", NULL, 2); | |
59 | syndromes[11] = strtoul("1010100", NULL, 2); | |
60 | syndromes[12] = strtoul("0101010", NULL, 2); | |
61 | syndromes[13] = strtoul("0010101", NULL, 2); | |
62 | syndromes[14] = strtoul("1100010", NULL, 2); | |
63 | syndromes[15] = strtoul("0011001", NULL, 2); | |
64 | syndromes[16] = strtoul("1000110", NULL, 2); | |
65 | syndromes[17] = strtoul("0100101", NULL, 2); | |
66 | syndromes[18] = strtoul("0111000", NULL, 2); | |
67 | syndromes[19] = strtoul("1001010", NULL, 2); | |
68 | syndromes[20] = strtoul("0010110", NULL, 2); | |
69 | syndromes[21] = strtoul("1010001", NULL, 2); | |
70 | syndromes[22] = strtoul("0101100", NULL, 2); | |
71 | syndromes[23] = strtoul("1001001", NULL, 2); | |
72 | syndromes[24] = strtoul("0010011", NULL, 2); | |
73 | syndromes[25] = strtoul("0100110", NULL, 2); | |
74 | syndromes[26] = strtoul("1011000", NULL, 2); | |
75 | syndromes[27] = strtoul("0110001", NULL, 2); | |
76 | syndromes[28] = strtoul("1100100", NULL, 2); | |
77 | syndromes[29] = strtoul("0001011", NULL, 2); | |
78 | ||
79 | // Convert the syndromes for each single bit error into the H matrix. | |
80 | // Each pattern (there are 10) is multiplied by the data (a | |
81 | // BL_Uint256) to generate one bit of ECC. | |
82 | for (uint_t pattern_ndx = 0; pattern_ndx < 7; ++pattern_ndx) | |
83 | patterns[6 - pattern_ndx] = calc_pattern(pattern_ndx); | |
84 | ||
85 | // self check | |
86 | // For Hsiao ECC, the check bits and the syndrome are calculated | |
87 | // using the same algorithm. | |
88 | // Check that inverting one data bit and calculating the resulting | |
89 | // ECC matching the bit's syndrome. | |
90 | for (uint_t syndrome_ndx = 0; syndrome_ndx < 30; ++syndrome_ndx) | |
91 | { | |
92 | uint32_t data = 1 << syndrome_ndx; | |
93 | ||
94 | if (calc_checks(7, patterns, data).get() != syndromes[syndrome_ndx].get()) | |
95 | { | |
96 | fprintf(stderr, | |
97 | "syndrome mismatch: ndx %d calc_check 0x%x syndrome 0x%x\n", | |
98 | syndrome_ndx, | |
99 | calc_checks(7, patterns, data).get(), | |
100 | syndromes[syndrome_ndx].get()); | |
101 | exit(-1); | |
102 | } | |
103 | } | |
104 | } | |
105 | ||
106 | uint64_t BL_Hsiao_30_7_Synd::Patterns::calc_pattern(uint_t pattern_ndx) | |
107 | { | |
108 | uint64_t pattern = 0; | |
109 | ||
110 | for (uint_t ndx = 0; ndx < 30; ++ndx) | |
111 | { | |
112 | if (syndromes[ndx].get() == 0) | |
113 | { | |
114 | fprintf(stderr, "bad zero syndrome: %d\n", ndx); | |
115 | exit(-1); | |
116 | } | |
117 | ||
118 | pattern |= ((syndromes[ndx].get() >> pattern_ndx) & 0x1ULL) | |
119 | << ndx; | |
120 | } | |
121 | ||
122 | return pattern; | |
123 | } |