2017-04-11 17:02:21 +04:00
|
|
|
#![feature(lang_items)]
|
2017-04-12 21:16:04 +04:00
|
|
|
#![feature(const_fn)]
|
2017-04-12 21:32:59 +04:00
|
|
|
#![feature(const_unique_new)]
|
2017-04-12 21:20:15 +04:00
|
|
|
#![feature(unique)]
|
2017-04-11 17:02:21 +04:00
|
|
|
#![no_std]
|
|
|
|
|
2017-04-11 20:25:51 +04:00
|
|
|
extern crate rlibc;
|
2017-04-12 21:24:25 +04:00
|
|
|
extern crate volatile;
|
2017-04-12 21:32:59 +04:00
|
|
|
extern crate spin;
|
2017-04-13 19:51:09 +04:00
|
|
|
extern crate multiboot2;
|
2017-04-11 20:25:51 +04:00
|
|
|
|
2017-04-12 21:35:08 +04:00
|
|
|
#[macro_use]
|
2017-04-12 21:16:04 +04:00
|
|
|
mod vga_buffer;
|
|
|
|
|
2017-04-11 17:02:21 +04:00
|
|
|
#[no_mangle]
|
2017-04-13 19:49:27 +04:00
|
|
|
pub extern fn rust_main(multiboot_information_address: usize) {
|
2017-04-12 21:35:08 +04:00
|
|
|
vga_buffer::clear_screen();
|
|
|
|
println!("Hello World{}", "!");
|
2017-04-11 21:30:19 +04:00
|
|
|
|
2017-04-13 19:52:32 +04:00
|
|
|
let boot_info = unsafe{ multiboot2::load(multiboot_information_address) };
|
|
|
|
let memory_map_tag = boot_info.memory_map_tag()
|
|
|
|
.expect("Memory map tag required");
|
|
|
|
|
|
|
|
println!("memory areas:");
|
|
|
|
for area in memory_map_tag.memory_areas() {
|
|
|
|
println!(" start: 0x{:x}, length: 0x{:x}",
|
|
|
|
area.base_addr, area.length);
|
|
|
|
}
|
|
|
|
|
2017-04-13 19:54:06 +04:00
|
|
|
let elf_sections_tag = boot_info.elf_sections_tag()
|
|
|
|
.expect("Elf-sections tag required");
|
|
|
|
|
|
|
|
println!("kernel sections:");
|
|
|
|
for section in elf_sections_tag.sections() {
|
|
|
|
println!(" addr: 0x{:x}, size: 0x{:x}, flags: 0x{:x}",
|
|
|
|
section.addr, section.size, section.flags);
|
|
|
|
}
|
|
|
|
|
2017-04-13 19:57:33 +04:00
|
|
|
let kernel_start = elf_sections_tag.sections().map(|s| s.addr)
|
|
|
|
.min().unwrap();
|
|
|
|
let kernel_end = elf_sections_tag.sections().map(|s| s.addr + s.size)
|
|
|
|
.max().unwrap();
|
|
|
|
let multiboot_start = multiboot_information_address;
|
|
|
|
let multiboot_end = multiboot_start + (boot_info.total_size as usize);
|
|
|
|
|
2017-04-11 21:30:19 +04:00
|
|
|
loop{}
|
2017-04-11 20:25:51 +04:00
|
|
|
}
|
2017-04-11 17:02:21 +04:00
|
|
|
|
|
|
|
#[lang = "eh_personality"] extern fn eh_personality() {}
|
2017-04-13 19:53:34 +04:00
|
|
|
|
|
|
|
#[lang = "panic_fmt"]
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32) -> ! {
|
|
|
|
println!("\n\nPANIC in {} at line {}:", file, line);
|
|
|
|
println!(" {}", fmt);
|
|
|
|
loop{}
|
|
|
|
}
|