Commit dccfafc4e1325dbf90d8ee7b2bc56e6e02eaf4b5
1 parent
111bfab3
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
Showing
1 changed file
with
7 additions
and
4 deletions
hw/cuda.c
| ... | ... | @@ -178,17 +178,20 @@ static int64_t get_next_irq_time(CUDATimer *s, int64_t current_time) |
| 178 | 178 | /* current counter value */ |
| 179 | 179 | d = muldiv64(current_time - s->load_time, |
| 180 | 180 | CUDA_TIMER_FREQ, ticks_per_sec); |
| 181 | - if (d <= s->counter_value) { | |
| 181 | + if (d < s->counter_value) { | |
| 182 | 182 | next_time = s->counter_value + 1; |
| 183 | - } else { | |
| 184 | - base = ((d - s->counter_value) / s->latch); | |
| 183 | + } else | |
| 184 | + { | |
| 185 | + base = ((d - s->counter_value + 1) / s->latch); | |
| 185 | 186 | base = (base * s->latch) + s->counter_value; |
| 186 | 187 | next_time = base + s->latch; |
| 187 | 188 | } |
| 189 | +#if 0 | |
| 188 | 190 | #ifdef DEBUG_CUDA |
| 189 | 191 | printf("latch=%d counter=%lld delta_next=%lld\n", |
| 190 | 192 | s->latch, d, next_time - d); |
| 191 | 193 | #endif |
| 194 | +#endif | |
| 192 | 195 | next_time = muldiv64(next_time, ticks_per_sec, CUDA_TIMER_FREQ) + |
| 193 | 196 | s->load_time; |
| 194 | 197 | if (next_time <= current_time) |
| ... | ... | @@ -505,6 +508,7 @@ static void cuda_receive_packet(CUDAState *s, |
| 505 | 508 | cuda_send_packet_to_host(s, obuf, 2); |
| 506 | 509 | break; |
| 507 | 510 | case CUDA_GET_TIME: |
| 511 | + case CUDA_SET_TIME: | |
| 508 | 512 | /* XXX: add time support ? */ |
| 509 | 513 | ti = time(NULL) + RTC_OFFSET; |
| 510 | 514 | obuf[0] = CUDA_PACKET; |
| ... | ... | @@ -516,7 +520,6 @@ static void cuda_receive_packet(CUDAState *s, |
| 516 | 520 | obuf[6] = ti; |
| 517 | 521 | cuda_send_packet_to_host(s, obuf, 7); |
| 518 | 522 | break; |
| 519 | - case CUDA_SET_TIME: | |
| 520 | 523 | case CUDA_FILE_SERVER_FLAG: |
| 521 | 524 | case CUDA_SET_DEVICE_LIST: |
| 522 | 525 | case CUDA_SET_AUTO_RATE: | ... | ... |