[SeaBIOS] iasl compiler/disassembler getting confused by Scope operator

Michael S. Tsirkin mst at redhat.com
Mon Oct 7 09:17:30 CEST 2013


I observe the following issue with acpica-tools-20130823-2.fc19.i686:
Compile a file, disassemble it then compile again,
this fails because the Extern directives produced by
disassembler confuse the compiler.

Wiuld be nice if this was fixed disasseble then compile
is a nice sanity-check tool.
Thanks!

--->

Original:


/*
 * Intel ACPI Component Architecture
 * AML Disassembler version 20130823-32 [Aug 28 2013]
 * Copyright (c) 2000 - 2013 Intel Corporation
 * 
 * Disassembly of SSDT, Mon Oct  7 09:48:29 2013
 *
 * Original Table Header:
 *     Signature        "SSDT"
 *     Length           0x00000FE0 (4064)
 *     Revision         0x01
 *     Checksum         0x9F
 *     OEM ID           "BOCHS "
 *     OEM Table ID     "BXPCSSDT"
 *     OEM Revision     0x00000001 (1)
 *     Compiler ID      "BXPC"
 *     Compiler Version 0x00000001 (1)
 */
DefinitionBlock ("SSDT.aml", "SSDT", 1, "BOCHS ", "BXPCSSDT", 0x00000001)
{

    External (_SB_.PCI0, DeviceObj)
    External (_SB_.PCI0.ISA_, DeviceObj)
    External (BNUM, FieldUnitObj)
    External (CPEJ, MethodObj)    // 2 Arguments
    External (CPMA, MethodObj)    // 1 Arguments
    External (CPST, MethodObj)    // 1 Arguments
    External (PCEJ, MethodObj)    // 2 Arguments
    External (PCID, FieldUnitObj)
    External (PCIU, FieldUnitObj)

    Scope (\)
    {
        Name (P0S, 0x80000000)
        Name (P0E, 0xFEBFFFFF)
        Name (P1V, 0x00)
        Name (P1S, Buffer (0x08)
        {
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        })
        Name (P1E, Buffer (0x08)
        {
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        })
        Name (P1L, Buffer (0x08)
        {
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        })
    }

    Scope (\)
    {
        Name (_S3, Package (0x04)  // _S3_: S3 System State
        {
            One, 
            One, 
            Zero, 
            Zero
        })
        Name (_S4, Package (0x04)  // _S4_: S4 System State
        {
            0x02, 
            0x02, 
            Zero, 
            Zero
        })
        Name (_S5, Package (0x04)  // _S5_: S5 System State
        {
            Zero, 
            Zero, 
            Zero, 
            Zero
        })
    }

    Scope (\_SB.PCI0.ISA)
    {
        Device (PEVT)
        {
            Name (_HID, "QEMU0001")  // _HID: Hardware ID
            Name (PEST, 0x0000)
            OperationRegion (PEOR, SystemIO, PEST, One)
            Field (PEOR, ByteAcc, NoLock, Preserve)
            {
                PEPT,   8
            }

            Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                Store (PEST, Local0)
                If (LEqual (Local0, Zero))
                {
                    Return (Zero)
                }
                Else
                {
                    Return (0x0F)
                }
            }

            Method (RDPT, 0, NotSerialized)
            {
                Store (PEPT, Local0)
                Return (Local0)
            }

            Method (WRPT, 1, NotSerialized)
            {
                Store (Arg0, PEPT)
            }

            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                IO (Decode16,
                    0x0000,             // Range Minimum
                    0x0000,             // Range Maximum
                    0x01,               // Alignment
                    0x01,               // Length
                    _Y03)
            })
            CreateWordField (_CRS, \_SB.PCI0.ISA.PEVT._Y03._MIN, IOMN)  // _MIN: Minimum Base Address
            CreateWordField (_CRS, \_SB.PCI0.ISA.PEVT._Y03._MAX, IOMX)  // _MAX: Maximum Base Address
            Method (_INI, 0, NotSerialized)  // _INI: Initialize
            {
                Store (PEST, IOMN)
                Store (PEST, IOMX)
            }
        }
    }

    Scope (_SB)
    {
        Scope (PCI0)
        {
            Name (BSEL, Zero)
            Device (S18)
            {
                Name (_SUN, 0x03)  // _SUN: Slot User Number
                Name (_ADR, 0x00030000)  // _ADR: Address
                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
                {
                    PCEJ (BSEL, _SUN)
                }
            }

            Method (DVNT, 2, NotSerialized)
            {
                If (And (Arg0, 0x08))
                {
                    Notify (S18, Arg1)
                }
            }

            Method (PCNT, 0, NotSerialized)
            {
                Store (Zero, BNUM)
                DVNT (PCIU, One)
                DVNT (PCID, 0x03)
                ^S20.PCNT ()
            }

            Device (S20)
            {
                Name (_SUN, 0x04)  // _SUN: Slot User Number
                Name (_ADR, 0x00040000)  // _ADR: Address
                Name (BSEL, One)
                Method (PCNT, 0, NotSerialized)
                {
                    Store (One, BNUM)
                }
            }
        }
    }
}


---

Compile with iasl foo.dsl

Disassemble with iasl -d -e DSDT SSDT.aml
(see DSDT.dsl at the end of the mail).


/*
 * Intel ACPI Component Architecture
 * AML Disassembler version 20130823-32 [Aug 28 2013]
 * Copyright (c) 2000 - 2013 Intel Corporation
 * 
 * Disassembly of SSDT.aml, Mon Oct  7 10:10:41 2013
 *
 * Original Table Header:
 *     Signature        "SSDT"
 *     Length           0x00000207 (519)
 *     Revision         0x01
 *     Checksum         0xBF
 *     OEM ID           "BOCHS "
 *     OEM Table ID     "BXPCSSDT"
 *     OEM Revision     0x00000001 (1)
 *     Compiler ID      "INTL"
 *     Compiler Version 0x20130823 (538118179)
 */
DefinitionBlock ("SSDT.aml", "SSDT", 1, "BOCHS ", "BXPCSSDT", 0x00000001)
{

    External (_SB_.PCI0.ISA_, DeviceObj)
    External (BNUM, FieldUnitObj)
    External (PCEJ, MethodObj)    // 2 Arguments
    External (PCI0, DeviceObj)
    External (PCID, FieldUnitObj)
    External (PCIU, FieldUnitObj)

    Scope (\)
    {
        Name (P0S, 0x80000000)
        Name (P0E, 0xFEBFFFFF)
        Name (P1V, Zero)
        Name (P1S, Buffer (0x08)
        {
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        })
        Name (P1E, Buffer (0x08)
        {
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        })
        Name (P1L, Buffer (0x08)
        {
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        })
    }

    Scope (\)
    {
        Name (_S3, Package (0x04)  // _S3_: S3 System State
        {
            One, 
            One, 
            Zero, 
            Zero
        })
        Name (_S4, Package (0x04)  // _S4_: S4 System State
        {
            0x02, 
            0x02, 
            Zero, 
            Zero
        })
        Name (_S5, Package (0x04)  // _S5_: S5 System State
        {
            Zero, 
            Zero, 
            Zero, 
            Zero
        })
    }

    Scope (\_SB.PCI0.ISA)
    {
        Device (PEVT)
        {
            Name (_HID, "QEMU0001")  // _HID: Hardware ID
            Name (PEST, Zero)
            OperationRegion (PEOR, SystemIO, PEST, One)
            Field (PEOR, ByteAcc, NoLock, Preserve)
            {
                PEPT,   8
            }

            Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                Store (PEST, Local0)
                If (LEqual (Local0, Zero))
                {
                    Return (Zero)
                }
                Else
                {
                    Return (0x0F)
                }
            }

            Method (RDPT, 0, NotSerialized)
            {
                Store (PEPT, Local0)
                Return (Local0)
            }

            Method (WRPT, 1, NotSerialized)
            {
                Store (Arg0, PEPT)
            }

            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                IO (Decode16,
                    0x0000,             // Range Minimum
                    0x0000,             // Range Maximum
                    0x01,               // Alignment
                    0x01,               // Length
                    _Y00)
            })
            CreateWordField (_CRS, \_SB.PCI0.ISA.PEVT._Y00._MIN, IOMN)  // _MIN: Minimum Base Address
            CreateWordField (_CRS, \_SB.PCI0.ISA.PEVT._Y00._MAX, IOMX)  // _MAX: Maximum Base Address
            Method (_INI, 0, NotSerialized)  // _INI: Initialize
            {
                Store (PEST, IOMN)
                Store (PEST, IOMX)
            }
        }
    }

    Scope (_SB)
    {
        Scope (PCI0)
        {
            Name (BSEL, Zero)
            Device (S18)
            {
                Name (_SUN, 0x03)  // _SUN: Slot User Number
                Name (_ADR, 0x00030000)  // _ADR: Address
                Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
                {
                    PCEJ (BSEL, _SUN)
                }
            }

            Method (DVNT, 2, NotSerialized)
            {
                If (And (Arg0, 0x08))
                {
                    Notify (S18, Arg1)
                }
            }

            Method (PCNT, 0, NotSerialized)
            {
                Store (Zero, BNUM)
                DVNT (PCIU, One)
                DVNT (PCID, 0x03)
                ^S20.PCNT ()
            }

            Device (S20)
            {
                Name (_SUN, 0x04)  // _SUN: Slot User Number
                Name (_ADR, 0x00040000)  // _ADR: Address
                Name (BSEL, One)
                Method (PCNT, 0, NotSerialized)
                {
                    Store (One, BNUM)
                }
            }
        }
    }
}

<----

Compilation error:
Intel ACPI Component Architecture
ASL Optimizing Compiler version 20130823-32 [Aug 28 2013]
Copyright (c) 2000 - 2013 Intel Corporation

SSDT.dsl    130:         Scope (PCI0)
Error    6117 -                   ^ Existing object has invalid type for
Scope operator (PCI0 [Untyped])



If you compane the original and the disassebled result,
you see the issue:


 DefinitionBlock ("SSDT.aml", "SSDT", 1, "BOCHS ", "BXPCSSDT",
0x00000001)
 {
 
-    External (_SB_.PCI0, DeviceObj)
     External (_SB_.PCI0.ISA_, DeviceObj)
     External (BNUM, FieldUnitObj)
     External (CPEJ, MethodObj)    // 2 Arguments
     External (CPMA, MethodObj)    // 1 Arguments
     External (CPST, MethodObj)    // 1 Arguments
     External (PCEJ, MethodObj)    // 2 Arguments
+    External (PCI0, DeviceObj)
     External (PCID, FieldUnitObj)
     External (PCIU, FieldUnitObj)
 

So External (_SB_.PCI0.ISA_, DeviceObj)
implicitly defines PCI0 as an untyped object,
Scope (PCI0) is then taken to refer to that
(since it's in the correct namespace).
Also, External (PCI0, DeviceObj) is produced in the wrong
namespace.


To reproduce you will need a DSDT (for disassembler),
see DSDT.dsl below:


/*
 * Intel ACPI Component Architecture
 * AML Disassembler version 20130823-32 [Aug 28 2013]
 * Copyright (c) 2000 - 2013 Intel Corporation
 * 
 * Disassembly of DSDT, Mon Oct  7 09:58:06 2013
 *
 * Original Table Header:
 *     Signature        "DSDT"
 *     Length           0x00001158 (4440)
 *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
 *     Checksum         0xC6
 *     OEM ID           "BXPC"
 *     OEM Table ID     "BXDSDT"
 *     OEM Revision     0x00000001 (1)
 *     Compiler ID      "INTL"
 *     Compiler Version 0x20130823 (538118179)
 */
DefinitionBlock ("DSDT.aml", "DSDT", 1, "BXPC", "BXDSDT", 0x00000001)
{
    External (_SB_.PCI0.PCNT, MethodObj)
    External (NTFY, MethodObj)

    External (CPON)
    External (P0E_, IntObj)
    External (P0S_, IntObj)
    External (P1E_, IntObj)
    External (P1L_, IntObj)
    External (P1S_, IntObj)
    External (P1V_)

    Scope (\)
    {
        OperationRegion (DBG, SystemIO, 0x0402, One)
        Field (DBG, ByteAcc, NoLock, Preserve)
        {
            DBGB,   8
        }

        Method (DBUG, 1, NotSerialized)
        {
            ToHexString (Arg0, Local0)
            ToBuffer (Local0, Local0)
            Subtract (SizeOf (Local0), One, Local1)
            Store (Zero, Local2)
            While (LLess (Local2, Local1))
            {
                Store (DerefOf (Index (Local0, Local2)), DBGB)
                Increment (Local2)
            }

            Store (0x0A, DBGB)
        }
    }

    Scope (_SB)
    {
        Device (PCI0)
        {
            Name (_HID, EisaId ("PNP0A03"))  // _HID: Hardware ID
            Name (_ADR, Zero)  // _ADR: Address
            Name (_UID, One)  // _UID: Unique ID
        }
    }

    Scope (_SB.PCI0)
    {
        Device (ISA)
        {
            Name (_ADR, 0x00010000)  // _ADR: Address
            OperationRegion (P40C, PCI_Config, 0x60, 0x04)
            Name (FDEN, One)
        }
    }

    Scope (_SB.PCI0)
    {
        OperationRegion (PCST, SystemIO, 0xAE00, 0x08)
        Field (PCST, DWordAcc, NoLock, WriteAsZeros)
        {
            PCIU,   32, 
            PCID,   32
        }

        OperationRegion (SEJ, SystemIO, 0xAE08, 0x04)
        Field (SEJ, DWordAcc, NoLock, WriteAsZeros)
        {
            B0EJ,   32
        }

        OperationRegion (BNMR, SystemIO, 0xAE10, 0x04)
        Field (BNMR, DWordAcc, NoLock, WriteAsZeros)
        {
            BNUM,   32
        }

        Mutex (BLCK, 0x00)
        Method (PCEJ, 2, NotSerialized)
        {
            Acquire (BLCK, 0xFFFF)
            Store (Arg0, BNUM)
            Store (ShiftLeft (One, Arg1), B0EJ)
            Release (BLCK)
            Return (Zero)
        }
    }

    Scope (_GPE)
    {
        Name (_HID, "ACPI0006")  // _HID: Hardware ID
        Method (_L00, 0, NotSerialized)  // _Lxx: Level-Triggered GPE
        {
        }

        Method (_E01, 0, NotSerialized)  // _Exx: Edge-Triggered GPE
        {
            Acquire (\_SB.PCI0.BLCK, 0xFFFF)
            \_SB.PCI0.PCNT ()
            Release (\_SB.PCI0.BLCK)
        }

    }
}





More information about the SeaBIOS mailing list