Print this page
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 - 2013, 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 %p Attempted physical table override failed",
      319 +                TableHeader->Signature,
      320 +                ACPI_CAST_PTR (void, TableDesc->Address)));
      321 +            return (NULL);
      322 +        }
      323 +
      324 +        OverrideType = "Physical";
      325 +        NewFlags = ACPI_TABLE_ORIGIN_MAPPED;
      326 +        goto FinishOverride;
      327 +    }
      328 +
      329 +    return (NULL); /* There was no override */
      330 +
      331 +
      332 +FinishOverride:
      333 +
      334 +    ACPI_INFO ((AE_INFO,
      335 +        "%4.4s %p %s table override, new table: %p",
      336 +        TableHeader->Signature,
      337 +        ACPI_CAST_PTR (void, TableDesc->Address),
      338 +        OverrideType, NewTable));
      339 +
      340 +    /* We can now unmap/delete the original table (if fully mapped) */
      341 +
      342 +    AcpiTbDeleteTable (TableDesc);
      343 +
      344 +    /* Setup descriptor for the new table */
      345 +
      346 +    TableDesc->Address = NewAddress;
      347 +    TableDesc->Pointer = NewTable;
      348 +    TableDesc->Length = NewTableLength;
      349 +    TableDesc->Flags = NewFlags;
      350 +
      351 +    return (NewTable);
      352 +}
      353 +
      354 +
      355 +/*******************************************************************************
      356 + *
 286  357   * FUNCTION:    AcpiTbResizeRootTableList
 287  358   *
 288  359   * PARAMETERS:  None
 289  360   *
 290  361   * RETURN:      Status
 291  362   *
 292  363   * DESCRIPTION: Expand the size of global table array
 293  364   *
 294  365   ******************************************************************************/
 295  366  
 296  367  ACPI_STATUS
 297  368  AcpiTbResizeRootTableList (
 298  369      void)
 299  370  {
 300  371      ACPI_TABLE_DESC         *Tables;
      372 +    UINT32                  TableCount;
 301  373  
 302  374  
 303  375      ACPI_FUNCTION_TRACE (TbResizeRootTableList);
 304  376  
 305  377  
 306  378      /* AllowResize flag is a parameter to AcpiInitializeTables */
 307  379  
 308  380      if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
 309  381      {
 310  382          ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
 311  383          return_ACPI_STATUS (AE_SUPPORT);
 312  384      }
 313  385  
 314  386      /* Increase the Table Array size */
 315  387  
      388 +    if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
      389 +    {
      390 +        TableCount = AcpiGbl_RootTableList.MaxTableCount;
      391 +    }
      392 +    else
      393 +    {
      394 +        TableCount = AcpiGbl_RootTableList.CurrentTableCount;
      395 +    }
      396 +
 316  397      Tables = ACPI_ALLOCATE_ZEROED (
 317      -        ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount +
 318      -            ACPI_ROOT_TABLE_SIZE_INCREMENT) *
      398 +        ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) *
 319  399          sizeof (ACPI_TABLE_DESC));
 320  400      if (!Tables)
 321  401      {
 322  402          ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
 323  403          return_ACPI_STATUS (AE_NO_MEMORY);
 324  404      }
 325  405  
 326  406      /* Copy and free the previous table array */
 327  407  
 328  408      if (AcpiGbl_RootTableList.Tables)
 329  409      {
 330  410          ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
 331      -            (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC));
      411 +            (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC));
 332  412  
 333  413          if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
 334  414          {
 335  415              ACPI_FREE (AcpiGbl_RootTableList.Tables);
 336  416          }
 337  417      }
 338  418  
 339  419      AcpiGbl_RootTableList.Tables = Tables;
 340      -    AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT;
 341      -    AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;
      420 +    AcpiGbl_RootTableList.MaxTableCount =
      421 +        TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
      422 +    AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
 342  423  
 343  424      return_ACPI_STATUS (AE_OK);
 344  425  }
 345  426  
 346  427  
 347  428  /*******************************************************************************
 348  429   *
 349  430   * FUNCTION:    AcpiTbStoreTable
 350  431   *
 351  432   * PARAMETERS:  Address             - Table address
↓ open down ↓ 69 lines elided ↑ open up ↑
 421  502      /* Table must be mapped or allocated */
 422  503  
 423  504      if (!TableDesc->Pointer)
 424  505      {
 425  506          return;
 426  507      }
 427  508  
 428  509      switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
 429  510      {
 430  511      case ACPI_TABLE_ORIGIN_MAPPED:
      512 +
 431  513          AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
 432  514          break;
 433  515  
 434  516      case ACPI_TABLE_ORIGIN_ALLOCATED:
      517 +
 435  518          ACPI_FREE (TableDesc->Pointer);
 436  519          break;
 437  520  
      521 +    /* Not mapped or allocated, there is nothing we can do */
      522 +
 438  523      default:
 439      -        break;
      524 +
      525 +        return;
 440  526      }
 441  527  
 442  528      TableDesc->Pointer = NULL;
 443  529  }
 444  530  
 445  531  
 446  532  /*******************************************************************************
 447  533   *
 448  534   * FUNCTION:    AcpiTbTerminate
 449  535   *
↓ open down ↓ 32 lines elided ↑ open up ↑
 482  568      {
 483  569          ACPI_FREE (AcpiGbl_RootTableList.Tables);
 484  570      }
 485  571  
 486  572      AcpiGbl_RootTableList.Tables = NULL;
 487  573      AcpiGbl_RootTableList.Flags = 0;
 488  574      AcpiGbl_RootTableList.CurrentTableCount = 0;
 489  575  
 490  576      ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
 491  577      (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
      578 +
      579 +    return_VOID;
 492  580  }
 493  581  
 494  582  
 495  583  /*******************************************************************************
 496  584   *
 497  585   * FUNCTION:    AcpiTbDeleteNamespaceByOwner
 498  586   *
 499  587   * PARAMETERS:  TableIndex          - Table index
 500  588   *
 501  589   * RETURN:      Status
↓ open down ↓ 219 lines elided ↑ open up ↑
 721  809          }
 722  810          else
 723  811          {
 724  812              AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
 725  813                  ~ACPI_TABLE_IS_LOADED;
 726  814          }
 727  815      }
 728  816  
 729  817      (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
 730  818  }
 731      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX