Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions src/aml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2855,13 +2855,6 @@ where

/// A `MethodContext` represents a piece of running AML code - either a real method, or the
/// top-level of an AML table.
///
/// ### Safety
/// `MethodContext` does not keep the lifetime of the underlying AML stream, which for tables is
/// borrowed from the underlying physical mapping. This is because the interpreter needs to
/// preempt method contexts that execute other methods, and these contexts may have disparate
/// lifetimes. This is made safe in the case of methods by the context holding a reference to the
/// method object, but must be handled manually for AML tables.
struct MethodContext {
current_block: Block,
block_stack: Vec<Block>,
Expand All @@ -2874,14 +2867,14 @@ struct MethodContext {
}

struct Block {
stream: *const [u8],
stream: Vec<u8>,
pc: usize,
kind: BlockKind,
}

impl Block {
fn stream(&self) -> &[u8] {
unsafe { &*self.stream }
&self.stream
}
}

Expand Down Expand Up @@ -3009,7 +3002,7 @@ impl OpInFlight {

impl MethodContext {
unsafe fn new_from_table(stream: &[u8]) -> MethodContext {
let block = Block { stream: stream as *const [u8], pc: 0, kind: BlockKind::Table };
let block = Block { stream: Vec::from(stream), pc: 0, kind: BlockKind::Table };
MethodContext {
current_block: block,
block_stack: Vec::new(),
Expand All @@ -3031,7 +3024,7 @@ impl MethodContext {
return Err(AmlError::MethodArgCountIncorrect);
}
let block = Block {
stream: code as &[u8] as *const [u8],
stream: code.clone(),
pc: 0,
kind: BlockKind::Method { method_scope: scope.clone() },
};
Expand Down Expand Up @@ -3079,7 +3072,7 @@ impl MethodContext {

fn start_new_block(&mut self, kind: BlockKind, length: usize) {
let block = Block {
stream: &self.current_block.stream()[..(self.current_block.pc + length)] as *const [u8],
stream: self.current_block.stream()[..(self.current_block.pc + length)].into(),
pc: self.current_block.pc,
kind,
};
Expand Down
1 change: 0 additions & 1 deletion tests/uacpi_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ DefinitionBlock("", "DSDT", 1, "RSACPI", "UACPI", 1) {
}

#[test]
#[ignore] // See issue #300
fn copy_object_to_self() {
const ASL: &str = r#"
DefinitionBlock("", "DSDT", 1, "RSACPI", "UACPI", 1) {
Expand Down