Fix 32-bit overflow in parallels image support
[qemu-kvm/fedora.git] / hw / i8254.h
blobd23303a8b3fc28df0dc815c5b7dd8239ce049fb0
1 /*
2 * QEMU 8253/8254 interval timer emulation
4 * Copyright (c) 2003-2004 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 #ifndef QEMU_I8254_H
26 #define QEMU_I8254_H
28 #define PIT_SAVEVM_NAME "i8254"
29 #define PIT_SAVEVM_VERSION 2
31 #define RW_STATE_LSB 1
32 #define RW_STATE_MSB 2
33 #define RW_STATE_WORD0 3
34 #define RW_STATE_WORD1 4
36 #define PIT_FLAGS_HPET_LEGACY 1
38 typedef struct PITChannelState {
39 int count; /* can be 65536 */
40 uint16_t latched_count;
41 uint8_t count_latched;
42 uint8_t status_latched;
43 uint8_t status;
44 uint8_t read_state;
45 uint8_t write_state;
46 uint8_t write_latch;
47 uint8_t rw_mode;
48 uint8_t mode;
49 uint8_t bcd; /* not supported */
50 uint8_t gate; /* timer start */
51 int64_t count_load_time;
52 /* irq handling */
53 int64_t next_transition_time;
54 QEMUTimer *irq_timer;
55 qemu_irq irq;
56 } PITChannelState;
58 struct PITState {
59 PITChannelState channels[3];
60 uint32_t flags;
63 void pit_save(QEMUFile *f, void *opaque);
65 int pit_load(QEMUFile *f, void *opaque, int version_id);
67 void pit_reset(void *opaque);
69 #endif