1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25
26
27
28
29
30
31
32
33
34#include <post.h>
35#include "cpu_asm.h"
36
37#if CONFIG_POST & CONFIG_SYS_POST_CPU
38
39extern int cpu_post_complex_1_asm (int a1, int a2, int a3, int a4, int n);
40extern int cpu_post_complex_2_asm (int x, int n);
41
42
43
44
45
46
47static int cpu_post_test_complex_1 (void)
48{
49 int a1 = 666;
50 int a2 = 667;
51 int a3 = 668;
52 int a4 = 66;
53 int n = 100;
54 int result = 6720;
55
56 if (cpu_post_complex_1_asm(a1, a2, a3, a4, n) != n * result)
57 {
58 return -1;
59 }
60
61 return 0;
62}
63
64
65
66static int cpu_post_test_complex_2 (void)
67{
68 int ret = -1;
69 int x;
70 int n;
71 int k;
72 int left;
73 int right;
74
75 for (x = -8; x <= 8; x ++)
76 {
77 n = 9;
78
79 left = cpu_post_complex_2_asm(x, n);
80 left *= 1 - x;
81
82 right = 1;
83 for (k = 0; k <= n; k ++)
84 {
85 right *= x;
86 }
87 right = 1 - right;
88
89 if (left != right)
90 {
91 goto Done;
92 }
93 }
94
95 ret = 0;
96 Done:
97
98 return ret;
99}
100
101int cpu_post_test_complex (void)
102{
103 int ret = 0;
104 int flag = disable_interrupts();
105
106 if (ret == 0)
107 {
108 ret = cpu_post_test_complex_1();
109 }
110
111 if (ret == 0)
112 {
113 ret = cpu_post_test_complex_2();
114 }
115
116 if (ret != 0)
117 {
118 post_log ("Error at complex test !\n");
119 }
120
121 if (flag)
122 enable_interrupts();
123
124 return ret;
125}
126
127#endif
128