Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/tables/tbinstal.c
          +++ new/usr/src/common/acpica/components/tables/tbinstal.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: tbinstal - ACPI table installation and removal
   4    4   *
   5    5   *****************************************************************************/
   6    6  
   7    7  /*
   8      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2014, Intel Corp.
   9    9   * All rights reserved.
  10   10   *
  11   11   * Redistribution and use in source and binary forms, with or without
  12   12   * modification, are permitted provided that the following conditions
  13   13   * are met:
  14   14   * 1. Redistributions of source code must retain the above copyright
  15   15   *    notice, this list of conditions, and the following disclaimer,
  16   16   *    without modification.
  17   17   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18   18   *    substantially similar to the "NO WARRANTY" disclaimer below
↓ open down ↓ 67 lines elided ↑ open up ↑
  86   86              TableDesc->Pointer = AcpiOsMapMemory (
  87   87                  TableDesc->Address, TableDesc->Length);
  88   88          }
  89   89  
  90   90          if (!TableDesc->Pointer)
  91   91          {
  92   92              return_ACPI_STATUS (AE_NO_MEMORY);
  93   93          }
  94   94      }
  95   95  
  96      -    /* FACS is the odd table, has no standard ACPI header and no checksum */
       96 +    /* Always calculate checksum, ignore bad checksum if requested */
  97   97  
  98      -    if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
  99      -    {
 100      -        /* Always calculate checksum, ignore bad checksum if requested */
       98 +    Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
 101   99  
 102      -        Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
 103      -    }
 104      -
 105  100      return_ACPI_STATUS (Status);
 106  101  }
 107  102  
 108  103  
 109  104  /*******************************************************************************
 110  105   *
 111  106   * FUNCTION:    AcpiTbAddTable
 112  107   *
 113  108   * PARAMETERS:  TableDesc           - Table descriptor
 114  109   *              TableIndex          - Where the table index is returned
↓ open down ↓ 6 lines elided ↑ open up ↑
 121  116   *
 122  117   ******************************************************************************/
 123  118  
 124  119  ACPI_STATUS
 125  120  AcpiTbAddTable (
 126  121      ACPI_TABLE_DESC         *TableDesc,
 127  122      UINT32                  *TableIndex)
 128  123  {
 129  124      UINT32                  i;
 130  125      ACPI_STATUS             Status = AE_OK;
 131      -    ACPI_TABLE_HEADER       *OverrideTable = NULL;
 132  126  
 133  127  
 134  128      ACPI_FUNCTION_TRACE (TbAddTable);
 135  129  
 136  130  
 137  131      if (!TableDesc->Pointer)
 138  132      {
 139  133          Status = AcpiTbVerifyTable (TableDesc);
 140  134          if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
 141  135          {
↓ open down ↓ 9 lines elided ↑ open up ↑
 151  145       * 3) Valid tables were encountered with a null signature, so we just
 152  146       *    gave up on validating the signature, (05/2008).
 153  147       * 4) We encountered non-AML tables such as the MADT, which caused
 154  148       *    interpreter errors and kernel faults. So now, we once again allow
 155  149       *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
 156  150       */
 157  151      if ((TableDesc->Pointer->Signature[0] != 0x00) &&
 158  152         (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) &&
 159  153         (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3)))
 160  154      {
 161      -        ACPI_ERROR ((AE_INFO,
 162      -            "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx",
 163      -            AcpiUtValidAcpiName (*(UINT32 *) TableDesc->Pointer->Signature) ?
      155 +        ACPI_BIOS_ERROR ((AE_INFO,
      156 +            "Table has invalid signature [%4.4s] (0x%8.8X), "
      157 +            "must be SSDT or OEMx",
      158 +            AcpiUtValidAcpiName (TableDesc->Pointer->Signature) ?
 164  159                  TableDesc->Pointer->Signature : "????",
 165  160              *(UINT32 *) TableDesc->Pointer->Signature));
 166  161  
 167  162          return_ACPI_STATUS (AE_BAD_SIGNATURE);
 168  163      }
 169  164  
 170  165      (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
 171  166  
 172  167      /* Check if table is already registered */
 173  168  
↓ open down ↓ 61 lines elided ↑ open up ↑
 235  230              TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
 236  231              TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
 237  232              Status = AE_OK;
 238  233              goto PrintHeader;
 239  234          }
 240  235      }
 241  236  
 242  237      /*
 243  238       * ACPI Table Override:
 244  239       * Allow the host to override dynamically loaded tables.
      240 +     * NOTE: the table is fully mapped at this point, and the mapping will
      241 +     * be deleted by TbTableOverride if the table is actually overridden.
 245  242       */
 246      -    Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable);
 247      -    if (ACPI_SUCCESS (Status) && OverrideTable)
 248      -    {
 249      -        ACPI_INFO ((AE_INFO,
 250      -            "%4.4s @ 0x%p Table override, replaced with:",
 251      -            TableDesc->Pointer->Signature,
 252      -            ACPI_CAST_PTR (void, TableDesc->Address)));
      243 +    (void) AcpiTbTableOverride (TableDesc->Pointer, TableDesc);
 253  244  
 254      -        /* We can delete the table that was passed as a parameter */
 255      -
 256      -        AcpiTbDeleteTable (TableDesc);
 257      -
 258      -        /* Setup descriptor for the new table */
 259      -
 260      -        TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable);
 261      -        TableDesc->Pointer = OverrideTable;
 262      -        TableDesc->Length = OverrideTable->Length;
 263      -        TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE;
 264      -    }
 265      -
 266  245      /* Add the table to the global root table list */
 267  246  
 268  247      Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
 269  248                  TableDesc->Length, TableDesc->Flags, TableIndex);
 270  249      if (ACPI_FAILURE (Status))
 271  250      {
 272  251          goto Release;
 273  252      }
 274  253  
 275  254  PrintHeader:
 276  255      AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
 277  256  
 278  257  Release:
 279  258      (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
 280  259      return_ACPI_STATUS (Status);
 281  260  }
 282  261  
 283  262  
 284  263  /*******************************************************************************
 285  264   *
      265 + * FUNCTION:    AcpiTbTableOverride
      266 + *
      267 + * PARAMETERS:  TableHeader         - Header for the original table
      268 + *              TableDesc           - Table descriptor initialized for the
      269 + *                                    original table. May or may not be mapped.
      270 + *
      271 + * RETURN:      Pointer to the entire new table. NULL if table not overridden.
      272 + *              If overridden, installs the new table within the input table
      273 + *              descriptor.
      274 + *
      275 + * DESCRIPTION: Attempt table override by calling the OSL override functions.
      276 + *              Note: If the table is overridden, then the entire new table
      277 + *              is mapped and returned by this function.
      278 + *
      279 + ******************************************************************************/
      280 +
      281 +ACPI_TABLE_HEADER *
      282 +AcpiTbTableOverride (
      283 +    ACPI_TABLE_HEADER       *TableHeader,
      284 +    ACPI_TABLE_DESC         *TableDesc)
      285 +{
      286 +    ACPI_STATUS             Status;
      287 +    ACPI_TABLE_HEADER       *NewTable = NULL;
      288 +    ACPI_PHYSICAL_ADDRESS   NewAddress = 0;
      289 +    UINT32                  NewTableLength = 0;
      290 +    UINT8                   NewFlags;
      291 +    char                    *OverrideType;
      292 +
      293 +
      294 +    /* (1) Attempt logical override (returns a logical address) */
      295 +
      296 +    Status = AcpiOsTableOverride (TableHeader, &NewTable);
      297 +    if (ACPI_SUCCESS (Status) && NewTable)
      298 +    {
      299 +        NewAddress = ACPI_PTR_TO_PHYSADDR (NewTable);
      300 +        NewTableLength = NewTable->Length;
      301 +        NewFlags = ACPI_TABLE_ORIGIN_OVERRIDE;
      302 +        OverrideType = "Logical";
      303 +        goto FinishOverride;
      304 +    }
      305 +
      306 +    /* (2) Attempt physical override (returns a physical address) */
      307 +
      308 +    Status = AcpiOsPhysicalTableOverride (TableHeader,
      309 +        &NewAddress, &NewTableLength);
      310 +    if (ACPI_SUCCESS (Status) && NewAddress && NewTableLength)
      311 +    {
      312 +        /* Map the entire new table */
      313 +
      314 +        NewTable = AcpiOsMapMemory (NewAddress, NewTableLength);
      315 +        if (!NewTable)
      316 +        {
      317 +            ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY,
      318 +                "%4.4s " ACPI_PRINTF_UINT
      319 +                " Attempted physical table override failed",
      320 +                TableHeader->Signature,
      321 +                ACPI_FORMAT_TO_UINT (TableDesc->Address)));
      322 +            return (NULL);
      323 +        }
      324 +
      325 +        OverrideType = "Physical";
      326 +        NewFlags = ACPI_TABLE_ORIGIN_MAPPED;
      327 +        goto FinishOverride;
      328 +    }
      329 +
      330 +    return (NULL); /* There was no override */
      331 +
      332 +
      333 +FinishOverride:
      334 +
      335 +    ACPI_INFO ((AE_INFO, "%4.4s " ACPI_PRINTF_UINT
      336 +        " %s table override, new table: " ACPI_PRINTF_UINT,
      337 +        TableHeader->Signature,
      338 +        ACPI_FORMAT_TO_UINT (TableDesc->Address),
      339 +        OverrideType, ACPI_FORMAT_TO_UINT (NewTable)));
      340 +
      341 +    /* We can now unmap/delete the original table (if fully mapped) */
      342 +
      343 +    AcpiTbDeleteTable (TableDesc);
      344 +
      345 +    /* Setup descriptor for the new table */
      346 +
      347 +    TableDesc->Address = NewAddress;
      348 +    TableDesc->Pointer = NewTable;
      349 +    TableDesc->Length = NewTableLength;
      350 +    TableDesc->Flags = NewFlags;
      351 +
      352 +    return (NewTable);
      353 +}
      354 +
      355 +
      356 +/*******************************************************************************
      357 + *
 286  358   * FUNCTION:    AcpiTbResizeRootTableList
 287  359   *
 288  360   * PARAMETERS:  None
 289  361   *
 290  362   * RETURN:      Status
 291  363   *
 292  364   * DESCRIPTION: Expand the size of global table array
 293  365   *
 294  366   ******************************************************************************/
 295  367  
 296  368  ACPI_STATUS
 297  369  AcpiTbResizeRootTableList (
 298  370      void)
 299  371  {
 300  372      ACPI_TABLE_DESC         *Tables;
      373 +    UINT32                  TableCount;
 301  374  
 302  375  
 303  376      ACPI_FUNCTION_TRACE (TbResizeRootTableList);
 304  377  
 305  378  
 306  379      /* AllowResize flag is a parameter to AcpiInitializeTables */
 307  380  
 308  381      if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
 309  382      {
 310  383          ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
 311  384          return_ACPI_STATUS (AE_SUPPORT);
 312  385      }
 313  386  
 314  387      /* Increase the Table Array size */
 315  388  
      389 +    if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
      390 +    {
      391 +        TableCount = AcpiGbl_RootTableList.MaxTableCount;
      392 +    }
      393 +    else
      394 +    {
      395 +        TableCount = AcpiGbl_RootTableList.CurrentTableCount;
      396 +    }
      397 +
 316  398      Tables = ACPI_ALLOCATE_ZEROED (
 317      -        ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount +
 318      -            ACPI_ROOT_TABLE_SIZE_INCREMENT) *
      399 +        ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) *
 319  400          sizeof (ACPI_TABLE_DESC));
 320  401      if (!Tables)
 321  402      {
 322  403          ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
 323  404          return_ACPI_STATUS (AE_NO_MEMORY);
 324  405      }
 325  406  
 326  407      /* Copy and free the previous table array */
 327  408  
 328  409      if (AcpiGbl_RootTableList.Tables)
 329  410      {
 330  411          ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
 331      -            (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC));
      412 +            (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC));
 332  413  
 333  414          if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
 334  415          {
 335  416              ACPI_FREE (AcpiGbl_RootTableList.Tables);
 336  417          }
 337  418      }
 338  419  
 339  420      AcpiGbl_RootTableList.Tables = Tables;
 340      -    AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT;
 341      -    AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;
      421 +    AcpiGbl_RootTableList.MaxTableCount =
      422 +        TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
      423 +    AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
 342  424  
 343  425      return_ACPI_STATUS (AE_OK);
 344  426  }
 345  427  
 346  428  
 347  429  /*******************************************************************************
 348  430   *
 349  431   * FUNCTION:    AcpiTbStoreTable
 350  432   *
 351  433   * PARAMETERS:  Address             - Table address
↓ open down ↓ 69 lines elided ↑ open up ↑
 421  503      /* Table must be mapped or allocated */
 422  504  
 423  505      if (!TableDesc->Pointer)
 424  506      {
 425  507          return;
 426  508      }
 427  509  
 428  510      switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
 429  511      {
 430  512      case ACPI_TABLE_ORIGIN_MAPPED:
      513 +
 431  514          AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
 432  515          break;
 433  516  
 434  517      case ACPI_TABLE_ORIGIN_ALLOCATED:
      518 +
 435  519          ACPI_FREE (TableDesc->Pointer);
 436  520          break;
 437  521  
      522 +    /* Not mapped or allocated, there is nothing we can do */
      523 +
 438  524      default:
 439      -        break;
      525 +
      526 +        return;
 440  527      }
 441  528  
 442  529      TableDesc->Pointer = NULL;
 443  530  }
 444  531  
 445  532  
 446  533  /*******************************************************************************
 447  534   *
 448  535   * FUNCTION:    AcpiTbTerminate
 449  536   *
↓ open down ↓ 32 lines elided ↑ open up ↑
 482  569      {
 483  570          ACPI_FREE (AcpiGbl_RootTableList.Tables);
 484  571      }
 485  572  
 486  573      AcpiGbl_RootTableList.Tables = NULL;
 487  574      AcpiGbl_RootTableList.Flags = 0;
 488  575      AcpiGbl_RootTableList.CurrentTableCount = 0;
 489  576  
 490  577      ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
 491  578      (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
      579 +
      580 +    return_VOID;
 492  581  }
 493  582  
 494  583  
 495  584  /*******************************************************************************
 496  585   *
 497  586   * FUNCTION:    AcpiTbDeleteNamespaceByOwner
 498  587   *
 499  588   * PARAMETERS:  TableIndex          - Table index
 500  589   *
 501  590   * RETURN:      Status
↓ open down ↓ 219 lines elided ↑ open up ↑
 721  810          }
 722  811          else
 723  812          {
 724  813              AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
 725  814                  ~ACPI_TABLE_IS_LOADED;
 726  815          }
 727  816      }
 728  817  
 729  818      (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
 730  819  }
 731      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX