-struct profil_args {
- short *bufbase;
- u_int bufsize;
- u_int pcoffset;
- u_int pcscale;
-};
-int
-profil(p, uap, retval)
- struct proc *p;
- register struct profil_args *uap;
- register_t *retval;
-{
- register struct uprof *upp = &p->p_stats->p_prof;
- struct uprof *upc, *nupc;
- int s;
-
- if (uap->pcscale > (1 << 16))
- return (EINVAL);
- if (uap->pcscale == 0) {
- stopprofclock(p);
- return (0);
- }
-
- /* Block profile interrupts while changing state. */
- s = splstatclock();
- PROFILE_LOCK(&upp->pr_lock);
- upp->pr_base = (caddr_t)uap->bufbase;
- upp->pr_size = uap->bufsize;
- upp->pr_off = uap->pcoffset;
- upp->pr_scale = uap->pcscale;
-
- /* remove buffers previously allocated with add_profil() */
- for (upc = upp->pr_next; upc; upc = nupc) {
- nupc = upc->pr_next;
- kfree(upc, sizeof (struct uprof));
- }
-
- upp->pr_next = 0;
- PROFILE_UNLOCK(&upp->pr_lock);
- startprofclock(p);
- splx(s);
- return(0);
-}
-
-struct add_profile_args {
- short *bufbase;
- u_int bufsize;
- u_int pcoffset;
- u_int pcscale;
-};
-int
-add_profil(p, uap, retval)
- struct proc *p;
- register struct add_profile_args *uap;
- register_t *retval;
-{
- struct uprof *upp = &p->p_stats->p_prof, *upc;
- int s;
-
- if (upp->pr_scale == 0)
- return (0);
- s = splstatclock();
- upc = (struct uprof *) kalloc(sizeof (struct uprof));
- upc->pr_base = (caddr_t)uap->bufbase;
- upc->pr_size = uap->bufsize;
- upc->pr_off = uap->pcoffset;
- upc->pr_scale = uap->pcscale;
- PROFILE_LOCK(&upp->pr_lock);
- upc->pr_next = upp->pr_next;
- upp->pr_next = upc;
- PROFILE_UNLOCK(&upp->pr_lock);
- splx(s);
- return(0);
-}