1: /*
   2:  * Copyright (c) 1982, 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)kgclock.c	7.1 (Berkeley) 6/5/86
   7:  */
   8: 
   9: #include "kg.h"
  10: #if NKG > 0
  11: /*
  12:  * KL-11 as profiling clock
  13:  */
  14: #include "../machine/pte.h"
  15: #include "../machine/psl.h"
  16: 
  17: #include "param.h"
  18: #include "map.h"
  19: #include "buf.h"
  20: #include "time.h"
  21: #include "kernel.h"
  22: 
  23: #include "ubavar.h"
  24: 
  25: int kgprobe(), kgattach();
  26: struct  uba_device *kginfo[1];
  27: u_short kgstd[] = { 0177560, 0 };
  28: struct  uba_driver kgdriver =
  29:     { kgprobe, 0, kgattach, 0, kgstd, "kg", kginfo };
  30: 
  31: struct klregs {
  32:     u_short fill[2];
  33:     u_short tcsr;
  34:     u_short tbuf;
  35: };
  36: #define KLSTRT  0300        /* intr enbl + done */
  37: struct  klregs *klbase;
  38: 
  39: int usekgclock = 1;     /* if zero, kgclock is disabled */
  40: 
  41: kgprobe(reg)
  42:     caddr_t reg;
  43: {
  44:     register int br, cvec;  /* value-result */
  45:     register struct klregs *klp = (struct klregs *)reg;
  46: 
  47:     klp->tcsr = KLSTRT;
  48:     DELAY(100000);
  49:     klp->tcsr = 0;
  50:     return (sizeof(struct klregs));
  51: }
  52: 
  53: kgattach(ui)
  54:     struct uba_device *ui;
  55: {
  56: 
  57:     klbase = (struct klregs *)ui->ui_addr;
  58: }
  59: 
  60: /*
  61:  * start the sampling clock
  62:  */
  63: startkgclock()
  64: {
  65: 
  66:     if (klbase && usekgclock && phz == 0)
  67:         klbase->tcsr = KLSTRT;  /* enable interrupts */
  68: }
  69: 
  70: /* ARGSUSED */
  71: kgclock(dev, r0, r1, r2, r3, r4 ,r5, pc, ps)
  72:     caddr_t pc;
  73:     int ps;
  74: {
  75:     register int k;
  76:     static long otime;
  77:     static long calibrate;
  78: 
  79:     if (usekgclock == 0) {
  80:         phz = 0;
  81:         otime = 0;
  82:         return;
  83:     }
  84:     klbase->tbuf = 0377;    /* reprime clock (scope sync too) */
  85:     if (phz == 0) {
  86:         if (otime == 0) {
  87:             otime = time.tv_sec + 1;
  88:             calibrate = 0;
  89:         }
  90:         if (time.tv_sec >= otime)
  91:             calibrate++;
  92:         if (time.tv_sec >= otime + 4) {
  93:             phz = calibrate / 4;
  94:             otime = 0;
  95:         }
  96:         return;
  97:     }
  98:     gatherstats(pc, ps);    /* this routine lives in kern_clock.c */
  99: }
 100: #endif

Defined functions

kgattach defined in line 53; used 2 times
kgclock defined in line 71; never used
kgprobe defined in line 41; used 2 times
startkgclock defined in line 63; used 1 times

Defined variables

kgdriver defined in line 28; never used
kginfo defined in line 26; used 1 times
  • in line 29
kgstd defined in line 27; used 1 times
  • in line 29
klbase defined in line 37; used 4 times
usekgclock defined in line 39; used 2 times

Defined struct's

klregs defined in line 31; used 10 times

Defined macros

KLSTRT defined in line 36; used 2 times
Last modified: 1986-06-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1117
Valid CSS Valid XHTML 1.0 Strict