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