|
@@ -77,14 +77,7 @@ where
|
|
|
*/
|
|
|
comment_scope_verbose(
|
|
|
"NamedObj",
|
|
|
- choice!(
|
|
|
- def_op_region(),
|
|
|
- def_field(),
|
|
|
- def_method(),
|
|
|
- def_device(),
|
|
|
- def_processor(),
|
|
|
- def_mutex()
|
|
|
- ),
|
|
|
+ choice!(def_op_region(), def_field(), def_method(), def_device(), def_processor(), def_mutex()),
|
|
|
)
|
|
|
}
|
|
|
|
|
@@ -98,12 +91,10 @@ where
|
|
|
opcode(opcode::DEF_NAME_OP)
|
|
|
.then(comment_scope(
|
|
|
"DefName",
|
|
|
- name_string().then(data_ref_object()).map_with_context(
|
|
|
- |(name, data_ref_object), context| {
|
|
|
- context.add_to_namespace(name, AmlValue::Name(box data_ref_object));
|
|
|
- (Ok(()), context)
|
|
|
- },
|
|
|
- ),
|
|
|
+ name_string().then(data_ref_object()).map_with_context(|(name, data_ref_object), context| {
|
|
|
+ context.add_to_namespace(name, AmlValue::Name(box data_ref_object));
|
|
|
+ (Ok(()), context)
|
|
|
+ }),
|
|
|
))
|
|
|
.discard_result()
|
|
|
}
|
|
@@ -204,32 +195,25 @@ where
|
|
|
ext_opcode(opcode::EXT_DEF_FIELD_OP)
|
|
|
.then(comment_scope(
|
|
|
"DefField",
|
|
|
- pkg_length().then(name_string()).then(take()).feed(
|
|
|
- |((list_length, region_name), flags)| {
|
|
|
- move |mut input: &'a [u8],
|
|
|
- mut context: &'c mut AmlContext|
|
|
|
- -> ParseResult<'a, 'c, ()> {
|
|
|
- /*
|
|
|
- * FieldList := Nothing | <FieldElement FieldList>
|
|
|
- */
|
|
|
- // TODO: can this pattern be expressed as a combinator
|
|
|
- let mut current_offset = 0;
|
|
|
- while list_length.still_parsing(input) {
|
|
|
- let (new_input, new_context, field_length) = field_element(
|
|
|
- region_name.clone(),
|
|
|
- FieldFlags::new(flags),
|
|
|
- current_offset,
|
|
|
- )
|
|
|
- .parse(input, context)?;
|
|
|
- input = new_input;
|
|
|
- context = new_context;
|
|
|
- current_offset += field_length;
|
|
|
- }
|
|
|
-
|
|
|
- Ok((input, context, ()))
|
|
|
+ pkg_length().then(name_string()).then(take()).feed(|((list_length, region_name), flags)| {
|
|
|
+ move |mut input: &'a [u8], mut context: &'c mut AmlContext| -> ParseResult<'a, 'c, ()> {
|
|
|
+ /*
|
|
|
+ * FieldList := Nothing | <FieldElement FieldList>
|
|
|
+ */
|
|
|
+ // TODO: can this pattern be expressed as a combinator
|
|
|
+ let mut current_offset = 0;
|
|
|
+ while list_length.still_parsing(input) {
|
|
|
+ let (new_input, new_context, field_length) =
|
|
|
+ field_element(region_name.clone(), FieldFlags::new(flags), current_offset)
|
|
|
+ .parse(input, context)?;
|
|
|
+ input = new_input;
|
|
|
+ context = new_context;
|
|
|
+ current_offset += field_length;
|
|
|
}
|
|
|
- },
|
|
|
- ),
|
|
|
+
|
|
|
+ Ok((input, context, ()))
|
|
|
+ }
|
|
|
+ }),
|
|
|
))
|
|
|
.discard_result()
|
|
|
}
|
|
@@ -266,9 +250,8 @@ where
|
|
|
* Reserved fields shouldn't actually be added to the namespace; they seem to show gaps in
|
|
|
* the operation region that aren't used for anything.
|
|
|
*/
|
|
|
- let reserved_field = opcode(opcode::RESERVED_FIELD)
|
|
|
- .then(pkg_length())
|
|
|
- .map(|((), length)| Ok(length.raw_length as u64));
|
|
|
+ let reserved_field =
|
|
|
+ opcode(opcode::RESERVED_FIELD).then(pkg_length()).map(|((), length)| Ok(length.raw_length as u64));
|
|
|
|
|
|
// TODO: work out what to do with an access field
|
|
|
// let access_field = opcode(opcode::ACCESS_FIELD)
|
|
@@ -276,20 +259,19 @@ where
|
|
|
// .then(take())
|
|
|
// .map_with_context(|(((), access_type), access_attrib), context| (Ok( , context));
|
|
|
|
|
|
- let named_field =
|
|
|
- name_seg().then(pkg_length()).map_with_context(move |(name_seg, length), context| {
|
|
|
- context.add_to_namespace(
|
|
|
- AmlName::from_name_seg(name_seg),
|
|
|
- AmlValue::Field {
|
|
|
- region: region_name.clone(),
|
|
|
- flags,
|
|
|
- offset: current_offset,
|
|
|
- length: length.raw_length as u64,
|
|
|
- },
|
|
|
- );
|
|
|
+ let named_field = name_seg().then(pkg_length()).map_with_context(move |(name_seg, length), context| {
|
|
|
+ context.add_to_namespace(
|
|
|
+ AmlName::from_name_seg(name_seg),
|
|
|
+ AmlValue::Field {
|
|
|
+ region: region_name.clone(),
|
|
|
+ flags,
|
|
|
+ offset: current_offset,
|
|
|
+ length: length.raw_length as u64,
|
|
|
+ },
|
|
|
+ );
|
|
|
|
|
|
- (Ok(length.raw_length as u64), context)
|
|
|
- });
|
|
|
+ (Ok(length.raw_length as u64), context)
|
|
|
+ });
|
|
|
|
|
|
choice!(reserved_field, named_field)
|
|
|
}
|
|
@@ -311,8 +293,7 @@ where
|
|
|
.then(name_string())
|
|
|
.then(take())
|
|
|
.feed(|((length, name), flags)| {
|
|
|
- take_to_end_of_pkglength(length)
|
|
|
- .map(move |code| Ok((name.clone(), flags, code)))
|
|
|
+ take_to_end_of_pkglength(length).map(move |code| Ok((name.clone(), flags, code)))
|
|
|
})
|
|
|
.map_with_context(|(name, flags, code), context| {
|
|
|
context.add_to_namespace(
|
|
@@ -345,9 +326,7 @@ where
|
|
|
|
|
|
(Ok((length, previous_scope)), context)
|
|
|
})
|
|
|
- .feed(|(length, previous_scope)| {
|
|
|
- term_list(length).map(move |_| Ok(previous_scope.clone()))
|
|
|
- })
|
|
|
+ .feed(|(length, previous_scope)| term_list(length).map(move |_| Ok(previous_scope.clone())))
|
|
|
.map_with_context(|previous_scope, context| {
|
|
|
context.current_scope = previous_scope;
|
|
|
(Ok(()), context)
|
|
@@ -375,12 +354,10 @@ where
|
|
|
.then(take_u32())
|
|
|
.then(take())
|
|
|
.feed(|((((pkg_length, name), proc_id), pblk_address), pblk_len)| {
|
|
|
- term_list(pkg_length)
|
|
|
- .map(move |_| Ok((name.clone(), proc_id, pblk_address, pblk_len)))
|
|
|
+ term_list(pkg_length).map(move |_| Ok((name.clone(), proc_id, pblk_address, pblk_len)))
|
|
|
})
|
|
|
.map_with_context(|(name, id, pblk_address, pblk_len), context| {
|
|
|
- context
|
|
|
- .add_to_namespace(name, AmlValue::Processor { id, pblk_address, pblk_len });
|
|
|
+ context.add_to_namespace(name, AmlValue::Processor { id, pblk_address, pblk_len });
|
|
|
(Ok(()), context)
|
|
|
}),
|
|
|
))
|
|
@@ -448,8 +425,7 @@ where
|
|
|
let mut package_contents = Vec::new();
|
|
|
|
|
|
while pkg_length.still_parsing(input) {
|
|
|
- let (new_input, new_context, value) =
|
|
|
- package_element().parse(input, context)?;
|
|
|
+ let (new_input, new_context, value) = package_element().parse(input, context)?;
|
|
|
input = new_input;
|
|
|
context = new_context;
|
|
|
|
|
@@ -545,12 +521,12 @@ where
|
|
|
opcode::BYTE_CONST => {
|
|
|
take().map(|value| Ok(AmlValue::Integer(value as u64))).parse(new_input, context)
|
|
|
}
|
|
|
- opcode::WORD_CONST => take_u16()
|
|
|
- .map(|value| Ok(AmlValue::Integer(value as u64)))
|
|
|
- .parse(new_input, context),
|
|
|
- opcode::DWORD_CONST => take_u32()
|
|
|
- .map(|value| Ok(AmlValue::Integer(value as u64)))
|
|
|
- .parse(new_input, context),
|
|
|
+ opcode::WORD_CONST => {
|
|
|
+ take_u16().map(|value| Ok(AmlValue::Integer(value as u64))).parse(new_input, context)
|
|
|
+ }
|
|
|
+ opcode::DWORD_CONST => {
|
|
|
+ take_u32().map(|value| Ok(AmlValue::Integer(value as u64))).parse(new_input, context)
|
|
|
+ }
|
|
|
opcode::QWORD_CONST => {
|
|
|
take_u64().map(|value| Ok(AmlValue::Integer(value))).parse(new_input, context)
|
|
|
}
|
|
@@ -624,8 +600,7 @@ mod test {
|
|
|
&[0x28]
|
|
|
);
|
|
|
check_ok!(
|
|
|
- computational_data()
|
|
|
- .parse(&[0x0d, b'A', b'B', b'C', b'D', b'\0', 0xff, 0xf5], &mut context),
|
|
|
+ computational_data().parse(&[0x0d, b'A', b'B', b'C', b'D', b'\0', 0xff, 0xf5], &mut context),
|
|
|
AmlValue::String(String::from("ABCD")),
|
|
|
&[0xff, 0xf5]
|
|
|
);
|