Blame view
post/lib_powerpc/b.c
3.21 KB
ad5bb451a Restructure POST ... |
1 2 3 4 |
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * |
1a4596601 Add GPL-2.0+ SPDX... |
5 |
* SPDX-License-Identifier: GPL-2.0+ |
ad5bb451a Restructure POST ... |
6 7 8 9 10 11 12 13 14 |
*/ #include <common.h> /* * CPU test * Branch instructions: b, bl, bc * * The first 2 instructions (b, bl) are verified by jumping |
a6f70a3d1 Fix spelling of "... |
15 |
* to a fixed address and checking whether control was transferred |
ad5bb451a Restructure POST ... |
16 17 18 19 20 21 22 |
* to that very point. For the bl instruction the value of the * link register is checked as well (using mfspr). * To verify the bc instruction various combinations of the BI/BO * fields, the CTR and the condition register values are * checked. The list of such combinations is pre-built and * linked in U-Boot at build time. */ |
ad5bb451a Restructure POST ... |
23 24 |
#include <post.h> #include "cpu_asm.h" |
6d0f6bcf3 rename CFG_ macro... |
25 |
#if CONFIG_POST & CONFIG_SYS_POST_CPU |
ad5bb451a Restructure POST ... |
26 27 28 29 30 31 |
extern void cpu_post_exec_11 (ulong *code, ulong *res, ulong op1); extern void cpu_post_exec_31 (ulong *code, ulong *ctr, ulong *lr, ulong *jump, ulong cr); static int cpu_post_test_bc (ulong cmd, ulong bo, ulong bi, |
a11e06965 Extend POST suppo... |
32 |
int pjump, int decr, int link, ulong pctr, ulong cr) |
ad5bb451a Restructure POST ... |
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
{ int ret = 0; ulong lr = 0; ulong ctr = pctr; ulong jump; unsigned long code[] = { ASM_MTCR(6), ASM_MFLR(6), ASM_MTCTR(3), ASM_MTLR(4), ASM_LI(5, 1), ASM_3O(cmd, bo, bi, 8), ASM_LI(5, 0), ASM_MFCTR(3), ASM_MFLR(4), ASM_MTLR(6), ASM_BLR, }; cpu_post_exec_31 (code, &ctr, &lr, &jump, cr); if (ret == 0) ret = pjump == jump ? 0 : -1; if (ret == 0) { |
a11e06965 Extend POST suppo... |
60 |
if (decr) |
ad5bb451a Restructure POST ... |
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
ret = pctr == ctr + 1 ? 0 : -1; else ret = pctr == ctr ? 0 : -1; } if (ret == 0) { if (link) ret = lr == (ulong) code + 24 ? 0 : -1; else ret = lr == 0 ? 0 : -1; } return ret; } int cpu_post_test_b (void) { int ret = 0; unsigned int i; |
f2302d443 Fix merge problems |
80 |
int flag = disable_interrupts(); |
ad5bb451a Restructure POST ... |
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
if (ret == 0) { ulong code[] = { ASM_MFLR(4), ASM_MTLR(3), ASM_B(4), ASM_MFLR(3), ASM_MTLR(4), ASM_BLR, }; ulong res; cpu_post_exec_11 (code, &res, 0); ret = res == 0 ? 0 : -1; if (ret != 0) { post_log ("Error at b1 test ! "); } } if (ret == 0) { ulong code[] = { ASM_MFLR(4), ASM_MTLR(3), ASM_BL(4), ASM_MFLR(3), ASM_MTLR(4), ASM_BLR, }; ulong res; cpu_post_exec_11 (code, &res, 0); ret = res == (ulong)code + 12 ? 0 : -1; if (ret != 0) { post_log ("Error at b2 test ! "); } } if (ret == 0) { ulong cc, cd; int cond; ulong ctr; int link; i = 0; for (cc = 0; cc < 4 && ret == 0; cc++) { for (cd = 0; cd < 4 && ret == 0; cd++) { for (link = 0; link <= 1 && ret == 0; link++) { for (cond = 0; cond <= 1 && ret == 0; cond++) { for (ctr = 1; ctr <= 2 && ret == 0; ctr++) { |
a11e06965 Extend POST suppo... |
149 |
int decr = cd < 2; |
ad5bb451a Restructure POST ... |
150 151 152 153 154 155 156 157 158 159 |
int cr = cond ? 0x80000000 : 0x00000000; int jumpc = cc >= 2 || (cc == 0 && !cond) || (cc == 1 && cond); int jumpd = cd >= 2 || (cd == 0 && ctr != 1) || (cd == 1 && ctr == 1); int jump = jumpc && jumpd; ret = cpu_post_test_bc (link ? OP_BCL : OP_BC, |
a11e06965 Extend POST suppo... |
160 |
(cc << 3) + (cd << 1), 0, jump, decr, link, |
ad5bb451a Restructure POST ... |
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
ctr, cr); if (ret != 0) { post_log ("Error at b3 test %d ! ", i); } i++; } } } } } } |
f2302d443 Fix merge problems |
176 177 |
if (flag) enable_interrupts(); |
ad5bb451a Restructure POST ... |
178 179 180 181 |
return ret; } #endif |