Init commit

This commit is contained in:
Gleb Zaharov 2024-02-07 02:50:48 +03:00
commit 0fdb03ab83
10 changed files with 160 additions and 0 deletions

6
.cargo/config.toml Normal file
View File

@ -0,0 +1,6 @@
[unstable]
build-std = ["core", "compiler_builtins", "alloc"]
[build]
target = "i686-kolibri.json"
rustflags = ["-C", "link-arg=-Tlink.x"]

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
*.kex

41
Cargo.lock generated Normal file
View File

@ -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"

10
Cargo.toml Normal file
View File

@ -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"] }

16
Makefile.toml Normal file
View File

@ -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"]

15
build.rs Normal file
View File

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

24
i686-kolibri.json Normal file
View File

@ -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
}

36
link.x Normal file
View File

@ -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 = .;
}

1
rust-toolchain Normal file
View File

@ -0,0 +1 @@
nightly

9
src/main.rs Normal file
View File

@ -0,0 +1,9 @@
#![no_std]
#![no_main]
use kos::threads::exit;
#[no_mangle]
fn kol_main() {
exit();
}