Skip to content

Commit aa02318

Browse files
committed
aml: rename invoke_method to evaluate
1 parent 387ddbb commit aa02318

File tree

3 files changed

+23
-31
lines changed

3 files changed

+23
-31
lines changed

src/aml/mod.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,9 @@ where
130130
Ok(())
131131
}
132132

133-
/// Invoke a method by its name, with the given set of arguments. If the referenced object is
134-
/// not a method, the object will instead be returned - this is useful for objects that can
135-
/// either be defined directly, or through a method (e.g. a `_CRS` object).
136-
pub fn invoke_method(&self, path: AmlName, args: Vec<WrappedObject>) -> Result<WrappedObject, AmlError> {
133+
/// Evaluate an object at the given path in the namespace. If the object is a method, this
134+
/// invokes the method with the given set of arguments.
135+
pub fn evaluate(&self, path: AmlName, args: Vec<WrappedObject>) -> Result<WrappedObject, AmlError> {
137136
trace!("Invoking AML method: {}", path);
138137

139138
let object = self.namespace.lock().get(path.clone())?.clone();
@@ -147,12 +146,12 @@ where
147146
}
148147
}
149148

150-
pub fn invoke_method_if_present(
149+
pub fn evaluate_if_present(
151150
&self,
152151
path: AmlName,
153152
args: Vec<WrappedObject>,
154153
) -> Result<Option<WrappedObject>, AmlError> {
155-
match self.invoke_method(path.clone(), args) {
154+
match self.evaluate(path.clone(), args) {
156155
Ok(result) => Ok(Some(result)),
157156
Err(AmlError::ObjectDoesNotExist(not_present)) => {
158157
if path == not_present {
@@ -181,10 +180,10 @@ where
181180
/*
182181
* This should match the initialization order of ACPICA and uACPI.
183182
*/
184-
if let Err(err) = self.invoke_method_if_present(AmlName::from_str("\\_INI").unwrap(), vec![]) {
183+
if let Err(err) = self.evaluate(AmlName::from_str("\\_INI").unwrap(), vec![]) {
185184
warn!("Invoking \\_INI failed: {:?}", err);
186185
}
187-
if let Err(err) = self.invoke_method_if_present(AmlName::from_str("\\_SB._INI").unwrap(), vec![]) {
186+
if let Err(err) = self.evaluate(AmlName::from_str("\\_SB._INI").unwrap(), vec![]) {
188187
warn!("Invoking \\_SB._INI failed: {:?}", err);
189188
}
190189

@@ -214,7 +213,7 @@ where
214213
| NamespaceLevelKind::ThermalZone
215214
| NamespaceLevelKind::PowerResource => {
216215
let should_initialize = match self
217-
.invoke_method_if_present(AmlName::from_str("_STA").unwrap().resolve(path)?, vec![])
216+
.evaluate_if_present(AmlName::from_str("_STA").unwrap().resolve(path)?, vec![])
218217
{
219218
Ok(Some(result)) => {
220219
let Object::Integer(result) = *result else { panic!() };
@@ -230,8 +229,8 @@ where
230229

231230
if should_initialize {
232231
num_devices_initialized += 1;
233-
if let Err(err) = self
234-
.invoke_method_if_present(AmlName::from_str("_INI").unwrap().resolve(path)?, vec![])
232+
if let Err(err) =
233+
self.evaluate_if_present(AmlName::from_str("_INI").unwrap().resolve(path)?, vec![])
235234
{
236235
warn!("Failed to evaluate _INI for device {}: {:?}", path, err);
237236
}
@@ -1367,10 +1366,14 @@ where
13671366
field_offset += length;
13681367
}
13691368
ACCESS_FIELD => {
1370-
let access_type = context.next()?;
1371-
let access_attrib = context.next()?;
1369+
/*
1370+
* These aren't actually fields themselves, but are created by `AccessAs` AML
1371+
* elements. They change the access type and attributes for remaining fields in
1372+
* the list.
1373+
*/
1374+
let _access_type = context.next()?;
1375+
let _access_attrib = context.next()?;
13721376
todo!()
1373-
// TODO
13741377
}
13751378
CONNECT_FIELD => {
13761379
// TODO: either consume a namestring or `BufferData` (it's not
@@ -2256,16 +2259,16 @@ where
22562259
* TODO: it's not ideal to do these reads for every native access. See if we can
22572260
* cache them somewhere?
22582261
*/
2259-
let seg = match self.invoke_method_if_present(AmlName::from_str("_SEG").unwrap().resolve(path)?, vec![])? {
2262+
let seg = match self.evaluate_if_present(AmlName::from_str("_SEG").unwrap().resolve(path)?, vec![])? {
22602263
Some(value) => value.as_integer()?,
22612264
None => 0,
22622265
};
2263-
let bus = match self.invoke_method_if_present(AmlName::from_str("_BBR").unwrap().resolve(path)?, vec![])? {
2266+
let bus = match self.evaluate_if_present(AmlName::from_str("_BBR").unwrap().resolve(path)?, vec![])? {
22642267
Some(value) => value.as_integer()?,
22652268
None => 0,
22662269
};
22672270
let (device, function) = {
2268-
let adr = self.invoke_method_if_present(AmlName::from_str("_ADR").unwrap().resolve(path)?, vec![])?;
2271+
let adr = self.evaluate_if_present(AmlName::from_str("_ADR").unwrap().resolve(path)?, vec![])?;
22692272
let adr = match adr {
22702273
Some(adr) => adr.as_integer()?,
22712274
None => 0,

src/aml/pci_routing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl PciRoutingTable {
6464
) -> Result<PciRoutingTable, AmlError> {
6565
let mut entries = Vec::new();
6666

67-
let prt = interpreter.invoke_method(prt_path.clone(), vec![])?;
67+
let prt = interpreter.evaluate(prt_path.clone(), vec![])?;
6868

6969
if let Object::Package(ref inner_values) = *prt {
7070
for value in inner_values {
@@ -177,7 +177,7 @@ impl PciRoutingTable {
177177
}),
178178
PciRouteType::LinkObject(ref name) => {
179179
let path = AmlName::from_str("_CRS").unwrap().resolve(name)?;
180-
let link_crs = interpreter.invoke_method(path, vec![])?;
180+
let link_crs = interpreter.evaluate(path, vec![])?;
181181

182182
let resources = resource::resource_descriptor_list(link_crs)?;
183183
match resources.as_slice() {

tools/aml_tester/src/main.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,7 @@ fn main() -> std::io::Result<()> {
216216

217217
fn run_test(stream: &[u8], interpreter: &mut Interpreter<Handler>) -> Result<(), AmlError> {
218218
interpreter.load_table(stream)?;
219-
220-
match interpreter.invoke_method(AmlName::from_str("\\MAIN").unwrap(), vec![]) {
221-
Ok(_) => Ok(()),
222-
Err(AmlError::ObjectDoesNotExist(name)) => {
223-
if name == AmlName::from_str("\\MAIN").unwrap() {
224-
Ok(())
225-
} else {
226-
Err(AmlError::ObjectDoesNotExist(name))
227-
}
228-
}
229-
Err(other) => Err(other),
230-
}
219+
interpreter.evaluate_if_present(AmlName::from_str("\\MAIN").unwrap(), vec![])
231220
}
232221

233222
fn find_tests(matches: &clap::ArgMatches) -> std::io::Result<Vec<PathBuf>> {

0 commit comments

Comments
 (0)