root / hw / acpi.h @ 0c90c52f
History | View | Annotate | Download (4.7 kB)
1 | 990b150e | Isaku Yamahata | #ifndef QEMU_HW_ACPI_H
|
---|---|---|---|
2 | 990b150e | Isaku Yamahata | #define QEMU_HW_ACPI_H
|
3 | 990b150e | Isaku Yamahata | /*
|
4 | 990b150e | Isaku Yamahata | * Copyright (c) 2009 Isaku Yamahata <yamahata at valinux co jp>
|
5 | 990b150e | Isaku Yamahata | * VA Linux Systems Japan K.K.
|
6 | 990b150e | Isaku Yamahata | *
|
7 | 990b150e | Isaku Yamahata | * This library is free software; you can redistribute it and/or
|
8 | 990b150e | Isaku Yamahata | * modify it under the terms of the GNU Lesser General Public
|
9 | 990b150e | Isaku Yamahata | * License as published by the Free Software Foundation; either
|
10 | 990b150e | Isaku Yamahata | * version 2 of the License, or (at your option) any later version.
|
11 | 990b150e | Isaku Yamahata | *
|
12 | 990b150e | Isaku Yamahata | * This library is distributed in the hope that it will be useful,
|
13 | 990b150e | Isaku Yamahata | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | 990b150e | Isaku Yamahata | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 | 990b150e | Isaku Yamahata | * Lesser General Public License for more details.
|
16 | 990b150e | Isaku Yamahata | *
|
17 | 990b150e | Isaku Yamahata | * You should have received a copy of the GNU Lesser General Public
|
18 | 1012e960 | Blue Swirl | * License along with this library; if not, see
|
19 | 1012e960 | Blue Swirl | * <http://www.gnu.org/licenses/>.
|
20 | 990b150e | Isaku Yamahata | */
|
21 | 990b150e | Isaku Yamahata | |
22 | 990b150e | Isaku Yamahata | /* from linux include/acpi/actype.h */
|
23 | 990b150e | Isaku Yamahata | /* Default ACPI register widths */
|
24 | 990b150e | Isaku Yamahata | |
25 | 990b150e | Isaku Yamahata | #define ACPI_GPE_REGISTER_WIDTH 8 |
26 | 990b150e | Isaku Yamahata | #define ACPI_PM1_REGISTER_WIDTH 16 |
27 | 990b150e | Isaku Yamahata | #define ACPI_PM2_REGISTER_WIDTH 8 |
28 | 990b150e | Isaku Yamahata | #define ACPI_PM_TIMER_WIDTH 32 |
29 | 990b150e | Isaku Yamahata | |
30 | 990b150e | Isaku Yamahata | /* PM Timer ticks per second (HZ) */
|
31 | 990b150e | Isaku Yamahata | #define PM_TIMER_FREQUENCY 3579545 |
32 | 990b150e | Isaku Yamahata | |
33 | 990b150e | Isaku Yamahata | |
34 | 990b150e | Isaku Yamahata | /* ACPI fixed hardware registers */
|
35 | 990b150e | Isaku Yamahata | |
36 | 990b150e | Isaku Yamahata | /* from linux/drivers/acpi/acpica/aclocal.h */
|
37 | 990b150e | Isaku Yamahata | /* Masks used to access the bit_registers */
|
38 | 990b150e | Isaku Yamahata | |
39 | 990b150e | Isaku Yamahata | /* PM1x_STS */
|
40 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_TIMER_STATUS 0x0001 |
41 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010 |
42 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020 |
43 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 |
44 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 |
45 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 |
46 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ |
47 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_WAKE_STATUS 0x8000 |
48 | 990b150e | Isaku Yamahata | |
49 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_ALL_FIXED_STATUS (\
|
50 | 990b150e | Isaku Yamahata | ACPI_BITMASK_TIMER_STATUS | \ |
51 | 990b150e | Isaku Yamahata | ACPI_BITMASK_BUS_MASTER_STATUS | \ |
52 | 990b150e | Isaku Yamahata | ACPI_BITMASK_GLOBAL_LOCK_STATUS | \ |
53 | 990b150e | Isaku Yamahata | ACPI_BITMASK_POWER_BUTTON_STATUS | \ |
54 | 990b150e | Isaku Yamahata | ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ |
55 | 990b150e | Isaku Yamahata | ACPI_BITMASK_RT_CLOCK_STATUS | \ |
56 | 990b150e | Isaku Yamahata | ACPI_BITMASK_WAKE_STATUS) |
57 | 990b150e | Isaku Yamahata | |
58 | 990b150e | Isaku Yamahata | /* PM1x_EN */
|
59 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_TIMER_ENABLE 0x0001 |
60 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020 |
61 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 |
62 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 |
63 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 |
64 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ |
65 | 990b150e | Isaku Yamahata | |
66 | 990b150e | Isaku Yamahata | /* PM1x_CNT */
|
67 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_SCI_ENABLE 0x0001 |
68 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 |
69 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 |
70 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_SLEEP_TYPE 0x1C00 |
71 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_SLEEP_ENABLE 0x2000 |
72 | 990b150e | Isaku Yamahata | |
73 | 990b150e | Isaku Yamahata | /* PM2_CNT */
|
74 | 990b150e | Isaku Yamahata | #define ACPI_BITMASK_ARB_DISABLE 0x0001 |
75 | 990b150e | Isaku Yamahata | |
76 | 990b150e | Isaku Yamahata | /* PM_TMR */
|
77 | a54d41a8 | Isaku Yamahata | struct ACPIPMTimer;
|
78 | a54d41a8 | Isaku Yamahata | typedef struct ACPIPMTimer ACPIPMTimer; |
79 | a54d41a8 | Isaku Yamahata | |
80 | a54d41a8 | Isaku Yamahata | typedef void (*acpi_update_sci_fn)(ACPIPMTimer *tmr); |
81 | a54d41a8 | Isaku Yamahata | |
82 | a54d41a8 | Isaku Yamahata | struct ACPIPMTimer {
|
83 | a54d41a8 | Isaku Yamahata | QEMUTimer *timer; |
84 | a54d41a8 | Isaku Yamahata | int64_t overflow_time; |
85 | a54d41a8 | Isaku Yamahata | |
86 | a54d41a8 | Isaku Yamahata | acpi_update_sci_fn update_sci; |
87 | a54d41a8 | Isaku Yamahata | }; |
88 | a54d41a8 | Isaku Yamahata | |
89 | a54d41a8 | Isaku Yamahata | void acpi_pm_tmr_update(ACPIPMTimer *tmr, bool enable); |
90 | a54d41a8 | Isaku Yamahata | void acpi_pm_tmr_calc_overflow_time(ACPIPMTimer *tmr);
|
91 | a54d41a8 | Isaku Yamahata | uint32_t acpi_pm_tmr_get(ACPIPMTimer *tmr); |
92 | a54d41a8 | Isaku Yamahata | void acpi_pm_tmr_init(ACPIPMTimer *tmr, acpi_update_sci_fn update_sci);
|
93 | a54d41a8 | Isaku Yamahata | void acpi_pm_tmr_reset(ACPIPMTimer *tmr);
|
94 | a54d41a8 | Isaku Yamahata | |
95 | a54d41a8 | Isaku Yamahata | #include "qemu-timer.h" |
96 | a54d41a8 | Isaku Yamahata | static inline int64_t acpi_pm_tmr_get_clock(void) |
97 | a54d41a8 | Isaku Yamahata | { |
98 | a54d41a8 | Isaku Yamahata | return muldiv64(qemu_get_clock_ns(vm_clock), PM_TIMER_FREQUENCY,
|
99 | a54d41a8 | Isaku Yamahata | get_ticks_per_sec()); |
100 | a54d41a8 | Isaku Yamahata | } |
101 | 990b150e | Isaku Yamahata | |
102 | 04dc308f | Isaku Yamahata | /* PM1a_EVT: piix and ich9 don't implement PM1b. */
|
103 | 04dc308f | Isaku Yamahata | struct ACPIPM1EVT
|
104 | 04dc308f | Isaku Yamahata | { |
105 | 04dc308f | Isaku Yamahata | uint16_t sts; |
106 | 04dc308f | Isaku Yamahata | uint16_t en; |
107 | 04dc308f | Isaku Yamahata | }; |
108 | 04dc308f | Isaku Yamahata | typedef struct ACPIPM1EVT ACPIPM1EVT; |
109 | 04dc308f | Isaku Yamahata | |
110 | 04dc308f | Isaku Yamahata | uint16_t acpi_pm1_evt_get_sts(ACPIPM1EVT *pm1, int64_t overflow_time); |
111 | 04dc308f | Isaku Yamahata | void acpi_pm1_evt_write_sts(ACPIPM1EVT *pm1, ACPIPMTimer *tmr, uint16_t val);
|
112 | 04dc308f | Isaku Yamahata | void acpi_pm1_evt_power_down(ACPIPM1EVT *pm1, ACPIPMTimer *tmr);
|
113 | 04dc308f | Isaku Yamahata | void acpi_pm1_evt_reset(ACPIPM1EVT *pm1);
|
114 | 04dc308f | Isaku Yamahata | |
115 | eaba51c5 | Isaku Yamahata | /* PM1a_CNT: piix and ich9 don't implement PM1b CNT. */
|
116 | eaba51c5 | Isaku Yamahata | struct ACPIPM1CNT {
|
117 | eaba51c5 | Isaku Yamahata | uint16_t cnt; |
118 | eaba51c5 | Isaku Yamahata | |
119 | eaba51c5 | Isaku Yamahata | qemu_irq cmos_s3; |
120 | eaba51c5 | Isaku Yamahata | }; |
121 | eaba51c5 | Isaku Yamahata | typedef struct ACPIPM1CNT ACPIPM1CNT; |
122 | eaba51c5 | Isaku Yamahata | |
123 | eaba51c5 | Isaku Yamahata | void acpi_pm1_cnt_init(ACPIPM1CNT *pm1_cnt, qemu_irq cmos_s3);
|
124 | eaba51c5 | Isaku Yamahata | void acpi_pm1_cnt_write(ACPIPM1EVT *pm1a, ACPIPM1CNT *pm1_cnt, uint16_t val);
|
125 | eaba51c5 | Isaku Yamahata | void acpi_pm1_cnt_update(ACPIPM1CNT *pm1_cnt,
|
126 | eaba51c5 | Isaku Yamahata | bool sci_enable, bool sci_disable); |
127 | eaba51c5 | Isaku Yamahata | void acpi_pm1_cnt_reset(ACPIPM1CNT *pm1_cnt);
|
128 | eaba51c5 | Isaku Yamahata | |
129 | 23910d3f | Isaku Yamahata | /* GPE0 */
|
130 | 23910d3f | Isaku Yamahata | struct ACPIGPE {
|
131 | 23910d3f | Isaku Yamahata | uint32_t blk; |
132 | 23910d3f | Isaku Yamahata | uint8_t len; |
133 | 23910d3f | Isaku Yamahata | |
134 | 23910d3f | Isaku Yamahata | uint8_t *sts; |
135 | 23910d3f | Isaku Yamahata | uint8_t *en; |
136 | 23910d3f | Isaku Yamahata | }; |
137 | 23910d3f | Isaku Yamahata | typedef struct ACPIGPE ACPIGPE; |
138 | 23910d3f | Isaku Yamahata | |
139 | 23910d3f | Isaku Yamahata | void acpi_gpe_init(ACPIGPE *gpe, uint8_t len);
|
140 | 23910d3f | Isaku Yamahata | void acpi_gpe_blk(ACPIGPE *gpe, uint32_t blk);
|
141 | 23910d3f | Isaku Yamahata | void acpi_gpe_reset(ACPIGPE *gpe);
|
142 | 23910d3f | Isaku Yamahata | |
143 | 23910d3f | Isaku Yamahata | void acpi_gpe_ioport_writeb(ACPIGPE *gpe, uint32_t addr, uint32_t val);
|
144 | 23910d3f | Isaku Yamahata | uint32_t acpi_gpe_ioport_readb(ACPIGPE *gpe, uint32_t addr); |
145 | 23910d3f | Isaku Yamahata | |
146 | 990b150e | Isaku Yamahata | #endif /* !QEMU_HW_ACPI_H */ |