1 /* This file implements entry points for system profiling.
3 * The entry points in this file are:
4 * do_sprofile: start/stop statistical profiling
5 * do_cprofile: get/reset call profiling tables
8 * 14 Aug, 2006 Created (Rogier Meurs)
11 #include <minix/config.h>
12 #include <minix/profile.h>
15 #include <minix/callnr.h>
16 #include <minix/com.h>
21 #if SPROFILE || CPROFILE
22 FORWARD
_PROTOTYPE( int check_addrs
, (int info_size
) );
25 /*===========================================================================*
27 *===========================================================================*/
28 PUBLIC
int do_sprofile(void)
34 switch(m_in
.PROF_ACTION
) {
37 if ((r
= check_addrs(sizeof(sprof_info_inst
)))) /* check pointers */
40 return sys_sprof(PROF_START
, m_in
.PROF_MEM_SIZE
, m_in
.PROF_FREQ
,
41 who_e
, m_in
.PROF_CTL_PTR
, m_in
.PROF_MEM_PTR
);
44 return sys_sprof(PROF_STOP
,0,0,0,0,0);
56 /*===========================================================================*
58 *===========================================================================*/
59 PUBLIC
int do_cprofile(void)
65 switch(m_in
.PROF_ACTION
) {
68 if (r
= check_addrs(sizeof(cprof_info_inst
))) /* check user pointers */
71 return sys_cprof(PROF_GET
, m_in
.PROF_MEM_SIZE
, who_e
,
72 m_in
.PROF_CTL_PTR
, m_in
.PROF_MEM_PTR
);
75 return sys_cprof(PROF_RESET
,0,0,0,0);
87 #if SPROFILE || CPROFILE
89 /*===========================================================================*
91 *===========================================================================*/
92 PRIVATE
int check_addrs(info_size
)
98 /* Check if supplied pointers point into user process. */
99 if ((r
= sys_umap(who_e
, D
, (vir_bytes
) m_in
.PROF_CTL_PTR
,
100 info_size
, &p
)) != OK
) {
101 printf("PM: PROFILE: umap failed for process %d\n", who_e
);
105 if ((r
=sys_umap(who_e
, D
, (vir_bytes
) m_in
.PROF_MEM_PTR
,
106 m_in
.PROF_MEM_SIZE
, &p
)) != OK
) {
107 printf("PM: PROFILE: umap failed for process %d\n", who_e
);