@@ -1120,13 +1120,14 @@ where
1120
1120
} ;
1121
1121
1122
1122
let result = Arc :: new ( Object :: Integer ( result) ) ;
1123
+ // TODO: use result for arg
1123
1124
self . do_store ( context, target, result. clone ( ) ) ?;
1124
1125
context. contribute_arg ( Argument :: Object ( result) ) ;
1125
1126
Ok ( ( ) )
1126
1127
}
1127
1128
1128
1129
fn do_unary_maths( & self , context: & mut MethodContext , op: OpInFlight ) -> Result <( ) , AmlError > {
1129
- let [ Argument :: Object ( operand) ] = & op. arguments [ ..] else { Err ( AmlError :: InvalidOperationOnObject ) ? } ;
1130
+ let [ Argument :: Object ( operand) ] = & op. arguments [ ..] else { panic ! ( ) } ;
1130
1131
let operand = operand. clone ( ) . unwrap_transparent_reference ( ) . as_integer ( ) ?;
1131
1132
1132
1133
let result = match op. op {
@@ -1137,6 +1138,7 @@ where
1137
1138
/*
1138
1139
* TODO: this is a particular instance where not respecting integers being
1139
1140
* 32-bit on revision 1 tables does cause properly incorrect behaviour...
1141
+ * TODO: we can fix this now we have the DSDT revision
1140
1142
*/
1141
1143
( operand. leading_zeros ( ) + 1 ) as u64
1142
1144
}
@@ -1164,7 +1166,7 @@ where
1164
1166
1165
1167
fn do_logical_op( & self , context: & mut MethodContext , op: OpInFlight ) -> Result <( ) , AmlError > {
1166
1168
if op. op == Opcode :: LNot {
1167
- let [ Argument :: Object ( operand) ] = & op. arguments [ ..] else { Err ( AmlError :: InvalidOperationOnObject ) ? } ;
1169
+ let [ Argument :: Object ( operand) ] = & op. arguments [ ..] else { panic ! ( ) } ;
1168
1170
let operand = operand. clone ( ) . unwrap_transparent_reference ( ) . as_integer ( ) ?;
1169
1171
let result = if operand == 0 { u64:: MAX } else { 0 } ;
1170
1172
@@ -1177,9 +1179,7 @@ where
1177
1179
return Ok ( ( ) ) ;
1178
1180
}
1179
1181
1180
- let [ Argument :: Object ( left) , Argument :: Object ( right) ] = & op. arguments [ ..] else {
1181
- Err ( AmlError :: InvalidOperationOnObject ) ?
1182
- } ;
1182
+ let [ Argument :: Object ( left) , Argument :: Object ( right) ] = & op. arguments [ ..] else { panic ! ( ) } ;
1183
1183
1184
1184
/*
1185
1185
* Some of these operations allow strings and buffers to be used as operands. Apparently
@@ -1220,7 +1220,7 @@ where
1220
1220
} ;
1221
1221
( left, right)
1222
1222
}
1223
- _ => panic ! ( ) ,
1223
+ _ => Err ( AmlError :: InvalidOperationOnObject { op : Operation :: LogicalOp , typ : left . typ ( ) } ) ? ,
1224
1224
} ;
1225
1225
1226
1226
let result = match op. op {
@@ -1268,7 +1268,7 @@ where
1268
1268
Object :: Buffer ( bytes. to_vec ( ) )
1269
1269
}
1270
1270
}
1271
- _ => Err ( AmlError :: InvalidOperationOnObject ) ?,
1271
+ _ => Err ( AmlError :: InvalidOperationOnObject { op : Operation :: Mid , typ : source . typ ( ) } ) ?,
1272
1272
} ) ;
1273
1273
1274
1274
self . do_store ( context, target, result. clone ( ) ) ?;
@@ -1334,7 +1334,7 @@ where
1334
1334
}
1335
1335
1336
1336
fn do_from_bcd( & self , context: & mut MethodContext , op: OpInFlight ) -> Result <( ) , AmlError > {
1337
- let [ Argument :: Object ( value) ] = & op. arguments [ ..] else { Err ( AmlError :: InvalidOperationOnObject ) ? } ;
1337
+ let [ Argument :: Object ( value) ] = & op. arguments [ ..] else { panic ! ( ) } ;
1338
1338
let mut value = value. clone ( ) . unwrap_transparent_reference ( ) . as_integer ( ) ?;
1339
1339
1340
1340
let mut result = 0 ;
@@ -1350,7 +1350,7 @@ where
1350
1350
}
1351
1351
1352
1352
fn do_to_bcd( & self , context: & mut MethodContext , op: OpInFlight ) -> Result <( ) , AmlError > {
1353
- let [ Argument :: Object ( value) ] = & op. arguments [ ..] else { Err ( AmlError :: InvalidOperationOnObject ) ? } ;
1353
+ let [ Argument :: Object ( value) ] = & op. arguments [ ..] else { panic ! ( ) } ;
1354
1354
let mut value = value. clone ( ) . unwrap_transparent_reference ( ) . as_integer ( ) ?;
1355
1355
1356
1356
let mut result = 0 ;
@@ -1366,14 +1366,14 @@ where
1366
1366
}
1367
1367
1368
1368
fn do_size_of( & self , context: & mut MethodContext , op: OpInFlight ) -> Result <( ) , AmlError > {
1369
- let [ Argument :: Object ( object) ] = & op. arguments [ ..] else { Err ( AmlError :: InvalidOperationOnObject ) ? } ;
1369
+ let [ Argument :: Object ( object) ] = & op. arguments [ ..] else { panic ! ( ) } ;
1370
1370
let object = object. clone ( ) . unwrap_reference ( ) ;
1371
1371
1372
1372
let result = match * object {
1373
1373
Object :: Buffer ( ref buffer) => buffer. len ( ) ,
1374
1374
Object :: String ( ref str) => str. len ( ) ,
1375
1375
Object :: Package ( ref package) => package. len ( ) ,
1376
- _ => Err ( AmlError :: InvalidOperationOnObject ) ?,
1376
+ _ => Err ( AmlError :: InvalidOperationOnObject { op : Operation :: SizeOf , typ : object . typ ( ) } ) ?,
1377
1377
} ;
1378
1378
1379
1379
context. contribute_arg ( Argument :: Object ( Arc :: new ( Object :: Integer ( result as u64 ) ) ) ) ;
@@ -2171,6 +2171,21 @@ enum Opcode {
2171
2171
InternalMethodCall ,
2172
2172
}
2173
2173
2174
+ #[ derive( Clone , Copy , PartialEq , Debug ) ]
2175
+ pub enum Operation {
2176
+ Mid ,
2177
+ SizeOf ,
2178
+ Acquire ,
2179
+ Release ,
2180
+ ConvertToBuffer ,
2181
+
2182
+ ReadBufferField ,
2183
+ WriteBufferField ,
2184
+ LogicalOp ,
2185
+ DecodePrt ,
2186
+ ParseResource ,
2187
+ }
2188
+
2174
2189
/*
2175
2190
* TODO: not sure if we should use a better error reporting system or just keep a giant enum?
2176
2191
*/
@@ -2197,7 +2212,7 @@ pub enum AmlError {
2197
2212
2198
2213
MethodArgCountIncorrect ,
2199
2214
2200
- InvalidOperationOnObject ,
2215
+ InvalidOperationOnObject { op : Operation , typ : ObjectType } ,
2201
2216
IndexOutOfBounds ,
2202
2217
ObjectNotOfExpectedType { expected : ObjectType , got : ObjectType } ,
2203
2218
0 commit comments