From d171fa675b9cb67e536ab722ecb2e72da0dc68a2 Mon Sep 17 00:00:00 2001 From: Luis Daniel Casais Date: Mon, 1 Dec 2025 10:34:06 +0100 Subject: [PATCH] refactor(architecture)!: change interrupt interface --- src/architecture.rs | 52 +++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/architecture.rs b/src/architecture.rs index 583c604..81b5dd1 100644 --- a/src/architecture.rs +++ b/src/architecture.rs @@ -487,26 +487,46 @@ pub struct MemoryLayout { stack: NonEmptyRangeInclusive, } +#[derive(Deserialize, JsonSchema, Debug, PartialEq, Eq, Clone)] +pub struct InterruptHandlers { + /// JS Handler for CREATOR interrupt handler's syscall interrupt + pub creator_syscall: Option, + /// JS Handler for the custom interrupt handler + pub custom: Option, +} + #[derive(Deserialize, JsonSchema, Debug, PartialEq, Eq, Clone)] pub struct Interrupts { - /// Controls whether interrupts are enabled by default (`true`) or not (`false`) - pub enabled: bool, - /// JS code to be executed in order to check whether an interrupt happened. - /// It must return an `InterruptType` (if an interrupt happened) or `null` (if it didn't) + /// Interrupt handler configuration + pub handlers: InterruptHandlers, + /// JS code to be executed in order to check what type of interrupt ocurred. + /// It must return an `InterruptType` (if an interrupt happened) or `null` + /// (if it didn't) pub check: String, - /// JS code to be executed in order to check whether interrupts are enabled - pub is_enabled: String, - /// JS code to be executed in order to enable interrupts - pub enable: String, - /// JS code to be executed in order to disable interrupts - pub disable: String, - /// JS code to be executed in order to obtain the interrupt handler address - pub get_handler_addr: String, - /// JS code to be executed in order to clear an interrupt - pub clear: String, - /// JS arrow (lambda) function to be executed in order to set an interrupt given an interrupt - /// type + /// JS code to be executed in order to enable the specified interrupt + /// `type`. Defaults to `global_enable` + pub enable: Option, + /// JS code to be executed in order to disable the specified interrupt + /// `type`. Defaults to `global_disable` + pub disable: Option, + /// JS code to be executed in order to globally enable interrupts + pub global_enable: String, + /// JS code to be executed in order to globally disable interrupts + pub global_disable: String, + /// JS code to be executed in order to clear an interrupt of the specified + /// `type`. Defaults to `global_clear` + pub clear: Option, + /// JS code to be executed in order to clear all interrupts + pub global_clear: String, + /// JS code to be executed in order to set an interrupt given an interrupt + /// `type` pub create: String, + /// JS code to check whether the specified interrupt `type` is enabled. Must + /// return a boolean. Defaults to `is_global_enabled` + pub is_enabled: Option, + /// JS code to check whether interrupts are globally is enabled. Must return + /// a boolean + pub is_global_enabled: String, } #[derive(Deserialize, JsonSchema, Debug, PartialEq, Eq, Clone)]