Revision 04762841
b/Makefile.target | ||
---|---|---|
195 | 195 |
obj-i386-y += vmmouse.o vmport.o hpet.o |
196 | 196 |
obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o |
197 | 197 |
obj-i386-y += debugcon.o multiboot.o |
198 |
obj-i386-y += pm_smbus.o |
|
198 |
obj-i386-y += pm_smbus.o apm.o
|
|
199 | 199 |
|
200 | 200 |
# shared objects |
201 | 201 |
obj-ppc-y = ppc.o |
... | ... | |
221 | 221 |
obj-mips-y += g364fb.o jazz_led.o |
222 | 222 |
obj-mips-y += gt64xxx.o pckbd.o mc146818rtc.o |
223 | 223 |
obj-mips-y += piix4.o cirrus_vga.o |
224 |
obj-mips-y += pm_smbus.o |
|
224 |
obj-mips-y += pm_smbus.o apm.o
|
|
225 | 225 |
|
226 | 226 |
obj-microblaze-y = petalogix_s3adsp1800_mmu.o |
227 | 227 |
|
b/hw/acpi.c | ||
---|---|---|
17 | 17 |
*/ |
18 | 18 |
#include "hw.h" |
19 | 19 |
#include "pc.h" |
20 |
#include "apm.h" |
|
20 | 21 |
#include "pm_smbus.h" |
21 | 22 |
#include "pci.h" |
22 | 23 |
#include "qemu-timer.h" |
... | ... | |
36 | 37 |
uint16_t pmsts; |
37 | 38 |
uint16_t pmen; |
38 | 39 |
uint16_t pmcntrl; |
39 |
uint8_t apmc; |
|
40 |
uint8_t apms; |
|
40 |
|
|
41 |
APMState apm; |
|
42 |
|
|
41 | 43 |
QEMUTimer *tmr_timer; |
42 | 44 |
int64_t tmr_overflow_time; |
43 | 45 |
|
... | ... | |
218 | 220 |
return val; |
219 | 221 |
} |
220 | 222 |
|
221 |
static void pm_smi_writeb(void *opaque, uint32_t addr, uint32_t val)
|
|
223 |
static void apm_ctrl_changed(uint32_t val, void *arg)
|
|
222 | 224 |
{ |
223 |
PIIX4PMState *s = opaque; |
|
224 |
addr &= 1; |
|
225 |
#ifdef DEBUG |
|
226 |
printf("pm_smi_writeb addr=0x%x val=0x%02x\n", addr, val); |
|
227 |
#endif |
|
228 |
if (addr == 0) { |
|
229 |
s->apmc = val; |
|
230 |
|
|
231 |
/* ACPI specs 3.0, 4.7.2.5 */ |
|
232 |
if (val == ACPI_ENABLE) { |
|
233 |
s->pmcntrl |= SCI_EN; |
|
234 |
} else if (val == ACPI_DISABLE) { |
|
235 |
s->pmcntrl &= ~SCI_EN; |
|
236 |
} |
|
225 |
PIIX4PMState *s = arg; |
|
237 | 226 |
|
238 |
if (s->dev.config[0x5b] & (1 << 1)) { |
|
239 |
if (s->smi_irq) { |
|
240 |
qemu_irq_raise(s->smi_irq); |
|
241 |
} |
|
242 |
} |
|
243 |
} else { |
|
244 |
s->apms = val; |
|
227 |
/* ACPI specs 3.0, 4.7.2.5 */ |
|
228 |
if (val == ACPI_ENABLE) { |
|
229 |
s->pmcntrl |= SCI_EN; |
|
230 |
} else if (val == ACPI_DISABLE) { |
|
231 |
s->pmcntrl &= ~SCI_EN; |
|
245 | 232 |
} |
246 |
} |
|
247 | 233 |
|
248 |
static uint32_t pm_smi_readb(void *opaque, uint32_t addr) |
|
249 |
{ |
|
250 |
PIIX4PMState *s = opaque; |
|
251 |
uint32_t val; |
|
252 |
|
|
253 |
addr &= 1; |
|
254 |
if (addr == 0) { |
|
255 |
val = s->apmc; |
|
256 |
} else { |
|
257 |
val = s->apms; |
|
234 |
if (s->dev.config[0x5b] & (1 << 1)) { |
|
235 |
if (s->smi_irq) { |
|
236 |
qemu_irq_raise(s->smi_irq); |
|
237 |
} |
|
258 | 238 |
} |
259 |
#ifdef DEBUG |
|
260 |
printf("pm_smi_readb addr=0x%x val=0x%02x\n", addr, val); |
|
261 |
#endif |
|
262 |
return val; |
|
263 | 239 |
} |
264 | 240 |
|
265 | 241 |
static void acpi_dbg_writel(void *opaque, uint32_t addr, uint32_t val) |
... | ... | |
315 | 291 |
VMSTATE_UINT16(pmsts, PIIX4PMState), |
316 | 292 |
VMSTATE_UINT16(pmen, PIIX4PMState), |
317 | 293 |
VMSTATE_UINT16(pmcntrl, PIIX4PMState), |
318 |
VMSTATE_UINT8(apmc, PIIX4PMState), |
|
319 |
VMSTATE_UINT8(apms, PIIX4PMState), |
|
294 |
VMSTATE_STRUCT(apm, PIIX4PMState, 0, vmstate_apm, APMState), |
|
320 | 295 |
VMSTATE_TIMER(tmr_timer, PIIX4PMState), |
321 | 296 |
VMSTATE_INT64(tmr_overflow_time, PIIX4PMState), |
322 | 297 |
VMSTATE_END_OF_LIST() |
... | ... | |
375 | 350 |
|
376 | 351 |
pci_conf[0x40] = 0x01; /* PM io base read only bit */ |
377 | 352 |
|
378 |
register_ioport_write(0xb2, 2, 1, pm_smi_writeb, s);
|
|
379 |
register_ioport_read(0xb2, 2, 1, pm_smi_readb, s);
|
|
353 |
/* APM */
|
|
354 |
apm_init(&s->apm, apm_ctrl_changed, s);
|
|
380 | 355 |
|
381 | 356 |
register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4, acpi_dbg_writel, s); |
382 | 357 |
|
b/hw/apm.c | ||
---|---|---|
1 |
/* |
|
2 |
* QEMU PC APM controller Emulation |
|
3 |
* This is split out from acpi.c |
|
4 |
* |
|
5 |
* Copyright (c) 2006 Fabrice Bellard |
|
6 |
* |
|
7 |
* This library is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU Lesser General Public |
|
9 |
* License version 2 as published by the Free Software Foundation. |
|
10 |
* |
|
11 |
* This library is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
* Lesser General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU Lesser General Public |
|
17 |
* License along with this library; if not, see <http://www.gnu.org/licenses/> |
|
18 |
*/ |
|
19 |
|
|
20 |
#include "apm.h" |
|
21 |
#include "hw.h" |
|
22 |
#include "isa.h" |
|
23 |
|
|
24 |
//#define DEBUG |
|
25 |
|
|
26 |
/* fixed I/O location */ |
|
27 |
#define APM_CNT_IOPORT 0xb2 |
|
28 |
#define APM_STS_IOPORT 0xb3 |
|
29 |
|
|
30 |
static void apm_ioport_writeb(void *opaque, uint32_t addr, uint32_t val) |
|
31 |
{ |
|
32 |
APMState *apm = opaque; |
|
33 |
addr &= 1; |
|
34 |
#ifdef DEBUG |
|
35 |
printf("apm_ioport_writeb addr=0x%x val=0x%02x\n", addr, val); |
|
36 |
#endif |
|
37 |
if (addr == 0) { |
|
38 |
apm->apmc = val; |
|
39 |
|
|
40 |
if (apm->callback) { |
|
41 |
(apm->callback)(val, apm->arg); |
|
42 |
} |
|
43 |
} else { |
|
44 |
apm->apms = val; |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
static uint32_t apm_ioport_readb(void *opaque, uint32_t addr) |
|
49 |
{ |
|
50 |
APMState *apm = opaque; |
|
51 |
uint32_t val; |
|
52 |
|
|
53 |
addr &= 1; |
|
54 |
if (addr == 0) { |
|
55 |
val = apm->apmc; |
|
56 |
} else { |
|
57 |
val = apm->apms; |
|
58 |
} |
|
59 |
#ifdef DEBUG |
|
60 |
printf("apm_ioport_readb addr=0x%x val=0x%02x\n", addr, val); |
|
61 |
#endif |
|
62 |
return val; |
|
63 |
} |
|
64 |
|
|
65 |
const VMStateDescription vmstate_apm = { |
|
66 |
.name = "APM State", |
|
67 |
.version_id = 1, |
|
68 |
.minimum_version_id = 1, |
|
69 |
.minimum_version_id_old = 1, |
|
70 |
.fields = (VMStateField[]) { |
|
71 |
VMSTATE_UINT8(apmc, APMState), |
|
72 |
VMSTATE_UINT8(apms, APMState), |
|
73 |
VMSTATE_END_OF_LIST() |
|
74 |
} |
|
75 |
}; |
|
76 |
|
|
77 |
void apm_init(APMState *apm, apm_ctrl_changed_t callback, void *arg) |
|
78 |
{ |
|
79 |
apm->callback = callback; |
|
80 |
apm->arg = arg; |
|
81 |
|
|
82 |
/* ioport 0xb2, 0xb3 */ |
|
83 |
register_ioport_write(APM_CNT_IOPORT, 2, 1, apm_ioport_writeb, apm); |
|
84 |
register_ioport_read(APM_CNT_IOPORT, 2, 1, apm_ioport_readb, apm); |
|
85 |
} |
b/hw/apm.h | ||
---|---|---|
1 |
#ifndef APM_H |
|
2 |
#define APM_H |
|
3 |
|
|
4 |
#include <stdint.h> |
|
5 |
#include "qemu-common.h" |
|
6 |
#include "hw.h" |
|
7 |
|
|
8 |
typedef void (*apm_ctrl_changed_t)(uint32_t val, void *arg); |
|
9 |
|
|
10 |
typedef struct APMState { |
|
11 |
uint8_t apmc; |
|
12 |
uint8_t apms; |
|
13 |
|
|
14 |
apm_ctrl_changed_t callback; |
|
15 |
void *arg; |
|
16 |
} APMState; |
|
17 |
|
|
18 |
void apm_init(APMState *s, apm_ctrl_changed_t callback, void *arg); |
|
19 |
|
|
20 |
extern const VMStateDescription vmstate_apm; |
|
21 |
|
|
22 |
#endif /* APM_H */ |
Also available in: Unified diff