diff --git a/src/acpi/aml/parser.rs b/src/acpi/aml/parser.rs index 0b57f13..e31c6f7 100644 --- a/src/acpi/aml/parser.rs +++ b/src/acpi/aml/parser.rs @@ -27,11 +27,17 @@ pub struct AmlExecutionContext { pub local_vars: [AmlValue; 8], pub arg_vars: [AmlValue; 8], pub state: ExecutionState, - pub namespace_delta: Vec + pub namespace_delta: Vec, + pub ctx_id: u64 } impl AmlExecutionContext { pub fn new(scope: String) -> AmlExecutionContext { + let mut idptr = ACPI_TABLE.next_ctx.write(); + let id: u64 = *idptr; + + *idptr += 1; + AmlExecutionContext { scope: scope, local_vars: [AmlValue::Uninitialized, @@ -51,7 +57,8 @@ impl AmlExecutionContext { AmlValue::Uninitialized, AmlValue::Uninitialized], state: ExecutionState::EXECUTING, - namespace_delta: vec!() + namespace_delta: vec!(), + ctx_id: id } } diff --git a/src/acpi/mod.rs b/src/acpi/mod.rs index d22140b..04112f3 100644 --- a/src/acpi/mod.rs +++ b/src/acpi/mod.rs @@ -315,13 +315,15 @@ pub fn set_global_s_state(state: u8) { pub struct Acpi { pub fadt: RwLock>, pub namespace: RwLock>>, - pub hpet: RwLock> + pub hpet: RwLock>, + pub next_ctx: RwLock, } pub static ACPI_TABLE: Acpi = Acpi { fadt: RwLock::new(None), namespace: RwLock::new(None), - hpet: RwLock::new(None) + hpet: RwLock::new(None), + next_ctx: RwLock::new(0), }; /// RSDP