minimal rust kernel compiling but not working yet
This commit is contained in:
parent
8db78c3730
commit
8d3bde9f87
4
asm/README.md
Normal file
4
asm/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
Assembly Bootloader
|
||||
=====
|
||||
|
||||
Following [3zanders](http://3zanders.co.uk/2017/10/16/writing-a-bootloader2/)
|
9
sar_ros/.cargo/config.toml
Normal file
9
sar_ros/.cargo/config.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[build]
|
||||
target = "x86_64-sar_ros.json"
|
||||
|
||||
[target.'cfg(target_os = "none")']
|
||||
runner = "bootimage runner"
|
||||
|
||||
[unstable]
|
||||
build-std-features = ["compiler-builtins-mem"]
|
||||
build-std = ["core", "compiler_builtins"]
|
16
sar_ros/Cargo.lock
generated
Normal file
16
sar_ros/Cargo.lock
generated
Normal file
@ -0,0 +1,16 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bootloader"
|
||||
version = "0.9.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6e02311b16c9819e7c72866d379cdd3026c3b7b25c1edf161f548f8e887e7ff"
|
||||
|
||||
[[package]]
|
||||
name = "sar_os"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bootloader",
|
||||
]
|
25
sar_ros/Cargo.toml
Normal file
25
sar_ros/Cargo.toml
Normal file
@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "sar_os"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
bootloader = "0.9.23"
|
||||
|
||||
#[profile.dev]
|
||||
#panic = "abort"
|
||||
#
|
||||
#[profile.release]
|
||||
#panic = "abort"
|
||||
#
|
||||
#[package.metadata.bootimage]
|
||||
## The cargo subcommand that will be used for building the kernel.
|
||||
##
|
||||
## For building using the `cargo-xbuild` crate, set this to `xbuild`.
|
||||
#build-command = ["build"]
|
||||
## The command invoked with the created bootimage (the "{}" will be replaced
|
||||
## with the path to the bootable disk image)
|
||||
## Applies to `bootimage run` and `bootimage runner`
|
||||
#run-command = ["qemu-system-x86_64", "-drive", "format=raw,file={}"]
|
4
sar_ros/README.md
Normal file
4
sar_ros/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
Minimal Rust Kernel
|
||||
=======
|
||||
|
||||
Following [Phil Opp's](https://os.phil-opp.com/minimal-rust-kernel/) minimal rust kernel tutorial
|
26
sar_ros/src/main.rs
Normal file
26
sar_ros/src/main.rs
Normal file
@ -0,0 +1,26 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
/// This function is called on panic.
|
||||
#[panic_handler]
|
||||
fn panic(_info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
static HELLO: &[u8] = b"Hello World!";
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn _start() -> ! {
|
||||
let vga_buffer = 0xb8000 as *mut u8;
|
||||
|
||||
for (i, &byte) in HELLO.iter().enumerate() {
|
||||
unsafe {
|
||||
*vga_buffer.offset(i as isize * 2) = byte;
|
||||
*vga_buffer.offset(i as isize * 2 + 1) = 0xb;
|
||||
}
|
||||
}
|
||||
|
||||
loop {}
|
||||
}
|
15
sar_ros/x86_64-sar_ros.json
Normal file
15
sar_ros/x86_64-sar_ros.json
Normal file
@ -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"
|
||||
}
|
Loading…
Reference in New Issue
Block a user