1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2a47a12beSStefan Roese /*
3a47a12beSStefan Roese * (C) Copyright 2002
4a47a12beSStefan Roese * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5a47a12beSStefan Roese */
6a47a12beSStefan Roese
7a47a12beSStefan Roese #include <common.h>
8a47a12beSStefan Roese
9a47a12beSStefan Roese /*
10a47a12beSStefan Roese * CPU test
11a47a12beSStefan Roese * Load/store multiple word instructions: lmw, stmw
12a47a12beSStefan Roese *
137ddd4475SWolfgang Denk * 27 consecutive words are loaded from a source memory buffer
147ddd4475SWolfgang Denk * into GPRs r5 through r31. After that, 27 consecutive words are stored
157ddd4475SWolfgang Denk * from the GPRs r5 through r31 into a target memory buffer. The contents
16a47a12beSStefan Roese * of the source and target buffers are then compared.
17a47a12beSStefan Roese */
18a47a12beSStefan Roese
19a47a12beSStefan Roese #include <post.h>
20a47a12beSStefan Roese #include "cpu_asm.h"
21a47a12beSStefan Roese
22a47a12beSStefan Roese #if CONFIG_POST & CONFIG_SYS_POST_CPU
23a47a12beSStefan Roese
24a47a12beSStefan Roese extern void cpu_post_exec_02(ulong *code, ulong op1, ulong op2);
25a47a12beSStefan Roese
cpu_post_test_multi(void)26a47a12beSStefan Roese int cpu_post_test_multi(void)
27a47a12beSStefan Roese {
28a47a12beSStefan Roese int ret = 0;
29a47a12beSStefan Roese unsigned int i;
307ddd4475SWolfgang Denk ulong src[27], dst[27];
31a47a12beSStefan Roese int flag = disable_interrupts();
32a47a12beSStefan Roese
33a63aec54SWolfgang Denk ulong code[] = {
3438081ff7SWolfgang Denk ASM_LMW(5, 3, 0), /* lmw r5, 0(r3) */
3538081ff7SWolfgang Denk ASM_STMW(5, 4, 0), /* stmr r5, 0(r4) */
3638081ff7SWolfgang Denk ASM_BLR, /* blr */
37a47a12beSStefan Roese };
38a47a12beSStefan Roese
39a63aec54SWolfgang Denk for (i = 0; i < ARRAY_SIZE(src); ++i) {
40a47a12beSStefan Roese src[i] = i;
41a47a12beSStefan Roese dst[i] = 0;
42a47a12beSStefan Roese }
43a47a12beSStefan Roese
44a47a12beSStefan Roese cpu_post_exec_02(code, (ulong) src, (ulong) dst);
45a47a12beSStefan Roese
46a47a12beSStefan Roese ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1;
47a47a12beSStefan Roese
48a47a12beSStefan Roese if (ret != 0)
49a47a12beSStefan Roese post_log("Error at multi test !\n");
50a47a12beSStefan Roese
51a47a12beSStefan Roese if (flag)
52a47a12beSStefan Roese enable_interrupts();
53a47a12beSStefan Roese
54a47a12beSStefan Roese return ret;
55a47a12beSStefan Roese }
56a47a12beSStefan Roese
57a47a12beSStefan Roese #endif
58