-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.rs
74 lines (59 loc) · 1.79 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#![no_std]
#![feature(no_std)]
#![feature(asm)]
#![feature(lang_items)]
#![feature(box_syntax)]
#![feature(core)]
#![feature(unique)]
#![feature(core_str_ext)]
#![feature(raw)]
//extern crate core;
use kernel::console::Color;
// Must be re-exported to be called from assembly
pub use kernel::interrupt::int_handler;
mod kernel;
mod sys;
mod apps;
use core::ptr::Unique;
use core::str::from_utf8;
#[lang="owned_box"]
pub struct Box<T>(Unique<T>);
#[no_mangle]
#[no_stack_check]
pub fn main() {
let mut console = kernel::console::Console::init();
console.clear_screen(Color::Black);
console.print_string("Welcome to rOSt.\n");
console.print_string("\nBegin PCI Scan...\n");
for bus in 0..255 {
for slot in 0..31 {
let vendor = kernel::pci::check_vendor(bus,slot);
if vendor != 0xFFFF {
console.print_string("Device found: ");
console.print_int(bus as u32);
console.print_string("-");
console.print_int(slot as u32);
console.print_char('\n');
console.print_string("Vendor: ");
console.print_int(vendor as u32);
console.print_char('\n');
}
}
}
console.print_string("\nTesting dynamic memory...\n");
let foo = box 12345;
console.print_int(*foo);
// TODO: Second box does not work..
// let foo2 = box 0;
// console.print_int(*foo2);
// console.print_int(*foo);
console.print_string("\nTesting keyboard input...\n");
apps::shell::run(console);
}
#[lang = "box_free"]
unsafe fn box_free<T>(ptr: *mut T) {
//TODO: Impl
}
// Stubs for functions needed to build as static lib.
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop{} }