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"
20 /* user address to write info struct */
21 PRIVATE vir_bytes sprof_info_addr_vir
;
23 /*===========================================================================*
25 *===========================================================================*/
26 PUBLIC
int do_sprofile(struct proc
* caller
, message
* m_ptr
)
30 switch(m_ptr
->PROF_ACTION
) {
33 /* Starting profiling.
35 * Check if profiling is not already running. Calculate physical
36 * addresses of user pointers. Reset counters. Start CMOS timer.
40 printf("SYSTEM: start s-profiling: already started\n");
44 /* Test endpoint number. */
45 if(!isokendpt(m_ptr
->PROF_ENDPT
, &proc_nr
))
48 /* Set parameters for statistical profiler. */
49 sprof_ep
= m_ptr
->PROF_ENDPT
;
50 sprof_info_addr_vir
= (vir_bytes
) m_ptr
->PROF_CTL_PTR
;
51 sprof_data_addr_vir
= (vir_bytes
) m_ptr
->PROF_MEM_PTR
;
53 sprof_info
.mem_used
= 0;
54 sprof_info
.total_samples
= 0;
55 sprof_info
.idle_samples
= 0;
56 sprof_info
.system_samples
= 0;
57 sprof_info
.user_samples
= 0;
59 sprof_mem_size
= m_ptr
->PROF_MEM_SIZE
;
61 init_profile_clock(m_ptr
->PROF_FREQ
);
68 /* Stopping profiling.
70 * Check if profiling is indeed running. Turn off profiling.
71 * Stop CMOS timer. Copy info struct to user process.
74 printf("SYSTEM: stop s-profiling: not started\n");
82 data_copy(KERNEL
, (vir_bytes
) &sprof_info
,
83 sprof_ep
, sprof_info_addr_vir
, sizeof(sprof_info
));