Annotation of Net2/arch/vax/uba/kgclock.c, revision 1.1

1.1     ! root        1: /*-
        !             2:  * Copyright (c) 1982, 1986 The Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms, with or without
        !             6:  * modification, are permitted provided that the following conditions
        !             7:  * are met:
        !             8:  * 1. Redistributions of source code must retain the above copyright
        !             9:  *    notice, this list of conditions and the following disclaimer.
        !            10:  * 2. Redistributions in binary form must reproduce the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer in the
        !            12:  *    documentation and/or other materials provided with the distribution.
        !            13:  * 3. All advertising materials mentioning features or use of this software
        !            14:  *    must display the following acknowledgement:
        !            15:  *     This product includes software developed by the University of
        !            16:  *     California, Berkeley and its contributors.
        !            17:  * 4. Neither the name of the University nor the names of its contributors
        !            18:  *    may be used to endorse or promote products derived from this software
        !            19:  *    without specific prior written permission.
        !            20:  *
        !            21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            31:  * SUCH DAMAGE.
        !            32:  *
        !            33:  *     @(#)kgclock.c   7.4 (Berkeley) 5/9/91
        !            34:  */
        !            35: 
        !            36: #include "kg.h"
        !            37: #if NKG > 0
        !            38: /*
        !            39:  * KL-11 as profiling clock
        !            40:  */
        !            41: #include "../include/pte.h"
        !            42: #include "../include/psl.h"
        !            43: 
        !            44: #include "sys/param.h"
        !            45: #include "sys/map.h"
        !            46: #include "sys/buf.h"
        !            47: #include "sys/time.h"
        !            48: #include "sys/kernel.h"
        !            49: 
        !            50: #include "ubavar.h"
        !            51: 
        !            52: int    kgprobe(), kgattach();
        !            53: struct uba_device *kginfo[1];
        !            54: u_short        kgstd[] = { 0177560, 0 };
        !            55: struct uba_driver kgdriver =
        !            56:     { kgprobe, 0, kgattach, 0, kgstd, "kg", kginfo };
        !            57: 
        !            58: struct klregs {
        !            59:        u_short fill[2];
        !            60:        u_short tcsr;
        !            61:        u_short tbuf;
        !            62: };
        !            63: #define        KLSTRT  0300            /* intr enbl + done */
        !            64: struct klregs *klbase;
        !            65: 
        !            66: int    usekgclock = 1;         /* if zero, kgclock is disabled */
        !            67: 
        !            68: kgprobe(reg)
        !            69:        caddr_t reg;
        !            70: {
        !            71:        register int br, cvec;  /* value-result */
        !            72:        register struct klregs *klp = (struct klregs *)reg;
        !            73: 
        !            74:        klp->tcsr = KLSTRT;
        !            75:        DELAY(100000);
        !            76:        klp->tcsr = 0;
        !            77:        return (sizeof(struct klregs));
        !            78: }
        !            79: 
        !            80: kgattach(ui)
        !            81:        struct uba_device *ui;
        !            82: {
        !            83: 
        !            84:        klbase = (struct klregs *)ui->ui_addr;
        !            85: }
        !            86: 
        !            87: /*
        !            88:  * start the sampling clock
        !            89:  */
        !            90: startkgclock()
        !            91: {
        !            92: 
        !            93:        if (klbase && usekgclock && phz == 0)
        !            94:                klbase->tcsr = KLSTRT;  /* enable interrupts */
        !            95: }
        !            96: 
        !            97: /* ARGSUSED */
        !            98: kgclock(dev, r0, r1, r2, r3, r4 ,r5, pc, ps)
        !            99:        caddr_t pc;
        !           100:        int ps;
        !           101: {
        !           102:        register int k;
        !           103:        static long otime;
        !           104:        static long calibrate;
        !           105: 
        !           106:        if (usekgclock == 0) {
        !           107:                phz = 0;
        !           108:                otime = 0;
        !           109:                return;
        !           110:        }
        !           111:        klbase->tbuf = 0377;    /* reprime clock (scope sync too) */
        !           112:        if (phz == 0) {
        !           113:                if (otime == 0) {
        !           114:                        otime = time.tv_sec + 1;
        !           115:                        calibrate = 0;
        !           116:                }
        !           117:                if (time.tv_sec >= otime)
        !           118:                        calibrate++;
        !           119:                if (time.tv_sec >= otime + 4) {
        !           120:                        phz = calibrate / 4;
        !           121:                        otime = 0;
        !           122:                }
        !           123:                return;
        !           124:        }
        !           125:        gatherstats(pc, ps);    /* this routine lives in kern_clock.c */
        !           126: }
        !           127: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.