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