From a5382534e605db6d9774eb3bcd940089227d6ca3 Mon Sep 17 00:00:00 2001
From: Connor Wood <connorwood71@gmail.com>
Date: Mon, 24 Jul 2017 18:53:21 +0100
Subject: [PATCH] Converted to integer fully

---
 src/acpi/aml/namespace.rs | 45 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/src/acpi/aml/namespace.rs b/src/acpi/aml/namespace.rs
index c818ef77..78beb9cb 100644
--- a/src/acpi/aml/namespace.rs
+++ b/src/acpi/aml/namespace.rs
@@ -210,6 +210,51 @@ impl AmlValue {
         match *self {
             AmlValue::IntegerConstant(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)
         }
     }
-- 
GitLab