Annotation of 42BSD/sys/vaxuba/kgclock.c, revision 1.1

1.1     ! root        1: /*     kgclock.c       6.1     83/07/29        */
        !             2: 
        !             3: #include "kg.h"
        !             4: #if NKG > 0
        !             5: /*
        !             6:  * KL-11 as profiling clock
        !             7:  */
        !             8: #include "../machine/pte.h"
        !             9: #include "../machine/psl.h"
        !            10: 
        !            11: #include "../h/param.h"
        !            12: #include "../h/map.h"
        !            13: #include "../h/buf.h"
        !            14: #include "../h/time.h"
        !            15: #include "../h/kernel.h"
        !            16: 
        !            17: #include "../vaxuba/ubavar.h"
        !            18: 
        !            19: int    kgprobe(), kgattach();
        !            20: struct uba_device *kginfo[1];
        !            21: u_short        kgstd[] = { 0177560, 0 };
        !            22: struct uba_driver kgdriver =
        !            23:     { kgprobe, 0, kgattach, 0, kgstd, "kg", kginfo };
        !            24: 
        !            25: struct klregs {
        !            26:        u_short fill[2];
        !            27:        u_short tcsr;
        !            28:        u_short tbuf;
        !            29: };
        !            30: #define        KLSTRT  0300            /* intr enbl + done */
        !            31: struct klregs *klbase;
        !            32: 
        !            33: kgprobe(reg)
        !            34:        caddr_t reg;
        !            35: {
        !            36:        register int br, cvec;  /* value-result */
        !            37:        register struct klregs *klp = (struct klregs *)reg;
        !            38: 
        !            39:        klp->tcsr = KLSTRT;
        !            40:        DELAY(100000);
        !            41:        klp->tcsr = 0;
        !            42: }
        !            43: 
        !            44: kgattach(ui)
        !            45:        struct uba_device *ui;
        !            46: {
        !            47: 
        !            48:        klbase = (struct klregs *)ui->ui_addr;
        !            49: }
        !            50: 
        !            51: /*
        !            52:  * start the sampling clock
        !            53:  */
        !            54: startkgclock()
        !            55: {
        !            56: 
        !            57:        if (klbase)
        !            58:                klbase->tcsr = KLSTRT;  /* enable interrupts */
        !            59: }
        !            60: 
        !            61: /* ARGSUSED */
        !            62: kgclock(dev, r0, r1, r2, r3, r4 ,r5, pc, ps)
        !            63:        caddr_t pc;
        !            64:        int ps;
        !            65: {
        !            66:        register int k;
        !            67:        static long otime;
        !            68:        static long calibrate;
        !            69: 
        !            70:        klbase->tbuf = 0377;    /* reprime clock (scope sync too) */
        !            71:        if (phz == 0) {
        !            72:                if (otime == 0) {
        !            73:                        otime = time.tv_sec + 1;
        !            74:                        calibrate = 0;
        !            75:                }
        !            76:                if (time.tv_sec >= otime)
        !            77:                        calibrate++;
        !            78:                if (time.tv_sec >= otime + 4) {
        !            79:                        phz = calibrate / 4;
        !            80:                        otime = 0;
        !            81:                }
        !            82:                return;
        !            83:        }
        !            84:        gatherstats(pc, ps);    /* this routine lives in kern_clock.c */
        !            85: }
        !            86: #endif

unix.superglobalmegacorp.com

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