mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Initial code for second edition
This commit is contained in:
@@ -4,3 +4,11 @@ name = "blog_os"
|
|||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
||||||
[dependencies]
|
[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
27
src/main.rs
Normal 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 {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user