Skip to content
Snippets Groups Projects
Unverified Commit a5382534 authored by Connor Wood's avatar Connor Wood
Browse files

Converted to integer fully

parent d7229d71
No related branches found
No related tags found
1 merge request!48Fully implemented AML parser, some amendments to ACPI infrastructure
...@@ -210,6 +210,51 @@ impl AmlValue { ...@@ -210,6 +210,51 @@ impl AmlValue {
match *self { match *self {
AmlValue::IntegerConstant(ref i) => Ok(i.clone()), AmlValue::IntegerConstant(ref i) => Ok(i.clone()),
AmlValue::Integer(ref i) => Ok(i.clone()), AmlValue::Integer(ref i) => Ok(i.clone()),
AmlValue::Buffer(ref b) => {
let mut b = b.clone();
if b.len() > 8 {
return Err(AmlError::AmlValueError);
}
let mut i: u64 = 0;
while b.len() > 0 {
i <<= 8;
i += b.pop().expect("Won't happen") as u64;
}
Ok(i)
},
AmlValue::BufferField(_) => {
let mut b = self.get_as_buffer()?;
if b.len() > 8 {
return Err(AmlError::AmlValueError);
}
let mut i: u64 = 0;
while b.len() > 0 {
i <<= 8;
i += b.pop().expect("Won't happen") as u64;
}
Ok(i)
},
AmlValue::String(ref s) => {
let mut s = s.clone()[0..8].to_string().to_uppercase();
let mut i: u64 = 0;
for c in s.chars() {
if !c.is_digit(16) {
break;
}
i <<= 8;
i += c.to_digit(16).unwrap() as u64;
}
Ok(i)
},
_ => Err(AmlError::AmlValueError) _ => Err(AmlError::AmlValueError)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment