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 "../system.h"
20 /*===========================================================================*
22 *===========================================================================*/
23 PUBLIC
int do_sprofile(m_ptr
)
24 register message
*m_ptr
; /* pointer to request message */
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 kprintf("SYSTEM: start s-profiling: already started\n");
44 isokendpt(m_ptr
->PROF_ENDPT
, &proc_nr
);
46 vir_dst
= (vir_bytes
) m_ptr
->PROF_CTL_PTR
;
47 length
= (phys_bytes
) sizeof (int *);
48 sprof_info_addr
= numap_local(proc_nr
, vir_dst
, length
);
50 vir_dst
= (vir_bytes
) m_ptr
->PROF_MEM_PTR
;
51 length
= (phys_bytes
) sizeof (char *);
52 sprof_data_addr
= numap_local(proc_nr
, vir_dst
, length
);
54 sprof_info
.mem_used
= 0;
55 sprof_info
.total_samples
= 0;
56 sprof_info
.idle_samples
= 0;
57 sprof_info
.system_samples
= 0;
58 sprof_info
.user_samples
= 0;
60 sprof_mem_size
= m_ptr
->PROF_MEM_SIZE
;
62 init_profile_clock(m_ptr
->PROF_FREQ
);
69 /* Stopping profiling.
71 * Check if profiling is indeed running. Turn off profiling.
72 * Stop CMOS timer. Copy info struct to user process.
75 kprintf("SYSTEM: stop s-profiling: not started\n");
83 phys_copy(vir2phys((vir_bytes
) &sprof_info
),
84 sprof_info_addr
, (phys_bytes
) sizeof(sprof_info
));