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 string instructions: lswi, stswi, lswx, stswx 13a47a12beSStefan Roese * 14a47a12beSStefan Roese * Several consecutive bytes from a source memory buffer are loaded 15a47a12beSStefan Roese * left to right into GPRs. After that, the bytes are stored 16a47a12beSStefan Roese * from the GPRs 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 extern void cpu_post_exec_04 (ulong *code, ulong op1, ulong op2, ulong op3, 27a47a12beSStefan Roese ulong op4); 28a47a12beSStefan Roese 29a47a12beSStefan Roese #include <bedbug/regs.h> 30a47a12beSStefan Roese int cpu_post_test_string (void) 31a47a12beSStefan Roese { 32a47a12beSStefan Roese int ret = 0; 33a47a12beSStefan Roese unsigned int i; 34a47a12beSStefan Roese int flag = disable_interrupts(); 35a47a12beSStefan Roese 36a47a12beSStefan Roese if (ret == 0) 37a47a12beSStefan Roese { 38a47a12beSStefan Roese char src [31], dst [31]; 39a47a12beSStefan Roese 40a47a12beSStefan Roese ulong code[] = 41a47a12beSStefan Roese { 42a47a12beSStefan Roese ASM_LSWI(5, 3, 31), 43a47a12beSStefan Roese ASM_STSWI(5, 4, 31), 44a47a12beSStefan Roese ASM_BLR, 45a47a12beSStefan Roese }; 46a47a12beSStefan Roese 47a47a12beSStefan Roese for (i = 0; i < sizeof(src); i ++) 48a47a12beSStefan Roese { 49a47a12beSStefan Roese src[i] = (char) i; 50a47a12beSStefan Roese dst[i] = 0; 51a47a12beSStefan Roese } 52a47a12beSStefan Roese 53a47a12beSStefan Roese cpu_post_exec_02(code, (ulong)src, (ulong)dst); 54a47a12beSStefan Roese 55a47a12beSStefan Roese ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1; 56a47a12beSStefan Roese } 57a47a12beSStefan Roese 58a47a12beSStefan Roese if (ret == 0) 59a47a12beSStefan Roese { 60a47a12beSStefan Roese char src [95], dst [95]; 61a47a12beSStefan Roese 62a47a12beSStefan Roese ulong code[] = 63a47a12beSStefan Roese { 64a47a12beSStefan Roese ASM_LSWX(8, 3, 5), 65a47a12beSStefan Roese ASM_STSWX(8, 4, 5), 66a47a12beSStefan Roese ASM_BLR, 67a47a12beSStefan Roese }; 68a47a12beSStefan Roese 69a47a12beSStefan Roese for (i = 0; i < sizeof(src); i ++) 70a47a12beSStefan Roese { 71a47a12beSStefan Roese src[i] = (char) i; 72a47a12beSStefan Roese dst[i] = 0; 73a47a12beSStefan Roese } 74a47a12beSStefan Roese 75a47a12beSStefan Roese cpu_post_exec_04(code, (ulong)src, (ulong)dst, 0, sizeof(src)); 76a47a12beSStefan Roese 77a47a12beSStefan Roese ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1; 78a47a12beSStefan Roese } 79a47a12beSStefan Roese 80a47a12beSStefan Roese if (ret != 0) 81a47a12beSStefan Roese { 82a47a12beSStefan Roese post_log ("Error at string test !\n"); 83a47a12beSStefan Roese } 84a47a12beSStefan Roese 85a47a12beSStefan Roese if (flag) 86a47a12beSStefan Roese enable_interrupts(); 87a47a12beSStefan Roese 88a47a12beSStefan Roese return ret; 89a47a12beSStefan Roese } 90a47a12beSStefan Roese 91a47a12beSStefan Roese #endif 92