Pārlūkot izejas kodu

Start untangling behaviour of stores

I don't think we've got this very right at all, and I have no idea what
we thought we were doing before really. This definitely needs some tests
to actually test it's doing the right thing eventually, but this is
definitely an improvement for now I think. We still need to work out how
to do args and locals properly (probably first by moving them to using
arrays... like wtf), and then implementing stores to buffer fields.
Isaac Woods 3 gadi atpakaļ
vecāks
revīzija
701f0033b1
2 mainītis faili ar 18 papildinājumiem un 11 dzēšanām
  1. 16 11
      aml/src/lib.rs
  2. 2 0
      tests/buffer_fields.asl

+ 16 - 11
aml/src/lib.rs

@@ -337,21 +337,22 @@ impl AmlContext {
         match target {
             Target::Name(ref path) => {
                 let (_, handle) = self.namespace.search(path, &self.current_scope)?;
-                let converted_object = match self.namespace.get(handle).unwrap().type_of() {
-                    /*
-                     * We special-case FieldUnits here because we don't have the needed information to actually do
-                     * the write if we try and convert using `as_type`.
-                     */
+
+                match self.namespace.get(handle).unwrap().type_of() {
                     AmlType::FieldUnit => {
                         let mut field = self.namespace.get(handle).unwrap().clone();
                         field.write_field(value, self)?;
-                        field.read_field(self)?
+                        field.read_field(self)
                     }
-                    typ => value.as_type(typ, self)?,
-                };
-
-                *self.namespace.get_mut(handle)? = converted_object;
-                Ok(self.namespace.get(handle)?.clone())
+                    AmlType::BufferField => {
+                        log::info!("Trying to write to buffer field!");
+                        todo!()
+                    }
+                    typ => {
+                        *self.namespace.get_mut(handle)? = value.as_type(typ, self)?;
+                        Ok(self.namespace.get(handle)?.clone())
+                    }
+                }
             }
 
             Target::Debug => {
@@ -364,6 +365,8 @@ impl AmlContext {
                     return Err(AmlError::NotExecutingControlMethod);
                 }
 
+                // TODO: I don't think these semantics are correct? If the arg/local is a field unit or buffer
+                // field, don't we need to do special stuff?
                 match arg_num {
                     1 => self.method_context.as_mut().unwrap().args.arg_1 = Some(value.clone()),
                     2 => self.method_context.as_mut().unwrap().args.arg_2 = Some(value.clone()),
@@ -381,6 +384,8 @@ impl AmlContext {
                     return Err(AmlError::NotExecutingControlMethod);
                 }
 
+                // TODO: I don't think these semantics are correct? If the arg/local is a field unit or buffer
+                // field, don't we need to do special stuff?
                 match local_num {
                     0 => self.method_context.as_mut().unwrap().local_0 = Some(value.clone()),
                     1 => self.method_context.as_mut().unwrap().local_1 = Some(value.clone()),

+ 2 - 0
tests/buffer_fields.asl

@@ -6,4 +6,6 @@ DefinitionBlock("buffer_fields.aml", "DSDT", 1, "RSACPI", "BUFFLD", 1) {
 	CreateWordField(X, 2, WORD)
 	CreateDWordField(X, 4, DWRD)
 	CreateQWordField(X, 8, QWRD)
+
+	BIT3 = 1
 }