hw/char/serial: Support serial_mm_init() with wakeup event.
Subsystems (3)
PATCH 1/1 hw/char/serial: Support serial_mm_init() with wakeup event.
Although the "wakeup" parameter is declared in SerialState, but there is no function actually setting it up. Support "wakeup" as parameter in serial_mm_init().
We also add a new parameter "wakeup_reason" to let users specify their own wakeup event id.
--- hw/arm/allwinner-a10.c | 4 +++- hw/arm/allwinner-h3.c | 13 +++++++++---- hw/arm/aspeed_ast2600.c | 4 +++- hw/arm/aspeed_soc.c | 4 +++- hw/arm/kzm.c | 4 +++- hw/arm/msf2-soc.c | 4 +++- hw/arm/musicpal.c | 6 ++++-- hw/arm/npcm7xx.c | 4 +++- hw/arm/pxa2xx.c | 7 +++++-- hw/char/omap_uart.c | 7 +++++-- hw/char/serial.c | 9 +++++++-- hw/hppa/lasi.c | 3 ++- hw/hppa/machine.c | 3 ++- hw/microblaze/petalogix_ml605_mmu.c | 3 ++- hw/mips/boston.c | 3 ++- hw/mips/jazz.c | 7 +++++-- hw/mips/loongson3_virt.c | 2 +- hw/mips/malta.c | 3 ++- hw/nios2/10m50_devboard.c | 4 +++- hw/openrisc/openrisc_sim.c | 4 +++- hw/ppc/e500.c | 6 ++++-- hw/ppc/ppc405_uc.c | 7 +++++-- hw/ppc/ppc440_bamboo.c | 7 +++++-- hw/ppc/sam460ex.c | 7 +++++-- hw/ppc/virtex_ml507.c | 4 +++- hw/riscv/virt.c | 4 +++- hw/sparc64/niagara.c | 4 +++- hw/sparc64/sun4u.c | 3 ++- hw/xtensa/xtfpga.c | 3 ++- include/hw/char/serial.h | 4 +++- 30 files changed, 105 insertions(+), 42 deletions(-)
hw/arm/allwinner-a10.c +3 -1
@@ -21,6 +21,7 @@#include "hw/sysbus.h" #include "hw/arm/allwinner-a10.h" #include "hw/misc/unimp.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "hw/boards.h" #include "hw/usb/hcd-ohci.h"
@@ -124,7 +125,8 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)/* FIXME use a qdev chardev prop instead of serial_hd() */ serial_mm_init (get_system_memory (),AW_A10_UART0_REG_BASE ,2 ,qdev_get_gpio_in (dev,1 ), -115200 ,serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +115200 ,serial_hd (0 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );if (machine_usb (current_machine)) {int i;
hw/arm/allwinner-h3.c +9 -4
@@ -28,6 +28,7 @@#include "hw/misc/unimp.h" #include "hw/usb/hcd-ehci.h" #include "hw/loader.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "hw/arm/allwinner-h3.h"
@@ -399,19 +400,23 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)/* UART0. For future clocktree API: All UARTS are connected to APB2_CLK. */ serial_mm_init (get_system_memory (), s->memmap[AW_H3_DEV_UART0 ],2 ,qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_UART0 ), -115200 ,serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +115200 ,serial_hd (0 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* UART1 */ serial_mm_init (get_system_memory (), s->memmap[AW_H3_DEV_UART1 ],2 ,qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_UART1 ), -115200 ,serial_hd (1 ),DEVICE_NATIVE_ENDIAN ); +115200 ,serial_hd (1 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* UART2 */ serial_mm_init (get_system_memory (), s->memmap[AW_H3_DEV_UART2 ],2 ,qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_UART2 ), -115200 ,serial_hd (2 ),DEVICE_NATIVE_ENDIAN ); +115200 ,serial_hd (2 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* UART3 */ serial_mm_init (get_system_memory (), s->memmap[AW_H3_DEV_UART3 ],2 ,qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_UART3 ), -115200 ,serial_hd (3 ),DEVICE_NATIVE_ENDIAN ); +115200 ,serial_hd (3 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* DRAMC */ sysbus_realize (SYS_BUS_DEVICE (&s->dramc), &error_fatal);
hw/arm/aspeed_ast2600.c +3 -1
@@ -16,6 +16,7 @@#include "qemu/error-report.h" #include "hw/i2c/aspeed_i2c.h" #include "net/net.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #define ASPEED_SOC_IOMEM_SIZE 0x00200000
@@ -350,7 +351,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)/* UART - attach an 8250 to the IO space as our UART */ serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 ,aspeed_soc_get_irq (s, s->uart_default),38400 , -serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +serial_hd (0 ),DEVICE_LITTLE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* I2C */ object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
hw/arm/aspeed_soc.c +3 -1
@@ -19,6 +19,7 @@#include "qemu/error-report.h" #include "hw/i2c/aspeed_i2c.h" #include "net/net.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #define ASPEED_SOC_IOMEM_SIZE 0x00200000
@@ -300,7 +301,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)/* UART - attach an 8250 to the IO space as our UART */ serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 ,aspeed_soc_get_irq (s, s->uart_default),38400 , -serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +serial_hd (0 ),DEVICE_LITTLE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* I2C */ object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
hw/arm/kzm.c +3 -1
@@ -23,6 +23,7 @@#include "hw/net/lan9118.h" #include "hw/char/serial.h" #include "sysemu/qtest.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h"
@@ -120,7 +121,8 @@ static void kzm_init(MachineState *machine)if (serial_hd (2 )) {/* touchscreen */ serial_mm_init (get_system_memory (),KZM_FPGA_ADDR +0x10 ,0 ,qdev_get_gpio_in (DEVICE (&s->soc.avic),52 ), -14745600 ,serial_hd (2 ),DEVICE_NATIVE_ENDIAN ); +14745600 ,serial_hd (2 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); } kzm_binfo.ram_size = machine->ram_size;
hw/arm/msf2-soc.c +3 -1
@@ -30,6 +30,7 @@#include "hw/arm/msf2-soc.h" #include "hw/misc/unimp.h" #include "hw/qdev-clock.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #define MSF2_TIMER_BASE 0x40004000
@@ -148,7 +149,8 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)if (serial_hd (i)) {serial_mm_init (get_system_memory (), uart_addr[i],2 ,qdev_get_gpio_in (armv7m, uart_irq[i]), -115200 ,serial_hd (i),DEVICE_NATIVE_ENDIAN ); +115200 ,serial_hd (i),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); } }
hw/arm/musicpal.c +4 -2
@@ -1253,10 +1253,12 @@ static void musicpal_init(MachineState *machine)serial_mm_init (address_space_mem,MP_UART1_BASE ,2 ,qdev_get_gpio_in (uart_orgate,0 ), -1825000 ,serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +1825000 ,serial_hd (0 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );serial_mm_init (address_space_mem,MP_UART2_BASE ,2 ,qdev_get_gpio_in (uart_orgate,1 ), -1825000 ,serial_hd (1 ),DEVICE_NATIVE_ENDIAN ); +1825000 ,serial_hd (1 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* Register flash */ dinfo =drive_get (IF_PFLASH ,0 ,0 );
hw/arm/npcm7xx.c +3 -1
@@ -25,6 +25,7 @@#include "hw/qdev-properties.h" #include "qapi/error.h" #include "qemu/units.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" /*
@@ -563,7 +564,8 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)for (i =0 ; i <ARRAY_SIZE (npcm7xx_uart_addr); i++) {serial_mm_init (get_system_memory (), npcm7xx_uart_addr[i],2 ,npcm7xx_irq (s,NPCM7XX_UART0_IRQ + i),115200 , -serial_hd (i),DEVICE_LITTLE_ENDIAN ); +serial_hd (i),DEVICE_LITTLE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }/* Random Number Generator. Cannot fail. */
hw/arm/pxa2xx.c +5 -2
@@ -27,6 +27,7 @@#include "sysemu/blockdev.h" #include "sysemu/qtest.h" #include "sysemu/rtc.h" +#include "sysemu/runstate.h" #include "qemu/cutils.h" #include "qemu/log.h" #include "qom/object.h"
@@ -2153,7 +2154,8 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,serial_mm_init (address_space, pxa270_serial[i].io_base,2 ,qdev_get_gpio_in (s->pic, pxa270_serial[i].irqn),14857000 /16 ,serial_hd (i), -DEVICE_NATIVE_ENDIAN ); +DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }else {break ; }
@@ -2286,7 +2288,8 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)serial_mm_init (address_space, pxa255_serial[i].io_base,2 ,qdev_get_gpio_in (s->pic, pxa255_serial[i].irqn),14745600 /16 ,serial_hd (i), -DEVICE_NATIVE_ENDIAN ); +DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }else {break ; }
hw/char/omap_uart.c +5 -2
@@ -22,6 +22,7 @@#include "hw/arm/omap.h" #include "hw/char/serial.h" #include "exec/address-spaces.h" +#include "sysemu/runstate.h" /* UARTs */ struct omap_uart_s {
@@ -63,7 +64,8 @@ struct omap_uart_s *omap_uart_init(hwaddr base, s->serial =serial_mm_init (get_system_memory (), base,2 , irq,omap_clk_getrate (fclk)/16 , chr ?:qemu_chr_new (label,"null" ,NULL ), -DEVICE_NATIVE_ENDIAN ); +DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );return s; }
@@ -183,5 +185,6 @@ void omap_uart_attach(struct omap_uart_s *s, Chardev *chr) s->serial =serial_mm_init (get_system_memory (), s->base,2 , s->irq,omap_clk_getrate (s->fclk) /16 , chr ?:qemu_chr_new ("null" ,"null" ,NULL ), -DEVICE_NATIVE_ENDIAN ); +DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }
hw/char/serial.c +7 -2
@@ -602,7 +602,7 @@ static void serial_receive1(void *opaque, const uint8_t *buf, int size)SerialState *s = opaque;if (s->wakeup) { -qemu_system_wakeup_request (QEMU_WAKEUP_REASON_OTHER ,NULL ); +qemu_system_wakeup_request (s->wakeup_reason,NULL ); }if (s->fcr &UART_FCR_FE ) {int i;
@@ -972,6 +972,8 @@ static Property serial_properties[] = {DEFINE_PROP_CHR ("chardev" , SerialState, chr),DEFINE_PROP_UINT32 ("baudbase" , SerialState, baudbase,115200 ),DEFINE_PROP_BOOL ("wakeup" , SerialState, wakeup, false), +DEFINE_PROP_UINT32 ("wakeup-reason" , SerialState, + wakeup_reason,QEMU_WAKEUP_REASON_OTHER ), DEFINE_PROP_END_OF_LIST(), };
@@ -1062,7 +1064,8 @@ static const VMStateDescription vmstate_serial_mm = {SerialMM *serial_mm_init (MemoryRegion *address_space,hwaddr base,int regshift,qemu_irq irq,int baudbase, -Chardev *chr,enum device_endian end) +Chardev *chr,enum device_endian end, +bool wakeup,uint32_t wakeup_reason) {SerialMM *smm =SERIAL_MM (qdev_new (TYPE_SERIAL_MM ));MemoryRegion *mr;
@@ -1072,6 +1075,8 @@ SerialMM *serial_mm_init(MemoryRegion *address_space,qdev_prop_set_chr (DEVICE (smm),"chardev" , chr);qdev_set_legacy_instance_id (DEVICE (smm), base,2 );qdev_prop_set_uint8 (DEVICE (smm),"endianness" , end); +qdev_prop_set_bit (DEVICE (smm),"wakeup" , wakeup); +qdev_prop_set_uint32 (DEVICE (smm),"wakeup-reason" , wakeup_reason);sysbus_realize_and_unref (SYS_BUS_DEVICE (smm), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (smm),0 , irq);
hw/hppa/lasi.c +2 -1
@@ -334,7 +334,8 @@ DeviceState *lasi_init(MemoryRegion *address_space) lasi_get_irq(LASI_UART_HPA));serial_mm_init (address_space,LASI_UART_HPA +0x800 ,0 , serial_irq,8000000 /16 , -serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +serial_hd (0 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }/* PS/2 Keyboard/Mouse */
hw/hppa/machine.c +2 -1
@@ -181,7 +181,8 @@ static void machine_hppa_init(MachineState *machine)if (serial_hd (0 )) {uint32_t addr =DINO_UART_HPA +0x800 ;serial_mm_init (addr_space, addr,0 , serial_irq, -115200 ,serial_hd (0 ),DEVICE_BIG_ENDIAN ); +115200 ,serial_hd (0 ),DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }/* fw_cfg configuration interface */
hw/microblaze/petalogix_ml605_mmu.c +2 -1
@@ -32,6 +32,7 @@#include "hw/sysbus.h" #include "net/net.h" #include "hw/block/flash.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "hw/boards.h" #include "hw/char/serial.h"
@@ -122,7 +123,7 @@ petalogix_ml605_init(MachineState *machine)serial_mm_init (address_space_mem,UART16550_BASEADDR +0x1000 ,2 , irq[UART16550_IRQ ],115200 ,serial_hd (0 ), -DEVICE_LITTLE_ENDIAN ); +DEVICE_LITTLE_ENDIAN , false,QEMU_WAKEUP_REASON_NONE );/* 2 timers at irq 2 @ 100 Mhz. */ dev =qdev_new ("xlnx.xps-timer" );
hw/mips/boston.c +2 -1
@@ -749,7 +749,8 @@ static void boston_mach_init(MachineState *machine) s->uart =serial_mm_init (sys_mem, boston_memmap[BOSTON_UART ].base,2 ,get_cps_irq (&s->cps,3 ),10000000 , -serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +serial_hd (0 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); lcd =g_new (MemoryRegion,1 );memory_region_init_io (lcd,NULL , &boston_lcd_ops, s,"boston-lcd" ,0x8 );
hw/mips/jazz.c +5 -2
@@ -49,6 +49,7 @@#include "hw/sysbus.h" #include "sysemu/qtest.h" #include "sysemu/reset.h" +#include "sysemu/runstate.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/help_option.h"
@@ -369,10 +370,12 @@ static void mips_jazz_init(MachineState *machine,/* Serial ports */ serial_mm_init (address_space,0x80006000 ,0 ,qdev_get_gpio_in (rc4030,8 ),8000000 /16 , -serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +serial_hd (0 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );serial_mm_init (address_space,0x80007000 ,0 ,qdev_get_gpio_in (rc4030,9 ),8000000 /16 , -serial_hd (1 ),DEVICE_NATIVE_ENDIAN ); +serial_hd (1 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* Parallel port */ if (parallel_hds[0 ])
hw/mips/loongson3_virt.c +1 -1
@@ -521,7 +521,7 @@ static void mips_loongson3_virt_init(MachineState *machine)serial_mm_init (address_space_mem, virt_memmap[VIRT_UART ].base,0 ,qdev_get_gpio_in (liointc,UART_IRQ ),115200 ,serial_hd (0 ), -DEVICE_NATIVE_ENDIAN ); +DEVICE_NATIVE_ENDIAN , false,QEMU_WAKEUP_REASON_NONE );sysbus_create_simple ("goldfish_rtc" , virt_memmap[VIRT_RTC ].base,qdev_get_gpio_in (liointc,RTC_IRQ ));
hw/mips/malta.c +2 -1
@@ -587,7 +587,8 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space, malta_fgpa_display_event, NULL, s, NULL, true); s->uart =serial_mm_init (address_space, base +0x900 ,3 , uart_irq, -230400 , uart_chr,DEVICE_NATIVE_ENDIAN ); +230400 , uart_chr,DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );malta_fpga_reset (s);qemu_register_reset (malta_fpga_reset, s);
hw/nios2/10m50_devboard.c +3 -1
@@ -28,6 +28,7 @@#include "hw/sysbus.h" #include "hw/char/serial.h" #include "hw/qdev-properties.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "hw/boards.h" #include "exec/memory.h"
@@ -80,7 +81,8 @@ static void nios2_10m50_ghrd_init(MachineState *machine)/* Register: Altera 16550 UART */ serial_mm_init (address_space_mem,0xf8001600 ,2 , irq[1 ],115200 , -serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +serial_hd (0 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* Register: Timer sys_clk_timer */ dev =qdev_new ("ALTR.timer" );
hw/openrisc/openrisc_sim.c +3 -1
@@ -35,6 +35,7 @@#include "hw/sysbus.h" #include "sysemu/qtest.h" #include "sysemu/reset.h" +#include "sysemu/runstate.h" #include "hw/core/split-irq.h" #include <libfdt.h>
@@ -258,7 +259,8 @@ static void openrisc_sim_serial_init(Or1ksimState *state, hwaddr base, serial_irq =get_cpu_irq (cpus,0 , irq_pin); }serial_mm_init (get_system_memory (), base,0 , serial_irq,115200 , -serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +serial_hd (0 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* Add device tree node for serial. */ nodename =g_strdup_printf ("/serial@%" HWADDR_PRIx, base);
hw/ppc/e500.c +4 -2
@@ -934,13 +934,15 @@ void ppce500_init(MachineState *machine)if (serial_hd (0 )) {serial_mm_init (ccsr_addr_space,MPC8544_SERIAL0_REGS_OFFSET ,0 ,qdev_get_gpio_in (mpicdev,42 ),399193 , -serial_hd (0 ),DEVICE_BIG_ENDIAN ); +serial_hd (0 ),DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }if (serial_hd (1 )) {serial_mm_init (ccsr_addr_space,MPC8544_SERIAL1_REGS_OFFSET ,0 ,qdev_get_gpio_in (mpicdev,42 ),399193 , -serial_hd (1 ),DEVICE_BIG_ENDIAN ); +serial_hd (1 ),DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }/* I2C */ dev =qdev_new ("mpc-i2c" );
hw/ppc/ppc405_uc.c +5 -2
@@ -34,6 +34,7 @@#include "hw/char/serial.h" #include "qemu/timer.h" #include "sysemu/reset.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "exec/address-spaces.h" #include "hw/intc/ppc-uic.h"
@@ -1498,13 +1499,15 @@ PowerPCCPU *ppc405ep_init(MemoryRegion *address_space_mem,serial_mm_init (address_space_mem,0xef600300 ,0 ,qdev_get_gpio_in (uicdev,0 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (0 ), -DEVICE_BIG_ENDIAN ); +DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }if (serial_hd (1 ) !=NULL ) {serial_mm_init (address_space_mem,0xef600400 ,0 ,qdev_get_gpio_in (uicdev,1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (1 ), -DEVICE_BIG_ENDIAN ); +DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }/* OCM */ ppc405_ocm_init (env);
hw/ppc/ppc440_bamboo.c +5 -2
@@ -30,6 +30,7 @@#include "ppc405.h" #include "sysemu/sysemu.h" #include "sysemu/reset.h" +#include "sysemu/runstate.h" #include "hw/sysbus.h" #include "hw/intc/ppc-uic.h" #include "hw/qdev-properties.h"
@@ -238,13 +239,15 @@ static void bamboo_init(MachineState *machine)serial_mm_init (address_space_mem,0xef600300 ,0 ,qdev_get_gpio_in (uicdev,0 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (0 ), -DEVICE_BIG_ENDIAN ); +DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }if (serial_hd (1 ) !=NULL ) {serial_mm_init (address_space_mem,0xef600400 ,0 ,qdev_get_gpio_in (uicdev,1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (1 ), -DEVICE_BIG_ENDIAN ); +DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }if (pcibus) {
hw/ppc/sam460ex.c +5 -2
@@ -30,6 +30,7 @@#include "hw/block/flash.h" #include "sysemu/sysemu.h" #include "sysemu/reset.h" +#include "sysemu/runstate.h" #include "hw/sysbus.h" #include "hw/char/serial.h" #include "hw/i2c/ppc4xx_i2c.h"
@@ -438,13 +439,15 @@ static void sam460ex_init(MachineState *machine)serial_mm_init (address_space_mem,0x4ef600300 ,0 ,qdev_get_gpio_in (uic[1 ],1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (0 ), -DEVICE_BIG_ENDIAN ); +DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }if (serial_hd (1 ) !=NULL ) {serial_mm_init (address_space_mem,0x4ef600400 ,0 ,qdev_get_gpio_in (uic[0 ],1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (1 ), -DEVICE_BIG_ENDIAN ); +DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); }/* Load U-Boot image. */
hw/ppc/virtex_ml507.c +3 -1
@@ -32,6 +32,7 @@#include "hw/block/flash.h" #include "sysemu/sysemu.h" #include "sysemu/reset.h" +#include "sysemu/runstate.h" #include "hw/boards.h" #include "sysemu/device_tree.h" #include "hw/loader.h"
@@ -248,7 +249,8 @@ static void virtex_init(MachineState *machine) }serial_mm_init (address_space_mem,UART16550_BASEADDR ,2 , irq[UART16550_IRQ ], -115200 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +115200 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );/* 2 timers at irq 2 @ 62 Mhz. */ dev =qdev_new ("xlnx.xps-timer" );
hw/riscv/virt.c +3 -1
@@ -39,6 +39,7 @@#include "hw/misc/sifive_test.h" #include "chardev/char.h" #include "sysemu/device_tree.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "sysemu/kvm.h" #include "hw/pci/pci.h"
@@ -1404,7 +1405,8 @@ static void virt_machine_init(MachineState *machine)serial_mm_init (system_memory, memmap[VIRT_UART0 ].base,0 ,qdev_get_gpio_in (DEVICE (mmio_irqchip),UART0_IRQ ),399193 , -serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +serial_hd (0 ),DEVICE_LITTLE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );sysbus_create_simple ("goldfish_rtc" , memmap[VIRT_RTC ].base,qdev_get_gpio_in (DEVICE (mmio_irqchip),RTC_IRQ ));
hw/sparc64/niagara.c +3 -1
@@ -34,6 +34,7 @@#include "sysemu/block-backend.h" #include "qemu/error-report.h" #include "sysemu/qtest.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "qapi/error.h"
@@ -151,7 +152,8 @@ static void niagara_init(MachineState *machine) } }serial_mm_init (sysmem,NIAGARA_UART_BASE ,0 ,NULL , -115200 ,serial_hd (0 ),DEVICE_BIG_ENDIAN ); +115200 ,serial_hd (0 ),DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE );create_unimplemented_device ("sun4v-iob" ,NIAGARA_IOBBASE ,NIAGARA_IOBSIZE );sun4v_rtc_init (NIAGARA_RTC_BASE ); }
hw/sparc64/sun4u.c +2 -1
@@ -326,7 +326,8 @@ static void ebus_realize(PCIDevice *pci_dev, Error **errp) i =0 ;if (s->console_serial_base) {serial_mm_init (pci_address_space (pci_dev), s->console_serial_base, -0 ,NULL ,115200 ,serial_hd (i),DEVICE_BIG_ENDIAN ); +0 ,NULL ,115200 ,serial_hd (i),DEVICE_BIG_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); i++; }serial_hds_isa_init (s->isa_bus, i,MAX_ISA_SERIAL_PORTS );
hw/xtensa/xtfpga.c +2 -1
@@ -312,7 +312,8 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) }serial_mm_init (system_io,0x0d050020 ,2 , extints[0 ], -115200 ,serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +115200 ,serial_hd (0 ),DEVICE_NATIVE_ENDIAN , + false,QEMU_WAKEUP_REASON_NONE ); dinfo =drive_get (IF_PFLASH ,0 ,0 );if (dinfo) {
include/hw/char/serial.h +3 -1
@@ -62,6 +62,7 @@ struct SerialState {uint32_t tsr_retry;guint watch_tag;bool wakeup; +uint32_t wakeup_reason;/* Time when the last byte was successfully sent out of the tsr */ uint64_t last_xmit_ts;
@@ -104,7 +105,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(SerialMM, SERIAL_MM)SerialMM *serial_mm_init (MemoryRegion *address_space,hwaddr base,int regshift,qemu_irq irq,int baudbase, -Chardev *chr,enum device_endian end); +Chardev *chr,enum device_endian end, +bool wakeup,uint32_t wakeup_reason);/* serial-isa.c */
Signature · 1 line
2.34.1.390.g2ae0a9cb82
Quoted 4 lines · Dylan Jhong
Although the "wakeup" parameter is declared in SerialState, but there is no function actually setting it up. Support "wakeup" as parameter in
serial_mm_init().
This patch seems to provide a new argument which every caller passes the same value for, unless I missed one somewhere. What's the reason for this change?
thanks
-- PMM
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Dylan Jhong
Although the "wakeup" parameter is declared in SerialState, but there is no function actually setting it up. Support "wakeup" as parameter in
serial_mm_init().
Quoted 6 lines
This patch seems to provide a new argument which every caller passes the same value for, unless I missed one somewhere. What's the reason for this change?
thanks
-- PMM
Hi PMM,
First of all, thank you for your review.
The purpose of this variable is to allow users to specify their own wakeup reason id.
At present, there are only 4 wakeup reasons provided by QEMU[*1].
Take uart as an example, which are classified as QEMU_WAKEUP_REASON_OTHER,
so there is no way to distinguish the source of the wakeup reason when designing a custom power manager device.
Indeed, as you can see, currently there is no device that supports the use of "wakeup_reason". But it will be used on the board we are going to upstream later.
The goal of this patch is to make the "wakeup" feature support more complete.
[*1] include/sysemu/runstate.h:42
typedef enum WakeupReason {
/* Always keep QEMU_WAKEUP_REASON_NONE = 0 */
QEMU_WAKEUP_REASON_NONE = 0,
QEMU_WAKEUP_REASON_RTC,
QEMU_WAKEUP_REASON_PMTIMER,
QEMU_WAKEUP_REASON_OTHER,
} WakeupReason;
Thanks,
Dylan
Quoted 15 lines · Dylan Jhong
Quoted 9 lines · Peter Maydell
Quoted 4 lines · Dylan Jhong
Although the "wakeup" parameter is declared in SerialState, but there is no function actually setting it up. Support "wakeup" as parameter in
serial_mm_init().This patch seems to provide a new argument which every caller passes the same value for, unless I missed one somewhere. What's the reason for this change?
First of all, thank you for your review.
The purpose of this variable is to allow users to specify their own wakeup reason id.
Quoted 6 lines
At present, there are only 4 wakeup reasons provided by QEMU[*1].
Take uart as an example, which are classified asQEMU_WAKEUP_REASON_OTHER,
so there is no way to distinguish the source of the wakeup reason when designing a custom power manager device.Indeed, as you can see, currently there is no device that supports the use of "
wakeup_reason". But it will be used on the board we are going to upstream later.
None of this tells me why different UARTs would want different wakeup reasons, or how, if I'm writing a new UART device model, I should select the wakeup reason, though.
If the intention of this change is as an initial step in the addition of a new board model, then you should provide it as part of the patchseries that's upstreaming that board, so that we can see in context how the proposed new API is going to be used.
Also, the patch changes the wakeup reason for every user of serial_mm_init() from "OTHER" to "NONE", which doesn't seem right.
Since serial_mm_init() is now just a legacy wrapper for creating a device and setting its properties, consider just having your new board model create and configure the device directly, including the new wakeup-reason property, rather than using serial_mm_init() and forcing all the other callers of it to change. (Doing that is bette modern QEMU coding style anyway, usually.)
thanks
-- PMM