• Erik Schmauss's avatar
    ACPICA: Remove legacy module-level code support · aa342261
    Erik Schmauss authored
    ACPICA commit 47f5607c204719d9239a12b889df725225098c8f
    
    Module-level code refers to executable ASL code that runs during
    table load. This is typically used in ASL to declare named objects
    based on a condition evaluated during table load like so:
    
    definition_block(...)
    {
      opreation_region (OPR1, system_memory, ...)
      Field (OPR1)
      {
        FLD1, 8 /* Assume that FLD1's value is 0x1 */
      }
    
      /* The if statement below is referred to as module-level code */
    
      If (FLD1)
      {
        /* Declare DEV1 conditionally */
        Device (DEV1) {...}
      }
    
      Device (DEV2)
      {
        ...
      }
    }
    
    In legacy module-level code, the execution of the If statement
    was deferred after other modules were loaded. The order of
    code execution for the table above is the following:
    
    1.) Load OPR1 to the ACPI Namespace
    2.) Load FLD1 to the ACPI Namespace (not intended for drivers)
    3.) Load DEV2 to the ACPI Namespace
    4.) Execute If (FLD1) and load DEV1 if the condition is true
    
    This legacy approach can be problematic for tables that look like the
    following:
    
    definition_block(...)
    {
      opreation_region (OPR1, system_memory, ...)
      Field (OPR1)
      {
        FLD1, 8 /* Assume that FLD1's value is 0x1 */
      }
    
      /* The if statement below is referred to as module-level code */
    
      If (FLD1)
      {
        /* Declare DEV1 conditionally */
        Device (DEV1) {...}
      }
    
      Scope (DEV1)
      {
        /* Add objects DEV1's scope */
        Name (OBJ1, 0x1234)
      }
    }
    
    When loading this in the legacy approach, Scope DEV1 gets evaluated
    before the If statement. The following is the order of execution:
    
    1.) Load OPR1 to the ACPI Namespace
    2.) Load FLD1 to the ACPI Namespace (not intended for drivers)
    3.) Add OBJ1 under DEV1's scope -- ERROR. DEV1 does not exist
    4.) Execute If (FLD1) and load DEV1 if the condition is true
    
    The legacy approach can never succeed for tables like this due to the
    deferral of the module-level code. Due to this limitation, a new
    module-level code was developed. This new approach exeutes if
    statements in the order that they appear in the definition block.
    With this approach, the order of execution for the above defintion
    block is as follows:
    
    1.) Load OPR1 to the ACPI Namespace
    2.) Load FLD1 to the ACPI Namespace (not intended for drivers)
    3.) Execute If (FLD1) and load DEV1 because the condition is true
    4.) Add OBJ1 under DEV1's scope.
    
    Since DEV1 is loaded in the namespace in step 3, step 4 executes
    successfully.
    
    This change removes support for the legacy module-level code
    execution. From this point onward, the new module-level code
    execution will be the official approach.
    
    Link: https://github.com/acpica/acpica/commit/47f5607cSigned-off-by: default avatarErik Schmauss <erik.schmauss@intel.com>
    Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    aa342261
acpixf.h 30.2 KB