From a577062dae0b25f0e249b5032435413fd3cb547c Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 3 Aug 2020 22:15:46 +0200 Subject: [PATCH] Add dummy-system-time process --- kernel/standalone/src/kernel.rs | 2 ++ modules/Cargo.lock | 19 ++++++++++++ modules/Cargo.toml | 1 + modules/dummy-system-time/Cargo.toml | 12 ++++++++ modules/dummy-system-time/src/main.rs | 42 +++++++++++++++++++++++++++ 5 files changed, 76 insertions(+) create mode 100644 modules/dummy-system-time/Cargo.toml create mode 100644 modules/dummy-system-time/src/main.rs diff --git a/kernel/standalone/src/kernel.rs b/kernel/standalone/src/kernel.rs index d67d56dbd..8c6d387a5 100644 --- a/kernel/standalone/src/kernel.rs +++ b/kernel/standalone/src/kernel.rs @@ -84,6 +84,8 @@ where )) .with_startup_process(build_wasm_module!("../../../modules/compositor")) .with_startup_process(build_wasm_module!("../../../modules/pci-printer")) + // TODO: actually implement system-time and remove this dummy; https://github.com/tomaka/redshirt/issues/542 + .with_startup_process(build_wasm_module!("../../../modules/dummy-system-time")) .with_startup_process(build_wasm_module!("../../../modules/kernel-debug-printer")) .with_startup_process(build_wasm_module!("../../../modules/log-to-kernel")) .with_startup_process(build_wasm_module!("../../../modules/http-server")) diff --git a/modules/Cargo.lock b/modules/Cargo.lock index ab66864e6..2cd2c89f4 100644 --- a/modules/Cargo.lock +++ b/modules/Cargo.lock @@ -521,6 +521,15 @@ dependencies = [ "generic-array 0.14.2", ] +[[package]] +name = "dummy-system-time" +version = "0.1.0" +dependencies = [ + "redshirt-interface-interface", + "redshirt-syscalls", + "redshirt-system-time-interface", +] + [[package]] name = "e1000" version = "0.1.0" @@ -2107,6 +2116,16 @@ dependencies = [ "spinning_top", ] +[[package]] +name = "redshirt-system-time-interface" +version = "0.1.0" +dependencies = [ + "futures", + "parity-scale-codec", + "pin-project", + "redshirt-syscalls", +] + [[package]] name = "redshirt-tcp-interface" version = "0.1.0" diff --git a/modules/Cargo.toml b/modules/Cargo.toml index a00babed7..2684e62dd 100644 --- a/modules/Cargo.toml +++ b/modules/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "compositor", + "dummy-system-time", "e1000", "hello-world", "http-server", diff --git a/modules/dummy-system-time/Cargo.toml b/modules/dummy-system-time/Cargo.toml new file mode 100644 index 000000000..07c051020 --- /dev/null +++ b/modules/dummy-system-time/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "dummy-system-time" +version = "0.1.0" +license = "GPL-3.0-or-later" +authors = ["Pierre Krieger "] +edition = "2018" +publish = false + +[dependencies] +redshirt-interface-interface = { path = "../../interfaces/interface" } +redshirt-syscalls = { path = "../../interfaces/syscalls" } +redshirt-system-time-interface = { path = "../../interfaces/system-time" } diff --git a/modules/dummy-system-time/src/main.rs b/modules/dummy-system-time/src/main.rs new file mode 100644 index 000000000..7ea99b765 --- /dev/null +++ b/modules/dummy-system-time/src/main.rs @@ -0,0 +1,42 @@ +// Copyright (C) 2019-2020 Pierre Krieger +// +// 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 3 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. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use redshirt_syscalls::{ffi::DecodedInterfaceOrDestroyed, Decode as _}; +use redshirt_system_time_interface::ffi as sys_time_ffi; + +fn main() { + redshirt_syscalls::block_on(async_main()) +} + +async fn async_main() { + redshirt_interface_interface::register_interface(sys_time_ffi::INTERFACE) + .await + .unwrap(); + + loop { + let interface_event = redshirt_syscalls::next_interface_message().await; + let msg = match interface_event { + DecodedInterfaceOrDestroyed::Interface(msg) => msg, + DecodedInterfaceOrDestroyed::ProcessDestroyed(_) => continue, + }; + + let msg_data = sys_time_ffi::TimeMessage::decode(msg.actual_data).unwrap(); + let sys_time_ffi::TimeMessage::GetSystem = msg_data; + + if let Some(id) = msg.message_id { + redshirt_syscalls::emit_answer(id, &0u128); + } + } +}