From 53298c039d42403df2756c35b36295bff9a86af0 Mon Sep 17 00:00:00 2001 From: Victor Ding Date: Wed, 17 Aug 2022 15:58:59 +0000 Subject: [PATCH] aml: Update OpRegion to take Aml as offset and length ACPI Machine Language (AML) Specification defines both RegionOffset and RegionLen as Term. BUG=b:194390621 TEST=tools/presubmit Change-Id: Ib9d09fab3069566e9fc84c823b6d9f644ac975a0 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3845277 Tested-by: Victor Ding Reviewed-by: Daniel Verkamp Commit-Queue: Victor Ding Auto-Submit: Victor Ding --- acpi_tables/src/aml.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/acpi_tables/src/aml.rs b/acpi_tables/src/aml.rs index 6365d22a49..fe05cc9ded 100644 --- a/acpi_tables/src/aml.rs +++ b/acpi_tables/src/aml.rs @@ -884,16 +884,16 @@ pub enum OpRegionSpace { } /// OperationRegion object with region name, region space type, its offset and length. -pub struct OpRegion { +pub struct OpRegion<'a> { path: Path, space: OpRegionSpace, - offset: usize, - length: usize, + offset: &'a dyn Aml, + length: &'a dyn Aml, } -impl OpRegion { +impl<'a> OpRegion<'a> { /// Create OperationRegion object. - pub fn new(path: Path, space: OpRegionSpace, offset: usize, length: usize) -> Self { + pub fn new(path: Path, space: OpRegionSpace, offset: &'a dyn Aml, length: &'a dyn Aml) -> Self { OpRegion { path, space, @@ -903,7 +903,7 @@ impl OpRegion { } } -impl Aml for OpRegion { +impl<'a> Aml for OpRegion<'a> { fn to_aml_bytes(&self, aml: &mut Vec) { let mut bytes = Vec::new(); self.path.to_aml_bytes(&mut bytes); @@ -1829,7 +1829,13 @@ mod tests { ]; let mut aml = Vec::new(); - OpRegion::new("PRST".into(), OpRegionSpace::SystemIO, 0xcd8, 0xc).to_aml_bytes(&mut aml); + OpRegion::new( + "PRST".into(), + OpRegionSpace::SystemIO, + &0xcd8_usize, + &0xc_usize, + ) + .to_aml_bytes(&mut aml); assert_eq!(aml, &op_region_data[..]); }