1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
12 * Load instructions: lbz(x)(u), lhz(x)(u), lha(x)(u), lwz(x)(u)
14 * All operations are performed on a 16-byte array. The array
15 * is 4-byte aligned. The base register points to offset 8.
16 * The immediate offset (index register) ranges in [-8 ... +7].
17 * The test cases are composed so that they do not
18 * cause alignment exceptions.
19 * The test contains a pre-built table describing all test cases.
20 * The table entry contains:
21 * the instruction opcode, the array contents, the value of the index
22 * register and the expected value of the destination register.
23 * After executing the instruction, the test verifies the
24 * value of the destination register and the value of the base
25 * register (it must change for "load with update" instructions).
31 #if CFG_POST & CFG_SYS_POST_CPU
33 extern void cpu_post_exec_22w (ulong *code, ulong *op1, ulong op2, ulong *op3);
34 extern void cpu_post_exec_21w (ulong *code, ulong *op1, ulong *op2);
36 static struct cpu_post_load_s
43 } cpu_post_load_table[] =
158 static unsigned int cpu_post_load_size = ARRAY_SIZE(cpu_post_load_table);
160 int cpu_post_test_load (void)
164 int flag = disable_interrupts();
166 for (i = 0; i < cpu_post_load_size && ret == 0; i++)
168 struct cpu_post_load_s *test = cpu_post_load_table + i;
170 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
171 ulong base0 = (ulong) (data + 8);
179 ASM_12(test->cmd, 5, 3, 4),
183 cpu_post_exec_22w (code, &base, test->offset, &value);
189 ASM_11I(test->cmd, 4, 3, test->offset),
193 cpu_post_exec_21w (code, &base, &value);
199 ret = base == base0 + test->offset ? 0 : -1;
201 ret = base == base0 ? 0 : -1;
209 ret = *(uchar *)(base0 + test->offset) == value ?
213 ret = *(ushort *)(base0 + test->offset) == value ?
217 ret = *(short *)(base0 + test->offset) == value ?
221 ret = *(ulong *)(base0 + test->offset) == value ?
229 post_log ("Error at load test %d !\n", i);