. service tells you which device it couldn't stat
[minix3.git] / servers / pm / profile.c
blob5853039914127188b2b235bb9426c87b3f27a71a
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
7 * Changes:
8 * 14 Aug, 2006 Created (Rogier Meurs)
9 */
11 #include <minix/config.h>
12 #include <minix/profile.h>
13 #include "pm.h"
14 #include <sys/wait.h>
15 #include <minix/callnr.h>
16 #include <minix/com.h>
17 #include <signal.h>
18 #include "mproc.h"
19 #include "param.h"
21 #if SPROFILE || CPROFILE
22 FORWARD _PROTOTYPE( int check_addrs, (int info_size) );
23 #endif
25 /*===========================================================================*
26 * do_sprofile *
27 *===========================================================================*/
28 PUBLIC int do_sprofile(void)
30 #if SPROFILE
32 int r;
34 switch(m_in.PROF_ACTION) {
36 case PROF_START:
37 if ((r = check_addrs(sizeof(sprof_info_inst)))) /* check pointers */
38 return r;
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);
43 case PROF_STOP:
44 return sys_sprof(PROF_STOP,0,0,0,0,0);
46 default:
47 return EINVAL;
50 #else
51 return ENOSYS;
52 #endif
56 /*===========================================================================*
57 * do_cprofile *
58 *===========================================================================*/
59 PUBLIC int do_cprofile(void)
61 #if CPROFILE
63 int r;
65 switch(m_in.PROF_ACTION) {
67 case PROF_GET:
68 if (r = check_addrs(sizeof(cprof_info_inst))) /* check user pointers */
69 return r;
71 return sys_cprof(PROF_GET, m_in.PROF_MEM_SIZE, who_e,
72 m_in.PROF_CTL_PTR, m_in.PROF_MEM_PTR);
74 case PROF_RESET:
75 return sys_cprof(PROF_RESET,0,0,0,0);
77 default:
78 return EINVAL;
81 #else
82 return ENOSYS;
83 #endif
87 #if SPROFILE || CPROFILE
89 /*===========================================================================*
90 * check_addrs *
91 *===========================================================================*/
92 PRIVATE int check_addrs(info_size)
93 int info_size;
95 int r;
96 phys_bytes p;
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);
102 return r;
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);
108 return r;
110 return 0;
113 #endif