1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifndef QEMU_I8254_INTERNAL_H
26#define QEMU_I8254_INTERNAL_H
27
28#include "hw/hw.h"
29#include "hw/i386/pc.h"
30#include "hw/isa/isa.h"
31
32typedef struct PITChannelState {
33 int count;
34 uint16_t latched_count;
35 uint8_t count_latched;
36 uint8_t status_latched;
37 uint8_t status;
38 uint8_t read_state;
39 uint8_t write_state;
40 uint8_t write_latch;
41 uint8_t rw_mode;
42 uint8_t mode;
43 uint8_t bcd;
44 uint8_t gate;
45 int64_t count_load_time;
46
47 int64_t next_transition_time;
48 QEMUTimer *irq_timer;
49 qemu_irq irq;
50 uint32_t irq_disabled;
51} PITChannelState;
52
53typedef struct PITCommonState {
54 ISADevice dev;
55 MemoryRegion ioports;
56 uint32_t iobase;
57 PITChannelState channels[3];
58} PITCommonState;
59
60#define TYPE_PIT_COMMON "pit-common"
61#define PIT_COMMON(obj) \
62 OBJECT_CHECK(PITCommonState, (obj), TYPE_PIT_COMMON)
63#define PIT_COMMON_CLASS(klass) \
64 OBJECT_CLASS_CHECK(PITCommonClass, (klass), TYPE_PIT_COMMON)
65#define PIT_COMMON_GET_CLASS(obj) \
66 OBJECT_GET_CLASS(PITCommonClass, (obj), TYPE_PIT_COMMON)
67
68typedef struct PITCommonClass {
69 ISADeviceClass parent_class;
70
71 void (*set_channel_gate)(PITCommonState *s, PITChannelState *sc, int val);
72 void (*get_channel_info)(PITCommonState *s, PITChannelState *sc,
73 PITChannelInfo *info);
74 void (*pre_save)(PITCommonState *s);
75 void (*post_load)(PITCommonState *s);
76} PITCommonClass;
77
78int pit_get_out(PITChannelState *s, int64_t current_time);
79int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time);
80void pit_get_channel_info_common(PITCommonState *s, PITChannelState *sc,
81 PITChannelInfo *info);
82void pit_reset_common(PITCommonState *s);
83
84#endif
85