Initial code for second edition

This commit is contained in:
Philipp Oppermann
2018-02-02 13:35:36 +01:00
parent 2629945c72
commit 5823bcb7ab
2 changed files with 35 additions and 0 deletions

View File

@@ -4,3 +4,11 @@ name = "blog_os"
version = "0.2.0"
[dependencies]
# the profile used for `cargo build`
[profile.dev]
panic = "abort" # disable stack unwinding on panic
# the profile used for `cargo build --release`
[profile.release]
panic = "abort" # disable stack unwinding on panic

27
src/main.rs Normal file
View File

@@ -0,0 +1,27 @@
#![feature(lang_items)] // required for defining the panic handler
#![no_std] // don't link the Rust standard library
#![no_main] // disable all Rust-level entry points
#[no_mangle] // don't mangle the name of this function
pub fn _start() -> ! {
// this function is the entry point, since the linker looks for a function
// named `_start_` by default
let vga_buffer = 0xb8000 as *const u8 as *mut u8;
unsafe {
*vga_buffer.offset(0) = b'O';
*vga_buffer.offset(1) = 0xa; // foreground color green
*vga_buffer.offset(0) = b'K';
*vga_buffer.offset(3) = 0xa; // foreground color green
}
loop {}
}
#[lang = "panic_fmt"] // define a function that should be called on panic
#[no_mangle] // TODO required?
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
_file: &'static str,
_line: u32,
_column: u32) -> ! {
loop {}
}