diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..f34b2b0 --- /dev/null +++ b/.cargo/config @@ -0,0 +1,5 @@ +[build] +target = "x86_64-D.TinctoriusAzureaus.json" + +[target.'cfg(target_os = "none")'] +runner = "bootimage runner" \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e507b1f..a12ddeb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -8,8 +8,20 @@ + + + - + + + + + + + + + + - + + + + + - - + + + + + + + + + @@ -103,4 +153,8 @@ + + + \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 3e9c311..537bf7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,25 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "bit_field" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bootloader" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "kernel" version = "0.1.0" +dependencies = [ + "bootloader 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] +[metadata] +"checksum bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a165d606cf084741d4ac3a28fb6e9b1eb0bd31f6cd999098cfddb0b2ab381dc0" +"checksum bootloader 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "45dd858bd74a742ec0fe887722952c263abd0825aa8d33a3704917a97d7bd41e" diff --git a/Cargo.toml b/Cargo.toml index 53d79c2..e4b9d97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,3 +3,4 @@ members = [ "kernel", ] + diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index eebd9e0..b084467 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -1,9 +1,13 @@ [package] name = "kernel" version = "0.1.0" -authors = ["Guillaume DIDIER "] +authors = ["Guillaume DIDIER "] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] + +[dependencies.bootloader] +version = "^0.8.1" +features = ["sse"] \ No newline at end of file diff --git a/kernel/src/main.rs b/kernel/src/main.rs index e7a11a9..36c6fd5 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -1,3 +1,28 @@ -fn main() { - println!("Hello, world!"); +// main.rs +// main file of the kernel + +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop {} +} + +static HELLO: &[u8] = b"Hello Frog!"; + +#[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 {} } diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..580640b --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly-2019-09-28 \ No newline at end of file diff --git a/x86_64-D.TinctoriusAzureaus.json b/x86_64-D.TinctoriusAzureaus.json new file mode 100644 index 0000000..a126452 --- /dev/null +++ b/x86_64-D.TinctoriusAzureaus.json @@ -0,0 +1,14 @@ +{ + "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 +}