commit 0fdb03ab83b3b5460569f2407fa489c0809ce1bf Author: sweetbread Date: Wed Feb 7 02:50:48 2024 +0300 Init commit diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..b155c62 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,6 @@ +[unstable] +build-std = ["core", "compiler_builtins", "alloc"] + +[build] +target = "i686-kolibri.json" +rustflags = ["-C", "link-arg=-Tlink.x"] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..24920f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +*.kex diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..6ad607a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,41 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cstr_core" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd98742e4fdca832d40cab219dc2e3048de17d873248f83f17df47c1bea70956" +dependencies = [ + "cty", + "memchr", +] + +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + +[[package]] +name = "kos" +version = "0.1.0" +source = "git+https://git.coders-squad.com/KOS_Rust/Core#b25d5edca7fd8995440884da7ed2d934ed8a13da" +dependencies = [ + "cstr_core", +] + +[[package]] +name = "kos_ytm" +version = "0.1.0" +dependencies = [ + "cstr_core", + "kos", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..19e1d48 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "kos_ytm" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +kos = { git = "https://git.coders-squad.com/KOS_Rust/Core" } +cstr_core = { version = "0.2.4", default-features = false, features = ["nightly"] } diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 0000000..cc81ed8 --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,16 @@ +[env.production] +RELEASE_FLAG = "--release" + +[tasks.default] +alias = "all" + +[tasks.all] +dependencies = ["build"] + +[tasks.clean] +command = "cargo" +args = ["clean"] + +[tasks.build] +command = "cargo" +args = ["objcopy", "@@remove-empty(RELEASE_FLAG)", "--", "-O", "binary", "rust.kex"] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..eea07b6 --- /dev/null +++ b/build.rs @@ -0,0 +1,15 @@ +use std::{env, process::Command}; + +fn main() { + println!("cargo:rerun-if-changed=src/syscalls.S"); + + let out_dir = env::var("OUT_DIR").unwrap(); + + Command::new("fasm") + .arg("src/syscalls.S") + .arg(&format!("{}/libsyscalls.a", out_dir)) + .status() + .unwrap(); + + println!("cargo:rustc-link-search={}", out_dir) +} diff --git a/i686-kolibri.json b/i686-kolibri.json new file mode 100644 index 0000000..ca800ed --- /dev/null +++ b/i686-kolibri.json @@ -0,0 +1,24 @@ +{ + "arch": "x86", + "cpu": "pentium", + "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128", + "dynamic-linking": false, + "executables": true, + "has-rpath": true, + "is-builtin": false, + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "llvm-target": "i686-unknown-none-code32", + "max-atomic-width": 32, + "os": "none", + "relocation-model": "static", + "position-independent-executables": false, + "relro-level": "off", + "target-c-int-width": "32", + "target-endian": "little", + "target-pointer-width": "32", + "vendor": "unknown", + "disable-redzone": true, + "panic-strategy": "abort", + "singlethread": true +} diff --git a/link.x b/link.x new file mode 100644 index 0000000..1a3cac8 --- /dev/null +++ b/link.x @@ -0,0 +1,36 @@ +PATH_SIZE = 1024; +PARAMS_SIZE = 256; +STACK_SIZE = 1024*64; + +SECTIONS { + hdr : { + LONG(0x554e454D); + LONG(0x31305445); + LONG(1); // Header version + LONG(kol_main); // Program start + LONG(END); // Image size + LONG(FILE_END + PATH_SIZE + PARAMS_SIZE + STACK_SIZE); // Required amount of memory + LONG(FILE_END + PATH_SIZE + PARAMS_SIZE + STACK_SIZE); // Stack + LONG(FILE_END + PATH_SIZE); // Boot params + LONG(FILE_END); // Application path + } + + .text : { + *(.text) + *(.text.*) + } + + END = .; + + .data ALIGN(16) : { + *(.rodata.*) + *(const) + *(CONST) + *(.data) + *(data) + } + + .bss ALIGN(16) : {*(.bss)} + + FILE_END = .; +} diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..bf867e0 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..28c149a --- /dev/null +++ b/src/main.rs @@ -0,0 +1,9 @@ +#![no_std] +#![no_main] + +use kos::threads::exit; + +#[no_mangle] +fn kol_main() { + exit(); +}