1 /* The kernel call that is implemented in this file:
4 * The parameters for this kernel call are:
5 * m7_i1: PROF_ACTION (start/stop profiling)
6 * m7_i2: PROF_MEM_SIZE (available memory for data)
7 * m7_i3: PROF_FREQ (requested sample frequency)
8 * m7_i4: PROF_ENDPT (endpoint of caller)
9 * m7_p1: PROF_CTL_PTR (location of info struct)
10 * m7_p2: PROF_MEM_PTR (location of memory for data)
13 * 14 Aug, 2006 Created (Rogier Meurs)
16 #include "kernel/system.h"
17 #include "kernel/watchdog.h"
21 /* user address to write info struct */
22 static vir_bytes sprof_info_addr_vir
;
24 static void clean_seen_flag(void)
28 for (i
= 0; i
< NR_TASKS
+ NR_PROCS
; i
++)
29 proc
[i
].p_misc_flags
&= ~MF_SPROF_SEEN
;
32 /*===========================================================================*
34 *===========================================================================*/
35 int do_sprofile(struct proc
* caller
, message
* m_ptr
)
40 switch(m_ptr
->PROF_ACTION
) {
43 /* Starting profiling.
45 * Check if profiling is not already running. Calculate physical
46 * addresses of user pointers. Reset counters. Start CMOS timer.
50 printf("SYSTEM: start s-profiling: already started\n");
54 /* Test endpoint number. */
55 if(!isokendpt(m_ptr
->PROF_ENDPT
, &proc_nr
))
58 /* Set parameters for statistical profiler. */
59 sprof_ep
= m_ptr
->PROF_ENDPT
;
60 sprof_info_addr_vir
= (vir_bytes
) m_ptr
->PROF_CTL_PTR
;
61 sprof_data_addr_vir
= (vir_bytes
) m_ptr
->PROF_MEM_PTR
;
63 sprof_info
.mem_used
= 0;
64 sprof_info
.total_samples
= 0;
65 sprof_info
.idle_samples
= 0;
66 sprof_info
.system_samples
= 0;
67 sprof_info
.user_samples
= 0;
69 sprof_mem_size
= m_ptr
->PROF_MEM_SIZE
< SAMPLE_BUFFER_SIZE
?
70 m_ptr
->PROF_MEM_SIZE
: SAMPLE_BUFFER_SIZE
;
72 switch (sprofiling_type
= m_ptr
->PROF_INTR_TYPE
) {
74 init_profile_clock(m_ptr
->PROF_FREQ
);
77 err
= nmi_watchdog_start_profiling(m_ptr
->PROF_FREQ
);
82 printf("ERROR : unknown profiling interrupt type\n");
93 /* Stopping profiling.
95 * Check if profiling is indeed running. Turn off profiling.
96 * Stop CMOS timer. Copy info struct to user process.
99 printf("SYSTEM: stop s-profiling: not started\n");
105 switch (sprofiling_type
) {
107 stop_profile_clock();
110 nmi_watchdog_stop_profiling();
114 data_copy(KERNEL
, (vir_bytes
) &sprof_info
,
115 sprof_ep
, sprof_info_addr_vir
, sizeof(sprof_info
));
116 data_copy(KERNEL
, (vir_bytes
) sprof_sample_buffer
,
117 sprof_ep
, sprof_data_addr_vir
, sprof_info
.mem_used
);
128 #endif /* SPROFILE */