1+ use alloc:: sync:: Arc ;
2+
13use crate :: acpi:: fadt;
24use crate :: acpi:: get_acpi_table;
35
46use crate :: mem:: paging:: PhysAddr ;
57
8+ use crate :: userland:: scheduler;
9+ use crate :: utils:: io;
10+
611struct LaiHost ;
712
813impl lai:: Host for LaiHost {
@@ -25,16 +30,55 @@ impl lai::Host for LaiHost {
2530 }
2631 . unwrap_or ( core:: ptr:: null ( ) )
2732 }
33+
34+ fn sleep ( & self , ms : u64 ) {
35+ scheduler:: get_scheduler ( )
36+ . inner
37+ . sleep ( Some ( ms as usize * 1_000_000 ) )
38+ . expect ( "lai: unexpected signal during sleep" )
39+ }
40+
41+ // Port I/O functions:
42+ #[ inline]
43+ fn outb ( & self , port : u16 , value : u8 ) {
44+ unsafe { io:: outb ( port, value) }
45+ }
46+
47+ #[ inline]
48+ fn outw ( & self , port : u16 , value : u16 ) {
49+ unsafe { io:: outw ( port, value) }
50+ }
51+
52+ #[ inline]
53+ fn outd ( & self , port : u16 , value : u32 ) {
54+ unsafe { io:: outl ( port, value) }
55+ }
56+
57+ #[ inline]
58+ fn inb ( & self , port : u16 ) -> u8 {
59+ unsafe { io:: inb ( port) }
60+ }
61+
62+ #[ inline]
63+ fn inw ( & self , port : u16 ) -> u16 {
64+ unsafe { io:: inw ( port) }
65+ }
66+
67+ #[ inline]
68+ fn ind ( & self , port : u16 ) -> u32 {
69+ unsafe { io:: inl ( port) }
70+ }
2871}
2972
3073pub fn init_lai ( ) {
31- let lai_host = box LaiHost ;
74+ let lai_host = Arc :: new ( LaiHost ) ;
3275 lai:: init ( lai_host) ;
3376
34- unsafe {
35- lai:: lai_set_acpi_revision ( get_acpi_table ( ) . revision ( ) as _ ) ;
36- lai:: lai_create_namespace ( ) ;
37- }
77+ lai:: set_acpi_revision ( get_acpi_table ( ) . revision ( ) as _ ) ;
78+ lai:: create_namespace ( ) ;
79+
80+ lai:: enable_acpi ( 1 ) ;
81+ lai:: enter_sleep ( 5 ) ;
3882}
3983
4084crate :: module_init!( init_lai) ;
0 commit comments