This commit is contained in:
pointer-to-bios 2024-09-12 07:28:31 +08:00
commit e538cc6b8b
12 changed files with 102 additions and 0 deletions

20
.cargo/config.toml Normal file
View File

@ -0,0 +1,20 @@
[alias]
b = "build"
br = "build --release"
c = "check"
t = "test"
r = "run"
rr = "run --release"
[build]
incremental = true
pipelining = true
rustflags = [
"-C", "code-model=large",
"-C", "relocation-model=static",
"-C", "embed-bitcode=no"
]
target = ["x86_64-unknown-none"]
[profile.x86_64-unknown-none]
panic = "abort"

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

7
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"rust-analyzer.cargo.allTargets": false,
"rust-analyzer.cargo.extraArgs": [
"--target",
"x86_64-unknown-none"
]
}

7
Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "nonx"
version = "0.1.0"

16
Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "nonx"
version = "0.1.0"
edition = "2021"
[dependencies]
[features]
default = ["large"]
large = [] # Enable for server or desktop devices.
small = [] # Enable for legacy server or desktop devices.
embeded = [] # Enable for embeded devices and extremely old devices.
[lib]
crate-type = ["staticlib"]
test = false

30
build.rs Normal file
View File

@ -0,0 +1,30 @@
use std::{env, path::Path, process::Command};
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
Command::new("llvm-as")
.args(&["src/kernel_end.ll", "-o"])
.arg(&format!("{}/kernel_end.bc", out_dir))
.status()
.unwrap();
Command::new("llc")
.arg(&format!("{}/kernel_end.bc", out_dir))
.arg("-o")
.arg(&format!("{}/kernel_end.s", out_dir))
.status()
.unwrap();
Command::new("as")
.arg("-o")
.arg(&format!("{}/kernel_end.o", out_dir))
.arg(&format!("{}/kernel_end.s", out_dir))
.status()
.unwrap();
Command::new("ar")
.args(&["crus", "libkernel_end.a", "kernel_end.o"])
.current_dir(&Path::new(&out_dir))
.status()
.unwrap();
println!("cargo::rustc-link-search=native={}", out_dir);
println!("cargo::rustc-link-lib=static=kernel_end");
println!("cargo::rerun-if-changed=src/kernel_end.ll");
}

1
src/kernel_end.ll Normal file
View File

@ -0,0 +1 @@
@KERNEL_END = global i32 0, section ".kernel-end"

13
src/lib.rs Normal file
View File

@ -0,0 +1,13 @@
#![no_std]
extern crate alloc;
use core::panic::PanicInfo;
pub mod memm;
pub mod plugin;
#[panic_handler]
fn panic_handler(_panic: &PanicInfo) -> ! {
loop {}
}

0
src/memm/manager.rs Normal file
View File

0
src/memm/mod.rs Normal file
View File

6
src/plugin/api_bus.rs Normal file
View File

@ -0,0 +1,6 @@
use alloc::string::String;
struct APIRegister{
name: String,
call: *mut fn(),
}

1
src/plugin/mod.rs Normal file
View File

@ -0,0 +1 @@
pub mod api_bus;