From 3f7102d7193d3c0f6cdda8e3106aac77188bb475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 23 Nov 2020 04:07:45 +0100 Subject: intial rs --- TODO | 19 +++++++++++++++++++ halt/Cargo.toml | 18 ++++++++++++++++++ halt/main.c | 5 +++++ halt/rust-toolchain | 1 + halt/rust.h | 1 + halt/src/main.rs | 26 ++++++++++++++++++++++++++ 6 files changed, 70 insertions(+) create mode 100644 TODO create mode 100644 halt/Cargo.toml create mode 100644 halt/main.c create mode 100644 halt/rust-toolchain create mode 100644 halt/rust.h create mode 100644 halt/src/main.rs diff --git a/TODO b/TODO new file mode 100644 index 0000000..8813f46 --- /dev/null +++ b/TODO @@ -0,0 +1,19 @@ +1: Hijacka deras Makefiler så de bygger rust, kopierar rust FFI och länkar. +Deras Makefiler fungerar uppenbarligen och koden borde kunna anropa rust FFI utan problem. + +2: Anropa deras libc från Rust, men börja med att typ returnera en int. + +3: userprog/rust.c som skickar allt till rust. + +4: build.rs som hanterar hela bygg-grejen. + +. +. +. + +99: i686-unknown-pintos + +rust.h: +int rust_main(int argc, char **argv); + +Haltar via exit i entry.c diff --git a/halt/Cargo.toml b/halt/Cargo.toml new file mode 100644 index 0000000..160a513 --- /dev/null +++ b/halt/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "halt" +version = "0.1.0" +authors = ["Gustav Sörnäs "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[profile.dev] +panic = "abort" + +[profile.release] +panic = "abort" + +[dependencies.libc] +version = "0.2" +default-features = false +features = ["extra_traits"] diff --git a/halt/main.c b/halt/main.c new file mode 100644 index 0000000..c89be21 --- /dev/null +++ b/halt/main.c @@ -0,0 +1,5 @@ +#include "rust.h" + +void _start (int argc, char **argv) { + main(); +} diff --git a/halt/rust-toolchain b/halt/rust-toolchain new file mode 100644 index 0000000..adfa491 --- /dev/null +++ b/halt/rust-toolchain @@ -0,0 +1 @@ +nightly-i686-unknown-linux-gnu diff --git a/halt/rust.h b/halt/rust.h new file mode 100644 index 0000000..eba2976 --- /dev/null +++ b/halt/rust.h @@ -0,0 +1 @@ +int main(void); diff --git a/halt/src/main.rs b/halt/src/main.rs new file mode 100644 index 0000000..8abf38a --- /dev/null +++ b/halt/src/main.rs @@ -0,0 +1,26 @@ +#![no_std] +#![no_main] +#![feature(start)] +//#![feature(asm)] +//#![link_args = "-L -lmain"] + +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +#[no_mangle] +pub unsafe extern "C" fn main() { + exit(0x69); +} + +#[link(name="pintos", kind="static")] +extern { + fn exit(status: i32); +} + +//#[no_mangle] +//#[start] +//unsafe extern "C" fn _start() { +// exit(main()); +//} -- cgit v1.2.1