Changeset 1972

Show
Ignore:
Timestamp:
04/09/08 22:55:17 (8 months ago)
Author:
aturner
Message:

writing to the ioport is complex enough it prolly doesn't belong full bore in
the header. refs #41

Location:
features/performance/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • features/performance/src/sleep.c

    r1970 r1972  
    6464} 
    6565 
     66void  
     67ioport_sleep(const struct timespec nap)  
     68{ 
     69    struct timeval nap_for; 
     70    u_int32_t usec; 
     71    time_t i; 
     72     
     73    TIMESPEC_TO_TIMEVAL(&nap_for, &nap); 
     74     
     75    /*  
     76     * process the seconds, we do this in a loop so we don't have to  
     77     * use slower 64bit integers or worry about integer overflows. 
     78     */ 
     79    for (i = 0; i < nap_for.tv_sec; i ++) { 
     80        usec = SEC_TO_MICROSEC(nap_for.tv_sec); 
     81        while (usec > 0) { 
     82            usec --; 
     83            outb(ioport_sleep_value, 0x80); 
     84        } 
     85    } 
     86     
     87    /* process the usec */ 
     88    usec = nap.tv_nsec / 1000; 
     89    usec --; /* fudge factor for all the above */ 
     90    while (usec > 0) { 
     91        usec --; 
     92        outb(ioport_sleep_value, 0x80); 
     93    } 
     94} 
  • features/performance/src/sleep.h

    r1971 r1972  
    8787 
    8888/*  
    89  * Not sure if this is any better then a gettimeofday() loop, but  
    90  * in order to find out, nap needs to be a timespec (nanosec precision) 
     89 * Apple's AbsoluteTime functions give at least .1usec precision 
     90 * which is pretty damn sweet 
    9191 */ 
    9292static inline void 
     
    140140void ioport_sleep_init(void); 
    141141 
    142 static inline void  
    143 ioport_sleep(const struct timespec nap)  
    144 { 
    145     struct timeval nap_for; 
    146     u_int32_t usec; 
    147     time_t i; 
    148      
    149     TIMESPEC_TO_TIMEVAL(&nap_for, &nap); 
    150      
    151     /*  
    152      * process the seconds, we do this in a loop so we don't have to  
    153      * use slower 64bit integers or worry about integer overflows. 
    154      */ 
    155     for (i = 0; i < nap_for.tv_sec; i ++) { 
    156         usec = SEC_TO_MICROSEC(nap_for.tv_sec); 
    157         while (usec > 0) { 
    158             usec --; 
    159             outb(ioport_sleep_value, 0x80); 
    160         } 
    161     } 
    162      
    163     /* process the usec */ 
    164     usec = nap.tv_nsec / 1000; 
    165     usec --; /* fudge factor for all the above */ 
    166     while (usec > 0) { 
    167         usec --; 
    168         outb(ioport_sleep_value, 0x80); 
    169     } 
    170 } 
     142void ioport_sleep(const struct timespec nap); 
    171143 
    172144#endif /* __SLEEP_H__ */