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/hardware/hwregs.c
          +++ new/usr/src/common/acpica/components/hardware/hwregs.c
   1      -
   2    1  /*******************************************************************************
   3    2   *
   4    3   * Module Name: hwregs - Read/write access functions for the various ACPI
   5    4   *                       control and status registers.
   6    5   *
   7    6   ******************************************************************************/
   8    7  
   9    8  /*
  10      - * Copyright (C) 2000 - 2011, Intel Corp.
        9 + * Copyright (C) 2000 - 2014, Intel Corp.
  11   10   * All rights reserved.
  12   11   *
  13   12   * Redistribution and use in source and binary forms, with or without
  14   13   * modification, are permitted provided that the following conditions
  15   14   * are met:
  16   15   * 1. Redistributions of source code must retain the above copyright
  17   16   *    notice, this list of conditions, and the following disclaimer,
  18   17   *    without modification.
  19   18   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  20   19   *    substantially similar to the "NO WARRANTY" disclaimer below
↓ open down ↓ 25 lines elided ↑ open up ↑
  46   45  #define __HWREGS_C__
  47   46  
  48   47  #include "acpi.h"
  49   48  #include "accommon.h"
  50   49  #include "acevents.h"
  51   50  
  52   51  #define _COMPONENT          ACPI_HARDWARE
  53   52          ACPI_MODULE_NAME    ("hwregs")
  54   53  
  55   54  
       55 +#if (!ACPI_REDUCED_HARDWARE)
       56 +
  56   57  /* Local Prototypes */
  57   58  
  58   59  static ACPI_STATUS
  59   60  AcpiHwReadMultiple (
  60   61      UINT32                  *Value,
  61   62      ACPI_GENERIC_ADDRESS    *RegisterA,
  62   63      ACPI_GENERIC_ADDRESS    *RegisterB);
  63   64  
  64   65  static ACPI_STATUS
  65   66  AcpiHwWriteMultiple (
  66   67      UINT32                  Value,
  67   68      ACPI_GENERIC_ADDRESS    *RegisterA,
  68   69      ACPI_GENERIC_ADDRESS    *RegisterB);
  69   70  
       71 +#endif /* !ACPI_REDUCED_HARDWARE */
  70   72  
  71   73  /******************************************************************************
  72   74   *
  73   75   * FUNCTION:    AcpiHwValidateRegister
  74   76   *
  75   77   * PARAMETERS:  Reg                 - GAS register structure
  76   78   *              MaxBitWidth         - Max BitWidth supported (32 or 64)
  77   79   *              Address             - Pointer to where the gas->address
  78   80   *                                    is returned
  79   81   *
↓ open down ↓ 83 lines elided ↑ open up ↑
 163  165   *          not been a need to implement these.
 164  166   *
 165  167   ******************************************************************************/
 166  168  
 167  169  ACPI_STATUS
 168  170  AcpiHwRead (
 169  171      UINT32                  *Value,
 170  172      ACPI_GENERIC_ADDRESS    *Reg)
 171  173  {
 172  174      UINT64                  Address;
      175 +    UINT64                  Value64;
 173  176      ACPI_STATUS             Status;
 174  177  
 175  178  
 176  179      ACPI_FUNCTION_NAME (HwRead);
 177  180  
 178  181  
 179  182      /* Validate contents of the GAS register */
 180  183  
 181  184      Status = AcpiHwValidateRegister (Reg, 32, &Address);
 182  185      if (ACPI_FAILURE (Status))
↓ open down ↓ 5 lines elided ↑ open up ↑
 188  191  
 189  192      *Value = 0;
 190  193  
 191  194      /*
 192  195       * Two address spaces supported: Memory or IO. PCI_Config is
 193  196       * not supported here because the GAS structure is insufficient
 194  197       */
 195  198      if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
 196  199      {
 197  200          Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
 198      -                    Address, Value, Reg->BitWidth);
      201 +                    Address, &Value64, Reg->BitWidth);
      202 +
      203 +        *Value = (UINT32) Value64;
 199  204      }
 200  205      else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
 201  206      {
 202  207          Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
 203  208                      Address, Value, Reg->BitWidth);
 204  209      }
 205  210  
 206  211      ACPI_DEBUG_PRINT ((ACPI_DB_IO,
 207  212          "Read:  %8.8X width %2d from %8.8X%8.8X (%s)\n",
 208  213          *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
↓ open down ↓ 38 lines elided ↑ open up ↑
 247  252          return (Status);
 248  253      }
 249  254  
 250  255      /*
 251  256       * Two address spaces supported: Memory or IO. PCI_Config is
 252  257       * not supported here because the GAS structure is insufficient
 253  258       */
 254  259      if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
 255  260      {
 256  261          Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
 257      -                    Address, Value, Reg->BitWidth);
      262 +                    Address, (UINT64) Value, Reg->BitWidth);
 258  263      }
 259  264      else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
 260  265      {
 261  266          Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
 262  267                      Address, Value, Reg->BitWidth);
 263  268      }
 264  269  
 265  270      ACPI_DEBUG_PRINT ((ACPI_DB_IO,
 266  271          "Wrote: %8.8X width %2d   to %8.8X%8.8X (%s)\n",
 267  272          Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
 268  273          AcpiUtGetRegionName (Reg->SpaceId)));
 269  274  
 270  275      return (Status);
 271  276  }
 272  277  
 273  278  
      279 +#if (!ACPI_REDUCED_HARDWARE)
 274  280  /*******************************************************************************
 275  281   *
 276  282   * FUNCTION:    AcpiHwClearAcpiStatus
 277  283   *
 278  284   * PARAMETERS:  None
 279  285   *
 280  286   * RETURN:      Status
 281  287   *
 282  288   * DESCRIPTION: Clears all fixed and general purpose status bits
 283  289   *
↓ open down ↓ 30 lines elided ↑ open up ↑
 314  320      Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
 315  321  
 316  322  UnlockAndExit:
 317  323      AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
 318  324      return_ACPI_STATUS (Status);
 319  325  }
 320  326  
 321  327  
 322  328  /*******************************************************************************
 323  329   *
 324      - * FUNCTION:    AcpiHwGetRegisterBitMask
      330 + * FUNCTION:    AcpiHwGetBitRegisterInfo
 325  331   *
 326  332   * PARAMETERS:  RegisterId          - Index of ACPI Register to access
 327  333   *
 328  334   * RETURN:      The bitmask to be used when accessing the register
 329  335   *
 330  336   * DESCRIPTION: Map RegisterId into a register bitmask.
 331  337   *
 332  338   ******************************************************************************/
 333  339  
 334  340  ACPI_BIT_REGISTER_INFO *
↓ open down ↓ 82 lines elided ↑ open up ↑
 417  423  
 418  424      switch (RegisterId)
 419  425      {
 420  426      case ACPI_REGISTER_PM1_STATUS:           /* PM1 A/B: 16-bit access each */
 421  427  
 422  428          Status = AcpiHwReadMultiple (&Value,
 423  429                      &AcpiGbl_XPm1aStatus,
 424  430                      &AcpiGbl_XPm1bStatus);
 425  431          break;
 426  432  
 427      -
 428  433      case ACPI_REGISTER_PM1_ENABLE:           /* PM1 A/B: 16-bit access each */
 429  434  
 430  435          Status = AcpiHwReadMultiple (&Value,
 431  436                      &AcpiGbl_XPm1aEnable,
 432  437                      &AcpiGbl_XPm1bEnable);
 433  438          break;
 434  439  
 435      -
 436  440      case ACPI_REGISTER_PM1_CONTROL:          /* PM1 A/B: 16-bit access each */
 437  441  
 438  442          Status = AcpiHwReadMultiple (&Value,
 439  443                      &AcpiGbl_FADT.XPm1aControlBlock,
 440  444                      &AcpiGbl_FADT.XPm1bControlBlock);
 441  445  
 442  446          /*
 443  447           * Zero the write-only bits. From the ACPI specification, "Hardware
 444  448           * Write-Only Bits": "Upon reads to registers with write-only bits,
 445  449           * software masks out all write-only bits."
 446  450           */
 447  451          Value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS;
 448  452          break;
 449  453  
 450      -
 451  454      case ACPI_REGISTER_PM2_CONTROL:          /* 8-bit access */
 452  455  
 453  456          Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock);
 454  457          break;
 455  458  
 456      -
 457  459      case ACPI_REGISTER_PM_TIMER:             /* 32-bit access */
 458  460  
 459  461          Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock);
 460  462          break;
 461  463  
 462      -
 463  464      case ACPI_REGISTER_SMI_COMMAND_BLOCK:    /* 8-bit access */
 464  465  
 465  466          Status = AcpiHwReadPort (AcpiGbl_FADT.SmiCommand, &Value, 8);
 466  467          break;
 467  468  
 468      -
 469  469      default:
      470 +
 470  471          ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X",
 471  472              RegisterId));
 472  473          Status = AE_BAD_PARAMETER;
 473  474          break;
 474  475      }
 475  476  
 476  477      if (ACPI_SUCCESS (Status))
 477  478      {
 478  479          *ReturnValue = Value;
 479  480      }
↓ open down ↓ 53 lines elided ↑ open up ↑
 533  534           *
 534  535           * This behavior is clarified in the ACPI 4.0 specification.
 535  536           */
 536  537          Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS;
 537  538  
 538  539          Status = AcpiHwWriteMultiple (Value,
 539  540                      &AcpiGbl_XPm1aStatus,
 540  541                      &AcpiGbl_XPm1bStatus);
 541  542          break;
 542  543  
 543      -
 544  544      case ACPI_REGISTER_PM1_ENABLE:           /* PM1 A/B: 16-bit access each */
 545  545  
 546  546          Status = AcpiHwWriteMultiple (Value,
 547  547                      &AcpiGbl_XPm1aEnable,
 548  548                      &AcpiGbl_XPm1bEnable);
 549  549          break;
 550  550  
 551      -
 552  551      case ACPI_REGISTER_PM1_CONTROL:          /* PM1 A/B: 16-bit access each */
 553      -
 554  552          /*
 555  553           * Perform a read first to preserve certain bits (per ACPI spec)
 556  554           * Note: This includes SCI_EN, we never want to change this bit
 557  555           */
 558  556          Status = AcpiHwReadMultiple (&ReadValue,
 559  557                      &AcpiGbl_FADT.XPm1aControlBlock,
 560  558                      &AcpiGbl_FADT.XPm1bControlBlock);
 561  559          if (ACPI_FAILURE (Status))
 562  560          {
 563  561              goto Exit;
↓ open down ↓ 3 lines elided ↑ open up ↑
 567  565  
 568  566          ACPI_INSERT_BITS (Value, ACPI_PM1_CONTROL_PRESERVED_BITS, ReadValue);
 569  567  
 570  568          /* Now we can write the data */
 571  569  
 572  570          Status = AcpiHwWriteMultiple (Value,
 573  571                      &AcpiGbl_FADT.XPm1aControlBlock,
 574  572                      &AcpiGbl_FADT.XPm1bControlBlock);
 575  573          break;
 576  574  
 577      -
 578  575      case ACPI_REGISTER_PM2_CONTROL:          /* 8-bit access */
 579      -
 580  576          /*
 581  577           * For control registers, all reserved bits must be preserved,
 582  578           * as per the ACPI spec.
 583  579           */
 584  580          Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock);
 585  581          if (ACPI_FAILURE (Status))
 586  582          {
 587  583              goto Exit;
 588  584          }
 589  585  
 590  586          /* Insert the bits to be preserved */
 591  587  
 592  588          ACPI_INSERT_BITS (Value, ACPI_PM2_CONTROL_PRESERVED_BITS, ReadValue);
 593  589  
 594  590          Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock);
 595  591          break;
 596  592  
 597      -
 598  593      case ACPI_REGISTER_PM_TIMER:             /* 32-bit access */
 599  594  
 600  595          Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock);
 601  596          break;
 602  597  
 603      -
 604  598      case ACPI_REGISTER_SMI_COMMAND_BLOCK:    /* 8-bit access */
 605  599  
 606  600          /* SMI_CMD is currently always in IO space */
 607  601  
 608  602          Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, Value, 8);
 609  603          break;
 610  604  
 611      -
 612  605      default:
      606 +
 613  607          ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X",
 614  608              RegisterId));
 615  609          Status = AE_BAD_PARAMETER;
 616  610          break;
 617  611      }
 618  612  
 619  613  Exit:
 620  614      return_ACPI_STATUS (Status);
 621  615  }
 622  616  
↓ open down ↓ 101 lines elided ↑ open up ↑
 724  718       * and writes have no side effects"
 725  719       */
 726  720      if (RegisterB->Address)
 727  721      {
 728  722          Status = AcpiHwWrite (Value, RegisterB);
 729  723      }
 730  724  
 731  725      return (Status);
 732  726  }
 733  727  
      728 +#endif /* !ACPI_REDUCED_HARDWARE */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX