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
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
;
49 uint8_t bcd
; /* not supported */
50 uint8_t gate
; /* timer start */
51 int64_t count_load_time
;
53 int64_t next_transition_time
;
62 PITChannelState channels
[3];
66 void pit_save(QEMUFile
*f
, void *opaque
);
68 int pit_load(QEMUFile
*f
, void *opaque
, int version_id
);
70 typedef struct PITState PITState
;
73 void kvm_pit_init(PITState
*pit
);