Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 711c1ec

Browse filesBrowse files
aml: move enable_acpi to aml_subsys
Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
1 parent 44327d4 commit 711c1ec
Copy full SHA for 711c1ec

File tree

Expand file treeCollapse file tree

5 files changed

+24
-9
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+24
-9
lines changed

‎src/aero_kernel/src/acpi/aml.rs

Copy file name to clipboardExpand all lines: src/aero_kernel/src/acpi/aml.rs
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ pub enum SleepState {
1010

1111
pub trait AmlSubsystem: Send + Sync {
1212
fn enter_state(&self, state: SleepState);
13+
/// Ensures that the system control interrupt (SCI) is properly
14+
/// configured, disables SCI event sources, installs the SCI handler, and
15+
/// transfers the system hardware into ACPI mode.
16+
///
17+
/// ## Parameters
18+
/// * `mode` - IRQ mode (ACPI spec section 5.8.1)
19+
fn enable_acpi(&self, mode: u32);
1320
}
1421

1522
static AML_SUBSYSTEM: Once<Arc<dyn AmlSubsystem>> = Once::new();

‎src/aero_kernel/src/arch/x86_64/interrupts/mod.rs

Copy file name to clipboardExpand all lines: src/aero_kernel/src/arch/x86_64/interrupts/mod.rs
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ impl InterruptController {
6767
}
6868
}
6969

70+
pub fn method(&self) -> usize {
71+
self.method.load(Ordering::SeqCst)
72+
}
73+
7074
/// Send EOI, indicating the completion of an interrupt.
7175
pub fn eoi(&self) {
7276
match self.method.load(Ordering::Acquire) {

‎src/aero_kernel/src/arch/x86_64/mod.rs

Copy file name to clipboardExpand all lines: src/aero_kernel/src/arch/x86_64/mod.rs
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub mod task;
2626
pub mod tls;
2727

2828
use crate::acpi;
29+
use crate::acpi::aml;
2930
use crate::apic;
3031
use crate::cmdline;
3132
use crate::mem;
@@ -42,6 +43,8 @@ use crate::utils::io;
4243
use raw_cpuid::CpuId;
4344
use stivale_boot::v2::*;
4445

46+
use self::interrupts::INTERRUPT_CONTROLLER;
47+
4548
#[repr(C, align(4096))]
4649
struct P2Align12<T>(T);
4750

@@ -234,6 +237,10 @@ extern "C" fn x86_64_aero_ap_main(ap_id: usize, stack_top_addr: VirtAddr) {
234237
crate::aero_ap_main(ap_id);
235238
}
236239

240+
pub fn enable_acpi() {
241+
aml::get_subsystem().enable_acpi(INTERRUPT_CONTROLLER.method() as _);
242+
}
243+
237244
pub fn init_cpu() {
238245
unsafe {
239246
// Enable the no-execute page protection feature.

‎src/aero_kernel/src/drivers/lai.rs

Copy file name to clipboardExpand all lines: src/aero_kernel/src/drivers/lai.rs
+4-9Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,26 @@ impl lai::Host for LaiHost {
4242
}
4343

4444
// Port I/O functions:
45-
#[inline]
4645
fn outb(&self, port: u16, value: u8) {
4746
unsafe { io::outb(port, value) }
4847
}
4948

50-
#[inline]
5149
fn outw(&self, port: u16, value: u16) {
5250
unsafe { io::outw(port, value) }
5351
}
5452

55-
#[inline]
5653
fn outd(&self, port: u16, value: u32) {
5754
unsafe { io::outl(port, value) }
5855
}
5956

60-
#[inline]
6157
fn inb(&self, port: u16) -> u8 {
6258
unsafe { io::inb(port) }
6359
}
6460

65-
#[inline]
6661
fn inw(&self, port: u16) -> u16 {
6762
unsafe { io::inw(port) }
6863
}
6964

70-
#[inline]
7165
fn ind(&self, port: u16) -> u32 {
7266
unsafe { io::inl(port) }
7367
}
@@ -91,7 +85,6 @@ impl lai::Host for LaiHost {
9185
}
9286

9387
// Memory functions:
94-
#[inline]
9588
fn map(&self, address: usize, _count: usize) -> *mut u8 {
9689
PhysAddr::new(address as u64)
9790
.as_hhdm_virt()
@@ -105,6 +98,10 @@ impl aml::AmlSubsystem for LaiSubsystem {
10598
fn enter_state(&self, state: aml::SleepState) {
10699
lai::enter_sleep(state as u8)
107100
}
101+
102+
fn enable_acpi(&self, mode: u32) {
103+
lai::enable_acpi(mode);
104+
}
108105
}
109106

110107
pub fn init_lai() {
@@ -114,8 +111,6 @@ pub fn init_lai() {
114111
lai::set_acpi_revision(get_acpi_table().revision() as _);
115112
lai::create_namespace();
116113

117-
lai::enable_acpi(1);
118-
119114
let subsystem = Arc::new(LaiSubsystem);
120115
aml::init(subsystem);
121116
}

‎src/aero_kernel/src/main.rs

Copy file name to clipboardExpand all lines: src/aero_kernel/src/main.rs
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ fn kernel_main_thread() {
144144
modules::init();
145145
log::info!("loaded kernel modules");
146146

147+
arch::enable_acpi();
148+
147149
drivers::pci::init(&mut offset_table);
148150
log::info!("loaded PCI driver");
149151

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.