Skip to content

Commit f4d41b1

Browse files
ibirnbaumcarlescufi
authored andcommitted
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 <[email protected]>
1 parent eef767e commit f4d41b1

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

boards/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ config QEMU_ICOUNT_SHIFT
5454
The virtual CPU will execute one instruction every 2^N nanoseconds
5555
of virtual time, where N is the value provided here.
5656

57+
config QEMU_ICOUNT_SLEEP
58+
bool "QEMU icount sleep mode enable"
59+
depends on QEMU_ICOUNT
60+
help
61+
When the virtual CPU is sleeping, the virtual time will advance
62+
at default speed unless this option is set. With this option set,
63+
the virtual time will jump to the next timer deadline instantly
64+
whenever the virtual CPU goes to sleep mode and will not advance
65+
if no timer is enabled. This behavior gives deterministic execution
66+
times from the guest point of view.
67+
5768
config QEMU_IVSHMEM_PLAIN_MEM_SIZE
5869
int "QEMU ivshmem-plain shared memory size in mega-bytes"
5970
default 1

boards/arm/qemu_cortex_a9/Kconfig.defconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ endif # NETWORKING
7171
if QEMU_ICOUNT
7272

7373
config QEMU_ICOUNT_SHIFT
74-
default 3
74+
default 8
75+
config QEMU_ICOUNT_SLEEP
76+
default y
7577

7678
endif # QEMU_ICOUNT
7779

cmake/emu/qemu.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,15 @@ endif()
7474
list(APPEND QEMU_FLAGS -mon chardev=con,mode=readline)
7575

7676
if(CONFIG_QEMU_ICOUNT)
77-
list(APPEND QEMU_FLAGS
77+
if(CONFIG_QEMU_ICOUNT_SLEEP)
78+
list(APPEND QEMU_FLAGS
79+
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=on
80+
-rtc clock=vm)
81+
else()
82+
list(APPEND QEMU_FLAGS
7883
-icount shift=${CONFIG_QEMU_ICOUNT_SHIFT},align=off,sleep=off
7984
-rtc clock=vm)
85+
endif()
8086
endif()
8187

8288
# Add a BT serial device when building for bluetooth, unless the

0 commit comments

Comments
 (0)