root / hw / hpet_emul.h @ 94a943ef
History | View | Annotate | Download (2.5 kB)
1 | 16b29ae1 | aliguori | /*
|
---|---|---|---|
2 | 16b29ae1 | aliguori | * QEMU Emulated HPET support
|
3 | 16b29ae1 | aliguori | *
|
4 | 16b29ae1 | aliguori | * Copyright IBM, Corp. 2008
|
5 | 16b29ae1 | aliguori | *
|
6 | 16b29ae1 | aliguori | * Authors:
|
7 | 16b29ae1 | aliguori | * Beth Kon <bkon@us.ibm.com>
|
8 | 16b29ae1 | aliguori | *
|
9 | 16b29ae1 | aliguori | * This work is licensed under the terms of the GNU GPL, version 2. See
|
10 | 16b29ae1 | aliguori | * the COPYING file in the top-level directory.
|
11 | 16b29ae1 | aliguori | *
|
12 | 16b29ae1 | aliguori | */
|
13 | 16b29ae1 | aliguori | #ifndef QEMU_HPET_EMUL_H
|
14 | 16b29ae1 | aliguori | #define QEMU_HPET_EMUL_H
|
15 | 16b29ae1 | aliguori | |
16 | 16b29ae1 | aliguori | #define HPET_BASE 0xfed00000 |
17 | 16b29ae1 | aliguori | #define HPET_CLK_PERIOD 10000000ULL /* 10000000 femtoseconds == 10ns*/ |
18 | 16b29ae1 | aliguori | |
19 | 16b29ae1 | aliguori | #define FS_PER_NS 1000000 |
20 | 16b29ae1 | aliguori | #define HPET_NUM_TIMERS 3 |
21 | ce536cfd | Beth Kon | #define HPET_TIMER_TYPE_LEVEL 0x002 |
22 | 16b29ae1 | aliguori | |
23 | 16b29ae1 | aliguori | #define HPET_CFG_ENABLE 0x001 |
24 | 16b29ae1 | aliguori | #define HPET_CFG_LEGACY 0x002 |
25 | 16b29ae1 | aliguori | |
26 | 16b29ae1 | aliguori | #define HPET_ID 0x000 |
27 | 16b29ae1 | aliguori | #define HPET_PERIOD 0x004 |
28 | 16b29ae1 | aliguori | #define HPET_CFG 0x010 |
29 | 16b29ae1 | aliguori | #define HPET_STATUS 0x020 |
30 | 16b29ae1 | aliguori | #define HPET_COUNTER 0x0f0 |
31 | 16b29ae1 | aliguori | #define HPET_TN_CFG 0x000 |
32 | 16b29ae1 | aliguori | #define HPET_TN_CMP 0x008 |
33 | 16b29ae1 | aliguori | #define HPET_TN_ROUTE 0x010 |
34 | 35730fa0 | aurel32 | #define HPET_CFG_WRITE_MASK 0x3 |
35 | 16b29ae1 | aliguori | |
36 | 16b29ae1 | aliguori | |
37 | 16b29ae1 | aliguori | #define HPET_TN_ENABLE 0x004 |
38 | 16b29ae1 | aliguori | #define HPET_TN_PERIODIC 0x008 |
39 | 16b29ae1 | aliguori | #define HPET_TN_PERIODIC_CAP 0x010 |
40 | 16b29ae1 | aliguori | #define HPET_TN_SIZE_CAP 0x020 |
41 | 16b29ae1 | aliguori | #define HPET_TN_SETVAL 0x040 |
42 | 16b29ae1 | aliguori | #define HPET_TN_32BIT 0x100 |
43 | 16b29ae1 | aliguori | #define HPET_TN_INT_ROUTE_MASK 0x3e00 |
44 | 35730fa0 | aurel32 | #define HPET_TN_CFG_WRITE_MASK 0x3f4e |
45 | 16b29ae1 | aliguori | #define HPET_TN_INT_ROUTE_SHIFT 9 |
46 | 16b29ae1 | aliguori | #define HPET_TN_INT_ROUTE_CAP_SHIFT 32 |
47 | 16b29ae1 | aliguori | #define HPET_TN_CFG_BITS_READONLY_OR_RESERVED 0xffff80b1U |
48 | 16b29ae1 | aliguori | |
49 | 16b29ae1 | aliguori | struct HPETState;
|
50 | 16b29ae1 | aliguori | typedef struct HPETTimer { /* timers */ |
51 | 16b29ae1 | aliguori | uint8_t tn; /*timer number*/
|
52 | 16b29ae1 | aliguori | QEMUTimer *qemu_timer; |
53 | 16b29ae1 | aliguori | struct HPETState *state;
|
54 | 16b29ae1 | aliguori | /* Memory-mapped, software visible timer registers */
|
55 | 16b29ae1 | aliguori | uint64_t config; /* configuration/cap */
|
56 | 16b29ae1 | aliguori | uint64_t cmp; /* comparator */
|
57 | 16b29ae1 | aliguori | uint64_t fsb; /* FSB route, not supported now */
|
58 | 16b29ae1 | aliguori | /* Hidden register state */
|
59 | 16b29ae1 | aliguori | uint64_t period; /* Last value written to comparator */
|
60 | c50c2d68 | aurel32 | uint8_t wrap_flag; /* timer pop will indicate wrap for one-shot 32-bit
|
61 | 16b29ae1 | aliguori | * mode. Next pop will be actual timer expiration.
|
62 | c50c2d68 | aurel32 | */
|
63 | 16b29ae1 | aliguori | } HPETTimer; |
64 | 16b29ae1 | aliguori | |
65 | 16b29ae1 | aliguori | typedef struct HPETState { |
66 | 16b29ae1 | aliguori | uint64_t hpet_offset; |
67 | 16b29ae1 | aliguori | qemu_irq *irqs; |
68 | 16b29ae1 | aliguori | HPETTimer timer[HPET_NUM_TIMERS]; |
69 | 16b29ae1 | aliguori | |
70 | 16b29ae1 | aliguori | /* Memory-mapped, software visible registers */
|
71 | 16b29ae1 | aliguori | uint64_t capability; /* capabilities */
|
72 | 16b29ae1 | aliguori | uint64_t config; /* configuration */
|
73 | 16b29ae1 | aliguori | uint64_t isr; /* interrupt status reg */
|
74 | 16b29ae1 | aliguori | uint64_t hpet_counter; /* main counter */
|
75 | 16b29ae1 | aliguori | } HPETState; |
76 | 16b29ae1 | aliguori | |
77 | 16b29ae1 | aliguori | #if defined TARGET_I386 || defined TARGET_X86_64
|
78 | 16b29ae1 | aliguori | extern uint32_t hpet_in_legacy_mode(void); |
79 | 16b29ae1 | aliguori | extern void hpet_init(qemu_irq *irq); |
80 | 16b29ae1 | aliguori | #endif
|
81 | 16b29ae1 | aliguori | |
82 | 16b29ae1 | aliguori | #endif |