The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/alphapc/clock.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #include        "u.h"
    2 #include        "../port/lib.h"
    3 #include        "mem.h"
    4 #include        "dat.h"
    5 #include        "fns.h"
    6 #include        "io.h"
    7 #include        "axp.h"
    8 #include        "ureg.h"
    9 
   10 void
   11 clockinit(void)
   12 {
   13 }
   14 
   15 uvlong
   16 cycletimer(void)
   17 {
   18         ulong pcc;
   19         vlong delta;
   20 
   21         pcc = rpcc(nil) & 0xFFFFFFFF;
   22         if(m->cpuhz == 0){
   23                 /*
   24                  * pcclast is needed to detect wraparound of
   25                  * the cycle timer which is only 32-bits.
   26                  * m->cpuhz is set from the info passed from
   27                  * the firmware.
   28                  * This could be in clockinit if can
   29                  * guarantee no wraparound between then and now.
   30                  *
   31                  * All the clock stuff needs work.
   32                  */
   33                 m->cpuhz = hwrpb->cfreq;
   34                 m->pcclast = pcc;
   35         }
   36         delta = pcc - m->pcclast;
   37         if(delta < 0)
   38                 delta += 0x100000000LL;
   39         m->pcclast = pcc;
   40         m->fastclock += delta;
   41 
   42         return MACHP(0)->fastclock;
   43 }
   44 
   45 uvlong
   46 fastticks(uvlong* hz)
   47 {
   48         uvlong ticks;
   49         int x;
   50 
   51         x = splhi();
   52         ticks = cycletimer();
   53         splx(x);
   54 
   55         if(hz)
   56                 *hz = m->cpuhz;
   57 
   58         return ticks;
   59 }
   60 
   61 ulong
   62 ยตs(void)
   63 {
   64         return fastticks2us(cycletimer());
   65 }
   66 
   67 /*  
   68  *  performance measurement ticks.  must be low overhead.
   69  *  doesn't have to count over a second.
   70  */
   71 ulong
   72 perfticks(void)
   73 {
   74         return rpcc(nil);
   75 }
   76 
   77 void
   78 timerset(Tval)
   79 {
   80 }
   81 
   82 void
   83 microdelay(int us)
   84 {
   85         uvlong eot;
   86 
   87         eot = fastticks(nil) + (m->cpuhz/1000000)*us;
   88         while(fastticks(nil) < eot)
   89                 ;
   90 }
   91 
   92 void
   93 delay(int millisecs)
   94 {
   95         microdelay(millisecs*1000);
   96 }
   97 
   98 void
   99 clock(Ureg *ureg)
  100 {
  101         static int count;
  102 
  103         cycletimer();
  104 
  105         /* HZ == 100, timer == 1024Hz.  error < 1ms */
  106         count += 100;
  107         if (count < 1024)
  108                 return;
  109         count -= 1024;
  110 
  111         timerintr(ureg, 0);
  112 }

Cache object: 52d0a7c651d27e31a2c8c5e71832e28a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.