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

AML: Implement CondRefOf #141

Open
rw-vanc opened this issue Jan 27, 2023 · 4 comments
Open

AML: Implement CondRefOf #141

rw-vanc opened this issue Jan 27, 2023 · 4 comments

Comments

@rw-vanc
Copy link
Contributor

rw-vanc commented Jan 27, 2023

On HP-dq3xxx, the following asl/aml occurs:
If (CondRefOf (PU2C))
5B 12 50 55 32 43 00

@rw-vanc
Copy link
Contributor Author

rw-vanc commented Jan 27, 2023

Which file should cond_ref_of be implemented in? ref_of is also not implemented.

@IsaacWoods
Copy link
Member

Yep, again not supported yet. The opcodes aren't handled mainly because the machinery for refs isn't there yet - but shouldn't be too hard to build out.

They are expression opcodes, so should be in expression.rs.

@rw-vanc
Copy link
Contributor Author

rw-vanc commented Mar 1, 2023

This is an example from the uefi spec

Store (DeRefOf (Index (DeRefOf (Index (IO0D, 0)), 5)), Local0)

What do suggest for the representation of these things in the AML parser?

@IsaacWoods
Copy link
Member

IsaacWoods commented Mar 3, 2023

Store (DeRefOf (Index (DeRefOf (Index (IO0D, 0)), 5)), Local0)

Hm yeah this is about as complex as these expressions will get afaik, but ofc we'll need to support them fully eventually so might as well now. Basically, I think we need to introduce a new value type (Reference) that stores how to access a value in the namespace (e.g. for Index, it's the 5th thing in IO0D, where that object can be a buffer, string, or package). Of course, this representation will need to be dynamic (i.e. probably end up as some boxed enums or something) to deal with arbitrary cases like your example.

I was originally dreading dealing with these because I thought that references could appear in all sorts of places (i.e. instead of regular objects, and you'd have to deal with implicitly dereferencing them), but it doesn't actually look that way! I think AML requires you to manually use DeRefOf when you want to "resolve" a reference into a real object, and so this should be handled by taking the given reference and running the resolution logic (e.g. look up the object from the namespace (or a local or whatever), and doing the actual index into it to get the current value of the referenced object).

CondRefOf is slightly more complex in that it needs to gracefully handle the referenced object not actually existing, but that shouldn't be too much worse.

So overall this doesn't actually sound too bad. Some existing types (maybe Target) might be useful. This is just my thoughts in the last 10 mins of thinking and reading the spec so don't take it as scripture, but hopefully that's helpful, and feel free to reach out with any questions and I'll get to them when I can.

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

No branches or pull requests

2 participants