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