1
2
3
4
5
6
7#include <common.h>
8#include <irq_func.h>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <post.h>
24#include "cpu_asm.h"
25
26#if CONFIG_POST & CONFIG_SYS_POST_CPU
27
28extern void cpu_post_exec_11 (ulong *code, ulong *res, ulong op1);
29
30static struct cpu_post_cmpi_s
31{
32 ulong cmd;
33 ulong op1;
34 ushort op2;
35 ulong cr;
36 ulong res;
37} cpu_post_cmpi_table[] =
38{
39 {
40 OP_CMPWI,
41 123,
42 123,
43 2,
44 0x02
45 },
46 {
47 OP_CMPWI,
48 123,
49 133,
50 3,
51 0x08
52 },
53 {
54 OP_CMPWI,
55 123,
56 -133,
57 4,
58 0x04
59 },
60 {
61 OP_CMPLWI,
62 123,
63 123,
64 2,
65 0x02
66 },
67 {
68 OP_CMPLWI,
69 123,
70 -133,
71 3,
72 0x08
73 },
74 {
75 OP_CMPLWI,
76 123,
77 113,
78 4,
79 0x04
80 },
81};
82static unsigned int cpu_post_cmpi_size = ARRAY_SIZE(cpu_post_cmpi_table);
83
84int cpu_post_test_cmpi (void)
85{
86 int ret = 0;
87 unsigned int i;
88 int flag = disable_interrupts();
89
90 for (i = 0; i < cpu_post_cmpi_size && ret == 0; i++)
91 {
92 struct cpu_post_cmpi_s *test = cpu_post_cmpi_table + i;
93 unsigned long code[] =
94 {
95 ASM_1IC(test->cmd, test->cr, 3, test->op2),
96 ASM_MFCR(3),
97 ASM_BLR
98 };
99 ulong res;
100
101 cpu_post_exec_11 (code, & res, test->op1);
102
103 ret = ((res >> (28 - 4 * test->cr)) & 0xe) == test->res ? 0 : -1;
104
105 if (ret != 0)
106 {
107 post_log ("Error at cmpi test %d !\n", i);
108 }
109 }
110
111 if (flag)
112 enable_interrupts();
113
114 return ret;
115}
116
117#endif
118