Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve displaying AML code using fmt::Display and Added more AML parsing #114

Merged
merged 14 commits into from
Jul 16, 2024

Conversation

Amjad50
Copy link
Owner

@Amjad50 Amjad50 commented Jul 14, 2024

Summary

I copied parts of how DebugStruct is implemented in the std library in rust. Because we needed to have some kind of recursive structure.

And also added parsing for ResourceTemplate macros, and other structs

Related issue

None, it was just to make AML better

Changes

  • Improve printing of AML code using fmt::Display, design inspired (copied) from DebugStruct in rust std
  • Fix parsing of flags field in FieldDef and IndexFieldDef
  • Improve parsing for OperationRegion
  • Improve parsing for Method and added the flags it uses and so on
  • Added parsing for ResourceTemplate macros, most are available except Connection descriptors
  • Fixed Device being printed as Scope

Checklist

  • The changes are tested and works as expected (mention if not)
  • Tests if applicable (new features, regression tests, etc...)
    (created Add more tests for AML/ASL #115 for this 😄, too lazy to add it here)
  • Documentation
  • Needed README changes (no need)

I copied parts of how `DebugStruct` is implemented in the `std` library
in rust. Because we needed to have some kind of recursive structure.

Due to us not having access to internal methods of `Formatter`, we
needed to use another way.

There is also another part of this commit.
We fixed the parsing of `FieldDef` and `IndexFieldDef` and parsed the
`flags` field. It was a bit annoying to separate that so I included it
here in this PR.

There are a lot more to improve on this, but this will make printing the
data much much easier instead of worrying about `depth` and other items.
The current method as mentioned in the TODO is not good and
we need to rewrite this and move to pure execution method to build
the label lookup tree
Parsed the argument denoting the operation space
Didn't add newlines after each field definition
We want to also support identifying `Buffer` macros, these are macros in
ASL that would generate Buffer, since we are dealing with AML directly,
we have them compiled to Buffers, and we don't know what the source code
actually contained. We can reverse the process, but we need to identify
the macro used based on context with other elements.
Parsed all types of elements supported even though we didn't need to for
some of them since the vm I'm using doesn't have `Connection` field.
I wasn't testing on this form, so I didn't notice the error
Return
Acquire printing the hex value correctly
Package number (this is very important as it was misleading
We are now storing which of them it is, since they are
in essence just the same, we use the same struct to represent them
These are macros available in ASL that describe resources,
and are compiled into Buffers in AML, so we are trying to bring them
back into ASL because its meant to be read that way.

This is part of the implementation, this thing is large and there are
several types, so splitting it is good
Added parsing for `AddressSpace` resources, now the missing part is the
connection resources, which will come later
@Amjad50 Amjad50 changed the title Improve displaying AML code using fmt::Display Improve displaying AML code using fmt::Display and Added more AML parsing Jul 16, 2024
Not much change really, but not sure what else to add.
Not sure if it would be good to go into more details.
Used 4 tab size, and fixed all the remaining issues with display
@Amjad50 Amjad50 merged commit b4aa087 into master Jul 16, 2024
4 checks passed
@Amjad50 Amjad50 deleted the aml_display branch July 16, 2024 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant