فهرست منبع

Namespace and dud table parsing API for now

Isaac Woods 6 سال پیش
والد
کامیت
2ca5c63fc2
2فایلهای تغییر یافته به همراه34 افزوده شده و 0 حذف شده
  1. 1 0
      aml_parser/Cargo.toml
  2. 33 0
      aml_parser/src/lib.rs

+ 1 - 0
aml_parser/Cargo.toml

@@ -10,3 +10,4 @@ license = "MIT/Apache-2.0"
 edition = "2018"
 
 [dependencies]
+log = "0.4"

+ 33 - 0
aml_parser/src/lib.rs

@@ -1 +1,34 @@
 #![no_std]
+#![feature(alloc, decl_macro)]
+
+extern crate alloc;
+
+#[cfg(test)]
+extern crate std;
+
+use alloc::{collections::BTreeMap, string::String};
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum AmlError {
+    UnexpectedEndOfStream,
+    UnexpectedByte(u8),
+}
+
+pub struct AmlNamespace {
+    namespace: BTreeMap<String, AmlValue>,
+}
+
+impl AmlNamespace {
+    pub fn new() -> AmlNamespace {
+        AmlNamespace { namespace: BTreeMap::new() }
+    }
+
+    pub fn parse_table(&mut self, stream: &[u8]) -> Result<(), AmlError> {
+        if stream.len() == 0 {
+            return Err(AmlError::UnexpectedEndOfStream);
+        }
+
+        log::info!("stream length: {}, {:#x}", stream.len(), stream[0]);
+        return Err(AmlError::UnexpectedEndOfStream);
+    }
+}