BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / hp300 / hp300 / clock.c
index b2a9579..4ecda8f 100644 (file)
@@ -7,16 +7,41 @@
  * the Systems Programming Group of the University of Utah Computer
  * Science Department.
  *
  * the Systems Programming Group of the University of Utah Computer
  * Science Department.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- * from: Utah $Hdr: clock.c 1.17 89/11/30$
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  *
  *
- *     @(#)clock.c     7.4 (Berkeley) %G%
+ * from: Utah $Hdr: clock.c 1.18 91/01/21$
+ *
+ *     @(#)clock.c     7.6 (Berkeley) 5/7/91
  */
 
  */
 
-#include "sys/param.h"
-#include "sys/user.h"
-#include "sys/kernel.h"
+#include "param.h"
+#include "kernel.h"
 #include "../dev/hilreg.h"
 #include "clockreg.h"
 
 #include "../dev/hilreg.h"
 #include "clockreg.h"
 
@@ -61,7 +86,7 @@ startrtclock()
 {
        register struct clkreg *clk;
 
 {
        register struct clkreg *clk;
 
-       clkstd[0] = IOV(0x5F8000);
+       clkstd[0] = IIOV(0x5F8000);
        clk = (struct clkreg *) clkstd[0];
 
        clk->clk_cr2 = CLK_CR1;
        clk = (struct clkreg *) clkstd[0];
 
        clk->clk_cr2 = CLK_CR1;
@@ -117,12 +142,11 @@ clkread()
  * configured as only a token effort is made to avoid conflicting use.
  */
 #include "sys/proc.h"
  * configured as only a token effort is made to avoid conflicting use.
  */
 #include "sys/proc.h"
+#include "sys/resourcevar.h"
 #include "sys/ioctl.h"
 #include "sys/malloc.h"
 #include "sys/ioctl.h"
 #include "sys/malloc.h"
+#include "vm/vm.h"
 #include "clockioctl.h"
 #include "clockioctl.h"
-#include "vm/vm_param.h"
-#include "vm/vm_pager.h"
-#include "vm/vm_prot.h"
 #include "sys/specdev.h"
 #include "sys/vnode.h"
 #include "sys/mman.h"
 #include "sys/specdev.h"
 #include "sys/vnode.h"
 #include "sys/mman.h"
@@ -164,27 +188,28 @@ clockopen(dev, flags)
 clockclose(dev, flags)
        dev_t dev;
 {
 clockclose(dev, flags)
        dev_t dev;
 {
-       (void) clockunmmap(dev, (caddr_t)0);
+       (void) clockunmmap(dev, (caddr_t)0, curproc);   /* XXX */
        stopclock();
        clockon = 0;
        return(0);
 }
 
 /*ARGSUSED*/
        stopclock();
        clockon = 0;
        return(0);
 }
 
 /*ARGSUSED*/
-clockioctl(dev, cmd, data, flag)
+clockioctl(dev, cmd, data, flag, p)
        dev_t dev;
        caddr_t data;
        dev_t dev;
        caddr_t data;
+       struct proc *p;
 {
        int error = 0;
        
        switch (cmd) {
 
        case CLOCKMAP:
 {
        int error = 0;
        
        switch (cmd) {
 
        case CLOCKMAP:
-               error = clockmmap(dev, (caddr_t *)data);
+               error = clockmmap(dev, (caddr_t *)data, p);
                break;
 
        case CLOCKUNMAP:
                break;
 
        case CLOCKUNMAP:
-               error = clockunmmap(dev, *(caddr_t *)data);
+               error = clockunmmap(dev, *(caddr_t *)data, p);
                break;
 
        case CLOCKGETRES:
                break;
 
        case CLOCKGETRES:
@@ -202,14 +227,14 @@ clockioctl(dev, cmd, data, flag)
 clockmap(dev, off, prot)
        dev_t dev;
 {
 clockmap(dev, off, prot)
        dev_t dev;
 {
-       return((off + (IOBASE+CLKBASE+CLKSR-1)) >> PGSHIFT);
+       return((off + (INTIOBASE+CLKBASE+CLKSR-1)) >> PGSHIFT);
 }
 
 }
 
-clockmmap(dev, addrp)
+clockmmap(dev, addrp, p)
        dev_t dev;
        caddr_t *addrp;
        dev_t dev;
        caddr_t *addrp;
+       struct proc *p;
 {
 {
-       struct proc *p = u.u_procp;             /* XXX */
        int error;
        struct vnode vn;
        struct specinfo si;
        int error;
        struct vnode vn;
        struct specinfo si;
@@ -223,21 +248,21 @@ clockmmap(dev, addrp)
        vn.v_type = VCHR;                       /* XXX */
        vn.v_specinfo = &si;                    /* XXX */
        vn.v_rdev = dev;                        /* XXX */
        vn.v_type = VCHR;                       /* XXX */
        vn.v_specinfo = &si;                    /* XXX */
        vn.v_rdev = dev;                        /* XXX */
-       error = vm_mmap(u.u_procp->p_map, (vm_offset_t *)addrp,
+       error = vm_mmap(&p->p_vmspace->vm_map, (vm_offset_t *)addrp,
                        PAGE_SIZE, VM_PROT_ALL, flags, (caddr_t)&vn, 0);
        return(error);
 }
 
                        PAGE_SIZE, VM_PROT_ALL, flags, (caddr_t)&vn, 0);
        return(error);
 }
 
-clockunmmap(dev, addr)
+clockunmmap(dev, addr, p)
        dev_t dev;
        caddr_t addr;
        dev_t dev;
        caddr_t addr;
+       struct proc *p;
 {
 {
-       struct proc *p = u.u_procp;             /* XXX */
        int rv;
 
        if (addr == 0)
                return(EINVAL);         /* XXX: how do we deal with this? */
        int rv;
 
        if (addr == 0)
                return(EINVAL);         /* XXX: how do we deal with this? */
-       rv = vm_deallocate(u.u_procp->p_map, (vm_offset_t)addr, PAGE_SIZE);
+       rv = vm_deallocate(p->p_vmspace->vm_map, (vm_offset_t)addr, PAGE_SIZE);
        return(rv == KERN_SUCCESS ? 0 : EINVAL);
 }
 
        return(rv == KERN_SUCCESS ? 0 : EINVAL);
 }
 
@@ -291,13 +316,15 @@ char profon    = 0;               /* Is profiling clock on? */
 initprofclock()
 {
 #if NCLOCK > 0
 initprofclock()
 {
 #if NCLOCK > 0
+       struct proc *p = curproc;               /* XXX */
+
        /*
         * If the high-res timer is running, force profiling off.
         * Unfortunately, this gets reflected back to the user not as
         * an error but as a lack of results.
         */
        if (clockon) {
        /*
         * If the high-res timer is running, force profiling off.
         * Unfortunately, this gets reflected back to the user not as
         * an error but as a lack of results.
         */
        if (clockon) {
-               u.u_prof.pr_scale = 0;
+               p->p_stats->p_prof.pr_scale = 0;
                return;
        }
        /*
                return;
        }
        /*
@@ -310,7 +337,7 @@ initprofclock()
         * Also assumes you don't do any forks or execs.  Oh well, there
         * is always adb...
         */
         * Also assumes you don't do any forks or execs.  Oh well, there
         * is always adb...
         */
-       if (u.u_prof.pr_scale)
+       if (p->p_stats->p_prof.pr_scale)
                profprocs++;
        else
                profprocs--;
                profprocs++;
        else
                profprocs--;
@@ -358,8 +385,8 @@ profclock(pc, ps)
         * If this process is being profiled record the tick.
         */
        if (USERMODE(ps)) {
         * If this process is being profiled record the tick.
         */
        if (USERMODE(ps)) {
-               if (u.u_prof.pr_scale)
-                       addupc(pc, &u.u_prof, 1);
+               if (p->p_stats.p_prof.pr_scale)
+                       addupc(pc, &curproc->p_stats.p_prof, 1);
        }
        /*
         * Came from kernel (supervisor) mode.
        }
        /*
         * Came from kernel (supervisor) mode.