Revision 5fafdf24 hw/i8254.c
b/hw/i8254.c | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* QEMU 8253/8254 interval timer emulation |
3 |
*
|
|
3 |
* |
|
4 | 4 |
* Copyright (c) 2003-2004 Fabrice Bellard |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | 7 |
* of this software and associated documentation files (the "Software"), to deal |
8 | 8 |
* in the Software without restriction, including without limitation the rights |
... | ... | |
121 | 121 |
} |
122 | 122 |
|
123 | 123 |
/* return -1 if no transition will occur. */ |
124 |
static int64_t pit_get_next_transition_time(PITChannelState *s,
|
|
124 |
static int64_t pit_get_next_transition_time(PITChannelState *s, |
|
125 | 125 |
int64_t current_time) |
126 | 126 |
{ |
127 | 127 |
uint64_t d, next_time, base; |
... | ... | |
147 | 147 |
case 3: |
148 | 148 |
base = (d / s->count) * s->count; |
149 | 149 |
period2 = ((s->count + 1) >> 1); |
150 |
if ((d - base) < period2)
|
|
150 |
if ((d - base) < period2) |
|
151 | 151 |
next_time = base + period2; |
152 | 152 |
else |
153 | 153 |
next_time = base + s->count; |
... | ... | |
309 | 309 |
PITState *pit = opaque; |
310 | 310 |
int ret, count; |
311 | 311 |
PITChannelState *s; |
312 |
|
|
312 |
|
|
313 | 313 |
addr &= 3; |
314 | 314 |
s = &pit->channels[addr]; |
315 | 315 |
if (s->status_latched) { |
... | ... | |
369 | 369 |
qemu_set_irq(s->irq, irq_level); |
370 | 370 |
#ifdef DEBUG_PIT |
371 | 371 |
printf("irq_level=%d next_delay=%f\n", |
372 |
irq_level,
|
|
372 |
irq_level, |
|
373 | 373 |
(double)(expire_time - current_time) / ticks_per_sec); |
374 | 374 |
#endif |
375 | 375 |
s->next_transition_time = expire_time; |
... | ... | |
391 | 391 |
PITState *pit = opaque; |
392 | 392 |
PITChannelState *s; |
393 | 393 |
int i; |
394 |
|
|
394 |
|
|
395 | 395 |
for(i = 0; i < 3; i++) { |
396 | 396 |
s = &pit->channels[i]; |
397 | 397 |
qemu_put_be32s(f, &s->count); |
... | ... | |
419 | 419 |
PITState *pit = opaque; |
420 | 420 |
PITChannelState *s; |
421 | 421 |
int i; |
422 |
|
|
422 |
|
|
423 | 423 |
if (version_id != 1) |
424 | 424 |
return -EINVAL; |
425 | 425 |
|
Also available in: Unified diff