Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | |
| 9 | /* |
| 10 | * CPU test |
| 11 | * Load/store string instructions: lswi, stswi, lswx, stswx |
| 12 | * |
| 13 | * Several consecutive bytes from a source memory buffer are loaded |
| 14 | * left to right into GPRs. After that, the bytes are stored |
| 15 | * from the GPRs into a target memory buffer. The contents |
| 16 | * of the source and target buffers are then compared. |
| 17 | */ |
| 18 | |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 19 | #include <post.h> |
| 20 | #include "cpu_asm.h" |
| 21 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 22 | #if CONFIG_POST & CONFIG_SYS_POST_CPU |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 23 | |
| 24 | extern void cpu_post_exec_02 (ulong *code, ulong op1, ulong op2); |
| 25 | extern void cpu_post_exec_04 (ulong *code, ulong op1, ulong op2, ulong op3, |
| 26 | ulong op4); |
| 27 | |
| 28 | #include <bedbug/regs.h> |
| 29 | int cpu_post_test_string (void) |
| 30 | { |
| 31 | int ret = 0; |
| 32 | unsigned int i; |
Stefan Roese | 3762825 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 33 | int flag = disable_interrupts(); |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 34 | |
| 35 | if (ret == 0) |
| 36 | { |
| 37 | char src [31], dst [31]; |
| 38 | |
| 39 | ulong code[] = |
| 40 | { |
| 41 | ASM_LSWI(5, 3, 31), |
| 42 | ASM_STSWI(5, 4, 31), |
| 43 | ASM_BLR, |
| 44 | }; |
| 45 | |
| 46 | for (i = 0; i < sizeof(src); i ++) |
| 47 | { |
| 48 | src[i] = (char) i; |
| 49 | dst[i] = 0; |
| 50 | } |
| 51 | |
| 52 | cpu_post_exec_02(code, (ulong)src, (ulong)dst); |
| 53 | |
| 54 | ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1; |
| 55 | } |
| 56 | |
| 57 | if (ret == 0) |
| 58 | { |
| 59 | char src [95], dst [95]; |
| 60 | |
| 61 | ulong code[] = |
| 62 | { |
| 63 | ASM_LSWX(8, 3, 5), |
| 64 | ASM_STSWX(8, 4, 5), |
| 65 | ASM_BLR, |
| 66 | }; |
| 67 | |
| 68 | for (i = 0; i < sizeof(src); i ++) |
| 69 | { |
| 70 | src[i] = (char) i; |
| 71 | dst[i] = 0; |
| 72 | } |
| 73 | |
| 74 | cpu_post_exec_04(code, (ulong)src, (ulong)dst, 0, sizeof(src)); |
| 75 | |
| 76 | ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1; |
| 77 | } |
| 78 | |
| 79 | if (ret != 0) |
| 80 | { |
| 81 | post_log ("Error at string test !\n"); |
| 82 | } |
| 83 | |
Stefan Roese | 3762825 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 84 | if (flag) |
| 85 | enable_interrupts(); |
| 86 | |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 87 | return ret; |
| 88 | } |
| 89 | |
| 90 | #endif |