AML, forward references?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

AML, forward references?

Post by Gigasoft »

The Bochs emulator provides a DSDT where a name (LNKD) is referenced by a package before it is defined. There is no way to know in advance what the name will refer to, so what am I to make of this? Is this even legal AML?

To illustrate the problem, suppose you have the following definition block. If it is legal, what does it do and what will be stored in \AAAA\DDDD? If not, where is the error?

Code: Select all

Device (AAAA) {
    Name (BBBB, Package(1) {CCCC})
    If (LEqual(ObjectType(Index(BBBB, 0)), 1)) {
        Device(CCCC) {
        }
        Name(DDDD, 0)
    } Else {
        Name(DDDD, 1)
    }
}
Name (CCCC, 1234)
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: AML, forward references?

Post by bzt »

Gigasoft wrote:Is this even legal AML?
Looks like it. I've found this patch from 2016, which says:
With old support, it appears to be the forward referencing in the arguments of the above opcodes is supported by the ACPICA interpreter, while the investigation result shows that Windows doesn't support the forward referencing even in the arguments.
(Again, this is from 2016)

I guess you'll have to parse the AML code more than once, using a multiple-pass parser. First collect the references (or prototypes), then in the second pass the definitions. That's how all compilers work that support forward-referencing languages.

Cheers,
bzt
Post Reply