Merge pull request #3088 from Cacodemon345/qt-acpi-button
qt: Reenable and make functional ACPI shutdown button
This commit is contained in:
@@ -97,6 +97,8 @@
|
||||
#include <86box/version.h>
|
||||
#include <86box/gdbstub.h>
|
||||
#include <86box/machine_status.h>
|
||||
#include <86box/apm.h>
|
||||
#include <86box/acpi.h>
|
||||
|
||||
// Disable c99-designator to avoid the warnings about int ng
|
||||
#ifdef __clang__
|
||||
@@ -1016,6 +1018,9 @@ pc_reset_hard_init(void)
|
||||
* modules that are.
|
||||
*/
|
||||
|
||||
/* Mark ACPI as unavailable */
|
||||
acpi_enabled = 0;
|
||||
|
||||
/* Reset the general machine support modules. */
|
||||
io_init();
|
||||
|
||||
|
23
src/acpi.c
23
src/acpi.c
@@ -40,7 +40,9 @@
|
||||
#include <86box/i2c.h>
|
||||
#include <86box/video.h>
|
||||
|
||||
int acpi_rtc_status = 0;
|
||||
int acpi_rtc_status = 0;
|
||||
atomic_int acpi_pwrbut_pressed = 0;
|
||||
int acpi_enabled = 0;
|
||||
|
||||
static double cpu_to_acpi;
|
||||
|
||||
@@ -1516,6 +1518,21 @@ acpi_ali_soft_smi_status_write(acpi_t *dev, uint8_t soft_smi)
|
||||
dev->regs.ali_soft_smi = soft_smi;
|
||||
}
|
||||
|
||||
void
|
||||
acpi_pwrbtn_timer(void* priv)
|
||||
{
|
||||
acpi_t *dev = (acpi_t *) priv;
|
||||
|
||||
timer_on_auto(&dev->pwrbtn_timer, 16. * 1000.);
|
||||
if (acpi_pwrbut_pressed) {
|
||||
acpi_pwrbut_pressed = 0;
|
||||
if (dev->regs.pmen & PWRBTN_EN) {
|
||||
dev->regs.pmsts |= PWRBTN_STS;
|
||||
acpi_update_irq(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
acpi_apm_out(uint16_t port, uint8_t val, void *p)
|
||||
{
|
||||
@@ -1707,9 +1724,13 @@ acpi_init(const device_t *info)
|
||||
|
||||
timer_add(&dev->timer, acpi_timer_overflow, dev, 0);
|
||||
timer_add(&dev->resume_timer, acpi_timer_resume, dev, 0);
|
||||
timer_add(&dev->pwrbtn_timer, acpi_pwrbtn_timer, dev, 0);
|
||||
|
||||
timer_on_auto(&dev->pwrbtn_timer, 16. * 1000.);
|
||||
|
||||
acpi_reset(dev);
|
||||
|
||||
acpi_enabled = 1;
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,11 @@
|
||||
#define ACPI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <atomic>
|
||||
using atomic_int = std::atomic_int;
|
||||
extern "C" {
|
||||
#else
|
||||
#include <stdatomic.h>
|
||||
#endif
|
||||
|
||||
#define ACPI_TIMER_FREQ 3579545
|
||||
@@ -90,7 +94,7 @@ typedef struct
|
||||
slot, irq_mode,
|
||||
irq_pin, irq_line,
|
||||
mirq_is_level;
|
||||
pc_timer_t timer, resume_timer;
|
||||
pc_timer_t timer, resume_timer, pwrbtn_timer;
|
||||
nvr_t *nvr;
|
||||
apm_t *apm;
|
||||
void *i2c,
|
||||
@@ -98,7 +102,9 @@ typedef struct
|
||||
} acpi_t;
|
||||
|
||||
/* Global variables. */
|
||||
extern int acpi_rtc_status;
|
||||
extern int acpi_rtc_status;
|
||||
extern atomic_int acpi_pwrbut_pressed;
|
||||
extern int acpi_enabled;
|
||||
|
||||
extern const device_t acpi_ali_device;
|
||||
extern const device_t acpi_intel_device;
|
||||
|
@@ -47,6 +47,9 @@ extern "C" {
|
||||
#include <86box/machine.h>
|
||||
#include <86box/vid_ega.h>
|
||||
#include <86box/version.h>
|
||||
//#include <86box/acpi.h> /* Requires timer.h include, which conflicts with Qt headers */
|
||||
extern atomic_int acpi_pwrbut_pressed;
|
||||
extern int acpi_enabled;
|
||||
|
||||
#ifdef USE_VNC
|
||||
# include <86box/vnc.h>
|
||||
@@ -1679,6 +1682,7 @@ MainWindow::refreshMediaMenu()
|
||||
mm->refresh(ui->menuMedia);
|
||||
status->refresh(ui->statusbar);
|
||||
ui->actionMCA_devices->setVisible(machine_has_bus(machine, MACHINE_BUS_MCA));
|
||||
ui->actionACPI_Shutdown->setEnabled(!!acpi_enabled);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2430,3 +2434,9 @@ MainWindow::on_actionApply_fullscreen_stretch_mode_when_maximized_triggered(bool
|
||||
device_force_redraw();
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionACPI_Shutdown_triggered()
|
||||
{
|
||||
acpi_pwrbut_pressed = 1;
|
||||
}
|
||||
|
||||
|
@@ -134,6 +134,9 @@ protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void changeEvent(QEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void on_actionACPI_Shutdown_triggered();
|
||||
|
||||
private slots:
|
||||
void on_actionShow_non_primary_monitors_triggered();
|
||||
|
||||
|
@@ -743,7 +743,7 @@
|
||||
</action>
|
||||
<action name="actionACPI_Shutdown">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../qt_resources.qrc">
|
||||
@@ -756,7 +756,7 @@
|
||||
<string>ACPI Shutdown</string>
|
||||
</property>
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionBegin_trace">
|
||||
|
Reference in New Issue
Block a user