2010-05-14 09:29:01 +02:00
|
|
|
#ifndef QEMU_HW_ACPI_H
|
|
|
|
#define QEMU_HW_ACPI_H
|
2016-06-29 15:29:06 +02:00
|
|
|
|
2010-05-14 09:29:01 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2009 Isaku Yamahata <yamahata at valinux co jp>
|
|
|
|
* VA Linux Systems Japan K.K.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2020-10-23 14:44:24 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2010-05-14 09:29:01 +02:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2010-05-15 19:52:49 +02:00
|
|
|
* License along with this library; if not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-05-14 09:29:01 +02:00
|
|
|
*/
|
|
|
|
|
2013-04-15 10:12:50 +02:00
|
|
|
#include "qemu/notify.h"
|
|
|
|
#include "exec/memory.h"
|
2016-05-31 11:57:57 +02:00
|
|
|
#include "hw/acpi/acpi_dev_interface.h"
|
2013-04-15 10:12:50 +02:00
|
|
|
|
2014-06-02 15:25:09 +02:00
|
|
|
/*
|
2014-06-17 21:02:00 +02:00
|
|
|
* current device naming scheme supports up to 256 memory devices
|
2014-06-02 15:25:09 +02:00
|
|
|
*/
|
|
|
|
#define ACPI_MAX_RAM_SLOTS 256
|
|
|
|
|
2010-05-14 09:29:01 +02:00
|
|
|
/* from linux include/acpi/actype.h */
|
|
|
|
/* Default ACPI register widths */
|
|
|
|
|
|
|
|
#define ACPI_GPE_REGISTER_WIDTH 8
|
|
|
|
#define ACPI_PM1_REGISTER_WIDTH 16
|
|
|
|
#define ACPI_PM2_REGISTER_WIDTH 8
|
|
|
|
#define ACPI_PM_TIMER_WIDTH 32
|
|
|
|
|
2017-10-17 18:44:17 +02:00
|
|
|
/* PC-style peripherals (also used by other machines). */
|
|
|
|
#define ACPI_PM_PROP_S3_DISABLED "disable_s3"
|
|
|
|
#define ACPI_PM_PROP_S4_DISABLED "disable_s4"
|
|
|
|
#define ACPI_PM_PROP_S4_VAL "s4_val"
|
|
|
|
#define ACPI_PM_PROP_SCI_INT "sci_int"
|
|
|
|
#define ACPI_PM_PROP_ACPI_ENABLE_CMD "acpi_enable_cmd"
|
|
|
|
#define ACPI_PM_PROP_ACPI_DISABLE_CMD "acpi_disable_cmd"
|
|
|
|
#define ACPI_PM_PROP_PM_IO_BASE "pm_io_base"
|
|
|
|
#define ACPI_PM_PROP_GPE0_BLK "gpe0_blk"
|
|
|
|
#define ACPI_PM_PROP_GPE0_BLK_LEN "gpe0_blk_len"
|
2021-08-16 10:32:14 +02:00
|
|
|
#define ACPI_PM_PROP_ACPI_PCIHP_BRIDGE "acpi-pci-hotplug-with-bridge-support"
|
|
|
|
#define ACPI_PM_PROP_ACPI_PCI_ROOTHP "acpi-root-pci-hotplug"
|
2017-10-17 18:44:17 +02:00
|
|
|
|
2010-05-14 09:29:01 +02:00
|
|
|
/* PM Timer ticks per second (HZ) */
|
|
|
|
#define PM_TIMER_FREQUENCY 3579545
|
|
|
|
|
|
|
|
|
|
|
|
/* ACPI fixed hardware registers */
|
|
|
|
|
|
|
|
/* from linux/drivers/acpi/acpica/aclocal.h */
|
|
|
|
/* Masks used to access the bit_registers */
|
|
|
|
|
|
|
|
/* PM1x_STS */
|
|
|
|
#define ACPI_BITMASK_TIMER_STATUS 0x0001
|
|
|
|
#define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010
|
|
|
|
#define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020
|
|
|
|
#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100
|
|
|
|
#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200
|
|
|
|
#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400
|
|
|
|
#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */
|
|
|
|
#define ACPI_BITMASK_WAKE_STATUS 0x8000
|
|
|
|
|
|
|
|
#define ACPI_BITMASK_ALL_FIXED_STATUS (\
|
2018-12-13 23:37:37 +01:00
|
|
|
ACPI_BITMASK_TIMER_STATUS | \
|
|
|
|
ACPI_BITMASK_BUS_MASTER_STATUS | \
|
|
|
|
ACPI_BITMASK_GLOBAL_LOCK_STATUS | \
|
|
|
|
ACPI_BITMASK_POWER_BUTTON_STATUS | \
|
|
|
|
ACPI_BITMASK_SLEEP_BUTTON_STATUS | \
|
|
|
|
ACPI_BITMASK_RT_CLOCK_STATUS | \
|
|
|
|
ACPI_BITMASK_WAKE_STATUS)
|
2010-05-14 09:29:01 +02:00
|
|
|
|
|
|
|
/* PM1x_EN */
|
|
|
|
#define ACPI_BITMASK_TIMER_ENABLE 0x0001
|
|
|
|
#define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020
|
|
|
|
#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100
|
|
|
|
#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200
|
|
|
|
#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400
|
|
|
|
#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */
|
|
|
|
|
2013-12-13 17:22:07 +01:00
|
|
|
#define ACPI_BITMASK_PM1_COMMON_ENABLED ( \
|
|
|
|
ACPI_BITMASK_RT_CLOCK_ENABLE | \
|
|
|
|
ACPI_BITMASK_POWER_BUTTON_ENABLE | \
|
|
|
|
ACPI_BITMASK_GLOBAL_LOCK_ENABLE | \
|
|
|
|
ACPI_BITMASK_TIMER_ENABLE)
|
|
|
|
|
2010-05-14 09:29:01 +02:00
|
|
|
/* PM1x_CNT */
|
|
|
|
#define ACPI_BITMASK_SCI_ENABLE 0x0001
|
|
|
|
#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
|
|
|
|
#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004
|
|
|
|
#define ACPI_BITMASK_SLEEP_TYPE 0x1C00
|
|
|
|
#define ACPI_BITMASK_SLEEP_ENABLE 0x2000
|
|
|
|
|
|
|
|
/* PM2_CNT */
|
|
|
|
#define ACPI_BITMASK_ARB_DISABLE 0x0001
|
|
|
|
|
2012-02-23 13:45:15 +01:00
|
|
|
/* structs */
|
2011-03-25 11:54:38 +01:00
|
|
|
typedef struct ACPIPMTimer ACPIPMTimer;
|
2012-02-23 13:45:15 +01:00
|
|
|
typedef struct ACPIPM1EVT ACPIPM1EVT;
|
|
|
|
typedef struct ACPIPM1CNT ACPIPM1CNT;
|
|
|
|
typedef struct ACPIGPE ACPIGPE;
|
2012-02-23 13:45:16 +01:00
|
|
|
typedef struct ACPIREGS ACPIREGS;
|
2011-03-25 11:54:38 +01:00
|
|
|
|
2012-02-23 13:45:16 +01:00
|
|
|
typedef void (*acpi_update_sci_fn)(ACPIREGS *ar);
|
2011-03-25 11:54:38 +01:00
|
|
|
|
|
|
|
struct ACPIPMTimer {
|
|
|
|
QEMUTimer *timer;
|
2012-11-22 12:12:30 +01:00
|
|
|
MemoryRegion io;
|
2011-03-25 11:54:38 +01:00
|
|
|
int64_t overflow_time;
|
|
|
|
|
|
|
|
acpi_update_sci_fn update_sci;
|
|
|
|
};
|
|
|
|
|
2012-02-23 13:45:15 +01:00
|
|
|
struct ACPIPM1EVT {
|
2012-11-22 13:25:10 +01:00
|
|
|
MemoryRegion io;
|
2012-02-23 13:45:15 +01:00
|
|
|
uint16_t sts;
|
|
|
|
uint16_t en;
|
2012-11-22 13:25:10 +01:00
|
|
|
acpi_update_sci_fn update_sci;
|
2012-02-23 13:45:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ACPIPM1CNT {
|
2012-11-22 13:17:57 +01:00
|
|
|
MemoryRegion io;
|
2012-02-23 13:45:15 +01:00
|
|
|
uint16_t cnt;
|
2012-11-22 13:17:57 +01:00
|
|
|
uint8_t s4_val;
|
2021-02-18 06:51:12 +01:00
|
|
|
bool acpi_only;
|
2012-02-23 13:45:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ACPIGPE {
|
|
|
|
uint8_t len;
|
|
|
|
|
|
|
|
uint8_t *sts;
|
|
|
|
uint8_t *en;
|
|
|
|
};
|
|
|
|
|
2012-02-23 13:45:16 +01:00
|
|
|
struct ACPIREGS {
|
|
|
|
ACPIPMTimer tmr;
|
|
|
|
ACPIGPE gpe;
|
|
|
|
struct {
|
|
|
|
ACPIPM1EVT evt;
|
|
|
|
ACPIPM1CNT cnt;
|
|
|
|
} pm1;
|
2012-02-23 13:45:20 +01:00
|
|
|
Notifier wakeup;
|
2012-02-23 13:45:16 +01:00
|
|
|
};
|
|
|
|
|
2012-02-23 13:45:15 +01:00
|
|
|
/* PM_TMR */
|
2012-02-23 13:45:16 +01:00
|
|
|
void acpi_pm_tmr_update(ACPIREGS *ar, bool enable);
|
|
|
|
void acpi_pm_tmr_calc_overflow_time(ACPIREGS *ar);
|
2012-11-22 12:12:30 +01:00
|
|
|
void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
|
|
|
|
MemoryRegion *parent);
|
2012-02-23 13:45:16 +01:00
|
|
|
void acpi_pm_tmr_reset(ACPIREGS *ar);
|
2011-03-25 11:54:38 +01:00
|
|
|
|
2011-03-25 11:54:39 +01:00
|
|
|
/* PM1a_EVT: piix and ich9 don't implement PM1b. */
|
2012-02-23 13:45:17 +01:00
|
|
|
uint16_t acpi_pm1_evt_get_sts(ACPIREGS *ar);
|
2012-02-23 13:45:16 +01:00
|
|
|
void acpi_pm1_evt_power_down(ACPIREGS *ar);
|
|
|
|
void acpi_pm1_evt_reset(ACPIREGS *ar);
|
2012-11-22 13:25:10 +01:00
|
|
|
void acpi_pm1_evt_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
|
|
|
|
MemoryRegion *parent);
|
2011-03-25 11:54:39 +01:00
|
|
|
|
2011-03-25 11:54:40 +01:00
|
|
|
/* PM1a_CNT: piix and ich9 don't implement PM1b CNT. */
|
2015-04-29 15:20:14 +02:00
|
|
|
void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent,
|
2021-02-18 06:51:12 +01:00
|
|
|
bool disable_s3, bool disable_s4, uint8_t s4_val,
|
|
|
|
bool acpi_only);
|
2012-02-23 13:45:16 +01:00
|
|
|
void acpi_pm1_cnt_update(ACPIREGS *ar,
|
2011-03-25 11:54:40 +01:00
|
|
|
bool sci_enable, bool sci_disable);
|
2012-02-23 13:45:16 +01:00
|
|
|
void acpi_pm1_cnt_reset(ACPIREGS *ar);
|
2011-03-25 11:54:40 +01:00
|
|
|
|
2011-03-25 11:54:41 +01:00
|
|
|
/* GPE0 */
|
2012-02-23 13:45:16 +01:00
|
|
|
void acpi_gpe_init(ACPIREGS *ar, uint8_t len);
|
|
|
|
void acpi_gpe_reset(ACPIREGS *ar);
|
2011-03-25 11:54:41 +01:00
|
|
|
|
2012-02-23 13:45:16 +01:00
|
|
|
void acpi_gpe_ioport_writeb(ACPIREGS *ar, uint32_t addr, uint32_t val);
|
|
|
|
uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr);
|
2011-03-25 11:54:41 +01:00
|
|
|
|
2015-05-13 11:21:36 +02:00
|
|
|
void acpi_send_gpe_event(ACPIREGS *ar, qemu_irq irq,
|
2016-05-31 11:57:57 +02:00
|
|
|
AcpiEventStatusBits status);
|
2015-05-13 11:21:36 +02:00
|
|
|
|
2013-12-13 17:22:07 +01:00
|
|
|
void acpi_update_sci(ACPIREGS *acpi_regs, qemu_irq irq);
|
|
|
|
|
2013-04-15 08:19:22 +02:00
|
|
|
/* acpi.c */
|
|
|
|
extern char unsigned *acpi_tables;
|
|
|
|
extern size_t acpi_tables_len;
|
|
|
|
|
2013-10-07 13:41:40 +02:00
|
|
|
uint8_t *acpi_table_first(void);
|
|
|
|
uint8_t *acpi_table_next(uint8_t *current);
|
|
|
|
unsigned acpi_table_len(void *current);
|
2013-04-15 08:19:22 +02:00
|
|
|
void acpi_table_add(const QemuOpts *opts, Error **errp);
|
|
|
|
|
2016-01-18 15:12:12 +01:00
|
|
|
typedef struct AcpiSlicOem AcpiSlicOem;
|
|
|
|
struct AcpiSlicOem {
|
|
|
|
char *id;
|
|
|
|
char *table_id;
|
|
|
|
};
|
|
|
|
int acpi_get_slic_oem(AcpiSlicOem *oem);
|
|
|
|
|
2016-06-29 15:29:06 +02:00
|
|
|
#endif /* QEMU_HW_ACPI_H */
|