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/ppc/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        "io.h"
    6 #include        "fns.h"
    7 #include        "ureg.h"
    8 
    9 static  ulong   clkreload;
   10 
   11 void
   12 delayloopinit(void)
   13 {
   14         ulong v;
   15         uvlong x;
   16 
   17         /* initial value for loopconst set in machinit */
   18         m->loopconst = 1000;
   19         v = getdec();
   20         delay(1000);
   21         v -= getdec();
   22 
   23         x = m->loopconst;
   24         x *= m->dechz;
   25         x /= v;
   26         m->loopconst = x;
   27 }
   28 
   29 void
   30 clockinit(void)
   31 {
   32         m->dechz = m->bushz/4;  /* true for all 604e */
   33         m->tbhz = m->dechz;     /* conjecture; manual doesn't say */
   34 
   35         delayloopinit();
   36 
   37         clkreload = m->dechz/HZ-1;
   38         putdec(clkreload);
   39 }
   40 
   41 void
   42 clockintr(Ureg *)
   43 {
   44         long v;
   45 
   46         v = -getdec();
   47         if(v > (clkreload >> 1)){
   48                 if(v > clkreload)
   49                         m->ticks += v/clkreload;
   50                 v = 0;
   51         }
   52         putdec(clkreload-v);
   53 }
   54 
   55 void
   56 delay(int l)
   57 {
   58         ulong i, j;
   59 
   60         j = 0;
   61         if(m)
   62                 j = m->loopconst;
   63         if(j == 0)
   64                 j = 1096;
   65         while(l-- > 0)
   66                 for(i=0; i < j; i++)
   67                         ;
   68 }
   69 
   70 void
   71 microdelay(int l)
   72 {
   73         ulong i;
   74 
   75         l *= m->loopconst;
   76         l += 500;
   77         l /= 1000;
   78         if(l <= 0)
   79                 l = 1;
   80         for(i = 0; i < l; i++)
   81                 ;
   82 }
   83 
   84 ulong
   85 perfticks(void)
   86 {
   87         return (ulong)fastticks(nil);
   88 }

Cache object: fc91808bc630d2ca802f544138748fd2


[ 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.