main.c
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <os.h>
#include <rmon.h>
#include "osprof.h"
#define PROF_HISTO_ARRAY_V ((u16 *)0x80300000)
#define PROF_HISTO_ARRAY_P ((u16 *)0xa0300000)
OSProf TestProf[2];
extern char _profSegmentTextStart[];
extern char _profSegmentTextEnd[];
char bootStack[STACKSIZE];
static void idle(void *);
static void main(void *);
static OSThread idleThread;
static char idleThreadStack[STACKSIZE];
static OSThread mainThread;
static char mainThreadStack[STACKSIZE];
static OSThread rmonThread;
static char rmonThreadStack[RMON_STACKSIZE];
void prof(void);
boot(void)
{
int *pr;
osInitialize();
osCreateThread(&mainThread, 1, main, (void *)0, mainThreadStack+STACKSIZE,
10);
osStartThread(&mainThread);
}
static void
main(void *arg)
{
int totalFailures = 0;
int i;
u16 bin;
/*
* Create idle thread
*/
osCreateThread(&idleThread, 3, idle, (void *)0, idleThreadStack+STACKSIZE,
0);
osStartThread(&idleThread);
/* Start VI manager */
osCreateViManager((OSPri)OS_PRIORITY_VIMGR);
/*
* Create rmon thread
*/
osCreateThread(&rmonThread, 0, rmonMain, (void *)0,
rmonThreadStack+RMON_STACKSIZE, OS_PRIORITY_RMON);
osStartThread(&rmonThread);
/*
* Initialize and turn on profiling
*/
TestProf[0].histo_base = PROF_HISTO_ARRAY_V;
TestProf[0].histo_size = ((u32)timer1 -
(u32)prof) >> 2;
TestProf[0].text_start = (u32 *)prof;
TestProf[0].text_end = (u32 *)timer1;
TestProf[1].histo_base = PROF_HISTO_ARRAY_V+TestProf[0].histo_size;
TestProf[1].histo_size = ((u32)_profSegmentTextEnd -
(u32)timer1) >> 2;
TestProf[1].text_start = (u32 *)timer1;
TestProf[1].text_end = (u32 *)_profSegmentTextEnd;
#ifdef PROFILE_INIT
rmonPrintf("0: histo_base %x\n", TestProf[0].histo_base);
rmonPrintf("0: histo_size %x\n", TestProf[0].histo_size);
rmonPrintf("0: text_start %x\n", TestProf[0].text_start);
rmonPrintf("0: text_end %x\n", TestProf[0].text_end);
rmonPrintf("1: histo_base %x\n", TestProf[1].histo_base);
rmonPrintf("1: histo_size %x\n", TestProf[1].histo_size);
rmonPrintf("1: text_start %x\n", TestProf[1].text_start);
rmonPrintf("1: text_end %x\n", TestProf[1].text_end);
rmonPrintf("Init profiling\n");
osProfileInit(TestProf, 2);
osProfileStart(1000); /* 1 millisecond sample */
rmonPrintf("Start profiling\n");
#endif /* PROFILE_INIT */
for(i = 0; i < 3; i++) {
/*
* Use some time on CPU
*/
rmonPrintf("loop test\n");
prof();
/*
* Make sure profiling counter doesn't interfere with other counters
*/
#ifdef JUNK
rmonPrintf("timer1\n");
totalFailures += timer1();
rmonPrintf("timer2\n");
totalFailures += timer2();
rmonPrintf("timer3\n");
totalFailures += timer3();
#endif /* JUNK */
#ifdef PROFILE_FLUSH
osProfileFlush();
rmonPrintf("Flush Profile Data\n");
#endif /* PROFILE_FLUSH */
} /* for loop */
#ifdef PROFILE_STOP
/*
* Turn off profiling
*/
osProfileStop();
rmonPrintf("Stop profiling\n");
#endif /* PROFILE_STOP */
/*
* XXX Profile several different text sections
*/
rmonPrintf("Done\n");
/* make sure profiling data same every time */
for(;;) {
}
}
static void
idle(void *arg)
{
for(;;);
}