summaryrefslogtreecommitdiff
path: root/hw/cuda.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-04-23 18:16:54 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-04-23 18:16:54 +0000
commitdccfafc4e1325dbf90d8ee7b2bc56e6e02eaf4b5 (patch)
tree9f5887ef075010e7a6e6c2b6cafee5731da78bec /hw/cuda.c
parent111bfab3b5c6a47a7182e095647e6a5e0e17feb8 (diff)
This patch fixes two bugs in cuda emulation:
- the CUDA timer is always triggered twice, with current code - SET_TIME command is supposed to send back a 7 bytes packet (Jocelyn Mayer) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1380 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/cuda.c')
-rw-r--r--hw/cuda.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/hw/cuda.c b/hw/cuda.c
index b196862805..7eea0421c5 100644
--- a/hw/cuda.c
+++ b/hw/cuda.c
@@ -178,17 +178,20 @@ static int64_t get_next_irq_time(CUDATimer *s, int64_t current_time)
/* current counter value */
d = muldiv64(current_time - s->load_time,
CUDA_TIMER_FREQ, ticks_per_sec);
- if (d <= s->counter_value) {
+ if (d < s->counter_value) {
next_time = s->counter_value + 1;
- } else {
- base = ((d - s->counter_value) / s->latch);
+ } else
+ {
+ base = ((d - s->counter_value + 1) / s->latch);
base = (base * s->latch) + s->counter_value;
next_time = base + s->latch;
}
+#if 0
#ifdef DEBUG_CUDA
printf("latch=%d counter=%lld delta_next=%lld\n",
s->latch, d, next_time - d);
#endif
+#endif
next_time = muldiv64(next_time, ticks_per_sec, CUDA_TIMER_FREQ) +
s->load_time;
if (next_time <= current_time)
@@ -505,6 +508,7 @@ static void cuda_receive_packet(CUDAState *s,
cuda_send_packet_to_host(s, obuf, 2);
break;
case CUDA_GET_TIME:
+ case CUDA_SET_TIME:
/* XXX: add time support ? */
ti = time(NULL) + RTC_OFFSET;
obuf[0] = CUDA_PACKET;
@@ -516,7 +520,6 @@ static void cuda_receive_packet(CUDAState *s,
obuf[6] = ti;
cuda_send_packet_to_host(s, obuf, 7);
break;
- case CUDA_SET_TIME:
case CUDA_FILE_SERVER_FLAG:
case CUDA_SET_DEVICE_LIST:
case CUDA_SET_AUTO_RATE: