]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - post/lib_powerpc/threex.c
1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
11 * Ternary instructions instr rA,rS,rB
13 * Logic instructions: or, orc, xor, nand, nor, eqv
14 * Shift instructions: slw, srw, sraw
16 * The test contains a pre-built table of instructions, operands and
17 * expected results. For each table entry, the test will cyclically use
18 * different sets of operand registers and result registers.
24 #if CONFIG_POST & CONFIG_SYS_POST_CPU
26 extern void cpu_post_exec_22 (ulong
*code
, ulong
*cr
, ulong
*res
, ulong op1
,
28 extern ulong
cpu_post_makecr (long v
);
30 static struct cpu_post_threex_s
36 } cpu_post_threex_table
[] =
111 static unsigned int cpu_post_threex_size
= ARRAY_SIZE(cpu_post_threex_table
);
113 int cpu_post_test_threex (void)
117 int flag
= disable_interrupts();
119 for (i
= 0; i
< cpu_post_threex_size
&& ret
== 0; i
++)
121 struct cpu_post_threex_s
*test
= cpu_post_threex_table
+ i
;
123 for (reg
= 0; reg
< 32 && ret
== 0; reg
++)
125 unsigned int reg0
= (reg
+ 0) % 32;
126 unsigned int reg1
= (reg
+ 1) % 32;
127 unsigned int reg2
= (reg
+ 2) % 32;
128 unsigned int stk
= reg
< 16 ? 31 : 15;
129 unsigned long code
[] =
132 ASM_ADDI(stk
, 1, -24),
135 ASM_STW(reg0
, stk
, 8),
136 ASM_STW(reg1
, stk
, 4),
137 ASM_STW(reg2
, stk
, 0),
138 ASM_LWZ(reg1
, stk
, 12),
139 ASM_LWZ(reg0
, stk
, 16),
140 ASM_12X(test
->cmd
, reg2
, reg1
, reg0
),
141 ASM_STW(reg2
, stk
, 12),
142 ASM_LWZ(reg2
, stk
, 0),
143 ASM_LWZ(reg1
, stk
, 4),
144 ASM_LWZ(reg0
, stk
, 8),
146 ASM_ADDI(1, stk
, 24),
150 unsigned long codecr
[] =
153 ASM_ADDI(stk
, 1, -24),
156 ASM_STW(reg0
, stk
, 8),
157 ASM_STW(reg1
, stk
, 4),
158 ASM_STW(reg2
, stk
, 0),
159 ASM_LWZ(reg1
, stk
, 12),
160 ASM_LWZ(reg0
, stk
, 16),
161 ASM_12X(test
->cmd
, reg2
, reg1
, reg0
) | BIT_C
,
162 ASM_STW(reg2
, stk
, 12),
163 ASM_LWZ(reg2
, stk
, 0),
164 ASM_LWZ(reg1
, stk
, 4),
165 ASM_LWZ(reg0
, stk
, 8),
167 ASM_ADDI(1, stk
, 24),
177 cpu_post_exec_22 (code
, & cr
, & res
, test
->op1
, test
->op2
);
179 ret
= res
== test
->res
&& cr
== 0 ? 0 : -1;
183 post_log ("Error at threex test %d !\n", i
);
189 cpu_post_exec_22 (codecr
, & cr
, & res
, test
->op1
, test
->op2
);
191 ret
= res
== test
->res
&&
192 (cr
& 0xe0000000) == cpu_post_makecr (res
) ? 0 : -1;
196 post_log ("Error at threex test %d !\n", i
);