From 21eab4381cf9cbd7b3fbf74b4340b845b9ecbaec Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Tue, 28 Nov 2023 12:19:14 -0500 Subject: [PATCH 01/12] Add -no_dvd parameter --- softmmu/vl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/softmmu/vl.c b/softmmu/vl.c index badf207da0c..14d59412c89 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2852,6 +2852,18 @@ void qemu_init(int argc, char **argv) } } + if (strlen(dvd_path) > 0) { + // Allow clearing the dvd path on boot. + for (int i = 1; i < argc; i++) { + if (argv[i] && strcmp(argv[i], "-no_dvd") == 0) { + argv[i] = NULL; + dvd_path = ""; + xemu_settings_set_string(&g_config.sys.files.dvd_path, ""); + break; + } + } + } + if (strlen(dvd_path) > 0) { if (xemu_check_file(dvd_path) || strcmp(dvd_path, hdd_path) == 0) { char *msg = g_strdup_printf("Failed to open DVD image file '%s'. Please check machine settings.", dvd_path); From 4e70c629e02122e8c88928c4f3d021f270abd298 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Tue, 28 Nov 2023 17:45:09 -0500 Subject: [PATCH 02/12] Proper eject handling, and revert -no-dvd. -Reverts -no_dvd arg -Adds eject/load tray handling to xbox smc. -Adds -eject_after_boot arg -Adds smc handling of eject_after_handling --- hw/xbox/smbus_xbox_smc.c | 38 ++++++++++++++++++++++++++++++++++++-- hw/xbox/xbox.c | 20 ++++++++++++++++++++ hw/xbox/xbox.h | 1 + softmmu/vl.c | 13 ++++++++++++- 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/hw/xbox/smbus_xbox_smc.c b/hw/xbox/smbus_xbox_smc.c index c7cf02e3e51..08a9ba2c2e9 100644 --- a/hw/xbox/smbus_xbox_smc.c +++ b/hw/xbox/smbus_xbox_smc.c @@ -37,11 +37,24 @@ #include "smbus.h" #include "sysemu/runstate.h" #include "hw/qdev-properties.h" +#include "ui/xemu-settings.h" #define TYPE_XBOX_SMC "smbus-xbox-smc" #define XBOX_SMC(obj) OBJECT_CHECK(SMBusSMCDevice, (obj), TYPE_XBOX_SMC) -// #define DEBUG +#ifdef __cplusplus +extern "C" { +#endif + +#include "../../xemu-config.h" + +extern struct config g_config; + +#ifdef __cplusplus +} +#endif + +#define DEBUG #ifdef DEBUG # define DPRINTF(format, ...) printf(format, ## __VA_ARGS__) #else @@ -91,7 +104,10 @@ #define SMC_REG_RESETONEJECT 0x19 #define SMC_REG_INTEN 0x1a #define SMC_REG_SCRATCH 0x1b +#define SMC_REG_SCRATCH_EJECT_AFTER_BOOT 0x01 +#define SMC_REG_SCRATCH_ERROR_AFTER_BOOT 0x02 #define SMC_REG_SCRATCH_SHORT_ANIMATION 0x04 +#define SMC_REG_SCRATCH_FORCE_DASH_BOOT 0x08 #define SMC_VERSION_LENGTH 3 @@ -114,8 +130,9 @@ static void smc_quick_cmd(SMBusDevice *dev, uint8_t read) static int smc_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) { + Error *error = NULL; SMBusSMCDevice *smc = XBOX_SMC(dev); - + smc->cmd = buf[0]; uint8_t cmd = smc->cmd; buf++; @@ -140,6 +157,19 @@ static int smc_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) } break; + case SMC_REG_TRAYEJECT: + if (buf[0]) { + const char *path = g_config.sys.files.dvd_path; + qmp_blockdev_change_medium(true, "ide0-cd1", false, NULL, path, + false, "", false, false, false, 0, + &error); + } else { + xemu_settings_set_string(&g_config.sys.files.dvd_path, ""); + qmp_eject(true, "ide0-cd1", false, NULL, true, false, &error); + } + xbox_smc_update_tray_state(); + break; + case SMC_REG_ERROR_WRITE: smc->error_reg = buf[0]; break; @@ -264,6 +294,10 @@ static void smbus_smc_realize(DeviceState *dev, Error **errp) smc->cmd = 0; smc->error_reg = 0; + if (object_property_get_bool(qdev_get_machine(), "eject-after-boot", NULL)) { + smc->scratch_reg = SMC_REG_SCRATCH_EJECT_AFTER_BOOT; + } + if (object_property_get_bool(qdev_get_machine(), "short-animation", NULL)) { smc->scratch_reg = SMC_REG_SCRATCH_SHORT_ANIMATION; } diff --git a/hw/xbox/xbox.c b/hw/xbox/xbox.c index 7a496118ab0..cdcb957a759 100644 --- a/hw/xbox/xbox.c +++ b/hw/xbox/xbox.c @@ -437,6 +437,19 @@ static bool machine_get_short_animation(Object *obj, Error **errp) return ms->short_animation; } +static void machine_set_eject_after_boot(Object *obj, bool value, + Error **errp) +{ + XboxMachineState *ms = XBOX_MACHINE(obj); + ms->eject_after_boot = value; +} + +static bool machine_get_eject_after_boot(Object *obj, Error **errp) +{ + XboxMachineState *ms = XBOX_MACHINE(obj); + return ms->eject_after_boot; +} + static char *machine_get_smc_version(Object *obj, Error **errp) { XboxMachineState *ms = XBOX_MACHINE(obj); @@ -504,6 +517,13 @@ static inline void xbox_machine_initfn(Object *obj) "Skip Xbox boot animation"); object_property_set_bool(obj, "short-animation", false, &error_fatal); + object_property_add_bool(obj, "eject-after-boot", + machine_get_eject_after_boot, + machine_set_eject_after_boot); + object_property_set_description(obj, "eject-after-boot", + "Eject disc tray after boot"); + object_property_set_bool(obj, "eject-after-boot", false, &error_fatal); + object_property_add_str(obj, "smc-version", machine_get_smc_version, machine_set_smc_version); object_property_set_description(obj, "smc-version", diff --git a/hw/xbox/xbox.h b/hw/xbox/xbox.h index 8e602d690e4..8a6aac6d588 100644 --- a/hw/xbox/xbox.h +++ b/hw/xbox/xbox.h @@ -45,6 +45,7 @@ typedef struct XboxMachineState { char *bootrom; char *avpack; bool short_animation; + bool eject_after_boot; char *smc_version; char *video_encoder; } XboxMachineState; diff --git a/softmmu/vl.c b/softmmu/vl.c index badf207da0c..61fa239fab8 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2782,8 +2782,19 @@ void qemu_init(int argc, char **argv) "none", }[g_config.sys.avpack]; - fake_argv[fake_argc++] = g_strdup_printf("xbox%s%s%s,avpack=%s", + bool eject_after_boot = false; + // Allow overriding the dvd path from command line + for (int i = 1; i < argc; i++) { + if (argv[i] && strcmp(argv[i], "-eject_after_boot") == 0) { + argv[i] = NULL; + eject_after_boot = true; + break; + } + } + + fake_argv[fake_argc++] = g_strdup_printf("xbox%s%s%s%s,avpack=%s", (bootrom_arg != NULL) ? bootrom_arg : "", + eject_after_boot ? ",eject-after-boot=on" : "", g_config.general.skip_boot_anim ? ",short-animation=on" : "", ",kernel-irqchip=off", avpack_str From 8b6cd8979cf3b9561582c838bf0e46226786689b Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Tue, 28 Nov 2023 18:13:56 -0500 Subject: [PATCH 03/12] Update vl.c --- softmmu/vl.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 1925ebba347..61fa239fab8 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2863,18 +2863,6 @@ void qemu_init(int argc, char **argv) } } - if (strlen(dvd_path) > 0) { - // Allow clearing the dvd path on boot. - for (int i = 1; i < argc; i++) { - if (argv[i] && strcmp(argv[i], "-no_dvd") == 0) { - argv[i] = NULL; - dvd_path = ""; - xemu_settings_set_string(&g_config.sys.files.dvd_path, ""); - break; - } - } - } - if (strlen(dvd_path) > 0) { if (xemu_check_file(dvd_path) || strcmp(dvd_path, hdd_path) == 0) { char *msg = g_strdup_printf("Failed to open DVD image file '%s'. Please check machine settings.", dvd_path); From f7ae22e3c07b710897748f5ba0fbf2b858688e41 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Tue, 28 Nov 2023 18:14:45 -0500 Subject: [PATCH 04/12] Update vl.c --- softmmu/vl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 61fa239fab8..c5a183e4fe4 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2783,7 +2783,6 @@ void qemu_init(int argc, char **argv) }[g_config.sys.avpack]; bool eject_after_boot = false; - // Allow overriding the dvd path from command line for (int i = 1; i < argc; i++) { if (argv[i] && strcmp(argv[i], "-eject_after_boot") == 0) { argv[i] = NULL; From b426beaa4abd2dea5e91fda36e80ff3f2433c832 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Sun, 17 Dec 2023 23:17:25 -0500 Subject: [PATCH 05/12] clang-formatting --- hw/xbox/smbus_xbox_smc.c | 27 ++++++++++++++------------- hw/xbox/xbox.c | 3 +-- softmmu/vl.c | 8 +++----- ui/xui/main-menu.cc | 3 ++- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/hw/xbox/smbus_xbox_smc.c b/hw/xbox/smbus_xbox_smc.c index 08a9ba2c2e9..5651cd87b0e 100644 --- a/hw/xbox/smbus_xbox_smc.c +++ b/hw/xbox/smbus_xbox_smc.c @@ -24,20 +24,20 @@ */ #include "qemu/osdep.h" -#include "qemu/option.h" -#include "hw/hw.h" #include "hw/acpi/acpi.h" +#include "hw/hw.h" #include "hw/i2c/i2c.h" #include "hw/i2c/smbus_slave.h" -#include "qemu/config-file.h" +#include "hw/qdev-properties.h" #include "qapi/error.h" +#include "qemu/config-file.h" +#include "qemu/option.h" #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" -#include "sysemu/sysemu.h" -#include "smbus.h" #include "sysemu/runstate.h" -#include "hw/qdev-properties.h" +#include "sysemu/sysemu.h" #include "ui/xemu-settings.h" +#include "smbus.h" #define TYPE_XBOX_SMC "smbus-xbox-smc" #define XBOX_SMC(obj) OBJECT_CHECK(SMBusSMCDevice, (obj), TYPE_XBOX_SMC) @@ -104,10 +104,10 @@ extern struct config g_config; #define SMC_REG_RESETONEJECT 0x19 #define SMC_REG_INTEN 0x1a #define SMC_REG_SCRATCH 0x1b -#define SMC_REG_SCRATCH_EJECT_AFTER_BOOT 0x01 -#define SMC_REG_SCRATCH_ERROR_AFTER_BOOT 0x02 +#define SMC_REG_SCRATCH_EJECT_AFTER_BOOT 0x01 +#define SMC_REG_SCRATCH_ERROR_AFTER_BOOT 0x02 #define SMC_REG_SCRATCH_SHORT_ANIMATION 0x04 -#define SMC_REG_SCRATCH_FORCE_DASH_BOOT 0x08 +#define SMC_REG_SCRATCH_FORCE_DASH_BOOT 0x08 #define SMC_VERSION_LENGTH 3 @@ -132,7 +132,7 @@ static int smc_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) { Error *error = NULL; SMBusSMCDevice *smc = XBOX_SMC(dev); - + smc->cmd = buf[0]; uint8_t cmd = smc->cmd; buf++; @@ -161,8 +161,8 @@ static int smc_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) if (buf[0]) { const char *path = g_config.sys.files.dvd_path; qmp_blockdev_change_medium(true, "ide0-cd1", false, NULL, path, - false, "", false, false, false, 0, - &error); + false, "", false, false, false, 0, + &error); } else { xemu_settings_set_string(&g_config.sys.files.dvd_path, ""); qmp_eject(true, "ide0-cd1", false, NULL, true, false, &error); @@ -294,7 +294,8 @@ static void smbus_smc_realize(DeviceState *dev, Error **errp) smc->cmd = 0; smc->error_reg = 0; - if (object_property_get_bool(qdev_get_machine(), "eject-after-boot", NULL)) { + if (object_property_get_bool(qdev_get_machine(), "eject-after-boot", + NULL)) { smc->scratch_reg = SMC_REG_SCRATCH_EJECT_AFTER_BOOT; } diff --git a/hw/xbox/xbox.c b/hw/xbox/xbox.c index cdcb957a759..88b48b68e77 100644 --- a/hw/xbox/xbox.c +++ b/hw/xbox/xbox.c @@ -437,8 +437,7 @@ static bool machine_get_short_animation(Object *obj, Error **errp) return ms->short_animation; } -static void machine_set_eject_after_boot(Object *obj, bool value, - Error **errp) +static void machine_set_eject_after_boot(Object *obj, bool value, Error **errp) { XboxMachineState *ms = XBOX_MACHINE(obj); ms->eject_after_boot = value; diff --git a/softmmu/vl.c b/softmmu/vl.c index c5a183e4fe4..25cfe13cf14 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2791,13 +2791,11 @@ void qemu_init(int argc, char **argv) } } - fake_argv[fake_argc++] = g_strdup_printf("xbox%s%s%s%s,avpack=%s", - (bootrom_arg != NULL) ? bootrom_arg : "", + fake_argv[fake_argc++] = g_strdup_printf( + "xbox%s%s%s%s,avpack=%s", (bootrom_arg != NULL) ? bootrom_arg : "", eject_after_boot ? ",eject-after-boot=on" : "", g_config.general.skip_boot_anim ? ",short-animation=on" : "", - ",kernel-irqchip=off", - avpack_str - ); + ",kernel-irqchip=off", avpack_str); if (bootrom_arg != NULL) { g_free(bootrom_arg); diff --git a/ui/xui/main-menu.cc b/ui/xui/main-menu.cc index eb7749a51b1..d57770b027c 100644 --- a/ui/xui/main-menu.cc +++ b/ui/xui/main-menu.cc @@ -990,7 +990,8 @@ void MainMenuSystemView::Draw() } if ((int)g_config.sys.avpack == CONFIG_SYS_AVPACK_NONE) { - ImGui::TextColored(ImVec4(1,0,0,1), "Setting AV Pack to NONE disables video output."); + ImGui::TextColored(ImVec4(1, 0, 0, 1), + "Setting AV Pack to NONE disables video output."); } SectionTitle("System Configuration"); From 569b9bde76b33b28275989808e9d7acfd0107639 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Sun, 17 Dec 2023 23:19:48 -0500 Subject: [PATCH 06/12] Fix how smc scratch reg flags are set --- hw/xbox/smbus_xbox_smc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/xbox/smbus_xbox_smc.c b/hw/xbox/smbus_xbox_smc.c index 5651cd87b0e..e2629ad78a6 100644 --- a/hw/xbox/smbus_xbox_smc.c +++ b/hw/xbox/smbus_xbox_smc.c @@ -296,11 +296,11 @@ static void smbus_smc_realize(DeviceState *dev, Error **errp) if (object_property_get_bool(qdev_get_machine(), "eject-after-boot", NULL)) { - smc->scratch_reg = SMC_REG_SCRATCH_EJECT_AFTER_BOOT; + smc->scratch_reg |= SMC_REG_SCRATCH_EJECT_AFTER_BOOT; } if (object_property_get_bool(qdev_get_machine(), "short-animation", NULL)) { - smc->scratch_reg = SMC_REG_SCRATCH_SHORT_ANIMATION; + smc->scratch_reg |= SMC_REG_SCRATCH_SHORT_ANIMATION; } avpack = object_property_get_str(qdev_get_machine(), "avpack", NULL); From 09c7a5692cd5b3c02d0ce1fc001e8b010a81de81 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Sun, 17 Dec 2023 23:21:51 -0500 Subject: [PATCH 07/12] don't declare DEBUG in smbux_xbox_smc.c --- hw/xbox/smbus_xbox_smc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xbox/smbus_xbox_smc.c b/hw/xbox/smbus_xbox_smc.c index e2629ad78a6..0db48cae3c8 100644 --- a/hw/xbox/smbus_xbox_smc.c +++ b/hw/xbox/smbus_xbox_smc.c @@ -54,7 +54,7 @@ extern struct config g_config; } #endif -#define DEBUG +// #define DEBUG #ifdef DEBUG # define DPRINTF(format, ...) printf(format, ## __VA_ARGS__) #else From 27df9ada5075e4459091b5be70b5393e29474334 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Sun, 17 Dec 2023 23:43:32 -0500 Subject: [PATCH 08/12] Omit unnecessary config include --- hw/xbox/smbus_xbox_smc.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/hw/xbox/smbus_xbox_smc.c b/hw/xbox/smbus_xbox_smc.c index 0db48cae3c8..05215bc4f80 100644 --- a/hw/xbox/smbus_xbox_smc.c +++ b/hw/xbox/smbus_xbox_smc.c @@ -42,18 +42,6 @@ #define TYPE_XBOX_SMC "smbus-xbox-smc" #define XBOX_SMC(obj) OBJECT_CHECK(SMBusSMCDevice, (obj), TYPE_XBOX_SMC) -#ifdef __cplusplus -extern "C" { -#endif - -#include "../../xemu-config.h" - -extern struct config g_config; - -#ifdef __cplusplus -} -#endif - // #define DEBUG #ifdef DEBUG # define DPRINTF(format, ...) printf(format, ## __VA_ARGS__) From c00d3d5dd741dea7f4482fea6952e3594d940d62 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Sat, 25 May 2024 21:35:44 -0400 Subject: [PATCH 09/12] run clang-format --- hw/xbox/smbus_xbox_smc.c | 114 ++-- hw/xbox/xbox.c | 128 ++-- hw/xbox/xbox.h | 3 +- softmmu/vl.c | 1193 +++++++++++++++++++------------------- ui/xui/main-menu.cc | 380 +++++++----- 5 files changed, 950 insertions(+), 868 deletions(-) diff --git a/hw/xbox/smbus_xbox_smc.c b/hw/xbox/smbus_xbox_smc.c index 05215bc4f80..a6da9a12fc0 100644 --- a/hw/xbox/smbus_xbox_smc.c +++ b/hw/xbox/smbus_xbox_smc.c @@ -44,9 +44,11 @@ // #define DEBUG #ifdef DEBUG -# define DPRINTF(format, ...) printf(format, ## __VA_ARGS__) +#define DPRINTF(format, ...) printf(format, ##__VA_ARGS__) #else -# define DPRINTF(format, ...) do { } while (0) +#define DPRINTF(format, ...) \ + do { \ + } while (0) #endif /* @@ -54,47 +56,47 @@ * http://www.xbox-linux.org/wiki/PIC */ -#define SMC_REG_VER 0x01 -#define SMC_REG_POWER 0x02 -#define SMC_REG_POWER_RESET 0x01 -#define SMC_REG_POWER_CYCLE 0x40 -#define SMC_REG_POWER_SHUTDOWN 0x80 -#define SMC_REG_TRAYSTATE 0x03 -#define SMC_REG_TRAYSTATE_OPEN 0x10 -#define SMC_REG_TRAYSTATE_NO_MEDIA_DETECTED 0x40 -#define SMC_REG_TRAYSTATE_MEDIA_DETECTED 0x60 -#define SMC_REG_AVPACK 0x04 -#define SMC_REG_AVPACK_SCART 0x00 -#define SMC_REG_AVPACK_HDTV 0x01 -#define SMC_REG_AVPACK_VGA 0x02 -#define SMC_REG_AVPACK_RFU 0x03 -#define SMC_REG_AVPACK_SVIDEO 0x04 -#define SMC_REG_AVPACK_COMPOSITE 0x06 -#define SMC_REG_AVPACK_NONE 0x07 -#define SMC_REG_FANMODE 0x05 -#define SMC_REG_FANSPEED 0x06 -#define SMC_REG_LEDMODE 0x07 -#define SMC_REG_LEDSEQ 0x08 -#define SMC_REG_CPUTEMP 0x09 -#define SMC_REG_BOARDTEMP 0x0a -#define SMC_REG_TRAYEJECT 0x0c -#define SMC_REG_INTACK 0x0d -#define SMC_REG_ERROR_WRITE 0x0e -#define SMC_REG_ERROR_READ 0x0f -#define SMC_REG_INTSTATUS 0x11 -#define SMC_REG_INTSTATUS_POWER 0x01 -#define SMC_REG_INTSTATUS_TRAYCLOSED 0x02 -#define SMC_REG_INTSTATUS_TRAYOPENING 0x04 -#define SMC_REG_INTSTATUS_AVPACK_PLUG 0x08 -#define SMC_REG_INTSTATUS_AVPACK_UNPLUG 0x10 -#define SMC_REG_INTSTATUS_EJECT_BUTTON 0x20 -#define SMC_REG_INTSTATUS_TRAYCLOSING 0x40 -#define SMC_REG_RESETONEJECT 0x19 -#define SMC_REG_INTEN 0x1a -#define SMC_REG_SCRATCH 0x1b +#define SMC_REG_VER 0x01 +#define SMC_REG_POWER 0x02 +#define SMC_REG_POWER_RESET 0x01 +#define SMC_REG_POWER_CYCLE 0x40 +#define SMC_REG_POWER_SHUTDOWN 0x80 +#define SMC_REG_TRAYSTATE 0x03 +#define SMC_REG_TRAYSTATE_OPEN 0x10 +#define SMC_REG_TRAYSTATE_NO_MEDIA_DETECTED 0x40 +#define SMC_REG_TRAYSTATE_MEDIA_DETECTED 0x60 +#define SMC_REG_AVPACK 0x04 +#define SMC_REG_AVPACK_SCART 0x00 +#define SMC_REG_AVPACK_HDTV 0x01 +#define SMC_REG_AVPACK_VGA 0x02 +#define SMC_REG_AVPACK_RFU 0x03 +#define SMC_REG_AVPACK_SVIDEO 0x04 +#define SMC_REG_AVPACK_COMPOSITE 0x06 +#define SMC_REG_AVPACK_NONE 0x07 +#define SMC_REG_FANMODE 0x05 +#define SMC_REG_FANSPEED 0x06 +#define SMC_REG_LEDMODE 0x07 +#define SMC_REG_LEDSEQ 0x08 +#define SMC_REG_CPUTEMP 0x09 +#define SMC_REG_BOARDTEMP 0x0a +#define SMC_REG_TRAYEJECT 0x0c +#define SMC_REG_INTACK 0x0d +#define SMC_REG_ERROR_WRITE 0x0e +#define SMC_REG_ERROR_READ 0x0f +#define SMC_REG_INTSTATUS 0x11 +#define SMC_REG_INTSTATUS_POWER 0x01 +#define SMC_REG_INTSTATUS_TRAYCLOSED 0x02 +#define SMC_REG_INTSTATUS_TRAYOPENING 0x04 +#define SMC_REG_INTSTATUS_AVPACK_PLUG 0x08 +#define SMC_REG_INTSTATUS_AVPACK_UNPLUG 0x10 +#define SMC_REG_INTSTATUS_EJECT_BUTTON 0x20 +#define SMC_REG_INTSTATUS_TRAYCLOSING 0x40 +#define SMC_REG_RESETONEJECT 0x19 +#define SMC_REG_INTEN 0x1a +#define SMC_REG_SCRATCH 0x1b #define SMC_REG_SCRATCH_EJECT_AFTER_BOOT 0x01 #define SMC_REG_SCRATCH_ERROR_AFTER_BOOT 0x02 -#define SMC_REG_SCRATCH_SHORT_ANIMATION 0x04 +#define SMC_REG_SCRATCH_SHORT_ANIMATION 0x04 #define SMC_REG_SCRATCH_FORCE_DASH_BOOT 0x08 #define SMC_VERSION_LENGTH 3 @@ -126,10 +128,11 @@ static int smc_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) buf++; len--; - if (len < 1) return 0; + if (len < 1) + return 0; DPRINTF("smc_write_byte: addr=0x%02x cmd=0x%02x val=0x%02x\n", - dev->i2c.address, cmd, buf[0]); + dev->i2c.address, cmd, buf[0]); switch (cmd) { case SMC_REG_VER: @@ -183,15 +186,15 @@ static int smc_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) static uint8_t smc_receive_byte(SMBusDevice *dev) { SMBusSMCDevice *smc = XBOX_SMC(dev); - DPRINTF("smc_receive_byte: addr=0x%02x cmd=0x%02x\n", - dev->i2c.address, smc->cmd); + DPRINTF("smc_receive_byte: addr=0x%02x cmd=0x%02x\n", dev->i2c.address, + smc->cmd); uint8_t cmd = smc->cmd++; switch (cmd) { case SMC_REG_VER: - return smc->version_string[ - smc->version_string_index++ % SMC_VERSION_LENGTH]; + return smc + ->version_string[smc->version_string_index++ % SMC_VERSION_LENGTH]; case SMC_REG_TRAYSTATE: return smc->traystate_reg; @@ -259,7 +262,8 @@ bool xbox_smc_avpack_to_reg(const char *avpack, uint8_t *value) void xbox_smc_append_avpack_hint(Error **errp) { - error_append_hint(errp, "Valid options are: composite, scart, svideo, vga, rfu, hdtv (default), none\n"); + error_append_hint(errp, "Valid options are: composite, scart, svideo, vga, " + "rfu, hdtv (default), none\n"); } void xbox_smc_append_smc_version_hint(Error **errp) @@ -301,10 +305,12 @@ static void smbus_smc_realize(DeviceState *dev, Error **errp) g_free(avpack); } - smc_version = object_property_get_str(qdev_get_machine(), "smc-version", NULL); + smc_version = + object_property_get_str(qdev_get_machine(), "smc-version", NULL); if (smc_version) { if (strlen(smc_version) != SMC_VERSION_LENGTH) { - error_setg(errp, "Unsupported SMC version string '%s'", smc_version); + error_setg(errp, "Unsupported SMC version string '%s'", + smc_version); xbox_smc_append_smc_version_hint(errp); } smc->version_string = g_strdup(smc_version); @@ -339,7 +345,7 @@ static void smbus_smc_register_devices(void) type_init(smbus_smc_register_devices) -void smbus_xbox_smc_init(I2CBus *smbus, int address) + void smbus_xbox_smc_init(I2CBus *smbus, int address) { DeviceState *dev; dev = qdev_new(TYPE_XBOX_SMC); @@ -386,9 +392,9 @@ void xbox_smc_update_tray_state(void) smc->intstatus_reg |= SMC_REG_INTSTATUS_TRAYOPENING; } else { BlockDriverState *bs = blk_bs(blk); - smc->traystate_reg = (bs && bs->drv) - ? SMC_REG_TRAYSTATE_MEDIA_DETECTED - : SMC_REG_TRAYSTATE_NO_MEDIA_DETECTED; + smc->traystate_reg = (bs && bs->drv) ? + SMC_REG_TRAYSTATE_MEDIA_DETECTED : + SMC_REG_TRAYSTATE_NO_MEDIA_DETECTED; smc->intstatus_reg |= SMC_REG_INTSTATUS_TRAYCLOSED; } diff --git a/hw/xbox/xbox.c b/hw/xbox/xbox.c index 88b48b68e77..6c95e9efdf2 100644 --- a/hw/xbox/xbox.c +++ b/hw/xbox/xbox.c @@ -19,41 +19,41 @@ */ #include "qemu/osdep.h" -#include "qemu/option.h" -#include "qemu/datadir.h" +#include "hw/boards.h" +#include "hw/dma/i8257.h" #include "hw/hw.h" -#include "hw/loader.h" #include "hw/i386/pc.h" +#include "hw/ide/pci.h" +#include "hw/kvm/clock.h" +#include "hw/loader.h" #include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" #include "hw/usb.h" #include "net/net.h" -#include "hw/boards.h" -#include "hw/ide/pci.h" -#include "sysemu/sysemu.h" +#include "qemu/datadir.h" +#include "qemu/option.h" #include "sysemu/kvm.h" +#include "sysemu/sysemu.h" #include "kvm/kvm_i386.h" -#include "hw/kvm/clock.h" -#include "hw/dma/i8257.h" +#include "exec/address-spaces.h" +#include "exec/memory.h" #include "hw/sysbus.h" #include "sysemu/arch_init.h" -#include "exec/memory.h" -#include "exec/address-spaces.h" #include "cpu.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "hw/timer/i8254.h" #include "hw/audio/pcspk.h" #include "hw/rtc/mc146818rtc.h" +#include "hw/timer/i8254.h" -#include "hw/xbox/xbox_pci.h" #include "hw/i2c/i2c.h" #include "hw/i2c/smbus_eeprom.h" -#include "hw/xbox/nv2a/nv2a.h" #include "hw/xbox/mcpx/apu.h" +#include "hw/xbox/nv2a/nv2a.h" +#include "hw/xbox/xbox_pci.h" #include "hw/xbox/xbox.h" #include "smbus.h" @@ -98,7 +98,8 @@ static void xbox_flash_init(MachineState *ms, MemoryRegion *rom_memory) } if (failed_to_load_bios) { - fprintf(stderr, "Failed to load BIOS '%s'\n", filename ? filename : "(null)"); + fprintf(stderr, "Failed to load BIOS '%s'\n", + filename ? filename : "(null)"); memset(bios_data, 0xff, bios_size); } if (filename != NULL) { @@ -173,13 +174,12 @@ static void xbox_flash_init(MachineState *ms, MemoryRegion *rom_memory) g_free(bios_data); /* duplicated by `rom_add_blob_fixed` */ } -static void xbox_memory_init(PCMachineState *pcms, - MemoryRegion *system_memory, +static void xbox_memory_init(PCMachineState *pcms, MemoryRegion *system_memory, MemoryRegion *rom_memory, MemoryRegion **ram_memory) { // int linux_boot, i; - MemoryRegion *ram;//, *option_rom_mr; + MemoryRegion *ram; //, *option_rom_mr; // FWCfgState *fw_cfg; MachineState *machine = MACHINE(pcms); // PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); @@ -191,8 +191,8 @@ static void xbox_memory_init(PCMachineState *pcms, * with older qemus that used qemu_ram_alloc(). */ ram = g_malloc(sizeof(*ram)); - memory_region_init_ram(ram, NULL, "xbox.ram", - machine->ram_size, &error_fatal); + memory_region_init_ram(ram, NULL, "xbox.ram", machine->ram_size, + &error_fatal); *ram_memory = ram; memory_region_add_subregion(system_memory, 0, ram); @@ -207,8 +207,7 @@ static void xbox_init(MachineState *machine) xbox_init_common(machine, NULL, NULL); } -void xbox_init_common(MachineState *machine, - PCIBus **pci_bus_out, +void xbox_init_common(MachineState *machine, PCIBus **pci_bus_out, ISABus **isa_bus_out) { PCMachineState *pcms = PC_MACHINE(machine); @@ -259,13 +258,8 @@ void xbox_init_common(MachineState *machine, gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled); - xbox_pci_init(x86ms->gsi, - get_system_memory(), get_system_io(), - pci_memory, ram_memory, rom_memory, - &pci_bus, - &isa_bus, - &smbus, - &agp_bus); + xbox_pci_init(x86ms->gsi, get_system_memory(), get_system_io(), pci_memory, + ram_memory, rom_memory, &pci_bus, &isa_bus, &smbus, &agp_bus); pcms->bus = pci_bus; @@ -366,23 +360,21 @@ void xbox_init_common(MachineState *machine, static void xbox_machine_options(MachineClass *m) { PCMachineClass *pcmc = PC_MACHINE_CLASS(m); - m->desc = "Microsoft Xbox"; - m->max_cpus = 1; + m->desc = "Microsoft Xbox"; + m->max_cpus = 1; m->option_rom_has_mr = true; - m->rom_file_has_mr = false; - m->no_floppy = 1, - m->no_cdrom = 1, - m->no_sdcard = 1, - m->default_cpu_type = X86_CPU_TYPE_NAME("pentium3"); - m->is_default = true; - - pcmc->pci_enabled = true; - pcmc->has_acpi_build = false; - pcmc->smbios_defaults = false; - pcmc->gigabyte_align = false; - pcmc->smbios_legacy_mode = true; + m->rom_file_has_mr = false; + m->no_floppy = 1, m->no_cdrom = 1, m->no_sdcard = 1, + m->default_cpu_type = X86_CPU_TYPE_NAME("pentium3"); + m->is_default = true; + + pcmc->pci_enabled = true; + pcmc->has_acpi_build = false; + pcmc->smbios_defaults = false; + pcmc->gigabyte_align = false; + pcmc->smbios_legacy_mode = true; pcmc->has_reserved_memory = false; - pcmc->default_nic_model = "nvnet"; + pcmc->default_nic_model = "nvnet"; } static char *machine_get_bootrom(Object *obj, Error **errp) @@ -392,8 +384,7 @@ static char *machine_get_bootrom(Object *obj, Error **errp) return g_strdup(ms->bootrom); } -static void machine_set_bootrom(Object *obj, const char *value, - Error **errp) +static void machine_set_bootrom(Object *obj, const char *value, Error **errp) { XboxMachineState *ms = XBOX_MACHINE(obj); @@ -408,8 +399,7 @@ static char *machine_get_avpack(Object *obj, Error **errp) return g_strdup(ms->avpack); } -static void machine_set_avpack(Object *obj, const char *value, - Error **errp) +static void machine_set_avpack(Object *obj, const char *value, Error **errp) { XboxMachineState *ms = XBOX_MACHINE(obj); @@ -423,8 +413,7 @@ static void machine_set_avpack(Object *obj, const char *value, ms->avpack = g_strdup(value); } -static void machine_set_short_animation(Object *obj, bool value, - Error **errp) +static void machine_set_short_animation(Object *obj, bool value, Error **errp) { XboxMachineState *ms = XBOX_MACHINE(obj); @@ -457,7 +446,7 @@ static char *machine_get_smc_version(Object *obj, Error **errp) } static void machine_set_smc_version(Object *obj, const char *value, - Error **errp) + Error **errp) { XboxMachineState *ms = XBOX_MACHINE(obj); @@ -479,17 +468,17 @@ static char *machine_get_video_encoder(Object *obj, Error **errp) } static void machine_set_video_encoder(Object *obj, const char *value, - Error **errp) + Error **errp) { XboxMachineState *ms = XBOX_MACHINE(obj); - if (strcmp(value, "conexant") != 0 && - strcmp(value, "focus") != 0 && - strcmp(value, "xcalibur") != 0 - ) { - error_setg(errp, "-machine video_encoder=%s: unsupported option", value); - error_append_hint(errp, "Valid options are: conexant (default), focus, xcalibur\n"); - return; + if (strcmp(value, "conexant") != 0 && strcmp(value, "focus") != 0 && + strcmp(value, "xcalibur") != 0) { + error_setg(errp, "-machine video_encoder=%s: unsupported option", + value); + error_append_hint( + errp, "Valid options are: conexant (default), focus, xcalibur\n"); + return; } g_free(ms->video_encoder); @@ -500,13 +489,13 @@ static inline void xbox_machine_initfn(Object *obj) { object_property_add_str(obj, "bootrom", machine_get_bootrom, machine_set_bootrom); - object_property_set_description(obj, "bootrom", - "Xbox bootrom file"); + object_property_set_description(obj, "bootrom", "Xbox bootrom file"); object_property_add_str(obj, "avpack", machine_get_avpack, machine_set_avpack); object_property_set_description(obj, "avpack", - "Xbox video connector: composite, scart, svideo, vga, rfu, hdtv (default), none"); + "Xbox video connector: composite, scart, " + "svideo, vga, rfu, hdtv (default), none"); object_property_set_str(obj, "avpack", "hdtv", &error_fatal); object_property_add_bool(obj, "short-animation", @@ -525,16 +514,16 @@ static inline void xbox_machine_initfn(Object *obj) object_property_add_str(obj, "smc-version", machine_get_smc_version, machine_set_smc_version); - object_property_set_description(obj, "smc-version", - "Set the SMC version number, default is P01"); + object_property_set_description( + obj, "smc-version", "Set the SMC version number, default is P01"); object_property_set_str(obj, "smc-version", "P01", &error_fatal); object_property_add_str(obj, "video-encoder", machine_get_video_encoder, machine_set_video_encoder); object_property_set_description(obj, "video-encoder", - "Set the encoder presented to the OS: conexant (default), focus, xcalibur"); + "Set the encoder presented to the OS: " + "conexant (default), focus, xcalibur"); object_property_set_str(obj, "video-encoder", "conexant", &error_fatal); - } static void xbox_machine_class_init(ObjectClass *oc, void *data) @@ -552,11 +541,10 @@ static const TypeInfo pc_machine_type_xbox = { .instance_init = xbox_machine_initfn, .class_size = sizeof(XboxMachineClass), .class_init = xbox_machine_class_init, - .interfaces = (InterfaceInfo[]) { - // { TYPE_HOTPLUG_HANDLER }, - // { TYPE_NMI }, - { } - }, + .interfaces = + (InterfaceInfo[]){ // { TYPE_HOTPLUG_HANDLER }, + // { TYPE_NMI }, + {} }, }; static void pc_machine_init_xbox(void) diff --git a/hw/xbox/xbox.h b/hw/xbox/xbox.h index 8a6aac6d588..7d4e9ff2ba2 100644 --- a/hw/xbox/xbox.h +++ b/hw/xbox/xbox.h @@ -25,8 +25,7 @@ #define MAX_IDE_BUS 2 -void xbox_init_common(MachineState *machine, - PCIBus **pci_bus_out, +void xbox_init_common(MachineState *machine, PCIBus **pci_bus_out, ISABus **isa_bus_out); #define TYPE_XBOX_MACHINE MACHINE_TYPE_NAME("xbox") diff --git a/softmmu/vl.c b/softmmu/vl.c index 25cfe13cf14..16be9d36bce 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -23,75 +23,75 @@ */ #include "qemu/osdep.h" -#include "qemu/help-texts.h" -#include "qemu/datadir.h" -#include "qemu/units.h" #include "exec/cpu-common.h" #include "exec/page-vary.h" #include "hw/qdev-properties.h" #include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" -#include "qemu-version.h" +#include "qapi/qmp/qstring.h" #include "qemu/cutils.h" +#include "qemu/datadir.h" +#include "qemu/help-texts.h" #include "qemu/help_option.h" #include "qemu/hw-version.h" +#include "qemu/units.h" #include "qemu/uuid.h" #include "sysemu/reset.h" -#include "sysemu/runstate.h" #include "sysemu/runstate-action.h" +#include "sysemu/runstate.h" #include "sysemu/seccomp.h" #include "sysemu/tcg.h" #include "sysemu/xen.h" +#include "qemu-version.h" -#include "qemu/error-report.h" -#include "qemu/sockets.h" -#include "qemu/accel.h" -#include "hw/usb.h" -#include "hw/isa/isa.h" -#include "hw/scsi/scsi.h" +#include "chardev/char.h" +#include "exec/gdbstub.h" +#include "hw/acpi/acpi.h" +#include "hw/audio/soundhw.h" +#include "hw/block/block.h" #include "hw/display/vga.h" #include "hw/firmware/smbios.h" -#include "hw/acpi/acpi.h" -#include "hw/xen/xen.h" +#include "hw/i386/pc.h" +#include "hw/i386/x86.h" +#include "hw/isa/isa.h" #include "hw/loader.h" +#include "hw/scsi/scsi.h" +#include "hw/usb.h" +#include "hw/xen/xen.h" +#include "migration/colo.h" +#include "migration/misc.h" +#include "migration/postcopy-ram.h" +#include "migration/snapshot.h" +#include "monitor/monitor.h" #include "monitor/qdev.h" #include "net/net.h" #include "net/slirp.h" -#include "monitor/monitor.h" -#include "ui/console.h" -#include "ui/input.h" -#include "sysemu/sysemu.h" -#include "sysemu/numa.h" -#include "sysemu/hostmem.h" -#include "exec/gdbstub.h" -#include "qemu/timer.h" -#include "chardev/char.h" +#include "qapi/qobject-input-visitor.h" +#include "qemu/accel.h" #include "qemu/bitmap.h" +#include "qemu/config-file.h" +#include "qemu/error-report.h" #include "qemu/log.h" +#include "qemu/main-loop.h" +#include "qemu/option.h" +#include "qemu/qemu-options.h" +#include "qemu/sockets.h" +#include "qemu/timer.h" #include "sysemu/blockdev.h" -#include "hw/block/block.h" -#include "hw/i386/x86.h" -#include "hw/i386/pc.h" -#include "migration/misc.h" -#include "migration/snapshot.h" -#include "sysemu/tpm.h" -#include "sysemu/dma.h" -#include "hw/audio/soundhw.h" -#include "audio/audio.h" -#include "sysemu/cpus.h" #include "sysemu/cpu-timers.h" -#include "migration/colo.h" -#include "migration/postcopy-ram.h" -#include "sysemu/kvm.h" +#include "sysemu/cpus.h" +#include "sysemu/dma.h" #include "sysemu/hax.h" -#include "qapi/qobject-input-visitor.h" -#include "qemu/option.h" -#include "qemu/config-file.h" -#include "qemu/qemu-options.h" -#include "qemu/main-loop.h" +#include "sysemu/hostmem.h" +#include "sysemu/kvm.h" +#include "sysemu/numa.h" +#include "sysemu/sysemu.h" +#include "sysemu/tpm.h" +#include "ui/console.h" +#include "ui/input.h" +#include "audio/audio.h" #ifdef CONFIG_VIRTFS #include "fsdev/qemu-fsdev.h" #endif @@ -99,47 +99,47 @@ #include "disas/disas.h" -#include "trace.h" -#include "trace/control.h" +#include "exec/confidential-guest-support.h" #include "qemu/plugin.h" #include "qemu/queue.h" #include "sysemu/arch_init.h" -#include "exec/confidential-guest-support.h" +#include "trace.h" +#include "trace/control.h" -#include "ui/qemu-spice.h" -#include "qapi/string-input-visitor.h" -#include "qapi/opts-visitor.h" -#include "qapi/clone-visitor.h" -#include "qom/object_interfaces.h" -#include "semihosting/semihost.h" +#include "block/qdict.h" #include "crypto/init.h" -#include "sysemu/replay.h" +#include "qapi/clone-visitor.h" +#include "qapi/opts-visitor.h" +#include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-ui.h" #include "qapi/qapi-events-run-state.h" #include "qapi/qapi-types-audio.h" #include "qapi/qapi-visit-audio.h" #include "qapi/qapi-visit-block-core.h" #include "qapi/qapi-visit-compat.h" #include "qapi/qapi-visit-machine.h" -#include "qapi/qapi-visit-ui.h" -#include "qapi/qapi-commands-block-core.h" -#include "qapi/qapi-commands-migration.h" -#include "qapi/qapi-commands-misc.h" #include "qapi/qapi-visit-qom.h" -#include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-visit-ui.h" #include "qapi/qmp/qdict.h" -#include "block/qdict.h" #include "qapi/qmp/qerror.h" -#include "sysemu/iothread.h" +#include "qapi/string-input-visitor.h" #include "qemu/guest-random.h" #include "qemu/keyval.h" +#include "qom/object_interfaces.h" +#include "sysemu/iothread.h" +#include "sysemu/replay.h" +#include "ui/qemu-spice.h" +#include "semihosting/semihost.h" #include "config-host.h" -#include "ui/xemu-settings.h" -#include "ui/xemu-notifications.h" -#include "ui/xemu-net.h" -#include "ui/xemu-input.h" #include "hw/xbox/eeprom_generation.h" +#include "ui/xemu-input.h" +#include "ui/xemu-net.h" +#include "ui/xemu-notifications.h" +#include "ui/xemu-settings.h" #define MAX_VIRTIO_CONSOLES 1 @@ -170,8 +170,10 @@ static const char *accelerators; static bool have_custom_ram_size; static const char *ram_memdev_id; static QDict *machine_opts_dict; -static QTAILQ_HEAD(, ObjectOption) object_opts = QTAILQ_HEAD_INITIALIZER(object_opts); -static QTAILQ_HEAD(, DeviceOption) device_opts = QTAILQ_HEAD_INITIALIZER(device_opts); +static QTAILQ_HEAD(, ObjectOption) + object_opts = QTAILQ_HEAD_INITIALIZER(object_opts); +static QTAILQ_HEAD(, DeviceOption) + device_opts = QTAILQ_HEAD_INITIALIZER(device_opts); static int display_remote; static int snapshot; static bool preconfig_requested; @@ -203,59 +205,58 @@ static struct { const char *driver; int *flag; } default_list[] = { - { .driver = "isa-serial", .flag = &default_serial }, - { .driver = "isa-parallel", .flag = &default_parallel }, - { .driver = "isa-fdc", .flag = &default_floppy }, - { .driver = "floppy", .flag = &default_floppy }, - { .driver = "ide-cd", .flag = &default_cdrom }, - { .driver = "ide-hd", .flag = &default_cdrom }, - { .driver = "scsi-cd", .flag = &default_cdrom }, - { .driver = "scsi-hd", .flag = &default_cdrom }, - { .driver = "VGA", .flag = &default_vga }, - { .driver = "isa-vga", .flag = &default_vga }, - { .driver = "cirrus-vga", .flag = &default_vga }, - { .driver = "isa-cirrus-vga", .flag = &default_vga }, - { .driver = "vmware-svga", .flag = &default_vga }, - { .driver = "qxl-vga", .flag = &default_vga }, - { .driver = "virtio-vga", .flag = &default_vga }, - { .driver = "ati-vga", .flag = &default_vga }, - { .driver = "vhost-user-vga", .flag = &default_vga }, - { .driver = "virtio-vga-gl", .flag = &default_vga }, + { .driver = "isa-serial", .flag = &default_serial }, + { .driver = "isa-parallel", .flag = &default_parallel }, + { .driver = "isa-fdc", .flag = &default_floppy }, + { .driver = "floppy", .flag = &default_floppy }, + { .driver = "ide-cd", .flag = &default_cdrom }, + { .driver = "ide-hd", .flag = &default_cdrom }, + { .driver = "scsi-cd", .flag = &default_cdrom }, + { .driver = "scsi-hd", .flag = &default_cdrom }, + { .driver = "VGA", .flag = &default_vga }, + { .driver = "isa-vga", .flag = &default_vga }, + { .driver = "cirrus-vga", .flag = &default_vga }, + { .driver = "isa-cirrus-vga", .flag = &default_vga }, + { .driver = "vmware-svga", .flag = &default_vga }, + { .driver = "qxl-vga", .flag = &default_vga }, + { .driver = "virtio-vga", .flag = &default_vga }, + { .driver = "ati-vga", .flag = &default_vga }, + { .driver = "vhost-user-vga", .flag = &default_vga }, + { .driver = "virtio-vga-gl", .flag = &default_vga }, }; static QemuOptsList qemu_rtc_opts = { .name = "rtc", .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head), .merge_lists = true, - .desc = { - { - .name = "base", - .type = QEMU_OPT_STRING, - },{ - .name = "clock", - .type = QEMU_OPT_STRING, - },{ - .name = "driftfix", - .type = QEMU_OPT_STRING, - }, - { /* end of list */ } - }, + .desc = { { + .name = "base", + .type = QEMU_OPT_STRING, + }, + { + .name = "clock", + .type = QEMU_OPT_STRING, + }, + { + .name = "driftfix", + .type = QEMU_OPT_STRING, + }, + { /* end of list */ } }, }; static QemuOptsList qemu_option_rom_opts = { .name = "option-rom", .implied_opt_name = "romfile", .head = QTAILQ_HEAD_INITIALIZER(qemu_option_rom_opts.head), - .desc = { - { - .name = "bootindex", - .type = QEMU_OPT_NUMBER, - }, { - .name = "romfile", - .type = QEMU_OPT_STRING, - }, - { /* end of list */ } - }, + .desc = { { + .name = "bootindex", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "romfile", + .type = QEMU_OPT_STRING, + }, + { /* end of list */ } }, }; static QemuOptsList qemu_accel_opts = { @@ -277,61 +278,64 @@ static QemuOptsList qemu_boot_opts = { .implied_opt_name = "order", .merge_lists = true, .head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head), - .desc = { - { - .name = "order", - .type = QEMU_OPT_STRING, - }, { - .name = "once", - .type = QEMU_OPT_STRING, - }, { - .name = "menu", - .type = QEMU_OPT_BOOL, - }, { - .name = "splash", - .type = QEMU_OPT_STRING, - }, { - .name = "splash-time", - .type = QEMU_OPT_NUMBER, - }, { - .name = "reboot-timeout", - .type = QEMU_OPT_NUMBER, - }, { - .name = "strict", - .type = QEMU_OPT_BOOL, - }, - { /*End of list */ } - }, + .desc = { { + .name = "order", + .type = QEMU_OPT_STRING, + }, + { + .name = "once", + .type = QEMU_OPT_STRING, + }, + { + .name = "menu", + .type = QEMU_OPT_BOOL, + }, + { + .name = "splash", + .type = QEMU_OPT_STRING, + }, + { + .name = "splash-time", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "reboot-timeout", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "strict", + .type = QEMU_OPT_BOOL, + }, + { /*End of list */ } }, }; static QemuOptsList qemu_add_fd_opts = { .name = "add-fd", .head = QTAILQ_HEAD_INITIALIZER(qemu_add_fd_opts.head), - .desc = { - { - .name = "fd", - .type = QEMU_OPT_NUMBER, - .help = "file descriptor of which a duplicate is added to fd set", - },{ - .name = "set", - .type = QEMU_OPT_NUMBER, - .help = "ID of the fd set to add fd to", - },{ - .name = "opaque", - .type = QEMU_OPT_STRING, - .help = "free-form string used to describe fd", - }, - { /* end of list */ } - }, + .desc = { { + .name = "fd", + .type = QEMU_OPT_NUMBER, + .help = + "file descriptor of which a duplicate is added to fd set", + }, + { + .name = "set", + .type = QEMU_OPT_NUMBER, + .help = "ID of the fd set to add fd to", + }, + { + .name = "opaque", + .type = QEMU_OPT_STRING, + .help = "free-form string used to describe fd", + }, + { /* end of list */ } }, }; static QemuOptsList qemu_object_opts = { .name = "object", .implied_opt_name = "qom-type", .head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head), - .desc = { - { } - }, + .desc = { {} }, }; static QemuOptsList qemu_tpmdev_opts = { @@ -347,35 +351,31 @@ static QemuOptsList qemu_tpmdev_opts = { static QemuOptsList qemu_overcommit_opts = { .name = "overcommit", .head = QTAILQ_HEAD_INITIALIZER(qemu_overcommit_opts.head), - .desc = { - { - .name = "mem-lock", - .type = QEMU_OPT_BOOL, - }, - { - .name = "cpu-pm", - .type = QEMU_OPT_BOOL, - }, - { /* end of list */ } - }, + .desc = { { + .name = "mem-lock", + .type = QEMU_OPT_BOOL, + }, + { + .name = "cpu-pm", + .type = QEMU_OPT_BOOL, + }, + { /* end of list */ } }, }; static QemuOptsList qemu_msg_opts = { .name = "msg", .head = QTAILQ_HEAD_INITIALIZER(qemu_msg_opts.head), - .desc = { - { - .name = "timestamp", - .type = QEMU_OPT_BOOL, - }, - { - .name = "guest-name", - .type = QEMU_OPT_BOOL, - .help = "Prepends guest name for error messages but only if " - "-name guest is set otherwise option is ignored\n", - }, - { /* end of list */ } - }, + .desc = { { + .name = "timestamp", + .type = QEMU_OPT_BOOL, + }, + { + .name = "guest-name", + .type = QEMU_OPT_BOOL, + .help = "Prepends guest name for error messages but only if " + "-name guest is set otherwise option is ignored\n", + }, + { /* end of list */ } }, }; static QemuOptsList qemu_name_opts = { @@ -383,26 +383,29 @@ static QemuOptsList qemu_name_opts = { .implied_opt_name = "guest", .merge_lists = true, .head = QTAILQ_HEAD_INITIALIZER(qemu_name_opts.head), - .desc = { - { - .name = "guest", - .type = QEMU_OPT_STRING, - .help = "Sets the name of the guest.\n" - "This name will be displayed in the SDL window caption.\n" - "The name will also be used for the VNC server", - }, { - .name = "process", - .type = QEMU_OPT_STRING, - .help = "Sets the name of the QEMU process, as shown in top etc", - }, { - .name = "debug-threads", - .type = QEMU_OPT_BOOL, - .help = "When enabled, name the individual threads; defaults off.\n" - "NOTE: The thread names are for debugging and not a\n" - "stable API.", - }, - { /* End of list */ } - }, + .desc = { { + .name = "guest", + .type = QEMU_OPT_STRING, + .help = + "Sets the name of the guest.\n" + "This name will be displayed in the SDL window caption.\n" + "The name will also be used for the VNC server", + }, + { + .name = "process", + .type = QEMU_OPT_STRING, + .help = + "Sets the name of the QEMU process, as shown in top etc", + }, + { + .name = "debug-threads", + .type = QEMU_OPT_BOOL, + .help = "When enabled, name the individual threads; defaults " + "off.\n" + "NOTE: The thread names are for debugging and not a\n" + "stable API.", + }, + { /* End of list */ } }, }; static QemuOptsList qemu_mem_opts = { @@ -410,21 +413,19 @@ static QemuOptsList qemu_mem_opts = { .implied_opt_name = "size", .head = QTAILQ_HEAD_INITIALIZER(qemu_mem_opts.head), .merge_lists = true, - .desc = { - { - .name = "size", - .type = QEMU_OPT_SIZE, - }, - { - .name = "slots", - .type = QEMU_OPT_NUMBER, - }, - { - .name = "maxmem", - .type = QEMU_OPT_SIZE, - }, - { /* end of list */ } - }, + .desc = { { + .name = "size", + .type = QEMU_OPT_SIZE, + }, + { + .name = "slots", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "maxmem", + .type = QEMU_OPT_SIZE, + }, + { /* end of list */ } }, }; static QemuOptsList qemu_icount_opts = { @@ -432,78 +433,84 @@ static QemuOptsList qemu_icount_opts = { .implied_opt_name = "shift", .merge_lists = true, .head = QTAILQ_HEAD_INITIALIZER(qemu_icount_opts.head), - .desc = { - { - .name = "shift", - .type = QEMU_OPT_STRING, - }, { - .name = "align", - .type = QEMU_OPT_BOOL, - }, { - .name = "sleep", - .type = QEMU_OPT_BOOL, - }, { - .name = "rr", - .type = QEMU_OPT_STRING, - }, { - .name = "rrfile", - .type = QEMU_OPT_STRING, - }, { - .name = "rrsnapshot", - .type = QEMU_OPT_STRING, - }, - { /* end of list */ } - }, + .desc = { { + .name = "shift", + .type = QEMU_OPT_STRING, + }, + { + .name = "align", + .type = QEMU_OPT_BOOL, + }, + { + .name = "sleep", + .type = QEMU_OPT_BOOL, + }, + { + .name = "rr", + .type = QEMU_OPT_STRING, + }, + { + .name = "rrfile", + .type = QEMU_OPT_STRING, + }, + { + .name = "rrsnapshot", + .type = QEMU_OPT_STRING, + }, + { /* end of list */ } }, }; static QemuOptsList qemu_fw_cfg_opts = { .name = "fw_cfg", .implied_opt_name = "name", .head = QTAILQ_HEAD_INITIALIZER(qemu_fw_cfg_opts.head), - .desc = { - { - .name = "name", - .type = QEMU_OPT_STRING, - .help = "Sets the fw_cfg name of the blob to be inserted", - }, { - .name = "file", - .type = QEMU_OPT_STRING, - .help = "Sets the name of the file from which " - "the fw_cfg blob will be loaded", - }, { - .name = "string", - .type = QEMU_OPT_STRING, - .help = "Sets content of the blob to be inserted from a string", - }, { - .name = "gen_id", - .type = QEMU_OPT_STRING, - .help = "Sets id of the object generating the fw_cfg blob " - "to be inserted", - }, - { /* end of list */ } - }, + .desc = { { + .name = "name", + .type = QEMU_OPT_STRING, + .help = "Sets the fw_cfg name of the blob to be inserted", + }, + { + .name = "file", + .type = QEMU_OPT_STRING, + .help = "Sets the name of the file from which " + "the fw_cfg blob will be loaded", + }, + { + .name = "string", + .type = QEMU_OPT_STRING, + .help = + "Sets content of the blob to be inserted from a string", + }, + { + .name = "gen_id", + .type = QEMU_OPT_STRING, + .help = "Sets id of the object generating the fw_cfg blob " + "to be inserted", + }, + { /* end of list */ } }, }; static QemuOptsList qemu_action_opts = { .name = "action", .merge_lists = true, .head = QTAILQ_HEAD_INITIALIZER(qemu_action_opts.head), - .desc = { - { - .name = "shutdown", - .type = QEMU_OPT_STRING, - },{ - .name = "reboot", - .type = QEMU_OPT_STRING, - },{ - .name = "panic", - .type = QEMU_OPT_STRING, - },{ - .name = "watchdog", - .type = QEMU_OPT_STRING, - }, - { /* end of list */ } - }, + .desc = { { + .name = "shutdown", + .type = QEMU_OPT_STRING, + }, + { + .name = "reboot", + .type = QEMU_OPT_STRING, + }, + { + .name = "panic", + .type = QEMU_OPT_STRING, + }, + { + .name = "watchdog", + .type = QEMU_OPT_STRING, + }, + { /* end of list */ } }, }; const char *qemu_get_vm_name(void) @@ -538,7 +545,7 @@ static void default_driver_check_json(void) { DeviceOption *opt; - QTAILQ_FOREACH(opt, &device_opts, next) { + QTAILQ_FOREACH (opt, &device_opts, next) { const char *driver = qdict_get_try_str(opt->opts, "driver"); default_driver_disable(driver); } @@ -677,7 +684,6 @@ static void default_drive(int enable, int snapshot, BlockInterfaceType type, dinfo = drive_new(opts, type, &error_abort); dinfo->is_default = true; - } static void configure_blockdev(BlockdevOptionsQueue *bdo_queue, @@ -705,8 +711,8 @@ static void configure_blockdev(BlockdevOptionsQueue *bdo_queue, g_free(bdo); } if (snapshot) { - qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, - NULL, NULL); + qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, + NULL); } if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine_class->block_default_type, &error_fatal)) { @@ -718,7 +724,6 @@ static void configure_blockdev(BlockdevOptionsQueue *bdo_queue, CDROM_OPTS); default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); - } static QemuOptsList qemu_smp_opts = { @@ -726,31 +731,35 @@ static QemuOptsList qemu_smp_opts = { .implied_opt_name = "cpus", .merge_lists = true, .head = QTAILQ_HEAD_INITIALIZER(qemu_smp_opts.head), - .desc = { - { - .name = "cpus", - .type = QEMU_OPT_NUMBER, - }, { - .name = "sockets", - .type = QEMU_OPT_NUMBER, - }, { - .name = "dies", - .type = QEMU_OPT_NUMBER, - }, { - .name = "clusters", - .type = QEMU_OPT_NUMBER, - }, { - .name = "cores", - .type = QEMU_OPT_NUMBER, - }, { - .name = "threads", - .type = QEMU_OPT_NUMBER, - }, { - .name = "maxcpus", - .type = QEMU_OPT_NUMBER, - }, - { /*End of list */ } - }, + .desc = { { + .name = "cpus", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "sockets", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "dies", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "clusters", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "cores", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "threads", + .type = QEMU_OPT_NUMBER, + }, + { + .name = "maxcpus", + .type = QEMU_OPT_NUMBER, + }, + { /*End of list */ } }, }; static void realtime_init(void) @@ -836,8 +845,7 @@ static MachineClass *find_default_machine(GSList *machines) static void version(void) { - printf("QEMU emulator version " QEMU_FULL_VERSION "\n" - QEMU_COPYRIGHT "\n"); + printf("QEMU emulator version " QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n"); } static void help(int exitcode) @@ -845,14 +853,14 @@ static void help(int exitcode) version(); printf("usage: %s [options] [disk_image]\n\n" "'disk_image' is a raw hard disk image for IDE hard disk 0\n\n", - g_get_prgname()); + g_get_prgname()); -#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ - if ((arch_mask) & arch_type) \ +#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ + if ((arch_mask)&arch_type) \ fputs(opt_help, stdout); #define ARCHHEADING(text, arch_mask) \ - if ((arch_mask) & arch_type) \ + if ((arch_mask)&arch_type) \ puts(stringify(text)); #define DEFHEADING(text) ARCHHEADING(text, QEMU_ARCH_ALL) @@ -865,8 +873,7 @@ static void help(int exitcode) "ctrl-alt toggle mouse and keyboard grab\n" "\n" "When using -nographic, press 'ctrl-a h' to get some help.\n" - "\n" - QEMU_HELP_BOTTOM "\n"); + "\n" QEMU_HELP_BOTTOM "\n"); exit(exitcode); } @@ -883,7 +890,7 @@ typedef struct QEMUOption { static const QEMUOption qemu_options[] = { { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, -#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ +#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ { option, opt_arg, opt_enum, arch_mask }, #define DEFHEADING(text) #define ARCHHEADING(text, arch_mask) @@ -893,8 +900,8 @@ static const QEMUOption qemu_options[] = { }; typedef struct VGAInterfaceInfo { - const char *opt_name; /* option name */ - const char *name; /* human-readable name */ + const char *opt_name; /* option name */ + const char *name; /* human-readable name */ /* Class names indicating that support is available. * If no class is specified, the interface is always available */ const char *class_names[2]; @@ -958,8 +965,7 @@ static bool vga_interface_available(VGAInterfaceType t) module_object_class_by_name(ti->class_names[1]); } -static const char * -get_default_vga_model(const MachineClass *machine_class) +static const char *get_default_vga_model(const MachineClass *machine_class) { if (machine_class->default_display) { return machine_class->default_display; @@ -985,8 +991,8 @@ static void select_vgahw(const MachineClass *machine_class, const char *p) if (vga_interface_available(t) && ti->opt_name) { printf("%-20s %s%s\n", ti->opt_name, ti->name ?: "", - (def && g_str_equal(ti->opt_name, def)) ? - " (default)" : ""); + (def && g_str_equal(ti->opt_name, def)) ? " (default)" : + ""); } } exit(0); @@ -1018,8 +1024,10 @@ static void select_vgahw(const MachineClass *machine_class, const char *p) vga_retrace_method = VGA_RETRACE_DUMB; else if (strstart(opts, "precise", &nextopt)) vga_retrace_method = VGA_RETRACE_PRECISE; - else goto invalid_vga; - } else goto invalid_vga; + else + goto invalid_vga; + } else + goto invalid_vga; opts = nextopt; } } @@ -1078,7 +1086,7 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp) gchar *buf; size_t size; const char *name, *file, *str, *gen_id; - FWCfgState *fw_cfg = (FWCfgState *) opaque; + FWCfgState *fw_cfg = (FWCfgState *)opaque; if (fw_cfg == NULL) { error_setg(errp, "fw_cfg device not available"); @@ -1211,20 +1219,20 @@ static void monitor_parse(const char *optarg, const char *mode, bool pretty) struct device_config { enum { - DEV_USB, /* -usbdevice */ - DEV_SERIAL, /* -serial */ - DEV_PARALLEL, /* -parallel */ - DEV_DEBUGCON, /* -debugcon */ - DEV_GDB, /* -gdb, -s */ - DEV_SCLP, /* s390 sclp */ + DEV_USB, /* -usbdevice */ + DEV_SERIAL, /* -serial */ + DEV_PARALLEL, /* -parallel */ + DEV_DEBUGCON, /* -debugcon */ + DEV_GDB, /* -gdb, -s */ + DEV_SCLP, /* s390 sclp */ } type; const char *cmdline; Location loc; QTAILQ_ENTRY(device_config) next; }; -static QTAILQ_HEAD(, device_config) device_configs = - QTAILQ_HEAD_INITIALIZER(device_configs); +static QTAILQ_HEAD(, device_config) + device_configs = QTAILQ_HEAD_INITIALIZER(device_configs); static void add_device_config(int type, const char *cmdline) { @@ -1242,7 +1250,7 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline)) struct device_config *conf; int rc; - QTAILQ_FOREACH(conf, &device_configs, next) { + QTAILQ_FOREACH (conf, &device_configs, next) { if (conf->type != type) continue; loc_push_restore(&conf->loc); @@ -1260,10 +1268,10 @@ static void qemu_disable_default_devices(void) MachineClass *machine_class = MACHINE_GET_CLASS(current_machine); default_driver_check_json(); - qemu_opts_foreach(qemu_find_opts("device"), - default_driver_check, NULL, NULL); - qemu_opts_foreach(qemu_find_opts("global"), - default_driver_check, NULL, NULL); + qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, + NULL); + qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, + NULL); if (!vga_model && !default_vga) { vga_interface_type = VGA_DEVICE; @@ -1305,8 +1313,8 @@ static void qemu_create_default_devices(void) * -nographic _and_ redirects all ports explicitly - this is valid * usage, -nographic is just a no-op in this case. */ - if (nographic - && (default_parallel || default_serial || default_monitor)) { + if (nographic && + (default_parallel || default_serial || default_monitor)) { error_report("-nographic cannot be used with -daemonize"); exit(1); } @@ -1381,7 +1389,8 @@ static int serial_parse(const char *devname) serial_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL); if (!serial_hds[index]) { error_report("could not connect serial device" - " to character backend '%s'", devname); + " to character backend '%s'", + devname); return -1; } num_serial_hds++; @@ -1412,7 +1421,8 @@ static int parallel_parse(const char *devname) parallel_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL); if (!parallel_hds[index]) { error_report("could not connect parallel device" - " to character backend '%s'", devname); + " to character backend '%s'", + devname); return -1; } index++; @@ -1498,8 +1508,8 @@ static void machine_help_func(const QDict *qdict) } } -static void -machine_merge_property(const char *propname, QDict *prop, Error **errp) +static void machine_merge_property(const char *propname, QDict *prop, + Error **errp) { QDict *opts; @@ -1511,9 +1521,8 @@ machine_merge_property(const char *propname, QDict *prop, Error **errp) qobject_unref(opts); } -static void -machine_parse_property_opt(QemuOptsList *opts_list, const char *propname, - const char *arg) +static void machine_parse_property_opt(QemuOptsList *opts_list, + const char *propname, const char *arg) { QDict *prop = NULL; bool help = false; @@ -1542,8 +1551,8 @@ static void qemu_unlink_pidfile(Notifier *n, void *data) unlink(upn->pid_file_realpath); } -static const QEMUOption *lookup_opt(int argc, char **argv, - const char **poptarg, int *poptind) +static const QEMUOption *lookup_opt(int argc, char **argv, const char **poptarg, + int *poptind) { const QEMUOption *popt; int optind = *poptind; @@ -1556,7 +1565,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv, if (r[1] == '-') r++; popt = qemu_options; - for(;;) { + for (;;) { if (!popt->name) { error_report("invalid option"); exit(1); @@ -1598,21 +1607,23 @@ static MachineClass *select_machine(QDict *qdict, Error **errp) } else { machine_class = find_default_machine(machines); if (!machine_class) { - error_setg(&local_err, "No machine specified, and there is no default"); + error_setg(&local_err, + "No machine specified, and there is no default"); } } g_slist_free(machines); if (local_err) { - error_append_hint(&local_err, "Use -machine help to list supported machines\n"); + error_append_hint(&local_err, + "Use -machine help to list supported machines\n"); error_propagate(errp, local_err); } return machine_class; } -static int object_parse_property_opt(Object *obj, - const char *name, const char *value, - const char *skip, Error **errp) +static int object_parse_property_opt(Object *obj, const char *name, + const char *value, const char *skip, + Error **errp) { if (g_str_equal(name, skip)) { return 0; @@ -1645,7 +1656,8 @@ static void keyval_dashify(QDict *qdict, Error **errp) } } if (qdict_haskey(qdict, new_key)) { - error_setg(errp, "Conflict between '%s' and '%s'", ent->key, new_key); + error_setg(errp, "Conflict between '%s' and '%s'", ent->key, + new_key); return; } qobject_ref(ent->value); @@ -1670,24 +1682,24 @@ static void qemu_apply_legacy_machine_options(QDict *qdict) value = qdict_get_try_str(qdict, "igd-passthru"); if (value) { - object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), "igd-passthru", value, - false); + object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), "igd-passthru", + value, false); qdict_del(qdict, "igd-passthru"); } value = qdict_get_try_str(qdict, "kvm-shadow-mem"); if (value) { - object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), "kvm-shadow-mem", value, - false); + object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), "kvm-shadow-mem", + value, false); qdict_del(qdict, "kvm-shadow-mem"); } value = qdict_get_try_str(qdict, "kernel-irqchip"); if (value) { - object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), "kernel-irqchip", value, - false); - object_register_sugar_prop(ACCEL_CLASS_NAME("whpx"), "kernel-irqchip", value, - false); + object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), "kernel-irqchip", + value, false); + object_register_sugar_prop(ACCEL_CLASS_NAME("whpx"), "kernel-irqchip", + value, false); qdict_del(qdict, "kernel-irqchip"); } @@ -1706,9 +1718,8 @@ static void qemu_apply_legacy_machine_options(QDict *qdict) prop = qdict_get(qdict, "memory"); if (prop) { - have_custom_ram_size = - qobject_type(prop) == QTYPE_QDICT && - qdict_haskey(qobject_to(QDict, prop), "size"); + have_custom_ram_size = qobject_type(prop) == QTYPE_QDICT && + qdict_haskey(qobject_to(QDict, prop), "size"); } } @@ -1716,7 +1727,7 @@ static void object_option_foreach_add(bool (*type_opt_predicate)(const char *)) { ObjectOption *opt, *next; - QTAILQ_FOREACH_SAFE(opt, &object_opts, next, next) { + QTAILQ_FOREACH_SAFE (opt, &object_opts, next, next) { const char *type = ObjectType_str(opt->opts->qom_type); if (type_opt_predicate(type)) { user_creatable_add_qapi(opt->opts, &error_fatal); @@ -1746,8 +1757,7 @@ static void object_option_parse(const char *optarg) v = qobject_input_visitor_new(obj); qobject_unref(obj); } else { - opts = qemu_opts_parse_noisily(qemu_find_opts("object"), - optarg, true); + opts = qemu_opts_parse_noisily(qemu_find_opts("object"), optarg, true); if (!opts) { exit(1); } @@ -1808,8 +1818,7 @@ static bool object_create_early(const char *type) } /* Reason: property "chardev" */ - if (g_str_equal(type, "rng-egd") || - g_str_equal(type, "qtest")) { + if (g_str_equal(type, "rng-egd") || g_str_equal(type, "qtest")) { return false; } @@ -1852,11 +1861,13 @@ static bool object_create_early(const char *type) static void qemu_apply_machine_options(QDict *qdict) { - object_set_properties_from_keyval(OBJECT(current_machine), qdict, false, &error_fatal); + object_set_properties_from_keyval(OBJECT(current_machine), qdict, false, + &error_fatal); if (semihosting_enabled(false) && !semihosting_get_argc()) { /* fall back to the -kernel/-append */ - semihosting_arg_fallback(current_machine->kernel_filename, current_machine->kernel_cmdline); + semihosting_arg_fallback(current_machine->kernel_filename, + current_machine->kernel_cmdline); } if (current_machine->smp.cpus > 1) { @@ -1904,12 +1915,12 @@ static void qemu_create_early_backends(void) /* spice must initialize before chardevs (for spicevmc and spiceport) */ qemu_spice.init(); - qemu_opts_foreach(qemu_find_opts("chardev"), - chardev_init_func, NULL, &error_fatal); + qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, + &error_fatal); #ifdef CONFIG_VIRTFS - qemu_opts_foreach(qemu_find_opts("fsdev"), - fsdev_init_func, NULL, &error_fatal); + qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, + &error_fatal); #endif /* @@ -1952,8 +1963,7 @@ static void qemu_create_late_backends(void) exit(1); } - qemu_opts_foreach(qemu_find_opts("mon"), - mon_init_func, NULL, &error_fatal); + qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, &error_fatal); if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) exit(1); @@ -1972,18 +1982,19 @@ static void qemu_resolve_machine_memdev(void) Object *backend; ram_addr_t backend_size; - backend = object_resolve_path_type(ram_memdev_id, - TYPE_MEMORY_BACKEND, NULL); + backend = + object_resolve_path_type(ram_memdev_id, TYPE_MEMORY_BACKEND, NULL); if (!backend) { error_report("Memory backend '%s' not found", ram_memdev_id); exit(EXIT_FAILURE); } if (!have_custom_ram_size) { - backend_size = object_property_get_uint(backend, "size", &error_abort); + backend_size = + object_property_get_uint(backend, "size", &error_abort); current_machine->ram_size = backend_size; } - object_property_set_link(OBJECT(current_machine), - "memory-backend", backend, &error_fatal); + object_property_set_link(OBJECT(current_machine), "memory-backend", + backend, &error_fatal); } } @@ -2029,12 +2040,13 @@ static void qemu_create_machine(QDict *qdict) MachineClass *machine_class = select_machine(qdict, &error_fatal); object_set_machine_compat_props(machine_class->compat_props); - current_machine = MACHINE(object_new_with_class(OBJECT_CLASS(machine_class))); + current_machine = + MACHINE(object_new_with_class(OBJECT_CLASS(machine_class))); object_property_add_child(object_get_root(), "machine", OBJECT(current_machine)); - object_property_add_child(container_get(OBJECT(current_machine), - "/unattached"), - "sysbus", OBJECT(sysbus_get_default())); + object_property_add_child( + container_get(OBJECT(current_machine), "/unattached"), "sysbus", + OBJECT(sysbus_get_default())); if (machine_class->minimum_page_bits) { if (!set_preferred_target_page_bits(machine_class->minimum_page_bits)) { @@ -2057,9 +2069,8 @@ static void qemu_create_machine(QDict *qdict) * specified either by the configuration file or by the command line. */ if (machine_class->default_machine_opts) { - QDict *default_opts = - keyval_parse(machine_class->default_machine_opts, NULL, NULL, - &error_abort); + QDict *default_opts = keyval_parse(machine_class->default_machine_opts, + NULL, NULL, &error_abort); qemu_apply_legacy_machine_options(default_opts); object_set_properties_from_keyval(OBJECT(current_machine), default_opts, false, &error_abort); @@ -2072,9 +2083,9 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) GlobalProperty *g; g = g_malloc0(sizeof(*g)); - g->driver = qemu_opt_get(opts, "driver"); + g->driver = qemu_opt_get(opts, "driver"); g->property = qemu_opt_get(opts, "property"); - g->value = qemu_opt_get(opts, "value"); + g->value = qemu_opt_get(opts, "value"); qdev_prop_register_global(g); return 0; } @@ -2085,10 +2096,8 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) */ static bool is_qemuopts_group(const char *group) { - if (g_str_equal(group, "object") || - g_str_equal(group, "machine") || - g_str_equal(group, "smp-opts") || - g_str_equal(group, "boot-opts")) { + if (g_str_equal(group, "object") || g_str_equal(group, "machine") || + g_str_equal(group, "smp-opts") || g_str_equal(group, "boot-opts")) { return false; } return true; @@ -2136,10 +2145,12 @@ static void qemu_parse_config_group(const char *group, QDict *qdict, } switch (qobject_type(crumpled)) { case QTYPE_QDICT: - qemu_record_config_group(group, qobject_to(QDict, crumpled), false, errp); + qemu_record_config_group(group, qobject_to(QDict, crumpled), false, + errp); break; case QTYPE_QLIST: - error_setg(errp, "Lists cannot be at top level of a configuration section"); + error_setg(errp, + "Lists cannot be at top level of a configuration section"); break; default: g_assert_not_reached(); @@ -2151,7 +2162,8 @@ static void qemu_read_default_config_file(Error **errp) { ERRP_GUARD(); int ret; - g_autofree char *file = get_relocated_path(CONFIG_QEMU_CONFDIR "/qemu.conf"); + g_autofree char *file = + get_relocated_path(CONFIG_QEMU_CONFDIR "/qemu.conf"); ret = qemu_read_config_file(file, qemu_parse_config_group, errp); if (ret < 0) { @@ -2192,8 +2204,7 @@ static void qemu_set_option(const char *str, Error **errp) static void user_register_global_props(void) { - qemu_opts_foreach(qemu_find_opts("global"), - global_init_func, NULL, NULL); + qemu_opts_foreach(qemu_find_opts("global"), global_init_func, NULL, NULL); } static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) @@ -2202,9 +2213,8 @@ static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) return 0; } -static int accelerator_set_property(void *opaque, - const char *name, const char *value, - Error **errp) +static int accelerator_set_property(void *opaque, const char *name, + const char *value, Error **errp) { return object_parse_property_opt(opaque, name, value, "accel", errp); } @@ -2229,9 +2239,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) } accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac))); object_apply_compat_props(OBJECT(accel)); - qemu_opt_foreach(opts, accelerator_set_property, - accel, - &error_fatal); + qemu_opt_foreach(opts, accelerator_set_property, accel, &error_fatal); ret = accel_init_machine(accel, current_machine); if (ret < 0) { @@ -2249,8 +2257,8 @@ static void configure_accelerators(const char *progname) { bool init_failed = false; - qemu_opts_foreach(qemu_find_opts("icount"), - do_configure_icount, NULL, &error_fatal); + qemu_opts_foreach(qemu_find_opts("icount"), do_configure_icount, NULL, + &error_fatal); if (QTAILQ_EMPTY(&qemu_accel_opts.head)) { char **accel_list, **tmp; @@ -2294,13 +2302,14 @@ static void configure_accelerators(const char *progname) g_strfreev(accel_list); } else { if (accelerators != NULL) { - error_report("The -accel and \"-machine accel=\" options are incompatible"); + error_report( + "The -accel and \"-machine accel=\" options are incompatible"); exit(1); } } - if (!qemu_opts_foreach(qemu_find_opts("accel"), - do_configure_accelerator, &init_failed, &error_fatal)) { + if (!qemu_opts_foreach(qemu_find_opts("accel"), do_configure_accelerator, + &init_failed, &error_fatal)) { if (!init_failed) { error_report("no accelerator found"); } @@ -2329,7 +2338,8 @@ static int xemu_check_file(const char *path) } // Duplicate commas to escape them -static char *strdup_double_commas(const char *input) { +static char *strdup_double_commas(const char *input) +{ size_t length = 0; for (const char *i = input; *i; i++) { if (*i == ',') { @@ -2342,7 +2352,7 @@ static char *strdup_double_commas(const char *input) { char *out = output; while (*in) { if (*in == ',') { - *(out++) = ','; + *(out++) = ','; } *(out++) = *(in++); } @@ -2357,15 +2367,15 @@ static void qemu_validate_options(const QDict *machine_opts) const char *kernel_cmdline = qdict_get_try_str(machine_opts, "append"); if (kernel_filename == NULL) { - if (kernel_cmdline != NULL) { - error_report("-append only allowed with -kernel option"); - exit(1); - } + if (kernel_cmdline != NULL) { + error_report("-append only allowed with -kernel option"); + exit(1); + } - if (initrd_filename != NULL) { - error_report("-initrd only allowed with -kernel option"); - exit(1); - } + if (initrd_filename != NULL) { + error_report("-initrd only allowed with -kernel option"); + exit(1); + } } if (loadvm && preconfig_requested) { @@ -2424,8 +2434,7 @@ static int process_runstate_actions(void *opaque, QemuOpts *opts, Error **errp) static void qemu_process_early_options(void) { - qemu_opts_foreach(qemu_find_opts("name"), - parse_name, NULL, &error_fatal); + qemu_opts_foreach(qemu_find_opts("name"), parse_name, NULL, &error_fatal); object_option_foreach_add(object_create_pre_sandbox); @@ -2436,17 +2445,17 @@ static void qemu_process_early_options(void) } #endif - if (qemu_opts_foreach(qemu_find_opts("action"), - process_runstate_actions, NULL, &error_fatal)) { + if (qemu_opts_foreach(qemu_find_opts("action"), process_runstate_actions, + NULL, &error_fatal)) { exit(1); } #ifndef _WIN32 - qemu_opts_foreach(qemu_find_opts("add-fd"), - parse_add_fd, NULL, &error_fatal); + qemu_opts_foreach(qemu_find_opts("add-fd"), parse_add_fd, NULL, + &error_fatal); - qemu_opts_foreach(qemu_find_opts("add-fd"), - cleanup_add_fd, NULL, &error_fatal); + qemu_opts_foreach(qemu_find_opts("add-fd"), cleanup_add_fd, NULL, + &error_fatal); #endif /* Open the logfile at this point and set the log mask if necessary. */ @@ -2478,8 +2487,8 @@ static void qemu_process_help_options(void) exit(0); } - if (qemu_opts_foreach(qemu_find_opts("device"), - device_help_func, NULL, NULL)) { + if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, + NULL)) { exit(0); } @@ -2507,8 +2516,8 @@ static void qemu_maybe_daemonize(const char *pid_file) pid_file_realpath = g_malloc0(PATH_MAX); if (!realpath(pid_file, pid_file_realpath)) { - error_report("cannot resolve PID file path: %s: %s", - pid_file, strerror(errno)); + error_report("cannot resolve PID file path: %s: %s", pid_file, + strerror(errno)); unlink(pid_file); exit(1); } @@ -2536,8 +2545,7 @@ static void qemu_init_displays(void) /* init remote displays */ #ifdef CONFIG_VNC - qemu_opts_foreach(qemu_find_opts("vnc"), - vnc_init_func, NULL, &error_fatal); + qemu_opts_foreach(qemu_find_opts("vnc"), vnc_init_func, NULL, &error_fatal); #endif if (using_spice) { @@ -2569,8 +2577,8 @@ static void qemu_create_cli_devices(void) soundhw_init(); - qemu_opts_foreach(qemu_find_opts("fw_cfg"), - parse_fw_cfg, fw_cfg_find(), &error_fatal); + qemu_opts_foreach(qemu_find_opts("fw_cfg"), parse_fw_cfg, fw_cfg_find(), + &error_fatal); /* init USB devices */ if (machine_usb(current_machine)) { @@ -2580,9 +2588,9 @@ static void qemu_create_cli_devices(void) /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); - qemu_opts_foreach(qemu_find_opts("device"), - device_init_func, NULL, &error_fatal); - QTAILQ_FOREACH(opt, &device_opts, next) { + qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, + &error_fatal); + QTAILQ_FOREACH (opt, &device_opts, next) { DeviceState *dev; loc_push_restore(&opt->loc); /* @@ -2643,7 +2651,9 @@ static void qemu_machine_creation_done(void) void qmp_x_exit_preconfig(Error **errp) { if (phase_check(PHASE_MACHINE_INITIALIZED)) { - error_setg(errp, "The command is permitted only before machine initialization"); + error_setg( + errp, + "The command is permitted only before machine initialization"); return; } @@ -2696,7 +2706,8 @@ static const char *get_eeprom_path(void) if (size < 0) { char *msg = g_strdup_printf("Failed to open EEPROM file '%s'.\n\n" - "Please check machine settings.", path); + "Please check machine settings.", + path); xemu_queue_error_message(msg); g_free(msg); return NULL; @@ -2705,7 +2716,8 @@ static const char *get_eeprom_path(void) if (size != 256) { char *msg = g_strdup_printf( "Invalid EEPROM file '%s' size of %d; should be 256 bytes.\n\n" - "Please check machine settings.", path, size); + "Please check machine settings.", + path, size); xemu_queue_error_message(msg); g_free(msg); return NULL; @@ -2725,7 +2737,7 @@ void qemu_init(int argc, char **argv) bool userconfig = true; FILE *vmstate_dump_file = NULL; -/*****************************************************************************/ + /*****************************************************************************/ // init earlier because it's needed for eeprom generation qcrypto_init(&error_fatal); @@ -2738,8 +2750,8 @@ void qemu_init(int argc, char **argv) // int fake_argc = 32 + argc; - char **fake_argv = malloc(sizeof(char*)*fake_argc); - memset(fake_argv, 0, sizeof(char*)*fake_argc); + char **fake_argv = malloc(sizeof(char *) * fake_argc); + memset(fake_argv, 0, sizeof(char *) * fake_argc); fake_argc = 0; fake_argv[fake_argc++] = argv[0]; @@ -2773,13 +2785,7 @@ void qemu_init(int argc, char **argv) } const char *avpack_str = (const char *[]){ - "scart", - "hdtv", - "vga", - "rfu", - "svideo", - "composite", - "none", + "scart", "hdtv", "vga", "rfu", "svideo", "composite", "none", }[g_config.sys.avpack]; bool eject_after_boot = false; @@ -2805,8 +2811,8 @@ void qemu_init(int argc, char **argv) if (eeprom_path) { fake_argv[fake_argc++] = strdup("-device"); char *escaped_eeprom_path = strdup_double_commas(eeprom_path); - fake_argv[fake_argc++] = g_strdup_printf("smbus-storage,file=%s", - escaped_eeprom_path); + fake_argv[fake_argc++] = + g_strdup_printf("smbus-storage,file=%s", escaped_eeprom_path); free(escaped_eeprom_path); } else { autostart = 0; @@ -2818,7 +2824,9 @@ void qemu_init(int argc, char **argv) // to configure the path. autostart = 0; } else if (xemu_check_file(flashrom_path)) { - char *msg = g_strdup_printf("Failed to open flash file '%s'. Please check machine settings.", flashrom_path); + char *msg = g_strdup_printf( + "Failed to open flash file '%s'. Please check machine settings.", + flashrom_path); xemu_queue_error_message(msg); g_free(msg); autostart = 0; @@ -2834,14 +2842,16 @@ void qemu_init(int argc, char **argv) const char *hdd_path = g_config.sys.files.hdd_path; if (strlen(hdd_path) > 0) { if (xemu_check_file(hdd_path)) { - char *msg = g_strdup_printf("Failed to open hard disk image file '%s'. Please check machine settings.", hdd_path); + char *msg = g_strdup_printf("Failed to open hard disk image file " + "'%s'. Please check machine settings.", + hdd_path); xemu_queue_error_message(msg); g_free(msg); } else { fake_argv[fake_argc++] = strdup("-drive"); char *escaped_hdd_path = strdup_double_commas(hdd_path); - fake_argv[fake_argc++] = g_strdup_printf("index=0,media=disk,file=%s%s", - escaped_hdd_path, + fake_argv[fake_argc++] = g_strdup_printf( + "index=0,media=disk,file=%s%s", escaped_hdd_path, strlen(escaped_hdd_path) > 0 ? ",locked=on" : ""); free(escaped_hdd_path); } @@ -2852,9 +2862,9 @@ void qemu_init(int argc, char **argv) for (int i = 1; i < argc; i++) { if (argv[i] && strcmp(argv[i], "-dvd_path") == 0) { argv[i] = NULL; - if (i < argc - 1 && argv[i+1]) { - dvd_path = argv[i+1]; - argv[i+1] = NULL; + if (i < argc - 1 && argv[i + 1]) { + dvd_path = argv[i + 1]; + argv[i + 1] = NULL; } break; } @@ -2862,7 +2872,9 @@ void qemu_init(int argc, char **argv) if (strlen(dvd_path) > 0) { if (xemu_check_file(dvd_path) || strcmp(dvd_path, hdd_path) == 0) { - char *msg = g_strdup_printf("Failed to open DVD image file '%s'. Please check machine settings.", dvd_path); + char *msg = g_strdup_printf("Failed to open DVD image file '%s'. " + "Please check machine settings.", + dvd_path); xemu_queue_error_message(msg); g_free(msg); dvd_path = ""; @@ -2873,14 +2885,15 @@ void qemu_init(int argc, char **argv) // connected but no media present. fake_argv[fake_argc++] = strdup("-drive"); char *escaped_dvd_path = strdup_double_commas(dvd_path); - fake_argv[fake_argc++] = g_strdup_printf("index=1,media=cdrom,file=%s", - escaped_dvd_path); + fake_argv[fake_argc++] = + g_strdup_printf("index=1,media=cdrom,file=%s", escaped_dvd_path); free(escaped_dvd_path); fake_argv[fake_argc++] = strdup("-display"); fake_argv[fake_argc++] = strdup("xemu"); - // Create USB Daughterboard for 1.0 Xbox. This is connected to Port 1 of the Root hub. + // Create USB Daughterboard for 1.0 Xbox. This is connected to Port 1 of the + // Root hub. fake_argv[fake_argc++] = strdup("-device"); fake_argv[fake_argc++] = strdup("usb-hub,port=1,ports=4"); @@ -2905,7 +2918,7 @@ void qemu_init(int argc, char **argv) argc = fake_argc; argv = fake_argv; -/*****************************************************************************/ + /*****************************************************************************/ qemu_add_opts(&qemu_drive_opts); @@ -2973,7 +2986,7 @@ void qemu_init(int argc, char **argv) /* second pass of option parsing */ optind = 1; - for(;;) { + for (;;) { if (optind >= argc) break; if (argv[optind][0] != '-') { @@ -2987,7 +3000,7 @@ void qemu_init(int argc, char **argv) error_report("Option not supported for this target"); exit(1); } - switch(popt->index) { + switch (popt->index) { case QEMU_OPTION_cpu: /* hw initialization will check this */ cpu_option = optarg; @@ -2999,25 +3012,23 @@ void qemu_init(int argc, char **argv) drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg, HD_OPTS); break; - case QEMU_OPTION_blockdev: - { - Visitor *v; - BlockdevOptionsQueueEntry *bdo; - - v = qobject_input_visitor_new_str(optarg, "driver", - &error_fatal); - - bdo = g_new(BlockdevOptionsQueueEntry, 1); - visit_type_BlockdevOptions(v, NULL, &bdo->bdo, - &error_fatal); - visit_free(v); - loc_save(&bdo->loc); - QSIMPLEQ_INSERT_TAIL(&bdo_queue, bdo, entry); - break; - } + case QEMU_OPTION_blockdev: { + Visitor *v; + BlockdevOptionsQueueEntry *bdo; + + v = qobject_input_visitor_new_str(optarg, "driver", + &error_fatal); + + bdo = g_new(BlockdevOptionsQueueEntry, 1); + visit_type_BlockdevOptions(v, NULL, &bdo->bdo, &error_fatal); + visit_free(v); + loc_save(&bdo->loc); + QSIMPLEQ_INSERT_TAIL(&bdo_queue, bdo, entry); + break; + } case QEMU_OPTION_drive: - opts = qemu_opts_parse_noisily(qemu_find_opts("drive"), - optarg, false); + opts = qemu_opts_parse_noisily(qemu_find_opts("drive"), optarg, + false); if (opts == NULL) { exit(1); } @@ -3038,18 +3049,15 @@ void qemu_init(int argc, char **argv) case QEMU_OPTION_pflash: drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS); break; - case QEMU_OPTION_snapshot: - { - Error *blocker = NULL; - snapshot = 1; - error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, - "-snapshot"); - replay_add_blocker(blocker); - } - break; + case QEMU_OPTION_snapshot: { + Error *blocker = NULL; + snapshot = 1; + error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "-snapshot"); + replay_add_blocker(blocker); + } break; case QEMU_OPTION_numa: - opts = qemu_opts_parse_noisily(qemu_find_opts("numa"), - optarg, true); + opts = qemu_opts_parse_noisily(qemu_find_opts("numa"), optarg, + true); if (!opts) { exit(1); } @@ -3066,7 +3074,7 @@ void qemu_init(int argc, char **argv) graphic_rotate = 90; break; case QEMU_OPTION_rotate: - graphic_rotate = strtol(optarg, (char **) &optarg, 10); + graphic_rotate = strtol(optarg, (char **)&optarg, 10); if (graphic_rotate != 0 && graphic_rotate != 90 && graphic_rotate != 180 && graphic_rotate != 270) { error_report("only 90, 180, 270 deg rotation is available"); @@ -3089,12 +3097,13 @@ void qemu_init(int argc, char **argv) drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS); break; case QEMU_OPTION_boot: - machine_parse_property_opt(qemu_find_opts("boot-opts"), "boot", optarg); + machine_parse_property_opt(qemu_find_opts("boot-opts"), "boot", + optarg); break; case QEMU_OPTION_fda: case QEMU_OPTION_fdb: - drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda, - optarg, FD_OPTS); + drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda, optarg, + FD_OPTS); break; case QEMU_OPTION_no_fd_bootchk: fd_bootchk = 0; @@ -3117,8 +3126,8 @@ void qemu_init(int argc, char **argv) break; #ifdef CONFIG_LIBISCSI case QEMU_OPTION_iscsi: - opts = qemu_opts_parse_noisily(qemu_find_opts("iscsi"), - optarg, false); + opts = qemu_opts_parse_noisily(qemu_find_opts("iscsi"), optarg, + false); if (!opts) { exit(1); } @@ -3126,7 +3135,7 @@ void qemu_init(int argc, char **argv) #endif case QEMU_OPTION_audio_help: audio_legacy_help(); - exit (0); + exit(0); break; case QEMU_OPTION_audiodev: audio_parse_option(optarg); @@ -3136,7 +3145,8 @@ void qemu_init(int argc, char **argv) char *model; Audiodev *dev = NULL; Visitor *v; - QDict *dict = keyval_parse(optarg, "driver", &help, &error_fatal); + QDict *dict = + keyval_parse(optarg, "driver", &help, &error_fatal); if (help || (qdict_haskey(dict, "driver") && is_help_option(qdict_get_str(dict, "driver")))) { audio_help(); @@ -3171,7 +3181,8 @@ void qemu_init(int argc, char **argv) exit(0); break; case QEMU_OPTION_m: - opts = qemu_opts_parse_noisily(qemu_find_opts("memory"), optarg, true); + opts = qemu_opts_parse_noisily(qemu_find_opts("memory"), optarg, + true); if (opts == NULL) { exit(1); } @@ -3230,49 +3241,46 @@ void qemu_init(int argc, char **argv) vga_model = optarg; default_vga = 0; break; - case QEMU_OPTION_g: - { - const char *p; - int w, h, depth; - p = optarg; - w = strtol(p, (char **)&p, 10); - if (w <= 0) { - graphic_error: - error_report("invalid resolution or depth"); - exit(1); - } - if (*p != 'x') - goto graphic_error; + case QEMU_OPTION_g: { + const char *p; + int w, h, depth; + p = optarg; + w = strtol(p, (char **)&p, 10); + if (w <= 0) { + graphic_error: + error_report("invalid resolution or depth"); + exit(1); + } + if (*p != 'x') + goto graphic_error; + p++; + h = strtol(p, (char **)&p, 10); + if (h <= 0) + goto graphic_error; + if (*p == 'x') { p++; - h = strtol(p, (char **)&p, 10); - if (h <= 0) - goto graphic_error; - if (*p == 'x') { - p++; - depth = strtol(p, (char **)&p, 10); - if (depth != 1 && depth != 2 && depth != 4 && - depth != 8 && depth != 15 && depth != 16 && - depth != 24 && depth != 32) - goto graphic_error; - } else if (*p == '\0') { - depth = graphic_depth; - } else { + depth = strtol(p, (char **)&p, 10); + if (depth != 1 && depth != 2 && depth != 4 && depth != 8 && + depth != 15 && depth != 16 && depth != 24 && + depth != 32) goto graphic_error; - } - - graphic_width = w; - graphic_height = h; - graphic_depth = depth; + } else if (*p == '\0') { + depth = graphic_depth; + } else { + goto graphic_error; } + + graphic_width = w; + graphic_height = h; + graphic_depth = depth; + } break; + case QEMU_OPTION_echr: { + char *r; + term_escape_char = strtol(optarg, &r, 0); + if (r == optarg) + printf("Bad argument to echr\n"); break; - case QEMU_OPTION_echr: - { - char *r; - term_escape_char = strtol(optarg, &r, 0); - if (r == optarg) - printf("Bad argument to echr\n"); - break; - } + } case QEMU_OPTION_monitor: default_monitor = 0; if (strncmp(optarg, "none", 4)) { @@ -3317,7 +3325,7 @@ void qemu_init(int argc, char **argv) QemuOpts *fsdev; QemuOpts *device; const char *writeout, *sock_fd, *socket, *path, *security_model, - *multidevs; + *multidevs; olist = qemu_find_opts("virtfs"); if (!olist) { @@ -3336,7 +3344,7 @@ void qemu_init(int argc, char **argv) } fsdev = qemu_opts_create(qemu_find_opts("fsdev"), qemu_opts_id(opts) ?: - qemu_opt_get(opts, "mount_tag"), + qemu_opt_get(opts, "mount_tag"), 1, NULL); if (!fsdev) { error_report("duplicate or invalid fsdev id: %s", @@ -3354,8 +3362,8 @@ void qemu_init(int argc, char **argv) exit(1); #endif } - qemu_opt_set(fsdev, "fsdriver", - qemu_opt_get(opts, "fsdriver"), &error_abort); + qemu_opt_set(fsdev, "fsdriver", qemu_opt_get(opts, "fsdriver"), + &error_abort); path = qemu_opt_get(opts, "path"); if (path) { qemu_opt_set(fsdev, "path", path, &error_abort); @@ -3384,8 +3392,8 @@ void qemu_init(int argc, char **argv) device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abort); - qemu_opt_set(device, "fsdev", - qemu_opts_id(fsdev), &error_abort); + qemu_opt_set(device, "fsdev", qemu_opts_id(fsdev), + &error_abort); qemu_opt_set(device, "mount_tag", qemu_opt_get(opts, "mount_tag"), &error_abort); break; @@ -3400,12 +3408,13 @@ void qemu_init(int argc, char **argv) case QEMU_OPTION_action: olist = qemu_find_opts("action"); if (!qemu_opts_parse_noisily(olist, optarg, false)) { - exit(1); + exit(1); } break; case QEMU_OPTION_watchdog_action: { QemuOpts *opts; - opts = qemu_opts_create(qemu_find_opts("action"), NULL, 0, &error_abort); + opts = qemu_opts_create(qemu_find_opts("action"), NULL, 0, + &error_abort); qemu_opt_set(opts, "watchdog", optarg, &error_abort); break; } @@ -3433,24 +3442,24 @@ void qemu_init(int argc, char **argv) win2k_install_hack = 1; break; case QEMU_OPTION_acpitable: - opts = qemu_opts_parse_noisily(qemu_find_opts("acpi"), - optarg, true); + opts = qemu_opts_parse_noisily(qemu_find_opts("acpi"), optarg, + true); if (!opts) { exit(1); } acpi_table_add(opts, &error_fatal); break; case QEMU_OPTION_smbios: - opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"), - optarg, false); + opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"), optarg, + false); if (!opts) { exit(1); } smbios_entry_add(opts, &error_fatal); break; case QEMU_OPTION_fwcfg: - opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"), - optarg, true); + opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"), optarg, + true); if (opts == NULL) { exit(1); } @@ -3462,33 +3471,33 @@ void qemu_init(int argc, char **argv) qdict_put_str(machine_opts_dict, "accel", "kvm"); break; case QEMU_OPTION_M: - case QEMU_OPTION_machine: - { - bool help; - - keyval_parse_into(machine_opts_dict, optarg, "type", &help, &error_fatal); - if (help) { - machine_help_func(machine_opts_dict); - exit(EXIT_SUCCESS); - } - break; + case QEMU_OPTION_machine: { + bool help; + + keyval_parse_into(machine_opts_dict, optarg, "type", &help, + &error_fatal); + if (help) { + machine_help_func(machine_opts_dict); + exit(EXIT_SUCCESS); } + break; + } case QEMU_OPTION_accel: accel_opts = qemu_opts_parse_noisily(qemu_find_opts("accel"), optarg, true); optarg = qemu_opt_get(accel_opts, "accel"); if (!optarg || is_help_option(optarg)) { printf("Accelerators supported in QEMU binary:\n"); - GSList *el, *accel_list = object_class_get_list(TYPE_ACCEL, - false); + GSList *el, + *accel_list = object_class_get_list(TYPE_ACCEL, false); for (el = accel_list; el; el = el->next) { - gchar *typename = g_strdup(object_class_get_name( - OBJECT_CLASS(el->data))); + gchar *typename = g_strdup( + object_class_get_name(OBJECT_CLASS(el->data))); /* omit qtest which is used for tests only */ if (g_strcmp0(typename, ACCEL_CLASS_NAME("qtest")) && g_str_has_suffix(typename, ACCEL_CLASS_SUFFIX)) { - gchar **optname = g_strsplit(typename, - ACCEL_CLASS_SUFFIX, 0); + gchar **optname = + g_strsplit(typename, ACCEL_CLASS_SUFFIX, 0); printf("%s\n", optname[0]); g_strfreev(optname); } @@ -3521,8 +3530,8 @@ void qemu_init(int argc, char **argv) } break; case QEMU_OPTION_smp: - machine_parse_property_opt(qemu_find_opts("smp-opts"), - "smp", optarg); + machine_parse_property_opt(qemu_find_opts("smp-opts"), "smp", + optarg); break; case QEMU_OPTION_vnc: vnc_parse(optarg); @@ -3576,8 +3585,8 @@ void qemu_init(int argc, char **argv) } break; case QEMU_OPTION_name: - opts = qemu_opts_parse_noisily(qemu_find_opts("name"), - optarg, true); + opts = qemu_opts_parse_noisily(qemu_find_opts("name"), optarg, + true); if (!opts) { exit(1); } @@ -3649,7 +3658,8 @@ void qemu_init(int argc, char **argv) qemu_plugin_opt_parse(optarg, &plugin_list); break; case QEMU_OPTION_readconfig: - qemu_read_config_file(optarg, qemu_parse_config_group, &error_fatal); + qemu_read_config_file(optarg, qemu_parse_config_group, + &error_fatal); break; #ifdef CONFIG_SPICE case QEMU_OPTION_spice: @@ -3688,8 +3698,8 @@ void qemu_init(int argc, char **argv) break; case QEMU_OPTION_add_fd: #ifndef _WIN32 - opts = qemu_opts_parse_noisily(qemu_find_opts("add-fd"), - optarg, false); + opts = qemu_opts_parse_noisily(qemu_find_opts("add-fd"), optarg, + false); if (!opts) { exit(1); } @@ -3711,21 +3721,19 @@ void qemu_init(int argc, char **argv) enable_mlock = qemu_opt_get_bool(opts, "mem-lock", false); enable_cpu_pm = qemu_opt_get_bool(opts, "cpu-pm", false); break; - case QEMU_OPTION_compat: - { - CompatPolicy *opts; - Visitor *v; + case QEMU_OPTION_compat: { + CompatPolicy *opts; + Visitor *v; - v = qobject_input_visitor_new_str(optarg, NULL, - &error_fatal); + v = qobject_input_visitor_new_str(optarg, NULL, &error_fatal); - visit_type_CompatPolicy(v, NULL, &opts, &error_fatal); - QAPI_CLONE_MEMBERS(CompatPolicy, &compat_policy, opts); + visit_type_CompatPolicy(v, NULL, &opts, &error_fatal); + QAPI_CLONE_MEMBERS(CompatPolicy, &compat_policy, opts); - qapi_free_CompatPolicy(opts); - visit_free(v); - break; - } + qapi_free_CompatPolicy(opts); + visit_free(v); + break; + } case QEMU_OPTION_msg: opts = qemu_opts_parse_noisily(qemu_find_opts("msg"), optarg, false); @@ -3750,7 +3758,8 @@ void qemu_init(int argc, char **argv) qsp_enable(); break; case QEMU_OPTION_nouserconfig: - /* Nothing to be parsed here. Especially, do not error out below. */ + /* Nothing to be parsed here. Especially, do not error out + * below. */ break; default: if (os_parse_cmd_args(popt->index, optarg)) { @@ -3840,8 +3849,8 @@ void qemu_init(int argc, char **argv) machine_class = MACHINE_GET_CLASS(current_machine); if (!qtest_enabled() && machine_class->deprecation_reason) { - warn_report("Machine type '%s' is deprecated: %s", - machine_class->name, machine_class->deprecation_reason); + warn_report("Machine type '%s' is deprecated: %s", machine_class->name, + machine_class->deprecation_reason); } /* diff --git a/ui/xui/main-menu.cc b/ui/xui/main-menu.cc index d57770b027c..d0c6c907d82 100644 --- a/ui/xui/main-menu.cc +++ b/ui/xui/main-menu.cc @@ -16,34 +16,38 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . // -#include "common.hh" -#include "scene-manager.hh" -#include "widgets.hh" +#include "qapi/error.h" #include "main-menu.hh" +#include "actions.hh" +#include "common.hh" #include "font-manager.hh" +#include "gl-helpers.hh" #include "input-manager.hh" +#include "misc.hh" +#include "reporting.hh" +#include "scene-manager.hh" #include "snapshot-manager.hh" #include "viewport-manager.hh" +#include "widgets.hh" #include "xemu-hud.h" -#include "misc.hh" -#include "gl-helpers.hh" -#include "reporting.hh" -#include "qapi/error.h" -#include "actions.hh" #include "../xemu-input.h" -#include "../xemu-notifications.h" -#include "../xemu-settings.h" #include "../xemu-monitor.h" -#include "../xemu-version.h" #include "../xemu-net.h" +#include "../xemu-notifications.h" #include "../xemu-os-utils.h" +#include "../xemu-settings.h" +#include "../xemu-version.h" #include "../xemu-xbe.h" MainMenuScene g_main_menu; -MainMenuTabView::~MainMenuTabView() {} -void MainMenuTabView::Draw() {} +MainMenuTabView::~MainMenuTabView() +{ +} +void MainMenuTabView::Draw() +{ +} void MainMenuGeneralView::Draw() { @@ -55,8 +59,9 @@ void MainMenuGeneralView::Draw() #if defined(__x86_64__) SectionTitle("Performance"); - Toggle("Hard FPU emulation", &g_config.perf.hard_fpu, - "Use hardware-accelerated floating point emulation (requires restart)"); + Toggle( + "Hard FPU emulation", &g_config.perf.hard_fpu, + "Use hardware-accelerated floating point emulation (requires restart)"); #endif Toggle("Cache shaders to disk", &g_config.perf.cache_shaders, @@ -84,7 +89,7 @@ void MainMenuInputView::Draw() float b_x = 0, b_x_stride = 100, b_y = 400; float b_w = 68, b_h = 81; // Dimensions of controller (rendered at origin) - float controller_width = 477.0f; + float controller_width = 477.0f; float controller_height = 395.0f; // Setup rendering to fbo for controller and port images @@ -120,14 +125,14 @@ void MainMenuInputView::Draw() // uses the texture as a unique ID. Push a new ID now to resolve // the conflict. ImGui::PushID(i); - float x = b_x+i*b_x_stride; - ImGui::PushStyleColor(ImGuiCol_Button, is_selected ? - color_active : - color_inactive); - bool activated = ImGui::ImageButton(id, - ImVec2(b_w*g_viewport_mgr.m_scale,b_h*g_viewport_mgr.m_scale), - ImVec2(x/t_w, (b_y+b_h)/t_h), - ImVec2((x+b_w)/t_w, b_y/t_h), + float x = b_x + i * b_x_stride; + ImGui::PushStyleColor(ImGuiCol_Button, + is_selected ? color_active : color_inactive); + bool activated = ImGui::ImageButton( + id, + ImVec2(b_w * g_viewport_mgr.m_scale, b_h * g_viewport_mgr.m_scale), + ImVec2(x / t_w, (b_y + b_h) / t_h), + ImVec2((x + b_w) / t_w, b_y / t_h), port_padding * g_viewport_mgr.m_scale); ImGui::PopStyleColor(); @@ -168,8 +173,8 @@ void MainMenuInputView::Draw() } ImGui::SetNextItemWidth(-FLT_MIN); - if (ImGui::BeginCombo("###InputDevices", name, ImGuiComboFlags_NoArrowButton)) - { + if (ImGui::BeginCombo("###InputDevices", name, + ImGuiComboFlags_NoArrowButton)) { // Handle "Not connected" bool is_selected = bound_state == NULL; if (ImGui::Selectable(not_connected, is_selected)) { @@ -182,13 +187,14 @@ void MainMenuInputView::Draw() // Handle all available input devices ControllerState *iter; - QTAILQ_FOREACH(iter, &available_controllers, entry) { + QTAILQ_FOREACH (iter, &available_controllers, entry) { is_selected = bound_state == iter; ImGui::PushID(iter); const char *selectable_label = iter->name; char buf[128]; if (iter->bound >= 0) { - snprintf(buf, sizeof(buf), "%s (Port %d)", iter->name, iter->bound+1); + snprintf(buf, sizeof(buf), "%s (Port %d)", iter->name, + iter->bound + 1); selectable_label = buf; } if (ImGui::Selectable(selectable_label, is_selected)) { @@ -228,7 +234,8 @@ void MainMenuInputView::Draw() ImVec2 cur = ImGui::GetCursorPos(); ImVec2 controller_display_size; - if (ImGui::GetContentRegionMax().x < controller_width*g_viewport_mgr.m_scale) { + if (ImGui::GetContentRegionMax().x < + controller_width * g_viewport_mgr.m_scale) { controller_display_size.x = ImGui::GetContentRegionMax().x; controller_display_size.y = controller_display_size.x * controller_height / controller_width; @@ -242,16 +249,15 @@ void MainMenuInputView::Draw() ImGui::GetCursorPosX() + (int)((ImGui::GetColumnWidth() - controller_display_size.x) / 2.0)); - ImGui::Image(id, - controller_display_size, - ImVec2(0, controller_height/t_h), - ImVec2(controller_width/t_w, 0)); + ImGui::Image(id, controller_display_size, + ImVec2(0, controller_height / t_h), + ImVec2(controller_width / t_w, 0)); ImVec2 pos = ImGui::GetCursorPos(); if (!device_selected) { const char *msg = "Please select an available input device"; ImVec2 dim = ImGui::CalcTextSize(msg); - ImGui::SetCursorPosX(cur.x + (controller_display_size.x-dim.x)/2); - ImGui::SetCursorPosY(cur.y + (controller_display_size.y-dim.y)/2); + ImGui::SetCursorPosX(cur.x + (controller_display_size.x - dim.x) / 2); + ImGui::SetCursorPosY(cur.y + (controller_display_size.y - dim.y) / 2); ImGui::Text("%s", msg); } @@ -284,7 +290,7 @@ void MainMenuDisplayView::Draw() "9x\0" "10x\0", "Increase surface scaling factor for higher quality")) { - nv2a_set_surface_scale_factor(rendering_scale+1); + nv2a_set_surface_scale_factor(rendering_scale + 1); } SectionTitle("Window"); @@ -324,8 +330,10 @@ void MainMenuDisplayView::Draw() ui_scale_idx = 0; } else { ui_scale_idx = g_config.display.ui.scale; - if (ui_scale_idx < 0) ui_scale_idx = 0; - else if (ui_scale_idx > 2) ui_scale_idx = 2; + if (ui_scale_idx < 0) + ui_scale_idx = 0; + else if (ui_scale_idx > 2) + ui_scale_idx = 2; } if (ChevronCombo("UI scale", &ui_scale_idx, "Auto\0" @@ -341,11 +349,12 @@ void MainMenuDisplayView::Draw() } Toggle("Animations", &g_config.display.ui.use_animations, "Enable xemu user interface animations"); - ChevronCombo("Display mode", &g_config.display.ui.fit, - "Center\0" - "Scale\0" - "Stretch\0", - "Select how the framebuffer should fit or scale into the window"); + ChevronCombo( + "Display mode", &g_config.display.ui.fit, + "Center\0" + "Scale\0" + "Stretch\0", + "Select how the framebuffer should fit or scale into the window"); ChevronCombo("Aspect ratio", &g_config.display.ui.aspect_ratio, "Native\0" "Auto (Default)\0" @@ -365,7 +374,6 @@ void MainMenuAudioView::Draw() SectionTitle("Quality"); Toggle("Real-time DSP processing", &g_config.audio.use_dsp, "Enable improved audio accuracy (experimental)"); - } NetworkInterface::NetworkInterface(pcap_if_t *pcap_desc, char *_friendlyname) @@ -411,7 +419,7 @@ void NetworkInterfaceManager::Refresh(void) return; } - for (iter=alldevs; iter != NULL; iter=iter->next) { + for (iter = alldevs; iter != NULL; iter = iter->next) { #if defined(_WIN32) char *friendly_name = get_windows_interface_friendly_name(iter->name); m_ifaces.emplace_back(new NetworkInterface(iter, friendly_name)); @@ -463,7 +471,8 @@ void MainMenuNetworkView::Draw() } bool appearing = ImGui::IsWindowAppearing(); - if (enabled) ImGui::BeginDisabled(); + if (enabled) + ImGui::BeginDisabled(); if (ChevronCombo( "Attached to", &g_config.net.backend, "NAT\0" @@ -483,9 +492,11 @@ void MainMenuNetworkView::Draw() case CONFIG_NET_BACKEND_UDP: DrawUdpOptions(appearing); break; - default: break; + default: + break; } - if (enabled) ImGui::EndDisabled(); + if (enabled) + ImGui::EndDisabled(); } void MainMenuNetworkView::DrawPcapOptions(bool appearing) @@ -500,9 +511,11 @@ void MainMenuNetworkView::DrawPcapOptions(bool appearing) const char *msg = "npcap library could not be loaded.\n" "To use this backend, please install npcap."; ImGui::Text("%s", msg); - ImGui::Dummy(ImVec2(0,10*g_viewport_mgr.m_scale)); - ImGui::SetCursorPosX((ImGui::GetWindowWidth()-120*g_viewport_mgr.m_scale)/2); - if (ImGui::Button("Install npcap", ImVec2(120*g_viewport_mgr.m_scale, 0))) { + ImGui::Dummy(ImVec2(0, 10 * g_viewport_mgr.m_scale)); + ImGui::SetCursorPosX( + (ImGui::GetWindowWidth() - 120 * g_viewport_mgr.m_scale) / 2); + if (ImGui::Button("Install npcap", + ImVec2(120 * g_viewport_mgr.m_scale, 0))) { xemu_open_web_browser("https://nmap.org/npcap/"); } #endif @@ -534,7 +547,8 @@ void MainMenuNetworkView::DrawPcapOptions(bool appearing) is_selected)) { iface_mgr->Select((*iface)); } - if (is_selected) ImGui::SetItemDefaultFocus(); + if (is_selected) + ImGui::SetItemDefaultFocus(); ImGui::PopID(); } ImGui::EndCombo(); @@ -548,22 +562,22 @@ void MainMenuNetworkView::DrawPcapOptions(bool appearing) void MainMenuNetworkView::DrawNatOptions(bool appearing) { - static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg; + static ImGuiTableFlags flags = + ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg; WidgetTitleDescriptionItem( "Port Forwarding", "Configure xemu to forward connections to guest on these ports"); float p = ImGui::GetFrameHeight() * 0.3; ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(p, p)); - if (ImGui::BeginTable("port_forward_tbl", 4, flags)) - { + if (ImGui::BeginTable("port_forward_tbl", 4, flags)) { ImGui::TableSetupColumn("Host Port"); ImGui::TableSetupColumn("Guest Port"); ImGui::TableSetupColumn("Protocol"); ImGui::TableSetupColumn("Action"); ImGui::TableHeadersRow(); - for (unsigned int row = 0; row < g_config.net.nat.forward_ports_count; row++) - { + for (unsigned int row = 0; row < g_config.net.nat.forward_ports_count; + row++) { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); @@ -575,10 +589,13 @@ void MainMenuNetworkView::DrawNatOptions(bool appearing) ImGui::TableSetColumnIndex(2); switch (g_config.net.nat.forward_ports[row].protocol) { case CONFIG_NET_NAT_FORWARD_PORTS_PROTOCOL_TCP: - ImGui::TextUnformatted("TCP"); break; + ImGui::TextUnformatted("TCP"); + break; case CONFIG_NET_NAT_FORWARD_PORTS_PROTOCOL_UDP: - ImGui::TextUnformatted("UDP"); break; - default: assert(0); + ImGui::TextUnformatted("UDP"); + break; + default: + assert(0); } ImGui::TableSetColumnIndex(3); @@ -592,12 +609,12 @@ void MainMenuNetworkView::DrawNatOptions(bool appearing) ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); - static char buf[8] = {"1234"}; + static char buf[8] = { "1234" }; ImGui::SetNextItemWidth(ImGui::GetColumnWidth()); ImGui::InputText("###hostport", buf, sizeof(buf)); ImGui::TableSetColumnIndex(1); - static char buf2[8] = {"1234"}; + static char buf2[8] = { "1234" }; ImGui::SetNextItemWidth(ImGui::GetColumnWidth()); ImGui::InputText("###guestport", buf2, sizeof(buf2)); @@ -625,8 +642,9 @@ void MainMenuNetworkView::DrawNatOptions(bool appearing) void MainMenuNetworkView::DrawUdpOptions(bool appearing) { if (appearing) { - strncpy(remote_addr, g_config.net.udp.remote_addr, sizeof(remote_addr)-1); - strncpy(local_addr, g_config.net.udp.bind_addr, sizeof(local_addr)-1); + strncpy(remote_addr, g_config.net.udp.remote_addr, + sizeof(remote_addr) - 1); + strncpy(local_addr, g_config.net.udp.bind_addr, sizeof(local_addr) - 1); } float size_ratio = 0.5; @@ -663,7 +681,9 @@ MainMenuSnapshotsView::~MainMenuSnapshotsView() g_free(m_search_regex); } -bool MainMenuSnapshotsView::BigSnapshotButton(QEMUSnapshotInfo *snapshot, XemuSnapshotData *data, int current_snapshot_binding) +bool MainMenuSnapshotsView::BigSnapshotButton(QEMUSnapshotInfo *snapshot, + XemuSnapshotData *data, + int current_snapshot_binding) { ImGuiStyle &style = ImGui::GetStyle(); ImDrawList *draw_list = ImGui::GetWindowDrawList(); @@ -673,18 +693,27 @@ bool MainMenuSnapshotsView::BigSnapshotButton(QEMUSnapshotInfo *snapshot, XemuSn ImGui::PopFont(); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, g_viewport_mgr.Scale(ImVec2(5, 5))); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, + g_viewport_mgr.Scale(ImVec2(5, 5))); ImGui::PushFont(g_font_mgr.m_menu_font_medium); ImVec2 ts_title = ImGui::CalcTextSize(snapshot->name); - ImVec2 thumbnail_size = g_viewport_mgr.Scale(ImVec2(XEMU_SNAPSHOT_THUMBNAIL_WIDTH, XEMU_SNAPSHOT_THUMBNAIL_HEIGHT)); + ImVec2 thumbnail_size = g_viewport_mgr.Scale( + ImVec2(XEMU_SNAPSHOT_THUMBNAIL_WIDTH, XEMU_SNAPSHOT_THUMBNAIL_HEIGHT)); ImVec2 thumbnail_pos(style.FramePadding.x, style.FramePadding.y); - ImVec2 name_pos(thumbnail_pos.x + thumbnail_size.x + style.FramePadding.x * 2, thumbnail_pos.y); - ImVec2 title_pos(name_pos.x, name_pos.y + ts_title.y + style.FramePadding.x); - ImVec2 date_pos(name_pos.x, title_pos.y + ts_title.y + style.FramePadding.x); - ImVec2 binding_pos(name_pos.x, date_pos.y + ts_title.y + style.FramePadding.x); - ImVec2 button_size(-FLT_MIN, fmax(thumbnail_size.y + style.FramePadding.y * 2, ts_title.y + ts_sub.y + style.FramePadding.y * 3)); + ImVec2 name_pos(thumbnail_pos.x + thumbnail_size.x + + style.FramePadding.x * 2, + thumbnail_pos.y); + ImVec2 title_pos(name_pos.x, + name_pos.y + ts_title.y + style.FramePadding.x); + ImVec2 date_pos(name_pos.x, + title_pos.y + ts_title.y + style.FramePadding.x); + ImVec2 binding_pos(name_pos.x, + date_pos.y + ts_title.y + style.FramePadding.x); + ImVec2 button_size(-FLT_MIN, + fmax(thumbnail_size.y + style.FramePadding.y * 2, + ts_title.y + ts_sub.y + style.FramePadding.y * 3)); bool load = ImGui::Button("###button", button_size); @@ -699,42 +728,55 @@ bool MainMenuSnapshotsView::BigSnapshotButton(QEMUSnapshotInfo *snapshot, XemuSn int thumbnail_width, thumbnail_height; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, thumbnail); - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &thumbnail_width); - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &thumbnail_height); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, + &thumbnail_width); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, + &thumbnail_height); // Draw black background behind thumbnail ImVec2 thumbnail_min(p0.x + thumbnail_pos.x, p0.y + thumbnail_pos.y); - ImVec2 thumbnail_max(thumbnail_min.x + thumbnail_size.x, thumbnail_min.y + thumbnail_size.y); + ImVec2 thumbnail_max(thumbnail_min.x + thumbnail_size.x, + thumbnail_min.y + thumbnail_size.y); draw_list->AddRectFilled(thumbnail_min, thumbnail_max, IM_COL32_BLACK); // Draw centered thumbnail image int scaled_width, scaled_height; - ScaleDimensions(thumbnail_width, thumbnail_height, thumbnail_size.x, thumbnail_size.y, &scaled_width, &scaled_height); - ImVec2 img_min = ImVec2(thumbnail_min.x + (thumbnail_size.x - scaled_width) / 2, - thumbnail_min.y + (thumbnail_size.y - scaled_height) / 2); - ImVec2 img_max = ImVec2(img_min.x + scaled_width, img_min.y + scaled_height); + ScaleDimensions(thumbnail_width, thumbnail_height, thumbnail_size.x, + thumbnail_size.y, &scaled_width, &scaled_height); + ImVec2 img_min = + ImVec2(thumbnail_min.x + (thumbnail_size.x - scaled_width) / 2, + thumbnail_min.y + (thumbnail_size.y - scaled_height) / 2); + ImVec2 img_max = + ImVec2(img_min.x + scaled_width, img_min.y + scaled_height); draw_list->AddImage((ImTextureID)(uint64_t)thumbnail, img_min, img_max); // Snapshot title ImGui::PushFont(g_font_mgr.m_menu_font_medium); - draw_list->AddText(ImVec2(p0.x + name_pos.x, p0.y + name_pos.y), IM_COL32(255, 255, 255, 255), snapshot->name); + draw_list->AddText(ImVec2(p0.x + name_pos.x, p0.y + name_pos.y), + IM_COL32(255, 255, 255, 255), snapshot->name); ImGui::PopFont(); // Snapshot XBE title name ImGui::PushFont(g_font_mgr.m_menu_font_small); - const char *title_name = data->xbe_title_name ? data->xbe_title_name : "(Unknown XBE Title Name)"; - draw_list->AddText(ImVec2(p0.x + title_pos.x, p0.y + title_pos.y), IM_COL32(255, 255, 255, 200), title_name); + const char *title_name = data->xbe_title_name ? data->xbe_title_name : + "(Unknown XBE Title Name)"; + draw_list->AddText(ImVec2(p0.x + title_pos.x, p0.y + title_pos.y), + IM_COL32(255, 255, 255, 200), title_name); // Snapshot date - g_autoptr(GDateTime) date = g_date_time_new_from_unix_local(snapshot->date_sec); + g_autoptr(GDateTime) date = + g_date_time_new_from_unix_local(snapshot->date_sec); char *date_buf = g_date_time_format(date, "%Y-%m-%d %H:%M:%S"); - draw_list->AddText(ImVec2(p0.x + date_pos.x, p0.y + date_pos.y), IM_COL32(255, 255, 255, 200), date_buf); + draw_list->AddText(ImVec2(p0.x + date_pos.x, p0.y + date_pos.y), + IM_COL32(255, 255, 255, 200), date_buf); g_free(date_buf); // Snapshot keyboard binding if (current_snapshot_binding != -1) { - char *binding_text = g_strdup_printf("Bound to F%d", current_snapshot_binding + 5); - draw_list->AddText(ImVec2(p0.x + binding_pos.x, p0.y + binding_pos.y), IM_COL32(255, 255, 255, 200), binding_text); + char *binding_text = + g_strdup_printf("Bound to F%d", current_snapshot_binding + 5); + draw_list->AddText(ImVec2(p0.x + binding_pos.x, p0.y + binding_pos.y), + IM_COL32(255, 255, 255, 200), binding_text); g_free(binding_text); } @@ -758,7 +800,7 @@ void MainMenuSnapshotsView::ClearSearch() int MainMenuSnapshotsView::OnSearchTextUpdate(ImGuiInputTextCallbackData *data) { GError *gerr = NULL; - MainMenuSnapshotsView *win = (MainMenuSnapshotsView*)data->UserData; + MainMenuSnapshotsView *win = (MainMenuSnapshotsView *)data->UserData; if (win->m_search_regex) { g_free(win->m_search_regex); @@ -770,7 +812,8 @@ int MainMenuSnapshotsView::OnSearchTextUpdate(ImGuiInputTextCallbackData *data) } char *buf = g_strdup_printf("(.*)%s(.*)", data->Buf); - win->m_search_regex = g_regex_new(buf, (GRegexCompileFlags)0, (GRegexMatchFlags)0, &gerr); + win->m_search_regex = + g_regex_new(buf, (GRegexCompileFlags)0, (GRegexMatchFlags)0, &gerr); g_free(buf); if (gerr) { win->m_search_regex = NULL; @@ -785,14 +828,17 @@ void MainMenuSnapshotsView::Draw() g_snapshot_mgr.Refresh(); SectionTitle("Snapshots"); - Toggle("Filter by current title", &g_config.general.snapshots.filter_current_game, - "Only display snapshots created while running the currently running XBE"); + Toggle("Filter by current title", + &g_config.general.snapshots.filter_current_game, + "Only display snapshots created while running the currently running " + "XBE"); if (g_config.general.snapshots.filter_current_game) { struct xbe *xbe = xemu_get_xbe_info(); if (xbe && xbe->cert) { if (xbe->cert->m_titleid != m_current_title_id) { - char *title_name = g_utf16_to_utf8(xbe->cert->m_title_name, 40, NULL, NULL, NULL); + char *title_name = g_utf16_to_utf8(xbe->cert->m_title_name, 40, + NULL, NULL, NULL); if (title_name) { m_current_title_name = title_name; g_free(title_name); @@ -816,7 +862,8 @@ void MainMenuSnapshotsView::Draw() bool snapshot_with_create_name_exists = false; for (int i = 0; i < g_snapshot_mgr.m_snapshots_len; ++i) { - if (g_strcmp0(m_search_buf.c_str(), g_snapshot_mgr.m_snapshots[i].name) == 0) { + if (g_strcmp0(m_search_buf.c_str(), + g_snapshot_mgr.m_snapshots[i].name) == 0) { snapshot_with_create_name_exists = true; break; } @@ -828,8 +875,10 @@ void MainMenuSnapshotsView::Draw() ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1, 0, 0, 1)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(1, 0, 0, 1)); } - if (ImGui::Button(snapshot_with_create_name_exists ? "Replace" : "Create", ImVec2(-FLT_MIN, 0))) { - xemu_snapshots_save(m_search_buf.empty() ? NULL : m_search_buf.c_str(), NULL); + if (ImGui::Button(snapshot_with_create_name_exists ? "Replace" : "Create", + ImVec2(-FLT_MIN, 0))) { + xemu_snapshots_save(m_search_buf.empty() ? NULL : m_search_buf.c_str(), + NULL); ClearSearch(); } if (snapshot_with_create_name_exists) { @@ -837,28 +886,36 @@ void MainMenuSnapshotsView::Draw() } if (snapshot_with_create_name_exists && ImGui::IsItemHovered()) { - ImGui::SetTooltip("A snapshot with the name \"%s\" already exists. This button will overwrite the existing snapshot.", m_search_buf.c_str()); + ImGui::SetTooltip("A snapshot with the name \"%s\" already exists. " + "This button will overwrite the existing snapshot.", + m_search_buf.c_str()); } ImGui::PopFont(); bool at_least_one_snapshot_displayed = false; for (int i = g_snapshot_mgr.m_snapshots_len - 1; i >= 0; i--) { - if (g_config.general.snapshots.filter_current_game && g_snapshot_mgr.m_extra_data[i].xbe_title_name && - m_current_title_name.size() && strcmp(m_current_title_name.c_str(), g_snapshot_mgr.m_extra_data[i].xbe_title_name)) { + if (g_config.general.snapshots.filter_current_game && + g_snapshot_mgr.m_extra_data[i].xbe_title_name && + m_current_title_name.size() && + strcmp(m_current_title_name.c_str(), + g_snapshot_mgr.m_extra_data[i].xbe_title_name)) { continue; } if (m_search_regex) { GMatchInfo *match; bool keep_entry = false; - - g_regex_match(m_search_regex, g_snapshot_mgr.m_snapshots[i].name, (GRegexMatchFlags)0, &match); + + g_regex_match(m_search_regex, g_snapshot_mgr.m_snapshots[i].name, + (GRegexMatchFlags)0, &match); keep_entry |= g_match_info_matches(match); g_match_info_free(match); if (g_snapshot_mgr.m_extra_data[i].xbe_title_name) { - g_regex_match(m_search_regex, g_snapshot_mgr.m_extra_data[i].xbe_title_name, (GRegexMatchFlags)0, &match); + g_regex_match(m_search_regex, + g_snapshot_mgr.m_extra_data[i].xbe_title_name, + (GRegexMatchFlags)0, &match); keep_entry |= g_match_info_matches(match); g_free(match); } @@ -873,7 +930,8 @@ void MainMenuSnapshotsView::Draw() int current_snapshot_binding = -1; for (int i = 0; i < 4; ++i) { - if (g_strcmp0(*(g_snapshot_shortcut_index_key_map[i]), snapshot->name) == 0) { + if (g_strcmp0(*(g_snapshot_shortcut_index_key_map[i]), + snapshot->name) == 0) { assert(current_snapshot_binding == -1); current_snapshot_binding = i; } @@ -885,13 +943,14 @@ void MainMenuSnapshotsView::Draw() bool load = BigSnapshotButton(snapshot, data, current_snapshot_binding); // FIXME: Provide context menu control annotation - if (ImGui::IsItemHovered() && ImGui::IsKeyPressed(ImGuiKey_GamepadFaceLeft)) { + if (ImGui::IsItemHovered() && + ImGui::IsKeyPressed(ImGuiKey_GamepadFaceLeft)) { ImGui::SetNextWindowPos(pos); ImGui::OpenPopup("Snapshot Options"); } - + DrawSnapshotContextMenu(snapshot, data, current_snapshot_binding); - + ImGui::PopID(); if (load) { @@ -915,12 +974,14 @@ void MainMenuSnapshotsView::Draw() } ImVec2 dim = ImGui::CalcTextSize(msg); ImVec2 cur = ImGui::GetCursorPos(); - ImGui::SetCursorPosX(cur.x + (ImGui::GetColumnWidth()-dim.x)/2); + ImGui::SetCursorPosX(cur.x + (ImGui::GetColumnWidth() - dim.x) / 2); ImGui::TextColored(ImVec4(0.94f, 0.94f, 0.94f, 0.70f), "%s", msg); } } -void MainMenuSnapshotsView::DrawSnapshotContextMenu(QEMUSnapshotInfo *snapshot, XemuSnapshotData *data, int current_snapshot_binding) +void MainMenuSnapshotsView::DrawSnapshotContextMenu( + QEMUSnapshotInfo *snapshot, XemuSnapshotData *data, + int current_snapshot_binding) { if (!ImGui::BeginPopupContextItem("Snapshot Options")) { return; @@ -936,9 +997,12 @@ void MainMenuSnapshotsView::DrawSnapshotContextMenu(QEMUSnapshotInfo *snapshot, if (ImGui::MenuItem(item_name)) { if (current_snapshot_binding >= 0) { - xemu_settings_set_string(g_snapshot_shortcut_index_key_map[current_snapshot_binding], ""); + xemu_settings_set_string(g_snapshot_shortcut_index_key_map + [current_snapshot_binding], + ""); } - xemu_settings_set_string(g_snapshot_shortcut_index_key_map[i], snapshot->name); + xemu_settings_set_string(g_snapshot_shortcut_index_key_map[i], + snapshot->name); current_snapshot_binding = i; ImGui::CloseCurrentPopup(); @@ -949,13 +1013,15 @@ void MainMenuSnapshotsView::DrawSnapshotContextMenu(QEMUSnapshotInfo *snapshot, if (current_snapshot_binding >= 0) { if (ImGui::MenuItem("Unbind")) { - xemu_settings_set_string(g_snapshot_shortcut_index_key_map[current_snapshot_binding], ""); + xemu_settings_set_string( + g_snapshot_shortcut_index_key_map[current_snapshot_binding], + ""); current_snapshot_binding = -1; } } ImGui::EndMenu(); } - + ImGui::Separator(); Error *err = NULL; @@ -982,11 +1048,13 @@ MainMenuSystemView::MainMenuSystemView() : m_dirty(false) void MainMenuSystemView::Draw() { - const char *rom_file_filters = ".bin Files\0*.bin\0.rom Files\0*.rom\0All Files\0*.*\0"; + const char *rom_file_filters = + ".bin Files\0*.bin\0.rom Files\0*.rom\0All Files\0*.*\0"; const char *qcow_file_filters = ".qcow2 Files\0*.qcow2\0All Files\0*.*\0"; if (m_dirty) { - ImGui::TextColored(ImVec4(1,0,0,1), "Application restart required to apply settings"); + ImGui::TextColored(ImVec4(1, 0, 0, 1), + "Application restart required to apply settings"); } if ((int)g_config.sys.avpack == CONFIG_SYS_AVPACK_NONE) { @@ -998,7 +1066,8 @@ void MainMenuSystemView::Draw() if (ChevronCombo( "System Memory", &g_config.sys.mem_limit, - "64 MiB (Default)\0""128 MiB\0", + "64 MiB (Default)\0" + "128 MiB\0", "Increase to 128 MiB for debug or homebrew applications")) { m_dirty = true; } @@ -1031,8 +1100,9 @@ void MainMenuSystemView::Draw() } } -MainMenuAboutView::MainMenuAboutView(): m_config_info_text{NULL} -{} +MainMenuAboutView::MainMenuAboutView() : m_config_info_text{ NULL } +{ +} void MainMenuAboutView::UpdateConfigInfoText() { @@ -1040,20 +1110,21 @@ void MainMenuAboutView::UpdateConfigInfoText() g_free(m_config_info_text); } - gchar *bootrom_checksum = GetFileMD5Checksum(g_config.sys.files.bootrom_path); + gchar *bootrom_checksum = + GetFileMD5Checksum(g_config.sys.files.bootrom_path); if (!bootrom_checksum) { bootrom_checksum = g_strdup("None"); } - gchar *flash_rom_checksum = GetFileMD5Checksum(g_config.sys.files.flashrom_path); + gchar *flash_rom_checksum = + GetFileMD5Checksum(g_config.sys.files.flashrom_path); if (!flash_rom_checksum) { flash_rom_checksum = g_strdup("None"); } - m_config_info_text = g_strdup_printf( - "MCPX Boot ROM MD5 Hash: %s\n" - "Flash ROM (BIOS) MD5 Hash: %s", - bootrom_checksum, flash_rom_checksum); + m_config_info_text = g_strdup_printf("MCPX Boot ROM MD5 Hash: %s\n" + "Flash ROM (BIOS) MD5 Hash: %s", + bootrom_checksum, flash_rom_checksum); g_free(bootrom_checksum); g_free(flash_rom_checksum); } @@ -1062,22 +1133,25 @@ void MainMenuAboutView::Draw() { static const char *build_info_text = NULL; if (build_info_text == NULL) { - build_info_text = g_strdup_printf( - "Version: %s\nBranch: %s\nCommit: %s\nDate: %s", - xemu_version, xemu_branch, xemu_commit, xemu_date); + build_info_text = + g_strdup_printf("Version: %s\nBranch: %s\nCommit: " + "%s\nDate: %s", + xemu_version, xemu_branch, xemu_commit, xemu_date); } static const char *sys_info_text = NULL; if (sys_info_text == NULL) { - const char *gl_shader_version = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); - const char *gl_version = (const char*)glGetString(GL_VERSION); - const char *gl_renderer = (const char*)glGetString(GL_RENDERER); - const char *gl_vendor = (const char*)glGetString(GL_VENDOR); + const char *gl_shader_version = + (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION); + const char *gl_version = (const char *)glGetString(GL_VERSION); + const char *gl_renderer = (const char *)glGetString(GL_RENDERER); + const char *gl_vendor = (const char *)glGetString(GL_VENDOR); sys_info_text = g_strdup_printf( - "CPU: %s\nOS Platform: %s\nOS Version: %s\nManufacturer: %s\n" + "CPU: %s\nOS Platform: %s\nOS Version: " + "%s\nManufacturer: %s\n" "GPU Model: %s\nDriver: %s\nShader: %s", - xemu_get_cpu_info(), xemu_get_os_platform(), xemu_get_os_info(), gl_vendor, - gl_renderer, gl_version, gl_shader_version); + xemu_get_cpu_info(), xemu_get_os_platform(), xemu_get_os_info(), + gl_vendor, gl_renderer, gl_version, gl_shader_version); } if (m_config_info_text == NULL) { @@ -1122,7 +1196,7 @@ void MainMenuAboutView::Draw() } MainMenuTabButton::MainMenuTabButton(std::string text, std::string icon) -: m_icon(icon), m_text(text) + : m_icon(icon), m_text(text) { } @@ -1135,8 +1209,10 @@ bool MainMenuTabButton::Draw(bool selected) IM_COL32(0, 0, 0, 0); ImGui::PushStyleColor(ImGuiCol_Button, col); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, selected ? col : IM_COL32(32, 32, 32, 255)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, selected ? col : IM_COL32(32, 32, 32, 255)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, + selected ? col : IM_COL32(32, 32, 32, 255)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, + selected ? col : IM_COL32(32, 32, 32, 255)); int p = ImGui::GetTextLineHeight() * 0.5; ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(p, p)); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0); @@ -1155,15 +1231,14 @@ bool MainMenuTabButton::Draw(bool selected) } MainMenuScene::MainMenuScene() -: m_animation(0.12, 0.12), - m_general_button("General", ICON_FA_GEARS), - m_input_button("Input", ICON_FA_GAMEPAD), - m_display_button("Display", ICON_FA_TV), - m_audio_button("Audio", ICON_FA_VOLUME_HIGH), - m_network_button("Network", ICON_FA_NETWORK_WIRED), - m_snapshots_button("Snapshots", ICON_FA_CLOCK_ROTATE_LEFT), - m_system_button("System", ICON_FA_MICROCHIP), - m_about_button("About", ICON_FA_CIRCLE_INFO) + : m_animation(0.12, 0.12), m_general_button("General", ICON_FA_GEARS), + m_input_button("Input", ICON_FA_GAMEPAD), + m_display_button("Display", ICON_FA_TV), + m_audio_button("Audio", ICON_FA_VOLUME_HIGH), + m_network_button("Network", ICON_FA_NETWORK_WIRED), + m_snapshots_button("Snapshots", ICON_FA_CLOCK_ROTATE_LEFT), + m_system_button("System", ICON_FA_MICROCHIP), + m_about_button("About", ICON_FA_CIRCLE_INFO) { m_had_focus_last_frame = false; m_focus_view = false; @@ -1250,11 +1325,12 @@ void MainMenuScene::HandleInput() bool focus = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows | ImGuiFocusedFlags_NoPopupHierarchy); - // XXX: Ensure we have focus for two frames. If a user cancels a popup window, we do not want to cancel main + // XXX: Ensure we have focus for two frames. If a user cancels a popup + // window, we do not want to cancel main // window as well. if (nofocus || (focus && m_had_focus_last_frame && - (ImGui::IsKeyDown(ImGuiKey_GamepadFaceRight) - || ImGui::IsKeyDown(ImGuiKey_Escape)))) { + (ImGui::IsKeyDown(ImGuiKey_GamepadFaceRight) || + ImGui::IsKeyDown(ImGuiKey_Escape)))) { Hide(); return; } @@ -1314,9 +1390,10 @@ bool MainMenuScene::Draw() float nav_width = width * 0.3; float content_width = width - nav_width; - ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(26,26,26,255)); + ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(26, 26, 26, 255)); - ImGui::BeginChild("###MainWindowNav", ImVec2(nav_width, -1), true, ImGuiWindowFlags_NavFlattened); + ImGui::BeginChild("###MainWindowNav", ImVec2(nav_width, -1), true, + ImGuiWindowFlags_NavFlattened); bool move_focus_to_tab = false; if (m_current_view_index != m_next_view_index) { @@ -1350,7 +1427,8 @@ bool MainMenuScene::Draw() int s = ImGui::GetTextLineHeight() * 0.75; ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(s, s)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(s, s)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 6*g_viewport_mgr.m_scale); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, + 6 * g_viewport_mgr.m_scale); ImGui::PushID(m_current_view_index); ImGui::BeginChild("###MainWindowContent", ImVec2(content_width, -1), @@ -1365,7 +1443,9 @@ bool MainMenuScene::Draw() ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 128)); ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32_BLACK_TRANS); ImVec2 pos = ImGui::GetCursorPos(); - ImGui::SetCursorPosX(ImGui::GetContentRegionMax().x - style.FramePadding.x * 2.0f - ImGui::GetTextLineHeight()); + ImGui::SetCursorPosX(ImGui::GetContentRegionMax().x - + style.FramePadding.x * 2.0f - + ImGui::GetTextLineHeight()); if (ImGui::Button(ICON_FA_XMARK)) { Hide(); } From 71d6e50425b90aea878cac7ecb2ce49fc13c0ba0 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Sat, 25 May 2024 22:25:18 -0400 Subject: [PATCH 10/12] pre-clang-format includes --- hw/xbox/smbus_xbox_smc.c | 13 ++-- hw/xbox/xbox.c | 26 ++++---- softmmu/vl.c | 125 ++++++++++++++++++++------------------- ui/xui/main-menu.cc | 23 +++---- 4 files changed, 95 insertions(+), 92 deletions(-) diff --git a/hw/xbox/smbus_xbox_smc.c b/hw/xbox/smbus_xbox_smc.c index a6da9a12fc0..04b48e20443 100644 --- a/hw/xbox/smbus_xbox_smc.c +++ b/hw/xbox/smbus_xbox_smc.c @@ -24,20 +24,21 @@ */ #include "qemu/osdep.h" -#include "hw/acpi/acpi.h" +#include "qemu/option.h" #include "hw/hw.h" +#include "hw/acpi/acpi.h" #include "hw/i2c/i2c.h" #include "hw/i2c/smbus_slave.h" -#include "hw/qdev-properties.h" -#include "qapi/error.h" #include "qemu/config-file.h" -#include "qemu/option.h" +#include "qapi/error.h" #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" -#include "sysemu/runstate.h" #include "sysemu/sysemu.h" -#include "ui/xemu-settings.h" #include "smbus.h" +#include "sysemu/runstate.h" +#include "hw/qdev-properties.h" + +#include "ui/xemu-settings.h" #define TYPE_XBOX_SMC "smbus-xbox-smc" #define XBOX_SMC(obj) OBJECT_CHECK(SMBusSMCDevice, (obj), TYPE_XBOX_SMC) diff --git a/hw/xbox/xbox.c b/hw/xbox/xbox.c index 6c95e9efdf2..e13398857e7 100644 --- a/hw/xbox/xbox.c +++ b/hw/xbox/xbox.c @@ -19,41 +19,41 @@ */ #include "qemu/osdep.h" -#include "hw/boards.h" -#include "hw/dma/i8257.h" +#include "qemu/option.h" +#include "qemu/datadir.h" #include "hw/hw.h" -#include "hw/i386/pc.h" -#include "hw/ide/pci.h" -#include "hw/kvm/clock.h" #include "hw/loader.h" +#include "hw/i386/pc.h" #include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" #include "hw/usb.h" #include "net/net.h" -#include "qemu/datadir.h" -#include "qemu/option.h" -#include "sysemu/kvm.h" +#include "hw/boards.h" +#include "hw/ide/pci.h" #include "sysemu/sysemu.h" +#include "sysemu/kvm.h" #include "kvm/kvm_i386.h" +#include "hw/kvm/clock.h" +#include "hw/dma/i8257.h" -#include "exec/address-spaces.h" -#include "exec/memory.h" #include "hw/sysbus.h" #include "sysemu/arch_init.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "cpu.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "hw/timer/i8254.h" #include "hw/audio/pcspk.h" #include "hw/rtc/mc146818rtc.h" -#include "hw/timer/i8254.h" +#include "hw/xbox/xbox_pci.h" #include "hw/i2c/i2c.h" #include "hw/i2c/smbus_eeprom.h" -#include "hw/xbox/mcpx/apu.h" #include "hw/xbox/nv2a/nv2a.h" -#include "hw/xbox/xbox_pci.h" +#include "hw/xbox/mcpx/apu.h" #include "hw/xbox/xbox.h" #include "smbus.h" diff --git a/softmmu/vl.c b/softmmu/vl.c index 16be9d36bce..16bbf0337b7 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -22,76 +22,77 @@ * THE SOFTWARE. */ + #include "qemu/osdep.h" +#include "qemu/help-texts.h" +#include "qemu/datadir.h" +#include "qemu/units.h" #include "exec/cpu-common.h" #include "exec/page-vary.h" #include "hw/qdev-properties.h" #include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qjson.h" #include "qapi/qmp/qstring.h" +#include "qapi/qmp/qjson.h" +#include "qemu-version.h" #include "qemu/cutils.h" -#include "qemu/datadir.h" -#include "qemu/help-texts.h" #include "qemu/help_option.h" #include "qemu/hw-version.h" -#include "qemu/units.h" #include "qemu/uuid.h" #include "sysemu/reset.h" -#include "sysemu/runstate-action.h" #include "sysemu/runstate.h" +#include "sysemu/runstate-action.h" #include "sysemu/seccomp.h" #include "sysemu/tcg.h" #include "sysemu/xen.h" -#include "qemu-version.h" -#include "chardev/char.h" -#include "exec/gdbstub.h" -#include "hw/acpi/acpi.h" -#include "hw/audio/soundhw.h" -#include "hw/block/block.h" -#include "hw/display/vga.h" -#include "hw/firmware/smbios.h" -#include "hw/i386/pc.h" -#include "hw/i386/x86.h" +#include "qemu/error-report.h" +#include "qemu/sockets.h" +#include "qemu/accel.h" +#include "hw/usb.h" #include "hw/isa/isa.h" -#include "hw/loader.h" #include "hw/scsi/scsi.h" -#include "hw/usb.h" +#include "hw/display/vga.h" +#include "hw/firmware/smbios.h" +#include "hw/acpi/acpi.h" #include "hw/xen/xen.h" -#include "migration/colo.h" -#include "migration/misc.h" -#include "migration/postcopy-ram.h" -#include "migration/snapshot.h" -#include "monitor/monitor.h" +#include "hw/loader.h" #include "monitor/qdev.h" #include "net/net.h" #include "net/slirp.h" -#include "qapi/qobject-input-visitor.h" -#include "qemu/accel.h" +#include "monitor/monitor.h" +#include "ui/console.h" +#include "ui/input.h" +#include "sysemu/sysemu.h" +#include "sysemu/numa.h" +#include "sysemu/hostmem.h" +#include "exec/gdbstub.h" +#include "qemu/timer.h" +#include "chardev/char.h" #include "qemu/bitmap.h" -#include "qemu/config-file.h" -#include "qemu/error-report.h" #include "qemu/log.h" -#include "qemu/main-loop.h" -#include "qemu/option.h" -#include "qemu/qemu-options.h" -#include "qemu/sockets.h" -#include "qemu/timer.h" #include "sysemu/blockdev.h" -#include "sysemu/cpu-timers.h" -#include "sysemu/cpus.h" -#include "sysemu/dma.h" -#include "sysemu/hax.h" -#include "sysemu/hostmem.h" -#include "sysemu/kvm.h" -#include "sysemu/numa.h" -#include "sysemu/sysemu.h" +#include "hw/block/block.h" +#include "hw/i386/x86.h" +#include "hw/i386/pc.h" +#include "migration/misc.h" +#include "migration/snapshot.h" #include "sysemu/tpm.h" -#include "ui/console.h" -#include "ui/input.h" +#include "sysemu/dma.h" +#include "hw/audio/soundhw.h" #include "audio/audio.h" +#include "sysemu/cpus.h" +#include "sysemu/cpu-timers.h" +#include "migration/colo.h" +#include "migration/postcopy-ram.h" +#include "sysemu/kvm.h" +#include "sysemu/hax.h" +#include "qapi/qobject-input-visitor.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "qemu/qemu-options.h" +#include "qemu/main-loop.h" #ifdef CONFIG_VIRTFS #include "fsdev/qemu-fsdev.h" #endif @@ -99,47 +100,47 @@ #include "disas/disas.h" -#include "exec/confidential-guest-support.h" +#include "trace.h" +#include "trace/control.h" #include "qemu/plugin.h" #include "qemu/queue.h" #include "sysemu/arch_init.h" -#include "trace.h" -#include "trace/control.h" +#include "exec/confidential-guest-support.h" -#include "block/qdict.h" -#include "crypto/init.h" -#include "qapi/clone-visitor.h" +#include "ui/qemu-spice.h" +#include "qapi/string-input-visitor.h" #include "qapi/opts-visitor.h" -#include "qapi/qapi-commands-block-core.h" -#include "qapi/qapi-commands-migration.h" -#include "qapi/qapi-commands-misc.h" -#include "qapi/qapi-commands-ui.h" +#include "qapi/clone-visitor.h" +#include "qom/object_interfaces.h" +#include "semihosting/semihost.h" +#include "crypto/init.h" +#include "sysemu/replay.h" #include "qapi/qapi-events-run-state.h" #include "qapi/qapi-types-audio.h" #include "qapi/qapi-visit-audio.h" #include "qapi/qapi-visit-block-core.h" #include "qapi/qapi-visit-compat.h" #include "qapi/qapi-visit-machine.h" -#include "qapi/qapi-visit-qom.h" #include "qapi/qapi-visit-ui.h" +#include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-visit-qom.h" +#include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qdict.h" +#include "block/qdict.h" #include "qapi/qmp/qerror.h" -#include "qapi/string-input-visitor.h" +#include "sysemu/iothread.h" #include "qemu/guest-random.h" #include "qemu/keyval.h" -#include "qom/object_interfaces.h" -#include "sysemu/iothread.h" -#include "sysemu/replay.h" -#include "ui/qemu-spice.h" -#include "semihosting/semihost.h" #include "config-host.h" -#include "hw/xbox/eeprom_generation.h" -#include "ui/xemu-input.h" -#include "ui/xemu-net.h" -#include "ui/xemu-notifications.h" #include "ui/xemu-settings.h" +#include "ui/xemu-notifications.h" +#include "ui/xemu-net.h" +#include "ui/xemu-input.h" +#include "hw/xbox/eeprom_generation.h" #define MAX_VIRTIO_CONSOLES 1 diff --git a/ui/xui/main-menu.cc b/ui/xui/main-menu.cc index 128f194e502..67265c938d3 100644 --- a/ui/xui/main-menu.cc +++ b/ui/xui/main-menu.cc @@ -16,28 +16,29 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . // -#include "qapi/error.h" -#include "main-menu.hh" -#include "actions.hh" + #include "common.hh" +#include "scene-manager.hh" +#include "widgets.hh" +#include "main-menu.hh" #include "font-manager.hh" -#include "gl-helpers.hh" #include "input-manager.hh" -#include "misc.hh" -#include "reporting.hh" -#include "scene-manager.hh" #include "snapshot-manager.hh" #include "viewport-manager.hh" -#include "widgets.hh" #include "xemu-hud.h" +#include "misc.hh" +#include "gl-helpers.hh" +#include "reporting.hh" +#include "qapi/error.h" +#include "actions.hh" #include "../xemu-input.h" -#include "../xemu-monitor.h" -#include "../xemu-net.h" #include "../xemu-notifications.h" -#include "../xemu-os-utils.h" #include "../xemu-settings.h" +#include "../xemu-monitor.h" #include "../xemu-version.h" +#include "../xemu-net.h" +#include "../xemu-os-utils.h" #include "../xemu-xbe.h" #include "../thirdparty/fatx/fatx.h" From 53ea5687f5ac3902c0d979a011812a14422c4461 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Sun, 26 May 2024 01:16:49 -0400 Subject: [PATCH 11/12] Do UI Eject/Load via SMC --- .gitignore | 1 + hw/xbox/smbus_xbox_smc.c | 9 +++++++++ ui/xemu.c | 35 ++++++++++++++++++++--------------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index bfac196fad1..6908e3810f1 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ build.log /macos-libs/ /macos-pkgs/ /xemu.iconset/ +/ccache diff --git a/hw/xbox/smbus_xbox_smc.c b/hw/xbox/smbus_xbox_smc.c index 04b48e20443..2eba19dd41c 100644 --- a/hw/xbox/smbus_xbox_smc.c +++ b/hw/xbox/smbus_xbox_smc.c @@ -376,6 +376,15 @@ void xbox_smc_eject_button(void) xbox_assert_extsmi(); } +void xbox_smc_tray_eject(uint8_t val) +{ + Object *obj = object_resolve_path_type("", TYPE_XBOX_SMC, NULL); + uint8_t buf[2]; + buf[0] = 0x0c; + buf[1] = val; + smc_write_data(obj,buf,2); +} + // FIXME: Ideally this would be called on a tray state change callback (see // tray_moved event), for now it's called explicitly from UI upon user // interaction. diff --git a/ui/xemu.c b/ui/xemu.c index b06e19eb1c7..38cd943f0e3 100644 --- a/ui/xemu.c +++ b/ui/xemu.c @@ -1556,7 +1556,9 @@ int main(int argc, char **argv) void xemu_eject_disc(Error **errp) { - Error *error = NULL; + xbox_smc_eject_button(); + + /*Error *error = NULL; xbox_smc_eject_button(); xemu_settings_set_string(&g_config.sys.files.dvd_path, ""); @@ -1567,25 +1569,28 @@ void xemu_eject_disc(Error **errp) error_propagate(errp, error); } - xbox_smc_update_tray_state(); + xbox_smc_update_tray_state();*/ } void xemu_load_disc(const char *path, Error **errp) { - Error *error = NULL; + xemu_settings_set_string(&g_config.sys.files.dvd_path, path); + xbox_smc_tray_eject(1); // issue smc tray load command - // Ensure an eject sequence is always triggered so Xbox software reloads - xbox_smc_eject_button(); - xemu_settings_set_string(&g_config.sys.files.dvd_path, ""); + // /*Error *error = NULL; - qmp_blockdev_change_medium(true, "ide0-cd1", false, NULL, path, - false, "", false, false, false, 0, - &error); - if (error) { - error_propagate(errp, error); - } else { - xemu_settings_set_string(&g_config.sys.files.dvd_path, path); - } + // // Ensure an eject sequence is always triggered so Xbox software reloads + // xbox_smc_eject_button(); + // xemu_settings_set_string(&g_config.sys.files.dvd_path, ""); + + // qmp_blockdev_change_medium(true, "ide0-cd1", false, NULL, path, + // false, "", false, false, false, 0, + // &error); + // if (error) { + // error_propagate(errp, error); + // } else { + // xemu_settings_set_string(&g_config.sys.files.dvd_path, path); + // } - xbox_smc_update_tray_state(); + // xbox_smc_update_tray_state();*/ } From 529b8a94e4a8216040330d2dcc6aef2b484a78b0 Mon Sep 17 00:00:00 2001 From: BiatuAutMiahn Date: Sun, 26 May 2024 01:19:44 -0400 Subject: [PATCH 12/12] Quick Cleanup --- ui/xemu.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/ui/xemu.c b/ui/xemu.c index 38cd943f0e3..75ed268565f 100644 --- a/ui/xemu.c +++ b/ui/xemu.c @@ -1557,40 +1557,10 @@ int main(int argc, char **argv) void xemu_eject_disc(Error **errp) { xbox_smc_eject_button(); - - /*Error *error = NULL; - - xbox_smc_eject_button(); - xemu_settings_set_string(&g_config.sys.files.dvd_path, ""); - - // Xbox software may request that the drive open, but do it now anyway - qmp_eject(true, "ide0-cd1", false, NULL, true, false, &error); - if (error) { - error_propagate(errp, error); - } - - xbox_smc_update_tray_state();*/ } void xemu_load_disc(const char *path, Error **errp) { xemu_settings_set_string(&g_config.sys.files.dvd_path, path); xbox_smc_tray_eject(1); // issue smc tray load command - - // /*Error *error = NULL; - - // // Ensure an eject sequence is always triggered so Xbox software reloads - // xbox_smc_eject_button(); - // xemu_settings_set_string(&g_config.sys.files.dvd_path, ""); - - // qmp_blockdev_change_medium(true, "ide0-cd1", false, NULL, path, - // false, "", false, false, false, 0, - // &error); - // if (error) { - // error_propagate(errp, error); - // } else { - // xemu_settings_set_string(&g_config.sys.files.dvd_path, path); - // } - - // xbox_smc_update_tray_state();*/ }