target-arm queue
Subsystems (2)
[PULL 02/46] target/arm: Conditionalize DBGDIDR
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Only define the register if it exists for the cpu.
Message-id: [email protected]
--- target/arm/helper.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
target/arm/helper.c +15 -6
@@ -6567,11 +6567,21 @@ static void define_debug_regs(ARMCPU *cpu)*/ int i;int wrps, brps, ctx_cmps; -ARMCPRegInfo dbgdidr = { - .name ="DBGDIDR" , .cp =14 , .crn =0 , .crm =0 , .opc1 =0 , .opc2 =0 , - .access =PL0_R , .accessfn = access_tda, - .type =ARM_CP_CONST , .resetvalue = cpu->isar.dbgdidr, - }; + +/* +* The Arm ARM says DBGDIDR is optional and deprecated if EL1 cannot +* use AArch32. Given that bit 15 is RES1, if the value is 0 then +* the register must not exist for this cpu. +*/ +if (cpu->isar.dbgdidr !=0 ) { +ARMCPRegInfo dbgdidr = { + .name ="DBGDIDR" , .cp =14 , .crn =0 , .crm =0 , + .opc1 =0 , .opc2 =0 , + .access =PL0_R , .accessfn = access_tda, + .type =ARM_CP_CONST , .resetvalue = cpu->isar.dbgdidr, + }; +define_one_arm_cp_reg (cpu, &dbgdidr); + }/* Note that all these register fields hold "number of Xs minus 1". */ brps =arm_num_brps (cpu);
@@ -6580,7 +6590,6 @@ static void define_debug_regs(ARMCPU *cpu)assert (ctx_cmps <= brps); -define_one_arm_cp_reg (cpu, &dbgdidr);define_arm_cp_regs (cpu, debug_cp_reginfo);if (arm_feature (&cpu->env,ARM_FEATURE_LPAE )) {
Signature · 1 line
2.20.1
[PULL 05/46] arm-virt: refactor gpios creation
In reply to Peter MaydellFrom: Maxim Uvarov <[email protected]>
No functional change. Just refactor code to better support secure and normal world gpios.
--- hw/arm/virt.c | 57 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 21 deletions(-)
hw/arm/virt.c +36 -21
@@ -820,17 +820,43 @@ static void virt_powerdown_req(Notifier *n, void *opaque) } } -static void create_gpio (const VirtMachineState *vms) +static void create_gpio_keys (const VirtMachineState *vms, +DeviceState *pl061_dev, +uint32_t phandle) +{ + gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 , +qdev_get_gpio_in (pl061_dev,3 )); + +qemu_fdt_add_subnode (vms->fdt,"/gpio-keys" ); +qemu_fdt_setprop_string (vms->fdt,"/gpio-keys" ,"compatible" ,"gpio-keys" ); +qemu_fdt_setprop_cell (vms->fdt,"/gpio-keys" ,"#size-cells" ,0 ); +qemu_fdt_setprop_cell (vms->fdt,"/gpio-keys" ,"#address-cells" ,1 ); + +qemu_fdt_add_subnode (vms->fdt,"/gpio-keys/poweroff" ); +qemu_fdt_setprop_string (vms->fdt,"/gpio-keys/poweroff" , +"label" ,"GPIO Key Poweroff" ); +qemu_fdt_setprop_cell (vms->fdt,"/gpio-keys/poweroff" ,"linux,code" , +KEY_POWER ); +qemu_fdt_setprop_cells (vms->fdt,"/gpio-keys/poweroff" , +"gpios" , phandle,3 ,0 ); +} + +static void create_gpio_devices (const VirtMachineState *vms,int gpio, +MemoryRegion *mem) {char *nodename;DeviceState *pl061_dev; -hwaddr base = vms->memmap[VIRT_GPIO ].base; -hwaddr size = vms->memmap[VIRT_GPIO ].size; -int irq = vms->irqmap[VIRT_GPIO ]; +hwaddr base = vms->memmap[gpio].base; +hwaddr size = vms->memmap[gpio].size; +int irq = vms->irqmap[gpio];const char compat[] ="arm,pl061\0arm,primecell" ; +SysBusDevice *s; - pl061_dev =sysbus_create_simple ("pl061" , base, -qdev_get_gpio_in (vms->gic, irq)); + pl061_dev =qdev_new ("pl061" ); + s =SYS_BUS_DEVICE (pl061_dev); +sysbus_realize_and_unref (s, &error_fatal); +memory_region_add_subregion (mem, base,sysbus_mmio_get_region (s,0 )); +sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->gic, irq));uint32_t phandle =qemu_fdt_alloc_phandle (vms->fdt); nodename =g_strdup_printf ("/pl061@%" PRIx64, base);
@@ -847,21 +873,10 @@ static void create_gpio(const VirtMachineState *vms)qemu_fdt_setprop_string (vms->fdt, nodename,"clock-names" ,"apb_pclk" );qemu_fdt_setprop_cell (vms->fdt, nodename,"phandle" , phandle); - gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 , -qdev_get_gpio_in (pl061_dev,3 )); -qemu_fdt_add_subnode (vms->fdt,"/gpio-keys" ); -qemu_fdt_setprop_string (vms->fdt,"/gpio-keys" ,"compatible" ,"gpio-keys" ); -qemu_fdt_setprop_cell (vms->fdt,"/gpio-keys" ,"#size-cells" ,0 ); -qemu_fdt_setprop_cell (vms->fdt,"/gpio-keys" ,"#address-cells" ,1 ); - -qemu_fdt_add_subnode (vms->fdt,"/gpio-keys/poweroff" ); -qemu_fdt_setprop_string (vms->fdt,"/gpio-keys/poweroff" , -"label" ,"GPIO Key Poweroff" ); -qemu_fdt_setprop_cell (vms->fdt,"/gpio-keys/poweroff" ,"linux,code" , -KEY_POWER ); -qemu_fdt_setprop_cells (vms->fdt,"/gpio-keys/poweroff" , -"gpios" , phandle,3 ,0 );g_free (nodename); + +/* Child gpio devices */ +create_gpio_keys (vms, pl061_dev, phandle); }static void create_virtio_devices (const VirtMachineState *vms)
@@ -1990,7 +2005,7 @@ static void machvirt_init(MachineState *machine)if (has_ged && aarch64 && firmware_loaded &&virt_is_acpi_enabled (vms)) { vms->acpi_dev =create_acpi_ged (vms); }else { -create_gpio (vms); +create_gpio_devices (vms,VIRT_GPIO , sysmem); }/* connect powerdown request */
Signature · 1 line
2.20.1
[PULL 03/46] arm: rename xlnx-zcu102.canbusN properties
In reply to Peter MaydellFrom: Paolo Bonzini <[email protected]>
The properties to attach a CANBUS object to the xlnx-zcu102 machine have a period in them. We want to use periods in properties for compound QAPI types, and besides the "xlnx-zcu102." prefix is both unnecessary and different from any other machine property name. Remove it.
Message-id: [email protected]
--- hw/arm/xlnx-zcu102.c | 4 ++-- tests/qtest/xlnx-can-test.c | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 17 deletions(-)
hw/arm/xlnx-zcu102.c +2 -2
@@ -219,12 +219,12 @@ static void xlnx_zcu102_machine_instance_init(Object *obj) s->secure = false;/* Default to virt (EL2) being disabled */ s->virt = false; -object_property_add_link (obj,"xlnx-zcu102.canbus0" ,TYPE_CAN_BUS , +object_property_add_link (obj,"canbus0" ,TYPE_CAN_BUS , (Object **)&s->canbus[0 ], object_property_allow_set_link,0 ); -object_property_add_link (obj,"xlnx-zcu102.canbus1" ,TYPE_CAN_BUS , +object_property_add_link (obj,"canbus1" ,TYPE_CAN_BUS , (Object **)&s->canbus[1 ], object_property_allow_set_link,0 );
tests/qtest/xlnx-can-test.c +15 -15
@@ -138,9 +138,9 @@ static void test_can_bus(void)uint8_t can_timestamp =1 ;QTestState *qts =qtest_init ("-machine xlnx-zcu102" -" -object can-bus,id=canbus0" -" -machine xlnx-zcu102.canbus0=canbus0" -" -machine xlnx-zcu102.canbus1=canbus0" +" -object can-bus,id=canbus" +" -machine canbus0=canbus" +" -machine canbus1=canbus" );/* Configure the CAN0 and CAN1. */
@@ -175,9 +175,9 @@ static void test_can_loopback(void)uint32_t status =0 ;QTestState *qts =qtest_init ("-machine xlnx-zcu102" -" -object can-bus,id=canbus0" -" -machine xlnx-zcu102.canbus0=canbus0" -" -machine xlnx-zcu102.canbus1=canbus0" +" -object can-bus,id=canbus" +" -machine canbus0=canbus" +" -machine canbus1=canbus" );/* Configure the CAN0 in loopback mode. */
@@ -223,9 +223,9 @@ static void test_can_filter(void)uint8_t can_timestamp =1 ;QTestState *qts =qtest_init ("-machine xlnx-zcu102" -" -object can-bus,id=canbus0" -" -machine xlnx-zcu102.canbus0=canbus0" -" -machine xlnx-zcu102.canbus1=canbus0" +" -object can-bus,id=canbus" +" -machine canbus0=canbus" +" -machine canbus1=canbus" );/* Configure the CAN0 and CAN1. */
@@ -271,9 +271,9 @@ static void test_can_sleepmode(void)uint8_t can_timestamp =1 ;QTestState *qts =qtest_init ("-machine xlnx-zcu102" -" -object can-bus,id=canbus0" -" -machine xlnx-zcu102.canbus0=canbus0" -" -machine xlnx-zcu102.canbus1=canbus0" +" -object can-bus,id=canbus" +" -machine canbus0=canbus" +" -machine canbus1=canbus" );/* Configure the CAN0. */
@@ -317,9 +317,9 @@ static void test_can_snoopmode(void)uint8_t can_timestamp =1 ;QTestState *qts =qtest_init ("-machine xlnx-zcu102" -" -object can-bus,id=canbus0" -" -machine xlnx-zcu102.canbus0=canbus0" -" -machine xlnx-zcu102.canbus1=canbus0" +" -object can-bus,id=canbus" +" -machine canbus0=canbus" +" -machine canbus1=canbus" );/* Configure the CAN0. */
Signature · 1 line
2.20.1
[PULL 08/46] target/arm: Replace magic value by MMU_DATA_LOAD definition
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
cpu_get_phys_page_debug() uses 'DATA LOAD' MMU access type.
Message-id: [email protected]
--- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/helper.c +1 -1
@@ -12418,7 +12418,7 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, *attrs = (MemTxAttrs ) {}; - ret =get_phys_addr (env, addr,0 , mmu_idx, &phys_addr, + ret =get_phys_addr (env, addr,MMU_DATA_LOAD , mmu_idx, &phys_addr, attrs, &prot, &page_size, &fi, &cacheattrs);if (ret) {
Signature · 1 line
2.20.1
[PULL 01/46] target/arm: Implement ID_PFR2
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
This was defined at some point before ARMv8.4, and will shortly be used by new processor descriptions.
Message-id: [email protected]
--- target/arm/cpu.h | 1 + target/arm/helper.c | 4 ++-- target/arm/kvm64.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-)
target/arm/cpu.h +1 -0
@@ -922,6 +922,7 @@ struct ARMCPU {uint32_t id_mmfr4;uint32_t id_pfr0;uint32_t id_pfr1; +uint32_t id_pfr2;uint32_t mvfr0;uint32_t mvfr1;uint32_t mvfr2;
target/arm/helper.c +2 -2
@@ -7662,11 +7662,11 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, .resetvalue = 0 }, - { .name = "MVFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, + { .name = "ID_PFR2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = 0 }, + .resetvalue = cpu->isar.id_pfr2 }, { .name = "MVFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST,
target/arm/kvm64.c +2 -0
@@ -578,6 +578,8 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ARM64_SYS_REG(3, 0, 0, 1, 0)); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_pfr1,ARM64_SYS_REG (3 ,0 ,0 ,1 ,1 )); + err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_pfr2, +ARM64_SYS_REG (3 ,0 ,0 ,3 ,4 )); err |=read_sys_reg32 (fdarray[2 ], &ahcf->isar.id_dfr0,ARM64_SYS_REG (3 ,0 ,0 ,1 ,2 )); err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0,
Signature · 1 line
2.20.1
[PULL 06/46] arm-virt: add secure pl061 for reset/power down
In reply to Peter MaydellFrom: Maxim Uvarov <[email protected]>
Add secure pl061 for reset/power down machine from the secure world (Arm Trusted Firmware). Connect it with gpio-pwr driver.
--- docs/system/arm/virt.rst | 2 ++ include/hw/arm/virt.h | 2 ++ hw/arm/virt.c | 56 +++++++++++++++++++++++++++++++++++++++- hw/arm/Kconfig | 1 + 4 files changed, 60 insertions(+), 1 deletion(-)
docs/system/arm/virt.rst +2 -0
@@ -43,6 +43,8 @@ The virt board supports: - Secure-World-only devices if the CPU has TrustZone: - A second PL011 UART + - A second PL061 GPIO controller, with GPIO lines for triggering + a system reset or system poweroff - A secure flash memory - 16MB of secure RAM
include/hw/arm/virt.h +2 -0
@@ -81,6 +81,7 @@ enum {VIRT_GPIO ,VIRT_SECURE_UART ,VIRT_SECURE_MEM , +VIRT_SECURE_GPIO ,VIRT_PCDIMM_ACPI ,VIRT_ACPI_GED , VIRT_NVDIMM_ACPI,
@@ -127,6 +128,7 @@ struct VirtMachineClass {bool kvm_no_adjvtime;bool no_kvm_steal_time;bool acpi_expose_flash; +bool no_secure_gpio; };struct VirtMachineState {
hw/arm/virt.c +55 -1
91 lines not on this page · raw message
hw/arm/Kconfig +1 -0
@@ -17,6 +17,7 @@ config ARM_VIRT select PL011 # UART select PL031 # RTC select PL061 # GPIO + select GPIO_PWR select PLATFORM_BUS select SMBIOS select VIRTIO_MMIO
Signature · 1 line
2.20.1
[PULL 09/46] configure: Move preadv check to meson.build
In reply to Peter MaydellMove the preadv availability check to meson.build. This is what we want to be doing for host-OS-feature-checks anyway, but it also fixes a problem with building for macOS with the most recent XCode SDK on a Catalina host.
On that configuration, 'preadv()' is provided as a weak symbol, so that programs can be built with optional support for it and make a runtime availability check to see whether the preadv() they have is a working one or one which they must not call because it will runtime-assert. QEMU's configure test passes (unless you're building with --enable-werror) because the test program using preadv() compiles, but then QEMU crashes at runtime when preadv() is called, with errors like:
dyld: lazy symbol binding failed: Symbol not found: _preadv
Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _preadv
Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication Expected in: /usr/lib/libSystem.B.dylib
Meson's own function availability check has a special case for macOS which adds '-Wl,-no_weak_imports' to the compiler flags, which forces the test to require the real function, not the macOS-version-too-old stub.
So this commit fixes the bug where macOS builds on Catalina currently require --disable-werror.
Message-id: [email protected]
--- configure | 16 ---------------- meson.build | 4 +++- 2 files changed, 3 insertions(+), 17 deletions(-)
configure +0 -16
@@ -3531,19 +3531,6 @@ if compile_prog "" "" ; then iovec=yes fi -########################################## -# preadv probe -cat > $TMPC <<EOF -#include <sys/types.h> -#include <sys/uio.h> -#include <unistd.h> -int main(void) { return preadv(0, 0, 0, 0); } -EOF -preadv=no -if compile_prog "" "" ; then - preadv=yes -fi - ########################################## # fdt probe
@@ -5748,9 +5735,6 @@ fi if test "$iovec" = "yes" ; then echo "CONFIG_IOVEC=y" >> $config_host_mak fi -if test "$preadv" = "yes" ; then - echo "CONFIG_PREADV=y" >> $config_host_mak -fi if test "$membarrier" = "yes" ; then echo "CONFIG_MEMBARRIER=y" >> $config_host_mak fi
meson.build +3 -1
@@ -1128,6 +1128,8 @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) +config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>')) + ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST'] strings = ['HOST_DSOSUF', 'CONFIG_IASL']
@@ -2414,7 +2416,7 @@ summary_info += {'PIE': get_option('b_pie')} summary_info += {'static build': config_host.has_key('CONFIG_STATIC')} summary_info += {'malloc trim support': has_malloc_trim} summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')} -summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')} +summary_info += {'preadv support': config_host_data.get('CONFIG_PREADV')} summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')} summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')} summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')}
Signature · 1 line
2.20.1
[PULL 12/46] darwin: remove redundant dependency declaration
In reply to Peter MaydellFrom: Joelle van Dyne <[email protected]>
Meson will find CoreFoundation, IOKit, and Cocoa as needed.
Message-id: [email protected]
--- configure | 1 - 1 file changed, 1 deletion(-)
configure +0 -1
@@ -780,7 +780,6 @@ Darwin) fi audio_drv_list="coreaudio try-sdl" audio_possible_drivers="coreaudio sdl" - QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS" # Disable attempts to use ObjectiveC features in os/object.h since they # won't work when we're compiling with gcc as a C compiler. QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
Signature · 1 line
2.20.1
The following changes since commit 7e7eb9f852a46b51a71ae9d82590b2e4d28827ee:
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-01-28' into staging (2021-01-28 22:43:18 +0000)
are available in the Git repository at:
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210129
for you to fetch changes up to 11749122e1a86866591306d43603d2795a3dea1a:
hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS (2021-01-29 10:47:29 +0000)
----------------------------------------------------------------
target-arm queue:
* Implement ID_PFR2
* Conditionalize DBGDIDR
* rename xlnx-zcu102.canbusN properties
* provide powerdown/reset mechanism for secure firmware on 'virt' board
* hw/misc: Fix arith overflow in NPCM7XX PWM module
* target/arm: Replace magic value by MMU_DATA_LOAD definition
* configure: fix preadv errors on Catalina macOS with new XCode
* Various configure and other cleanups in preparation for iOS support
* hvf: Add hypervisor entitlement to output binaries (needed for Big Sur)
* Implement pvpanic-pci device
* Convert the CMSDK timer devices to the Clock framework
----------------------------------------------------------------
Alexander Graf (1):
hvf: Add hypervisor entitlement to output binaries
Hao Wu (1):
hw/misc: Fix arith overflow in NPCM7XX PWM module
Joelle van Dyne (7):
configure: cross-compiling with empty cross_prefix
osdep: build with non-working system() function
darwin: remove redundant dependency declaration
darwin: fix cross-compiling for Darwin
configure: cross compile should use x86_64 cpu_family
darwin: detect CoreAudio for build
darwin: remove 64-bit build detection on 32-bit OS
Maxim Uvarov (3):
hw: gpio: implement gpio-pwr driver for qemu reset/poweroff
arm-virt: refactor gpios creation
arm-virt: add secure pl061 for reset/power down
Mihai Carabas (4):
hw/misc/pvpanic: split-out generic and bus dependent code hw/misc/pvpanic: add PCI interface support pvpanic : update pvpanic spec document tests/qtest: add a test case for pvpanic-pci
Paolo Bonzini (1):
arm: rename xlnx-zcu102.canbusN properties
Peter Maydell (26):
configure: Move preadv check to meson.build
ptimer: Add new ptimer_set_period_from_clock() function
clock: Add new clock_has_source() function
tests: Add a simple test of the CMSDK APB timer
tests: Add a simple test of the CMSDK APB watchdog
tests: Add a simple test of the CMSDK APB dual timer hw/timer/cmsdk-apb-timer: Rename CMSDKAPBTIMER struct to CMSDKAPBTimer hw/timer/cmsdk-apb-timer: Add Clock input hw/timer/cmsdk-apb-dualtimer: Add Clock input hw/watchdog/cmsdk-apb-watchdog: Add Clock input hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ" hw/arm/armsse: Wire up clocks
hw/arm/mps2: Inline CMSDK_APB_TIMER creation
hw/arm/mps2: Create and connect SYSCLK Clock
hw/arm/mps2-tz: Create and connect ARMSSE Clocks hw/arm/musca: Create and connect ARMSSE Clocks hw/arm/stellaris: Convert SSYS to QOM device hw/arm/stellaris: Create Clock input for watchdog hw/timer/cmsdk-apb-timer: Convert to use Clock input hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input tests/qtest/cmsdk-apb-watchdog-test: Test clock changes hw/arm/armsse: Use Clock to set system_clock_scale
arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE
arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS
Philippe Mathieu-Daudé (1):
target/arm: Replace magic value by MMU_DATA_LOAD definition
Richard Henderson (2):
target/arm: Implement ID_PFR2
target/arm: Conditionalize DBGDIDR
docs/devel/clocks.rst | 16 +++ docs/specs/pci-ids.txt | 1 + docs/specs/pvpanic.txt | 13 ++- docs/system/arm/virt.rst | 2 + configure | 78 ++++++++------ meson.build | 34 ++++++- include/hw/arm/armsse.h | 14 ++- include/hw/arm/virt.h | 2 + include/hw/clock.h | 15 +++ include/hw/misc/pvpanic.h | 24 ++++- include/hw/pci/pci.h | 1 + include/hw/ptimer.h | 22 ++++ include/hw/timer/cmsdk-apb-dualtimer.h | 5 +- include/hw/timer/cmsdk-apb-timer.h | 34 ++----- include/hw/watchdog/cmsdk-apb-watchdog.h | 5 +- include/qemu/osdep.h | 12 +++ include/qemu/typedefs.h | 1 + target/arm/cpu.h | 1 + hw/arm/armsse.c | 48 ++++++--- hw/arm/mps2-tz.c | 14 ++- hw/arm/mps2.c | 28 ++++- hw/arm/musca.c | 13 ++- hw/arm/stellaris.c | 170 +++++++++++++++++++++++-------- hw/arm/virt.c | 111 ++++++++++++++++---- hw/arm/xlnx-zcu102.c | 4 +- hw/core/ptimer.c | 34 +++++++ hw/gpio/gpio_pwr.c | 70 +++++++++++++ hw/misc/npcm7xx_pwm.c | 23 ++++- hw/misc/pvpanic-isa.c | 94 +++++++++++++++++ hw/misc/pvpanic-pci.c | 94 +++++++++++++++++ hw/misc/pvpanic.c | 85 ++-------------- hw/timer/cmsdk-apb-dualtimer.c | 53 +++++++--- hw/timer/cmsdk-apb-timer.c | 55 +++++----- hw/watchdog/cmsdk-apb-watchdog.c | 29 ++++-- target/arm/helper.c | 27 +++-- target/arm/kvm64.c | 2 + tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++ tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++ tests/qtest/cmsdk-apb-watchdog-test.c | 131 ++++++++++++++++++++++++ tests/qtest/npcm7xx_pwm-test.c | 4 +- tests/qtest/pvpanic-pci-test.c | 94 +++++++++++++++++ tests/qtest/xlnx-can-test.c | 30 +++--- MAINTAINERS | 3 + accel/hvf/entitlements.plist | 8 ++ hw/arm/Kconfig | 1 + hw/gpio/Kconfig | 3 + hw/gpio/meson.build | 1 + hw/i386/Kconfig | 2 +- hw/misc/Kconfig | 12 ++- hw/misc/meson.build | 4 +- scripts/entitlement.sh | 13 +++ tests/qtest/meson.build | 6 +- 52 files changed, 1432 insertions(+), 319 deletions(-) create mode 100644 hw/gpio/gpio_pwr.c create mode 100644 hw/misc/pvpanic-isa.c create mode 100644 hw/misc/pvpanic-pci.c create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c create mode 100644 tests/qtest/cmsdk-apb-timer-test.c create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c create mode 100644 tests/qtest/pvpanic-pci-test.c create mode 100644 accel/hvf/entitlements.plist create mode 100755 scripts/entitlement.sh
[PULL 11/46] osdep: build with non-working system() function
From: Joelle van Dyne <[email protected]>
Build without error on hosts without a working system(). If system() is called, return -1 with ENOSYS.
Message-id: [email protected]
--- meson.build | 1 + include/qemu/osdep.h | 12 ++++++++++++ 2 files changed, 13 insertions(+)
meson.build +1 -0
@@ -1127,6 +1127,7 @@ config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h')) config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) +config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>')) config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
include/qemu/osdep.h +12 -0
@@ -710,4 +710,16 @@ static inline void qemu_thread_jit_write(void) {}static inline void qemu_thread_jit_execute (void ) {}#endif +/** +* Platforms which do not support system() return ENOSYS +*/ +#ifndef HAVE_SYSTEM_FUNCTION +#define system platform_does_not_support_system +static inline int platform_does_not_support_system (const char *command) +{ + errno =ENOSYS ; +return -1 ; +} +#endif /* !HAVE_SYSTEM_FUNCTION */ +#endif
Signature · 1 line
2.20.1
[PULL 13/46] darwin: fix cross-compiling for Darwin
In reply to Peter MaydellFrom: Joelle van Dyne <[email protected]>
Add objc to the Meson cross file as well as detection of Darwin.
Message-id: [email protected]
--- configure | 4 ++++ 1 file changed, 4 insertions(+)
configure +4 -0
@@ -6282,6 +6282,7 @@ echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross echo "[binaries]" >> $cross echo "c = [$(meson_quote $cc)]" >> $cross test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross +test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross echo "ar = [$(meson_quote $ar)]" >> $cross echo "nm = [$(meson_quote $nm)]" >> $cross echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
@@ -6300,6 +6301,9 @@ if test "$cross_compile" = "yes"; then if test "$linux" = "yes" ; then echo "system = 'linux'" >> $cross fi + if test "$darwin" = "yes" ; then + echo "system = 'darwin'" >> $cross + fi case "$ARCH" in i386|x86_64) echo "cpu_family = 'x86'" >> $cross
Signature · 1 line
2.20.1
[PULL 14/46] configure: cross compile should use x86_64 cpu_family
In reply to Peter MaydellFrom: Joelle van Dyne <[email protected]>
Message-id: [email protected]
--- configure | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
configure +4 -1
@@ -6305,9 +6305,12 @@ if test "$cross_compile" = "yes"; then echo "system = 'darwin'" >> $cross fi case "$ARCH" in - i386|x86_64) + i386) echo "cpu_family = 'x86'" >> $cross ;; + x86_64) + echo "cpu_family = 'x86_64'" >> $cross + ;; ppc64le) echo "cpu_family = 'ppc64'" >> $cross ;;
Signature · 1 line
2.20.1
[PULL 16/46] darwin: remove 64-bit build detection on 32-bit OS
In reply to Peter MaydellFrom: Joelle van Dyne <[email protected]>
A workaround added in early days of 64-bit OSX forced x86_64 if the host machine had 64-bit support. This creates issues when cross- compiling for ARM64. Additionally, the user can always use --cpu=* to manually set the host CPU and therefore this workaround should be removed.
Message-id: [email protected]
--- configure | 11 ----------- 1 file changed, 11 deletions(-)
configure +0 -11
@@ -625,13 +625,6 @@ fi # the correct CPU with the --cpu option. case $targetos in Darwin) - # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can - # run 64-bit userspace code. - # If the user didn't specify a CPU explicitly and the kernel says this is - # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code. - if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then - cpu="x86_64" - fi HOST_DSOSUF=".dylib" ;; SunOS)
@@ -775,10 +768,6 @@ OpenBSD) Darwin) bsd="yes" darwin="yes" - if [ "$cpu" = "x86_64" ] ; then - QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS" - QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS" - fi audio_drv_list="try-coreaudio try-sdl" audio_possible_drivers="coreaudio sdl" # Disable attempts to use ObjectiveC features in os/object.h since they
Signature · 1 line
2.20.1
[PULL 07/46] hw/misc: Fix arith overflow in NPCM7XX PWM module
In reply to Peter MaydellFrom: Hao Wu <[email protected]>
Fix potential overflow problem when calculating pwm_duty.
1. Ensure p->cmr and p->cnr to be from [0,65535], according to the hardware specification.
2. Changed duty to uint32_t. However, since MAX_DUTY * (p->cmr+1) can excceed UINT32_MAX, we convert them to uint64_t in computation and converted them back to uint32_t.
(duty is guaranteed to be <= MAX_DUTY so it won't overflow.)
Message-id: [email protected]
--- hw/misc/npcm7xx_pwm.c | 23 +++++++++++++++++++---- tests/qtest/npcm7xx_pwm-test.c | 4 ++-- 2 files changed, 21 insertions(+), 6 deletions(-)
hw/misc/npcm7xx_pwm.c +19 -4
@@ -58,6 +58,9 @@ REG32(NPCM7XX_PWM_PWDR3, 0x50);#define NPCM7XX_CH_INV BIT(2)#define NPCM7XX_CH_MOD BIT(3) +#define NPCM7XX_MAX_CMR 65535 +#define NPCM7XX_MAX_CNR 65535 +/* Offset of each PWM channel's prescaler in the PPR register. */ static const int npcm7xx_ppr_base[] = {0 ,0 ,8 ,8 };/* Offset of each PWM channel's clock selector in the CSR register. */
@@ -96,7 +99,7 @@ static uint32_t npcm7xx_pwm_calculate_freq(NPCM7xxPWM *p)static uint32_t npcm7xx_pwm_calculate_duty (NPCM7xxPWM *p) { -uint64_t duty; +uint32_t duty;if (p->running) {if (p->cnr ==0 ) {
@@ -104,7 +107,7 @@ static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p) }else if (p->cmr >= p->cnr) { duty =NPCM7XX_PWM_MAX_DUTY ; }else { - duty =NPCM7XX_PWM_MAX_DUTY * (p->cmr +1 ) / (p->cnr +1 ); + duty = (uint64_t )NPCM7XX_PWM_MAX_DUTY * (p->cmr +1 ) / (p->cnr +1 ); } }else { duty =0 ;
@@ -357,7 +360,13 @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset,case A_NPCM7XX_PWM_CNR2 :case A_NPCM7XX_PWM_CNR3 : p = &s->pwm[npcm7xx_cnr_index (offset)]; - p->cnr = value; +if (value >NPCM7XX_MAX_CNR ) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: invalid cnr value: %u" , __func__, value); + p->cnr =NPCM7XX_MAX_CNR ; + }else { + p->cnr = value; + }npcm7xx_pwm_update_output (p);break ;
@@ -366,7 +375,13 @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset,case A_NPCM7XX_PWM_CMR2 :case A_NPCM7XX_PWM_CMR3 : p = &s->pwm[npcm7xx_cmr_index (offset)]; - p->cmr = value; +if (value >NPCM7XX_MAX_CMR ) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: invalid cmr value: %u" , __func__, value); + p->cmr =NPCM7XX_MAX_CMR ; + }else { + p->cmr = value; + }npcm7xx_pwm_update_output (p);break ;
tests/qtest/npcm7xx_pwm-test.c +2 -2
@@ -272,7 +272,7 @@ static uint64_t pwm_compute_freq(QTestState *qts, uint32_t ppr, uint32_t csr,static uint64_t pwm_compute_duty (uint32_t cnr,uint32_t cmr,bool inverted) { -uint64_t duty; +uint32_t duty;if (cnr ==0 ) {/* PWM is stopped. */
@@ -280,7 +280,7 @@ static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted) }else if (cmr >= cnr) { duty =MAX_DUTY ; }else { - duty =MAX_DUTY * (cmr +1 ) / (cnr +1 ); + duty = (uint64_t )MAX_DUTY * (cmr +1 ) / (cnr +1 ); }if (inverted) {
Signature · 1 line
2.20.1
[PULL 18/46] hw/misc/pvpanic: split-out generic and bus dependent code
In reply to Peter MaydellFrom: Mihai Carabas <[email protected]>
To ease the PCI device addition in next patches, split the code as follows:
- generic code (read/write/setup) is being kept in pvpanic.c
- ISA dependent code moved to pvpanic-isa.c
Also, rename:
- ISA_PVPANIC_DEVICE -> PVPANIC_ISA_DEVICE.
- TYPE_PVPANIC -> TYPE_PVPANIC_ISA.
- MemoryRegion io -> mr.
- pvpanic_ioport_* in pvpanic_*.
Update the build system with the new files and config structure.
--- include/hw/misc/pvpanic.h | 23 +++++++++- hw/misc/pvpanic-isa.c | 94 +++++++++++++++++++++++++++++++++++++++ hw/misc/pvpanic.c | 85 +++-------------------------------- hw/i386/Kconfig | 2 +- hw/misc/Kconfig | 6 ++- hw/misc/meson.build | 3 +- tests/qtest/meson.build | 2 +- 7 files changed, 130 insertions(+), 85 deletions(-) create mode 100644 hw/misc/pvpanic-isa.c
include/hw/misc/pvpanic.h +21 -2
@@ -17,13 +17,32 @@#include "qom/object.h" -#define TYPE_PVPANIC "pvpanic" +#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"#define PVPANIC_IOPORT_PROP "ioport" +/* The bit of supported pv event, TODO: include uapi header and remove this */ +#define PVPANIC_F_PANICKED 0 +#define PVPANIC_F_CRASHLOADED 1 + +/* The pv event value */ +#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) +#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) + +/* +* PVPanicState for any device type +*/ +typedef struct PVPanicState PVPanicState ; +struct PVPanicState { +MemoryRegion mr; +uint8_t events; +}; + +void pvpanic_setup_io (PVPanicState *s,DeviceState *dev,unsigned size); +static inline uint16_t pvpanic_port (void ) { -Object *o =object_resolve_path_type ("" ,TYPE_PVPANIC ,NULL ); +Object *o =object_resolve_path_type ("" ,TYPE_PVPANIC_ISA_DEVICE ,NULL );if (!o) {return 0 ; }
hw/misc/pvpanic-isa.c new file +94 -0
94 lines not on this page · raw message
hw/misc/pvpanic.c +6 -79
114 lines not on this page · raw message
hw/i386/Kconfig +1 -1
@@ -14,7 +14,7 @@ config PC imply ISA_DEBUG imply PARALLEL imply PCI_DEVICES - imply PVPANIC + imply PVPANIC_ISA imply QXL imply SEV imply SGA
hw/misc/Kconfig +5 -1
@@ -121,9 +121,13 @@ config IOTKIT_SYSCTL config IOTKIT_SYSINFO bool -config PVPANIC +config PVPANIC_COMMON + bool + +config PVPANIC_ISA bool depends on ISA_BUS + select PVPANIC_COMMON config AUX bool
hw/misc/meson.build +2 -1
@@ -13,6 +13,7 @@ softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c')) softmmu_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c')) softmmu_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c')) softmmu_ss.add(when: 'CONFIG_LED', if_true: files('led.c')) +softmmu_ss.add(when: 'CONFIG_PVPANIC_COMMON', if_true: files('pvpanic.c')) # ARM devices softmmu_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c'))
@@ -98,7 +99,7 @@ softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSINFO', if_true: files('iotkit-sysinfo.c') softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c')) softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c')) -softmmu_ss.add(when: 'CONFIG_PVPANIC', if_true: files('pvpanic.c')) +softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c')) softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
tests/qtest/meson.build +1 -1
@@ -33,7 +33,7 @@ qtests_i386 = \ (config_host.has_key('CONFIG_LINUX') and \ config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \ (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \ - (config_all_devices.has_key('CONFIG_PVPANIC') ? ['pvpanic-test'] : []) + \ + (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \ (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \ (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \ (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \
Signature · 1 line
2.20.1
[PULL 19/46] hw/misc/pvpanic: add PCI interface support
In reply to Peter MaydellFrom: Mihai Carabas <[email protected]>
Add PCI interface support for PVPANIC device. Create a new file pvpanic-pci.c where the PCI specific routines reside and update the build system with the new files and config structure.
--- docs/specs/pci-ids.txt | 1 + include/hw/misc/pvpanic.h | 1 + include/hw/pci/pci.h | 1 + hw/misc/pvpanic-pci.c | 94 +++++++++++++++++++++++++++++++++++++++ hw/misc/Kconfig | 6 +++ hw/misc/meson.build | 1 + 6 files changed, 104 insertions(+) create mode 100644 hw/misc/pvpanic-pci.c
docs/specs/pci-ids.txt +1 -0
@@ -64,6 +64,7 @@ PCI devices (other than virtio): 1b36:000d PCI xhci usb host adapter 1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c 1b36:0010 PCIe NVMe device (-device nvme) +1b36:0011 PCI PVPanic device (-device pvpanic-pci) All these devices are documented in docs/specs.
include/hw/misc/pvpanic.h +1 -0
@@ -18,6 +18,7 @@#include "qom/object.h" #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" +#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci"#define PVPANIC_IOPORT_PROP "ioport"
include/hw/pci/pci.h +1 -0
@@ -107,6 +107,7 @@ extern bool pci_available;#define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e#define PCI_DEVICE_ID_REDHAT_MDPY 0x000f#define PCI_DEVICE_ID_REDHAT_NVME 0x0010 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011#define PCI_DEVICE_ID_REDHAT_QXL 0x0100#define FMT_PCIBUS PRIx64
hw/misc/pvpanic-pci.c new file +94 -0
94 lines not on this page · raw message
hw/misc/Kconfig +6 -0
@@ -124,6 +124,12 @@ config IOTKIT_SYSINFO config PVPANIC_COMMON bool +config PVPANIC_PCI + bool + default y if PCI_DEVICES + depends on PCI + select PVPANIC_COMMON + config PVPANIC_ISA bool depends on ISA_BUS
hw/misc/meson.build +1 -0
@@ -100,6 +100,7 @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c')) softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c')) softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) +softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c')) softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c')) softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
Signature · 1 line
2.20.1
[PULL 17/46] hvf: Add hypervisor entitlement to output binaries
In reply to Peter MaydellFrom: Alexander Graf <[email protected]>
In macOS 11, QEMU only gets access to Hypervisor.framework if it has the respective entitlement. Add an entitlement template and automatically self sign and apply the entitlement in the build.
--- meson.build | 29 +++++++++++++++++++++++++---- accel/hvf/entitlements.plist | 8 ++++++++ scripts/entitlement.sh | 13 +++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 accel/hvf/entitlements.plist create mode 100755 scripts/entitlement.sh
meson.build +25 -4
@@ -2167,9 +2167,14 @@ foreach target : target_dirs }] endif foreach exe: execs - emulators += {exe['name']: - executable(exe['name'], exe['sources'], - install: true, + exe_name = exe['name'] + exe_sign = 'CONFIG_HVF' in config_target + if exe_sign + exe_name += '-unsigned' + endif + + emulator = executable(exe_name, exe['sources'], + install: not exe_sign, c_args: c_args, dependencies: arch_deps + deps + exe['dependencies'], objects: lib.extract_all_objects(recursive: true),
@@ -2177,7 +2182,23 @@ foreach target : target_dirs link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []), link_args: link_args, gui_app: exe['gui']) - } + + if exe_sign + emulators += {exe['name'] : custom_target(exe['name'], + install: true, + install_dir: get_option('bindir'), + depends: emulator, + output: exe['name'], + command: [ + meson.current_source_dir() / 'scripts/entitlement.sh', + meson.current_build_dir() / exe_name, + meson.current_build_dir() / exe['name'], + meson.current_source_dir() / 'accel/hvf/entitlements.plist' + ]) + } + else + emulators += {exe['name']: emulator} + endif if 'CONFIG_TRACE_SYSTEMTAP' in config_host foreach stp: [
accel/hvf/entitlements.plist new file +8 -0
@@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>com.apple.security.hypervisor</key> + <true/> +</dict> +</plist>
scripts/entitlement.sh new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh -e +# +# Helper script for the build process to apply entitlements + +SRC="$1" +DST="$2" +ENTITLEMENT="$3" + +trap 'rm "$DST.tmp"' exit +cp -af "$SRC" "$DST.tmp" +codesign --entitlements "$ENTITLEMENT" --force -s - "$DST.tmp" +mv "$DST.tmp" "$DST" +trap '' exit
Signature · 1 line
2.20.1
[PULL 04/46] hw: gpio: implement gpio-pwr driver for qemu reset/poweroff
In reply to Peter MaydellFrom: Maxim Uvarov <[email protected]>
Implement gpio-pwr driver to allow reboot and poweroff machine. This is simple driver with just 2 gpios lines. Current use case is to reboot and poweroff virt machine in secure mode. Secure pl066 gpio chip is needed for that.
--- hw/gpio/gpio_pwr.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ hw/gpio/Kconfig | 3 ++ hw/gpio/meson.build | 1 + 3 files changed, 74 insertions(+) create mode 100644 hw/gpio/gpio_pwr.c
hw/gpio/gpio_pwr.c new file +70 -0
@@ -0,0 +1,70 @@ +/* +* GPIO qemu power controller +* +* Copyright (c) 2020 Linaro Limited +* +* Author: Maxim Uvarov <[email protected]> +* +* Virtual gpio driver which can be used on top of pl061 +* to reboot and shutdown qemu virtual machine. One of use +* case is gpio driver for secure world application (ARM +* Trusted Firmware.). +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +/* +* QEMU interface: +* two named input GPIO lines: +* 'reset' : when asserted, trigger system reset +* 'shutdown' : when asserted, trigger system shutdown +*/ + +#include "qemu/osdep.h" +#include "hw/sysbus.h" +#include "sysemu/runstate.h" + +#define TYPE_GPIOPWR "gpio-pwr" +OBJECT_DECLARE_SIMPLE_TYPE(GPIO_PWR_State, GPIOPWR) + +struct GPIO_PWR_State { +SysBusDevice parent_obj; +}; + +static void gpio_pwr_reset (void *opaque,int n,int level) +{ +if (level) { +qemu_system_reset_request (SHUTDOWN_CAUSE_GUEST_RESET ); + } +} + +static void gpio_pwr_shutdown (void *opaque,int n,int level) +{ +if (level) { +qemu_system_reset_request (SHUTDOWN_CAUSE_GUEST_SHUTDOWN ); + } +} + +static void gpio_pwr_init (Object *obj) +{ +DeviceState *dev =DEVICE (obj); + +qdev_init_gpio_in_named (dev, gpio_pwr_reset,"reset" ,1 ); +qdev_init_gpio_in_named (dev, gpio_pwr_shutdown,"shutdown" ,1 ); +} + +static const TypeInfo gpio_pwr_info = { + .name =TYPE_GPIOPWR , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (GPIO_PWR_State), + .instance_init = gpio_pwr_init, +}; + +static void gpio_pwr_register_types (void ) +{ +type_register_static (&gpio_pwr_info); +} + +type_init (gpio_pwr_register_types)
hw/gpio/Kconfig +3 -0
@@ -8,5 +8,8 @@ config PL061 config GPIO_KEY bool +config GPIO_PWR + bool + config SIFIVE_GPIO bool
hw/gpio/meson.build +1 -0
@@ -1,5 +1,6 @@ softmmu_ss.add(when: 'CONFIG_E500', if_true: files('mpc8xxx.c')) softmmu_ss.add(when: 'CONFIG_GPIO_KEY', if_true: files('gpio_key.c')) +softmmu_ss.add(when: 'CONFIG_GPIO_PWR', if_true: files('gpio_pwr.c')) softmmu_ss.add(when: 'CONFIG_MAX7310', if_true: files('max7310.c')) softmmu_ss.add(when: 'CONFIG_PL061', if_true: files('pl061.c')) softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_gpio.c'))
Signature · 1 line
2.20.1
[PULL 26/46] tests: Add a simple test of the CMSDK APB dual timer
In reply to Peter MaydellAdd a simple test of the CMSDK dual timer, since we're about to do some refactoring of how it is clocked.
Message-id: [email protected]
Message-id: [email protected]
--- tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++++ MAINTAINERS | 1 + tests/qtest/meson.build | 1 + 3 files changed, 132 insertions(+) create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c
tests/qtest/cmsdk-apb-dualtimer-test.c new file +130 -0
@@ -0,0 +1,130 @@ +/* +* QTest testcase for the CMSDK APB dualtimer device +* +* Copyright (c) 2021 Linaro Limited +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +*/ + +#include "qemu/osdep.h" +#include "libqtest-single.h" + +/* IoTKit/ARMSSE dualtimer; driven at 25MHz in mps2-an385, so 40ns per tick */ +#define TIMER_BASE 0x40002000 + +#define TIMER1LOAD 0 +#define TIMER1VALUE 4 +#define TIMER1CONTROL 8 +#define TIMER1INTCLR 0xc +#define TIMER1RIS 0x10 +#define TIMER1MIS 0x14 +#define TIMER1BGLOAD 0x18 + +#define TIMER2LOAD 0x20 +#define TIMER2VALUE 0x24 +#define TIMER2CONTROL 0x28 +#define TIMER2INTCLR 0x2c +#define TIMER2RIS 0x30 +#define TIMER2MIS 0x34 +#define TIMER2BGLOAD 0x38 + +#define CTRL_ENABLE (1 << 7) +#define CTRL_PERIODIC (1 << 6) +#define CTRL_INTEN (1 << 5) +#define CTRL_PRESCALE_1 (0 << 2) +#define CTRL_PRESCALE_16 (1 << 2) +#define CTRL_PRESCALE_256 (2 << 2) +#define CTRL_32BIT (1 << 1) +#define CTRL_ONESHOT (1 << 0) + +static void test_dualtimer (void ) +{ +g_assert_true (readl (TIMER_BASE +TIMER1RIS ) ==0 ); + +/* Start timer: will fire after 40000 ns */ +writel (TIMER_BASE +TIMER1LOAD ,1000 ); +/* enable in free-running, wrapping, interrupt mode */ +writel (TIMER_BASE +TIMER1CONTROL ,CTRL_ENABLE |CTRL_INTEN ); + +/* Step to just past the 500th tick and check VALUE */ +clock_step (500 *40 +1 ); + g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0); + g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 500); + +/* Just past the 1000th tick: timer should have fired */ +clock_step (500 *40 ); + g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 1); + g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0); + +/* +* We are in free-running wrapping 16-bit mode, so on the following +* tick VALUE should have wrapped round to 0xffff. +*/ +clock_step (40 ); + g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0xffff); + +/* Check that any write to INTCLR clears interrupt */ +writel (TIMER_BASE +TIMER1INTCLR ,1 ); + g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0); + +/* Turn off the timer */ +writel (TIMER_BASE +TIMER1CONTROL ,0 ); +} + +static void test_prescale (void ) +{ +g_assert_true (readl (TIMER_BASE +TIMER2RIS ) ==0 ); + +/* Start timer: will fire after 40 * 256 * 1000 == 1024000 ns */ +writel (TIMER_BASE +TIMER2LOAD ,1000 ); +/* enable in periodic, wrapping, interrupt mode, prescale 256 */ +writel (TIMER_BASE +TIMER2CONTROL , +CTRL_ENABLE |CTRL_INTEN |CTRL_PERIODIC |CTRL_PRESCALE_256 ); + +/* Step to just past the 500th tick and check VALUE */ +clock_step (40 *256 *501 ); + g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0); + g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 500); + +/* Just past the 1000th tick: timer should have fired */ +clock_step (40 *256 *500 ); + g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 1); + g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 0); + +/* In periodic mode the tick VALUE now reloads */ +clock_step (40 *256 ); + g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 1000); + +/* Check that any write to INTCLR clears interrupt */ +writel (TIMER_BASE +TIMER2INTCLR ,1 ); + g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0); + +/* Turn off the timer */ +writel (TIMER_BASE +TIMER2CONTROL ,0 ); +} + +int main (int argc,char **argv) +{ +int r; + +g_test_init (&argc, &argv,NULL ); + +qtest_start ("-machine mps2-an385" ); + +qtest_add_func ("/cmsdk-apb-dualtimer/dualtimer" , test_dualtimer); +qtest_add_func ("/cmsdk-apb-dualtimer/prescale" , test_prescale); + + r =g_test_run (); + +qtest_end (); + +return r; +}
MAINTAINERS +1 -0
@@ -584,6 +584,7 @@ F: include/hw/timer/cmsdk-apb-timer.h F: tests/qtest/cmsdk-apb-timer-test.c F: hw/timer/cmsdk-apb-dualtimer.c F: include/hw/timer/cmsdk-apb-dualtimer.h +F: tests/qtest/cmsdk-apb-dualtimer-test.c F: hw/char/cmsdk-apb-uart.c F: include/hw/char/cmsdk-apb-uart.h F: hw/watchdog/cmsdk-apb-watchdog.c
tests/qtest/meson.build +1 -0
@@ -142,6 +142,7 @@ qtests_npcm7xx = \ 'npcm7xx_timer-test', 'npcm7xx_watchdog_timer-test'] qtests_arm = \ + (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \ (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \ (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
Signature · 1 line
2.20.1
[PULL 15/46] darwin: detect CoreAudio for build
In reply to Peter MaydellFrom: Joelle van Dyne <[email protected]>
On iOS there is no CoreAudio, so we should not assume Darwin always has it.
Message-id: [email protected]
--- configure | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
configure +33 -2
@@ -319,6 +319,7 @@ fdt="auto" netmap="no" sdl="auto" sdl_image="auto" +coreaudio="auto" virtiofsd="auto" virtfs="auto" libudev="auto"
@@ -778,7 +779,7 @@ Darwin) QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS" QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS" fi - audio_drv_list="coreaudio try-sdl" + audio_drv_list="try-coreaudio try-sdl" audio_possible_drivers="coreaudio sdl" # Disable attempts to use ObjectiveC features in os/object.h since they # won't work when we're compiling with gcc as a C compiler.
@@ -3146,6 +3147,24 @@ EOF fi fi +########################################## +# detect CoreAudio +if test "$coreaudio" != "no" ; then + coreaudio_libs="-framework CoreAudio" + cat > $TMPC << EOF +#include <CoreAudio/CoreAudio.h> +int main(void) +{ + return (int)AudioGetCurrentHostTime(); +} +EOF + if compile_prog "" "$coreaudio_libs" ; then + coreaudio=yes + else + coreaudio=no + fi +fi + ########################################## # Sound support libraries probe
@@ -3202,8 +3221,20 @@ for drv in $audio_drv_list; do fi ;; - coreaudio) + coreaudio | try-coreaudio) + if test "$coreaudio" = "no"; then + if test "$drv" = "try-coreaudio"; then + audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio//') + else + error_exit "$drv check failed" \ + "Make sure to have the $drv is available." + fi + else coreaudio_libs="-framework CoreAudio" + if test "$drv" = "try-coreaudio"; then + audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio/coreaudio/') + fi + fi ;; dsound)
Signature · 1 line
2.20.1
[PULL 24/46] tests: Add a simple test of the CMSDK APB timer
In reply to Peter MaydellAdd a simple test of the CMSDK APB timer, since we're about to do some refactoring of how it is clocked.
Message-id: [email protected]
Message-id: [email protected]
--- tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++++++++++++++++++ MAINTAINERS | 1 + tests/qtest/meson.build | 1 + 3 files changed, 77 insertions(+) create mode 100644 tests/qtest/cmsdk-apb-timer-test.c
tests/qtest/cmsdk-apb-timer-test.c new file +75 -0
@@ -0,0 +1,75 @@ +/* +* QTest testcase for the CMSDK APB timer device +* +* Copyright (c) 2021 Linaro Limited +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +*/ + +#include "qemu/osdep.h" +#include "libqtest-single.h" + +/* IoTKit/ARMSSE-200 timer0; driven at 25MHz in mps2-an385, so 40ns per tick */ +#define TIMER_BASE 0x40000000 + +#define CTRL 0 +#define VALUE 4 +#define RELOAD 8 +#define INTSTATUS 0xc + +static void test_timer (void ) +{ +g_assert_true (readl (TIMER_BASE +INTSTATUS ) ==0 ); + +/* Start timer: will fire after 40 * 1000 == 40000 ns */ +writel (TIMER_BASE +RELOAD ,1000 ); +writel (TIMER_BASE +CTRL ,9 ); + +/* Step to just past the 500th tick and check VALUE */ +clock_step (40 *500 +1 ); + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0); + g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 500); + +/* Just past the 1000th tick: timer should have fired */ +clock_step (40 *500 ); + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1); + g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 0); + +/* VALUE reloads at the following tick */ +clock_step (40 ); + g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 1000); + +/* Check write-1-to-clear behaviour of INTSTATUS */ +writel (TIMER_BASE +INTSTATUS ,0 ); + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1); +writel (TIMER_BASE +INTSTATUS ,1 ); + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0); + +/* Turn off the timer */ +writel (TIMER_BASE +CTRL ,0 ); +} + +int main (int argc,char **argv) +{ +int r; + +g_test_init (&argc, &argv,NULL ); + +qtest_start ("-machine mps2-an385" ); + +qtest_add_func ("/cmsdk-apb-timer/timer" , test_timer); + + r =g_test_run (); + +qtest_end (); + +return r; +}
MAINTAINERS +1 -0
@@ -581,6 +581,7 @@ F: include/hw/rtc/pl031.h F: include/hw/arm/primecell.h F: hw/timer/cmsdk-apb-timer.c F: include/hw/timer/cmsdk-apb-timer.h +F: tests/qtest/cmsdk-apb-timer-test.c F: hw/timer/cmsdk-apb-dualtimer.c F: include/hw/timer/cmsdk-apb-dualtimer.h F: hw/char/cmsdk-apb-uart.c
tests/qtest/meson.build +1 -0
@@ -142,6 +142,7 @@ qtests_npcm7xx = \ 'npcm7xx_timer-test', 'npcm7xx_watchdog_timer-test'] qtests_arm = \ + (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ ['arm-cpu-features',
Signature · 1 line
2.20.1
[PULL 10/46] configure: cross-compiling with empty cross_prefix
In reply to Peter MaydellFrom: Joelle van Dyne <[email protected]>
The iOS toolchain does not use the host prefix naming convention. So we need to enable cross-compile options while allowing the PREFIX to be blank.
Message-id: [email protected]
--- configure | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
configure +4 -2
@@ -238,6 +238,7 @@ cpu="" iasl="iasl" interp_prefix="/usr/gnemul/qemu-%M" static="no" +cross_compile="no" cross_prefix="" audio_drv_list="" block_drv_rw_whitelist=""
@@ -469,6 +470,7 @@ for opt do optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') case "$opt" in --cross-prefix=*) cross_prefix="$optarg" + cross_compile="yes" ;; --cc=*) CC="$optarg" ;;
@@ -1691,7 +1693,7 @@ $(echo Deprecated targets: $deprecated_targets_list | \ --target-list-exclude=LIST exclude a set of targets from the default target-list Advanced options (experts only): - --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix] + --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] --cc=CC use C compiler CC [$cc] --iasl=IASL use ACPI compiler IASL [$iasl] --host-cc=CC use C compiler CC [$host_cc] for code run at
@@ -6290,7 +6292,7 @@ if has $sdl2_config; then fi echo "strip = [$(meson_quote $strip)]" >> $cross echo "windres = [$(meson_quote $windres)]" >> $cross -if test -n "$cross_prefix"; then +if test "$cross_compile" = "yes"; then cross_arg="--cross-file config-meson.cross" echo "[host_machine]" >> $cross if test "$mingw32" = "yes" ; then
Signature · 1 line
2.20.1
[PULL 31/46] hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ"
In reply to Peter MaydellWhile we transition the ARMSSE code from integer properties specifying clock frequencies to Clock objects, we want to have the device provide both at once. We want the final name of the main input Clock to be "MAINCLK", following the hardware name. Unfortunately creating an input Clock with a name X creates an under-the-hood QOM property X; for "MAINCLK" this clashes with the existing UINT32 property of that name.
Rename the UINT32 property to MAINCLK_FRQ so it can coexist with the MAINCLK Clock; once the transition is complete MAINCLK_FRQ will be deleted.
Commit created with:
perl -p -i -e 's/MAINCLK/MAINCLK_FRQ/g' hw/arm/{armsse,mps2-tz,musca}.c include/hw/arm/armsse.h
Message-id: [email protected]
Message-id: [email protected]
--- include/hw/arm/armsse.h | 2 +- hw/arm/armsse.c | 6 +++--- hw/arm/mps2-tz.c | 2 +- hw/arm/musca.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
include/hw/arm/armsse.h +1 -1
@@ -39,7 +39,7 @@* QEMU interface: * + QOM property "memory" is a MemoryRegion containing the devices provided * by the board model. -* + QOM property "MAINCLK" is the frequency of the main system clock +* + QOM property "MAINCLK_FRQ" is the frequency of the main system clock * + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts. * (In hardware, the SSE-200 permits the number of expansion interrupts * for the two CPUs to be configured separately, but we restrict it to
hw/arm/armsse.c +3 -3
@@ -47,7 +47,7 @@ static Property iotkit_properties[] = {DEFINE_PROP_LINK ("memory" ,ARMSSE , board_memory,TYPE_MEMORY_REGION , MemoryRegion *),DEFINE_PROP_UINT32 ("EXP_NUMIRQ" ,ARMSSE , exp_numirq,64 ), -DEFINE_PROP_UINT32 ("MAINCLK" ,ARMSSE , mainclk_frq,0 ), +DEFINE_PROP_UINT32 ("MAINCLK_FRQ" ,ARMSSE , mainclk_frq,0 ),DEFINE_PROP_UINT32 ("SRAM_ADDR_WIDTH" ,ARMSSE , sram_addr_width,15 ),DEFINE_PROP_UINT32 ("init-svtor" ,ARMSSE , init_svtor,0x10000000 ), DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
@@ -59,7 +59,7 @@ static Property armsse_properties[] = {DEFINE_PROP_LINK ("memory" ,ARMSSE , board_memory,TYPE_MEMORY_REGION , MemoryRegion *),DEFINE_PROP_UINT32 ("EXP_NUMIRQ" ,ARMSSE , exp_numirq,64 ), -DEFINE_PROP_UINT32 ("MAINCLK" ,ARMSSE , mainclk_frq,0 ), +DEFINE_PROP_UINT32 ("MAINCLK_FRQ" ,ARMSSE , mainclk_frq,0 ),DEFINE_PROP_UINT32 ("SRAM_ADDR_WIDTH" ,ARMSSE , sram_addr_width,15 ),DEFINE_PROP_UINT32 ("init-svtor" ,ARMSSE , init_svtor,0x10000000 ), DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false),
@@ -448,7 +448,7 @@ static void armsse_realize(DeviceState *dev, Error **errp) }if (!s->mainclk_frq) { -error_setg (errp,"MAINCLK property was not set" ); +error_setg (errp,"MAINCLK_FRQ property was not set" );return ; }
hw/arm/mps2-tz.c +1 -1
@@ -402,7 +402,7 @@ static void mps2tz_common_init(MachineState *machine)object_property_set_link (OBJECT (&mms->iotkit),"memory" ,OBJECT (system_memory), &error_abort);qdev_prop_set_uint32 (iotkitdev,"EXP_NUMIRQ" ,MPS2TZ_NUMIRQ ); -qdev_prop_set_uint32 (iotkitdev,"MAINCLK" ,SYSCLK_FRQ ); +qdev_prop_set_uint32 (iotkitdev,"MAINCLK_FRQ" ,SYSCLK_FRQ );sysbus_realize (SYS_BUS_DEVICE (&mms->iotkit), &error_fatal);/*
hw/arm/musca.c +1 -1
@@ -375,7 +375,7 @@ static void musca_init(MachineState *machine)qdev_prop_set_uint32 (ssedev,"EXP_NUMIRQ" , mmc->num_irqs);qdev_prop_set_uint32 (ssedev,"init-svtor" , mmc->init_svtor);qdev_prop_set_uint32 (ssedev,"SRAM_ADDR_WIDTH" , mmc->sram_addr_width); -qdev_prop_set_uint32 (ssedev,"MAINCLK" ,SYSCLK_FRQ ); +qdev_prop_set_uint32 (ssedev,"MAINCLK_FRQ" ,SYSCLK_FRQ );/* * Musca-A takes the default SSE-200 FPU/DSP settings (ie no for * CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0.
Signature · 1 line
2.20.1
[PULL 22/46] ptimer: Add new ptimer_set_period_from_clock() function
In reply to Peter MaydellThe ptimer API currently provides two methods for setting the period:ptimer_set_period(), which takes a period in nanoseconds, and ptimer_set_freq(), which takes a frequency in Hz. Neither of these lines up nicely with the Clock API, because although both the Clock and the ptimer track the frequency using a representation of whole and fractional nanoseconds, conversion via either period-in-ns or frequency-in-Hz will introduce a rounding error.
Add a new function ptimer_set_period_from_clock() which takes the Clock object directly to avoid the rounding issues. This includes a facility for the user to specify that there is a frequency divider between the Clock proper and the timer, as some timer devices like the CMSDK APB dualtimer need this.
To avoid having to drag in clock.h from ptimer.h we add the Clock type to typedefs.h.
Message-id: [email protected]
Message-id: [email protected]
--- include/hw/ptimer.h | 22 ++++++++++++++++++++++ include/qemu/typedefs.h | 1 + hw/core/ptimer.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+)
include/hw/ptimer.h +22 -0
@@ -165,6 +165,28 @@ void ptimer_transaction_commit(ptimer_state *s);*/ void ptimer_set_period (ptimer_state *s,int64_t period); +/** +* ptimer_set_period_from_clock - Set counter increment from a Clock +* @s: ptimer to configure +* @clk: pointer to Clock object to take period from +* @divisor: value to scale the clock frequency down by +* +* If the ptimer is being driven from a Clock, this is the preferred +* way to tell the ptimer about the period, because it avoids any +* possible rounding errors that might happen if the internal +* representation of the Clock period was converted to either a period +* in ns or a frequency in Hz. +* +* If the ptimer should run at the same frequency as the clock, +* pass 1 as the @divisor; if the ptimer should run at half the +* frequency, pass 2, and so on. +* +* This function will assert if it is called outside a +* ptimer_transaction_begin/commit block. +*/ +void ptimer_set_period_from_clock (ptimer_state *s,const Clock *clock, +unsigned int divisor); +/** * ptimer_set_freq - Set counter frequency in Hz * @s: ptimer to configure
include/qemu/typedefs.h +1 -0
@@ -34,6 +34,7 @@ typedef struct BlockDriverState BlockDriverState;typedef struct BusClass BusClass ;typedef struct BusState BusState ;typedef struct Chardev Chardev ; +typedef struct Clock Clock ;typedef struct CompatProperty CompatProperty ;typedef struct CoMutex CoMutex ;typedef struct CPUAddressSpace CPUAddressSpace ;
hw/core/ptimer.c +34 -0
@@ -15,6 +15,7 @@#include "sysemu/qtest.h" #include "block/aio.h" #include "sysemu/cpus.h" +#include "hw/clock.h" #define DELTA_ADJUST 1#define DELTA_NO_ADJUST -1
@@ -348,6 +349,39 @@ void ptimer_set_period(ptimer_state *s, int64_t period) } } +/* Set counter increment interval from a Clock */ +void ptimer_set_period_from_clock (ptimer_state *s,const Clock *clk, +unsigned int divisor) +{ +/* +* The raw clock period is a 64-bit value in units of 2^-32 ns; +* put another way it's a 32.32 fixed-point ns value. Our internal +* representation of the period is 64.32 fixed point ns, so +* the conversion is simple. +*/ +uint64_t raw_period =clock_get (clk); +uint64_t period_frac; + +assert (s->in_transaction); + s->delta =ptimer_get_count (s); + s->period =extract64 (raw_period,32 ,32 ); + period_frac =extract64 (raw_period,0 ,32 ); +/* +* divisor specifies a possible frequency divisor between the +* clock and the timer, so it is a multiplier on the period. +* We do the multiply after splitting the raw period out into +* period and frac to avoid having to do a 32*64->96 multiply. +*/ + s->period *= divisor; + period_frac *= divisor; + s->period +=extract64 (period_frac,32 ,32 ); + s->period_frac = (uint32_t )period_frac; + +if (s->enabled) { + s->need_reload = true; + } +} +/* Set counter frequency in Hz. */ void ptimer_set_freq (ptimer_state *s,uint32_t freq) {
Signature · 1 line
2.20.1
[PULL 21/46] tests/qtest: add a test case for pvpanic-pci
In reply to Peter MaydellFrom: Mihai Carabas <[email protected]>
Add a test case for pvpanic-pci device. The scenario is the same as pvpanic ISA device, but is using the PCI bus.
--- tests/qtest/pvpanic-pci-test.c | 94 ++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 1 + 2 files changed, 95 insertions(+) create mode 100644 tests/qtest/pvpanic-pci-test.c
tests/qtest/pvpanic-pci-test.c new file +94 -0
@@ -0,0 +1,94 @@ +/* +* QTest testcase for PV Panic PCI device +* +* Copyright (C) 2020 Oracle +* +* Authors: +* Mihai Carabas <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "libqos/libqtest.h" +#include "qapi/qmp/qdict.h" +#include "libqos/pci.h" +#include "libqos/pci-pc.h" +#include "hw/pci/pci_regs.h" + +static void test_panic_nopause (void ) +{ +uint8_t val; +QDict *response, *data; +QTestState *qts; +QPCIBus *pcibus; +QPCIDevice *dev; +QPCIBar bar; + + qts =qtest_init ("-device pvpanic-pci,addr=04.0 -action panic=none" ); + pcibus =qpci_new_pc (qts,NULL ); + dev =qpci_device_find (pcibus,QPCI_DEVFN (0x4 ,0x0 )); +qpci_device_enable (dev); + bar =qpci_iomap (dev,0 ,NULL ); + +qpci_memread (dev, bar,0 , &val,sizeof (val)); + g_assert_cmpuint(val, ==, 3); + + val =1 ; +qpci_memwrite (dev, bar,0 , &val,sizeof (val)); + + response =qtest_qmp_eventwait_ref (qts,"GUEST_PANICKED" ); +g_assert (qdict_haskey (response,"data" )); + data =qdict_get_qdict (response,"data" ); +g_assert (qdict_haskey (data,"action" )); + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "run"); +qobject_unref (response); + +qtest_quit (qts); +} + +static void test_panic (void ) +{ +uint8_t val; +QDict *response, *data; +QTestState *qts; +QPCIBus *pcibus; +QPCIDevice *dev; +QPCIBar bar; + + qts =qtest_init ("-device pvpanic-pci,addr=04.0 -action panic=pause" ); + pcibus =qpci_new_pc (qts,NULL ); + dev =qpci_device_find (pcibus,QPCI_DEVFN (0x4 ,0x0 )); +qpci_device_enable (dev); + bar =qpci_iomap (dev,0 ,NULL ); + +qpci_memread (dev, bar,0 , &val,sizeof (val)); + g_assert_cmpuint(val, ==, 3); + + val =1 ; +qpci_memwrite (dev, bar,0 , &val,sizeof (val)); + + response =qtest_qmp_eventwait_ref (qts,"GUEST_PANICKED" ); +g_assert (qdict_haskey (response,"data" )); + data =qdict_get_qdict (response,"data" ); +g_assert (qdict_haskey (data,"action" )); + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause"); +qobject_unref (response); + +qtest_quit (qts); +} + +int main (int argc,char **argv) +{ +int ret; + +g_test_init (&argc, &argv,NULL ); +qtest_add_func ("/pvpanic-pci/panic" , test_panic); +qtest_add_func ("/pvpanic-pci/panic-nopause" , test_panic_nopause); + + ret =g_test_run (); + +return ret; +}
tests/qtest/meson.build +1 -0
@@ -34,6 +34,7 @@ qtests_i386 = \ config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \ (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \ (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \ + (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) + \ (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \ (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \ (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \
Signature · 1 line
2.20.1
[PULL 23/46] clock: Add new clock_has_source() function
In reply to Peter MaydellAdd a function for checking whether a clock has a source. This is useful for devices which have input clocks that must be wired up by the board as it allows them to fail in realize rather than ploughing on with a zero-period clock.
Message-id: [email protected]
Message-id: [email protected]
--- docs/devel/clocks.rst | 16 ++++++++++++++++ include/hw/clock.h | 15 +++++++++++++++ 2 files changed, 31 insertions(+)
docs/devel/clocks.rst +16 -0
@@ -235,6 +235,22 @@ object during device instance init. For example: /* set initial value to 10ns / 100MHz */ clock_set_ns(clk, 10); +To enforce that the clock is wired up by the board code, you can +call ``clock_has_source()`` in your device's realize method: + +.. code-block:: c + + if (!clock_has_source(s->clk)) { + error_setg(errp, "MyDevice: clk input must be connected"); + return; + } + +Note that this only checks that the clock has been wired up; it is +still possible that the output clock connected to it is disabled +or has not yet been configured, in which case the period will be +zero. You should use the clock callback to find out when the clock +period changes. + Fetching clock frequency/period -------------------------------
include/hw/clock.h +15 -0
@@ -139,6 +139,21 @@ void clock_clear_callback(Clock *clk);*/ void clock_set_source (Clock *clk,Clock *src); +/** +* clock_has_source: +* @clk: the clock +* +* Returns true if the clock has a source clock connected to it. +* This is useful for devices which have input clocks which must +* be connected by the board/SoC code which creates them. The +* device code can use this to check in its realize method that +* the clock has been connected. +*/ +static inline bool clock_has_source (const Clock *clk) +{ +return clk->source !=NULL ; +} +/** * clock_set: * @clk: the clock to initialize.
Signature · 1 line
2.20.1
[PULL 25/46] tests: Add a simple test of the CMSDK APB watchdog
In reply to Peter MaydellAdd a simple test of the CMSDK watchdog, since we're about to do some refactoring of how it is clocked.
Message-id: [email protected]
Message-id: [email protected]
--- tests/qtest/cmsdk-apb-watchdog-test.c | 79 +++++++++++++++++++++++++++ MAINTAINERS | 1 + tests/qtest/meson.build | 1 + 3 files changed, 81 insertions(+) create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c
tests/qtest/cmsdk-apb-watchdog-test.c new file +79 -0
@@ -0,0 +1,79 @@ +/* +* QTest testcase for the CMSDK APB watchdog device +* +* Copyright (c) 2021 Linaro Limited +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +*/ + +#include "qemu/osdep.h" +#include "libqtest-single.h" + +/* +* lm3s811evb watchdog; at board startup this runs at 200MHz / 16 == 12.5MHz, +* which is 80ns per tick. +*/ +#define WDOG_BASE 0x40000000 + +#define WDOGLOAD 0 +#define WDOGVALUE 4 +#define WDOGCONTROL 8 +#define WDOGINTCLR 0xc +#define WDOGRIS 0x10 +#define WDOGMIS 0x14 +#define WDOGLOCK 0xc00 + +static void test_watchdog (void ) +{ + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); + +writel (WDOG_BASE +WDOGCONTROL ,1 ); +writel (WDOG_BASE +WDOGLOAD ,1000 ); + +/* Step to just past the 500th tick */ +clock_step (500 *80 +1 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); + +/* Just past the 1000th tick: timer should have fired */ +clock_step (500 *80 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0); + +/* VALUE reloads at following tick */ +clock_step (80 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); + +/* Writing any value to WDOGINTCLR clears the interrupt and reloads */ +clock_step (500 *80 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); +writel (WDOG_BASE +WDOGINTCLR ,0 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); +} + +int main (int argc,char **argv) +{ +int r; + +g_test_init (&argc, &argv,NULL ); + +qtest_start ("-machine lm3s811evb" ); + +qtest_add_func ("/cmsdk-apb-watchdog/watchdog" , test_watchdog); + + r =g_test_run (); + +qtest_end (); + +return r; +}
MAINTAINERS +1 -0
@@ -588,6 +588,7 @@ F: hw/char/cmsdk-apb-uart.c F: include/hw/char/cmsdk-apb-uart.h F: hw/watchdog/cmsdk-apb-watchdog.c F: include/hw/watchdog/cmsdk-apb-watchdog.h +F: tests/qtest/cmsdk-apb-watchdog-test.c F: hw/misc/tz-ppc.c F: include/hw/misc/tz-ppc.h F: hw/misc/tz-mpc.c
tests/qtest/meson.build +1 -0
@@ -143,6 +143,7 @@ qtests_npcm7xx = \ 'npcm7xx_watchdog_timer-test'] qtests_arm = \ (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ + (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \ (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ ['arm-cpu-features',
Signature · 1 line
2.20.1
[PULL 20/46] pvpanic : update pvpanic spec document
In reply to Peter MaydellFrom: Mihai Carabas <[email protected]>
Add pvpanic PCI device support details in docs/specs/pvpanic.txt.
--- docs/specs/pvpanic.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
docs/specs/pvpanic.txt +12 -1
@@ -1,7 +1,7 @@ PVPANIC DEVICE ============== -pvpanic device is a simulated ISA device, through which a guest panic +pvpanic device is a simulated device, through which a guest panic event is sent to qemu, and a QMP event is generated. This allows management apps (e.g. libvirt) to be notified and respond to the event.
@@ -9,6 +9,9 @@ The management app has the option of waiting for GUEST_PANICKED events, and/or polling for guest-panicked RunState, to learn when the pvpanic device has fired a panic event. +The pvpanic device can be implemented as an ISA device (using IOPORT) or as a +PCI device. + ISA Interface -------------
@@ -24,6 +27,14 @@ bit 1: a guest panic has happened and will be handled by the guest; the host should record it or report it, but should not affect the execution of the guest. +PCI Interface +------------- + +The PCI interface is similar to the ISA interface except that it uses an MMIO +address space provided by its BAR0, 1 byte long. Any machine with a PCI bus +can enable a pvpanic device by adding '-device pvpanic-pci' to the command +line. + ACPI Interface --------------
Signature · 1 line
2.20.1
[PULL 27/46] hw/timer/cmsdk-apb-timer: Rename CMSDKAPBTIMER struct to CMSDKAPBTimer
In reply to Peter MaydellThe state struct for the CMSDK APB timer device doesn't follow our usual naming convention of camelcase -- "CMSDK" and "APB" are both acronyms, but "TIMER" is not so should not be all-uppercase. Globally rename the struct to "CMSDKAPBTimer" (bringing it into line with CMSDKAPBWatchdog and CMSDKAPBDualTimer; CMSDKAPBUART remains as-is because "UART" is an acronym).
Commit created with:
perl -p -i -e 's/CMSDKAPBTIMER/CMSDKAPBTimer/g' hw/timer/cmsdk-apb-timer.c include/hw/arm/armsse.h include/hw/timer/cmsdk-apb-timer.h
Message-id: [email protected]
Message-id: [email protected]
--- include/hw/arm/armsse.h | 6 +++--- include/hw/timer/cmsdk-apb-timer.h | 4 ++-- hw/timer/cmsdk-apb-timer.c | 28 ++++++++++++++-------------- 3 files changed, 19 insertions(+), 19 deletions(-)
include/hw/arm/armsse.h +3 -3
@@ -153,9 +153,9 @@ struct ARMSSE {TZPPC apb_ppc0;TZPPC apb_ppc1;TZMPC mpc[IOTS_NUM_MPC ]; -CMSDKAPBTIMER timer0; -CMSDKAPBTIMER timer1; -CMSDKAPBTIMER s32ktimer; +CMSDKAPBTimer timer0; +CMSDKAPBTimer timer1; +CMSDKAPBTimer s32ktimer;qemu_or_irq ppc_irq_orgate;SplitIRQ sec_resp_splitter;SplitIRQ ppc_irq_splitter[NUM_PPCS ];
include/hw/timer/cmsdk-apb-timer.h +2 -2
@@ -18,9 +18,9 @@#include "qom/object.h" #define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer" -OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTIMER, CMSDK_APB_TIMER) +OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER) -struct CMSDKAPBTIMER { +struct CMSDKAPBTimer {/*< private >*/ SysBusDevice parent_obj;
hw/timer/cmsdk-apb-timer.c +14 -14
@@ -67,14 +67,14 @@ static const int timer_id[] = { 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */ }; -static void cmsdk_apb_timer_update (CMSDKAPBTIMER *s) +static void cmsdk_apb_timer_update (CMSDKAPBTimer *s) {qemu_set_irq (s->timerint, !!(s->intstatus &R_INTSTATUS_IRQ_MASK )); }static uint64_t cmsdk_apb_timer_read (void *opaque,hwaddr offset,unsigned size) { -CMSDKAPBTIMER *s =CMSDK_APB_TIMER (opaque); +CMSDKAPBTimer *s =CMSDK_APB_TIMER (opaque);uint64_t r;switch (offset) {
@@ -106,7 +106,7 @@ static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size)static void cmsdk_apb_timer_write (void *opaque,hwaddr offset,uint64_t value,unsigned size) { -CMSDKAPBTIMER *s =CMSDK_APB_TIMER (opaque); +CMSDKAPBTimer *s =CMSDK_APB_TIMER (opaque);trace_cmsdk_apb_timer_write (offset, value, size);
@@ -181,7 +181,7 @@ static const MemoryRegionOps cmsdk_apb_timer_ops = {static void cmsdk_apb_timer_tick (void *opaque) { -CMSDKAPBTIMER *s =CMSDK_APB_TIMER (opaque); +CMSDKAPBTimer *s =CMSDK_APB_TIMER (opaque);if (s->ctrl &R_CTRL_IRQEN_MASK ) { s->intstatus |=R_INTSTATUS_IRQ_MASK ;
@@ -191,7 +191,7 @@ static void cmsdk_apb_timer_tick(void *opaque)static void cmsdk_apb_timer_reset (DeviceState *dev) { -CMSDKAPBTIMER *s =CMSDK_APB_TIMER (dev); +CMSDKAPBTimer *s =CMSDK_APB_TIMER (dev);trace_cmsdk_apb_timer_reset (); s->ctrl =0 ;
@@ -206,7 +206,7 @@ static void cmsdk_apb_timer_reset(DeviceState *dev)static void cmsdk_apb_timer_init (Object *obj) {SysBusDevice *sbd =SYS_BUS_DEVICE (obj); -CMSDKAPBTIMER *s =CMSDK_APB_TIMER (obj); +CMSDKAPBTimer *s =CMSDK_APB_TIMER (obj);memory_region_init_io (&s->iomem, obj, &cmsdk_apb_timer_ops, s,"cmsdk-apb-timer" ,0x1000 );
@@ -216,7 +216,7 @@ static void cmsdk_apb_timer_init(Object *obj)static void cmsdk_apb_timer_realize (DeviceState *dev,Error **errp) { -CMSDKAPBTIMER *s =CMSDK_APB_TIMER (dev); +CMSDKAPBTimer *s =CMSDK_APB_TIMER (dev);if (s->pclk_frq ==0 ) {error_setg (errp,"CMSDK APB timer: pclk-frq property must be set" );
@@ -239,17 +239,17 @@ static const VMStateDescription cmsdk_apb_timer_vmstate = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField []) { -VMSTATE_PTIMER (timer,CMSDKAPBTIMER ), -VMSTATE_UINT32 (ctrl,CMSDKAPBTIMER ), -VMSTATE_UINT32 (value,CMSDKAPBTIMER ), -VMSTATE_UINT32 (reload,CMSDKAPBTIMER ), -VMSTATE_UINT32 (intstatus,CMSDKAPBTIMER ), +VMSTATE_PTIMER (timer, CMSDKAPBTimer), +VMSTATE_UINT32 (ctrl, CMSDKAPBTimer), +VMSTATE_UINT32 (value, CMSDKAPBTimer), +VMSTATE_UINT32 (reload, CMSDKAPBTimer), +VMSTATE_UINT32 (intstatus, CMSDKAPBTimer),VMSTATE_END_OF_LIST () } };static Property cmsdk_apb_timer_properties[] = { -DEFINE_PROP_UINT32 ("pclk-frq" ,CMSDKAPBTIMER , pclk_frq,0 ), +DEFINE_PROP_UINT32 ("pclk-frq" , CMSDKAPBTimer, pclk_frq,0 ),DEFINE_PROP_END_OF_LIST (), };
@@ -266,7 +266,7 @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data)static const TypeInfo cmsdk_apb_timer_info = { .name =TYPE_CMSDK_APB_TIMER , .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (CMSDKAPBTIMER ), + .instance_size =sizeof (CMSDKAPBTimer), .instance_init = cmsdk_apb_timer_init, .class_init = cmsdk_apb_timer_class_init, };
Signature · 1 line
2.20.1
[PULL 33/46] hw/arm/mps2: Inline CMSDK_APB_TIMER creation
In reply to Peter MaydellThe old-style convenience function cmsdk_apb_timer_create() for creating CMSDK_APB_TIMER objects is used in only two places in mps2.c. Most of the rest of the code in that file uses the new "initialize in place" coding style.
We want to connect up a Clock object which should be done between the object creation and realization; rather than adding a Clock* argument to the convenience function, convert the timer creation code in mps2.c to the same style as is used already for the watchdog, dualtimer and other devices, and delete the now-unused convenience function.
Message-id: [email protected]
Message-id: [email protected]
--- include/hw/timer/cmsdk-apb-timer.h | 21 --------------------- hw/arm/mps2.c | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 23 deletions(-)
include/hw/timer/cmsdk-apb-timer.h +0 -21
@@ -45,25 +45,4 @@ struct CMSDKAPBTimer { uint32_t intstatus; }; -/** -* cmsdk_apb_timer_create - convenience function to create TYPE_CMSDK_APB_TIMER -* @addr: location in system memory to map registers -* @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate) -*/ -static inline DeviceState *cmsdk_apb_timer_create (hwaddr addr, -qemu_irq timerint, -uint32_t pclk_frq) -{ -DeviceState *dev; -SysBusDevice *s; - - dev =qdev_new (TYPE_CMSDK_APB_TIMER ); - s =SYS_BUS_DEVICE (dev); -qdev_prop_set_uint32 (dev,"pclk-frq" , pclk_frq); -sysbus_realize_and_unref (s, &error_fatal); -sysbus_mmio_map (s,0 , addr); -sysbus_connect_irq (s,0 , timerint); -return dev; -} -#endif
hw/arm/mps2.c +16 -2
@@ -83,6 +83,7 @@ struct MPS2MachineState {/* CMSDK APB subsystem */ CMSDKAPBDualTimer dualtimer;CMSDKAPBWatchdog watchdog; +CMSDKAPBTimer timer[2 ]; };#define TYPE_MPS2_MACHINE "mps2"
@@ -330,8 +331,21 @@ static void mps2_common_init(MachineState *machine) }/* CMSDK APB subsystem */ -cmsdk_apb_timer_create (0x40000000 ,qdev_get_gpio_in (armv7m,8 ),SYSCLK_FRQ ); -cmsdk_apb_timer_create (0x40001000 ,qdev_get_gpio_in (armv7m,9 ),SYSCLK_FRQ ); +for (i =0 ; i <ARRAY_SIZE (mms->timer); i++) { + g_autofree char *name = g_strdup_printf("timer%d", i); +hwaddr base =0x40000000 + i *0x1000 ; +int irqno =8 + i; +SysBusDevice *sbd; + +object_initialize_child (OBJECT (mms), name, &mms->timer[i], +TYPE_CMSDK_APB_TIMER ); + sbd =SYS_BUS_DEVICE (&mms->timer[i]); +qdev_prop_set_uint32 (DEVICE (&mms->timer[i]),"pclk-frq" ,SYSCLK_FRQ ); +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_mmio_map (sbd,0 , base); +sysbus_connect_irq (sbd,0 ,qdev_get_gpio_in (armv7m, irqno)); + } +object_initialize_child (OBJECT (mms),"dualtimer" , &mms->dualtimer,TYPE_CMSDK_APB_DUALTIMER );qdev_prop_set_uint32 (DEVICE (&mms->dualtimer),"pclk-frq" ,SYSCLK_FRQ );
Signature · 1 line
2.20.1
[PULL 32/46] hw/arm/armsse: Wire up clocks
In reply to Peter MaydellCreate two input clocks on the ARMSSE devices, one for the normal MAINCLK, and one for the 32KHz S32KCLK, and wire these up to the appropriate devices. The old property-based clock frequency setting will remain in place until conversion is complete.
This is a migration compatibility break for machines mps2-an505, mps2-an521, musca-a, musca-b1.
Message-id: [email protected]
Message-id: [email protected]
--- include/hw/arm/armsse.h | 6 ++++++ hw/arm/armsse.c | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-)
include/hw/arm/armsse.h +6 -0
@@ -37,6 +37,8 @@* per-CPU identity and control register blocks * * QEMU interface: +* + Clock input "MAINCLK": clock for CPUs and most peripherals +* + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals * + QOM property "memory" is a MemoryRegion containing the devices provided * by the board model. * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock
@@ -103,6 +105,7 @@#include "hw/misc/armsse-mhu.h" #include "hw/misc/unimp.h" #include "hw/or-irq.h" +#include "hw/clock.h" #include "hw/core/split-irq.h" #include "hw/cpu/cluster.h" #include "qom/object.h"
@@ -209,6 +212,9 @@ struct ARMSSE {uint32_t nsccfg; +Clock *mainclk; +Clock *s32kclk; +/* Properties */ MemoryRegion *board_memory;uint32_t exp_numirq;
hw/arm/armsse.c +15 -2
@@ -21,6 +21,7 @@#include "hw/arm/armsse.h" #include "hw/arm/boot.h" #include "hw/irq.h" +#include "hw/qdev-clock.h" /* Format of the System Information block SYS_CONFIG register */ typedef enum SysConfigFormat {
@@ -241,6 +242,9 @@ static void armsse_init(Object *obj)assert (info->sram_banks <=MAX_SRAM_BANKS );assert (info->num_cpus <=SSE_MAX_CPUS ); + s->mainclk =qdev_init_clock_in (DEVICE (s),"MAINCLK" ,NULL ,NULL ); + s->s32kclk =qdev_init_clock_in (DEVICE (s),"S32KCLK" ,NULL ,NULL ); +memory_region_init (&s->container, obj,"armsse-container" ,UINT64_MAX );for (i =0 ; i < info->num_cpus; i++) {
@@ -711,6 +715,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)* map its upstream ends to the right place in the container. */ qdev_prop_set_uint32 (DEVICE (&s->timer0),"pclk-frq" , s->mainclk_frq); +qdev_connect_clock_in (DEVICE (&s->timer0),"pclk" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->timer0), errp)) {return ; }
@@ -721,6 +726,7 @@ static void armsse_realize(DeviceState *dev, Error **errp) &error_abort);qdev_prop_set_uint32 (DEVICE (&s->timer1),"pclk-frq" , s->mainclk_frq); +qdev_connect_clock_in (DEVICE (&s->timer1),"pclk" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->timer1), errp)) {return ; }
@@ -731,6 +737,7 @@ static void armsse_realize(DeviceState *dev, Error **errp) &error_abort);qdev_prop_set_uint32 (DEVICE (&s->dualtimer),"pclk-frq" , s->mainclk_frq); +qdev_connect_clock_in (DEVICE (&s->dualtimer),"TIMCLK" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->dualtimer), errp)) {return ; }
@@ -889,6 +896,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)* 0x4002f000: S32K timer */ qdev_prop_set_uint32 (DEVICE (&s->s32ktimer),"pclk-frq" ,S32KCLK ); +qdev_connect_clock_in (DEVICE (&s->s32ktimer),"pclk" , s->s32kclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->s32ktimer), errp)) {return ; }
@@ -982,6 +990,7 @@ static void armsse_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0));qdev_prop_set_uint32 (DEVICE (&s->s32kwatchdog),"wdogclk-frq" ,S32KCLK ); +qdev_connect_clock_in (DEVICE (&s->s32kwatchdog),"WDOGCLK" , s->s32kclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->s32kwatchdog), errp)) {return ; }
@@ -992,6 +1001,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)/* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */ qdev_prop_set_uint32 (DEVICE (&s->nswatchdog),"wdogclk-frq" , s->mainclk_frq); +qdev_connect_clock_in (DEVICE (&s->nswatchdog),"WDOGCLK" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->nswatchdog), errp)) {return ; }
@@ -1000,6 +1010,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->nswatchdog),0 ,0x40081000 );qdev_prop_set_uint32 (DEVICE (&s->swatchdog),"wdogclk-frq" , s->mainclk_frq); +qdev_connect_clock_in (DEVICE (&s->swatchdog),"WDOGCLK" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->swatchdog), errp)) {return ; }
@@ -1127,9 +1138,11 @@ static void armsse_idau_check(IDAUInterface *ii, uint32_t address,static const VMStateDescription armsse_vmstate = { .name ="iotkit" , - .version_id =1 , - .minimum_version_id =1 , + .version_id =2 , + .minimum_version_id =2 , .fields = (VMStateField []) { +VMSTATE_CLOCK (mainclk,ARMSSE ), +VMSTATE_CLOCK (s32kclk,ARMSSE ),VMSTATE_UINT32 (nsccfg,ARMSSE ),VMSTATE_END_OF_LIST () }
Signature · 1 line
2.20.1
[PULL 29/46] hw/timer/cmsdk-apb-dualtimer: Add Clock input
In reply to Peter MaydellAs the first step in converting the CMSDK_APB_DUALTIMER device to the Clock framework, add a Clock input. For the moment we do nothing with this clock; we will change the behaviour from using the pclk-frq property to using the Clock once all the users of this device have been converted to wire up the Clock.
We take the opportunity to correct the name of the clock input to match the hardware -- the dual timer names the clock which drives the timers TIMCLK. (It does also have a 'pclk' input, which is used only for the register and APB bus logic; on the SSE-200 these clocks are both connected together.)
This is a migration compatibility break for machines mps2-an385, mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a, musca-b1.
Message-id: [email protected]
Message-id: [email protected]
--- include/hw/timer/cmsdk-apb-dualtimer.h | 3 +++ hw/timer/cmsdk-apb-dualtimer.c | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
include/hw/timer/cmsdk-apb-dualtimer.h +3 -0
@@ -17,6 +17,7 @@* * QEMU interface: * + QOM property "pclk-frq": frequency at which the timer is clocked +* + Clock input "TIMCLK": clock (for both timers) * + sysbus MMIO region 0: the register bank * + sysbus IRQ 0: combined timer interrupt TIMINTC * + sysbus IRO 1: timer block 1 interrupt TIMINT1
@@ -28,6 +29,7 @@#include "hw/sysbus.h" #include "hw/ptimer.h" +#include "hw/clock.h" #include "qom/object.h" #define TYPE_CMSDK_APB_DUALTIMER "cmsdk-apb-dualtimer"
@@ -62,6 +64,7 @@ struct CMSDKAPBDualTimer {MemoryRegion iomem;qemu_irq timerintc;uint32_t pclk_frq; +Clock *timclk;CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES ];uint32_t timeritcr;
hw/timer/cmsdk-apb-dualtimer.c +5 -2
@@ -25,6 +25,7 @@#include "hw/irq.h" #include "hw/qdev-properties.h" #include "hw/registerfields.h" +#include "hw/qdev-clock.h" #include "hw/timer/cmsdk-apb-dualtimer.h" #include "migration/vmstate.h"
@@ -445,6 +446,7 @@ static void cmsdk_apb_dualtimer_init(Object *obj)for (i =0 ; i <ARRAY_SIZE (s->timermod); i++) {sysbus_init_irq (sbd, &s->timermod[i].timerint); } + s->timclk =qdev_init_clock_in (DEVICE (s),"TIMCLK" ,NULL ,NULL ); }static void cmsdk_apb_dualtimer_realize (DeviceState *dev,Error **errp)
@@ -485,9 +487,10 @@ static const VMStateDescription cmsdk_dualtimermod_vmstate = {static const VMStateDescription cmsdk_apb_dualtimer_vmstate = { .name ="cmsdk-apb-dualtimer" , - .version_id =1 , - .minimum_version_id =1 , + .version_id =2 , + .minimum_version_id =2 , .fields = (VMStateField []) { +VMSTATE_CLOCK (timclk, CMSDKAPBDualTimer), VMSTATE_STRUCT_ARRAY(timermod, CMSDKAPBDualTimer, CMSDK_APB_DUALTIMER_NUM_MODULES, 1, cmsdk_dualtimermod_vmstate,
Signature · 1 line
2.20.1
[PULL 34/46] hw/arm/mps2: Create and connect SYSCLK Clock
In reply to Peter MaydellCreate a fixed-frequency Clock object to be the SYSCLK, and wire it up to the devices that require it.
Message-id: [email protected]
Message-id: [email protected]
--- hw/arm/mps2.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/arm/mps2.c +9 -0
@@ -46,6 +46,7 @@#include "hw/net/lan9118.h" #include "net/net.h" #include "hw/watchdog/cmsdk-apb-watchdog.h" +#include "hw/qdev-clock.h" #include "qom/object.h" typedef enum MPS2FPGAType {
@@ -84,6 +85,7 @@ struct MPS2MachineState {CMSDKAPBDualTimer dualtimer;CMSDKAPBWatchdog watchdog;CMSDKAPBTimer timer[2 ]; +Clock *sysclk; };#define TYPE_MPS2_MACHINE "mps2"
@@ -140,6 +142,10 @@ static void mps2_common_init(MachineState *machine)exit (EXIT_FAILURE ); } +/* This clock doesn't need migration because it is fixed-frequency */ + mms->sysclk =clock_new (OBJECT (machine),"SYSCLK" ); +clock_set_hz (mms->sysclk,SYSCLK_FRQ ); +/* The FPGA images have an odd combination of different RAMs, * because in hardware they are different implementations and * connected to different buses, giving varying performance/size
@@ -341,6 +347,7 @@ static void mps2_common_init(MachineState *machine) TYPE_CMSDK_APB_TIMER); sbd =SYS_BUS_DEVICE (&mms->timer[i]);qdev_prop_set_uint32 (DEVICE (&mms->timer[i]),"pclk-frq" ,SYSCLK_FRQ ); +qdev_connect_clock_in (DEVICE (&mms->timer[i]),"pclk" , mms->sysclk);sysbus_realize_and_unref (sbd, &error_fatal);sysbus_mmio_map (sbd,0 , base);sysbus_connect_irq (sbd,0 ,qdev_get_gpio_in (armv7m, irqno));
@@ -349,6 +356,7 @@ static void mps2_common_init(MachineState *machine)object_initialize_child (OBJECT (mms),"dualtimer" , &mms->dualtimer,TYPE_CMSDK_APB_DUALTIMER );qdev_prop_set_uint32 (DEVICE (&mms->dualtimer),"pclk-frq" ,SYSCLK_FRQ ); +qdev_connect_clock_in (DEVICE (&mms->dualtimer),"TIMCLK" , mms->sysclk);sysbus_realize (SYS_BUS_DEVICE (&mms->dualtimer), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (&mms->dualtimer),0 ,qdev_get_gpio_in (armv7m,10 ));
@@ -356,6 +364,7 @@ static void mps2_common_init(MachineState *machine)object_initialize_child (OBJECT (mms),"watchdog" , &mms->watchdog,TYPE_CMSDK_APB_WATCHDOG );qdev_prop_set_uint32 (DEVICE (&mms->watchdog),"wdogclk-frq" ,SYSCLK_FRQ ); +qdev_connect_clock_in (DEVICE (&mms->watchdog),"WDOGCLK" , mms->sysclk);sysbus_realize (SYS_BUS_DEVICE (&mms->watchdog), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (&mms->watchdog),0 ,qdev_get_gpio_in_named (armv7m,"NMI" ,0 ));
Signature · 1 line
2.20.1
[PULL 30/46] hw/watchdog/cmsdk-apb-watchdog: Add Clock input
In reply to Peter MaydellAs the first step in converting the CMSDK_APB_TIMER device to the Clock framework, add a Clock input. For the moment we do nothing with this clock; we will change the behaviour from using the wdogclk-frq property to using the Clock once all the users of this device have been converted to wire up the Clock.
This is a migration compatibility break for machines mps2-an385, mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a, musca-b1, lm3s811evb, lm3s6965evb.
Message-id: [email protected]
Message-id: [email protected]
--- include/hw/watchdog/cmsdk-apb-watchdog.h | 3 +++ hw/watchdog/cmsdk-apb-watchdog.c | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
include/hw/watchdog/cmsdk-apb-watchdog.h +3 -0
@@ -17,6 +17,7 @@* * QEMU interface: * + QOM property "wdogclk-frq": frequency at which the watchdog is clocked +* + Clock input "WDOGCLK": clock for the watchdog's timer * + sysbus MMIO region 0: the register bank * + sysbus IRQ 0: watchdog interrupt *
@@ -33,6 +34,7 @@#include "hw/sysbus.h" #include "hw/ptimer.h" +#include "hw/clock.h" #include "qom/object.h" #define TYPE_CMSDK_APB_WATCHDOG "cmsdk-apb-watchdog"
@@ -54,6 +56,7 @@ struct CMSDKAPBWatchdog {uint32_t wdogclk_frq;bool is_luminary;struct ptimer_state *timer; +Clock *wdogclk;uint32_t control;uint32_t intstatus;
hw/watchdog/cmsdk-apb-watchdog.c +5 -2
@@ -30,6 +30,7 @@#include "hw/irq.h" #include "hw/qdev-properties.h" #include "hw/registerfields.h" +#include "hw/qdev-clock.h" #include "hw/watchdog/cmsdk-apb-watchdog.h" #include "migration/vmstate.h"
@@ -318,6 +319,7 @@ static void cmsdk_apb_watchdog_init(Object *obj) s, "cmsdk-apb-watchdog", 0x1000);sysbus_init_mmio (sbd, &s->iomem);sysbus_init_irq (sbd, &s->wdogint); + s->wdogclk =qdev_init_clock_in (DEVICE (s),"WDOGCLK" ,NULL ,NULL ); s->is_luminary = false; s->id = cmsdk_apb_watchdog_id;
@@ -346,9 +348,10 @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp)static const VMStateDescription cmsdk_apb_watchdog_vmstate = { .name ="cmsdk-apb-watchdog" , - .version_id =1 , - .minimum_version_id =1 , + .version_id =2 , + .minimum_version_id =2 , .fields = (VMStateField []) { +VMSTATE_CLOCK (wdogclk, CMSDKAPBWatchdog),VMSTATE_PTIMER (timer, CMSDKAPBWatchdog),VMSTATE_UINT32 (control, CMSDKAPBWatchdog),VMSTATE_UINT32 (intstatus, CMSDKAPBWatchdog),
Signature · 1 line
2.20.1
[PULL 28/46] hw/timer/cmsdk-apb-timer: Add Clock input
In reply to Peter MaydellAs the first step in converting the CMSDK_APB_TIMER device to the Clock framework, add a Clock input. For the moment we do nothing with this clock; we will change the behaviour from using the pclk-frq property to using the Clock once all the users of this device have been converted to wire up the Clock.
Since the device doesn't already have a doc comment for its "QEMU interface", we add one including the new Clock.
This is a migration compatibility break for machines mps2-an505, mps2-an521, musca-a, musca-b1.
Message-id: [email protected]
Message-id: [email protected]
--- include/hw/timer/cmsdk-apb-timer.h | 9 +++++++++ hw/timer/cmsdk-apb-timer.c | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-)
include/hw/timer/cmsdk-apb-timer.h +9 -0
@@ -15,11 +15,19 @@#include "hw/qdev-properties.h" #include "hw/sysbus.h" #include "hw/ptimer.h" +#include "hw/clock.h" #include "qom/object.h" #define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer"OBJECT_DECLARE_SIMPLE_TYPE (CMSDKAPBTimer,CMSDK_APB_TIMER ) +/* +* QEMU interface: +* + QOM property "pclk-frq": frequency at which the timer is clocked +* + Clock input "pclk": clock for the timer +* + sysbus MMIO region 0: the register bank +* + sysbus IRQ 0: timer interrupt TIMERINT + */struct CMSDKAPBTimer {/*< private >*/ SysBusDevice parent_obj;
@@ -29,6 +37,7 @@ struct CMSDKAPBTimer {qemu_irq timerint;uint32_t pclk_frq;struct ptimer_state *timer; +Clock *pclk;uint32_t ctrl;uint32_t value;
hw/timer/cmsdk-apb-timer.c +5 -2
@@ -35,6 +35,7 @@#include "hw/sysbus.h" #include "hw/irq.h" #include "hw/registerfields.h" +#include "hw/qdev-clock.h" #include "hw/timer/cmsdk-apb-timer.h" #include "migration/vmstate.h"
@@ -212,6 +213,7 @@ static void cmsdk_apb_timer_init(Object *obj) s, "cmsdk-apb-timer", 0x1000);sysbus_init_mmio (sbd, &s->iomem);sysbus_init_irq (sbd, &s->timerint); + s->pclk =qdev_init_clock_in (DEVICE (s),"pclk" ,NULL ,NULL ); }static void cmsdk_apb_timer_realize (DeviceState *dev,Error **errp)
@@ -236,10 +238,11 @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)static const VMStateDescription cmsdk_apb_timer_vmstate = { .name ="cmsdk-apb-timer" , - .version_id =1 , - .minimum_version_id =1 , + .version_id =2 , + .minimum_version_id =2 , .fields = (VMStateField []) {VMSTATE_PTIMER (timer, CMSDKAPBTimer), +VMSTATE_CLOCK (pclk, CMSDKAPBTimer),VMSTATE_UINT32 (ctrl, CMSDKAPBTimer),VMSTATE_UINT32 (value, CMSDKAPBTimer),VMSTATE_UINT32 (reload, CMSDKAPBTimer),
Signature · 1 line
2.20.1
[PULL 36/46] hw/arm/musca: Create and connect ARMSSE Clocks
In reply to Peter MaydellCreate and connect the two clocks needed by the ARMSSE.
Message-id: [email protected]
Message-id: [email protected]
--- hw/arm/musca.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
hw/arm/musca.c +12 -0
@@ -33,6 +33,7 @@#include "hw/misc/tz-ppc.h" #include "hw/misc/unimp.h" #include "hw/rtc/pl031.h" +#include "hw/qdev-clock.h" #include "qom/object.h" #define MUSCA_NUMIRQ_MAX 96
@@ -82,6 +83,8 @@ struct MuscaMachineState {UnimplementedDeviceState sdio;UnimplementedDeviceState gpio;UnimplementedDeviceState cryptoisland; +Clock *sysclk; +Clock *s32kclk; };#define TYPE_MUSCA_MACHINE "musca"
@@ -96,6 +99,8 @@ OBJECT_DECLARE_TYPE(MuscaMachineState, MuscaMachineClass, MUSCA_MACHINE)* don't model that in our SSE-200 model yet. */ #define SYSCLK_FRQ 40000000 +/* Slow 32Khz S32KCLK frequency in Hz */ +#define S32KCLK_FRQ (32 * 1000)static qemu_irq get_sse_irq_in (MuscaMachineState *mms,int irqno) {
@@ -367,6 +372,11 @@ static void musca_init(MachineState *machine)exit (1 ); } + mms->sysclk =clock_new (OBJECT (machine),"SYSCLK" ); +clock_set_hz (mms->sysclk,SYSCLK_FRQ ); + mms->s32kclk =clock_new (OBJECT (machine),"S32KCLK" ); +clock_set_hz (mms->s32kclk,S32KCLK_FRQ ); +object_initialize_child (OBJECT (machine),"sse-200" , &mms->sse,TYPE_SSE200 ); ssedev =DEVICE (&mms->sse);
@@ -376,6 +386,8 @@ static void musca_init(MachineState *machine)qdev_prop_set_uint32 (ssedev,"init-svtor" , mmc->init_svtor);qdev_prop_set_uint32 (ssedev,"SRAM_ADDR_WIDTH" , mmc->sram_addr_width);qdev_prop_set_uint32 (ssedev,"MAINCLK_FRQ" ,SYSCLK_FRQ ); +qdev_connect_clock_in (ssedev,"MAINCLK" , mms->sysclk); +qdev_connect_clock_in (ssedev,"S32KCLK" , mms->s32kclk);/* * Musca-A takes the default SSE-200 FPU/DSP settings (ie no for * CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0.
Signature · 1 line
2.20.1
[PULL 35/46] hw/arm/mps2-tz: Create and connect ARMSSE Clocks
In reply to Peter MaydellCreate and connect the two clocks needed by the ARMSSE.
Message-id: [email protected]
Message-id: [email protected]
--- hw/arm/mps2-tz.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
hw/arm/mps2-tz.c +13 -0
@@ -62,6 +62,7 @@#include "hw/net/lan9118.h" #include "net/net.h" #include "hw/core/split-irq.h" +#include "hw/qdev-clock.h" #include "qom/object.h" #define MPS2TZ_NUMIRQ 92
@@ -100,6 +101,8 @@ struct MPS2TZMachineState {qemu_or_irq uart_irq_orgate;DeviceState *lan9118;SplitIRQ cpu_irq_splitter[MPS2TZ_NUMIRQ ]; +Clock *sysclk; +Clock *s32kclk; };#define TYPE_MPS2TZ_MACHINE "mps2tz"
@@ -110,6 +113,8 @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE)/* Main SYSCLK frequency in Hz */ #define SYSCLK_FRQ 20000000 +/* Slow 32Khz S32KCLK frequency in Hz */ +#define S32KCLK_FRQ (32 * 1000)/* Create an alias of an entire original MemoryRegion @orig * located at @base in the memory map.
@@ -396,6 +401,12 @@ static void mps2tz_common_init(MachineState *machine)exit (EXIT_FAILURE ); } +/* These clocks don't need migration because they are fixed-frequency */ + mms->sysclk =clock_new (OBJECT (machine),"SYSCLK" ); +clock_set_hz (mms->sysclk,SYSCLK_FRQ ); + mms->s32kclk =clock_new (OBJECT (machine),"S32KCLK" ); +clock_set_hz (mms->s32kclk,S32KCLK_FRQ ); +object_initialize_child (OBJECT (machine),TYPE_IOTKIT , &mms->iotkit, mmc->armsse_type); iotkitdev =DEVICE (&mms->iotkit);
@@ -403,6 +414,8 @@ static void mps2tz_common_init(MachineState *machine) OBJECT(system_memory), &error_abort);qdev_prop_set_uint32 (iotkitdev,"EXP_NUMIRQ" ,MPS2TZ_NUMIRQ );qdev_prop_set_uint32 (iotkitdev,"MAINCLK_FRQ" ,SYSCLK_FRQ ); +qdev_connect_clock_in (iotkitdev,"MAINCLK" , mms->sysclk); +qdev_connect_clock_in (iotkitdev,"S32KCLK" , mms->s32kclk);sysbus_realize (SYS_BUS_DEVICE (&mms->iotkit), &error_fatal);/*
Signature · 1 line
2.20.1
[PULL 37/46] hw/arm/stellaris: Convert SSYS to QOM device
In reply to Peter MaydellConvert the SSYS code in the Stellaris boards (which encapsulates the system registers) to a proper QOM device. This will provide us with somewhere to put the output Clock whose frequency depends on the setting of the PLL configuration registers.
This is a migration compatibility break for lm3s811evb, lm3s6965evb.
We use 3-phase reset here because the Clock will need to propagate its value in the hold phase.
For the moment we reset the device during the board creation so that the system_clock_scale global gets set; this will be removed in a subsequent commit.
Message-id: [email protected]
Message-id: [email protected]
--- hw/arm/stellaris.c | 132 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 107 insertions(+), 25 deletions(-)
hw/arm/stellaris.c +107 -25
@@ -357,7 +357,12 @@ static void stellaris_gptm_realize(DeviceState *dev, Error **errp)/* System controller. */ -typedef struct { +#define TYPE_STELLARIS_SYS "stellaris-sys" +OBJECT_DECLARE_SIMPLE_TYPE(ssys_state, STELLARIS_SYS) + +struct ssys_state { +SysBusDevice parent_obj; +MemoryRegion iomem;uint32_t pborctl;uint32_t ldopctl;
@@ -371,11 +376,18 @@ typedef struct {uint32_t dcgc[3 ];uint32_t clkvclr;uint32_t ldoarst; +qemu_irq irq; +/* Properties (all read-only registers) */ uint32_t user0;uint32_t user1; -qemu_irq irq; -stellaris_board_info *board; -} ssys_state; +uint32_t did0; +uint32_t did1; +uint32_t dc0; +uint32_t dc1; +uint32_t dc2; +uint32_t dc3; +uint32_t dc4; +};static void ssys_update (ssys_state *s) {
@@ -430,7 +442,7 @@ static uint32_t pllcfg_fury[16] = {static int ssys_board_class (const ssys_state *s) { -uint32_t did0 = s->board->did0; +uint32_t did0 = s->did0;switch (did0 &DID0_VER_MASK ) {case DID0_VER_0 :return DID0_CLASS_SANDSTORM ;
@@ -456,19 +468,19 @@ static uint64_t ssys_read(void *opaque, hwaddr offset,switch (offset) {case 0x000 :/* DID0 */ -return s->board->did0; +return s->did0;case 0x004 :/* DID1 */ -return s->board->did1; +return s->did1;case 0x008 :/* DC0 */ -return s->board->dc0; +return s->dc0;case 0x010 :/* DC1 */ -return s->board->dc1; +return s->dc1;case 0x014 :/* DC2 */ -return s->board->dc2; +return s->dc2;case 0x018 :/* DC3 */ -return s->board->dc3; +return s->dc3;case 0x01c :/* DC4 */ -return s->board->dc4; +return s->dc4;case 0x030 :/* PBORCTL */ return s->pborctl;case 0x034 :/* LDOPCTL */
@@ -646,9 +658,9 @@ static const MemoryRegionOps ssys_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static void ssys_reset (void *opaque) +static void stellaris_sys_reset_enter (Object *obj,ResetType type) { -ssys_state *s = (ssys_state *)opaque; +ssys_state *s =STELLARIS_SYS (obj); s->pborctl =0x7ffd ; s->rcc =0x078e3ac0 ;
@@ -661,9 +673,19 @@ static void ssys_reset(void *opaque) s->rcgc[0 ] =1 ; s->scgc[0 ] =1 ; s->dcgc[0 ] =1 ; +} + +static void stellaris_sys_reset_hold (Object *obj) +{ +ssys_state *s =STELLARIS_SYS (obj); +ssys_calculate_system_clock (s); } +static void stellaris_sys_reset_exit (Object *obj) +{ +} +static int stellaris_sys_post_load (void *opaque,int version_id) {ssys_state *s = opaque;
@@ -695,27 +717,66 @@ static const VMStateDescription vmstate_stellaris_sys = { } }; +static Property stellaris_sys_properties[] = { +DEFINE_PROP_UINT32 ("user0" , ssys_state, user0,0 ), +DEFINE_PROP_UINT32 ("user1" , ssys_state, user1,0 ), +DEFINE_PROP_UINT32 ("did0" , ssys_state, did0,0 ), +DEFINE_PROP_UINT32 ("did1" , ssys_state, did1,0 ), +DEFINE_PROP_UINT32 ("dc0" , ssys_state, dc0,0 ), +DEFINE_PROP_UINT32 ("dc1" , ssys_state, dc1,0 ), +DEFINE_PROP_UINT32 ("dc2" , ssys_state, dc2,0 ), +DEFINE_PROP_UINT32 ("dc3" , ssys_state, dc3,0 ), +DEFINE_PROP_UINT32 ("dc4" , ssys_state, dc4,0 ), +DEFINE_PROP_END_OF_LIST () +}; + +static void stellaris_sys_instance_init (Object *obj) +{ +ssys_state *s =STELLARIS_SYS (obj); +SysBusDevice *sbd =SYS_BUS_DEVICE (s); + +memory_region_init_io (&s->iomem, obj, &ssys_ops, s,"ssys" ,0x00001000 ); +sysbus_init_mmio (sbd, &s->iomem); +sysbus_init_irq (sbd, &s->irq); +} +static int stellaris_sys_init (uint32_t base,qemu_irq irq,stellaris_board_info * board,uint8_t *macaddr) { -ssys_state *s; +DeviceState *dev =qdev_new (TYPE_STELLARIS_SYS ); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); - s =g_new0 (ssys_state,1 ); - s->irq = irq; - s->board = board;/* Most devices come preprogrammed with a MAC address in the user data. */ - s->user0 = macaddr[0 ] | (macaddr[1 ] <<8 ) | (macaddr[2 ] <<16 ); - s->user1 = macaddr[3 ] | (macaddr[4 ] <<8 ) | (macaddr[5 ] <<16 ); +qdev_prop_set_uint32 (dev,"user0" , + macaddr[0 ] | (macaddr[1 ] <<8 ) | (macaddr[2 ] <<16 )); +qdev_prop_set_uint32 (dev,"user1" , + macaddr[3 ] | (macaddr[4 ] <<8 ) | (macaddr[5 ] <<16 )); +qdev_prop_set_uint32 (dev,"did0" , board->did0); +qdev_prop_set_uint32 (dev,"did1" , board->did1); +qdev_prop_set_uint32 (dev,"dc0" , board->dc0); +qdev_prop_set_uint32 (dev,"dc1" , board->dc1); +qdev_prop_set_uint32 (dev,"dc2" , board->dc2); +qdev_prop_set_uint32 (dev,"dc3" , board->dc3); +qdev_prop_set_uint32 (dev,"dc4" , board->dc4); + +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_mmio_map (sbd,0 , base); +sysbus_connect_irq (sbd,0 , irq); + +/* +* Normally we should not be resetting devices like this during +* board creation. For the moment we need to do so, because +* system_clock_scale will only get set when the STELLARIS_SYS +* device is reset, and we need its initial value to pass to +* the watchdog device. This hack can be removed once the +* watchdog has been converted to use a Clock input instead. +*/ +device_cold_reset (dev); -memory_region_init_io (&s->iomem,NULL , &ssys_ops, s,"ssys" ,0x00001000 ); -memory_region_add_subregion (get_system_memory (), base, &s->iomem); -ssys_reset (s); -vmstate_register (NULL ,VMSTATE_INSTANCE_ID_ANY , &vmstate_stellaris_sys, s);return 0 ; } -/* I2C controller. */ #define TYPE_STELLARIS_I2C "stellaris-i2c"
@@ -1553,11 +1614,32 @@ static const TypeInfo stellaris_adc_info = { .class_init = stellaris_adc_class_init, }; +static void stellaris_sys_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ResettableClass *rc =RESETTABLE_CLASS (klass); + + dc->vmsd = &vmstate_stellaris_sys; + rc->phases.enter = stellaris_sys_reset_enter; + rc->phases.hold = stellaris_sys_reset_hold; + rc->phases.exit = stellaris_sys_reset_exit; +device_class_set_props (dc, stellaris_sys_properties); +} + +static const TypeInfo stellaris_sys_info = { + .name =TYPE_STELLARIS_SYS , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (ssys_state), + .instance_init = stellaris_sys_instance_init, + .class_init = stellaris_sys_class_init, +}; +static void stellaris_register_types (void ) {type_register_static (&stellaris_i2c_info);type_register_static (&stellaris_gptm_info);type_register_static (&stellaris_adc_info); +type_register_static (&stellaris_sys_info); }type_init (stellaris_register_types)
Signature · 1 line
2.20.1
[PULL 38/46] hw/arm/stellaris: Create Clock input for watchdog
In reply to Peter MaydellCreate and connect the Clock input for the watchdog device on the Stellaris boards. Because the Stellaris boards model the ability to change the clock rate by programming PLL registers, we have to create an output Clock on the ssys_state device and wire it up to the watchdog.
Note that the old comment on ssys_calculate_system_clock() got the units wrong -- system_clock_scale is in nanoseconds, not milliseconds. Improve the commentary to clarify how we are calculating the period.
Message-id: [email protected]
Message-id: [email protected]
--- hw/arm/stellaris.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-)
hw/arm/stellaris.c +31 -12
@@ -26,6 +26,7 @@#include "hw/watchdog/cmsdk-apb-watchdog.h" #include "migration/vmstate.h" #include "hw/misc/unimp.h" +#include "hw/qdev-clock.h" #include "cpu.h" #include "qom/object.h"
@@ -377,6 +378,7 @@ struct ssys_state {uint32_t clkvclr;uint32_t ldoarst;qemu_irq irq; +Clock *sysclk;/* Properties (all read-only registers) */ uint32_t user0;uint32_t user1;
@@ -555,15 +557,26 @@ static bool ssys_use_rcc2(ssys_state *s) }/* -* Caculate the sys. clock period in ms. +* Calculate the system clock period. We only want to propagate +* this change to the rest of the system if we're not being called +* from migration post-load. */ -static void ssys_calculate_system_clock (ssys_state *s) +static void ssys_calculate_system_clock (ssys_state *s,bool propagate_clock) { +/* +* SYSDIV field specifies divisor: 0 == /1, 1 == /2, etc. Input +* clock is 200MHz, which is a period of 5 ns. Dividing the clock +* frequency by X is the same as multiplying the period by X. +*/ if (ssys_use_rcc2 (s)) { system_clock_scale =5 * (((s->rcc2 >>23 ) &0x3f ) +1 ); }else { system_clock_scale =5 * (((s->rcc >>23 ) &0xf ) +1 ); } +clock_set_ns (s->sysclk, system_clock_scale); +if (propagate_clock) { +clock_propagate (s->sysclk); + } } static void ssys_write(void *opaque, hwaddr offset,
@@ -598,7 +611,7 @@ static void ssys_write(void *opaque, hwaddr offset, s->int_status |= (1 <<6 ); } s->rcc = value; -ssys_calculate_system_clock (s); +ssys_calculate_system_clock (s, true);break ;case 0x070 :/* RCC2 */ if (ssys_board_class (s) ==DID0_CLASS_SANDSTORM ) {
@@ -610,7 +623,7 @@ static void ssys_write(void *opaque, hwaddr offset, s->int_status |= (1 <<6 ); } s->rcc2 = value; -ssys_calculate_system_clock (s); +ssys_calculate_system_clock (s, true);break ;case 0x100 :/* RCGC0 */ s->rcgc[0 ] = value;
@@ -679,7 +692,8 @@ static void stellaris_sys_reset_hold(Object *obj) {ssys_state *s =STELLARIS_SYS (obj); -ssys_calculate_system_clock (s); +/* OK to propagate clocks from the hold phase */ +ssys_calculate_system_clock (s, true); }static void stellaris_sys_reset_exit (Object *obj)
@@ -690,7 +704,7 @@ static int stellaris_sys_post_load(void *opaque, int version_id) {ssys_state *s = opaque; -ssys_calculate_system_clock (s); +ssys_calculate_system_clock (s, false);return 0 ; }
@@ -713,6 +727,7 @@ static const VMStateDescription vmstate_stellaris_sys = {VMSTATE_UINT32_ARRAY (dcgc, ssys_state,3 ),VMSTATE_UINT32 (clkvclr, ssys_state),VMSTATE_UINT32 (ldoarst, ssys_state), +/* No field for sysclk -- handled in post-load instead */ VMSTATE_END_OF_LIST() } };
@@ -738,11 +753,12 @@ static void stellaris_sys_instance_init(Object *obj)memory_region_init_io (&s->iomem, obj, &ssys_ops, s,"ssys" ,0x00001000 );sysbus_init_mmio (sbd, &s->iomem);sysbus_init_irq (sbd, &s->irq); + s->sysclk =qdev_init_clock_out (DEVICE (s),"SYSCLK" ); } -static int stellaris_sys_init (uint32_t base,qemu_irq irq, -stellaris_board_info * board, -uint8_t *macaddr) +static DeviceState *stellaris_sys_init (uint32_t base,qemu_irq irq, +stellaris_board_info *board, +uint8_t *macaddr) {DeviceState *dev =qdev_new (TYPE_STELLARIS_SYS );SysBusDevice *sbd =SYS_BUS_DEVICE (dev);
@@ -774,7 +790,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq,*/ device_cold_reset (dev); -return 0 ; +return dev; }/* I2C controller. */
@@ -1341,6 +1357,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)int flash_size;I2CBus *i2c;DeviceState *dev; +DeviceState *ssys_dev;int i;int j;
@@ -1391,8 +1408,8 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) } } -stellaris_sys_init (0x400fe000 ,qdev_get_gpio_in (nvic,28 ), - board, nd_table[0 ].macaddr.a); + ssys_dev =stellaris_sys_init (0x400fe000 ,qdev_get_gpio_in (nvic,28 ), + board, nd_table[0 ].macaddr.a);if (board->dc1 & (1 <<3 )) {/* watchdog present */
@@ -1401,6 +1418,8 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)/* system_clock_scale is valid now */ uint32_t mainclk =NANOSECONDS_PER_SECOND / system_clock_scale;qdev_prop_set_uint32 (dev,"wdogclk-frq" , mainclk); +qdev_connect_clock_in (dev,"WDOGCLK" , +qdev_get_clock_out (ssys_dev,"SYSCLK" ));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev),
Signature · 1 line
2.20.1
[PULL 40/46] hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input
In reply to Peter MaydellSwitch the CMSDK APB dualtimer device over to using its Clock input; the pclk-frq property is now ignored.
Message-id: [email protected]
Message-id: [email protected]
--- hw/timer/cmsdk-apb-dualtimer.c | 42 ++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-)
hw/timer/cmsdk-apb-dualtimer.c +37 -5
@@ -106,6 +106,22 @@ static void cmsdk_apb_dualtimer_update(CMSDKAPBDualTimer *s)qemu_set_irq (s->timerintc, timintc); } +static int cmsdk_dualtimermod_divisor (CMSDKAPBDualTimerModule *m) +{ +/* Return the divisor set by the current CONTROL.PRESCALE value */ +switch (FIELD_EX32 (m->control,CONTROL ,PRESCALE )) { +case 0 : +return 1 ; +case 1 : +return 16 ; +case 2 : +case 3 :/* UNDEFINED, we treat like 2 (and complained when it was set) */ +return 256 ; +default : +g_assert_not_reached (); + } +} +static void cmsdk_dualtimermod_write_control (CMSDKAPBDualTimerModule *m,uint32_t newctrl) {
@@ -146,7 +162,7 @@ static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m,default :g_assert_not_reached (); } -ptimer_set_freq (m->timer, m->parent->pclk_frq / divisor); +ptimer_set_period_from_clock (m->timer, m->parent->timclk, divisor); }if (changed &R_CONTROL_MODE_MASK ) {
@@ -414,7 +430,8 @@ static void cmsdk_dualtimermod_reset(CMSDKAPBDualTimerModule *m)* limit must both be set to 0xffff, so we wrap at 16 bits. */ ptimer_set_limit (m->timer,0xffff ,1 ); -ptimer_set_freq (m->timer, m->parent->pclk_frq); +ptimer_set_period_from_clock (m->timer, m->parent->timclk, +cmsdk_dualtimermod_divisor (m));ptimer_transaction_commit (m->timer); }
@@ -432,6 +449,20 @@ static void cmsdk_apb_dualtimer_reset(DeviceState *dev) s->timeritop =0 ; } +static void cmsdk_apb_dualtimer_clk_update (void *opaque) +{ +CMSDKAPBDualTimer *s =CMSDK_APB_DUALTIMER (opaque); +int i; + +for (i =0 ; i <ARRAY_SIZE (s->timermod); i++) { +CMSDKAPBDualTimerModule *m = &s->timermod[i]; +ptimer_transaction_begin (m->timer); +ptimer_set_period_from_clock (m->timer, m->parent->timclk, +cmsdk_dualtimermod_divisor (m)); +ptimer_transaction_commit (m->timer); + } +} +static void cmsdk_apb_dualtimer_init (Object *obj) {SysBusDevice *sbd =SYS_BUS_DEVICE (obj);
@@ -446,7 +477,8 @@ static void cmsdk_apb_dualtimer_init(Object *obj)for (i =0 ; i <ARRAY_SIZE (s->timermod); i++) {sysbus_init_irq (sbd, &s->timermod[i].timerint); } - s->timclk =qdev_init_clock_in (DEVICE (s),"TIMCLK" ,NULL ,NULL ); + s->timclk =qdev_init_clock_in (DEVICE (s),"TIMCLK" , + cmsdk_apb_dualtimer_clk_update, s); }static void cmsdk_apb_dualtimer_realize (DeviceState *dev,Error **errp)
@@ -454,8 +486,8 @@ static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp)CMSDKAPBDualTimer *s =CMSDK_APB_DUALTIMER (dev);int i; -if (s->pclk_frq ==0 ) { -error_setg (errp,"CMSDK APB timer: pclk-frq property must be set" ); +if (!clock_has_source (s->timclk)) { +error_setg (errp,"CMSDK APB dualtimer: TIMCLK clock must be connected" );return ; }
Signature · 1 line
2.20.1
[PULL 41/46] hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input
In reply to Peter MaydellSwitch the CMSDK APB watchdog device over to using its Clock input; the wdogclk_frq property is now ignored.
Message-id: [email protected]
Message-id: [email protected]
--- hw/watchdog/cmsdk-apb-watchdog.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
hw/watchdog/cmsdk-apb-watchdog.c +14 -4
@@ -310,6 +310,15 @@ static void cmsdk_apb_watchdog_reset(DeviceState *dev)ptimer_transaction_commit (s->timer); } +static void cmsdk_apb_watchdog_clk_update (void *opaque) +{ +CMSDKAPBWatchdog *s =CMSDK_APB_WATCHDOG (opaque); + +ptimer_transaction_begin (s->timer); +ptimer_set_period_from_clock (s->timer, s->wdogclk,1 ); +ptimer_transaction_commit (s->timer); +} +static void cmsdk_apb_watchdog_init (Object *obj) {SysBusDevice *sbd =SYS_BUS_DEVICE (obj);
@@ -319,7 +328,8 @@ static void cmsdk_apb_watchdog_init(Object *obj) s, "cmsdk-apb-watchdog", 0x1000);sysbus_init_mmio (sbd, &s->iomem);sysbus_init_irq (sbd, &s->wdogint); - s->wdogclk =qdev_init_clock_in (DEVICE (s),"WDOGCLK" ,NULL ,NULL ); + s->wdogclk =qdev_init_clock_in (DEVICE (s),"WDOGCLK" , + cmsdk_apb_watchdog_clk_update, s); s->is_luminary = false; s->id = cmsdk_apb_watchdog_id;
@@ -329,9 +339,9 @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp) {CMSDKAPBWatchdog *s =CMSDK_APB_WATCHDOG (dev); -if (s->wdogclk_frq ==0 ) { +if (!clock_has_source (s->wdogclk)) {error_setg (errp, -"CMSDK APB watchdog: wdogclk-frq property must be set" ); +"CMSDK APB watchdog: WDOGCLK clock must be connected" );return ; }
@@ -342,7 +352,7 @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp) PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);ptimer_transaction_begin (s->timer); -ptimer_set_freq (s->timer, s->wdogclk_frq); +ptimer_set_period_from_clock (s->timer, s->wdogclk,1 );ptimer_transaction_commit (s->timer); }
Signature · 1 line
2.20.1
[PULL 39/46] hw/timer/cmsdk-apb-timer: Convert to use Clock input
In reply to Peter MaydellSwitch the CMSDK APB timer device over to using its Clock input; the pclk-frq property is now ignored.
Message-id: [email protected]
Message-id: [email protected]
--- hw/timer/cmsdk-apb-timer.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
hw/timer/cmsdk-apb-timer.c +14 -4
@@ -204,6 +204,15 @@ static void cmsdk_apb_timer_reset(DeviceState *dev)ptimer_transaction_commit (s->timer); } +static void cmsdk_apb_timer_clk_update (void *opaque) +{ +CMSDKAPBTimer *s =CMSDK_APB_TIMER (opaque); + +ptimer_transaction_begin (s->timer); +ptimer_set_period_from_clock (s->timer, s->pclk,1 ); +ptimer_transaction_commit (s->timer); +} +static void cmsdk_apb_timer_init (Object *obj) {SysBusDevice *sbd =SYS_BUS_DEVICE (obj);
@@ -213,15 +222,16 @@ static void cmsdk_apb_timer_init(Object *obj) s, "cmsdk-apb-timer", 0x1000);sysbus_init_mmio (sbd, &s->iomem);sysbus_init_irq (sbd, &s->timerint); - s->pclk =qdev_init_clock_in (DEVICE (s),"pclk" ,NULL ,NULL ); + s->pclk =qdev_init_clock_in (DEVICE (s),"pclk" , + cmsdk_apb_timer_clk_update, s); }static void cmsdk_apb_timer_realize (DeviceState *dev,Error **errp) {CMSDKAPBTimer *s =CMSDK_APB_TIMER (dev); -if (s->pclk_frq ==0 ) { -error_setg (errp,"CMSDK APB timer: pclk-frq property must be set" ); +if (!clock_has_source (s->pclk)) { +error_setg (errp,"CMSDK APB timer: pclk clock must be connected" );return ; }
@@ -232,7 +242,7 @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);ptimer_transaction_begin (s->timer); -ptimer_set_freq (s->timer, s->pclk_frq); +ptimer_set_period_from_clock (s->timer, s->pclk,1 );ptimer_transaction_commit (s->timer); }
Signature · 1 line
2.20.1
[PULL 42/46] tests/qtest/cmsdk-apb-watchdog-test: Test clock changes
In reply to Peter MaydellNow that the CMSDK APB watchdog uses its Clock input, it will correctly respond when the system clock frequency is changed using the RCC register on in the Stellaris board system registers. Test that when the RCC register is written it causes the watchdog timer to change speed.
Message-id: [email protected]
Message-id: [email protected]
--- tests/qtest/cmsdk-apb-watchdog-test.c | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
tests/qtest/cmsdk-apb-watchdog-test.c +52 -0
@@ -15,6 +15,7 @@*/ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "libqtest-single.h" /*
@@ -31,6 +32,11 @@#define WDOGMIS 0x14#define WDOGLOCK 0xc00 +#define SSYS_BASE 0x400fe000 +#define RCC 0x60 +#define SYSDIV_SHIFT 23 +#define SYSDIV_LENGTH 4 +static void test_watchdog (void ) { g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
@@ -61,6 +67,50 @@ static void test_watchdog(void) g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); } +static void test_clock_change (void ) +{ +uint32_t rcc; + +/* +* Test that writing to the stellaris board's RCC register to +* change the system clock frequency causes the watchdog +* to change the speed it counts at. +*/ + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); + +writel (WDOG_BASE +WDOGCONTROL ,1 ); +writel (WDOG_BASE +WDOGLOAD ,1000 ); + +/* Step to just past the 500th tick */ +clock_step (80 *500 +1 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); + +/* Rewrite RCC.SYSDIV from 16 to 8, so the clock is now 40ns per tick */ + rcc =readl (SSYS_BASE +RCC ); + g_assert_cmpuint(extract32(rcc, SYSDIV_SHIFT, SYSDIV_LENGTH), ==, 0xf); + rcc =deposit32 (rcc,SYSDIV_SHIFT ,SYSDIV_LENGTH ,7 ); +writel (SSYS_BASE +RCC , rcc); + +/* Just past the 1000th tick: timer should have fired */ +clock_step (40 *500 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); + + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0); + +/* VALUE reloads at following tick */ +clock_step (41 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); + +/* Writing any value to WDOGINTCLR clears the interrupt and reloads */ +clock_step (40 *500 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); +writel (WDOG_BASE +WDOGINTCLR ,0 ); + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); +} +int main (int argc,char **argv) {int r;
@@ -70,6 +120,8 @@ int main(int argc, char **argv)qtest_start ("-machine lm3s811evb" );qtest_add_func ("/cmsdk-apb-watchdog/watchdog" , test_watchdog); +qtest_add_func ("/cmsdk-apb-watchdog/watchdog_clock_change" , + test_clock_change); r =g_test_run ();
Signature · 1 line
2.20.1
[PULL 44/46] arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE
In reply to Peter MaydellRemove all the code that sets frequency properties on the CMSDK timer, dualtimer and watchdog devices and on the ARMSSE SoC device:
these properties are unused now that the devices rely on their Clock inputs instead.
Message-id: [email protected]
Message-id: [email protected]
--- hw/arm/armsse.c | 7 ------- hw/arm/mps2-tz.c | 1 - hw/arm/mps2.c | 3 --- hw/arm/musca.c | 1 - hw/arm/stellaris.c | 3 --- 5 files changed, 15 deletions(-)
hw/arm/armsse.c +0 -7
@@ -727,7 +727,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)* it to the appropriate PPC port; then we can realize the PPC and * map its upstream ends to the right place in the container. */ -qdev_prop_set_uint32 (DEVICE (&s->timer0),"pclk-frq" , s->mainclk_frq);qdev_connect_clock_in (DEVICE (&s->timer0),"pclk" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->timer0), errp)) {return ;
@@ -738,7 +737,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)object_property_set_link (OBJECT (&s->apb_ppc0),"port[0]" ,OBJECT (mr), &error_abort); -qdev_prop_set_uint32 (DEVICE (&s->timer1),"pclk-frq" , s->mainclk_frq);qdev_connect_clock_in (DEVICE (&s->timer1),"pclk" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->timer1), errp)) {return ;
@@ -749,7 +747,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)object_property_set_link (OBJECT (&s->apb_ppc0),"port[1]" ,OBJECT (mr), &error_abort); -qdev_prop_set_uint32 (DEVICE (&s->dualtimer),"pclk-frq" , s->mainclk_frq);qdev_connect_clock_in (DEVICE (&s->dualtimer),"TIMCLK" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->dualtimer), errp)) {return ;
@@ -908,7 +905,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)/* Devices behind APB PPC1: * 0x4002f000: S32K timer */ -qdev_prop_set_uint32 (DEVICE (&s->s32ktimer),"pclk-frq" ,S32KCLK );qdev_connect_clock_in (DEVICE (&s->s32ktimer),"pclk" , s->s32kclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->s32ktimer), errp)) {return ;
@@ -1002,7 +998,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)qdev_connect_gpio_out (DEVICE (&s->nmi_orgate),0 ,qdev_get_gpio_in_named (DEVICE (&s->armv7m),"NMI" ,0 )); -qdev_prop_set_uint32 (DEVICE (&s->s32kwatchdog),"wdogclk-frq" ,S32KCLK );qdev_connect_clock_in (DEVICE (&s->s32kwatchdog),"WDOGCLK" , s->s32kclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->s32kwatchdog), errp)) {return ;
@@ -1013,7 +1008,6 @@ static void armsse_realize(DeviceState *dev, Error **errp)/* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */ -qdev_prop_set_uint32 (DEVICE (&s->nswatchdog),"wdogclk-frq" , s->mainclk_frq);qdev_connect_clock_in (DEVICE (&s->nswatchdog),"WDOGCLK" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->nswatchdog), errp)) {return ;
@@ -1022,7 +1016,6 @@ static void armsse_realize(DeviceState *dev, Error **errp) armsse_get_common_irq_in(s, 1));sysbus_mmio_map (SYS_BUS_DEVICE (&s->nswatchdog),0 ,0x40081000 ); -qdev_prop_set_uint32 (DEVICE (&s->swatchdog),"wdogclk-frq" , s->mainclk_frq);qdev_connect_clock_in (DEVICE (&s->swatchdog),"WDOGCLK" , s->mainclk);if (!sysbus_realize (SYS_BUS_DEVICE (&s->swatchdog), errp)) {return ;
hw/arm/mps2-tz.c +0 -1
@@ -413,7 +413,6 @@ static void mps2tz_common_init(MachineState *machine)object_property_set_link (OBJECT (&mms->iotkit),"memory" ,OBJECT (system_memory), &error_abort);qdev_prop_set_uint32 (iotkitdev,"EXP_NUMIRQ" ,MPS2TZ_NUMIRQ ); -qdev_prop_set_uint32 (iotkitdev,"MAINCLK_FRQ" ,SYSCLK_FRQ );qdev_connect_clock_in (iotkitdev,"MAINCLK" , mms->sysclk);qdev_connect_clock_in (iotkitdev,"S32KCLK" , mms->s32kclk);sysbus_realize (SYS_BUS_DEVICE (&mms->iotkit), &error_fatal);
hw/arm/mps2.c +0 -3
@@ -346,7 +346,6 @@ static void mps2_common_init(MachineState *machine)object_initialize_child (OBJECT (mms), name, &mms->timer[i],TYPE_CMSDK_APB_TIMER ); sbd =SYS_BUS_DEVICE (&mms->timer[i]); -qdev_prop_set_uint32 (DEVICE (&mms->timer[i]),"pclk-frq" ,SYSCLK_FRQ );qdev_connect_clock_in (DEVICE (&mms->timer[i]),"pclk" , mms->sysclk);sysbus_realize_and_unref (sbd, &error_fatal);sysbus_mmio_map (sbd,0 , base);
@@ -355,7 +354,6 @@ static void mps2_common_init(MachineState *machine)object_initialize_child (OBJECT (mms),"dualtimer" , &mms->dualtimer,TYPE_CMSDK_APB_DUALTIMER ); -qdev_prop_set_uint32 (DEVICE (&mms->dualtimer),"pclk-frq" ,SYSCLK_FRQ );qdev_connect_clock_in (DEVICE (&mms->dualtimer),"TIMCLK" , mms->sysclk);sysbus_realize (SYS_BUS_DEVICE (&mms->dualtimer), &error_fatal); sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0,
@@ -363,7 +361,6 @@ static void mps2_common_init(MachineState *machine)sysbus_mmio_map (SYS_BUS_DEVICE (&mms->dualtimer),0 ,0x40002000 );object_initialize_child (OBJECT (mms),"watchdog" , &mms->watchdog,TYPE_CMSDK_APB_WATCHDOG ); -qdev_prop_set_uint32 (DEVICE (&mms->watchdog),"wdogclk-frq" ,SYSCLK_FRQ );qdev_connect_clock_in (DEVICE (&mms->watchdog),"WDOGCLK" , mms->sysclk);sysbus_realize (SYS_BUS_DEVICE (&mms->watchdog), &error_fatal); sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0,
hw/arm/musca.c +0 -1
@@ -385,7 +385,6 @@ static void musca_init(MachineState *machine)qdev_prop_set_uint32 (ssedev,"EXP_NUMIRQ" , mmc->num_irqs);qdev_prop_set_uint32 (ssedev,"init-svtor" , mmc->init_svtor);qdev_prop_set_uint32 (ssedev,"SRAM_ADDR_WIDTH" , mmc->sram_addr_width); -qdev_prop_set_uint32 (ssedev,"MAINCLK_FRQ" ,SYSCLK_FRQ );qdev_connect_clock_in (ssedev,"MAINCLK" , mms->sysclk);qdev_connect_clock_in (ssedev,"S32KCLK" , mms->s32kclk);/*
hw/arm/stellaris.c +0 -3
@@ -1415,9 +1415,6 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)if (board->dc1 & (1 <<3 )) {/* watchdog present */ dev =qdev_new (TYPE_LUMINARY_WATCHDOG ); -/* system_clock_scale is valid now */ -uint32_t mainclk =NANOSECONDS_PER_SECOND / system_clock_scale; -qdev_prop_set_uint32 (dev,"wdogclk-frq" , mainclk);qdev_connect_clock_in (dev,"WDOGCLK" ,qdev_get_clock_out (ssys_dev,"SYSCLK" ));
Signature · 1 line
2.20.1
[PULL 46/46] hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS
In reply to Peter MaydellNow that the watchdog device uses its Clock input rather than being passed the value of system_clock_scale at creation time, we can remove the hack where we reset the STELLARIS_SYS at board creation time to force it to set system_clock_scale. Instead it will be reset at the usual point in startup and will inform the watchdog of the clock frequency at that point.
Message-id: [email protected]
Message-id: [email protected]
--- hw/arm/stellaris.c | 10 ---------- 1 file changed, 10 deletions(-)
hw/arm/stellaris.c +0 -10
@@ -780,16 +780,6 @@ static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq,sysbus_mmio_map (sbd,0 , base);sysbus_connect_irq (sbd,0 , irq); -/* -* Normally we should not be resetting devices like this during -* board creation. For the moment we need to do so, because -* system_clock_scale will only get set when the STELLARIS_SYS -* device is reset, and we need its initial value to pass to -* the watchdog device. This hack can be removed once the -* watchdog has been converted to use a Clock input instead. -*/ -device_cold_reset (dev); -return dev; }
Signature · 1 line
2.20.1
[PULL 45/46] arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE
In reply to Peter MaydellNow no users are setting the frq properties on the CMSDK timer, dualtimer, watchdog or ARMSSE SoC devices, we can remove the properties and the struct fields that back them.
Message-id: [email protected]
Message-id: [email protected]
--- include/hw/arm/armsse.h | 2 -- include/hw/timer/cmsdk-apb-dualtimer.h | 2 -- include/hw/timer/cmsdk-apb-timer.h | 2 -- include/hw/watchdog/cmsdk-apb-watchdog.h | 2 -- hw/arm/armsse.c | 2 -- hw/timer/cmsdk-apb-dualtimer.c | 6 ------ hw/timer/cmsdk-apb-timer.c | 6 ------ hw/watchdog/cmsdk-apb-watchdog.c | 6 ------ 8 files changed, 28 deletions(-)
include/hw/arm/armsse.h +0 -2
@@ -41,7 +41,6 @@* + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals * + QOM property "memory" is a MemoryRegion containing the devices provided * by the board model. -* + QOM property "MAINCLK_FRQ" is the frequency of the main system clock * + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts. * (In hardware, the SSE-200 permits the number of expansion interrupts * for the two CPUs to be configured separately, but we restrict it to
@@ -218,7 +217,6 @@ struct ARMSSE {/* Properties */ MemoryRegion *board_memory;uint32_t exp_numirq; -uint32_t mainclk_frq;uint32_t sram_addr_width;uint32_t init_svtor;bool cpu_fpu[SSE_MAX_CPUS ];
include/hw/timer/cmsdk-apb-dualtimer.h +0 -2
@@ -16,7 +16,6 @@* https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit * * QEMU interface: -* + QOM property "pclk-frq": frequency at which the timer is clocked * + Clock input "TIMCLK": clock (for both timers) * + sysbus MMIO region 0: the register bank * + sysbus IRQ 0: combined timer interrupt TIMINTC
@@ -63,7 +62,6 @@ struct CMSDKAPBDualTimer {/*< public >*/ MemoryRegion iomem;qemu_irq timerintc; -uint32_t pclk_frq;Clock *timclk;CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES ];
include/hw/timer/cmsdk-apb-timer.h +0 -2
@@ -23,7 +23,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER)/* * QEMU interface: -* + QOM property "pclk-frq": frequency at which the timer is clocked * + Clock input "pclk": clock for the timer * + sysbus MMIO region 0: the register bank * + sysbus IRQ 0: timer interrupt TIMERINT
@@ -35,7 +34,6 @@ struct CMSDKAPBTimer {/*< public >*/ MemoryRegion iomem;qemu_irq timerint; -uint32_t pclk_frq;struct ptimer_state *timer;Clock *pclk;
include/hw/watchdog/cmsdk-apb-watchdog.h +0 -2
@@ -16,7 +16,6 @@* https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit * * QEMU interface: -* + QOM property "wdogclk-frq": frequency at which the watchdog is clocked * + Clock input "WDOGCLK": clock for the watchdog's timer * + sysbus MMIO region 0: the register bank * + sysbus IRQ 0: watchdog interrupt
@@ -53,7 +52,6 @@ struct CMSDKAPBWatchdog {/*< public >*/ MemoryRegion iomem;qemu_irq wdogint; -uint32_t wdogclk_frq;bool is_luminary;struct ptimer_state *timer;Clock *wdogclk;
hw/arm/armsse.c +0 -2
@@ -48,7 +48,6 @@ static Property iotkit_properties[] = {DEFINE_PROP_LINK ("memory" ,ARMSSE , board_memory,TYPE_MEMORY_REGION , MemoryRegion *),DEFINE_PROP_UINT32 ("EXP_NUMIRQ" ,ARMSSE , exp_numirq,64 ), -DEFINE_PROP_UINT32 ("MAINCLK_FRQ" ,ARMSSE , mainclk_frq,0 ),DEFINE_PROP_UINT32 ("SRAM_ADDR_WIDTH" ,ARMSSE , sram_addr_width,15 ),DEFINE_PROP_UINT32 ("init-svtor" ,ARMSSE , init_svtor,0x10000000 ), DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
@@ -60,7 +59,6 @@ static Property armsse_properties[] = {DEFINE_PROP_LINK ("memory" ,ARMSSE , board_memory,TYPE_MEMORY_REGION , MemoryRegion *),DEFINE_PROP_UINT32 ("EXP_NUMIRQ" ,ARMSSE , exp_numirq,64 ), -DEFINE_PROP_UINT32 ("MAINCLK_FRQ" ,ARMSSE , mainclk_frq,0 ),DEFINE_PROP_UINT32 ("SRAM_ADDR_WIDTH" ,ARMSSE , sram_addr_width,15 ),DEFINE_PROP_UINT32 ("init-svtor" ,ARMSSE , init_svtor,0x10000000 ), DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false),
hw/timer/cmsdk-apb-dualtimer.c +0 -6
@@ -533,11 +533,6 @@ static const VMStateDescription cmsdk_apb_dualtimer_vmstate = { } }; -static Property cmsdk_apb_dualtimer_properties[] = { -DEFINE_PROP_UINT32 ("pclk-frq" , CMSDKAPBDualTimer, pclk_frq,0 ), -DEFINE_PROP_END_OF_LIST (), -}; -static void cmsdk_apb_dualtimer_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -545,7 +540,6 @@ static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data) dc->realize = cmsdk_apb_dualtimer_realize; dc->vmsd = &cmsdk_apb_dualtimer_vmstate; dc->reset = cmsdk_apb_dualtimer_reset; -device_class_set_props (dc, cmsdk_apb_dualtimer_properties); }static const TypeInfo cmsdk_apb_dualtimer_info = {
hw/timer/cmsdk-apb-timer.c +0 -6
@@ -261,11 +261,6 @@ static const VMStateDescription cmsdk_apb_timer_vmstate = { } }; -static Property cmsdk_apb_timer_properties[] = { -DEFINE_PROP_UINT32 ("pclk-frq" , CMSDKAPBTimer, pclk_frq,0 ), -DEFINE_PROP_END_OF_LIST (), -}; -static void cmsdk_apb_timer_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -273,7 +268,6 @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data) dc->realize = cmsdk_apb_timer_realize; dc->vmsd = &cmsdk_apb_timer_vmstate; dc->reset = cmsdk_apb_timer_reset; -device_class_set_props (dc, cmsdk_apb_timer_properties); }static const TypeInfo cmsdk_apb_timer_info = {
hw/watchdog/cmsdk-apb-watchdog.c +0 -6
@@ -373,11 +373,6 @@ static const VMStateDescription cmsdk_apb_watchdog_vmstate = { } }; -static Property cmsdk_apb_watchdog_properties[] = { -DEFINE_PROP_UINT32 ("wdogclk-frq" , CMSDKAPBWatchdog, wdogclk_frq,0 ), -DEFINE_PROP_END_OF_LIST (), -}; -static void cmsdk_apb_watchdog_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -385,7 +380,6 @@ static void cmsdk_apb_watchdog_class_init(ObjectClass *klass, void *data) dc->realize = cmsdk_apb_watchdog_realize; dc->vmsd = &cmsdk_apb_watchdog_vmstate; dc->reset = cmsdk_apb_watchdog_reset; -device_class_set_props (dc, cmsdk_apb_watchdog_properties); }static const TypeInfo cmsdk_apb_watchdog_info = {
Signature · 1 line
2.20.1
[PULL 43/46] hw/arm/armsse: Use Clock to set system_clock_scale
In reply to Peter MaydellUse the MAINCLK Clock input to set the system_clock_scale variable rather than using the mainclk_frq property.
Message-id: [email protected]
Message-id: [email protected]
--- hw/arm/armsse.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
hw/arm/armsse.c +19 -5
@@ -232,6 +232,16 @@ static void armsse_forward_sec_resp_cfg(ARMSSE *s)qdev_connect_gpio_out (dev_splitter,2 , s->sec_resp_cfg_in); } +static void armsse_mainclk_update (void *opaque) +{ +ARMSSE *s =ARM_SSE (opaque); +/* +* Set system_clock_scale from our Clock input; this is what +* controls the tick rate of the CPU SysTick timer. +*/ + system_clock_scale =clock_ticks_to_ns (s->mainclk,1 ); +} +static void armsse_init (Object *obj) {ARMSSE *s =ARM_SSE (obj);
@@ -242,7 +252,8 @@ static void armsse_init(Object *obj)assert (info->sram_banks <=MAX_SRAM_BANKS );assert (info->num_cpus <=SSE_MAX_CPUS ); - s->mainclk =qdev_init_clock_in (DEVICE (s),"MAINCLK" ,NULL ,NULL ); + s->mainclk =qdev_init_clock_in (DEVICE (s),"MAINCLK" , + armsse_mainclk_update, s); s->s32kclk =qdev_init_clock_in (DEVICE (s),"S32KCLK" ,NULL ,NULL );memory_region_init (&s->container, obj,"armsse-container" ,UINT64_MAX );
@@ -451,9 +462,11 @@ static void armsse_realize(DeviceState *dev, Error **errp)return ; } -if (!s->mainclk_frq) { -error_setg (errp,"MAINCLK_FRQ property was not set" ); -return ; +if (!clock_has_source (s->mainclk)) { +error_setg (errp,"MAINCLK clock was not connected" ); + } +if (!clock_has_source (s->s32kclk)) { +error_setg (errp,"S32KCLK clock was not connected" ); }assert (info->num_cpus <=SSE_MAX_CPUS );
@@ -1115,7 +1128,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)*/ sysbus_init_mmio (SYS_BUS_DEVICE (s), &s->container); - system_clock_scale =NANOSECONDS_PER_SECOND / s->mainclk_frq; +/* Set initial system_clock_scale from MAINCLK */ +armsse_mainclk_update (s); } static void armsse_idau_check(IDAUInterface *ii, uint32_t address,
Signature · 1 line
2.20.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PULL 00/46] target-arm queue
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
7e7eb9f..5101d00 master -> master
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
e4eff82 hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS 5f7695b arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE 61b34fd arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE 568ae2e hw/arm/armsse: Use Clock to set system_clock_scale
fcb2844 tests/qtest/cmsdk-apb-watchdog-test: Test clock changes 0e465a3 hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input 714ce6c hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input a947916 hw/timer/cmsdk-apb-timer: Convert to use Clock input
e307bd8 hw/arm/stellaris: Create Clock input for watchdog
69adf23 hw/arm/stellaris: Convert SSYS to QOM device
103b89d hw/arm/musca: Create and connect ARMSSE Clocks
0350223 hw/arm/mps2-tz: Create and connect ARMSSE Clocks
0d30c31 hw/arm/mps2: Create and connect SYSCLK Clock
de9dbba hw/arm/mps2: Inline CMSDK_APB_TIMER creation
27ac1e9 hw/arm/armsse: Wire up clocks
9885628 hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ" 4d027bf hw/watchdog/cmsdk-apb-watchdog: Add Clock input
fc55f0a hw/timer/cmsdk-apb-dualtimer: Add Clock input
ab869a2 hw/timer/cmsdk-apb-timer: Add Clock input
e25a861 hw/timer/cmsdk-apb-timer: Rename CMSDKAPBTIMER struct to CMSDKAPBTimer eb6abc6 tests: Add a simple test of the CMSDK APB dual timer
5aa5062 tests: Add a simple test of the CMSDK APB watchdog
7d74e5d tests: Add a simple test of the CMSDK APB timer
99411a9 clock: Add new clock_has_source() function
5fd09a8 ptimer: Add new ptimer_set_period_from_clock() function 36bda30 tests/qtest: add a test case for pvpanic-pci
ae9e986 pvpanic : update pvpanic spec document
2b579e1 hw/misc/pvpanic: add PCI interface support
16a85d3 hw/misc/pvpanic: split-out generic and bus dependent code b01511c hvf: Add hypervisor entitlement to output binaries
ae4c601 darwin: remove 64-bit build detection on 32-bit OS
e9f538c darwin: detect CoreAudio for build
2f25d4a configure: cross compile should use x86_64 cpu_family
0bb8eeb darwin: fix cross-compiling for Darwin
9e6aa95 darwin: remove redundant dependency declaration
eaf3508 osdep: build with non-working system() function
83cd152 configure: cross-compiling with empty cross_prefix
69c2d85 configure: Move preadv check to meson.build
63f5cbe target/arm: Replace magic value by MMU_DATA_LOAD definition 447d650 hw/misc: Fix arith overflow in NPCM7XX PWM module
55b8e80 arm-virt: add secure pl061 for reset/power down
92ff23b arm-virt: refactor gpios creation
b50aad5 hw: gpio: implement gpio-pwr driver for qemu reset/poweroff e84395b arm: rename xlnx-zcu102.canbusN properties
1d12dd9 target/arm: Conditionalize DBGDIDR
11b098b target/arm: Implement ID_PFR2
=== OUTPUT BEGIN ===
1/46 Checking commit 11b098ba1811 (target/arm: Implement ID_PFR2)
2/46 Checking commit 1d12dd960d76 (target/arm: Conditionalize DBGDIDR)
3/46 Checking commit e84395bcb317 (arm: rename xlnx-zcu102.canbusN properties) 4/46 Checking commit b50aad50088a (hw: gpio: implement gpio-pwr driver for qemu reset/poweroff)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#37:
new file mode 100644
total: 0 errors, 1 warnings, 84 lines checked
Patch 4/46 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
5/46 Checking commit 92ff23b6fda5 (arm-virt: refactor gpios creation)
6/46 Checking commit 55b8e80c576a (arm-virt: add secure pl061 for reset/power down) 7/46 Checking commit 447d6508952e (hw/misc: Fix arith overflow in NPCM7XX PWM module) 8/46 Checking commit 63f5cbec4eda (target/arm: Replace magic value by MMU_DATA_LOAD definition) 9/46 Checking commit 69c2d852a523 (configure: Move preadv check to meson.build) 10/46 Checking commit 83cd15231abb (configure: cross-compiling with empty cross_prefix) 11/46 Checking commit eaf35083688d (osdep: build with non-working system() function) 12/46 Checking commit 9e6aa95cba9d (darwin: remove redundant dependency declaration) 13/46 Checking commit 0bb8eeb33670 (darwin: fix cross-compiling for Darwin) 14/46 Checking commit 2f25d4a2e787 (configure: cross compile should use x86_64 cpu_family) 15/46 Checking commit e9f538c8046d (darwin: detect CoreAudio for build)
16/46 Checking commit ae4c601e2ff4 (darwin: remove 64-bit build detection on 32-bit OS) 17/46 Checking commit b01511c00efb (hvf: Add hypervisor entitlement to output binaries)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#23:
new file mode 100644
total: 0 errors, 1 warnings, 62 lines checked
Patch 17/46 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
18/46 Checking commit 16a85d3ef395 (hw/misc/pvpanic: split-out generic and bus dependent code)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#87:
new file mode 100644
ERROR: line over 90 characters
#159: FILE: hw/misc/pvpanic-isa.c:68:
+ DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
WARNING: line over 80 characters
#255: FILE: hw/misc/pvpanic.c:69:
+ memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size);
total: 1 errors, 2 warnings, 238 lines checked
Patch 18/46 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
19/46 Checking commit 2b579e1074f2 (hw/misc/pvpanic: add PCI interface support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #68:
new file mode 100644
ERROR: line over 90 characters
#129: FILE: hw/misc/pvpanic-pci.c:57:
+ DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
total: 1 errors, 1 warnings, 134 lines checked
Patch 19/46 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
20/46 Checking commit ae9e9861eee8 (pvpanic : update pvpanic spec document) 21/46 Checking commit 36bda303a417 (tests/qtest: add a test case for pvpanic-pci)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #34:
new file mode 100644
total: 0 errors, 1 warnings, 101 lines checked
Patch 21/46 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
22/46 Checking commit 5fd09a8f7a84 (ptimer: Add new ptimer_set_period_from_clock() function) 23/46 Checking commit 99411a915fca (clock: Add new clock_has_source() function)
24/46 Checking commit 7d74e5dff9e0 (tests: Add a simple test of the CMSDK APB timer)
25/46 Checking commit 5aa5062d8bdb (tests: Add a simple test of the CMSDK APB watchdog)
26/46 Checking commit eb6abc6a1f32 (tests: Add a simple test of the CMSDK APB dual timer) 27/46 Checking commit e25a8618b6d2 (hw/timer/cmsdk-apb-timer: Rename CMSDKAPBTIMER struct to CMSDKAPBTimer) 28/46 Checking commit ab869a2737f7 (hw/timer/cmsdk-apb-timer: Add Clock input)
29/46 Checking commit fc55f0aa68d3 (hw/timer/cmsdk-apb-dualtimer: Add Clock input)
30/46 Checking commit 4d027bf8ba02 (hw/watchdog/cmsdk-apb-watchdog: Add Clock input)
31/46 Checking commit 9885628292fd (hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ") 32/46 Checking commit 27ac1e9412e1 (hw/arm/armsse: Wire up clocks)
33/46 Checking commit de9dbbac8cc4 (hw/arm/mps2: Inline CMSDK_APB_TIMER creation)
34/46 Checking commit 0d30c31abee7 (hw/arm/mps2: Create and connect SYSCLK Clock)
35/46 Checking commit 035022338fda (hw/arm/mps2-tz: Create and connect ARMSSE Clocks)
36/46 Checking commit 103b89d35001 (hw/arm/musca: Create and connect ARMSSE Clocks)
37/46 Checking commit 69adf233fbec (hw/arm/stellaris: Convert SSYS to QOM device)
38/46 Checking commit e307bd835a08 (hw/arm/stellaris: Create Clock input for watchdog)
39/46 Checking commit a9479168f8e0 (hw/timer/cmsdk-apb-timer: Convert to use Clock input) 40/46 Checking commit 714ce6cf8b5f (hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input) 41/46 Checking commit 0e465a3ae76f (hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input) 42/46 Checking commit fcb2844113a5 (tests/qtest/cmsdk-apb-watchdog-test: Test clock changes) 43/46 Checking commit 568ae2e471d2 (hw/arm/armsse: Use Clock to set system_clock_scale)
44/46 Checking commit 61b34fd1d20a (arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE) 45/46 Checking commit 5f7695b028b9 (arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE) 46/46 Checking commit e4eff82a714f (hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Re: [PULL 21/46] tests/qtest: add a test case for pvpanic-pci
In reply to Peter MaydellQuoted 11 lines · Peter Maydell
From: Mihai Carabas <[email protected]>
Add a test case for pvpanic-pci device. The scenario is the same as pvpanic ISA device, but is using the PCI bus.
Signed-off-by Mihai Carabas <[email protected]>Acked-by Thomas Huth <[email protected]>Reviewed-by Peter Maydell <[email protected]>Signed-off-by Mihai Carabas <[email protected]>Signed-off-by Peter Maydell <[email protected]>
This turns out to trigger the oss-fuzz build's leak-sanitizer:
https://gitlab.com/qemu-project/qemu/-/jobs/995177788
Quoted 18 lines
tests/qtest/pvpanic-pci-test.c new file +18
-0+static void test_panic_nopause (void ) +{ +uint8_t val; +QDict *response, *data; +QTestState *qts; +QPCIBus *pcibus; +QPCIDevice *dev; +QPCIBar bar; + + qts =qtest_init ("-device pvpanic-pci,addr=04.0 -action panic=none" ); + pcibus =qpci_new_pc (qts,NULL ); + dev =qpci_device_find (pcibus,QPCI_DEVFN (0x4 ,0x0 )); +qpci_device_enable (dev); + bar =qpci_iomap (dev,0 ,NULL ); + +qpci_memread (dev, bar,0 , &val,sizeof (val)); + g_assert_cmpuint(val, ==, 3); +
tests/qtest/pvpanic-pci-test.c line 48
Quoted 10 lines
tests/qtest/pvpanic-pci-test.c new file +10
-0+ val =1 ; +qpci_memwrite (dev, bar,0 , &val,sizeof (val)); + + response =qtest_qmp_eventwait_ref (qts,"GUEST_PANICKED" ); +g_assert (qdict_haskey (response,"data" )); + data =qdict_get_qdict (response,"data" ); +g_assert (qdict_haskey (data,"action" )); + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "run"); +qobject_unref (response); +
I'm going to squash in the trivial fix, which is to add
g_free(dev);
qpci_free_pc(pcibus);here and similarly in the test_panic() function.
Quoted 2 lines
+
qtest_quit(qts);
+ }
thanks
-- PMM
Re: [PULL 21/46] tests/qtest: add a test case for pvpanic-pci
La 29.01.2021 17:57, Peter Maydell a scris:
Quoted 43 lines · Peter Maydell
Quoted 10 lines
From: Mihai Carabas <[email protected]>
Add a test case for pvpanic-pci device. The scenario is the same as pvpanic ISA device, but is using the PCI bus.
Signed-off-by Mihai Carabas <[email protected]>Acked-by Thomas Huth <[email protected]>Reviewed-by Peter Maydell <[email protected]>Signed-off-by Mihai Carabas <[email protected]>Signed-off-by Peter Maydell <[email protected]>This turns out to trigger the oss-fuzz build's leak-sanitizer:
https://urldefense.com/v3/__https://gitlab.com/qemu-project/qemu/-/jobs/995177788__;!!GqivPVa7Brio!IGLAgdVRl_78c_PuUhuLJVDG1KFnc1gv3Pf1yTTcSiizygGvYHmq3YQ3YxwmMAwSMQ$Quoted 18 lines
tests/qtest/pvpanic-pci-test.c new file +18
-0+static void test_panic_nopause (void ) +{ +uint8_t val; +QDict *response, *data; +QTestState *qts; +QPCIBus *pcibus; +QPCIDevice *dev; +QPCIBar bar; + + qts =qtest_init ("-device pvpanic-pci,addr=04.0 -action panic=none" ); + pcibus =qpci_new_pc (qts,NULL ); + dev =qpci_device_find (pcibus,QPCI_DEVFN (0x4 ,0x0 )); +qpci_device_enable (dev); + bar =qpci_iomap (dev,0 ,NULL ); + +qpci_memread (dev, bar,0 , &val,sizeof (val)); + g_assert_cmpuint(val, ==, 3); +tests/qtest/pvpanic-pci-test.c line 48
Quoted 10 lines
tests/qtest/pvpanic-pci-test.c new file +10
-0+ val =1 ; +qpci_memwrite (dev, bar,0 , &val,sizeof (val)); + + response =qtest_qmp_eventwait_ref (qts,"GUEST_PANICKED" ); +g_assert (qdict_haskey (response,"data" )); + data =qdict_get_qdict (response,"data" ); +g_assert (qdict_haskey (data,"action" )); + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "run"); +qobject_unref (response); +I'm going to squash in the trivial fix, which is to add
Quoted 4 lines
g_free(dev); qpci_free_pc(pcibus);here and similarly in the
test_panic()function.
Thank you! Sorry for missing that trivial leak:(.
Thanks,
Mihai
Quoted 5 lines
Quoted 3 lines
+
qtest_quit(qts);
+ }thanks
-- PMM