178 |
/* current counter value */ |
/* current counter value */ |
179 |
d = muldiv64(current_time - s->load_time, |
d = muldiv64(current_time - s->load_time, |
180 |
CUDA_TIMER_FREQ, ticks_per_sec); |
CUDA_TIMER_FREQ, ticks_per_sec); |
181 |
if (d <= s->counter_value) { |
if (d < s->counter_value) { |
182 |
next_time = s->counter_value + 1; |
next_time = s->counter_value + 1; |
183 |
} else { |
} else |
184 |
base = ((d - s->counter_value) / s->latch); |
{ |
185 |
|
base = ((d - s->counter_value + 1) / s->latch); |
186 |
base = (base * s->latch) + s->counter_value; |
base = (base * s->latch) + s->counter_value; |
187 |
next_time = base + s->latch; |
next_time = base + s->latch; |
188 |
} |
} |
189 |
|
#if 0 |
190 |
#ifdef DEBUG_CUDA |
#ifdef DEBUG_CUDA |
191 |
printf("latch=%d counter=%lld delta_next=%lld\n", |
printf("latch=%d counter=%lld delta_next=%lld\n", |
192 |
s->latch, d, next_time - d); |
s->latch, d, next_time - d); |
193 |
#endif |
#endif |
194 |
|
#endif |
195 |
next_time = muldiv64(next_time, ticks_per_sec, CUDA_TIMER_FREQ) + |
next_time = muldiv64(next_time, ticks_per_sec, CUDA_TIMER_FREQ) + |
196 |
s->load_time; |
s->load_time; |
197 |
if (next_time <= current_time) |
if (next_time <= current_time) |
508 |
cuda_send_packet_to_host(s, obuf, 2); |
cuda_send_packet_to_host(s, obuf, 2); |
509 |
break; |
break; |
510 |
case CUDA_GET_TIME: |
case CUDA_GET_TIME: |
511 |
|
case CUDA_SET_TIME: |
512 |
/* XXX: add time support ? */ |
/* XXX: add time support ? */ |
513 |
ti = time(NULL) + RTC_OFFSET; |
ti = time(NULL) + RTC_OFFSET; |
514 |
obuf[0] = CUDA_PACKET; |
obuf[0] = CUDA_PACKET; |
520 |
obuf[6] = ti; |
obuf[6] = ti; |
521 |
cuda_send_packet_to_host(s, obuf, 7); |
cuda_send_packet_to_host(s, obuf, 7); |
522 |
break; |
break; |
|
case CUDA_SET_TIME: |
|
523 |
case CUDA_FILE_SERVER_FLAG: |
case CUDA_FILE_SERVER_FLAG: |
524 |
case CUDA_SET_DEVICE_LIST: |
case CUDA_SET_DEVICE_LIST: |
525 |
case CUDA_SET_AUTO_RATE: |
case CUDA_SET_AUTO_RATE: |