-
-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathmain.rs
More file actions
51 lines (40 loc) · 1.38 KB
/
Copy pathmain.rs
File metadata and controls
51 lines (40 loc) · 1.38 KB
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
//! A simple executable to check that the `acpi` crate can be used in a no-alloc environment.
//!
//! This was born out of a comment in [issue 311](https://github.com/rust-osdev/acpi/issues/311)
//! that it didn't work.
//!
//! This executable should build, but actually attempting to run it will result in an access
//! violation. It is enough that it builds successfully.
//!
//! Heavily adapted from the
//! [example by zulinx86](https://zenn.dev/zulinx86/articles/rust-nostd-101)
#![no_std]
#![no_main]
mod null_handler;
use core::{arch::asm, panic::PanicInfo};
use null_handler::NullHandler;
fn sys_exit(status: i32) -> ! {
unsafe {
asm!(
"syscall",
in("rax") 60,
in("rdi") status,
options(noreturn)
);
}
}
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
use ::acpi::{AcpiTables, sdt::madt::Madt};
// Clearly actually executing this will result in an access violation. The point is to check that it compiles.
let tables = unsafe { AcpiTables::from_rsdp(NullHandler {}, 0xd1e as usize) }
.unwrap_or_else(|x| panic!("Failed to parse RSDP table: {:?}", x));
let mut _madt = tables.find_table::<Madt>().expect("Failed to find MADT");
_madt.get().entries().for_each(|_entry| {});
// Just in case it doesn't die already!
sys_exit(0);
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}