cmake: boards: make QEMU icount sleep parameter configurable

When QEMU is running in icount mode, the behaviour regarding
the CPU being in sleep mode is configurable, with the default
value being set to 'off'. In this case, instruction counting
continues even when the CPU is sleeping or no target time is
set in the system timer. If the sleep parameter is set to
'on', instruction counting stops if the CPU is sleeping, and
the instruction count will fast-forward directly to the next
target time once it is being set.

In the Xilinx derivative of QEMU (which simulates ZynqMP and
Zynq-7000 SoCs), the default configuration causes QEMU to no
longer accept control commands via the console or remotely
whenever Zephyr enters and remains in idle mode.

Therefore, this commit makes the value of the sleep para-
meter of the icount functionality configurable, with the
default value remaining 'off'. The value can be changed at
board level alongside with the specification of the icount
shift value.

Signed-off-by: Immo Birnbaum <Immo.Birnbaum@Weidmueller.com>
This commit is contained in:
Immo Birnbaum 2021-10-15 11:45:11 +02:00 committed by Carles Cufí
commit f4d41b1a6c
3 changed files with 21 additions and 2 deletions

View file

@ -54,6 +54,17 @@ config QEMU_ICOUNT_SHIFT
The virtual CPU will execute one instruction every 2^N nanoseconds
of virtual time, where N is the value provided here.
config QEMU_ICOUNT_SLEEP
bool "QEMU icount sleep mode enable"
depends on QEMU_ICOUNT
help
When the virtual CPU is sleeping, the virtual time will advance
at default speed unless this option is set. With this option set,
the virtual time will jump to the next timer deadline instantly
whenever the virtual CPU goes to sleep mode and will not advance
if no timer is enabled. This behavior gives deterministic execution
times from the guest point of view.
config QEMU_IVSHMEM_PLAIN_MEM_SIZE
int "QEMU ivshmem-plain shared memory size in mega-bytes"
default 1

View file

@ -71,7 +71,9 @@ endif # NETWORKING
if QEMU_ICOUNT
config QEMU_ICOUNT_SHIFT
default 3
default 8
config QEMU_ICOUNT_SLEEP
default y
endif # QEMU_ICOUNT

View file

@ -74,9 +74,15 @@ endif()
list(APPEND QEMU_FLAGS -mon chardev=con,mode=readline)
if(CONFIG_QEMU_ICOUNT)
list(APPEND QEMU_FLAGS
if(CONFIG_QEMU_ICOUNT_SLEEP)
list(APPEND QEMU_FLAGS
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=on
-rtc clock=vm)
else()
list(APPEND QEMU_FLAGS
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=off
-rtc clock=vm)
endif()
endif()
# Add a BT serial device when building for bluetooth, unless the