From fa2420d5d92d0320db5cf1e5344ed6a69c3e78f5 Mon Sep 17 00:00:00 2001 From: Felix Wittwer Date: Sun, 27 Mar 2022 17:45:56 +0200 Subject: [PATCH] Initial Commit --- .cargo/config.toml | 9 +++++++++ .gitignore | 1 + Cargo.lock | 7 +++++++ Cargo.toml | 16 ++++++++++++++++ src/main.rs | 17 +++++++++++++++++ x86_64_plain_os.json | 15 +++++++++++++++ 6 files changed, 65 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs create mode 100644 x86_64_plain_os.json diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..9b4e124 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,9 @@ +[build] +target = "x86_64_plain_os.json" + +[unstable] +# enable implementations for memset, memcpy and memcmp etc. +build-std-features = ["compiler-builtins-mem"] +# for our target triple, there is no `core` prebuilt. So we need to do this by +# ourselves using this option: +build-std = ["core", "compiler_builtins"] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..a083e15 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "plain_os" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..1be67dc --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "plain_os" +version = "0.1.0" +edition = "2021" + +resolver = "2" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[profile.dev] +panic = "abort" # disable stack unwinding on panic + +[profile.release] +panic = "abort" # disable stack unwinding on panic + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..c388797 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,17 @@ +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +/// This function defines the panic handler +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop{} +} + +#[no_mangle] +pub extern "C" fn _start() -> ! { + // this function is the entry point, since the linker looks for a function + // named `_start` by default + loop {} +} diff --git a/x86_64_plain_os.json b/x86_64_plain_os.json new file mode 100644 index 0000000..346fefd --- /dev/null +++ b/x86_64_plain_os.json @@ -0,0 +1,15 @@ +{ + "llvm-target": "x86_64-unknown-none", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "none", + "executables": true, + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "panic-strategy": "abort", + "disable-redzone": true, + "features": "-mmx,-sse,+soft-float" +} \ No newline at end of file