Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dummy-system-time process #544

Merged
merged 1 commit into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kernel/standalone/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
19 changes: 19 additions & 0 deletions modules/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions modules/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"compositor",
"dummy-system-time",
"e1000",
"hello-world",
"http-server",
Expand Down
12 changes: 12 additions & 0 deletions modules/dummy-system-time/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "dummy-system-time"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <[email protected]>"]
edition = "2018"
publish = false

[dependencies]
redshirt-interface-interface = { path = "../../interfaces/interface" }
redshirt-syscalls = { path = "../../interfaces/syscalls" }
redshirt-system-time-interface = { path = "../../interfaces/system-time" }
42 changes: 42 additions & 0 deletions modules/dummy-system-time/src/main.rs
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

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);
}
}
}