diff --git a/src/aml.rs b/src/aml.rs index 1cb0ccd..6761eed 100644 --- a/src/aml.rs +++ b/src/aml.rs @@ -119,6 +119,7 @@ impl Aml for Ones { /// Name/Device/Method/Scope and so on... pub struct Path { root: bool, + parent: bool, name_parts: Vec<[u8; 4]>, } @@ -126,6 +127,8 @@ impl Aml for Path { fn to_aml_bytes(&self, sink: &mut dyn AmlSink) { if self.root { sink.byte(b'\\'); + } else if self.parent { + sink.byte(b'^'); } match self.name_parts.len() { @@ -151,7 +154,9 @@ impl Path { /// not has 4 bytes will not be accepted. pub fn new(name: &str) -> Self { let root = name.starts_with('\\'); - let offset = root as usize; + let parent = name.starts_with('^'); + let offset = (root || parent) as usize; + let mut name_parts = Vec::new(); for part in name[offset..].split('.') { assert_eq!(part.len(), 4); @@ -160,7 +165,11 @@ impl Path { name_parts.push(name_part); } - Path { root, name_parts } + Path { + root, + parent, + name_parts, + } } } @@ -1995,6 +2004,9 @@ mod tests { (&"\\_SB_".into() as &Path).to_aml_bytes(&mut aml); assert_eq!(aml, [0x5C, 0x5F, 0x53, 0x42, 0x5F]); aml.clear(); + (&"^_SB_".into() as &Path).to_aml_bytes(&mut aml); + assert_eq!(aml, [0x5E, 0x5F, 0x53, 0x42, 0x5F]); + aml.clear(); (&"_SB_.COM1".into() as &Path).to_aml_bytes(&mut aml); assert_eq!(aml, [0x2E, 0x5F, 0x53, 0x42, 0x5F, 0x43, 0x4F, 0x4D, 0x31]); aml.clear();