2017-04-11 17:02:21 +04:00
|
|
|
#![feature(lang_items)]
|
|
|
|
#![no_std]
|
|
|
|
|
2017-04-11 20:25:51 +04:00
|
|
|
extern crate rlibc;
|
|
|
|
|
2017-04-11 17:02:21 +04:00
|
|
|
#[no_mangle]
|
2017-04-11 20:25:51 +04:00
|
|
|
pub extern fn rust_main() {
|
2017-04-11 21:30:19 +04:00
|
|
|
// ATTENTION: we have a very small stack and no guard page
|
|
|
|
|
|
|
|
let hello = b"Hello World!";
|
|
|
|
let color_byte = 0x1f; // white foreground, blue background
|
|
|
|
|
|
|
|
let mut hello_colored = [color_byte; 24];
|
|
|
|
for (i, char_byte) in hello.into_iter().enumerate() {
|
|
|
|
hello_colored[i*2] = *char_byte;
|
|
|
|
}
|
|
|
|
|
|
|
|
// write `Hello World!` to the center of the VGA text buffer
|
|
|
|
let buffer_ptr = (0xb8000 + 1988) as *mut _;
|
|
|
|
unsafe { *buffer_ptr = hello_colored };
|
|
|
|
|
|
|
|
loop{}
|
2017-04-11 20:25:51 +04:00
|
|
|
}
|
2017-04-11 17:02:21 +04:00
|
|
|
|
|
|
|
#[lang = "eh_personality"] extern fn eh_personality() {}
|
|
|
|
#[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! {loop{}}
|