From 444e2be93fd685ead03a78c3100603e985c158d7 Mon Sep 17 00:00:00 2001 From: Alexander Hansen Date: Thu, 19 Dec 2024 05:46:41 +0100 Subject: [PATCH] Add convenience function vmcu_system_step_n Enable stepping more than one instruction at a time. --- engine/include/libvmcu/libvmcu_system.h | 7 +++++++ engine/include/system/system.h | 1 + engine/src/system/system.c | 13 +++++++++++++ 3 files changed, 21 insertions(+) diff --git a/engine/include/libvmcu/libvmcu_system.h b/engine/include/libvmcu/libvmcu_system.h index 3344b4d..7e26dc5 100644 --- a/engine/include/libvmcu/libvmcu_system.h +++ b/engine/include/libvmcu/libvmcu_system.h @@ -78,6 +78,13 @@ extern void vmcu_system_dtor(vmcu_system_t *this); * */ extern int vmcu_system_step(vmcu_system_t *this); +/* + * vmcu_system_step_n - multiple steps + * @this: pointer to virtual system + * @nsteps: number of steps + * */ +extern int vmcu_system_step_n(vmcu_system_t *this, uint64_t nsteps); + /* * vmcu_system_backstep - single step back * @this: pointer to virtual system diff --git a/engine/include/system/system.h b/engine/include/system/system.h index 2a244bc..8e4f507 100644 --- a/engine/include/system/system.h +++ b/engine/include/system/system.h @@ -40,6 +40,7 @@ extern void vmcu_system_dtor(vmcu_system_t *this); /* General System Functions */ extern int vmcu_system_step(vmcu_system_t *this); +extern int vmcu_system_step_n(vmcu_system_t *this, uint64_t nsteps); extern void vmcu_system_backstep(vmcu_system_t *this); extern void vmcu_system_reboot(vmcu_system_t *this); diff --git a/engine/src/system/system.c b/engine/src/system/system.c index afad442..34236d1 100644 --- a/engine/src/system/system.c +++ b/engine/src/system/system.c @@ -78,6 +78,19 @@ void vmcu_system_dtor(vmcu_system_t *this) { free(this); } +int vmcu_system_step_n(vmcu_system_t *this, uint64_t nsteps) { + + int err = 0; + + for(uint64_t i = 0; i < nsteps; i++){ + err = vmcu_system_step(this); + if (err){ + return err; + } + } + return err; +} + int vmcu_system_step(vmcu_system_t *this) { int err = 0;