cerr-sb1.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. /*
  2. * Copyright (C) 2001,2002,2003 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <linux/config.h>
  19. #include <linux/sched.h>
  20. #include <asm/mipsregs.h>
  21. #include <asm/sibyte/sb1250.h>
  22. #ifndef CONFIG_SIBYTE_BUS_WATCHER
  23. #include <asm/io.h>
  24. #include <asm/sibyte/sb1250_regs.h>
  25. #include <asm/sibyte/sb1250_scd.h>
  26. #endif
  27. /* SB1 definitions */
  28. /* XXX should come from config1 XXX */
  29. #define SB1_CACHE_INDEX_MASK 0x1fe0
  30. #define CP0_ERRCTL_RECOVERABLE (1 << 31)
  31. #define CP0_ERRCTL_DCACHE (1 << 30)
  32. #define CP0_ERRCTL_ICACHE (1 << 29)
  33. #define CP0_ERRCTL_MULTIBUS (1 << 23)
  34. #define CP0_ERRCTL_MC_TLB (1 << 15)
  35. #define CP0_ERRCTL_MC_TIMEOUT (1 << 14)
  36. #define CP0_CERRI_TAG_PARITY (1 << 29)
  37. #define CP0_CERRI_DATA_PARITY (1 << 28)
  38. #define CP0_CERRI_EXTERNAL (1 << 26)
  39. #define CP0_CERRI_IDX_VALID(c) (!((c) & CP0_CERRI_EXTERNAL))
  40. #define CP0_CERRI_DATA (CP0_CERRI_DATA_PARITY)
  41. #define CP0_CERRD_MULTIPLE (1 << 31)
  42. #define CP0_CERRD_TAG_STATE (1 << 30)
  43. #define CP0_CERRD_TAG_ADDRESS (1 << 29)
  44. #define CP0_CERRD_DATA_SBE (1 << 28)
  45. #define CP0_CERRD_DATA_DBE (1 << 27)
  46. #define CP0_CERRD_EXTERNAL (1 << 26)
  47. #define CP0_CERRD_LOAD (1 << 25)
  48. #define CP0_CERRD_STORE (1 << 24)
  49. #define CP0_CERRD_FILLWB (1 << 23)
  50. #define CP0_CERRD_COHERENCY (1 << 22)
  51. #define CP0_CERRD_DUPTAG (1 << 21)
  52. #define CP0_CERRD_DPA_VALID(c) (!((c) & CP0_CERRD_EXTERNAL))
  53. #define CP0_CERRD_IDX_VALID(c) \
  54. (((c) & (CP0_CERRD_LOAD | CP0_CERRD_STORE)) ? (!((c) & CP0_CERRD_EXTERNAL)) : 0)
  55. #define CP0_CERRD_CAUSES \
  56. (CP0_CERRD_LOAD | CP0_CERRD_STORE | CP0_CERRD_FILLWB | CP0_CERRD_COHERENCY | CP0_CERRD_DUPTAG)
  57. #define CP0_CERRD_TYPES \
  58. (CP0_CERRD_TAG_STATE | CP0_CERRD_TAG_ADDRESS | CP0_CERRD_DATA_SBE | CP0_CERRD_DATA_DBE | CP0_CERRD_EXTERNAL)
  59. #define CP0_CERRD_DATA (CP0_CERRD_DATA_SBE | CP0_CERRD_DATA_DBE)
  60. static uint32_t extract_ic(unsigned short addr, int data);
  61. static uint32_t extract_dc(unsigned short addr, int data);
  62. static inline void breakout_errctl(unsigned int val)
  63. {
  64. if (val & CP0_ERRCTL_RECOVERABLE)
  65. prom_printf(" recoverable");
  66. if (val & CP0_ERRCTL_DCACHE)
  67. prom_printf(" dcache");
  68. if (val & CP0_ERRCTL_ICACHE)
  69. prom_printf(" icache");
  70. if (val & CP0_ERRCTL_MULTIBUS)
  71. prom_printf(" multiple-buserr");
  72. prom_printf("\n");
  73. }
  74. static inline void breakout_cerri(unsigned int val)
  75. {
  76. if (val & CP0_CERRI_TAG_PARITY)
  77. prom_printf(" tag-parity");
  78. if (val & CP0_CERRI_DATA_PARITY)
  79. prom_printf(" data-parity");
  80. if (val & CP0_CERRI_EXTERNAL)
  81. prom_printf(" external");
  82. prom_printf("\n");
  83. }
  84. static inline void breakout_cerrd(unsigned int val)
  85. {
  86. switch (val & CP0_CERRD_CAUSES) {
  87. case CP0_CERRD_LOAD:
  88. prom_printf(" load,");
  89. break;
  90. case CP0_CERRD_STORE:
  91. prom_printf(" store,");
  92. break;
  93. case CP0_CERRD_FILLWB:
  94. prom_printf(" fill/wb,");
  95. break;
  96. case CP0_CERRD_COHERENCY:
  97. prom_printf(" coherency,");
  98. break;
  99. case CP0_CERRD_DUPTAG:
  100. prom_printf(" duptags,");
  101. break;
  102. default:
  103. prom_printf(" NO CAUSE,");
  104. break;
  105. }
  106. if (!(val & CP0_CERRD_TYPES))
  107. prom_printf(" NO TYPE");
  108. else {
  109. if (val & CP0_CERRD_MULTIPLE)
  110. prom_printf(" multi-err");
  111. if (val & CP0_CERRD_TAG_STATE)
  112. prom_printf(" tag-state");
  113. if (val & CP0_CERRD_TAG_ADDRESS)
  114. prom_printf(" tag-address");
  115. if (val & CP0_CERRD_DATA_SBE)
  116. prom_printf(" data-SBE");
  117. if (val & CP0_CERRD_DATA_DBE)
  118. prom_printf(" data-DBE");
  119. if (val & CP0_CERRD_EXTERNAL)
  120. prom_printf(" external");
  121. }
  122. prom_printf("\n");
  123. }
  124. #ifndef CONFIG_SIBYTE_BUS_WATCHER
  125. static void check_bus_watcher(void)
  126. {
  127. uint32_t status, l2_err, memio_err;
  128. /* Destructive read, clears register and interrupt */
  129. status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS));
  130. /* Bit 31 is always on, but there's no #define for that */
  131. if (status & ~(1UL << 31)) {
  132. l2_err = csr_in32(IOADDR(A_BUS_L2_ERRORS));
  133. memio_err = csr_in32(IOADDR(A_BUS_MEM_IO_ERRORS));
  134. prom_printf("Bus watcher error counters: %08x %08x\n", l2_err, memio_err);
  135. prom_printf("\nLast recorded signature:\n");
  136. prom_printf("Request %02x from %d, answered by %d with Dcode %d\n",
  137. (unsigned int)(G_SCD_BERR_TID(status) & 0x3f),
  138. (int)(G_SCD_BERR_TID(status) >> 6),
  139. (int)G_SCD_BERR_RID(status),
  140. (int)G_SCD_BERR_DCODE(status));
  141. } else {
  142. prom_printf("Bus watcher indicates no error\n");
  143. }
  144. }
  145. #else
  146. extern void check_bus_watcher(void);
  147. #endif
  148. asmlinkage void sb1_cache_error(void)
  149. {
  150. uint64_t cerr_dpa;
  151. uint32_t errctl, cerr_i, cerr_d, dpalo, dpahi, eepc, res;
  152. prom_printf("Cache error exception on CPU %x:\n",
  153. (read_c0_prid() >> 25) & 0x7);
  154. __asm__ __volatile__ (
  155. " .set push\n\t"
  156. " .set mips64\n\t"
  157. " .set noat\n\t"
  158. " mfc0 %0, $26\n\t"
  159. " mfc0 %1, $27\n\t"
  160. " mfc0 %2, $27, 1\n\t"
  161. " dmfc0 $1, $27, 3\n\t"
  162. " dsrl32 %3, $1, 0 \n\t"
  163. " sll %4, $1, 0 \n\t"
  164. " mfc0 %5, $30\n\t"
  165. " .set pop"
  166. : "=r" (errctl), "=r" (cerr_i), "=r" (cerr_d),
  167. "=r" (dpahi), "=r" (dpalo), "=r" (eepc));
  168. cerr_dpa = (((uint64_t)dpahi) << 32) | dpalo;
  169. prom_printf(" c0_errorepc == %08x\n", eepc);
  170. prom_printf(" c0_errctl == %08x", errctl);
  171. breakout_errctl(errctl);
  172. if (errctl & CP0_ERRCTL_ICACHE) {
  173. prom_printf(" c0_cerr_i == %08x", cerr_i);
  174. breakout_cerri(cerr_i);
  175. if (CP0_CERRI_IDX_VALID(cerr_i)) {
  176. /* Check index of EPC, allowing for delay slot */
  177. if (((eepc & SB1_CACHE_INDEX_MASK) != (cerr_i & SB1_CACHE_INDEX_MASK)) &&
  178. ((eepc & SB1_CACHE_INDEX_MASK) != ((cerr_i & SB1_CACHE_INDEX_MASK) - 4)))
  179. prom_printf(" cerr_i idx doesn't match eepc\n");
  180. else {
  181. res = extract_ic(cerr_i & SB1_CACHE_INDEX_MASK,
  182. (cerr_i & CP0_CERRI_DATA) != 0);
  183. if (!(res & cerr_i))
  184. prom_printf("...didn't see indicated icache problem\n");
  185. }
  186. }
  187. }
  188. if (errctl & CP0_ERRCTL_DCACHE) {
  189. prom_printf(" c0_cerr_d == %08x", cerr_d);
  190. breakout_cerrd(cerr_d);
  191. if (CP0_CERRD_DPA_VALID(cerr_d)) {
  192. prom_printf(" c0_cerr_dpa == %010llx\n", cerr_dpa);
  193. if (!CP0_CERRD_IDX_VALID(cerr_d)) {
  194. res = extract_dc(cerr_dpa & SB1_CACHE_INDEX_MASK,
  195. (cerr_d & CP0_CERRD_DATA) != 0);
  196. if (!(res & cerr_d))
  197. prom_printf("...didn't see indicated dcache problem\n");
  198. } else {
  199. if ((cerr_dpa & SB1_CACHE_INDEX_MASK) != (cerr_d & SB1_CACHE_INDEX_MASK))
  200. prom_printf(" cerr_d idx doesn't match cerr_dpa\n");
  201. else {
  202. res = extract_dc(cerr_d & SB1_CACHE_INDEX_MASK,
  203. (cerr_d & CP0_CERRD_DATA) != 0);
  204. if (!(res & cerr_d))
  205. prom_printf("...didn't see indicated problem\n");
  206. }
  207. }
  208. }
  209. }
  210. check_bus_watcher();
  211. while (1);
  212. /*
  213. * This tends to make things get really ugly; let's just stall instead.
  214. * panic("Can't handle the cache error!");
  215. */
  216. }
  217. /* Parity lookup table. */
  218. static const uint8_t parity[256] = {
  219. 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
  220. 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
  221. 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
  222. 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
  223. 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
  224. 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
  225. 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
  226. 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0
  227. };
  228. /* Masks to select bits for Hamming parity, mask_72_64[i] for bit[i] */
  229. static const uint64_t mask_72_64[8] = {
  230. 0x0738C808099264FFULL,
  231. 0x38C808099264FF07ULL,
  232. 0xC808099264FF0738ULL,
  233. 0x08099264FF0738C8ULL,
  234. 0x099264FF0738C808ULL,
  235. 0x9264FF0738C80809ULL,
  236. 0x64FF0738C8080992ULL,
  237. 0xFF0738C808099264ULL
  238. };
  239. /* Calculate the parity on a range of bits */
  240. static char range_parity(uint64_t dword, int max, int min)
  241. {
  242. char parity = 0;
  243. int i;
  244. dword >>= min;
  245. for (i=max-min; i>=0; i--) {
  246. if (dword & 0x1)
  247. parity = !parity;
  248. dword >>= 1;
  249. }
  250. return parity;
  251. }
  252. /* Calculate the 4-bit even byte-parity for an instruction */
  253. static unsigned char inst_parity(uint32_t word)
  254. {
  255. int i, j;
  256. char parity = 0;
  257. for (j=0; j<4; j++) {
  258. char byte_parity = 0;
  259. for (i=0; i<8; i++) {
  260. if (word & 0x80000000)
  261. byte_parity = !byte_parity;
  262. word <<= 1;
  263. }
  264. parity <<= 1;
  265. parity |= byte_parity;
  266. }
  267. return parity;
  268. }
  269. static uint32_t extract_ic(unsigned short addr, int data)
  270. {
  271. unsigned short way;
  272. int valid;
  273. uint64_t taglo, va, tlo_tmp;
  274. uint32_t taghi, taglolo, taglohi;
  275. uint8_t lru;
  276. int res = 0;
  277. prom_printf("Icache index 0x%04x ", addr);
  278. for (way = 0; way < 4; way++) {
  279. /* Index-load-tag-I */
  280. __asm__ __volatile__ (
  281. " .set push \n\t"
  282. " .set noreorder \n\t"
  283. " .set mips64 \n\t"
  284. " .set noat \n\t"
  285. " cache 4, 0(%3) \n\t"
  286. " mfc0 %0, $29 \n\t"
  287. " dmfc0 $1, $28 \n\t"
  288. " dsrl32 %1, $1, 0 \n\t"
  289. " sll %2, $1, 0 \n\t"
  290. " .set pop"
  291. : "=r" (taghi), "=r" (taglohi), "=r" (taglolo)
  292. : "r" ((way << 13) | addr));
  293. taglo = ((unsigned long long)taglohi << 32) | taglolo;
  294. if (way == 0) {
  295. lru = (taghi >> 14) & 0xff;
  296. prom_printf("[Bank %d Set 0x%02x] LRU > %d %d %d %d > MRU\n",
  297. ((addr >> 5) & 0x3), /* bank */
  298. ((addr >> 7) & 0x3f), /* index */
  299. (lru & 0x3),
  300. ((lru >> 2) & 0x3),
  301. ((lru >> 4) & 0x3),
  302. ((lru >> 6) & 0x3));
  303. }
  304. va = (taglo & 0xC0000FFFFFFFE000ULL) | addr;
  305. if ((taglo & (1 << 31)) && (((taglo >> 62) & 0x3) == 3))
  306. va |= 0x3FFFF00000000000ULL;
  307. valid = ((taghi >> 29) & 1);
  308. if (valid) {
  309. tlo_tmp = taglo & 0xfff3ff;
  310. if (((taglo >> 10) & 1) ^ range_parity(tlo_tmp, 23, 0)) {
  311. prom_printf(" ** bad parity in VTag0/G/ASID\n");
  312. res |= CP0_CERRI_TAG_PARITY;
  313. }
  314. if (((taglo >> 11) & 1) ^ range_parity(taglo, 63, 24)) {
  315. prom_printf(" ** bad parity in R/VTag1\n");
  316. res |= CP0_CERRI_TAG_PARITY;
  317. }
  318. }
  319. if (valid ^ ((taghi >> 27) & 1)) {
  320. prom_printf(" ** bad parity for valid bit\n");
  321. res |= CP0_CERRI_TAG_PARITY;
  322. }
  323. prom_printf(" %d [VA %016llx] [Vld? %d] raw tags: %08X-%016llX\n",
  324. way, va, valid, taghi, taglo);
  325. if (data) {
  326. uint32_t datahi, insta, instb;
  327. uint8_t predecode;
  328. int offset;
  329. /* (hit all banks and ways) */
  330. for (offset = 0; offset < 4; offset++) {
  331. /* Index-load-data-I */
  332. __asm__ __volatile__ (
  333. " .set push\n\t"
  334. " .set noreorder\n\t"
  335. " .set mips64\n\t"
  336. " .set noat\n\t"
  337. " cache 6, 0(%3) \n\t"
  338. " mfc0 %0, $29, 1\n\t"
  339. " dmfc0 $1, $28, 1\n\t"
  340. " dsrl32 %1, $1, 0 \n\t"
  341. " sll %2, $1, 0 \n\t"
  342. " .set pop \n"
  343. : "=r" (datahi), "=r" (insta), "=r" (instb)
  344. : "r" ((way << 13) | addr | (offset << 3)));
  345. predecode = (datahi >> 8) & 0xff;
  346. if (((datahi >> 16) & 1) != (uint32_t)range_parity(predecode, 7, 0)) {
  347. prom_printf(" ** bad parity in predecode\n");
  348. res |= CP0_CERRI_DATA_PARITY;
  349. }
  350. /* XXXKW should/could check predecode bits themselves */
  351. if (((datahi >> 4) & 0xf) ^ inst_parity(insta)) {
  352. prom_printf(" ** bad parity in instruction a\n");
  353. res |= CP0_CERRI_DATA_PARITY;
  354. }
  355. if ((datahi & 0xf) ^ inst_parity(instb)) {
  356. prom_printf(" ** bad parity in instruction b\n");
  357. res |= CP0_CERRI_DATA_PARITY;
  358. }
  359. prom_printf(" %05X-%08X%08X", datahi, insta, instb);
  360. }
  361. prom_printf("\n");
  362. }
  363. }
  364. return res;
  365. }
  366. /* Compute the ECC for a data doubleword */
  367. static uint8_t dc_ecc(uint64_t dword)
  368. {
  369. uint64_t t;
  370. uint32_t w;
  371. uint8_t p;
  372. int i;
  373. p = 0;
  374. for (i = 7; i >= 0; i--)
  375. {
  376. p <<= 1;
  377. t = dword & mask_72_64[i];
  378. w = (uint32_t)(t >> 32);
  379. p ^= (parity[w>>24] ^ parity[(w>>16) & 0xFF]
  380. ^ parity[(w>>8) & 0xFF] ^ parity[w & 0xFF]);
  381. w = (uint32_t)(t & 0xFFFFFFFF);
  382. p ^= (parity[w>>24] ^ parity[(w>>16) & 0xFF]
  383. ^ parity[(w>>8) & 0xFF] ^ parity[w & 0xFF]);
  384. }
  385. return p;
  386. }
  387. struct dc_state {
  388. unsigned char val;
  389. char *name;
  390. };
  391. static struct dc_state dc_states[] = {
  392. { 0x00, "INVALID" },
  393. { 0x0f, "COH-SHD" },
  394. { 0x13, "NCO-E-C" },
  395. { 0x19, "NCO-E-D" },
  396. { 0x16, "COH-E-C" },
  397. { 0x1c, "COH-E-D" },
  398. { 0xff, "*ERROR*" }
  399. };
  400. #define DC_TAG_VALID(state) \
  401. (((state) == 0xf) || ((state) == 0x13) || ((state) == 0x19) || ((state == 0x16)) || ((state) == 0x1c))
  402. static char *dc_state_str(unsigned char state)
  403. {
  404. struct dc_state *dsc = dc_states;
  405. while (dsc->val != 0xff) {
  406. if (dsc->val == state)
  407. break;
  408. dsc++;
  409. }
  410. return dsc->name;
  411. }
  412. static uint32_t extract_dc(unsigned short addr, int data)
  413. {
  414. int valid, way;
  415. unsigned char state;
  416. uint64_t taglo, pa;
  417. uint32_t taghi, taglolo, taglohi;
  418. uint8_t ecc, lru;
  419. int res = 0;
  420. prom_printf("Dcache index 0x%04x ", addr);
  421. for (way = 0; way < 4; way++) {
  422. __asm__ __volatile__ (
  423. " .set push\n\t"
  424. " .set noreorder\n\t"
  425. " .set mips64\n\t"
  426. " .set noat\n\t"
  427. " cache 5, 0(%3)\n\t" /* Index-load-tag-D */
  428. " mfc0 %0, $29, 2\n\t"
  429. " dmfc0 $1, $28, 2\n\t"
  430. " dsrl32 %1, $1, 0\n\t"
  431. " sll %2, $1, 0\n\t"
  432. " .set pop"
  433. : "=r" (taghi), "=r" (taglohi), "=r" (taglolo)
  434. : "r" ((way << 13) | addr));
  435. taglo = ((unsigned long long)taglohi << 32) | taglolo;
  436. pa = (taglo & 0xFFFFFFE000ULL) | addr;
  437. if (way == 0) {
  438. lru = (taghi >> 14) & 0xff;
  439. prom_printf("[Bank %d Set 0x%02x] LRU > %d %d %d %d > MRU\n",
  440. ((addr >> 11) & 0x2) | ((addr >> 5) & 1), /* bank */
  441. ((addr >> 6) & 0x3f), /* index */
  442. (lru & 0x3),
  443. ((lru >> 2) & 0x3),
  444. ((lru >> 4) & 0x3),
  445. ((lru >> 6) & 0x3));
  446. }
  447. state = (taghi >> 25) & 0x1f;
  448. valid = DC_TAG_VALID(state);
  449. prom_printf(" %d [PA %010llx] [state %s (%02x)] raw tags: %08X-%016llX\n",
  450. way, pa, dc_state_str(state), state, taghi, taglo);
  451. if (valid) {
  452. if (((taglo >> 11) & 1) ^ range_parity(taglo, 39, 26)) {
  453. prom_printf(" ** bad parity in PTag1\n");
  454. res |= CP0_CERRD_TAG_ADDRESS;
  455. }
  456. if (((taglo >> 10) & 1) ^ range_parity(taglo, 25, 13)) {
  457. prom_printf(" ** bad parity in PTag0\n");
  458. res |= CP0_CERRD_TAG_ADDRESS;
  459. }
  460. } else {
  461. res |= CP0_CERRD_TAG_STATE;
  462. }
  463. if (data) {
  464. uint64_t datalo;
  465. uint32_t datalohi, datalolo, datahi;
  466. int offset;
  467. for (offset = 0; offset < 4; offset++) {
  468. /* Index-load-data-D */
  469. __asm__ __volatile__ (
  470. " .set push\n\t"
  471. " .set noreorder\n\t"
  472. " .set mips64\n\t"
  473. " .set noat\n\t"
  474. " cache 7, 0(%3)\n\t" /* Index-load-data-D */
  475. " mfc0 %0, $29, 3\n\t"
  476. " dmfc0 $1, $28, 3\n\t"
  477. " dsrl32 %1, $1, 0 \n\t"
  478. " sll %2, $1, 0 \n\t"
  479. " .set pop"
  480. : "=r" (datahi), "=r" (datalohi), "=r" (datalolo)
  481. : "r" ((way << 13) | addr | (offset << 3)));
  482. datalo = ((unsigned long long)datalohi << 32) | datalolo;
  483. ecc = dc_ecc(datalo);
  484. if (ecc != datahi) {
  485. int bits = 0;
  486. prom_printf(" ** bad ECC (%02x %02x) ->",
  487. datahi, ecc);
  488. ecc ^= datahi;
  489. while (ecc) {
  490. if (ecc & 1) bits++;
  491. ecc >>= 1;
  492. }
  493. res |= (bits == 1) ? CP0_CERRD_DATA_SBE : CP0_CERRD_DATA_DBE;
  494. }
  495. prom_printf(" %02X-%016llX", datahi, datalo);
  496. }
  497. prom_printf("\n");
  498. }
  499. }
  500. return res;
  501. }