|
@@ -97,9 +97,9 @@ impl Namespace {
|
|
|
}
|
|
|
|
|
|
/// Search for an object at the given path of the namespace, applying the search rules
|
|
|
- /// described in §5.3 of the ACPI specification, if they are applicable. Returns the handle of
|
|
|
- /// the first valid object, if found.
|
|
|
- pub fn search(&self, path: &AmlName, starting_scope: &AmlName) -> Result<AmlHandle, AmlError> {
|
|
|
+ /// described in §5.3 of the ACPI specification, if they are applicable. Returns the resolved name, and the
|
|
|
+ /// handle of the first valid object, if found.
|
|
|
+ pub fn search(&self, path: &AmlName, starting_scope: &AmlName) -> Result<(AmlName, AmlHandle), AmlError> {
|
|
|
if path.search_rules_apply() {
|
|
|
/*
|
|
|
* If search rules apply, we need to recursively look through the namespace. If the
|
|
@@ -110,8 +110,9 @@ impl Namespace {
|
|
|
assert!(scope.is_absolute());
|
|
|
loop {
|
|
|
// Search for the name at this namespace level. If we find it, we're done.
|
|
|
- if let Some(handle) = self.name_map.get(&path.resolve(&scope)?) {
|
|
|
- return Ok(*handle);
|
|
|
+ let name = path.resolve(&scope)?;
|
|
|
+ if let Some(handle) = self.name_map.get(&name) {
|
|
|
+ return Ok((name, *handle));
|
|
|
}
|
|
|
|
|
|
// If we don't find it, go up a level in the namespace and search for it there,
|
|
@@ -119,18 +120,20 @@ impl Namespace {
|
|
|
match scope.parent() {
|
|
|
Ok(parent) => scope = parent,
|
|
|
// If we still haven't found the value and have run out of parents, return `None`.
|
|
|
- Err(AmlError::RootHasNoParent) => {
|
|
|
- return Err(AmlError::ObjectDoesNotExist(path.as_string()))
|
|
|
- }
|
|
|
+ Err(AmlError::RootHasNoParent) => return Err(AmlError::ObjectDoesNotExist(path.as_string())),
|
|
|
Err(err) => return Err(err),
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
// If search rules don't apply, simply resolve it against the starting scope
|
|
|
- self.name_map
|
|
|
- .get(&path.resolve(starting_scope)?)
|
|
|
- .map(|&handle| handle)
|
|
|
- .ok_or(AmlError::ObjectDoesNotExist(path.as_string()))
|
|
|
+ let name = path.resolve(starting_scope)?;
|
|
|
+ Ok((
|
|
|
+ name,
|
|
|
+ self.name_map
|
|
|
+ .get(&path.resolve(starting_scope)?)
|
|
|
+ .map(|&handle| handle)
|
|
|
+ .ok_or(AmlError::ObjectDoesNotExist(path.as_string()))?,
|
|
|
+ ))
|
|
|
}
|
|
|
}
|
|
|
}
|